dpdk: Decoupling the meaning of xd->device_index in dpdk_plugin 48/12548/6
authorRui Cai <rucai@microsoft.com>
Fri, 11 May 2018 22:55:33 +0000 (22:55 +0000)
committerDamjan Marion <dmarion@me.com>
Thu, 31 May 2018 22:01:15 +0000 (22:01 +0000)
Prior to the change, dpdk plugin assumes xd->device_index is
used both as index for internal dpdk_main->devices array
and DPDK port index to call into DPDK APIs.

However, when running on top of Failsafe PMDs,
DPDK port index range may no longer be contiguous (as noted:
http://dpdk.org/ml/archives/dev/2018-March/092375.html
for related changes in DPDK). Because this, dpdk plugin can
no longer iterate through all available DPDK ports
with a for 0->rte_eth_dev_count() loop and the assumption of
device_index no longer holds.

This is part of initial effort to enable vpp running over
dpdk on failsafe PMD in Microsoft Azure(3/4).

Change-Id: I416fd80f2d40e12e139f8f3492814da98343eae7
Signed-off-by: Rui Cai <rucai@microsoft.com>
src/plugins/dpdk/device/cli.c
src/plugins/dpdk/device/common.c
src/plugins/dpdk/device/device.c
src/plugins/dpdk/device/dpdk.h
src/plugins/dpdk/device/dpdk_priv.h
src/plugins/dpdk/device/format.c
src/plugins/dpdk/device/init.c
src/plugins/dpdk/device/node.c
src/plugins/dpdk/hqos/hqos.c

