Fix MTU size for the bonded interface
[vpp.git] / vnet / vnet / devices / dpdk / init.c
index 705c037..3de33ed 100644 (file)
@@ -71,7 +71,7 @@ dpdk_port_setup (dpdk_main_t * dm, dpdk_device_t * xd)
 
   ASSERT (os_get_cpu_number () == 0);
 
-  if (xd->admin_up)
+  if (xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP)
     {
       vnet_hw_interface_set_flags (dm->vnet_main, xd->vlib_hw_if_index, 0);
       rte_eth_dev_stop (xd->device_index);
@@ -123,7 +123,7 @@ dpdk_port_setup (dpdk_main_t * dm, dpdk_device_t * xd)
                                  xd->device_index, rv);
     }
 
-  if (xd->admin_up)
+  if (xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP)
     {
       int rv;
       rv = rte_eth_dev_start (xd->device_index);
@@ -143,12 +143,16 @@ dpdk_flag_change (vnet_main_t * vnm, vnet_hw_interface_t * hi, u32 flags)
 
   if (ETHERNET_INTERFACE_FLAG_CONFIG_PROMISC (flags))
     {
-      old = xd->promisc;
-      xd->promisc = flags & ETHERNET_INTERFACE_FLAG_ACCEPT_ALL;
+      old = (xd->flags & DPDK_DEVICE_FLAG_PROMISC) != 0;
 
-      if (xd->admin_up)
+      if (flags & ETHERNET_INTERFACE_FLAG_ACCEPT_ALL)
+       xd->flags |= DPDK_DEVICE_FLAG_PROMISC;
+      else
+       xd->flags &= ~DPDK_DEVICE_FLAG_PROMISC;
+
+      if (xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP)
        {
-         if (xd->promisc)
+         if (xd->flags & DPDK_DEVICE_FLAG_PROMISC)
            rte_eth_promiscuous_enable (xd->device_index);
          else
            rte_eth_promiscuous_disable (xd->device_index);
@@ -181,7 +185,7 @@ dpdk_flag_change (vnet_main_t * vnm, vnet_hw_interface_t * hi, u32 flags)
 
          xd->port_conf.rxmode.max_rx_pkt_len = hi->max_packet_bytes;
 
-         if (xd->admin_up)
+         if (xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP)
            rte_eth_dev_stop (xd->device_index);
 
          rv = rte_eth_dev_configure
@@ -194,7 +198,7 @@ dpdk_flag_change (vnet_main_t * vnm, vnet_hw_interface_t * hi, u32 flags)
 
          rte_eth_dev_set_mtu (xd->device_index, hi->max_packet_bytes);
 
-         if (xd->admin_up)
+         if (xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP)
            {
              int rv = rte_eth_dev_start (xd->device_index);
              if (rv < 0)
@@ -829,18 +833,16 @@ dpdk_bind_devices_to_uio (dpdk_config_main_t * conf)
   vlib_pci_main_t *pm = &pci_main;
   clib_error_t *error;
   vlib_pci_device_t *d;
-  pci_config_header_t *c;
   u8 *pci_addr = 0;
   int num_whitelisted = vec_len (conf->dev_confs);
 
   /* *INDENT-OFF* */
   pool_foreach (d, pm->pci_devs, ({
     dpdk_device_config_t * devconf = 0;
-    c = &d->config0.header;
     vec_reset_length (pci_addr);
     pci_addr = format (pci_addr, "%U%c", format_vlib_pci_addr, &d->bus_address, 0);
 
-    if (c->device_class != PCI_CLASS_NETWORK_ETHERNET)
+    if (d->device_class != PCI_CLASS_NETWORK_ETHERNET)
       continue;
 
     if (num_whitelisted)
@@ -854,24 +856,24 @@ dpdk_bind_devices_to_uio (dpdk_config_main_t * conf)
       }
 
     /* virtio */
-    if (c->vendor_id == 0x1af4 && c->device_id == 0x1000)
+    if (d->vendor_id == 0x1af4 && d->device_id == 0x1000)
       ;
     /* vmxnet3 */
-    else if (c->vendor_id == 0x15ad && c->device_id == 0x07b0)
+    else if (d->vendor_id == 0x15ad && d->device_id == 0x07b0)
       ;
     /* all Intel devices */
-    else if (c->vendor_id == 0x8086)
+    else if (d->vendor_id == 0x8086)
       ;
     /* Cisco VIC */
-    else if (c->vendor_id == 0x1137 && c->device_id == 0x0043)
+    else if (d->vendor_id == 0x1137 && d->device_id == 0x0043)
       ;
     /* Chelsio T4/T5 */
-    else if (c->vendor_id == 0x1425 && (c->device_id & 0xe000) == 0x4000)
+    else if (d->vendor_id == 0x1425 && (d->device_id & 0xe000) == 0x4000)
       ;
     else
       {
         clib_warning ("Unsupported Ethernet PCI device 0x%04x:0x%04x found "
-                     "at PCI address %s\n", (u16) c->vendor_id, (u16) c->device_id,
+                     "at PCI address %s\n", (u16) d->vendor_id, (u16) d->device_id,
                      pci_addr);
         continue;
       }
@@ -1479,13 +1481,13 @@ dpdk_update_link_state (dpdk_device_t * xd, f64 now)
       } *ed;
       ed = ELOG_DATA (&vm->elog_main, e);
       ed->sw_if_index = xd->vlib_sw_if_index;
-      ed->admin_up = xd->admin_up;
+      ed->admin_up = (xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP) != 0;
       ed->old_link_state = (u8)
        vnet_hw_interface_is_link_up (vnm, xd->vlib_hw_if_index);
       ed->new_link_state = (u8) xd->link.link_status;
     }
 
-  if ((xd->admin_up == 1) &&
+  if ((xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP) &&
       ((xd->link.link_status != 0) ^
        vnet_hw_interface_is_link_up (vnm, xd->vlib_hw_if_index)))
     {
@@ -1686,6 +1688,7 @@ dpdk_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f)
                    clib_memcpy (bhi->hw_address, addr, 6);
                    clib_memcpy (bei->address, addr, 6);
                    /* Init l3 packet size allowed on bonded interface */
+                   bhi->max_packet_bytes = ETHERNET_MAX_PACKET_BYTES;
                    bhi->max_l3_packet_bytes[VLIB_RX] =
                      bhi->max_l3_packet_bytes[VLIB_TX] =
                      ETHERNET_MAX_PACKET_BYTES - sizeof (ethernet_header_t);
@@ -1711,6 +1714,17 @@ dpdk_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f)
                          vnet_get_sw_interface (vnm, sdev->vlib_sw_if_index);
                        shi->bond_info = VNET_HW_INTERFACE_BOND_INFO_SLAVE;
                        ssi->flags |= VNET_SW_INTERFACE_FLAG_BOND_SLAVE;
+
+                       /* Set l3 packet size allowed as the lowest of slave */
+                       if (bhi->max_l3_packet_bytes[VLIB_RX] >
+                           shi->max_l3_packet_bytes[VLIB_RX])
+                         bhi->max_l3_packet_bytes[VLIB_RX] =
+                           bhi->max_l3_packet_bytes[VLIB_TX] =
+                           shi->max_l3_packet_bytes[VLIB_RX];
+
+                       /* Set max packet size allowed as the lowest of slave */
+                       if (bhi->max_packet_bytes > shi->max_packet_bytes)
+                         bhi->max_packet_bytes = shi->max_packet_bytes;
                      }
                  }
              }