1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2020 Intel Corporation
8 #include <rte_bus_pci.h>
9 #include <rte_ethdev_driver.h>
10 #include <rte_ethdev_pci.h>
11 #include <rte_malloc.h>
14 #include "igc_ethdev.h"
16 #define IGC_INTEL_VENDOR_ID 0x8086
17 #define IGC_DEV_ID_I225_LM 0x15F2
18 #define IGC_DEV_ID_I225_V 0x15F3
19 #define IGC_DEV_ID_I225_K 0x3100
20 #define IGC_DEV_ID_I225_I 0x15F8
21 #define IGC_DEV_ID_I220_V 0x15F7
23 static const struct rte_pci_id pci_id_igc_map[] = {
24 { RTE_PCI_DEVICE(IGC_INTEL_VENDOR_ID, IGC_DEV_ID_I225_LM) },
25 { RTE_PCI_DEVICE(IGC_INTEL_VENDOR_ID, IGC_DEV_ID_I225_V) },
26 { RTE_PCI_DEVICE(IGC_INTEL_VENDOR_ID, IGC_DEV_ID_I225_I) },
27 { RTE_PCI_DEVICE(IGC_INTEL_VENDOR_ID, IGC_DEV_ID_I225_K) },
28 { .vendor_id = 0, /* sentinel */ },
31 static int eth_igc_configure(struct rte_eth_dev *dev);
32 static int eth_igc_link_update(struct rte_eth_dev *dev, int wait_to_complete);
33 static void eth_igc_stop(struct rte_eth_dev *dev);
34 static int eth_igc_start(struct rte_eth_dev *dev);
35 static void eth_igc_close(struct rte_eth_dev *dev);
36 static int eth_igc_reset(struct rte_eth_dev *dev);
37 static int eth_igc_promiscuous_enable(struct rte_eth_dev *dev);
38 static int eth_igc_promiscuous_disable(struct rte_eth_dev *dev);
39 static int eth_igc_infos_get(struct rte_eth_dev *dev,
40 struct rte_eth_dev_info *dev_info);
42 eth_igc_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
43 uint16_t nb_rx_desc, unsigned int socket_id,
44 const struct rte_eth_rxconf *rx_conf,
45 struct rte_mempool *mb_pool);
47 eth_igc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
48 uint16_t nb_desc, unsigned int socket_id,
49 const struct rte_eth_txconf *tx_conf);
51 static const struct eth_dev_ops eth_igc_ops = {
52 .dev_configure = eth_igc_configure,
53 .link_update = eth_igc_link_update,
54 .dev_stop = eth_igc_stop,
55 .dev_start = eth_igc_start,
56 .dev_close = eth_igc_close,
57 .dev_reset = eth_igc_reset,
58 .promiscuous_enable = eth_igc_promiscuous_enable,
59 .promiscuous_disable = eth_igc_promiscuous_disable,
60 .dev_infos_get = eth_igc_infos_get,
61 .rx_queue_setup = eth_igc_rx_queue_setup,
62 .tx_queue_setup = eth_igc_tx_queue_setup,
66 eth_igc_configure(struct rte_eth_dev *dev)
68 PMD_INIT_FUNC_TRACE();
74 eth_igc_link_update(struct rte_eth_dev *dev, int wait_to_complete)
76 PMD_INIT_FUNC_TRACE();
78 RTE_SET_USED(wait_to_complete);
83 eth_igc_stop(struct rte_eth_dev *dev)
85 PMD_INIT_FUNC_TRACE();
90 eth_igc_start(struct rte_eth_dev *dev)
92 PMD_INIT_FUNC_TRACE();
98 eth_igc_close(struct rte_eth_dev *dev)
100 PMD_INIT_FUNC_TRACE();
105 eth_igc_dev_init(struct rte_eth_dev *dev)
107 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
109 PMD_INIT_FUNC_TRACE();
110 dev->dev_ops = ð_igc_ops;
113 * for secondary processes, we don't initialize any further as primary
114 * has already done this work. Only check we don't need a different
117 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
120 dev->data->mac_addrs = rte_zmalloc("igc",
121 RTE_ETHER_ADDR_LEN, 0);
122 if (dev->data->mac_addrs == NULL) {
123 PMD_INIT_LOG(ERR, "Failed to allocate %d bytes for storing MAC",
128 /* Pass the information to the rte_eth_dev_close() that it should also
129 * release the private port resources.
131 dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
133 PMD_INIT_LOG(DEBUG, "port_id %d vendorID=0x%x deviceID=0x%x",
134 dev->data->port_id, pci_dev->id.vendor_id,
135 pci_dev->id.device_id);
141 eth_igc_dev_uninit(__rte_unused struct rte_eth_dev *eth_dev)
143 PMD_INIT_FUNC_TRACE();
145 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
148 eth_igc_close(eth_dev);
153 eth_igc_reset(struct rte_eth_dev *dev)
157 PMD_INIT_FUNC_TRACE();
159 ret = eth_igc_dev_uninit(dev);
163 return eth_igc_dev_init(dev);
167 eth_igc_promiscuous_enable(struct rte_eth_dev *dev)
169 PMD_INIT_FUNC_TRACE();
175 eth_igc_promiscuous_disable(struct rte_eth_dev *dev)
177 PMD_INIT_FUNC_TRACE();
183 eth_igc_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
185 PMD_INIT_FUNC_TRACE();
187 dev_info->max_rx_queues = IGC_QUEUE_PAIRS_NUM;
188 dev_info->max_tx_queues = IGC_QUEUE_PAIRS_NUM;
193 eth_igc_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
194 uint16_t nb_rx_desc, unsigned int socket_id,
195 const struct rte_eth_rxconf *rx_conf,
196 struct rte_mempool *mb_pool)
198 PMD_INIT_FUNC_TRACE();
200 RTE_SET_USED(rx_queue_id);
201 RTE_SET_USED(nb_rx_desc);
202 RTE_SET_USED(socket_id);
203 RTE_SET_USED(rx_conf);
204 RTE_SET_USED(mb_pool);
209 eth_igc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
210 uint16_t nb_desc, unsigned int socket_id,
211 const struct rte_eth_txconf *tx_conf)
213 PMD_INIT_FUNC_TRACE();
215 RTE_SET_USED(queue_idx);
216 RTE_SET_USED(nb_desc);
217 RTE_SET_USED(socket_id);
218 RTE_SET_USED(tx_conf);
223 eth_igc_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
224 struct rte_pci_device *pci_dev)
226 PMD_INIT_FUNC_TRACE();
227 return rte_eth_dev_pci_generic_probe(pci_dev, 0, eth_igc_dev_init);
231 eth_igc_pci_remove(struct rte_pci_device *pci_dev)
233 PMD_INIT_FUNC_TRACE();
234 return rte_eth_dev_pci_generic_remove(pci_dev, eth_igc_dev_uninit);
237 static struct rte_pci_driver rte_igc_pmd = {
238 .id_table = pci_id_igc_map,
239 .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
240 .probe = eth_igc_pci_probe,
241 .remove = eth_igc_pci_remove,
244 RTE_PMD_REGISTER_PCI(net_igc, rte_igc_pmd);
245 RTE_PMD_REGISTER_PCI_TABLE(net_igc, pci_id_igc_map);
246 RTE_PMD_REGISTER_KMOD_DEP(net_igc, "* igb_uio | uio_pci_generic | vfio-pci");