dpdk: allow interface name to be specified from startup.conf 19/16219/4
authorDamjan Marion <damarion@cisco.com>
Tue, 27 Nov 2018 12:41:02 +0000 (13:41 +0100)
committerMarco Varlese <marco.varlese@suse.de>
Wed, 28 Nov 2018 14:12:22 +0000 (14:12 +0000)
Example:

dpdk {
    dev 0000:01:00.0 { name eth0 }
    dev 0000:02:00.0 { name eth1 }
}

Change-Id: I11e60e969a7e3548c99ac0c0c3531767819cb157
Signed-off-by: Damjan Marion <damarion@cisco.com>
src/plugins/dpdk/device/dpdk.h
src/plugins/dpdk/device/format.c
src/plugins/dpdk/device/init.c
src/vpp/conf/startup.conf

index 0e5851d..4c45e87 100644 (file)
@@ -218,6 +218,7 @@ typedef struct
   u16 nb_tx_desc;
     CLIB_CACHE_LINE_ALIGN_MARK (cacheline1);
 
+  u8 *name;
   u8 *interface_name_suffix;
 
   /* number of sub-interfaces */
@@ -332,6 +333,7 @@ void dpdk_hqos_metadata_set (dpdk_device_hqos_per_worker_thread_t * hqos,
 typedef struct
 {
   vlib_pci_addr_t pci_addr;
+  u8 *name;
   u8 is_blacklisted;
   u8 vlan_strip_offload;
 #define DPDK_DEVICE_VLAN_STRIP_DEFAULT 0
index fdc2850..bbc61e3 100644 (file)
@@ -157,6 +157,9 @@ format_dpdk_device_name (u8 * s, va_list * args)
   struct rte_pci_device *pci_dev;
   u8 *ret;
 
+  if (xd->name)
+    return format (s, "%s", xd->name);
+
   if (dm->conf->interface_name_format_decimal)
     devname_format = "%s%d/%d/%d";
   else
index c2e4d22..6cde041 100644 (file)
@@ -320,10 +320,6 @@ dpdk_lib_init (dpdk_main_t * dm)
                        pci_addr.as_u32);
        }
 
-      if (p)
-       devconf = pool_elt_at_index (dm->conf->dev_confs, p[0]);
-      else
-       devconf = &dm->conf->default_devconf;
 
       /* Create vnet interface */
       vec_add2_aligned (dm->devices, xd, 1, CLIB_CACHE_LINE_BYTES);
@@ -331,6 +327,14 @@ dpdk_lib_init (dpdk_main_t * dm)
       xd->nb_tx_desc = DPDK_NB_TX_DESC_DEFAULT;
       xd->cpu_socket = (i8) rte_eth_dev_socket_id (i);
 
+      if (p)
+       {
+         devconf = pool_elt_at_index (dm->conf->dev_confs, p[0]);
+         xd->name = devconf->name;
+       }
+      else
+       devconf = &dm->conf->default_devconf;
+
       /* Handle interface naming for devices with multiple ports sharing same PCI ID */
       if (pci_dev)
        {
@@ -1028,6 +1032,8 @@ dpdk_device_config (dpdk_config_main_t * conf, vlib_pci_addr_t pci_addr,
        ;
       else if (unformat (input, "num-tx-desc %u", &devconf->num_tx_desc))
        ;
+      else if (unformat (input, "name %s", &devconf->name))
+       ;
       else if (unformat (input, "workers %U", unformat_bitmap_list,
                         &devconf->workers))
        ;
index 66b0c22..7532f50 100644 (file)
@@ -94,6 +94,11 @@ cpu {
        ## Whitelist specific interface by specifying PCI address
        # dev 0000:02:00.0
 
+       ## Set interface name
+       # dev 0000:02:00.1 {
+       #       name eth0
+       # }
+
        ## Whitelist specific interface by specifying PCI address and in
        ## addition specify custom parameters for this interface
        # dev 0000:02:00.1 {