MCPcopy Create free account
hub / github.com/F-Stack/f-stack / mvneta_eth_dev_create

Function mvneta_eth_dev_create

dpdk/drivers/net/mvneta/mvneta_ethdev.c:810–858  ·  view source on GitHub ↗

* Create device representing Ethernet port. * * @param name * Pointer to the port's name. * * @return * 0 on success, negative error value otherwise. */

Source from the content-addressed store, hash-verified

808 * 0 on success, negative error value otherwise.
809 */
810static int
811mvneta_eth_dev_create(struct rte_vdev_device *vdev, const char *name)
812{
813 int ret, fd = socket(AF_INET, SOCK_DGRAM, 0);
814 struct rte_eth_dev *eth_dev;
815 struct mvneta_priv *priv;
816 struct ifreq req;
817
818 eth_dev = rte_eth_dev_allocate(name);
819 if (!eth_dev)
820 return -ENOMEM;
821
822 priv = rte_zmalloc_socket(name, sizeof(*priv), 0, rte_socket_id());
823 if (!priv) {
824 ret = -ENOMEM;
825 goto out_free;
826 }
827 eth_dev->data->dev_private = priv;
828
829 eth_dev->data->mac_addrs =
830 rte_zmalloc("mac_addrs",
831 RTE_ETHER_ADDR_LEN * MVNETA_MAC_ADDRS_MAX, 0);
832 if (!eth_dev->data->mac_addrs) {
833 MVNETA_LOG(ERR, "Failed to allocate space for eth addrs");
834 ret = -ENOMEM;
835 goto out_free;
836 }
837
838 memset(&req, 0, sizeof(req));
839 strcpy(req.ifr_name, name);
840 ret = ioctl(fd, SIOCGIFHWADDR, &req);
841 if (ret)
842 goto out_free;
843
844 memcpy(eth_dev->data->mac_addrs[0].addr_bytes,
845 req.ifr_addr.sa_data, RTE_ETHER_ADDR_LEN);
846
847 eth_dev->device = &vdev->device;
848 eth_dev->rx_pkt_burst = mvneta_rx_pkt_burst;
849 mvneta_set_tx_function(eth_dev);
850 eth_dev->dev_ops = &mvneta_ops;
851
852 rte_eth_dev_probing_finish(eth_dev);
853 return 0;
854out_free:
855 rte_eth_dev_release_port(eth_dev);
856
857 return ret;
858}
859
860/**
861 * Cleanup previously created device representing Ethernet port.

Callers 1

rte_pmd_mvneta_probeFunction · 0.85

Calls 11

rte_eth_dev_allocateFunction · 0.85
rte_zmalloc_socketFunction · 0.85
rte_socket_idFunction · 0.85
rte_zmallocFunction · 0.85
memsetFunction · 0.85
mvneta_set_tx_functionFunction · 0.85
rte_eth_dev_release_portFunction · 0.85
socketClass · 0.50
ioctlFunction · 0.50
memcpyFunction · 0.50

Tested by

no test coverage detected