gso: remove the interface count

Type: refactor

Change-Id: I51405b9d09fb6fb03d08569369fdd4e11c647908
Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
diff --git a/src/vnet/devices/tap/tap.c b/src/vnet/devices/tap/tap.c
index 288099e..38f0605 100644
--- a/src/vnet/devices/tap/tap.c
+++ b/src/vnet/devices/tap/tap.c
@@ -583,7 +583,6 @@
   if (args->tap_flags & TAP_FLAG_GSO)
     {
       hw->flags |= VNET_HW_INTERFACE_FLAG_SUPPORTS_GSO;
-      vnm->interface_main.gso_interface_count++;
     }
   vnet_hw_interface_set_input_node (vnm, vif->hw_if_index,
 				    virtio_input_node.index);
@@ -640,10 +639,6 @@
   if (vif->type != VIRTIO_IF_TYPE_TAP)
     return VNET_API_ERROR_INVALID_INTERFACE;
 
-  /* decrement if this was a GSO interface */
-  if (hw->flags & VNET_HW_INTERFACE_FLAG_SUPPORTS_GSO)
-    vnm->interface_main.gso_interface_count--;
-
   /* bring down the interface */
   vnet_hw_interface_set_flags (vnm, vif->hw_if_index, 0);
   vnet_sw_interface_set_flags (vnm, vif->sw_if_index, 0);
@@ -683,7 +678,6 @@
     {
       if ((hw->flags & VNET_HW_INTERFACE_FLAG_SUPPORTS_GSO) == 0)
 	{
-	  vnm->interface_main.gso_interface_count++;
 	  hw->flags |= VNET_HW_INTERFACE_FLAG_SUPPORTS_GSO;
 	}
     }
@@ -691,7 +685,6 @@
     {
       if ((hw->flags & VNET_HW_INTERFACE_FLAG_SUPPORTS_GSO) != 0)
 	{
-	  vnm->interface_main.gso_interface_count--;
 	  hw->flags &= ~VNET_HW_INTERFACE_FLAG_SUPPORTS_GSO;
 	}
     }
diff --git a/src/vnet/devices/virtio/device.c b/src/vnet/devices/virtio/device.c
index f9a1677..16d1c80 100644
--- a/src/vnet/devices/virtio/device.c
+++ b/src/vnet/devices/virtio/device.c
@@ -313,9 +313,8 @@
   virtio_main_t *nm = &virtio_main;
   vnet_interface_output_runtime_t *rund = (void *) node->runtime_data;
   virtio_if_t *vif = pool_elt_at_index (nm->interfaces, rund->dev_instance);
-  vnet_main_t *vnm = vnet_get_main ();
 
-  if (vnm->interface_main.gso_interface_count > 0)
+  if (vif->gso_enabled > 0)
     return virtio_interface_tx_inline (vm, node, frame, vif, 1 /* do_gso */ );
   else
     return virtio_interface_tx_inline (vm, node, frame, vif,
diff --git a/src/vnet/devices/virtio/pci.c b/src/vnet/devices/virtio/pci.c
index 5cbf75f..925c6f5 100644
--- a/src/vnet/devices/virtio/pci.c
+++ b/src/vnet/devices/virtio/pci.c
@@ -1207,7 +1207,6 @@
 	    {
 	      vif->gso_enabled = 1;
 	      hw->flags |= VNET_HW_INTERFACE_FLAG_SUPPORTS_GSO;
-	      vnm->interface_main.gso_interface_count++;
 	    }
 	}
       if (vif->features & VIRTIO_FEATURE (VIRTIO_NET_F_MQ))
@@ -1248,9 +1247,6 @@
 
   virtio_pci_legacy_reset (vm, vif);
 
