Skip to content

Commit 3423ca2

Browse files
Geetha sowjanyadavem330
authored andcommitted
octeontx2-pf: Free pending and dropped SQEs
On interface down, the pending SQEs in the NIX get dropped or drained out during SMQ flush. But skb's pointed by these SQEs never get free or updated to the stack as respective CQE never get added. This patch fixes the issue by freeing all valid skb's in SQ SG list. Fixes: b1bc845 ("octeontx2-pf: Cleanup all receive buffers in SG descriptor") Signed-off-by: Geetha sowjanya <gakula@marvell.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 40cb2fd commit 3423ca2

File tree

4 files changed

+49
-10
lines changed

4 files changed

+49
-10
lines changed

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

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,6 @@ void otx2_sqb_flush(struct otx2_nic *pfvf)
818818
int qidx, sqe_tail, sqe_head;
819819
struct otx2_snd_queue *sq;
820820
u64 incr, *ptr, val;
821-
int timeout = 1000;
822821

823822
ptr = (u64 *)otx2_get_regaddr(pfvf, NIX_LF_SQ_OP_STATUS);
824823
for (qidx = 0; qidx < otx2_get_total_tx_queues(pfvf); qidx++) {
@@ -827,15 +826,11 @@ void otx2_sqb_flush(struct otx2_nic *pfvf)
827826
continue;
828827

829828
incr = (u64)qidx << 32;
830-
while (timeout) {
831-
val = otx2_atomic64_add(incr, ptr);
832-
sqe_head = (val >> 20) & 0x3F;
833-
sqe_tail = (val >> 28) & 0x3F;
834-
if (sqe_head == sqe_tail)
835-
break;
836-
usleep_range(1, 3);
837-
timeout--;
838-
}
829+
val = otx2_atomic64_add(incr, ptr);
830+
sqe_head = (val >> 20) & 0x3F;
831+
sqe_tail = (val >> 28) & 0x3F;
832+
if (sqe_head != sqe_tail)
833+
usleep_range(50, 60);
839834
}
840835
}
841836

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,7 @@ int otx2_txschq_config(struct otx2_nic *pfvf, int lvl, int prio, bool pfc_en);
977977
int otx2_txsch_alloc(struct otx2_nic *pfvf);
978978
void otx2_txschq_stop(struct otx2_nic *pfvf);
979979
void otx2_txschq_free_one(struct otx2_nic *pfvf, u16 lvl, u16 schq);
980+
void otx2_free_pending_sqe(struct otx2_nic *pfvf);
980981
void otx2_sqb_flush(struct otx2_nic *pfvf);
981982
int otx2_alloc_rbuf(struct otx2_nic *pfvf, struct otx2_pool *pool,
982983
dma_addr_t *dma);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,6 +1601,7 @@ static void otx2_free_hw_resources(struct otx2_nic *pf)
16011601
else
16021602
otx2_cleanup_tx_cqes(pf, cq);
16031603
}
1604+
otx2_free_pending_sqe(pf);
16041605

16051606
otx2_free_sq_res(pf);
16061607

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,9 +1247,11 @@ void otx2_cleanup_rx_cqes(struct otx2_nic *pfvf, struct otx2_cq_queue *cq, int q
12471247

12481248
void otx2_cleanup_tx_cqes(struct otx2_nic *pfvf, struct otx2_cq_queue *cq)
12491249
{
1250+
int tx_pkts = 0, tx_bytes = 0;
12501251
struct sk_buff *skb = NULL;
12511252
struct otx2_snd_queue *sq;
12521253
struct nix_cqe_tx_s *cqe;
1254+
struct netdev_queue *txq;
12531255
int processed_cqe = 0;
12541256
struct sg_list *sg;
12551257
int qidx;
@@ -1270,12 +1272,20 @@ void otx2_cleanup_tx_cqes(struct otx2_nic *pfvf, struct otx2_cq_queue *cq)
12701272
sg = &sq->sg[cqe->comp.sqe_id];
12711273
skb = (struct sk_buff *)sg->skb;
12721274
if (skb) {
1275+
tx_bytes += skb->len;
1276+
tx_pkts++;
12731277
otx2_dma_unmap_skb_frags(pfvf, sg);
12741278
dev_kfree_skb_any(skb);
12751279
sg->skb = (u64)NULL;
12761280
}
12771281
}
12781282

1283+
if (likely(tx_pkts)) {
1284+
if (qidx >= pfvf->hw.tx_queues)
1285+
qidx -= pfvf->hw.xdp_queues;
1286+
txq = netdev_get_tx_queue(pfvf->netdev, qidx);
1287+
netdev_tx_completed_queue(txq, tx_pkts, tx_bytes);
1288+
}
12791289
/* Free CQEs to HW */
12801290
otx2_write64(pfvf, NIX_LF_CQ_OP_DOOR,
12811291
((u64)cq->cq_idx << 32) | processed_cqe);
@@ -1302,6 +1312,38 @@ int otx2_rxtx_enable(struct otx2_nic *pfvf, bool enable)
13021312
return err;
13031313
}
13041314

1315+
void otx2_free_pending_sqe(struct otx2_nic *pfvf)
1316+
{
1317+
int tx_pkts = 0, tx_bytes = 0;
1318+
struct sk_buff *skb = NULL;
1319+
struct otx2_snd_queue *sq;
1320+
struct netdev_queue *txq;
1321+
struct sg_list *sg;
1322+
int sq_idx, sqe;
1323+
1324+
for (sq_idx = 0; sq_idx < pfvf->hw.tx_queues; sq_idx++) {
1325+
sq = &pfvf->qset.sq[sq_idx];
1326+
for (sqe = 0; sqe < sq->sqe_cnt; sqe++) {
1327+
sg = &sq->sg[sqe];
1328+
skb = (struct sk_buff *)sg->skb;
1329+
if (skb) {
1330+
tx_bytes += skb->len;
1331+
tx_pkts++;
1332+
otx2_dma_unmap_skb_frags(pfvf, sg);
1333+
dev_kfree_skb_any(skb);
1334+
sg->skb = (u64)NULL;
1335+
}
1336+
}
1337+
1338+
if (!tx_pkts)
1339+
continue;
1340+
txq = netdev_get_tx_queue(pfvf->netdev, sq_idx);
1341+
netdev_tx_completed_queue(txq, tx_pkts, tx_bytes);
1342+
tx_pkts = 0;
1343+
tx_bytes = 0;
1344+
}
1345+
}
1346+
13051347
static void otx2_xdp_sqe_add_sg(struct otx2_snd_queue *sq, u64 dma_addr,
13061348
int len, int *offset)
13071349
{

0 commit comments

Comments
 (0)