DPDK patches and discussions
 help / color / mirror / Atom feed
From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com,
	Chaoyong He <chaoyong.he@corigine.com>
Subject: [PATCH 04/10] net/nfp: add the insert metadata logic of NFDk
Date: Wed,  7 Jun 2023 09:57:03 +0800	[thread overview]
Message-ID: <20230607015709.336420-5-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20230607015709.336420-1-chaoyong.he@corigine.com>

NFD3 and NFDk have the same format metadata for the RX direction,
while they are different for the TX direction.

Add the insert metadata logic of NFDk.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
 drivers/net/nfp/flower/nfp_flower.c |  8 +++++++-
 drivers/net/nfp/nfdk/nfp_nfdk.h     |  2 ++
 drivers/net/nfp/nfdk/nfp_nfdk_dp.c  | 18 ++++++++++++++++++
 3 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index 3636c347bb..8631664180 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -16,6 +16,7 @@
 #include "../nfp_cpp_bridge.h"
 #include "../nfp_rxtx.h"
 #include "../nfd3/nfp_nfd3.h"
+#include "../nfdk/nfp_nfdk.h"
 #include "../nfpcore/nfp_mip.h"
 #include "../nfpcore/nfp_rtsym.h"
 #include "../nfpcore/nfp_nsp.h"
@@ -1061,11 +1062,16 @@ nfp_flower_enable_services(struct nfp_app_fw_flower *app_fw_flower)
 static void
 nfp_flower_pkt_add_metadata_register(struct nfp_app_fw_flower *app_fw_flower)
 {
+	struct nfp_net_hw *hw;
 	struct nfp_flower_nfd_func *nfd_func;
 
+	hw = app_fw_flower->pf_hw;
 	nfd_func = &app_fw_flower->nfd_func;
 
-	nfd_func->pkt_add_metadata_t = nfp_flower_nfd3_pkt_add_metadata;
+	if (hw->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3)
+		nfd_func->pkt_add_metadata_t = nfp_flower_nfd3_pkt_add_metadata;
+	else
+		nfd_func->pkt_add_metadata_t = nfp_flower_nfdk_pkt_add_metadata;
 }
 
 uint32_t
diff --git a/drivers/net/nfp/nfdk/nfp_nfdk.h b/drivers/net/nfp/nfdk/nfp_nfdk.h
index c39501990a..0e3c6cc90d 100644
--- a/drivers/net/nfp/nfdk/nfp_nfdk.h
+++ b/drivers/net/nfp/nfdk/nfp_nfdk.h
@@ -227,6 +227,8 @@ nfp_net_nfdk_tx_tso(struct nfp_net_txq *txq,
 	return txd.raw;
 }
 
+uint32_t nfp_flower_nfdk_pkt_add_metadata(struct rte_mbuf *mbuf,
+		uint32_t port_id);
 uint16_t nfp_net_nfdk_xmit_pkts(void *tx_queue,
 		struct rte_mbuf **tx_pkts,
 		uint16_t nb_pkts);
diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
index 9b815800bb..59c507e03b 100644
--- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
+++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
@@ -12,8 +12,26 @@
 #include "../nfp_rxtx.h"
 #include "../nfpcore/nfp_mip.h"
 #include "../nfpcore/nfp_rtsym.h"
+#include "../flower/nfp_flower.h"
+#include "../flower/nfp_flower_cmsg.h"
 #include "nfp_nfdk.h"
 
+uint32_t
+nfp_flower_nfdk_pkt_add_metadata(struct rte_mbuf *mbuf,
+		uint32_t port_id)
+{
+	uint32_t header;
+	char *meta_offset;
+
+	meta_offset = rte_pktmbuf_prepend(mbuf, FLOWER_PKT_DATA_OFFSET);
+	header = NFP_NET_META_PORTID << NFP_NET_META_NFDK_LENGTH | FLOWER_PKT_DATA_OFFSET;
+	*(rte_be32_t *)meta_offset = rte_cpu_to_be_32(header);
+	meta_offset += NFP_NET_META_HEADER_SIZE;
+	*(rte_be32_t *)meta_offset = rte_cpu_to_be_32(port_id);
+
+	return FLOWER_PKT_DATA_OFFSET;
+}
+
 static inline uint16_t
 nfp_net_nfdk_headlen_to_segs(uint16_t headlen)
 {
-- 
2.39.1


  parent reply	other threads:[~2023-06-07  1:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-07  1:56 [PATCH 00/10] support rte_flow for flower firmware with NFDk Chaoyong He
2023-06-07  1:57 ` [PATCH 01/10] net/nfp: fix the problem of rtsym Chaoyong He
2023-06-07  1:57 ` [PATCH 02/10] net/nfp: add a check function for the NFD version Chaoyong He
2023-06-07  1:57 ` [PATCH 03/10] net/nfp: refactor the insert metadata logic of NFD3 Chaoyong He
2023-06-07  1:57 ` Chaoyong He [this message]
2023-06-07  1:57 ` [PATCH 05/10] net/nfp: add a dispatch layer for Tx function of ctrl VNIC Chaoyong He
2023-06-07  1:57 ` [PATCH 06/10] net/nfp: add the xmit function of NFDk for " Chaoyong He
2023-06-07  1:57 ` [PATCH 07/10] net/nfp: add a dispatch layer for Tx function of representor Chaoyong He
2023-06-07  1:57 ` [PATCH 08/10] net/nfp: merge the xmit function of NFD3 Chaoyong He
2023-06-07  1:57 ` [PATCH 09/10] net/nfp: add the xmit function of NFDk for PF representor Chaoyong He
2023-06-07  1:57 ` [PATCH 10/10] net/nfp: merge the recv function Chaoyong He
2023-06-07 14:23 ` [PATCH 00/10] support rte_flow for flower firmware with NFDk Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230607015709.336420-5-chaoyong.he@corigine.com \
    --to=chaoyong.he@corigine.com \
    --cc=dev@dpdk.org \
    --cc=niklas.soderlund@corigine.com \
    --cc=oss-drivers@corigine.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).