index 151a6f4..2530858 100644 (file)
@@ -65,7 +65,7 @@ get_hqos (u32 hw_if_index, u32 subport_id, dpdk_device_t ** xd,
   hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
   *xd = vec_elt_at_index (dm->devices, hw->dev_instance);
 
-  rte_eth_dev_info_get ((*xd)->device_index, &dev_info);
+  rte_eth_dev_info_get ((*xd)->port_id, &dev_info);
   if (dev_info.pci_dev)
     {                          /* bonded interface has no pci info */
       vlib_pci_addr_t pci_addr;
@@ -1283,7 +1283,7 @@ set_dpdk_if_hqos_pktfield (vlib_main_t * vm, unformat_input_t * input,
   hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
   xd = vec_elt_at_index (dm->devices, hw->dev_instance);
 
-  rte_eth_dev_info_get (xd->device_index, &dev_info);
+  rte_eth_dev_info_get (xd->port_id, &dev_info);
   if (dev_info.pci_dev)
     {                          /* bonded interface has no pci info */
       vlib_pci_addr_t pci_addr;
@@ -1474,7 +1474,7 @@ show_dpdk_if_hqos (vlib_main_t * vm, unformat_input_t * input,
   hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
   xd = vec_elt_at_index (dm->devices, hw->dev_instance);
 
-  rte_eth_dev_info_get (xd->device_index, &dev_info);
+  rte_eth_dev_info_get (xd->port_id, &dev_info);
   if (dev_info.pci_dev)
     {                          /* bonded interface has no pci info */
       vlib_pci_addr_t pci_addr;
@@ -1884,7 +1884,7 @@ show_dpdk_hqos_queue_stats (vlib_main_t * vm, unformat_input_t * input,
   hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
   xd = vec_elt_at_index (dm->devices, hw->dev_instance);
 
-  rte_eth_dev_info_get (xd->device_index, &dev_info);
+  rte_eth_dev_info_get (xd->port_id, &dev_info);
   if (dev_info.pci_dev)
     {                          /* bonded interface has no pci info */
       vlib_pci_addr_t pci_addr;
index e9eac14..dad4332 100644 (file)
@@ -31,11 +31,9 @@ void
 dpdk_device_error (dpdk_device_t * xd, char *str, int rv)
 {
   dpdk_log_err ("Interface %U error %d: %s",
-               format_dpdk_device_name, xd->device_index, rv,
-               rte_strerror (rv));
+               format_dpdk_device_name, xd->port_id, rv, rte_strerror (rv));
   xd->errors = clib_error_return (xd->errors, "%s[port:%d, errno:%d]: %s",
-                                 str, xd->device_index, rv,
-                                 rte_strerror (rv));
+                                 str, xd->port_id, rv, rte_strerror (rv));
 }
 
 void
@@ -68,7 +66,7 @@ dpdk_device_setup (dpdk_device_t * xd)
        xd->port_conf.fdir_conf.mode = RTE_FDIR_MODE_NONE;
     }
 
-  rv = rte_eth_dev_configure (xd->device_index, xd->rx_q_used,
+  rv = rte_eth_dev_configure (xd->port_id, xd->rx_q_used,
                              xd->tx_q_used, &xd->port_conf);
 
   if (rv < 0)
@@ -80,13 +78,16 @@ dpdk_device_setup (dpdk_device_t * xd)
   /* Set up one TX-queue per worker thread */
   for (j = 0; j < xd->tx_q_used; j++)
     {
-      rv = rte_eth_tx_queue_setup (xd->device_index, j, xd->nb_tx_desc,
-                                  xd->cpu_socket, &xd->tx_conf);
+      rv =
+       rte_eth_tx_queue_setup (xd->port_id, j, xd->nb_tx_desc,
+                               xd->cpu_socket, &xd->tx_conf);
 
       /* retry with any other CPU socket */
       if (rv < 0)
-       rv = rte_eth_tx_queue_setup (xd->device_index, j, xd->nb_tx_desc,
-                                    SOCKET_ID_ANY, &xd->tx_conf);
+       rv =
+         rte_eth_tx_queue_setup (xd->port_id, j,
+                                 xd->nb_tx_desc, SOCKET_ID_ANY,
+                                 &xd->tx_conf);
       if (rv < 0)
        dpdk_device_error (xd, "rte_eth_tx_queue_setup", rv);
     }
@@ -101,15 +102,17 @@ dpdk_device_setup (dpdk_device_t * xd)
       unsigned lcore = vlib_worker_threads[tidx].lcore_id;
       u16 socket_id = rte_lcore_to_socket_id (lcore);
 
-      rv = rte_eth_rx_queue_setup (xd->device_index, j, xd->nb_rx_desc,
-                                  xd->cpu_socket, 0,
-                                  dm->pktmbuf_pools[socket_id]);
+      rv =
+       rte_eth_rx_queue_setup (xd->port_id, j, xd->nb_rx_desc,
+                               xd->cpu_socket, 0,
+                               dm->pktmbuf_pools[socket_id]);
 
       /* retry with any other CPU socket */
       if (rv < 0)
-       rv = rte_eth_rx_queue_setup (xd->device_index, j, xd->nb_rx_desc,
-                                    SOCKET_ID_ANY, 0,
-                                    dm->pktmbuf_pools[socket_id]);
+       rv =
+         rte_eth_rx_queue_setup (xd->port_id, j,
+                                 xd->nb_rx_desc, SOCKET_ID_ANY, 0,
+                                 dm->pktmbuf_pools[socket_id]);
 
       privp = rte_mempool_get_priv (dm->pktmbuf_pools[socket_id]);
       xd->buffer_pool_for_queue[j] = privp->buffer_pool_index;
@@ -121,7 +124,7 @@ dpdk_device_setup (dpdk_device_t * xd)
   if (vec_len (xd->errors))
     goto error;
 
-  rte_eth_dev_set_mtu (xd->device_index, hi->max_packet_bytes);
+  rte_eth_dev_set_mtu (xd->port_id, hi->max_packet_bytes);
 
   if (xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP)
     dpdk_device_start (xd);
@@ -144,7 +147,7 @@ dpdk_device_start (dpdk_device_t * xd)
   if (xd->flags & DPDK_DEVICE_FLAG_PMD_INIT_FAIL)
     return;
 
-  rv = rte_eth_dev_start (xd->device_index);
+  rv = rte_eth_dev_start (xd->port_id);
 
   if (rv)
     {
@@ -154,7 +157,7 @@ dpdk_device_start (dpdk_device_t * xd)
 
   if (xd->default_mac_address)
     rv =
-      rte_eth_dev_default_mac_addr_set (xd->device_index,
+      rte_eth_dev_default_mac_addr_set (xd->port_id,
                                        (struct ether_addr *)
                                        xd->default_mac_address);
 
@@ -162,16 +165,16 @@ dpdk_device_start (dpdk_device_t * xd)
     dpdk_device_error (xd, "rte_eth_dev_default_mac_addr_set", rv);
 
   if (xd->flags & DPDK_DEVICE_FLAG_PROMISC)
-    rte_eth_promiscuous_enable (xd->device_index);
+    rte_eth_promiscuous_enable (xd->port_id);
   else
-    rte_eth_promiscuous_disable (xd->device_index);
+    rte_eth_promiscuous_disable (xd->port_id);
 
-  rte_eth_allmulticast_enable (xd->device_index);
+  rte_eth_allmulticast_enable (xd->port_id);
 
   if (xd->pmd == VNET_DPDK_PMD_BOND)
     {
       dpdk_portid_t slink[16];
-      int nlink = rte_eth_bond_slaves_get (xd->device_index, slink, 16);
+      int nlink = rte_eth_bond_slaves_get (xd->port_id, slink, 16);
       while (nlink >= 1)
        {
          dpdk_portid_t dpdk_port = slink[--nlink];
@@ -180,7 +183,7 @@ dpdk_device_start (dpdk_device_t * xd)
     }
 
   dpdk_log_info ("Interface %U started",
-                format_dpdk_device_name, xd->device_index);
+                format_dpdk_device_name, xd->port_id);
 }
 
 void
@@ -189,14 +192,14 @@ dpdk_device_stop (dpdk_device_t * xd)
   if (xd->flags & DPDK_DEVICE_FLAG_PMD_INIT_FAIL)
     return;
 
-  rte_eth_allmulticast_disable (xd->device_index);
-  rte_eth_dev_stop (xd->device_index);
+  rte_eth_allmulticast_disable (xd->port_id);
+  rte_eth_dev_stop (xd->port_id);
 
   /* For bonded interface, stop slave links */
   if (xd->pmd == VNET_DPDK_PMD_BOND)
     {
       dpdk_portid_t slink[16];
-      int nlink = rte_eth_bond_slaves_get (xd->device_index, slink, 16);
+      int nlink = rte_eth_bond_slaves_get (xd->port_id, slink, 16);
       while (nlink >= 1)
        {
          dpdk_portid_t dpdk_port = slink[--nlink];
@@ -204,7 +207,7 @@ dpdk_device_stop (dpdk_device_t * xd)
        }
     }
   dpdk_log_info ("Interface %U stopped",
-                format_dpdk_device_name, xd->device_index);
+                format_dpdk_device_name, xd->port_id);
 }
 
 /* Even type for send_garp_na_process */
index fe659fb..d5ab258 100644 (file)
@@ -51,7 +51,7 @@ dpdk_set_mac_address (vnet_hw_interface_t * hi, char *address)
   dpdk_main_t *dm = &dpdk_main;
   dpdk_device_t *xd = vec_elt_at_index (dm->devices, hi->dev_instance);
 
-  error = rte_eth_dev_default_mac_addr_set (xd->device_index,
+  error = rte_eth_dev_default_mac_addr_set (xd->port_id,
                                            (struct ether_addr *) address);
 
   if (error)
@@ -226,7 +226,7 @@ static_always_inline
       else if (PREDICT_TRUE (xd->flags & DPDK_DEVICE_FLAG_PMD))
        {
          /* no wrap, transmit in one burst */
-         n_sent = rte_eth_tx_burst (xd->device_index, queue_id, mb, n_left);
+         n_sent = rte_eth_tx_burst (xd->port_id, queue_id, mb, n_left);
        }
       else
        {
@@ -248,8 +248,8 @@ static_always_inline
                                         xd->hw_if_index)->tx_node_index;
 
          vlib_error_count (vm, node_index, DPDK_TX_FUNC_ERROR_BAD_RETVAL, 1);
-         clib_warning ("rte_eth_tx_burst[%d]: error %d", xd->device_index,
-                       n_sent);
+         clib_warning ("rte_eth_tx_burst[%d]: error %d",
+                       xd->port_id, n_sent);
          return n_left;        // untransmitted packets
        }
       n_left -= n_sent;
@@ -629,25 +629,25 @@ dpdk_subif_add_del_function (vnet_main_t * vnm,
       goto done;
     }
 
-  vlan_offload = rte_eth_dev_get_vlan_offload (xd->device_index);
+  vlan_offload = rte_eth_dev_get_vlan_offload (xd->port_id);
   vlan_offload |= ETH_VLAN_FILTER_OFFLOAD;
 
-  if ((r = rte_eth_dev_set_vlan_offload (xd->device_index, vlan_offload)))
+  if ((r = rte_eth_dev_set_vlan_offload (xd->port_id, vlan_offload)))
     {
       xd->num_subifs = prev_subifs;
       err = clib_error_return (0, "rte_eth_dev_set_vlan_offload[%d]: err %d",
-                              xd->device_index, r);
+                              xd->port_id, r);
       goto done;
     }
 
 
   if ((r =
-       rte_eth_dev_vlan_filter (xd->device_index, t->sub.eth.outer_vlan_id,
-                               is_add)))
+       rte_eth_dev_vlan_filter (xd->port_id,
+                               t->sub.eth.outer_vlan_id, is_add)))
     {
       xd->num_subifs = prev_subifs;
       err = clib_error_return (0, "rte_eth_dev_vlan_filter[%d]: err %d",
-                              xd->device_index, r);
+                              xd->port_id, r);
       goto done;
     }
 
index 86cc670..b447e71 100644 (file)
@@ -18,6 +18,8 @@
 /* $$$$ We should rename always_inline -> clib_always_inline */
 #undef always_inline
 
+#define ALLOW_EXPERIMENTAL_API
+
 #include <rte_config.h>
 
 #include <rte_common.h>
@@ -191,9 +193,12 @@ typedef struct
   CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
   volatile u32 **lockp;
 
-  /* Instance ID */
+  /* Instance ID to access internal device array. */
   dpdk_portid_t device_index;
 
+  /* DPDK device port number */
+  dpdk_portid_t port_id;
+
   u32 hw_if_index;
   u32 sw_if_index;
 
index cbc116e..c73f57e 100644 (file)
@@ -65,14 +65,13 @@ dpdk_get_xstats (dpdk_device_t * xd)
   if (!(xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP))
     return;
   int len;
-  if ((len = rte_eth_xstats_get (xd->device_index, NULL, 0)) > 0)
+  if ((len = rte_eth_xstats_get (xd->port_id, NULL, 0)) > 0)
     {
       vec_validate (xd->xstats, len - 1);
       vec_validate (xd->last_cleared_xstats, len - 1);
 
       len =
-       rte_eth_xstats_get (xd->device_index, xd->xstats,
-                           vec_len (xd->xstats));
+       rte_eth_xstats_get (xd->port_id, xd->xstats, vec_len (xd->xstats));
 
       ASSERT (vec_len (xd->xstats) == len);
       ASSERT (vec_len (xd->last_cleared_xstats) == len);
@@ -98,7 +97,7 @@ dpdk_update_counters (dpdk_device_t * xd, f64 now)
 
   xd->time_last_stats_update = now ? now : xd->time_last_stats_update;
   clib_memcpy (&xd->last_stats, &xd->stats, sizeof (xd->last_stats));
-  rte_eth_stats_get (xd->device_index, &xd->stats);
+  rte_eth_stats_get (xd->port_id, &xd->stats);
 
   /* maybe bump interface rx no buffer counter */
   if (PREDICT_FALSE (xd->stats.rx_nombuf != xd->last_stats.rx_nombuf))
index 22f37c4..f10b00e 100644 (file)
@@ -253,7 +253,7 @@ format_dpdk_device_name (u8 * s, va_list * args)
                  dev_info.pci_dev->addr.devid,
                  dev_info.pci_dev->addr.function);
   else
-    ret = format (s, "%s%d", device_name, dm->devices[i].device_index);
+    ret = format (s, "%s%d", device_name, dm->devices[i].port_id);
 
   if (dm->devices[i].interface_name_suffix)
     return format (ret, "/%s", dm->devices[i].interface_name_suffix);
@@ -396,7 +396,7 @@ format_dpdk_link_status (u8 * s, va_list * args)
   s = format (s, "%s ", l->link_status ? "up" : "down");
   if (l->link_status)
     {
-      u32 promisc = rte_eth_promiscuous_get (xd->device_index);
+      u32 promisc = rte_eth_promiscuous_get (xd->port_id);
 
       s = format (s, "%s duplex ", (l->link_duplex == ETH_LINK_FULL_DUPLEX) ?
                  "full" : "half");
@@ -489,12 +489,12 @@ format_dpdk_device (u8 * s, va_list * args)
   dpdk_update_link_state (xd, now);
 
   s = format (s, "%U\n%Ucarrier %U",
-             format_dpdk_device_type, xd->device_index,
+             format_dpdk_device_type, xd->port_id,
              format_white_space, indent + 2, format_dpdk_link_status, xd);
   s = format (s, "%Uflags: %U\n",
              format_white_space, indent + 2, format_dpdk_device_flags, xd);
 
-  rte_eth_dev_info_get (xd->device_index, &di);
+  rte_eth_dev_info_get (xd->port_id, &di);
 
   if (verbose > 1 && xd->flags & DPDK_DEVICE_FLAG_PMD)
     {
@@ -504,7 +504,7 @@ format_dpdk_device (u8 * s, va_list * args)
       int retval;
 
       rss_conf.rss_key = 0;
-      retval = rte_eth_dev_rss_hash_conf_get (xd->device_index, &rss_conf);
+      retval = rte_eth_dev_rss_hash_conf_get (xd->port_id, &rss_conf);
       if (retval < 0)
        clib_warning ("rte_eth_dev_rss_hash_conf_get returned %d", retval);
       pci = di.pci_dev;
@@ -528,9 +528,10 @@ format_dpdk_device (u8 * s, va_list * args)
       s =
        format (s, "%Upromiscuous:       unicast %s all-multicast %s\n",
                format_white_space, indent + 2,
-               rte_eth_promiscuous_get (xd->device_index) ? "on" : "off",
-               rte_eth_allmulticast_get (xd->device_index) ? "on" : "off");
-      vlan_off = rte_eth_dev_get_vlan_offload (xd->device_index);
+               rte_eth_promiscuous_get (xd->port_id) ?
+               "on" : "off",
+               rte_eth_allmulticast_get (xd->port_id) ? "on" : "off");
+      vlan_off = rte_eth_dev_get_vlan_offload (xd->port_id);
       s = format (s, "%Uvlan offload:      strip %s filter %s qinq %s\n",
                  format_white_space, indent + 2,
                  vlan_off & ETH_VLAN_STRIP_OFFLOAD ? "on" : "off",
@@ -576,9 +577,9 @@ format_dpdk_device (u8 * s, va_list * args)
   u32 i = 0;
   struct rte_eth_xstat *xstat, *last_xstat;
   struct rte_eth_xstat_name *xstat_names = 0;
-  int len = rte_eth_xstats_get_names (xd->device_index, NULL, 0);
+  int len = rte_eth_xstats_get_names (xd->port_id, NULL, 0);
   vec_validate (xstat_names, len - 1);
-  rte_eth_xstats_get_names (xd->device_index, xstat_names, len);
+  rte_eth_xstats_get_names (xd->port_id, xstat_names, len);
 
   ASSERT (vec_len (xd->xstats) == vec_len (xd->last_cleared_xstats));
 
index d7c369a..b5a8e3b 100644 (file)
@@ -107,9 +107,9 @@ dpdk_flag_change (vnet_main_t * vnm, vnet_hw_interface_t * hi, u32 flags)
       if (xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP)
        {
          if (xd->flags & DPDK_DEVICE_FLAG_PROMISC)
-           rte_eth_promiscuous_enable (xd->device_index);
+           rte_eth_promiscuous_enable (xd->port_id);
          else
-           rte_eth_promiscuous_disable (xd->device_index);
+           rte_eth_promiscuous_disable (xd->port_id);
        }
     }
   else if (ETHERNET_INTERFACE_FLAG_CONFIG_MTU (flags))
@@ -254,7 +254,8 @@ dpdk_lib_init (dpdk_main_t * dm)
       vnet_buffer (&ptd->buffer_template)->sw_if_index[VLIB_TX] = (u32) ~ 0;
     }
 
-  for (i = 0; i < nports; i++)
+  /* *INDENT-OFF* */
+  RTE_ETH_FOREACH_DEV(i)
     {
       u8 addr[6];
       u8 vlan_strip = 0;
@@ -507,8 +508,8 @@ dpdk_lib_init (dpdk_main_t * dm)
       if (xd->tx_q_used < tm->n_vlib_mains)
        dpdk_device_lock_init (xd);
 
+      xd->port_id = i;
       xd->device_index = xd - dm->devices;
-      ASSERT (i == xd->device_index);
       xd->per_interface_next_index = ~0;
 
       /* assign interface to input thread */
@@ -621,12 +622,10 @@ dpdk_lib_init (dpdk_main_t * dm)
        {
          int i;
          q = 0;
-         /* *INDENT-OFF* */
          clib_bitmap_foreach (i, devconf->workers, ({
            vnet_hw_interface_assign_rx_thread (dm->vnet_main, xd->hw_if_index, q++,
                                             vdm->first_worker_thread_index + i);
          }));
-         /* *INDENT-ON* */
        }
       else
        for (q = 0; q < xd->rx_q_used; q++)
@@ -684,10 +683,10 @@ dpdk_lib_init (dpdk_main_t * dm)
       if (vlan_strip)
        {
          int vlan_off;
-         vlan_off = rte_eth_dev_get_vlan_offload (xd->device_index);
+         vlan_off = rte_eth_dev_get_vlan_offload (xd->port_id);
          vlan_off |= ETH_VLAN_STRIP_OFFLOAD;
          xd->port_conf.rxmode.hw_vlan_strip = vlan_off;
-         if (rte_eth_dev_set_vlan_offload (xd->device_index, vlan_off) == 0)
+         if (rte_eth_dev_set_vlan_offload (xd->port_id, vlan_off) == 0)
            dpdk_log_info ("VLAN strip enabled for interface\n");
          else
            dpdk_log_warn ("VLAN strip cannot be supported by interface\n");
@@ -702,8 +701,9 @@ dpdk_lib_init (dpdk_main_t * dm)
       if (dm->conf->no_multi_seg)
        mtu = mtu > ETHER_MAX_LEN ? ETHER_MAX_LEN : mtu;
 
-      rte_eth_dev_set_mtu (xd->device_index, mtu);
+      rte_eth_dev_set_mtu (xd->port_id, mtu);
     }
+  /* *INDENT-ON* */
 
   if (nb_desc > dm->conf->num_mbufs)
     dpdk_log_err ("%d mbufs allocated but total rx/tx ring size is %d\n",
@@ -1377,7 +1377,7 @@ dpdk_update_link_state (dpdk_device_t * xd, f64 now)
 
   xd->time_last_link_update = now ? now : xd->time_last_link_update;
   memset (&xd->link, 0, sizeof (xd->link));
-  rte_eth_link_get_nowait (xd->device_index, &xd->link);
+  rte_eth_link_get_nowait (xd->port_id, &xd->link);
 
   if (LINK_STATE_ELOGS)
     {
@@ -1509,6 +1509,7 @@ dpdk_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f)
   dpdk_device_t *xd;
   vlib_thread_main_t *tm = vlib_get_thread_main ();
   int i;
+  int j;
 
   error = dpdk_lib_init (dm);
 
@@ -1535,10 +1536,19 @@ dpdk_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f)
     int nports = rte_eth_dev_count ();
     if (nports > 0)
       {
-       for (i = 0; i < nports; i++)
+       /* *INDENT-OFF* */
+       RTE_ETH_FOREACH_DEV(i)
          {
-           xd = &dm->devices[i];
-           ASSERT (i == xd->device_index);
+           xd = NULL;
+           for (j = 0; j < nports; j++)
+             {
+               if (dm->devices[j].port_id == i)
+                 {
+                   xd = &dm->devices[j];
+                 }
+             }
+           ASSERT (xd != NULL);
+
            if (xd->pmd == VNET_DPDK_PMD_BOND)
              {
                u8 addr[6];
@@ -1625,6 +1635,7 @@ dpdk_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f)
                  }
              }
          }
+       /* *INDENT-ON* */
       }
   }
 
