xref: /dpdk/drivers/net/cxgbe/cxgbevf_ethdev.c (revision 011ebc23)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2018 Chelsio Communications.
3  * All rights reserved.
4  */
5 
6 #include <rte_ethdev_driver.h>
7 #include <rte_ethdev_pci.h>
8 
9 #include "cxgbe.h"
10 #include "cxgbe_pfvf.h"
11 
12 /*
13  * Macros needed to support the PCI Device ID Table ...
14  */
15 #define CH_PCI_DEVICE_ID_TABLE_DEFINE_BEGIN \
16 	static const struct rte_pci_id cxgb4vf_pci_tbl[] = {
17 #define CH_PCI_DEVICE_ID_FUNCTION 0x8
18 
19 #define PCI_VENDOR_ID_CHELSIO 0x1425
20 
21 #define CH_PCI_ID_TABLE_ENTRY(devid) \
22 		{ RTE_PCI_DEVICE(PCI_VENDOR_ID_CHELSIO, (devid)) }
23 
24 #define CH_PCI_DEVICE_ID_TABLE_DEFINE_END \
25 		{ .vendor_id = 0, } \
26 	}
27 
28 /*
29  *... and the PCI ID Table itself ...
30  */
31 #include "t4_pci_id_tbl.h"
32 
33 static const struct eth_dev_ops cxgbevf_eth_dev_ops = {
34 	.dev_start              = cxgbe_dev_start,
35 	.dev_stop               = cxgbe_dev_stop,
36 	.dev_close              = cxgbe_dev_close,
37 	.promiscuous_enable     = cxgbe_dev_promiscuous_enable,
38 	.promiscuous_disable    = cxgbe_dev_promiscuous_disable,
39 	.allmulticast_enable    = cxgbe_dev_allmulticast_enable,
40 	.allmulticast_disable   = cxgbe_dev_allmulticast_disable,
41 	.dev_configure          = cxgbe_dev_configure,
42 	.dev_infos_get          = cxgbe_dev_info_get,
43 	.dev_supported_ptypes_get = cxgbe_dev_supported_ptypes_get,
44 	.link_update            = cxgbe_dev_link_update,
45 	.mtu_set                = cxgbe_dev_mtu_set,
46 	.tx_queue_setup         = cxgbe_dev_tx_queue_setup,
47 	.tx_queue_start         = cxgbe_dev_tx_queue_start,
48 	.tx_queue_stop          = cxgbe_dev_tx_queue_stop,
49 	.tx_queue_release       = cxgbe_dev_tx_queue_release,
50 	.rx_queue_setup         = cxgbe_dev_rx_queue_setup,
51 	.rx_queue_start         = cxgbe_dev_rx_queue_start,
52 	.rx_queue_stop          = cxgbe_dev_rx_queue_stop,
53 	.rx_queue_release       = cxgbe_dev_rx_queue_release,
54 };
55 
56 /*
57  * Initialize driver
58  * It returns 0 on success.
59  */
60 static int eth_cxgbevf_dev_init(struct rte_eth_dev *eth_dev)
61 {
62 	CXGBE_FUNC_TRACE();
63 
64 	eth_dev->dev_ops = &cxgbevf_eth_dev_ops;
65 
66 	/* XXX: Do probe */
67 	return -EIO;
68 }
69 
70 static int eth_cxgbevf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
71 				 struct rte_pci_device *pci_dev)
72 {
73 	return rte_eth_dev_pci_generic_probe(pci_dev, sizeof(struct port_info),
74 					     eth_cxgbevf_dev_init);
75 }
76 
77 static int eth_cxgbevf_pci_remove(struct rte_pci_device *pci_dev)
78 {
79 	return rte_eth_dev_pci_generic_remove(pci_dev, NULL);
80 }
81 
82 static struct rte_pci_driver rte_cxgbevf_pmd = {
83 	.id_table = cxgb4vf_pci_tbl,
84 	.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
85 	.probe = eth_cxgbevf_pci_probe,
86 	.remove = eth_cxgbevf_pci_remove,
87 };
88 
89 RTE_PMD_REGISTER_PCI(net_cxgbevf, rte_cxgbevf_pmd);
90 RTE_PMD_REGISTER_PCI_TABLE(net_cxgbevf, cxgb4vf_pci_tbl);
91 RTE_PMD_REGISTER_KMOD_DEP(net_cxgbevf, "* igb_uio | vfio-pci");
92