Increment MRU if hardware supports CRC stripping 26/626/2
authorJurek Matuszewski <jurekm@cisco.com>
Mon, 28 Mar 2016 19:15:15 +0000 (15:15 -0400)
committerGerrit Code Review <gerrit@fd.io>
Tue, 29 Mar 2016 08:59:46 +0000 (08:59 +0000)
Change-Id: I46bd007c3c75e5fb872c1beba557e6140fa8d715
Signed-off-by: Todd Foggoa (tfoggoa) <tfoggoa@cisco.com>
vnet/vnet/devices/dpdk/init.c

index 8bb253a..d57f6c1 100644 (file)
@@ -472,9 +472,33 @@ dpdk_lib_init (dpdk_main_t * dm)
        * Otherwise rte_eth_dev_configure() will fail and the port will
        * not be available.
        */
-      xd->port_conf.rxmode.max_rx_pkt_len = 
-             (ETHERNET_MAX_PACKET_BYTES > dev_info.max_rx_pktlen) ? 
-             dev_info.max_rx_pktlen : ETHERNET_MAX_PACKET_BYTES;
+      if (ETHERNET_MAX_PACKET_BYTES > dev_info.max_rx_pktlen)
+        {
+          /*
+           * This device does not support the platforms's max frame
+           * size. Use it's advertised mru instead.
+           */
+          xd->port_conf.rxmode.max_rx_pkt_len = dev_info.max_rx_pktlen;
+        }
+      else
+        {
+          xd->port_conf.rxmode.max_rx_pkt_len = ETHERNET_MAX_PACKET_BYTES;
+
+          /*
+           * Some platforms do not account for Ethernet FCS (4 bytes) in
+           * MTU calculations. To interop with them increase mru but only
+           * if the device's settings can support it.
+           */
+          if ((dev_info.max_rx_pktlen >= (ETHERNET_MAX_PACKET_BYTES + 4)) &&
+              xd->port_conf.rxmode.hw_strip_crc)
+            {
+              /*
+               * Allow additional 4 bytes (for Ethernet FCS). These bytes are
+               * stripped by h/w and so will not consume any buffer memory.
+               */
+              xd->port_conf.rxmode.max_rx_pkt_len += 4;
+            }
+        }
 
       /*
        * DAW-FIXME: VMXNET3 driver doesn't support jumbo / multi-buffer pkts