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 6A10842B87; Wed, 24 May 2023 06:53:56 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F0B1B40ED8; Wed, 24 May 2023 06:53:55 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id C6D924067E for ; Wed, 24 May 2023 06:53:54 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34O4qHw3025077 for ; Tue, 23 May 2023 21:53:53 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=auICYpry5tb6ALwT/wyVuGdWNi+BLMngBDLOX67EwvM=; b=NupMivsUObX8wzGzYD5Sn+EDpkb3wAlrcbxb7KyE7yu4de45+1aithSvWWLekPBcI/EZ UdRnD8/8/qt7MsNO1VUF/k5nLRI4sUE40PnAW2H605k8NG95Ylm/m5XJOX3J4gV7UHjs 44m8ghsSIQ1q4BW5u+hJoJmkdbZFnj6y7U17lcgBlgIQb4uomrN2GPXgcc7feZQ6VeHs dPq1Rir8nBVlJM/mrjPyimrop2gCdLEHAQnBGM7EHDC3BmWk5E1qq54N6nHa25YGNrkK fsfPRQIfzAnVfCGKMePrS15pCOA9H6GocC3f51rgmP8jHOO/gsAfOon240XE/FvhjbQQ 0w== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3qsbxer04h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 23 May 2023 21:53:53 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Tue, 23 May 2023 21:53:52 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Tue, 23 May 2023 21:53:52 -0700 Received: from satheeshpaullabpc.. (unknown [10.28.34.33]) by maili.marvell.com (Postfix) with ESMTP id 129C43F703F; Tue, 23 May 2023 21:53:49 -0700 (PDT) From: To: Nithin Dabilpuram , Kiran Kumar K , Sunil Kumar Kori , Satha Rao CC: , Satheesh Paul Subject: [dpdk-dev] [PATCH v2 1/2] common/cnxk: support Tx queue flow pattern in ROC API Date: Wed, 24 May 2023 10:23:45 +0530 Message-ID: <20230524045346.2477489-1-psatheesh@marvell.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230519034219.2209868-1-psatheesh@marvell.com> References: <20230519034219.2209868-1-psatheesh@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: yGrSGfOvQhXD2tlqkCMRuRd7YUQqG9et X-Proofpoint-GUID: yGrSGfOvQhXD2tlqkCMRuRd7YUQqG9et X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-05-24_02,2023-05-23_02,2023-05-22_02 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 From: Satheesh Paul Added ROC API changes to support Tx queue flow pattern item. Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar K --- v2: * Updated documentation for Tx queue pattern item and verified generated documents as well. drivers/common/cnxk/roc_npc.c | 16 +++++--- drivers/common/cnxk/roc_npc.h | 1 + drivers/common/cnxk/roc_npc_mcam.c | 61 +++++++++++++++++++++++------ drivers/common/cnxk/roc_npc_parse.c | 52 ++++++++++++++++++++++++ drivers/common/cnxk/roc_npc_priv.h | 2 + 5 files changed, 115 insertions(+), 17 deletions(-) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index d556b4c3a5..1baa71fc45 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -779,11 +779,10 @@ npc_parse_pattern(struct npc *npc, const struct roc_npc_item_info pattern[], struct roc_npc_flow *flow, struct npc_parse_state *pst) { npc_parse_stage_func_t parse_stage_funcs[] = { - npc_parse_meta_items, npc_parse_mark_item, npc_parse_pre_l2, - npc_parse_cpt_hdr, npc_parse_higig2_hdr, npc_parse_la, - npc_parse_lb, npc_parse_lc, npc_parse_ld, - npc_parse_le, npc_parse_lf, npc_parse_lg, - npc_parse_lh, + npc_parse_meta_items, npc_parse_mark_item, npc_parse_pre_l2, npc_parse_cpt_hdr, + npc_parse_higig2_hdr, npc_parse_tx_queue, npc_parse_la, npc_parse_lb, + npc_parse_lc, npc_parse_ld, npc_parse_le, npc_parse_lf, + npc_parse_lg, npc_parse_lh, }; uint8_t layer = 0; int key_offset; @@ -792,9 +791,9 @@ npc_parse_pattern(struct npc *npc, const struct roc_npc_item_info pattern[], if (pattern == NULL) return NPC_ERR_PARAM; - memset(pst, 0, sizeof(*pst)); pst->npc = npc; pst->flow = flow; + pst->nix_intf = flow->nix_intf; /* Use integral byte offset */ key_offset = pst->npc->keyx_len[flow->nix_intf]; @@ -864,8 +863,12 @@ npc_parse_rule(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, struct npc_parse_state *pst) { struct npc *npc = roc_npc_to_npc_priv(roc_npc); + struct roc_nix *roc_nix = roc_npc->roc_nix; + struct nix *nix = roc_nix_to_nix_priv(roc_nix); int err; + pst->nb_tx_queues = nix->nb_tx_queues; + /* Check attr */ err = npc_parse_attr(npc, attr, flow); if (err) @@ -1445,6 +1448,7 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, return NULL; } memset(flow, 0, sizeof(*flow)); + memset(&parse_state, 0, sizeof(parse_state)); rc = npc_parse_rule(roc_npc, attr, pattern, actions, flow, &parse_state); diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index 26a43c12cb..5984da1c1a 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -39,6 +39,7 @@ enum roc_npc_item_type { ROC_NPC_ITEM_TYPE_QINQ, ROC_NPC_ITEM_TYPE_RAW, ROC_NPC_ITEM_TYPE_MARK, + ROC_NPC_ITEM_TYPE_TX_QUEUE, ROC_NPC_ITEM_TYPE_END, }; diff --git a/drivers/common/cnxk/roc_npc_mcam.c b/drivers/common/cnxk/roc_npc_mcam.c index 72892be300..e0019818c7 100644 --- a/drivers/common/cnxk/roc_npc_mcam.c +++ b/drivers/common/cnxk/roc_npc_mcam.c @@ -587,9 +587,47 @@ npc_mcam_set_channel(struct roc_npc_flow *flow, flow->mcam_mask[0] |= (uint64_t)mask; } +static int +npc_mcam_set_pf_func(struct npc *npc, struct roc_npc_flow *flow, uint16_t pf_func) +{ +#define NPC_PF_FUNC_WIDTH 2 +#define NPC_KEX_PF_FUNC_MASK 0xFFFF + uint16_t nr_bytes, hdr_offset, key_offset, pf_func_offset; + uint8_t *flow_mcam_data, *flow_mcam_mask; + struct npc_lid_lt_xtract_info *xinfo; + bool pffunc_found = false; + uint16_t mask = 0xFFFF; + int i; + + flow_mcam_data = (uint8_t *)flow->mcam_data; + flow_mcam_mask = (uint8_t *)flow->mcam_mask; + + xinfo = &npc->prx_dxcfg[NIX_INTF_TX][NPC_LID_LA][NPC_LT_LA_IH_NIX_ETHER]; + + for (i = 0; i < NPC_MAX_LD; i++) { + nr_bytes = xinfo->xtract[i].len; + hdr_offset = xinfo->xtract[i].hdr_off; + key_offset = xinfo->xtract[i].key_off; + + if (hdr_offset > 0 || nr_bytes < NPC_PF_FUNC_WIDTH) + continue; + else + pffunc_found = true; + + pf_func_offset = key_offset + nr_bytes - NPC_PF_FUNC_WIDTH; + memcpy((void *)&flow_mcam_data[pf_func_offset], (uint8_t *)&pf_func, + NPC_PF_FUNC_WIDTH); + memcpy((void *)&flow_mcam_mask[pf_func_offset], (uint8_t *)&mask, + NPC_PF_FUNC_WIDTH); + } + if (!pffunc_found) + return -EINVAL; + + return 0; +} + int -npc_mcam_alloc_and_write(struct npc *npc, struct roc_npc_flow *flow, - struct npc_parse_state *pst) +npc_mcam_alloc_and_write(struct npc *npc, struct roc_npc_flow *flow, struct npc_parse_state *pst) { struct npc_mcam_write_entry_req *req; struct nix_inl_dev *inl_dev = NULL; @@ -668,6 +706,16 @@ npc_mcam_alloc_and_write(struct npc *npc, struct roc_npc_flow *flow, */ req->entry_data.vtag_action = flow->vtag_action; + if (flow->nix_intf == NIX_INTF_TX) { + uint16_t pf_func = (flow->npc_action >> 4) & 0xffff; + + pf_func = plt_cpu_to_be_16(pf_func); + + rc = npc_mcam_set_pf_func(npc, flow, pf_func); + if (rc) + return rc; + } + for (idx = 0; idx < ROC_NPC_MAX_MCAM_WIDTH_DWORDS; idx++) { req->entry_data.kw[idx] = flow->mcam_data[idx]; req->entry_data.kw_mask[idx] = flow->mcam_mask[idx]; @@ -718,15 +766,6 @@ npc_mcam_alloc_and_write(struct npc *npc, struct roc_npc_flow *flow, flow->mcam_mask[0] |= (0x7ULL << la_offset); } } - } else { - uint16_t pf_func = (flow->npc_action >> 4) & 0xffff; - - pf_func = plt_cpu_to_be_16(pf_func); - req->entry_data.kw[0] |= ((uint64_t)pf_func << 32); - req->entry_data.kw_mask[0] |= ((uint64_t)0xffff << 32); - - flow->mcam_data[0] |= ((uint64_t)pf_func << 32); - flow->mcam_mask[0] |= ((uint64_t)0xffff << 32); } rc = mbox_process_msg(mbox, (void *)&rsp); diff --git a/drivers/common/cnxk/roc_npc_parse.c b/drivers/common/cnxk/roc_npc_parse.c index 571fdb36fc..acaebaed21 100644 --- a/drivers/common/cnxk/roc_npc_parse.c +++ b/drivers/common/cnxk/roc_npc_parse.c @@ -181,6 +181,58 @@ npc_parse_higig2_hdr(struct npc_parse_state *pst) return npc_update_parse_state(pst, &info, lid, lt, 0); } +int +npc_parse_tx_queue(struct npc_parse_state *pst) +{ + struct nix_inst_hdr_s nix_inst_hdr, nix_inst_hdr_mask; + uint8_t hw_mask[NPC_MAX_EXTRACT_HW_LEN]; + struct npc_parse_item_info parse_info; + const uint16_t *send_queue; + int lid, lt, rc = 0; + + memset(&nix_inst_hdr, 0, sizeof(nix_inst_hdr)); + memset(&nix_inst_hdr_mask, 0, sizeof(nix_inst_hdr_mask)); + memset(&parse_info, 0, sizeof(parse_info)); + + if (pst->pattern->type != ROC_NPC_ITEM_TYPE_TX_QUEUE) + return 0; + + if (pst->flow->nix_intf != NIX_INTF_TX) + return NPC_ERR_INVALID_SPEC; + + lid = NPC_LID_LA; + lt = NPC_LT_LA_IH_NIX_ETHER; + send_queue = (const uint16_t *)pst->pattern->spec; + + if (*send_queue >= pst->nb_tx_queues) + return NPC_ERR_INVALID_SPEC; + + nix_inst_hdr.sq = *send_queue; + nix_inst_hdr_mask.sq = 0xFFFF; + + parse_info.def_mask = NULL; + parse_info.spec = &nix_inst_hdr; + parse_info.mask = &nix_inst_hdr_mask; + parse_info.len = sizeof(nix_inst_hdr); + parse_info.def_mask = NULL; + parse_info.hw_hdr_len = 0; + + memset(hw_mask, 0, sizeof(hw_mask)); + + parse_info.hw_mask = &hw_mask; + npc_get_hw_supp_mask(pst, &parse_info, lid, lt); + + rc = npc_mask_is_supported(parse_info.mask, parse_info.hw_mask, parse_info.len); + if (!rc) + return NPC_ERR_INVALID_MASK; + + rc = npc_update_parse_state(pst, &parse_info, lid, lt, 0); + if (rc) + return rc; + + return 0; +} + int npc_parse_la(struct npc_parse_state *pst) { diff --git a/drivers/common/cnxk/roc_npc_priv.h b/drivers/common/cnxk/roc_npc_priv.h index 714dcb09c9..6f41df18bb 100644 --- a/drivers/common/cnxk/roc_npc_priv.h +++ b/drivers/common/cnxk/roc_npc_priv.h @@ -200,6 +200,7 @@ struct npc_parse_state { bool set_ipv6ext_ltype_mask; bool is_second_pass_rule; bool has_eth_type; + uint16_t nb_tx_queues; }; enum npc_kpu_parser_flag { @@ -448,6 +449,7 @@ int npc_parse_mark_item(struct npc_parse_state *pst); int npc_parse_pre_l2(struct npc_parse_state *pst); int npc_parse_higig2_hdr(struct npc_parse_state *pst); int npc_parse_cpt_hdr(struct npc_parse_state *pst); +int npc_parse_tx_queue(struct npc_parse_state *pst); int npc_parse_la(struct npc_parse_state *pst); int npc_parse_lb(struct npc_parse_state *pst); int npc_parse_lc(struct npc_parse_state *pst); -- 2.39.2