tap: add support to configure tap interface host MTU size
[vpp.git] / src / vat / api_format.c
index 536c4b0..f107246 100644 (file)
@@ -7300,11 +7300,11 @@ api_bd_ip_mac_add_del (vat_main_t * vam)
 
   M (BD_IP_MAC_ADD_DEL, mp);
 
-  mp->bd_id = ntohl (bd_id);
+  mp->entry.bd_id = ntohl (bd_id);
   mp->is_add = is_add;
 
-  clib_memcpy (&mp->ip, &ip, sizeof (ip));
-  clib_memcpy (&mp->mac, &mac, sizeof (mac));
+  clib_memcpy (&mp->entry.ip, &ip, sizeof (ip));
+  clib_memcpy (&mp->entry.mac, &mac, sizeof (mac));
 
   S (mp);
   W (ret);
@@ -7349,21 +7349,12 @@ static void vl_api_bd_ip_mac_details_t_handler
   (vl_api_bd_ip_mac_details_t * mp)
 {
   vat_main_t *vam = &vat_main;
-  u8 *ip = 0;
-
-  if (!mp->is_ipv6)
-    ip =
-      format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
-  else
-    ip =
-      format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
 
   print (vam->ofp,
-        "\n%-5d %-7s %-20U %-30s",
-        ntohl (mp->bd_id), mp->is_ipv6 ? "ip6" : "ip4",
-        format_ethernet_address, mp->mac_address, ip);
-
-  vec_free (ip);
+        "\n%-5d %U %U",
+        ntohl (mp->entry.bd_id),
+        format_vl_api_mac_address, mp->entry.mac,
+        format_vl_api_address, &mp->entry.ip);
 }
 
 static void vl_api_bd_ip_mac_details_t_handler_json
@@ -7380,19 +7371,13 @@ static void vl_api_bd_ip_mac_details_t_handler_json
   node = vat_json_array_add (&vam->json_tree);
 
   vat_json_init_object (node);
-  vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
-  vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
+  vat_json_object_add_uint (node, "bd_id", ntohl (mp->entry.bd_id));
   vat_json_object_add_string_copy (node, "mac_address",
-                                  format (0, "%U", format_ethernet_address,
-                                          &mp->mac_address));
+                                  format (0, "%U", format_vl_api_mac_address,
+                                          &mp->entry.mac));
   u8 *ip = 0;
 
-  if (!mp->is_ipv6)
-    ip =
-      format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
-  else
-    ip =
-      format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
+  ip = format (0, "%U", format_vl_api_address, &mp->entry.ip);
   vat_json_object_add_string_copy (node, "ip_address", ip);
   vec_free (ip);
 }
@@ -7444,6 +7429,7 @@ api_tap_create_v2 (vat_main_t * vam)
 {
   unformat_input_t *i = vam->input;
   vl_api_tap_create_v2_t *mp;
+#define TAP_FLAG_GSO (1 << 0)
   u8 mac_address[6];
   u8 random_mac = 1;
   u32 id = ~0;
@@ -7460,6 +7446,9 @@ api_tap_create_v2 (vat_main_t * vam)
   ip6_address_t host_ip6_gw;
   u8 host_ip6_gw_set = 0;
   u32 host_ip6_prefix_len = 0;
+  u8 host_mtu_set = 0;
+  u32 host_mtu_size = 0;
+  u32 tap_flags = 0;
   int ret;
   u32 rx_ring_sz = 0, tx_ring_sz = 0;
 
@@ -7499,6 +7488,12 @@ api_tap_create_v2 (vat_main_t * vam)
        ;
       else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
        ;
+      else if (unformat (i, "host-mtu-size %d", &host_mtu_size))
+       host_mtu_set = 1;
+      else if (unformat (i, "no-gso"))
+       tap_flags &= ~TAP_FLAG_GSO;
+      else if (unformat (i, "gso"))
+       tap_flags |= TAP_FLAG_GSO;
       else
        break;
     }
@@ -7548,6 +7543,11 @@ api_tap_create_v2 (vat_main_t * vam)
       errmsg ("tx ring size must be 32768 or lower. ");
       return -99;
     }
+  if (host_mtu_set && (host_mtu_size < 64 || host_mtu_size > 65355))
+    {
+      errmsg ("host MTU size must be in between 64 and 65355. ");
+      return -99;
+    }
 
   /* Construct the API message */
   M (TAP_CREATE_V2, mp);
@@ -7561,6 +7561,9 @@ api_tap_create_v2 (vat_main_t * vam)
   mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
   mp->rx_ring_sz = ntohs (rx_ring_sz);
   mp->tx_ring_sz = ntohs (tx_ring_sz);
+  mp->host_mtu_set = host_mtu_set;
+  mp->host_mtu_size = ntohl (host_mtu_size);
+  mp->tap_flags = ntohl (tap_flags);
 
   if (random_mac == 0)
     clib_memcpy (mp->mac_address, mac_address, 6);
@@ -21858,7 +21861,7 @@ _(l2_flags,                                                             \
 _(bridge_flags,                                                         \
   "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
 _(tap_create_v2,                                                        \
-  "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
+  "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>] [host-mtu-size <mtu>] [gso | no-gso]") \
 _(tap_delete_v2,                                                        \
   "<vpp-if-name> | sw_if_index <id>")                                   \
 _(sw_interface_tap_v2_dump, "")                                         \