diff mbox series

[v3,05/19] net/dpaa: set the correct frame size in device MTU

Message ID 1515581201-29784-6-git-send-email-hemant.agrawal@nxp.com
State New
Headers show
Series DPAA PMD improvements | expand

Commit Message

Hemant Agrawal Jan. 10, 2018, 10:46 a.m. UTC
From: Ashish Jain <ashish.jain@nxp.com>


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 | 20 +++++++++++++-------
 drivers/net/dpaa/dpaa_ethdev.h |  4 ++++
 2 files changed, 17 insertions(+), 7 deletions(-)

-- 
2.7.4
diff mbox series

Patch

diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 24943ef..5a2ea4f 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -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;
 }
diff --git a/drivers/net/dpaa/dpaa_ethdev.h b/drivers/net/dpaa/dpaa_ethdev.h
index 9c3b42c..548ccff 100644
--- a/drivers/net/dpaa/dpaa_ethdev.h
+++ b/drivers/net/dpaa/dpaa_ethdev.h
@@ -45,6 +45,10 @@ 
 /*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