108 lines
3.3 KiB
Diff
108 lines
3.3 KiB
Diff
From b5c93dae2b73115c46f2e66dc87be61a200e006b Mon Sep 17 00:00:00 2001
|
|
From: jiangheng12 <jiangheng14@huawei.com>
|
|
Date: Sat, 1 Apr 2023 21:56:20 +0800
|
|
Subject: [PATCH] hinic: free tx mbuf use rte_pktmbuf_free_seg
|
|
|
|
---
|
|
drivers/net/hinic/hinic_pmd_tx.c | 27 ++++++++++++++++++---------
|
|
drivers/net/hinic/hinic_pmd_tx.h | 9 +++++++++
|
|
2 files changed, 27 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/drivers/net/hinic/hinic_pmd_tx.c b/drivers/net/hinic/hinic_pmd_tx.c
|
|
index f09b1a6..8eab94d 100644
|
|
--- a/drivers/net/hinic/hinic_pmd_tx.c
|
|
+++ b/drivers/net/hinic/hinic_pmd_tx.c
|
|
@@ -30,13 +30,6 @@
|
|
#define TX_MSS_DEFAULT 0x3E00
|
|
#define TX_MSS_MIN 0x50
|
|
|
|
-#define HINIC_NONTSO_PKT_MAX_SGE 17 /* non-tso max sge 17 */
|
|
-#define HINIC_NONTSO_SEG_NUM_INVALID(num) \
|
|
- ((num) > HINIC_NONTSO_PKT_MAX_SGE)
|
|
-
|
|
-#define HINIC_TSO_PKT_MAX_SGE 127 /* tso max sge 127 */
|
|
-#define HINIC_TSO_SEG_NUM_INVALID(num) ((num) > HINIC_TSO_PKT_MAX_SGE)
|
|
-
|
|
/* sizeof(struct hinic_sq_bufdesc) == 16, shift 4 */
|
|
#define HINIC_BUF_DESC_SIZE(nr_descs) (SIZE_8BYTES(((u32)nr_descs) << 4))
|
|
|
|
@@ -640,6 +633,7 @@ static inline void hinic_xmit_mbuf_cleanup(struct hinic_txq *txq)
|
|
if (likely(mbuf->nb_segs == 1)) {
|
|
m = rte_pktmbuf_prefree_seg(mbuf);
|
|
tx_info->mbuf = NULL;
|
|
+ tx_info->nb_segs = 0;
|
|
|
|
if (unlikely(m == NULL))
|
|
continue;
|
|
@@ -653,8 +647,11 @@ static inline void hinic_xmit_mbuf_cleanup(struct hinic_txq *txq)
|
|
mbuf_free[nb_free++] = m;
|
|
}
|
|
} else {
|
|
- rte_pktmbuf_free(mbuf);
|
|
+ for (int j = 0; j < tx_info->nb_segs; j++) {
|
|
+ rte_pktmbuf_free_seg(tx_info->mbufs[j]);
|
|
+ }
|
|
tx_info->mbuf = NULL;
|
|
+ tx_info->nb_segs = 0;
|
|
}
|
|
}
|
|
|
|
@@ -1191,6 +1188,13 @@ u16 hinic_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, u16 nb_pkts)
|
|
tx_info->mbuf = mbuf_pkt;
|
|
tx_info->wqebb_cnt = wqe_wqebb_cnt;
|
|
|
|
+ tx_info->nb_segs = mbuf_pkt->nb_segs;
|
|
+ struct rte_mbuf *tmp = mbuf_pkt;
|
|
+ for (int j = 0; j < mbuf_pkt->nb_segs; j++) {
|
|
+ tx_info->mbufs[j] = tmp;
|
|
+ tmp = tmp->next;
|
|
+ }
|
|
+
|
|
/* 7. fill sq wqe header section */
|
|
hinic_fill_sq_wqe_header(&sq_wqe->ctrl, queue_info,
|
|
sqe_info.sge_cnt, sqe_info.owner);
|
|
@@ -1231,7 +1235,12 @@ void hinic_free_all_tx_mbufs(struct hinic_txq *txq)
|
|
tx_info->cpy_mbuf = NULL;
|
|
}
|
|
|
|
- rte_pktmbuf_free(tx_info->mbuf);
|
|
+ for (int j = 0; j < tx_info->nb_segs; j++) {
|
|
+ rte_pktmbuf_free_seg(tx_info->mbufs[j]);
|
|
+ tx_info->mbufs[j] = NULL;
|
|
+ }
|
|
+ tx_info->nb_segs = 0;
|
|
+
|
|
hinic_update_sq_local_ci(nic_dev->hwdev, txq->q_id,
|
|
tx_info->wqebb_cnt);
|
|
|
|
diff --git a/drivers/net/hinic/hinic_pmd_tx.h b/drivers/net/hinic/hinic_pmd_tx.h
|
|
index a3ec629..70159bd 100644
|
|
--- a/drivers/net/hinic/hinic_pmd_tx.h
|
|
+++ b/drivers/net/hinic/hinic_pmd_tx.h
|
|
@@ -20,6 +20,13 @@
|
|
RTE_MBUF_F_TX_OUTER_IP_CKSUM | \
|
|
RTE_MBUF_F_TX_TCP_SEG)
|
|
|
|
+#define HINIC_NONTSO_PKT_MAX_SGE 17 /* non-tso max sge 17 */
|
|
+#define HINIC_NONTSO_SEG_NUM_INVALID(num) \
|
|
+ ((num) > HINIC_NONTSO_PKT_MAX_SGE)
|
|
+
|
|
+#define HINIC_TSO_PKT_MAX_SGE 127 /* tso max sge 127 */
|
|
+#define HINIC_TSO_SEG_NUM_INVALID(num) ((num) > HINIC_TSO_PKT_MAX_SGE)
|
|
+
|
|
enum sq_wqe_type {
|
|
SQ_NORMAL_WQE = 0,
|
|
};
|
|
@@ -98,6 +105,8 @@ struct hinic_txq_stats {
|
|
|
|
struct hinic_tx_info {
|
|
struct rte_mbuf *mbuf;
|
|
+ struct rte_mbuf *mbufs[HINIC_TSO_PKT_MAX_SGE];
|
|
+ int nb_segs;
|
|
int wqebb_cnt;
|
|
struct rte_mbuf *cpy_mbuf;
|
|
};
|
|
--
|
|
2.23.0
|
|
|