From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 074B345BB3; Wed, 23 Oct 2024 17:02:30 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F139642E1D; Wed, 23 Oct 2024 17:02:07 +0200 (CEST) Received: from mx0a-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 9949342E1D for ; Wed, 23 Oct 2024 17:02:06 +0200 (CEST) Received: from pps.filterd (m0431384.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49NASKOc001665 for ; Wed, 23 Oct 2024 08:02:05 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=g cccJN2PXZXWsrf4bjIDWtG3v+tSvrwsySkGpAgXaYI=; b=d6cVf9fACDBwSMqht houQWQmH5ywHJ+0QDCXOJb7ZDfO692P2Ff5yd0fY8j6jcYss+5teis3GlmCkQ6ef JtS7NMYsLTiY4iD3mOiFId2pSC96LI+hf91lYkS8j6m4eTw/11I5JY0t7NhZUdzI 5oIYx+5uHw9CSQDAvZ4hOAUL9sgtAZeinztINwW+Fyr7+WJ3zS8lLjk5OU7s1hUt LqRPmSZCX+KzrNMGQjKucyfj+Vje3svZoKAxo2cVge5/MOobwOXbBcYp1HMtkisS SeA0jzHIiO9TnBas7Lm4I70eQyDqbrNEFJmGHkhghLVsN/ncyOlvarLe5F6PtmBB wFW4A== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 42eydy8mmp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 23 Oct 2024 08:02:04 -0700 (PDT) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 23 Oct 2024 08:02:03 -0700 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 23 Oct 2024 08:02:03 -0700 Received: from localhost.localdomain (unknown [10.29.52.211]) by maili.marvell.com (Postfix) with ESMTP id 666013F7069; Wed, 23 Oct 2024 08:02:01 -0700 (PDT) From: Harman Kalra To: Nithin Dabilpuram , Kiran Kumar K , Sunil Kumar Kori , Satha Rao , Harman Kalra CC: Subject: [PATCH 5/8] net/cnxk: append mark ID action Date: Wed, 23 Oct 2024 20:31:39 +0530 Message-ID: <20241023150143.113877-5-hkalra@marvell.com> X-Mailer: git-send-email 2.46.0.469.g4590f2e941 In-Reply-To: <20241023150143.113877-1-hkalra@marvell.com> References: <20241023150143.113877-1-hkalra@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: RZNOH4vFj3fC9XhamBMPyCoD-E6kTJmW X-Proofpoint-ORIG-GUID: RZNOH4vFj3fC9XhamBMPyCoD-E6kTJmW X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.687,Hydra:6.0.235,FMLib:17.0.607.475 definitions=2020-10-13_15,2020-10-13_02,2020-04-07_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org In case of represented port action corresponding to a representee, a mark ID is appended to identify the flow. Signed-off-by: Harman Kalra --- 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 #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