From: Harman Kalra <hkalra@marvell.com>
To: Nithin Dabilpuram <ndabilpuram@marvell.com>,
Kiran Kumar K <kirankumark@marvell.com>,
Sunil Kumar Kori <skori@marvell.com>,
Satha Rao <skoteshwar@marvell.com>,
Harman Kalra <hkalra@marvell.com>
Cc: <dev@dpdk.org>
Subject: [PATCH 5/8] net/cnxk: append mark ID action
Date: Wed, 23 Oct 2024 20:31:39 +0530 [thread overview]
Message-ID: <20241023150143.113877-5-hkalra@marvell.com> (raw)
In-Reply-To: <20241023150143.113877-1-hkalra@marvell.com>
In case of represented port action corresponding to a representee,
a mark ID is appended to identify the flow.
Signed-off-by: Harman Kalra <hkalra@marvell.com>
---
drivers/net/cnxk/cnxk_flow.c | 73 ++++++++++++++++++++++++------------
1 file changed, 50 insertions(+), 23 deletions(-)
diff --git a/drivers/net/cnxk/cnxk_flow.c b/drivers/net/cnxk/cnxk_flow.c
index d3c20e8315..7c60e5200b 100644
--- a/drivers/net/cnxk/cnxk_flow.c
+++ b/drivers/net/cnxk/cnxk_flow.c
@@ -5,6 +5,9 @@
#include <cnxk_rep.h>
#define IS_REP_BIT 7
+
+#define TNL_DCP_MATCH_ID 5
+#define NRML_MATCH_ID 1
const struct cnxk_rte_flow_term_info term[] = {
[RTE_FLOW_ITEM_TYPE_ETH] = {ROC_NPC_ITEM_TYPE_ETH, sizeof(struct rte_flow_item_eth)},
[RTE_FLOW_ITEM_TYPE_VLAN] = {ROC_NPC_ITEM_TYPE_VLAN, sizeof(struct rte_flow_item_vlan)},
@@ -187,12 +190,43 @@ roc_npc_parse_sample_subaction(struct rte_eth_dev *eth_dev, const struct rte_flo
return 0;
}
+static int
+append_mark_action(struct roc_npc_action *in_actions, uint8_t has_tunnel_pattern,
+ uint64_t *free_allocs, int *act_cnt)
+{
+ struct rte_flow_action_mark *act_mark;
+ int i = *act_cnt, j = 0;
+
+ /* Add Mark action */
+ i++;
+ act_mark = plt_zmalloc(sizeof(struct rte_flow_action_mark), 0);
+ if (!act_mark) {
+ plt_err("Error allocation memory");
+ return -ENOMEM;
+ }
+
+ while (free_allocs[j] != 0)
+ j++;
+ free_allocs[j] = (uint64_t)act_mark;
+ /* Mark ID format: (tunnel type - VxLAN, Geneve << 6) | Tunnel decap */
+ act_mark->id =
+ has_tunnel_pattern ? ((has_tunnel_pattern << 6) | TNL_DCP_MATCH_ID) : NRML_MATCH_ID;
+ in_actions[i].type = ROC_NPC_ACTION_TYPE_MARK;
+ in_actions[i].conf = (struct rte_flow_action_mark *)act_mark;
+
+ plt_rep_dbg("Assigned mark ID %x", act_mark->id);
+
+ *act_cnt = i;
+
+ return 0;
+}
+
static int
representor_rep_portid_action(struct roc_npc_action *in_actions, struct rte_eth_dev *eth_dev,
struct rte_eth_dev *portid_eth_dev,
enum rte_flow_action_type act_type, uint8_t rep_pattern,
- uint16_t *dst_pf_func, bool is_rep, uint64_t *free_allocs,
- int *act_cnt)
+ uint16_t *dst_pf_func, bool is_rep, uint8_t has_tunnel_pattern,
+ uint64_t *free_allocs, int *act_cnt)
{
struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
struct rte_eth_dev *rep_eth_dev = portid_eth_dev;
@@ -203,7 +237,7 @@ representor_rep_portid_action(struct roc_npc_action *in_actions, struct rte_eth_
struct cnxk_rep_dev *rep_dev;
struct roc_npc *npc;
uint16_t vlan_tci;
- int j = 0;
+ int j = 0, rc;
/* For inserting an action in the list */
int i = *act_cnt;
@@ -322,6 +356,11 @@ representor_rep_portid_action(struct roc_npc_action *in_actions, struct rte_eth_
in_actions[i].type = ROC_NPC_ACTION_TYPE_PORT_ID;
npc->rep_act_pf_func = rep_dev->hw_func;
*dst_pf_func = rep_dev->hw_func;
+
+ /* Append a mark action - needed to identify the flow */
+ rc = append_mark_action(in_actions, has_tunnel_pattern, free_allocs, &i);
+ if (rc)
+ return rc;
}
}
done:
@@ -336,34 +375,21 @@ representor_portid_action(struct roc_npc_action *in_actions, struct rte_eth_dev
int *act_cnt)
{
struct rte_eth_dev *rep_eth_dev = portid_eth_dev;
- struct rte_flow_action_mark *act_mark;
struct cnxk_rep_dev *rep_dev;
/* For inserting an action in the list */
- int i = *act_cnt, j = 0;
+ int i = *act_cnt, rc;
rep_dev = cnxk_rep_pmd_priv(rep_eth_dev);
*dst_pf_func = rep_dev->hw_func;
- /* Add Mark action */
- i++;
- act_mark = plt_zmalloc(sizeof(struct rte_flow_action_mark), 0);
- if (!act_mark) {
- plt_err("Error allocation memory");
- return -ENOMEM;
- }
-
- while (free_allocs[j] != 0)
- j++;
- free_allocs[j] = (uint64_t)act_mark;
- /* Mark ID format: (tunnel type - VxLAN, Geneve << 6) | Tunnel decap */
- act_mark->id = has_tunnel_pattern ? ((has_tunnel_pattern << 6) | 5) : 1;
- in_actions[i].type = ROC_NPC_ACTION_TYPE_MARK;
- in_actions[i].conf = (struct rte_flow_action_mark *)act_mark;
+ rc = append_mark_action(in_actions, has_tunnel_pattern, free_allocs, &i);
+ if (rc)
+ return rc;
*act_cnt = i;
- plt_rep_dbg("Rep port %d ID %d mark ID is %d rep_dev->hw_func 0x%x", rep_dev->port_id,
- rep_dev->rep_id, act_mark->id, rep_dev->hw_func);
+ plt_rep_dbg("Rep port %d ID %d rep_dev->hw_func 0x%x", rep_dev->port_id, rep_dev->rep_id,
+ rep_dev->hw_func);
return 0;
}
@@ -441,7 +467,8 @@ cnxk_map_actions(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr,
if (representor_rep_portid_action(in_actions, eth_dev,
portid_eth_dev, actions->type,
rep_pattern, dst_pf_func, is_rep,
- free_allocs, &i)) {
+ has_tunnel_pattern, free_allocs,
+ &i)) {
plt_err("Representor port action set failed");
goto err_exit;
}
--
2.46.0.469.g4590f2e941
next prev parent reply other threads:[~2024-10-23 15:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-23 15:01 [PATCH 1/8] common/cnxk: common mbox for representor events Harman Kalra
2024-10-23 15:01 ` [PATCH 2/8] net/cnxk: " Harman Kalra
2024-10-23 15:01 ` [PATCH 3/8] common/cnxk: fix double free of flow aging resources Harman Kalra
2024-10-23 15:01 ` [PATCH 4/8] net/cnxk: fix eswitch multiseg Harman Kalra
2024-10-23 15:01 ` Harman Kalra [this message]
2024-10-23 15:01 ` [PATCH 6/8] net/cnxk: support single flow dump Harman Kalra
2024-10-23 15:01 ` [PATCH 7/8] common/cnxk: update representee RSS rule via PF Harman Kalra
2024-10-23 15:01 ` [PATCH 8/8] net/cnxk: handle RSS action for representees Harman Kalra
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=20241023150143.113877-5-hkalra@marvell.com \
--to=hkalra@marvell.com \
--cc=dev@dpdk.org \
--cc=kirankumark@marvell.com \
--cc=ndabilpuram@marvell.com \
--cc=skori@marvell.com \
--cc=skoteshwar@marvell.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).