dpdk: remove unused flag
[vpp.git] / src / plugins / dpdk / device / init.c
index af96d44..f5eb862 100644 (file)
@@ -204,6 +204,7 @@ dpdk_enable_l4_csum_offload (dpdk_device_t * xd)
 static clib_error_t *
 dpdk_lib_init (dpdk_main_t * dm)
 {
+  vnet_main_t *vnm = vnet_get_main ();
   u32 nports;
   u32 mtu, max_rx_frame;
   int i;
@@ -229,10 +230,6 @@ dpdk_lib_init (dpdk_main_t * dm)
   if (CLIB_DEBUG > 0)
     dpdk_log_notice ("DPDK drivers found %d ports...", nports);
 
-  if (dm->conf->enable_tcp_udp_checksum)
-    dm->buffer_flags_template &= ~(VNET_BUFFER_F_L4_CHECKSUM_CORRECT
-                                  | VNET_BUFFER_F_L4_CHECKSUM_COMPUTED);
-
   /* vlib_buffer_t template */
   vec_validate_aligned (dm->per_thread_data, tm->n_vlib_mains - 1,
                        CLIB_CACHE_LINE_BYTES);
@@ -240,7 +237,6 @@ dpdk_lib_init (dpdk_main_t * dm)
     {
       dpdk_per_thread_data_t *ptd = vec_elt_at_index (dm->per_thread_data, i);
       clib_memset (&ptd->buffer_template, 0, sizeof (vlib_buffer_t));
-      ptd->buffer_template.flags = dm->buffer_flags_template;
       vnet_buffer (&ptd->buffer_template)->sw_if_index[VLIB_TX] = (u32) ~ 0;
     }
 
@@ -248,7 +244,6 @@ dpdk_lib_init (dpdk_main_t * dm)
   RTE_ETH_FOREACH_DEV(i)
     {
       u8 addr[6];
-      int vlan_off;
       struct rte_eth_dev_info dev_info;
       struct rte_pci_device *pci_dev;
       struct rte_vmbus_device *vmbus_dev;
@@ -445,8 +440,6 @@ dpdk_lib_init (dpdk_main_t * dm)
       vec_validate_aligned (xd->rx_queues, xd->rx_q_used - 1,
                            CLIB_CACHE_LINE_BYTES);
 
-      xd->flags |= DPDK_DEVICE_FLAG_PMD;
-
       /* workaround for drivers not setting driver_name */
       if ((!dev_info.driver_name) && (pci_dev))
        dev_info.driver_name = pci_dev->driver->driver.name;
@@ -622,8 +615,11 @@ dpdk_lib_init (dpdk_main_t * dm)
            case VNET_DPDK_PMD_VMXNET3:
              xd->port_type = VNET_DPDK_PORT_TYPE_ETH_1G;
              xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MULTI_SEGS;
-             if (dm->conf->no_tx_checksum_offload == 0)
+             /* TCP csum offload not working although udp might work. Left
+              * disabled for now */
+             if (0 && (dm->conf->no_tx_checksum_offload == 0))
                {
+                 xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
                  xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
                  xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
                  xd->flags |= DPDK_DEVICE_FLAG_TX_OFFLOAD;
@@ -711,10 +707,9 @@ dpdk_lib_init (dpdk_main_t * dm)
       /* assign interface to input thread */
       int q;
 
-      error = ethernet_register_interface
-       (dm->vnet_main, dpdk_device_class.index, xd->device_index,
-        /* ethernet address */ addr,
-        &xd->hw_if_index, dpdk_flag_change);
+      error = ethernet_register_interface (
+       vnm, dpdk_device_class.index, xd->device_index,
+       /* ethernet address */ addr, &xd->hw_if_index, dpdk_flag_change);
       if (error)
        return error;
 
@@ -793,34 +788,33 @@ dpdk_lib_init (dpdk_main_t * dm)
       /*Set port rxmode config */
       xd->port_conf.rxmode.max_rx_pkt_len = max_rx_frame;
 
-      sw = vnet_get_hw_sw_interface (dm->vnet_main, xd->hw_if_index);
+      sw = vnet_get_hw_sw_interface (vnm, xd->hw_if_index);
       xd->sw_if_index = sw->sw_if_index;
-      vnet_hw_if_set_input_node (dm->vnet_main, xd->hw_if_index,
-                                dpdk_input_node.index);
+      vnet_hw_if_set_input_node (vnm, xd->hw_if_index, dpdk_input_node.index);
 
       if (devconf->workers)
        {
-         int i;
+         int j;
          q = 0;
-         clib_bitmap_foreach (i, devconf->workers)  {
+         clib_bitmap_foreach (j, devconf->workers)
+           {
              dpdk_rx_queue_t *rxq = vec_elt_at_index (xd->rx_queues, q);
              rxq->queue_index = vnet_hw_if_register_rx_queue (
-               dm->vnet_main, xd->hw_if_index, q++,
-               vdm->first_worker_thread_index + i);
-         }
+               vnm, xd->hw_if_index, q++, vdm->first_worker_thread_index + j);
+           }
        }
       else
        for (q = 0; q < xd->rx_q_used; q++)
          {
            dpdk_rx_queue_t *rxq = vec_elt_at_index (xd->rx_queues, q);
            rxq->queue_index = vnet_hw_if_register_rx_queue (
-             dm->vnet_main, xd->hw_if_index, q, VNET_HW_IF_RXQ_THREAD_ANY);
+             vnm, xd->hw_if_index, q, VNET_HW_IF_RXQ_THREAD_ANY);
          }
 
-      vnet_hw_if_update_runtime_data (dm->vnet_main, xd->hw_if_index);
+      vnet_hw_if_update_runtime_data (vnm, xd->hw_if_index);
 
       /*Get vnet hardware interface */
-      hi = vnet_get_hw_interface (dm->vnet_main, xd->hw_if_index);
+      hi = vnet_get_hw_interface (vnm, xd->hw_if_index);
 
       /*Override default max_packet_bytes and max_supported_bytes set in
        * ethernet_register_interface() above*/
@@ -833,8 +827,8 @@ dpdk_lib_init (dpdk_main_t * dm)
          /* Indicate ability to support L3 DMAC filtering and
           * initialize interface to L3 non-promisc mode */
          hi->caps |= VNET_HW_INTERFACE_CAP_SUPPORTS_MAC_FILTER;
-         ethernet_set_flags (dm->vnet_main, xd->hw_if_index,
-                            ETHERNET_INTERFACE_FLAG_DEFAULT_L3);
+         ethernet_set_flags (vnm, xd->hw_if_index,
+                             ETHERNET_INTERFACE_FLAG_DEFAULT_L3);
        }
 
       if (dm->conf->no_tx_checksum_offload == 0)
