[dpdk-dev] [PATCH 1/2] ethdev: Allow to overload pci_drv.devinit and pci_drv.devuninit

krytarowski at caviumnetworks.com krytarowski at caviumnetworks.com
Tue Feb 2 15:27:18 CET 2016


From: Kamil Rytarowski <Kamil.Rytarowski at caviumnetworks.com>

This change enables drivers needing custom pci (de)initialization functions
through the standard callback overloading.

For example:

 /*
  * virtual function driver struct
  */
 static struct eth_driver rte_DRIVER_pmd = {
 	{
 		.name = "rte_DRIVER_pmd",
 		.id_table = pci_id_DRIVER_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
		.devinit = DRIVER_pci_devinit,
 	},
 	.eth_dev_init = eth_DRIVER_dev_init,
 	.dev_private_size = sizeof(struct DRIVER),
 };

Use-case is as follows: NIC offers several pci virtual functions, while
one of them is to be treated as port, we need to configure the rest in a
specific way for particular device for full interface (port) functionality.

Signed-off-by: Kamil Rytarowski <Kamil.Rytarowski at caviumnetworks.com>
---
 lib/librte_ether/rte_ethdev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 756b234..ac4aeab 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -351,8 +351,10 @@ rte_eth_dev_uninit(struct rte_pci_device *pci_dev)
 void
 rte_eth_driver_register(struct eth_driver *eth_drv)
 {
-	eth_drv->pci_drv.devinit = rte_eth_dev_init;
-	eth_drv->pci_drv.devuninit = rte_eth_dev_uninit;
+	if (!eth_drv->pci_drv.devinit)
+		eth_drv->pci_drv.devinit = rte_eth_dev_init;
+	if (!eth_drv->pci_drv.devuninit)
+		eth_drv->pci_drv.devuninit = rte_eth_dev_uninit;
 	rte_eal_pci_register(&eth_drv->pci_drv);
 }
 
-- 
1.9.1



More information about the dev mailing list