From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6E4CFA04AC; Mon, 24 Aug 2020 09:04:36 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5962D1B53; Mon, 24 Aug 2020 09:04:35 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 16DDE100C for ; Mon, 24 Aug 2020 09:04:33 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 07O6xNRE018120; Mon, 24 Aug 2020 00:04:33 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=NhaJHQRkEUormxtKxOwQIx769HS0gy5j8GhRi0pS3C8=; b=N4R5039x2tumS+xp0RSZ2AzjIHhYnAOcnEHO8FfL1tnkiDS0dwD1neQy6N9n6KQ08SbF zNwFTlFcuux3Ftmt7g1ECkrY3PqZsJoT+fJD1Ax8Dn3N4Ab25USYmEOaYiWuk3qUpgRx 2sJ7bLz3q5/o6pdUeBNA9zr2FKK1N/AQxR/y0s/6xOuqOBaQFgwZI+6J/OJqmgs44ubB OEutkX5uuWTxG9M5qeUYQ8aKl9Z7K85vRvMjQ3/NMftO2Mw2JLElfM813Vvio02M6mc6 zgPjmIY+rvtepxggoPg9VlR/hvos0/4sY9gzXoTne7pnYLUxb5GFfLtK0/VKdOgbUAar 8A== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0b-0016f401.pphosted.com with ESMTP id 3332vmnjpu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 24 Aug 2020 00:04:32 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 24 Aug 2020 00:04:31 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 24 Aug 2020 00:04:30 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 24 Aug 2020 00:04:30 -0700 Received: from localhost.localdomain (unknown [10.28.34.15]) by maili.marvell.com (Postfix) with ESMTP id 338C33F7043; Mon, 24 Aug 2020 00:04:27 -0700 (PDT) From: To: Jerin Jacob , Nithin Dabilpuram , Kiran Kumar K , "John McNamara" , Marko Kovacevic CC: Date: Mon, 24 Aug 2020 12:34:24 +0530 Message-ID: <20200824070424.252040-1-kirankumark@marvell.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-08-24_06:2020-08-24, 2020-08-24 signatures=0 Subject: [dpdk-dev] [PATCH] net/octeontx2: add support VLAN insert and strip action X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Kiran Kumar K Adding support for RTE Flow VLAN insert and strip actions for octeontx2 device. Signed-off-by: Kiran Kumar K --- doc/guides/nics/octeontx2.rst | 68 +++++++------ drivers/net/octeontx2/otx2_flow.c | 126 ++++++++++++++++++++++++ drivers/net/octeontx2/otx2_flow.h | 6 ++ drivers/net/octeontx2/otx2_flow_parse.c | 76 ++++++++++++-- drivers/net/octeontx2/otx2_flow_utils.c | 15 +-- 5 files changed, 237 insertions(+), 54 deletions(-) diff --git a/doc/guides/nics/octeontx2.rst b/doc/guides/nics/octeontx2.rst index bb591a8b7..f3be79bbb 100644 --- a/doc/guides/nics/octeontx2.rst +++ b/doc/guides/nics/octeontx2.rst @@ -385,38 +385,46 @@ Actions: .. table:: Ingress action types - +----+--------------------------------+ - | # | Action Type | - +====+================================+ - | 1 | RTE_FLOW_ACTION_TYPE_VOID | - +----+--------------------------------+ - | 2 | RTE_FLOW_ACTION_TYPE_MARK | - +----+--------------------------------+ - | 3 | RTE_FLOW_ACTION_TYPE_FLAG | - +----+--------------------------------+ - | 4 | RTE_FLOW_ACTION_TYPE_COUNT | - +----+--------------------------------+ - | 5 | RTE_FLOW_ACTION_TYPE_DROP | - +----+--------------------------------+ - | 6 | RTE_FLOW_ACTION_TYPE_QUEUE | - +----+--------------------------------+ - | 7 | RTE_FLOW_ACTION_TYPE_RSS | - +----+--------------------------------+ - | 8 | RTE_FLOW_ACTION_TYPE_SECURITY | - +----+--------------------------------+ - | 9 | RTE_FLOW_ACTION_TYPE_PF | - +----+--------------------------------+ - | 10 | RTE_FLOW_ACTION_TYPE_VF | - +----+--------------------------------+ + +----+-----------------------------------------+ + | # | Action Type | + +====+=========================================+ + | 1 | RTE_FLOW_ACTION_TYPE_VOID | + +----+-----------------------------------------+ + | 2 | RTE_FLOW_ACTION_TYPE_MARK | + +----+-----------------------------------------+ + | 3 | RTE_FLOW_ACTION_TYPE_FLAG | + +----+-----------------------------------------+ + | 4 | RTE_FLOW_ACTION_TYPE_COUNT | + +----+-----------------------------------------+ + | 5 | RTE_FLOW_ACTION_TYPE_DROP | + +----+-----------------------------------------+ + | 6 | RTE_FLOW_ACTION_TYPE_QUEUE | + +----+-----------------------------------------+ + | 7 | RTE_FLOW_ACTION_TYPE_RSS | + +----+-----------------------------------------+ + | 8 | RTE_FLOW_ACTION_TYPE_SECURITY | + +----+-----------------------------------------+ + | 9 | RTE_FLOW_ACTION_TYPE_PF | + +----+-----------------------------------------+ + | 10 | RTE_FLOW_ACTION_TYPE_VF | + +----+-----------------------------------------+ + | 11 | RTE_FLOW_ACTION_TYPE_OF_POP_VLAN | + +----+-----------------------------------------+ .. _table_octeontx2_supported_egress_action_types: .. table:: Egress action types - +----+--------------------------------+ - | # | Action Type | - +====+================================+ - | 1 | RTE_FLOW_ACTION_TYPE_COUNT | - +----+--------------------------------+ - | 2 | RTE_FLOW_ACTION_TYPE_DROP | - +----+--------------------------------+ + +----+-----------------------------------------+ + | # | Action Type | + +====+=========================================+ + | 1 | RTE_FLOW_ACTION_TYPE_COUNT | + +----+-----------------------------------------+ + | 2 | RTE_FLOW_ACTION_TYPE_DROP | + +----+-----------------------------------------+ + | 3 | RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN | + +----+-----------------------------------------+ + | 4 | RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID | + +----+-----------------------------------------+ + | 5 | RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP | + +----+-----------------------------------------+ diff --git a/drivers/net/octeontx2/otx2_flow.c b/drivers/net/octeontx2/otx2_flow.c index 13a76e441..9b32b2acc 100644 --- a/drivers/net/octeontx2/otx2_flow.c +++ b/drivers/net/octeontx2/otx2_flow.c @@ -6,6 +6,8 @@ #include "otx2_ethdev_sec.h" #include "otx2_flow.h" +enum flow_vtag_cfg_dir { VTAG_TX, VTAG_RX }; + int otx2_flow_free_all_resources(struct otx2_eth_dev *hw) { @@ -460,6 +462,109 @@ otx2_flow_validate(struct rte_eth_dev *dev, &parse_state); } +static int +flow_program_vtag_action(struct rte_eth_dev *eth_dev, + const struct rte_flow_action actions[], + struct rte_flow *flow) +{ + uint16_t vlan_id = 0, vlan_ethtype = RTE_ETHER_TYPE_VLAN; + struct otx2_eth_dev *dev = eth_dev->data->dev_private; + union { + uint64_t reg; + struct nix_tx_vtag_action_s act; + } tx_vtag_action; + struct otx2_mbox *mbox = dev->mbox; + struct nix_vtag_config *vtag_cfg; + struct nix_vtag_config_rsp *rsp; + bool vlan_insert_action = false; + uint64_t rx_vtag_action = 0; + uint8_t vlan_pcp = 0; + int rc; + + for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { + if (actions->type == RTE_FLOW_ACTION_TYPE_OF_POP_VLAN) { + if (dev->npc_flow.vtag_actions == 1) { + vtag_cfg = + otx2_mbox_alloc_msg_nix_vtag_cfg(mbox); + vtag_cfg->cfg_type = VTAG_RX; + vtag_cfg->rx.strip_vtag = 1; + /* Always capture */ + vtag_cfg->rx.capture_vtag = 1; + vtag_cfg->vtag_size = NIX_VTAGSIZE_T4; + vtag_cfg->rx.vtag_type = 0; + + rc = otx2_mbox_process(mbox); + if (rc) + return rc; + } + + rx_vtag_action |= (NIX_RX_VTAGACTION_VTAG_VALID << 15); + rx_vtag_action |= (NPC_LID_LB << 8); + rx_vtag_action |= NIX_RX_VTAGACTION_VTAG0_RELPTR; + flow->vtag_action = rx_vtag_action; + } else if (actions->type == + RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID) { + const struct rte_flow_action_of_set_vlan_vid *vtag = + (const struct rte_flow_action_of_set_vlan_vid *) + actions->conf; + vlan_id = rte_be_to_cpu_16(vtag->vlan_vid); + if (vlan_id > 0xfff) { + otx2_err("Invalid vlan_id for set vlan action"); + return -EINVAL; + } + vlan_insert_action = true; + } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN) { + const struct rte_flow_action_of_push_vlan *ethtype = + (const struct rte_flow_action_of_push_vlan *) + actions->conf; + vlan_ethtype = rte_be_to_cpu_16(ethtype->ethertype); + if (vlan_ethtype != RTE_ETHER_TYPE_VLAN && + vlan_ethtype != RTE_ETHER_TYPE_QINQ) { + otx2_err("Invalid ethtype specified for push" + " vlan action"); + return -EINVAL; + } + vlan_insert_action = true; + } else if (actions->type == + RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP) { + const struct rte_flow_action_of_set_vlan_pcp *pcp = + (const struct rte_flow_action_of_set_vlan_pcp *) + actions->conf; + vlan_pcp = pcp->vlan_pcp; + if (vlan_pcp > 0x7) { + otx2_err("Invalid PCP value for pcp action"); + return -EINVAL; + } + vlan_insert_action = true; + } + } + + if (vlan_insert_action) { + vtag_cfg = otx2_mbox_alloc_msg_nix_vtag_cfg(mbox); + vtag_cfg->cfg_type = VTAG_TX; + vtag_cfg->vtag_size = NIX_VTAGSIZE_T4; + vtag_cfg->tx.vtag0 = + ((vlan_ethtype << 16) | (vlan_pcp << 13) | vlan_id); + vtag_cfg->tx.cfg_vtag0 = 1; + rc = otx2_mbox_process_msg(mbox, (void *)&rsp); + if (rc) + return rc; + + tx_vtag_action.reg = 0; + tx_vtag_action.act.vtag0_def = rsp->vtag0_idx; + if (tx_vtag_action.act.vtag0_def < 0) { + otx2_err("Failed to config TX VTAG action"); + return -EINVAL; + } + tx_vtag_action.act.vtag0_lid = NPC_LID_LA; + tx_vtag_action.act.vtag0_op = NIX_TX_VTAGOP_INSERT; + tx_vtag_action.act.vtag0_relptr = + NIX_TX_VTAGACTION_VTAG0_RELPTR; + flow->vtag_action = tx_vtag_action.reg; + } + return 0; +} + static struct rte_flow * otx2_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, @@ -489,6 +594,15 @@ otx2_flow_create(struct rte_eth_dev *dev, if (rc != 0) goto err_exit; + rc = flow_program_vtag_action(dev, actions, flow); + if (rc != 0) { + rte_flow_error_set(error, EIO, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "Failed to program vlan action"); + goto err_exit; + } + rc = flow_program_npc(&parse_state, mbox, &hw->npc_flow); if (rc != 0) { rte_flow_error_set(error, EIO, @@ -561,6 +675,17 @@ otx2_flow_destroy(struct rte_eth_dev *dev, } } + if (flow->nix_intf == OTX2_INTF_RX && flow->vtag_action) { + npc->vtag_actions--; + if (npc->vtag_actions == 0) { + if (hw->vlan_info.strip_on == 0) { + hw->rx_offload_flags &= + ~NIX_RX_OFFLOAD_VLAN_STRIP_F; + otx2_eth_set_rx_function(dev); + } + } + } + rc = flow_free_rss_action(dev, flow); if (rc != 0) { rte_flow_error_set(error, EIO, @@ -849,6 +974,7 @@ otx2_flow_init(struct otx2_eth_dev *hw) } rte_atomic32_init(&npc->mark_actions); + npc->vtag_actions = 0; npc->mcam_entries = NPC_MCAM_TOT_ENTRIES >> npc->keyw[NPC_MCAM_RX]; /* Free, free_rev, live and live_rev entries */ diff --git a/drivers/net/octeontx2/otx2_flow.h b/drivers/net/octeontx2/otx2_flow.h index df78f41d3..1f118c408 100644 --- a/drivers/net/octeontx2/otx2_flow.h +++ b/drivers/net/octeontx2/otx2_flow.h @@ -55,6 +55,10 @@ enum { #define OTX2_FLOW_ACT_COUNT (1 << 7) #define OTX2_FLOW_ACT_PF (1 << 8) #define OTX2_FLOW_ACT_VF (1 << 9) +#define OTX2_FLOW_ACT_VLAN_STRIP (1 << 10) +#define OTX2_FLOW_ACT_VLAN_INSERT (1 << 11) +#define OTX2_FLOW_ACT_VLAN_ETHTYPE_INSERT (1 << 12) +#define OTX2_FLOW_ACT_VLAN_PCP_INSERT (1 << 13) /* terminating actions */ #define OTX2_FLOW_ACT_TERM (OTX2_FLOW_ACT_DROP | \ @@ -154,6 +158,7 @@ struct rte_flow { uint64_t mcam_data[OTX2_MAX_MCAM_WIDTH_DWORDS]; uint64_t mcam_mask[OTX2_MAX_MCAM_WIDTH_DWORDS]; uint64_t npc_action; + uint64_t vtag_action; TAILQ_ENTRY(rte_flow) next; }; @@ -162,6 +167,7 @@ TAILQ_HEAD(otx2_flow_list, rte_flow); /* Accessed from ethdev private - otx2_eth_dev */ struct otx2_npc_flow_info { rte_atomic32_t mark_actions; + uint32_t vtag_actions; uint32_t keyx_supp_nmask[NPC_MAX_INTF];/* nibble mask */ uint32_t keyx_len[NPC_MAX_INTF]; /* per intf key len in bits */ uint32_t datax_len[NPC_MAX_INTF]; /* per intf data len in bits */ diff --git a/drivers/net/octeontx2/otx2_flow_parse.c b/drivers/net/octeontx2/otx2_flow_parse.c index 2d9a5857c..b7ff5fd03 100644 --- a/drivers/net/octeontx2/otx2_flow_parse.c +++ b/drivers/net/octeontx2/otx2_flow_parse.c @@ -813,6 +813,7 @@ otx2_flow_parse_actions(struct rte_eth_dev *dev, const struct rte_flow_action_mark *act_mark; const struct rte_flow_action_queue *act_q; const struct rte_flow_action_vf *vf_act; + bool vlan_insert_action = false; const char *errmsg = NULL; int sel_act, req_act = 0; uint16_t pf_func, vf_id; @@ -932,6 +933,18 @@ otx2_flow_parse_actions(struct rte_eth_dev *dev, req_act |= OTX2_FLOW_ACT_SEC; rq = 0; break; + case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID: + req_act |= OTX2_FLOW_ACT_VLAN_INSERT; + break; + case RTE_FLOW_ACTION_TYPE_OF_POP_VLAN: + req_act |= OTX2_FLOW_ACT_VLAN_STRIP; + break; + case RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN: + req_act |= OTX2_FLOW_ACT_VLAN_ETHTYPE_INSERT; + break; + case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP: + req_act |= OTX2_FLOW_ACT_VLAN_PCP_INSERT; + break; default: errmsg = "Unsupported action specified"; errcode = ENOTSUP; @@ -939,20 +952,46 @@ otx2_flow_parse_actions(struct rte_eth_dev *dev, } } + if (req_act & + (OTX2_FLOW_ACT_VLAN_INSERT | OTX2_FLOW_ACT_VLAN_ETHTYPE_INSERT | + OTX2_FLOW_ACT_VLAN_PCP_INSERT)) + vlan_insert_action = true; + + if ((req_act & + (OTX2_FLOW_ACT_VLAN_INSERT | OTX2_FLOW_ACT_VLAN_ETHTYPE_INSERT | + OTX2_FLOW_ACT_VLAN_PCP_INSERT)) == + OTX2_FLOW_ACT_VLAN_PCP_INSERT) { + errmsg = " PCP insert action can't be supported alone"; + errcode = ENOTSUP; + goto err_exit; + } + + /* Both STRIP and INSERT actions are not supported */ + if (vlan_insert_action && (req_act & OTX2_FLOW_ACT_VLAN_STRIP)) { + errmsg = "Both VLAN insert and strip actions not supported" + " together"; + errcode = ENOTSUP; + goto err_exit; + } + /* Check if actions specified are compatible */ if (attr->egress) { - /* Only DROP/COUNT is supported */ - if (!(req_act & OTX2_FLOW_ACT_DROP)) { - errmsg = "DROP is required action for egress"; - errcode = EINVAL; - goto err_exit; - } else if (req_act & ~(OTX2_FLOW_ACT_DROP | - OTX2_FLOW_ACT_COUNT)) { - errmsg = "Unsupported action specified"; + if (req_act & OTX2_FLOW_ACT_VLAN_STRIP) { + errmsg = "VLAN pop action is not supported on Egress"; errcode = ENOTSUP; goto err_exit; } - flow->npc_action = NIX_TX_ACTIONOP_DROP; + + if (req_act & OTX2_FLOW_ACT_DROP) { + flow->npc_action = NIX_TX_ACTIONOP_DROP; + } else if ((req_act & OTX2_FLOW_ACT_COUNT) || + vlan_insert_action) { + flow->npc_action = NIX_TX_ACTIONOP_UCAST_DEFAULT; + } else { + errmsg = "Unsupported action for egress"; + errcode = EINVAL; + goto err_exit; + } goto set_pf_func; } @@ -985,8 +1024,20 @@ otx2_flow_parse_actions(struct rte_eth_dev *dev, goto err_exit; } + if (vlan_insert_action) { + errmsg = "VLAN push/Insert action is not supported on Ingress"; + errcode = ENOTSUP; + goto err_exit; + } + + if (req_act & OTX2_FLOW_ACT_VLAN_STRIP) + npc->vtag_actions++; + + /* Only VLAN action is provided */ + if (req_act == OTX2_FLOW_ACT_VLAN_STRIP) + flow->npc_action = NIX_RX_ACTIONOP_UCAST; /* Set NIX_RX_ACTIONOP */ - if (req_act & (OTX2_FLOW_ACT_PF | OTX2_FLOW_ACT_VF)) { + else if (req_act & (OTX2_FLOW_ACT_PF | OTX2_FLOW_ACT_VF)) { flow->npc_action = NIX_RX_ACTIONOP_UCAST; if (req_act & OTX2_FLOW_ACT_QUEUE) flow->npc_action |= (uint64_t)rq << 20; @@ -1032,6 +1083,11 @@ otx2_flow_parse_actions(struct rte_eth_dev *dev, otx2_eth_set_rx_function(dev); } + if (npc->vtag_actions == 1) { + hw->rx_offload_flags |= NIX_RX_OFFLOAD_VLAN_STRIP_F; + otx2_eth_set_rx_function(dev); + } + set_pf_func: /* Ideally AF must ensure that correct pf_func is set */ flow->npc_action |= (uint64_t)pf_func << 4; diff --git a/drivers/net/octeontx2/otx2_flow_utils.c b/drivers/net/octeontx2/otx2_flow_utils.c index 14625c9ad..6215a542f 100644 --- a/drivers/net/octeontx2/otx2_flow_utils.c +++ b/drivers/net/octeontx2/otx2_flow_utils.c @@ -916,20 +916,7 @@ otx2_flow_mcam_alloc_and_write(struct rte_flow *flow, struct otx2_mbox *mbox, (flow->nix_intf == OTX2_INTF_RX) ? NPC_MCAM_RX : NPC_MCAM_TX; req->enable_entry = 1; req->entry_data.action = flow->npc_action; - - /* - * DPDK sets vtag action on per interface basis, not - * per flow basis. It is a matter of how we decide to support - * this pmd specific behavior. There are two ways: - * 1. Inherit the vtag action from the one configured - * for this interface. This can be read from the - * vtag_action configured for default mcam entry of - * this pf_func. - * 2. Do not support vtag action with rte_flow. - * - * Second approach is used now. - */ - req->entry_data.vtag_action = 0ULL; + req->entry_data.vtag_action = flow->vtag_action; for (idx = 0; idx < OTX2_MAX_MCAM_WIDTH_DWORDS; idx++) { req->entry_data.kw[idx] = flow->mcam_data[idx]; -- 2.25.1