@@ -888,52 +882,6 @@ dpdk_lib_init (dpdk_main_t * dm)
                       format_dpdk_device_name, i,
                       format_dpdk_device_errors, xd);
 
-      /*
-       * A note on Cisco VIC (PMD_ENIC) and VLAN:
-       *
-       * With Cisco VIC vNIC, every ingress packet is tagged. On a
-       * trunk vNIC (C series "standalone" server), packets on no VLAN
-       * are tagged with vlan 0. On an access vNIC (standalone or B
-       * series "blade" server), packets on the default/native VLAN
-       * are tagged with that vNIC's VLAN. VPP expects these packets
-       * to be untagged, and previously enabled VLAN strip on VIC by
-       * default. But it also broke vlan sub-interfaces.
-       *
-       * The VIC adapter has "untag default vlan" ingress VLAN rewrite
-       * mode, which removes tags from these packets. VPP now includes
-       * a local patch for the enic driver to use this untag mode, so
-       * enabling vlan stripping is no longer needed. In future, the
-       * driver + dpdk will have an API to set the mode after
-       * rte_eal_init. Then, this note and local patch will be
-       * removed.
-       */
-
-      /*
-       * VLAN stripping: default to VLAN strip disabled, unless specified
-       * otherwise in the startup config.
-       */
-
-        vlan_off = rte_eth_dev_get_vlan_offload (xd->port_id);
-        if (devconf->vlan_strip_offload == DPDK_DEVICE_VLAN_STRIP_ON)
-          {
-            vlan_off |= ETH_VLAN_STRIP_OFFLOAD;
-            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");
-            xd->port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
-          }
-        else
-          {
-            if (vlan_off & ETH_VLAN_STRIP_OFFLOAD)
-              {
-               vlan_off &= ~ETH_VLAN_STRIP_OFFLOAD;
-               if (rte_eth_dev_set_vlan_offload (xd->port_id, vlan_off) >= 0)
-                 dpdk_log_warn ("set VLAN offload failed\n");
-              }
-            xd->port_conf.rxmode.offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
-          }
-
         if (hi)
           hi->max_packet_bytes = xd->port_conf.rxmode.max_rx_pkt_len
             - sizeof (ethernet_header_t);