-  if (vif->gso_enabled)
-    vnm->interface_main.gso_interface_count--;
-
   if (vif->hw_if_index)
     {
       vnet_hw_interface_set_flags (vnm, vif->hw_if_index, 0);
diff --git a/src/vnet/devices/virtio/vhost_user_inline.h b/src/vnet/devices/virtio/vhost_user_inline.h
index 8725c96..e4a1d59 100644
--- a/src/vnet/devices/virtio/vhost_user_inline.h
+++ b/src/vnet/devices/virtio/vhost_user_inline.h
@@ -277,20 +277,16 @@
 static_always_inline void
 vhost_user_update_gso_interface_count (vhost_user_intf_t * vui, u8 add)
 {
-  vnet_main_t *vnm = vnet_get_main ();
   vhost_user_main_t *vum = &vhost_user_main;
 
   if (vui->enable_gso)
     {
       if (add)
 	{
-	  vnm->interface_main.gso_interface_count++;
 	  vum->gso_count++;
 	}
       else
 	{
-	  ASSERT (vnm->interface_main.gso_interface_count > 0);
-	  vnm->interface_main.gso_interface_count--;
 	  ASSERT (vum->gso_count > 0);
 	  vum->gso_count--;
 	}
diff --git a/src/vnet/interface.c b/src/vnet/interface.c
index 0b4d78a..51c5d82 100644
--- a/src/vnet/interface.c
+++ b/src/vnet/interface.c
@@ -1341,7 +1341,6 @@
       }
   }
 
-  im->gso_interface_count = 0;
   /* init per-thread data */
   vec_validate_aligned (im->per_thread_data, vlib_num_workers (),
 			CLIB_CACHE_LINE_BYTES);
diff --git a/src/vnet/interface.h b/src/vnet/interface.h
index e6450f5..2bfb8db 100644
--- a/src/vnet/interface.h
+++ b/src/vnet/interface.h
@@ -871,9 +871,6 @@
   /* per-thread data */
   vnet_interface_per_thread_data_t *per_thread_data;
 
-  /* enable GSO processing in packet path if this count is > 0 */
-  u32 gso_interface_count;
-
   /* feature_arc_index */
   u8 output_feature_arc_index;
 } vnet_interface_main_t;
