[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250715111351.1440171-1-hkelam@marvell.com>
Date: Tue, 15 Jul 2025 16:43:51 +0530
From: Hariprasad Kelam <hkelam@...vell.com>
To: <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>
CC: Hariprasad Kelam <hkelam@...vell.com>,
Sunil Goutham
<sgoutham@...vell.com>,
Geetha sowjanya <gakula@...vell.com>,
"Subbaraya
Sundeep" <sbhatta@...vell.com>,
Bharat Bhushan <bbhushan2@...vell.com>,
"Andrew Lunn" <andrew+netdev@...n.ch>,
"David S. Miller"
<davem@...emloft.net>,
"Eric Dumazet" <edumazet@...gle.com>,
Jakub Kicinski
<kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Tomasz Duszynski
<tduszynski@...vell.com>,
Simon Horman <horms@...nel.org>
Subject: [net PatchV2] Octeontx2-vf: Fix max packet length errors
Implement packet length validation before submitting packets to
the hardware to prevent MAXLEN_ERR. Increment tx_dropped counter
on failure.
Fixes: 3184fb5ba96e ("octeontx2-vf: Virtual function driver support")
Fixes: 22f858796758 ("octeontx2-pf: Add basic net_device_ops")
Fixes: 3ca6c4c882a7 ("octeontx2-pf: Add packet transmission support")
Signed-off-by: Hariprasad Kelam <hkelam@...vell.com>
---
v2 * Add the packet length check for rep dev
Increment tx_dropped counter on failure
.../net/ethernet/marvell/octeontx2/nic/otx2_common.c | 4 +++-
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 1 +
drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c | 8 ++++++++
drivers/net/ethernet/marvell/octeontx2/nic/rep.c | 11 ++++++++++-
4 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
index 6b5c9536d26d..c5beb6e61b56 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
@@ -139,6 +139,8 @@ void otx2_get_stats64(struct net_device *netdev,
struct otx2_nic *pfvf = netdev_priv(netdev);
struct otx2_dev_stats *dev_stats;
+ netdev_stats_to_stats64(stats, &netdev->stats);
+
otx2_get_dev_stats(pfvf);
dev_stats = &pfvf->hw.dev_stats;
@@ -149,7 +151,7 @@ void otx2_get_stats64(struct net_device *netdev,
stats->tx_bytes = dev_stats->tx_bytes;
stats->tx_packets = dev_stats->tx_frames;
- stats->tx_dropped = dev_stats->tx_drops;
+ stats->tx_dropped += dev_stats->tx_drops;
}
EXPORT_SYMBOL(otx2_get_stats64);
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
index db7c466fdc39..8a93868b86bf 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
@@ -2165,6 +2165,7 @@ static netdev_tx_t otx2_xmit(struct sk_buff *skb, struct net_device *netdev)
/* Check for minimum and maximum packet length */
if (skb->len <= ETH_HLEN ||
(!skb_shinfo(skb)->gso_size && skb->len > pf->tx_max_pktlen)) {
+ netdev->stats.tx_dropped++;
dev_kfree_skb(skb);
return NETDEV_TX_OK;
}
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c
index 8a8b598bd389..f9e15f389ad6 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c
@@ -394,6 +394,14 @@ static netdev_tx_t otx2vf_xmit(struct sk_buff *skb, struct net_device *netdev)
struct otx2_snd_queue *sq;
struct netdev_queue *txq;
+ /* Check for minimum and maximum packet length */
+ if (skb->len <= ETH_HLEN ||
+ (!skb_shinfo(skb)->gso_size && skb->len > vf->tx_max_pktlen)) {
+ netdev->stats.tx_dropped++;
+ dev_kfree_skb(skb);
+ return NETDEV_TX_OK;
+ }
+
sq = &vf->qset.sq[qidx];
txq = netdev_get_tx_queue(netdev, qidx);
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
index 2cd3da3b6843..a96545f9654e 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
@@ -384,6 +384,7 @@ static void rvu_rep_get_stats64(struct net_device *dev,
if (!(rep->flags & RVU_REP_VF_INITIALIZED))
return;
+ netdev_stats_to_stats64(stats, &dev->stats);
stats->rx_packets = rep->stats.rx_frames;
stats->rx_bytes = rep->stats.rx_bytes;
stats->rx_dropped = rep->stats.rx_drops;
@@ -391,7 +392,7 @@ static void rvu_rep_get_stats64(struct net_device *dev,
stats->tx_packets = rep->stats.tx_frames;
stats->tx_bytes = rep->stats.tx_bytes;
- stats->tx_dropped = rep->stats.tx_drops;
+ stats->tx_dropped += rep->stats.tx_drops;
schedule_delayed_work(&rep->stats_wrk, msecs_to_jiffies(100));
}
@@ -419,6 +420,14 @@ static netdev_tx_t rvu_rep_xmit(struct sk_buff *skb, struct net_device *dev)
struct otx2_snd_queue *sq;
struct netdev_queue *txq;
+ /* Check for minimum and maximum packet length */
+ if (skb->len <= ETH_HLEN ||
+ (!skb_shinfo(skb)->gso_size && skb->len > pf->tx_max_pktlen)) {
+ dev->stats.tx_dropped++;
+ dev_kfree_skb(skb);
+ return NETDEV_TX_OK;
+ }
+
sq = &pf->qset.sq[rep->rep_id];
txq = netdev_get_tx_queue(dev, 0);
--
2.34.1
Powered by blists - more mailing lists