@@ -1313,10 +1261,6 @@ dpdk_device_config (dpdk_config_main_t *conf, void *addr,
          if (error)
            break;
        }
-      else if (unformat (input, "vlan-strip-offload off"))
-       devconf->vlan_strip_offload = DPDK_DEVICE_VLAN_STRIP_OFF;
-      else if (unformat (input, "vlan-strip-offload on"))
-       devconf->vlan_strip_offload = DPDK_DEVICE_VLAN_STRIP_ON;
       else if (unformat (input, "tso on"))
        {
          devconf->tso = DPDK_DEVICE_TSO_ON;
@@ -1501,11 +1445,6 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input)
 
          num_whitelisted++;
        }
-      else if (unformat (input, "num-mem-channels %d", &conf->nchannels))
-       conf->nchannels_set_manually = 0;
-      else if (unformat (input, "num-crypto-mbufs %d",
-                        &conf->num_crypto_mbufs))
-       ;
       else if (unformat (input, "uio-driver %s", &conf->uio_driver_name))
        ;
       else if (unformat (input, "socket-mem %s", &socket_mem))
@@ -1581,17 +1520,6 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input)
              vec_add1 (conf->eal_init_args, s);        \
            }
        foreach_eal_single_hyphen_arg
-#undef _
-#define _(a,b)                                         \
-           else if (unformat(input, #a " %s", &s))     \
-             {                                         \
-               tmp = format (0, "-%s%c", #b, 0);       \
-               vec_add1 (conf->eal_init_args, tmp);    \
-               vec_add1 (s, 0);                        \
-               vec_add1 (conf->eal_init_args, s);      \
-               conf->a##_set_manually = 1;             \
-             }
-       foreach_eal_single_hyphen_mandatory_arg
 #undef _
        else if (unformat (input, "default"))
        ;
@@ -1648,38 +1576,6 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input)
   if (error)
     return error;
 
-  /* I'll bet that -c and -n must be the first and second args... */
-  if (!conf->coremask_set_manually)
-    {
-      vlib_thread_registration_t *tr;
-      uword *coremask = 0;
-      int i;
-
-      /* main thread core */
-      coremask = clib_bitmap_set (coremask, tm->main_lcore, 1);
-
-      for (i = 0; i < vec_len (tm->registrations); i++)
-       {
-         tr = tm->registrations[i];
-         coremask = clib_bitmap_or (coremask, tr->coremask);
-       }
-
-      vec_insert (conf->eal_init_args, 2, 1);
-      conf->eal_init_args[1] = (u8 *) "-c";
-      tmp = format (0, "%U%c", format_bitmap_hex, coremask, 0);
-      conf->eal_init_args[2] = tmp;
-      clib_bitmap_free (coremask);
-    }
-
-  if (!conf->nchannels_set_manually)
-    {
-      vec_insert (conf->eal_init_args, 2, 3);
-      conf->eal_init_args[3] = (u8 *) "-n";
-      tmp = format (0, "%d", conf->nchannels);
-      vec_terminate_c_string (tmp);
-      conf->eal_init_args[4] = tmp;
-    }
-
   if (no_pci == 0 && geteuid () == 0)
     dpdk_bind_devices_to_uio (conf);
 
@@ -1690,15 +1586,11 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input)
     if (devconf->x == 0 && conf->default_devconf.x > 0) \
       devconf->x = conf->default_devconf.x ;
 
-  /* *INDENT-OFF* */
   pool_foreach (devconf, conf->dev_confs)  {
 
     /* default per-device config items */
     foreach_dpdk_device_config_item
 
-      /* copy vlan_strip config from default device */
-      _ (vlan_strip_offload)
-
       /* copy tso config from default device */
       _ (tso)
 
@@ -1734,17 +1626,9 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input)
          vec_add1 (conf->eal_init_args, tmp);
     }
   }