index 7f4b2cb..b4fadf0 100644 (file)
@@ -474,7 +474,7 @@ dpdk_device_input (vlib_main_t * vm, dpdk_main_t * dm, dpdk_device_t * xd,
   /* get up to DPDK_RX_BURST_SZ buffers from PMD */
   while (n_rx_packets < DPDK_RX_BURST_SZ)
     {
-      n = rte_eth_rx_burst (xd->device_index, queue_id,
+      n = rte_eth_rx_burst (xd->port_id, queue_id,
                            ptd->mbufs + n_rx_packets,
                            DPDK_RX_BURST_SZ - n_rx_packets);
       n_rx_packets += n;
index 123ecba..04455c5 100644 (file)
@@ -282,13 +282,13 @@ dpdk_port_setup_hqos (dpdk_device_t * xd, dpdk_device_config_hqos_t * hqos)
       u32 swq_flags = RING_F_SP_ENQ | RING_F_SC_DEQ;
 
       snprintf (name, sizeof (name), "SWQ-worker%u-to-device%u", i,
-               xd->device_index);
+               xd->port_id);
       xd->hqos_ht->swq[i] =
        rte_ring_create (name, hqos->swq_size, xd->cpu_socket, swq_flags);
       if (xd->hqos_ht->swq[i] == NULL)
        return clib_error_return (0,
                                  "SWQ-worker%u-to-device%u: rte_ring_create err",
-                                 i, xd->device_index);
+                                 i, xd->port_id);
     }
 
   /*
@@ -296,19 +296,19 @@ dpdk_port_setup_hqos (dpdk_device_t * xd, dpdk_device_config_hqos_t * hqos)
    */
 
   /* HQoS port */
