+ /*
+ * Ensure default mtu is not > the mtu read from the hardware.
+ * Otherwise rte_eth_dev_configure() will fail and the port will
+ * not be available.
+ * Calculate max_frame_size and mtu supported by NIC
+ */
+ 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.
+ */
+ max_rx_frame = dev_info.max_rx_pktlen;
+ mtu = dev_info.max_rx_pktlen - sizeof (ethernet_header_t);
+ }
+ else
+ {
+ /* VPP treats MTU and max_rx_pktlen both equal to
+ * ETHERNET_MAX_PACKET_BYTES, if dev_info.max_rx_pktlen >=
+ * ETHERNET_MAX_PACKET_BYTES + sizeof(ethernet_header_t)
+ */
+ if (dev_info.max_rx_pktlen >= (ETHERNET_MAX_PACKET_BYTES +
+ sizeof (ethernet_header_t)))
+ {
+ mtu = ETHERNET_MAX_PACKET_BYTES;
+ max_rx_frame = 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 (dpdk_port_crc_strip_enabled (xd) &&
+ (dev_info.max_rx_pktlen >= (ETHERNET_MAX_PACKET_BYTES +
+ sizeof (ethernet_header_t) +
+ 4)))
+ {
+ max_rx_frame += 4;
+ }
+ }
+ else
+ {
+ max_rx_frame = ETHERNET_MAX_PACKET_BYTES;
+ mtu = ETHERNET_MAX_PACKET_BYTES - sizeof (ethernet_header_t);
+
+ if (dpdk_port_crc_strip_enabled (xd) &&
+ (dev_info.max_rx_pktlen >= (ETHERNET_MAX_PACKET_BYTES + 4)))
+ {
+ max_rx_frame += 4;
+ }
+ }
+ }
+
+ if (xd->pmd == VNET_DPDK_PMD_FAILSAFE)
+ {
+ /* failsafe device numerables are reported with active device only,
+ * need to query the mtu for current device setup to overwrite
+ * reported value.
+ */
+ uint16_t dev_mtu;
+ if (!rte_eth_dev_get_mtu (i, &dev_mtu))
+ {
+ mtu = dev_mtu;
+ max_rx_frame = mtu + sizeof (ethernet_header_t);
+
+ if (dpdk_port_crc_strip_enabled (xd))
+ {
+ max_rx_frame += 4;
+ }
+ }
+ }
+
+ /*Set port rxmode config */
+ xd->port_conf.rxmode.max_rx_pkt_len = max_rx_frame;
+