dpdk: keep buffer flags per-device 20/34820/2
authorDamjan Marion <damarion@cisco.com>
Tue, 4 Jan 2022 19:07:32 +0000 (20:07 +0100)
committerOle Tr�an <otroan@employees.org>
Wed, 5 Jan 2022 10:48:54 +0000 (10:48 +0000)
Type: improvement
Change-Id: Idb0b079df49c12643c9a93ee0effe011d3489068
Signed-off-by: Damjan Marion <damarion@cisco.com>
src/plugins/dpdk/device/common.c
src/plugins/dpdk/device/dpdk.h
src/plugins/dpdk/device/init.c
src/plugins/dpdk/device/node.c

index b3de5cf..3bd5001 100644 (file)
@@ -147,7 +147,12 @@ dpdk_device_setup (dpdk_device_t * xd)
     goto error;
 
   rte_eth_dev_set_mtu (xd->port_id, hi->max_packet_bytes);
+  xd->buffer_flags =
+    (VLIB_BUFFER_TOTAL_LENGTH_VALID | VLIB_BUFFER_EXT_HDR_VALID);
 
+  if (xd->port_conf.rxmode.offloads & DEV_RX_OFFLOAD_TCP_CKSUM)
+    xd->buffer_flags |=
+      (VNET_BUFFER_F_L4_CHECKSUM_COMPUTED | VNET_BUFFER_F_L4_CHECKSUM_CORRECT);
   if (xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP)
     dpdk_device_start (xd);
 
index 7ead961..362c74b 100644 (file)
@@ -176,6 +176,7 @@ typedef struct
 
   u32 hw_if_index;
   u32 sw_if_index;
+  u32 buffer_flags;
 
   /* next node index if we decide to steal the rx graph arc */
   u32 per_interface_next_index;
@@ -330,14 +331,10 @@ typedef struct
 
 typedef struct
 {
-
   /* Devices */
   dpdk_device_t *devices;
   dpdk_per_thread_data_t *per_thread_data;
 
-  /* buffer flags template, configurable to enable/disable tcp / udp cksum */
-  u32 buffer_flags_template;
-
   /*
    * flag indicating that a posted admin up/down
    * (via post_sw_interface_set_flags) is in progress
index 53fd24b..06fb55e 100644 (file)
@@ -230,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);
@@ -241,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;
     }
 
@@ -1887,12 +1882,6 @@ dpdk_init (vlib_main_t * vm)
 
   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;
 
index 2357e39..9acf594 100644 (file)
@@ -376,6 +376,7 @@ dpdk_device_input (vlib_main_t * vm, dpdk_main_t * dm, dpdk_device_t * xd,
   /* Update buffer template */
   vnet_buffer (bt)->sw_if_index[VLIB_RX] = xd->sw_if_index;
   bt->error = node->errors[DPDK_ERROR_NONE];
+  bt->flags = xd->buffer_flags;
   /* as DPDK is allocating empty buffers from mempool provided before interface
      start for each queue, it is safe to store this in the template */
   bt->buffer_pool_index = rxq->buffer_pool_index;