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>,
	stable@dpdk.org
Subject: [PATCH] net/nfp: fix TP flow action for UDP
Date: Fri,  9 Jun 2023 14:22:19 +0800	[thread overview]
Message-ID: <20230609062219.1308140-1-chaoyong.he@corigine.com> (raw)

The former logic can't distinguish the TCP and UDP set action, and
only send a TCP type ctrl message to firmware, which cause the set
action of UDP can't offload.

Fixes: fc185097bbe6 ("net/nfp: support TP source flow action")
Fixes: 87986df09d75 ("net/nfp: support TP destination flow action")
Cc: stable@dpdk.org

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
 drivers/net/nfp/nfp_flow.c | 30 ++++++++++++++++++++++++++----
 drivers/net/nfp/nfp_flow.h |  1 +
 2 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index 41b722f4d8..9f7d86e832 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -1909,6 +1909,19 @@ nfp_flow_inner_item_get(const struct rte_flow_item items[],
 	return false;
 }
 
+static bool
+nfp_flow_tcp_flag_check(const struct rte_flow_item items[])
+{
+	const struct rte_flow_item *item;
+
+	for (item = items; item->type != RTE_FLOW_ITEM_TYPE_END; ++item) {
+		if (item->type == RTE_FLOW_ITEM_TYPE_TCP)
+			return true;
+	}
+
+	return false;
+}
+
 static int
 nfp_flow_compile_item_proc(struct nfp_flower_representor *repr,
 		const struct rte_flow_item items[],
@@ -2004,6 +2017,9 @@ nfp_flow_compile_items(struct nfp_flower_representor *representor,
 		mbuf_off_mask += sizeof(struct nfp_flower_ext_meta);
 	}
 
+	if (nfp_flow_tcp_flag_check(items))
+		nfp_flow->tcp_flag = true;
+
 	/* Check if this is a tunnel flow and get the inner item*/
 	is_tun_flow = nfp_flow_inner_item_get(items, &loop_item);
 	if (is_tun_flow)
@@ -2175,7 +2191,8 @@ static void
 nfp_flow_action_set_tp(char *act_data,
 		const struct rte_flow_action *action,
 		bool tp_src_flag,
-		bool tp_set_flag)
+		bool tp_set_flag,
+		bool tcp_flag)
 {
 	size_t act_size;
 	struct nfp_fl_act_set_tport *set_tp;
@@ -2187,7 +2204,10 @@ nfp_flow_action_set_tp(char *act_data,
 		set_tp = (struct nfp_fl_act_set_tport *)act_data;
 
 	act_size = sizeof(struct nfp_fl_act_set_tport);
-	set_tp->head.jump_id = NFP_FL_ACTION_OPCODE_SET_TCP;
+	if (tcp_flag)
+		set_tp->head.jump_id = NFP_FL_ACTION_OPCODE_SET_TCP;
+	else
+		set_tp->head.jump_id = NFP_FL_ACTION_OPCODE_SET_UDP;
 	set_tp->head.len_lw  = act_size >> NFP_FL_LW_SIZ;
 	set_tp->reserved     = 0;
 
@@ -3442,7 +3462,8 @@ nfp_flow_compile_action(struct nfp_flower_representor *representor,
 			break;
 		case RTE_FLOW_ACTION_TYPE_SET_TP_SRC:
 			PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_SET_TP_SRC");
-			nfp_flow_action_set_tp(position, action, true, tp_set_flag);
+			nfp_flow_action_set_tp(position, action, true,
+					tp_set_flag, nfp_flow->tcp_flag);
 			if (!tp_set_flag) {
 				position += sizeof(struct nfp_fl_act_set_tport);
 				tp_set_flag = true;
@@ -3450,7 +3471,8 @@ nfp_flow_compile_action(struct nfp_flower_representor *representor,
 			break;
 		case RTE_FLOW_ACTION_TYPE_SET_TP_DST:
 			PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_SET_TP_DST");
-			nfp_flow_action_set_tp(position, action, false, tp_set_flag);
+			nfp_flow_action_set_tp(position, action, false,
+					tp_set_flag, nfp_flow->tcp_flag);
 			if (!tp_set_flag) {
 				position += sizeof(struct nfp_fl_act_set_tport);
 				tp_set_flag = true;
diff --git a/drivers/net/nfp/nfp_flow.h b/drivers/net/nfp/nfp_flow.h
index d352671c2c..414bd4573b 100644
--- a/drivers/net/nfp/nfp_flow.h
+++ b/drivers/net/nfp/nfp_flow.h
@@ -225,6 +225,7 @@ struct rte_flow {
 	uint32_t mtr_id;
 	uint32_t port_id;
 	bool install_flag;
+	bool tcp_flag;    /**< Used in the SET_TP_* action */
 	enum nfp_flow_type type;
 };
 
-- 
2.39.1


             reply	other threads:[~2023-06-09  6:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-09  6:22 Chaoyong He [this message]
2023-06-09 14:15 ` 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=20230609062219.1308140-1-chaoyong.he@corigine.com \
    --to=chaoyong.he@corigine.com \
    --cc=dev@dpdk.org \
    --cc=niklas.soderlund@corigine.com \
    --cc=oss-drivers@corigine.com \
    --cc=stable@dpdk.org \
    /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).