-  /* *INDENT-ON* */
 
 #undef _
 
-  /* set master-lcore */
-  tmp = format (0, "--main-lcore%c", 0);
-  vec_add1 (conf->eal_init_args, tmp);
-  tmp = format (0, "%u%c", tm->main_lcore, 0);
-  vec_add1 (conf->eal_init_args, tmp);
-
-
   if (socket_mem)
     clib_warning ("socket-mem argument is deprecated");
 
@@ -1825,10 +1709,6 @@ dpdk_update_link_state (dpdk_device_t * xd, f64 now)
   u32 hw_flags = 0;
   u8 hw_flags_chg = 0;
 
-  /* only update link state for PMD interfaces */
-  if ((xd->flags & DPDK_DEVICE_FLAG_PMD) == 0)
-    return;
-
   xd->time_last_link_update = now ? now : xd->time_last_link_update;
   clib_memset (&xd->link, 0, sizeof (xd->link));
   rte_eth_link_get_nowait (xd->port_id, &xd->link);
@@ -1992,35 +1872,28 @@ dpdk_init (vlib_main_t * vm)
 
   dpdk_cli_reference ();
 
-  dm->vlib_main = vm;
-  dm->vnet_main = vnet_get_main ();
   dm->conf = &dpdk_config_main;
 
-  dm->conf->nchannels = 4;
   vec_add1 (dm->conf->eal_init_args, (u8 *) "vnet");
 
-  /* Default vlib_buffer_t flags, DISABLES tcp/udp checksumming... */
-  dm->buffer_flags_template = (VLIB_BUFFER_TOTAL_LENGTH_VALID |
-                              VLIB_BUFFER_EXT_HDR_VALID |
-                              VNET_BUFFER_F_L4_CHECKSUM_COMPUTED |
-                              VNET_BUFFER_F_L4_CHECKSUM_CORRECT);
-
   dm->stat_poll_interval = DPDK_STATS_POLL_INTERVAL;
   dm->link_state_poll_interval = DPDK_LINK_POLL_INTERVAL;
 
   dm->log_default = vlib_log_register_class ("dpdk", 0);
   dm->log_cryptodev = vlib_log_register_class ("dpdk", "cryptodev");
-  dm->log_ipsec = vlib_log_register_class ("dpdk", "ipsec");
 
   return error;
 }
 
 VLIB_INIT_FUNCTION (dpdk_init);
 
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */
+static clib_error_t *
+dpdk_worker_thread_init (vlib_main_t *vm)
+{
+  if (rte_thread_register () < 0)
+    clib_panic ("dpdk: cannot register thread %u - %s", vm->thread_index,
+               rte_strerror (rte_errno));
+  return 0;
+}
+
+VLIB_WORKER_INIT_FUNCTION (dpdk_worker_thread_init);