Fix MTU size for the bonded interface
[vpp.git] / vnet / vnet / devices / dpdk / init.c
index afaaa85..3de33ed 100644 (file)
@@ -833,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)
@@ -858,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;
       }
@@ -1690,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);
@@ -1715,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;
                      }
                  }
              }