-  snprintf (name, sizeof (name), "HQoS%u", xd->device_index);
+  snprintf (name, sizeof (name), "HQoS%u", xd->port_id);
   hqos->port.name = strdup (name);
   if (hqos->port.name == NULL)
-    return clib_error_return (0, "HQoS%u: strdup err", xd->device_index);
+    return clib_error_return (0, "HQoS%u: strdup err", xd->port_id);
 
-  hqos->port.socket = rte_eth_dev_socket_id (xd->device_index);
+  hqos->port.socket = rte_eth_dev_socket_id (xd->port_id);
   if (hqos->port.socket == SOCKET_ID_ANY)
     hqos->port.socket = 0;
 
   xd->hqos_ht->hqos = rte_sched_port_config (&hqos->port);
   if (xd->hqos_ht->hqos == NULL)
     return clib_error_return (0, "HQoS%u: rte_sched_port_config err",
-                             xd->device_index);
+                             xd->port_id);
 
   /* HQoS subport */
   for (subport_id = 0; subport_id < hqos->port.n_subports_per_port;
@@ -322,7 +322,7 @@ dpdk_port_setup_hqos (dpdk_device_t * xd, dpdk_device_config_hqos_t * hqos)
       if (rv)
        return clib_error_return (0,
                                  "HQoS%u subport %u: rte_sched_subport_config err (%d)",
-                                 xd->device_index, subport_id, rv);
+                                 xd->port_id, subport_id, rv);
 
       /* HQoS pipe */
       for (pipe_id = 0; pipe_id < hqos->port.n_pipes_per_subport; pipe_id++)
