Skip to content

Commit a64494a

Browse files
Hariprasad Kelamkuba-moo
authored andcommitted
Octeontx2-vf: Fix max packet length errors
Once driver submits the packets to the hardware, each packet traverse through multiple transmit levels in the following order: SMQ -> TL4 -> TL3 -> TL2 -> TL1 The SMQ supports configurable minimum and maximum packet sizes. It enters to a hang state, if driver submits packets with out of bound lengths. To avoid the same, implement packet length validation before submitting packets to the hardware. Increment tx_dropped counter on failure. Fixes: 3184fb5 ("octeontx2-vf: Virtual function driver support") Fixes: 22f8587 ("octeontx2-pf: Add basic net_device_ops") Fixes: 3ca6c4c ("octeontx2-pf: Add packet transmission support") Signed-off-by: Hariprasad Kelam <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent abadf0f commit a64494a

File tree

6 files changed

+30
-2
lines changed

6 files changed

+30
-2
lines changed

drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ void otx2_get_dev_stats(struct otx2_nic *pfvf)
124124
dev_stats->rx_ucast_frames;
125125

126126
dev_stats->tx_bytes = OTX2_GET_TX_STATS(TX_OCTS);
127-
dev_stats->tx_drops = OTX2_GET_TX_STATS(TX_DROP);
127+
dev_stats->tx_drops = OTX2_GET_TX_STATS(TX_DROP) +
128+
(unsigned long)atomic_long_read(&dev_stats->tx_discards);
129+
128130
dev_stats->tx_bcast_frames = OTX2_GET_TX_STATS(TX_BCAST);
129131
dev_stats->tx_mcast_frames = OTX2_GET_TX_STATS(TX_MCAST);
130132
dev_stats->tx_ucast_frames = OTX2_GET_TX_STATS(TX_UCAST);

drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ struct otx2_dev_stats {
153153
u64 tx_bcast_frames;
154154
u64 tx_mcast_frames;
155155
u64 tx_drops;
156+
atomic_long_t tx_discards;
156157
};
157158

158159
/* Driver counted stats */

drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2220,6 +2220,7 @@ static netdev_tx_t otx2_xmit(struct sk_buff *skb, struct net_device *netdev)
22202220
{
22212221
struct otx2_nic *pf = netdev_priv(netdev);
22222222
int qidx = skb_get_queue_mapping(skb);
2223+
struct otx2_dev_stats *dev_stats;
22232224
struct otx2_snd_queue *sq;
22242225
struct netdev_queue *txq;
22252226
int sq_idx;
@@ -2232,6 +2233,8 @@ static netdev_tx_t otx2_xmit(struct sk_buff *skb, struct net_device *netdev)
22322233
/* Check for minimum and maximum packet length */
22332234
if (skb->len <= ETH_HLEN ||
22342235
(!skb_shinfo(skb)->gso_size && skb->len > pf->tx_max_pktlen)) {
2236+
dev_stats = &pf->hw.dev_stats;
2237+
atomic_long_inc(&dev_stats->tx_discards);
22352238
dev_kfree_skb(skb);
22362239
return NETDEV_TX_OK;
22372240
}

drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,19 @@ static netdev_tx_t otx2vf_xmit(struct sk_buff *skb, struct net_device *netdev)
417417
{
418418
struct otx2_nic *vf = netdev_priv(netdev);
419419
int qidx = skb_get_queue_mapping(skb);
420+
struct otx2_dev_stats *dev_stats;
420421
struct otx2_snd_queue *sq;
421422
struct netdev_queue *txq;
422423

424+
/* Check for minimum and maximum packet length */
425+
if (skb->len <= ETH_HLEN ||
426+
(!skb_shinfo(skb)->gso_size && skb->len > vf->tx_max_pktlen)) {
427+
dev_stats = &vf->hw.dev_stats;
428+
atomic_long_inc(&dev_stats->tx_discards);
429+
dev_kfree_skb(skb);
430+
return NETDEV_TX_OK;
431+
}
432+
423433
sq = &vf->qset.sq[qidx];
424434
txq = netdev_get_tx_queue(netdev, qidx);
425435

drivers/net/ethernet/marvell/octeontx2/nic/rep.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,8 @@ static void rvu_rep_get_stats(struct work_struct *work)
371371
stats->rx_mcast_frames = rsp->rx.mcast;
372372
stats->tx_bytes = rsp->tx.octs;
373373
stats->tx_frames = rsp->tx.ucast + rsp->tx.bcast + rsp->tx.mcast;
374-
stats->tx_drops = rsp->tx.drop;
374+
stats->tx_drops = rsp->tx.drop +
375+
(unsigned long)atomic_long_read(&stats->tx_discards);
375376
exit:
376377
mutex_unlock(&priv->mbox.lock);
377378
}
@@ -418,6 +419,16 @@ static netdev_tx_t rvu_rep_xmit(struct sk_buff *skb, struct net_device *dev)
418419
struct otx2_nic *pf = rep->mdev;
419420
struct otx2_snd_queue *sq;
420421
struct netdev_queue *txq;
422+
struct rep_stats *stats;
423+
424+
/* Check for minimum and maximum packet length */
425+
if (skb->len <= ETH_HLEN ||
426+
(!skb_shinfo(skb)->gso_size && skb->len > pf->tx_max_pktlen)) {
427+
stats = &rep->stats;
428+
atomic_long_inc(&stats->tx_discards);
429+
dev_kfree_skb(skb);
430+
return NETDEV_TX_OK;
431+
}
421432

422433
sq = &pf->qset.sq[rep->rep_id];
423434
txq = netdev_get_tx_queue(dev, 0);

drivers/net/ethernet/marvell/octeontx2/nic/rep.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ struct rep_stats {
2727
u64 tx_bytes;
2828
u64 tx_frames;
2929
u64 tx_drops;
30+
atomic_long_t tx_discards;
3031
};
3132

3233
struct rep_dev {

0 commit comments

Comments
 (0)