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 106D4A0C55; Wed, 13 Oct 2021 18:43:47 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7C4504117B; Wed, 13 Oct 2021 18:43:11 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id C072140151 for ; Wed, 13 Oct 2021 18:42:58 +0200 (CEST) Received: from localhost.localdomain (unknown [5.144.123.99]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id 8DCD27F6FB; Wed, 13 Oct 2021 19:42:58 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 8DCD27F6FB DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1634143378; bh=7/q4fzUQxPP4V/syQQfKoukhqcS6WE4Ivqkxcr44Uno=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=HrbgR6Rgb/ymnXXGgBUY4QwhGAMEBAnX6n2UEp6DlaFcAMZWwKUDngy1QG9T020qC UU+I3DlRIKuyLEypTZn7t12uZ1RVDjLlnrQbcJKVMVLdI1RWExSngpJpoWhefBdIV7 mOGmAWlAQB/QYAoqncUn9nHoSHSzj+dbC8cpYOLo= From: Ivan Malov To: dev@dpdk.org Cc: Ferruh Yigit , Thomas Monjalon , Ori Kam , Andrew Rybchenko , Ajit Khaparde , Somnath Kotur Date: Wed, 13 Oct 2021 19:42:38 +0300 Message-Id: <20211013164243.21264-8-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211013164243.21264-1-ivan.malov@oktetlabs.ru> References: <20211001134716.1608857-1-andrew.rybchenko@oktetlabs.ru> <20211013164243.21264-1-ivan.malov@oktetlabs.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v4 07/12] net/bnxt: support meta flow items to match on traffic source 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 Sender: "dev" From: Andrew Rybchenko Add support for items PORT_REPRESENTOR and REPRESENTED_PORT based on the existing support for item PORT_ID. The use of item PORT_ID depends on the specified direction attribute. Items PORT_REPRESENTOR and REPRESENTED_PORT, in turn, define traffic direction themselves. The former matches traffic from the driver's vNIC. The latter matches packets from either a v-port (network) or a VF's vNIC (if the driver's port is a VF representor). Signed-off-by: Andrew Rybchenko --- doc/guides/nics/features/bnxt.ini | 2 + drivers/net/bnxt/tf_ulp/ulp_rte_handler_tbl.c | 10 ++- drivers/net/bnxt/tf_ulp/ulp_rte_parser.c | 77 ++++++++++++++----- drivers/net/bnxt/tf_ulp/ulp_rte_parser.h | 6 +- 4 files changed, 72 insertions(+), 23 deletions(-) diff --git a/doc/guides/nics/features/bnxt.ini b/doc/guides/nics/features/bnxt.ini index 60cc8bfa15..1b58caa4ac 100644 --- a/doc/guides/nics/features/bnxt.ini +++ b/doc/guides/nics/features/bnxt.ini @@ -69,6 +69,8 @@ udp = Y vf = Y vlan = Y vxlan = Y +port_representor = Y +represented_port = Y [rte_flow actions] count = Y diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_handler_tbl.c b/drivers/net/bnxt/tf_ulp/ulp_rte_handler_tbl.c index 9b165c12b5..d28dd2e587 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_rte_handler_tbl.c +++ b/drivers/net/bnxt/tf_ulp/ulp_rte_handler_tbl.c @@ -266,7 +266,7 @@ struct bnxt_ulp_rte_hdr_info ulp_hdr_info[] = { }, [RTE_FLOW_ITEM_TYPE_PORT_ID] = { .hdr_type = BNXT_ULP_HDR_TYPE_SUPPORTED, - .proto_hdr_func = ulp_rte_port_id_hdr_handler + .proto_hdr_func = ulp_rte_port_hdr_handler }, [RTE_FLOW_ITEM_TYPE_RAW] = { .hdr_type = BNXT_ULP_HDR_TYPE_NOT_SUPPORTED, @@ -427,6 +427,14 @@ struct bnxt_ulp_rte_hdr_info ulp_hdr_info[] = { [RTE_FLOW_ITEM_TYPE_HIGIG2] = { .hdr_type = BNXT_ULP_HDR_TYPE_NOT_SUPPORTED, .proto_hdr_func = NULL + }, + [RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR] = { + .hdr_type = BNXT_ULP_HDR_TYPE_SUPPORTED, + .proto_hdr_func = ulp_rte_port_hdr_handler + }, + [RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT] = { + .hdr_type = BNXT_ULP_HDR_TYPE_SUPPORTED, + .proto_hdr_func = ulp_rte_port_hdr_handler } }; diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c index f1e270af8b..efda522c3e 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c +++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c @@ -400,7 +400,8 @@ bnxt_ulp_rte_parser_direction_compute(struct ulp_rte_parser_params *params) static int32_t ulp_rte_parser_svif_set(struct ulp_rte_parser_params *params, uint32_t ifindex, - uint16_t mask) + uint16_t mask, + enum bnxt_ulp_direction_type item_dir) { uint16_t svif; enum bnxt_ulp_direction_type dir; @@ -429,11 +430,14 @@ ulp_rte_parser_svif_set(struct ulp_rte_parser_params *params, bnxt_ulp_rte_parser_direction_compute(params); /* Get the computed direction */ - dir = ULP_COMP_FLD_IDX_RD(params, BNXT_ULP_CF_IDX_DIRECTION); - if (dir == BNXT_ULP_DIR_INGRESS) { + dir = (item_dir != BNXT_ULP_DIR_INVALID) ? item_dir : + ULP_COMP_FLD_IDX_RD(params, BNXT_ULP_CF_IDX_DIRECTION); + if (dir == BNXT_ULP_DIR_INGRESS && + port_type != BNXT_ULP_INTF_TYPE_VF_REP) { svif_type = BNXT_ULP_PHY_PORT_SVIF; } else { - if (port_type == BNXT_ULP_INTF_TYPE_VF_REP) + if (port_type == BNXT_ULP_INTF_TYPE_VF_REP && + item_dir != BNXT_ULP_DIR_EGRESS) svif_type = BNXT_ULP_VF_FUNC_SVIF; else svif_type = BNXT_ULP_DRV_FUNC_SVIF; @@ -474,7 +478,8 @@ ulp_rte_parser_implicit_match_port_process(struct ulp_rte_parser_params *params) } /* Update the SVIF details */ - rc = ulp_rte_parser_svif_set(params, ifindex, svif_mask); + rc = ulp_rte_parser_svif_set(params, ifindex, svif_mask, + BNXT_ULP_DIR_INVALID); return rc; } @@ -522,7 +527,8 @@ ulp_rte_pf_hdr_handler(const struct rte_flow_item *item __rte_unused, } /* Update the SVIF details */ - return ulp_rte_parser_svif_set(params, ifindex, svif_mask); + return ulp_rte_parser_svif_set(params, ifindex, svif_mask, + BNXT_ULP_DIR_INVALID); } /* Function to handle the parsing of RTE Flow item VF Header. */ @@ -555,39 +561,72 @@ ulp_rte_vf_hdr_handler(const struct rte_flow_item *item, return rc; } /* Update the SVIF details */ - return ulp_rte_parser_svif_set(params, ifindex, mask); + return ulp_rte_parser_svif_set(params, ifindex, mask, + BNXT_ULP_DIR_INVALID); } -/* Function to handle the parsing of RTE Flow item port id Header. */ +/* Parse items PORT_ID, PORT_REPRESENTOR and REPRESENTED_PORT. */ int32_t -ulp_rte_port_id_hdr_handler(const struct rte_flow_item *item, - struct ulp_rte_parser_params *params) +ulp_rte_port_hdr_handler(const struct rte_flow_item *item, + struct ulp_rte_parser_params *params) { - const struct rte_flow_item_port_id *port_spec = item->spec; - const struct rte_flow_item_port_id *port_mask = item->mask; + enum bnxt_ulp_direction_type item_dir; + uint16_t ethdev_id; uint16_t mask = 0; int32_t rc = BNXT_TF_RC_PARSE_ERR; uint32_t ifindex; - if (!port_spec) { - BNXT_TF_DBG(ERR, "ParseErr:Port id is not valid\n"); + if (!item->spec) { + BNXT_TF_DBG(ERR, "ParseErr:Port spec is not valid\n"); return rc; } - if (!port_mask) { - BNXT_TF_DBG(ERR, "ParseErr:Phy Port mask is not valid\n"); + if (!item->mask) { + BNXT_TF_DBG(ERR, "ParseErr:Port mask is not valid\n"); + return rc; + } + + switch (item->type) { + case RTE_FLOW_ITEM_TYPE_PORT_ID: { + const struct rte_flow_item_port_id *port_spec = item->spec; + const struct rte_flow_item_port_id *port_mask = item->mask; + + item_dir = BNXT_ULP_DIR_INVALID; + ethdev_id = port_spec->id; + mask = port_mask->id; + break; + } + case RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR: { + const struct rte_flow_item_ethdev *ethdev_spec = item->spec; + const struct rte_flow_item_ethdev *ethdev_mask = item->mask; + + item_dir = BNXT_ULP_DIR_INGRESS; + ethdev_id = ethdev_spec->port_id; + mask = ethdev_mask->port_id; + break; + } + case RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT: { + const struct rte_flow_item_ethdev *ethdev_spec = item->spec; + const struct rte_flow_item_ethdev *ethdev_mask = item->mask; + + item_dir = BNXT_ULP_DIR_EGRESS; + ethdev_id = ethdev_spec->port_id; + mask = ethdev_mask->port_id; + break; + } + default: + BNXT_TF_DBG(ERR, "ParseErr:Unexpected item\n"); return rc; } - mask = port_mask->id; /* perform the conversion from dpdk port to bnxt ifindex */ if (ulp_port_db_dev_port_to_ulp_index(params->ulp_ctx, - port_spec->id, + ethdev_id, &ifindex)) { BNXT_TF_DBG(ERR, "ParseErr:Portid is not valid\n"); return rc; } /* Update the SVIF details */ - return ulp_rte_parser_svif_set(params, ifindex, mask); + return ulp_rte_parser_svif_set(params, ifindex, mask, item_dir); } /* Function to handle the parsing of RTE Flow item phy port Header. */ diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h index e14f86278a..0acb93946b 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h +++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h @@ -90,10 +90,10 @@ int32_t ulp_rte_vf_hdr_handler(const struct rte_flow_item *item, struct ulp_rte_parser_params *params); -/* Function to handle the parsing of RTE Flow item port id Header. */ +/* Parse items PORT_ID, PORT_REPRESENTOR and REPRESENTED_PORT. */ int32_t -ulp_rte_port_id_hdr_handler(const struct rte_flow_item *item, - struct ulp_rte_parser_params *params); +ulp_rte_port_hdr_handler(const struct rte_flow_item *item, + struct ulp_rte_parser_params *params); /* Function to handle the parsing of RTE Flow item port Header. */ int32_t -- 2.20.1