[dpdk-dev] [PATCH v4 1/3] bonding: add support for PCI Port Hotplug

Declan Doherty declan.doherty at intel.com
Wed Jul 15 12:22:18 CEST 2015


On 07/07/15 11:21, Bernard Iremonger wrote:
> This patch depends on the Port Hotplug Framework.
> It implements the rte_dev_uninit_t() function for the link bonding pmd.
>
> Signed-off-by: Bernard Iremonger <bernard.iremonger at intel.com>
> ---
...
>

I think we can clean up the create function a bit further as the 
pci_id_table is static for all bonded devices we can just statically 
initialize it, as this will remove the resetting of the parameters each 
time a bonding device is created. See below

Declan

diff --git a/drivers/net/bonding/rte_eth_bond_api.c 
b/drivers/net/bonding/rte_eth_bond_api.c
index 9d8da1c..bf25470 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -193,12 +193,19 @@ number_of_sockets(void)
  }

  const char driver_name[] = "rte_bond_pmd";
-static struct rte_pci_id pci_id_table;
+
+static struct rte_pci_id pci_id_table = {
+       .device_id = PCI_ANY_ID,
+       .subsystem_device_id = PCI_ANY_ID,
+       .vendor_id = PCI_ANY_ID,
+       .subsystem_vendor_id = PCI_ANY_ID
+};

  static struct eth_driver rte_bond_pmd = {
         .pci_drv = {
                 .name = driver_name,
                 .drv_flags = RTE_PCI_DRV_INTR_LSC | RTE_PCI_DRV_DETACHABLE,
+               .id_table = &pci_id_table
         },
  };

@@ -208,7 +215,6 @@ rte_eth_bond_create(const char *name, uint8_t mode, 
uint8_t socket_id)
         struct rte_pci_device *pci_dev = NULL;
         struct bond_dev_private *internals = NULL;
         struct rte_eth_dev *eth_dev = NULL;
-       struct rte_pci_driver *pci_drv = NULL;

         /* now do all data allocation - for eth_dev structure, dummy 
pci driver
          * and internal (private) data
@@ -231,16 +237,6 @@ rte_eth_bond_create(const char *name, uint8_t mode, 
uint8_t socket_id)
                 goto err;
         }

-       pci_drv = &rte_bond_pmd.pci_drv;
-
-       memset(&pci_id_table, 0, sizeof(pci_id_table));
-       pci_id_table.device_id = PCI_ANY_ID;
-       pci_id_table.subsystem_device_id = PCI_ANY_ID;
-       pci_id_table.vendor_id = PCI_ANY_ID;
-       pci_id_table.subsystem_vendor_id = PCI_ANY_ID;
-
-       pci_drv->id_table = &pci_id_table;
-
         internals = rte_zmalloc_socket(name, sizeof(*internals), 0, 
socket_id);
         if (internals == NULL) {
                 RTE_BOND_LOG(ERR, "Unable to malloc internals on socket");
@@ -255,8 +251,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, 
uint8_t socket_id)
         }

         pci_dev->numa_node = socket_id;
-       pci_drv->name = driver_name;
-       pci_dev->driver = pci_drv;
+       pci_dev->driver = &rte_bond_pmd.pci_drv;

         eth_dev->driver = &rte_bond_pmd;
         eth_dev->data->dev_private = internals;



More information about the dev mailing list