diff --git a/src/vnet/ip/ip4_forward.c b/src/vnet/ip/ip4_forward.c
index a67b061..bb036c8 100644
--- a/src/vnet/ip/ip4_forward.c
+++ b/src/vnet/ip/ip4_forward.c
@@ -2394,8 +2394,7 @@
 ip4_rewrite_inline_with_gso (vlib_main_t * vm,
 			     vlib_node_runtime_t * node,
 			     vlib_frame_t * frame,
-			     int do_counters, int is_midchain, int is_mcast,
-			     int do_gso)
+			     int do_counters, int is_midchain, int is_mcast)
 {
   ip_lookup_main_t *lm = &ip4_main.lookup_main;
   u32 *from = vlib_frame_vector_args (frame);
@@ -2477,9 +2476,9 @@
       u16 ip0_len = clib_net_to_host_u16 (ip0->length);
       u16 ip1_len = clib_net_to_host_u16 (ip1->length);
 
-      if (do_gso && (b[0]->flags & VNET_BUFFER_F_GSO))
+      if (b[0]->flags & VNET_BUFFER_F_GSO)
 	ip0_len = gso_mtu_sz (b[0]);
-      if (do_gso && (b[1]->flags & VNET_BUFFER_F_GSO))
+      if (b[1]->flags & VNET_BUFFER_F_GSO)
 	ip1_len = gso_mtu_sz (b[1]);
 
       ip4_mtu_check (b[0], ip0_len,
@@ -2653,7 +2652,7 @@
       /* Check MTU of outgoing interface. */
       u16 ip0_len = clib_net_to_host_u16 (ip0->length);
 
-      if (do_gso && (b[0]->flags & VNET_BUFFER_F_GSO))
+      if (b[0]->flags & VNET_BUFFER_F_GSO)
 	ip0_len = gso_mtu_sz (b[0]);
 
       ip4_mtu_check (b[0], ip0_len,
@@ -2751,7 +2750,7 @@
 
       /* Check MTU of outgoing interface. */
       u16 ip0_len = clib_net_to_host_u16 (ip0->length);
-      if (do_gso && (b[0]->flags & VNET_BUFFER_F_GSO))
+      if (b[0]->flags & VNET_BUFFER_F_GSO)
 	ip0_len = gso_mtu_sz (b[0]);
 
       ip4_mtu_check (b[0], ip0_len,
@@ -2833,15 +2832,8 @@
 		    vlib_frame_t * frame,
 		    int do_counters, int is_midchain, int is_mcast)
 {
-  vnet_main_t *vnm = vnet_get_main ();
-  if (PREDICT_FALSE (vnm->interface_main.gso_interface_count > 0))
-    return ip4_rewrite_inline_with_gso (vm, node, frame, do_counters,
-					is_midchain, is_mcast,
-					1 /* do_gso */ );
-  else
-    return ip4_rewrite_inline_with_gso (vm, node, frame, do_counters,
-					is_midchain, is_mcast,
-					0 /* no do_gso */ );
+  return ip4_rewrite_inline_with_gso (vm, node, frame, do_counters,
+				      is_midchain, is_mcast);
 }
 
 
diff --git a/src/vnet/ip/ip6_forward.c b/src/vnet/ip/ip6_forward.c
index acf6501..ae7083b 100644
--- a/src/vnet/ip/ip6_forward.c
+++ b/src/vnet/ip/ip6_forward.c
@@ -1680,8 +1680,7 @@
 ip6_rewrite_inline_with_gso (vlib_main_t * vm,
 			     vlib_node_runtime_t * node,
 			     vlib_frame_t * frame,
-			     int do_counters, int is_midchain, int is_mcast,
-			     int do_gso)
+			     int do_counters, int is_midchain, int is_mcast)
 {
   ip_lookup_main_t *lm = &ip6_main.lookup_main;
   u32 *from = vlib_frame_vector_args (frame);
@@ -1833,9 +1832,9 @@
 	  u16 ip1_len =
 	    clib_net_to_host_u16 (ip1->payload_length) +
 	    sizeof (ip6_header_t);
-	  if (do_gso && (p0->flags & VNET_BUFFER_F_GSO))
+	  if (p0->flags & VNET_BUFFER_F_GSO)
 	    ip0_len = gso_mtu_sz (p0);
-	  if (do_gso && (p1->flags & VNET_BUFFER_F_GSO))
+	  if (p1->flags & VNET_BUFFER_F_GSO)
 	    ip1_len = gso_mtu_sz (p1);
 
 
@@ -2010,7 +2009,7 @@
 	  u16 ip0_len =
 	    clib_net_to_host_u16 (ip0->payload_length) +
 	    sizeof (ip6_header_t);
-	  if (do_gso && (p0->flags & VNET_BUFFER_F_GSO))
+	  if (p0->flags & VNET_BUFFER_F_GSO)
 	    ip0_len = gso_mtu_sz (p0);
 
 	  ip6_mtu_check (p0, ip0_len,
@@ -2081,15 +2080,8 @@
 		    vlib_frame_t * frame,
 		    int do_counters, int is_midchain, int is_mcast)
 {
-  vnet_main_t *vnm = vnet_get_main ();
-  if (PREDICT_FALSE (vnm->interface_main.gso_interface_count > 0))
-    return ip6_rewrite_inline_with_gso (vm, node, frame, do_counters,
-					is_midchain, is_mcast,
-					1 /* do_gso */ );
-  else
-    return ip6_rewrite_inline_with_gso (vm, node, frame, do_counters,
-					is_midchain, is_mcast,
-					0 /* no do_gso */ );
+  return ip6_rewrite_inline_with_gso (vm, node, frame, do_counters,
+				      is_midchain, is_mcast);
 }
 
 VLIB_NODE_FN (ip6_rewrite_node) (vlib_main_t * vm,
diff --git a/src/vnet/pg/stream.c b/src/vnet/pg/stream.c
index c4a57ea..f09e9a4 100644
--- a/src/vnet/pg/stream.c
+++ b/src/vnet/pg/stream.c
@@ -217,7 +217,6 @@
       if (gso_enabled)
 	{
 	  hi->flags |= VNET_HW_INTERFACE_FLAG_SUPPORTS_GSO;
-	  vnm->interface_main.gso_interface_count++;
 	  pi->gso_enabled = 1;
 	  pi->gso_size = gso_size;
 	}