@@ -336,8 +336,7 @@ dpdk_port_setup_hqos (dpdk_device_t * xd, dpdk_device_config_hqos_t * hqos)
          if (rv)
            return clib_error_return (0,
                                      "HQoS%u subport %u pipe %u: rte_sched_pipe_config err (%d)",
-                                     xd->device_index, subport_id, pipe_id,
-                                     rv);
+                                     xd->port_id, subport_id, pipe_id, rv);
        }
     }
 
@@ -411,7 +410,7 @@ dpdk_hqos_thread_internal_hqos_dbg_bypass (vlib_main_t * vm)
       dpdk_device_t *xd = vec_elt_at_index (dm->devices, dq->device);
 
       dpdk_device_hqos_per_hqos_thread_t *hqos = xd->hqos_ht;
-      u32 device_index = xd->device_index;
+      u32 device_index = xd->port_id;
       u16 queue_id = dq->queue_id;
 
       struct rte_mbuf **pkts_enq = hqos->pkts_enq;
@@ -498,7 +497,7 @@ dpdk_hqos_thread_internal (vlib_main_t * vm)
       dpdk_device_t *xd = vec_elt_at_index (dm->devices, dq->device);
 
       dpdk_device_hqos_per_hqos_thread_t *hqos = xd->hqos_ht;
-      u32 device_index = xd->device_index;
+      u32 device_index = xd->port_id;
       u16 queue_id = dq->queue_id;
 
       struct rte_mbuf **pkts_enq = hqos->pkts_enq;