* Initialisation of the enetc device * * @param eth_dev * - Pointer to the structure rte_eth_dev * * @return * - On success, zero. * - On failure, negative value. */
| 882 | * - On failure, negative value. |
| 883 | */ |
| 884 | static int |
| 885 | enetc_dev_init(struct rte_eth_dev *eth_dev) |
| 886 | { |
| 887 | int error = 0; |
| 888 | struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); |
| 889 | struct enetc_eth_hw *hw = |
| 890 | ENETC_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); |
| 891 | |
| 892 | PMD_INIT_FUNC_TRACE(); |
| 893 | eth_dev->dev_ops = &enetc_ops; |
| 894 | eth_dev->rx_pkt_burst = &enetc_recv_pkts; |
| 895 | eth_dev->tx_pkt_burst = &enetc_xmit_pkts; |
| 896 | |
| 897 | /* Retrieving and storing the HW base address of device */ |
| 898 | hw->hw.reg = (void *)pci_dev->mem_resource[0].addr; |
| 899 | hw->device_id = pci_dev->id.device_id; |
| 900 | |
| 901 | error = enetc_hardware_init(hw); |
| 902 | if (error != 0) { |
| 903 | ENETC_PMD_ERR("Hardware initialization failed"); |
| 904 | return -1; |
| 905 | } |
| 906 | |
| 907 | /* Allocate memory for storing MAC addresses */ |
| 908 | eth_dev->data->mac_addrs = rte_zmalloc("enetc_eth", |
| 909 | RTE_ETHER_ADDR_LEN, 0); |
| 910 | if (!eth_dev->data->mac_addrs) { |
| 911 | ENETC_PMD_ERR("Failed to allocate %d bytes needed to " |
| 912 | "store MAC addresses", |
| 913 | RTE_ETHER_ADDR_LEN * 1); |
| 914 | error = -ENOMEM; |
| 915 | return -1; |
| 916 | } |
| 917 | |
| 918 | /* Copy the permanent MAC address */ |
| 919 | rte_ether_addr_copy((struct rte_ether_addr *)hw->mac.addr, |
| 920 | ð_dev->data->mac_addrs[0]); |
| 921 | |
| 922 | /* Set MTU */ |
| 923 | enetc_port_wr(&hw->hw, ENETC_PM0_MAXFRM, |
| 924 | ENETC_SET_MAXFRM(RTE_ETHER_MAX_LEN)); |
| 925 | eth_dev->data->mtu = RTE_ETHER_MAX_LEN - RTE_ETHER_HDR_LEN - |
| 926 | RTE_ETHER_CRC_LEN; |
| 927 | |
| 928 | if (rte_eal_iova_mode() == RTE_IOVA_PA) |
| 929 | dpaax_iova_table_populate(); |
| 930 | |
| 931 | ENETC_PMD_DEBUG("port_id %d vendorID=0x%x deviceID=0x%x", |
| 932 | eth_dev->data->port_id, pci_dev->id.vendor_id, |
| 933 | pci_dev->id.device_id); |
| 934 | return 0; |
| 935 | } |
| 936 | |
| 937 | static int |
| 938 | enetc_dev_uninit(struct rte_eth_dev *eth_dev) |
nothing calls this directly
no test coverage detected