net/dpaa: set the correct frame size in device MTU
authorAshish Jain <ashish.jain@nxp.com>
Wed, 10 Jan 2018 10:46:27 +0000 (16:16 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 16 Jan 2018 17:47:49 +0000 (18:47 +0100)
Setting correct frame size in dpaa_dev_mtu_set
api call. Also setting correct max frame size in
hardware in dev_configure for jumbo frames

Signed-off-by: Ashish Jain <ashish.jain@nxp.com>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
drivers/net/dpaa/dpaa_ethdev.c
drivers/net/dpaa/dpaa_ethdev.h

index 24943ef..5a2ea4f 100644 (file)
@@ -85,19 +85,21 @@ static int
 dpaa_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
 {
        struct dpaa_if *dpaa_intf = dev->data->dev_private;
+       uint32_t frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN
+                               + VLAN_TAG_SIZE;
 
        PMD_INIT_FUNC_TRACE();
 
-       if (mtu < ETHER_MIN_MTU)
+       if (mtu < ETHER_MIN_MTU || frame_size > DPAA_MAX_RX_PKT_LEN)
                return -EINVAL;
-       if (mtu > ETHER_MAX_LEN)
+       if (frame_size > ETHER_MAX_LEN)
                dev->data->dev_conf.rxmode.jumbo_frame = 1;
        else
                dev->data->dev_conf.rxmode.jumbo_frame = 0;
 
-       dev->data->dev_conf.rxmode.max_rx_pkt_len = mtu;
+       dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
 
-       fman_if_set_maxfrm(dpaa_intf->fif, mtu);
+       fman_if_set_maxfrm(dpaa_intf->fif, frame_size);
 
        return 0;
 }
@@ -105,15 +107,19 @@ dpaa_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
 static int
 dpaa_eth_dev_configure(struct rte_eth_dev *dev __rte_unused)
 {
+       struct dpaa_if *dpaa_intf = dev->data->dev_private;
+
        PMD_INIT_FUNC_TRACE();
 
        if (dev->data->dev_conf.rxmode.jumbo_frame == 1) {
                if (dev->data->dev_conf.rxmode.max_rx_pkt_len <=
-                   DPAA_MAX_RX_PKT_LEN)
-                       return dpaa_mtu_set(dev,
+                   DPAA_MAX_RX_PKT_LEN) {
+                       fman_if_set_maxfrm(dpaa_intf->fif,
                                dev->data->dev_conf.rxmode.max_rx_pkt_len);
-               else
+                       return 0;
+               } else {
                        return -1;
+               }
        }
        return 0;
 }
index 9c3b42c..548ccff 100644 (file)
 /*Maximum number of slots available in TX ring*/
 #define MAX_TX_RING_SLOTS      8
 
+#ifndef VLAN_TAG_SIZE
+#define VLAN_TAG_SIZE   4 /** < Vlan Header Length */
+#endif
+
 /* PCD frame queues */
 #define DPAA_PCD_FQID_START            0x400
 #define DPAA_PCD_FQID_MULTIPLIER       0x100