* [net PatchV2] Octeontx2-vf: Fix max packet length errors
@ 2025-07-15 11:13 Hariprasad Kelam
2025-07-15 16:12 ` Simon Horman
2025-07-16 23:24 ` Jakub Kicinski
0 siblings, 2 replies; 3+ messages in thread
From: Hariprasad Kelam @ 2025-07-15 11:13 UTC (permalink / raw)
To: netdev, linux-kernel
Cc: Hariprasad Kelam, Sunil Goutham, Geetha sowjanya,
Subbaraya Sundeep, Bharat Bhushan, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Tomasz Duszynski,
Simon Horman
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@marvell.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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [net PatchV2] Octeontx2-vf: Fix max packet length errors
2025-07-15 11:13 [net PatchV2] Octeontx2-vf: Fix max packet length errors Hariprasad Kelam
@ 2025-07-15 16:12 ` Simon Horman
2025-07-16 23:24 ` Jakub Kicinski
1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2025-07-15 16:12 UTC (permalink / raw)
To: Hariprasad Kelam
Cc: netdev, linux-kernel, Sunil Goutham, Geetha sowjanya,
Subbaraya Sundeep, Bharat Bhushan, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Tomasz Duszynski
On Tue, Jul 15, 2025 at 04:43:51PM +0530, Hariprasad Kelam wrote:
> 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@marvell.com>
> ---
> v2 * Add the packet length check for rep dev
> Increment tx_dropped counter on failure
Thanks for the update.
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [net PatchV2] Octeontx2-vf: Fix max packet length errors
2025-07-15 11:13 [net PatchV2] Octeontx2-vf: Fix max packet length errors Hariprasad Kelam
2025-07-15 16:12 ` Simon Horman
@ 2025-07-16 23:24 ` Jakub Kicinski
1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2025-07-16 23:24 UTC (permalink / raw)
To: Hariprasad Kelam
Cc: netdev, linux-kernel, Sunil Goutham, Geetha sowjanya,
Subbaraya Sundeep, Bharat Bhushan, Andrew Lunn, David S. Miller,
Eric Dumazet, Paolo Abeni, Tomasz Duszynski, Simon Horman
On Tue, 15 Jul 2025 16:43:51 +0530 Hariprasad Kelam wrote:
> + 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;
Please don't add new uses of netdev->stats.
struct net_device_stats stats; /* not used by modern drivers */
--
pw-bot: cr
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-07-16 23:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-15 11:13 [net PatchV2] Octeontx2-vf: Fix max packet length errors Hariprasad Kelam
2025-07-15 16:12 ` Simon Horman
2025-07-16 23:24 ` Jakub Kicinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).