[08/14] net/nfp: structure adjustment

Message ID 20220602015304.710197-9-jin.liu@corigine.com (mailing list archive)
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers
Series Add support of NFP3800 chip and firmware with NFDk |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Jin Liu June 2, 2022, 1:52 a.m. UTC
  Add and modify the nfp PMD struct and macro that will be used by NFDK
firmware.

Signed-off-by: Jin Liu <jin.liu@corigine.com>
Signed-off-by: Diana Wang <na.wang@corigine.com>
Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
 drivers/net/nfp/nfp_rxtx.h | 69 +++++++++++++++++++++++++++++++++++---
 1 file changed, 65 insertions(+), 4 deletions(-)
  

Comments

Ferruh Yigit June 2, 2022, 10:54 p.m. UTC | #1
On 6/2/2022 2:52 AM, Jin Liu wrote:
> Add and modify the nfp PMD struct and macro that will be used by NFDK
> firmware.
> 
> Signed-off-by: Jin Liu <jin.liu@corigine.com>
> Signed-off-by: Diana Wang <na.wang@corigine.com>
> Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
> Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
> Signed-off-by: Niklas Söderlund <niklas.soderlund@corigine.com>

<...>

> @@ -114,9 +166,14 @@ struct nfp_net_txq {
>   	 * For each descriptor keep a reference to the mbuf and
>   	 * DMA address used until completion is signalled.
>   	 */
> -	struct {
> -		struct rte_mbuf *mbuf;
> -	} *txbufs;
> +	union {
> +		struct {
> +			struct rte_mbuf *mbuf;
> +		} *txbufs;
> +		struct {
> +			struct rte_mbuf *mbuf;
> +		} *ktxbufs;

What is the point of this union? Both structs are same.
  
Jin Liu June 14, 2022, 8:49 a.m. UTC | #2
We want to distinguish between NFD3 and NFDk, and maybe it is not necessary, I will update it, thanks

-----Original Message-----
From: Ferruh Yigit <ferruh.yigit@xilinx.com> 
Sent: Friday, June 3, 2022 06:54
To: Kevin Liu <jin.liu@corigine.com>; dev@dpdk.org
Cc: Niklas Soderlund <niklas.soderlund@corigine.com>; Diana Wang <na.wang@corigine.com>; Nole Zhang <peng.zhang@corigine.com>; Chaoyong He <chaoyong.he@corigine.com>
Subject: Re: [PATCH 08/14] net/nfp: structure adjustment

On 6/2/2022 2:52 AM, Jin Liu wrote:
> Add and modify the nfp PMD struct and macro that will be used by NFDK 
> firmware.
> 
> Signed-off-by: Jin Liu <jin.liu@corigine.com>
> Signed-off-by: Diana Wang <na.wang@corigine.com>
> Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
> Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
> Signed-off-by: Niklas Söderlund <niklas.soderlund@corigine.com>

<...>

> @@ -114,9 +166,14 @@ struct nfp_net_txq {
>   	 * For each descriptor keep a reference to the mbuf and
>   	 * DMA address used until completion is signalled.
>   	 */
> -	struct {
> -		struct rte_mbuf *mbuf;
> -	} *txbufs;
> +	union {
> +		struct {
> +			struct rte_mbuf *mbuf;
> +		} *txbufs;
> +		struct {
> +			struct rte_mbuf *mbuf;
> +		} *ktxbufs;

What is the point of this union? Both structs are same.
  

Patch

diff --git a/drivers/net/nfp/nfp_rxtx.h b/drivers/net/nfp/nfp_rxtx.h
index 87a9c59b3b..81e2f7560b 100644
--- a/drivers/net/nfp/nfp_rxtx.h
+++ b/drivers/net/nfp/nfp_rxtx.h
@@ -53,6 +53,31 @@ 
 #define PCIE_DESC_TX_ENCAP_VXLAN        (1 << 1)
 #define PCIE_DESC_TX_ENCAP_GRE          (1 << 0)
 
+#define NFDK_TX_MAX_DATA_PER_HEAD       0x00001000
+#define NFDK_DESC_TX_DMA_LEN_HEAD       0x0fff
+#define NFDK_DESC_TX_TYPE_HEAD          0xf000
+#define NFDK_DESC_TX_DMA_LEN            0x3fff
+#define NFDK_TX_DESC_PER_SIMPLE_PKT     2
+#define NFDK_DESC_TX_TYPE_TSO           2
+#define NFDK_DESC_TX_TYPE_SIMPLE        8
+#define NFDK_DESC_TX_TYPE_GATHER        1
+#define NFDK_DESC_TX_EOP                BIT(14)
+#define NFDK_DESC_TX_L4_CSUM            BIT(1)
+#define NFDK_DESC_TX_L3_CSUM            BIT(0)
+
+#define NFDK_TX_MAX_DATA_PER_DESC      0x00004000
+#define NFDK_TX_DESC_GATHER_MAX        17
+#define DIV_ROUND_UP(n, d)             (((n) + (d) - 1) / (d))
+#define NFDK_TX_DESC_BLOCK_SZ          256
+#define NFDK_TX_DESC_BLOCK_CNT         (NFDK_TX_DESC_BLOCK_SZ /         \
+					sizeof(struct nfp_net_nfdk_tx_desc))
+#define NFDK_TX_DESC_STOP_CNT          (NFDK_TX_DESC_BLOCK_CNT *        \
+					NFDK_TX_DESC_PER_SIMPLE_PKT)
+#define NFDK_TX_MAX_DATA_PER_BLOCK     0x00010000
+#define D_BLOCK_CPL(idx)               (NFDK_TX_DESC_BLOCK_CNT -        \
+					(idx) % NFDK_TX_DESC_BLOCK_CNT)
+#define D_IDX(ring, idx)               ((idx) & ((ring)->tx_count - 1))
+
 struct nfp_net_nfd3_tx_desc {
 	union {
 		struct {
@@ -84,6 +109,33 @@  struct nfp_net_nfd3_tx_desc {
 	};
 };
 
+struct nfp_net_nfdk_tx_desc {
+	union {
+		struct {
+			__le16 dma_addr_hi;  /* High bits of host buf address */
+			__le16 dma_len_type; /* Length to DMA for this desc */
+			__le32 dma_addr_lo;  /* Low 32bit of host buf addr */
+		};
+
+		struct {
+			__le16 mss;	/* MSS to be used for LSO */
+			uint8_t lso_hdrlen;  /* LSO, TCP payload offset */
+			uint8_t lso_totsegs; /* LSO, total segments */
+			uint8_t l3_offset;   /* L3 header offset */
+			uint8_t l4_offset;   /* L4 header offset */
+			__le16 lso_meta_res; /* Rsvd bits in TSO metadata */
+		};
+
+		struct {
+			uint8_t flags;	/* TX Flags, see @NFDK_DESC_TX_* */
+			uint8_t reserved[7];	/* meta byte placeholder */
+		};
+
+		__le32 vals[2];
+		__le64 raw;
+	};
+};
+
 struct nfp_net_txq {
 	struct nfp_net_hw *hw; /* Backpointer to nfp_net structure */
 
@@ -114,9 +166,14 @@  struct nfp_net_txq {
 	 * For each descriptor keep a reference to the mbuf and
 	 * DMA address used until completion is signalled.
 	 */
-	struct {
-		struct rte_mbuf *mbuf;
-	} *txbufs;
+	union {
+		struct {
+			struct rte_mbuf *mbuf;
+		} *txbufs;
+		struct {
+			struct rte_mbuf *mbuf;
+		} *ktxbufs;
+	};
 
 	/*
 	 * Information about the host side queue location. @txds is
@@ -124,7 +181,10 @@  struct nfp_net_txq {
 	 * of the queue and @size is the size in bytes for the queue
 	 * (needed for free)
 	 */
-	struct nfp_net_nfd3_tx_desc *txds;
+	union {
+		struct nfp_net_nfd3_tx_desc *txds;
+		struct nfp_net_nfdk_tx_desc *ktxds;
+	};
 
 	/*
 	 * At this point 48 bytes have been used for all the fields in the
@@ -137,6 +197,7 @@  struct nfp_net_txq {
 	uint32_t tx_hthresh;   /* not used by now. Future? */
 	uint32_t tx_wthresh;   /* not used by now. Future? */
 	uint16_t port_id;
+	uint16_t data_pending; /* used by nfdk only */
 	int qidx;
 	int tx_qcidx;
 	__le64 dma;