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 70D4BA0032; Fri, 1 Oct 2021 15:48:21 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 31975411F9; Fri, 1 Oct 2021 15:48:02 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 39FCB411DF for ; Fri, 1 Oct 2021 15:48:00 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id 018167F6E2; Fri, 1 Oct 2021 16:47:59 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id 559507F6D8; Fri, 1 Oct 2021 16:47:28 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 559507F6D8 Authentication-Results: shelob.oktetlabs.ru/559507F6D8; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: Ajit Khaparde , Somnath Kotur Cc: dev@dpdk.org, Ori Kam , Thomas Monjalon , Ferruh Yigit , Ivan Malov Date: Fri, 1 Oct 2021 16:47:12 +0300 Message-Id: <20211001134716.1608857-9-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211001134716.1608857-1-andrew.rybchenko@oktetlabs.ru> References: <20210907125157.3843-1-ivan.malov@oktetlabs.ru> <20211001134716.1608857-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v1 08/12] net/bnxt: support ethdev and E-Switch port flow actions 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" Add support for RTE_FLOW_ACTION_TYPE_ETHDEV and RTE_FLOW_ACTION_TYPE_ESWITCH_PORT actions based on RTE_FLOW_ACTION_TYPE_PORT_ID action. Signed-off-by: Andrew Rybchenko --- drivers/net/bnxt/tf_ulp/ulp_rte_handler_tbl.c | 12 ++- drivers/net/bnxt/tf_ulp/ulp_rte_parser.c | 84 ++++++++++++++----- drivers/net/bnxt/tf_ulp/ulp_rte_parser.h | 9 +- 3 files changed, 80 insertions(+), 25 deletions(-) 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 87914cc845..a31728c217 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_rte_handler_tbl.c +++ b/drivers/net/bnxt/tf_ulp/ulp_rte_handler_tbl.c @@ -67,7 +67,7 @@ struct bnxt_ulp_rte_act_info ulp_act_info[] = { }, [RTE_FLOW_ACTION_TYPE_PORT_ID] = { .act_type = BNXT_ULP_ACT_TYPE_SUPPORTED, - .proto_act_func = ulp_rte_port_id_act_handler + .proto_act_func = ulp_rte_port_act_handler }, [RTE_FLOW_ACTION_TYPE_METER] = { .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, @@ -212,7 +212,15 @@ struct bnxt_ulp_rte_act_info ulp_act_info[] = { [RTE_FLOW_ACTION_TYPE_SAMPLE] = { .act_type = BNXT_ULP_ACT_TYPE_SUPPORTED, .proto_act_func = ulp_rte_sample_act_handler - } + }, + [RTE_FLOW_ACTION_TYPE_ETHDEV] = { + .act_type = BNXT_ULP_ACT_TYPE_SUPPORTED, + .proto_act_func = ulp_rte_port_act_handler + }, + [RTE_FLOW_ACTION_TYPE_ESWITCH_PORT] = { + .act_type = BNXT_ULP_ACT_TYPE_SUPPORTED, + .proto_act_func = ulp_rte_port_act_handler + }, }; struct bnxt_ulp_rte_act_info ulp_vendor_act_info[] = { diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c index c747150864..8e04229ee7 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c +++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c @@ -496,10 +496,11 @@ ulp_rte_parser_implicit_act_port_process(struct ulp_rte_parser_params *params) return BNXT_TF_RC_SUCCESS; } port_id.id = ULP_COMP_FLD_IDX_RD(params, BNXT_ULP_CF_IDX_INCOMING_IF); + action_item.type = RTE_FLOW_ACTION_TYPE_PORT_ID; action_item.conf = &port_id; /* Update the action port based on incoming port */ - ulp_rte_port_id_act_handler(&action_item, params); + ulp_rte_port_act_handler(&action_item, params); /* Reset the action port set bit */ ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_ACT_PORT_IS_SET, 0); @@ -2171,7 +2172,8 @@ ulp_rte_count_act_handler(const struct rte_flow_action *action_item, /* Function to handle the parsing of action ports. */ static int32_t ulp_rte_parser_act_port_set(struct ulp_rte_parser_params *param, - uint32_t ifindex) + uint32_t ifindex, + enum bnxt_ulp_direction_type act_dir) { enum bnxt_ulp_direction_type dir; uint16_t pid_s; @@ -2181,8 +2183,13 @@ ulp_rte_parser_act_port_set(struct ulp_rte_parser_params *param, uint32_t vnic_type; /* Get the direction */ - dir = ULP_COMP_FLD_IDX_RD(param, BNXT_ULP_CF_IDX_DIRECTION); - if (dir == BNXT_ULP_DIR_EGRESS) { + /* If action implicitly specifies direction, use the specification. */ + dir = (act_dir == BNXT_ULP_DIR_INVALID) ? + ULP_COMP_FLD_IDX_RD(param, BNXT_ULP_CF_IDX_DIRECTION) : + act_dir; + port_type = ULP_COMP_FLD_IDX_RD(param, BNXT_ULP_CF_IDX_ACT_PORT_TYPE); + if (dir == BNXT_ULP_DIR_EGRESS && + port_type != BNXT_ULP_INTF_TYPE_VF_REP) { /* For egress direction, fill vport */ if (ulp_port_db_vport_get(param->ulp_ctx, ifindex, &pid_s)) return BNXT_TF_RC_ERROR; @@ -2193,9 +2200,14 @@ ulp_rte_parser_act_port_set(struct ulp_rte_parser_params *param, &pid, BNXT_ULP_ACT_PROP_SZ_VPORT); } else { /* For ingress direction, fill vnic */ - port_type = ULP_COMP_FLD_IDX_RD(param, - BNXT_ULP_CF_IDX_ACT_PORT_TYPE); - if (port_type == BNXT_ULP_INTF_TYPE_VF_REP) + /* + * In ETHDEV action case, destination is a driver + * function of the representor itself, otherwise + * (PORT_ID or ESWITCH_PORT) the destination is + * corresponding VF. + */ + if (act_dir != BNXT_ULP_DIR_INGRESS && + port_type == BNXT_ULP_INTF_TYPE_VF_REP) vnic_type = BNXT_ULP_VF_FUNC_VNIC; else vnic_type = BNXT_ULP_DRV_FUNC_VNIC; @@ -2242,7 +2254,8 @@ ulp_rte_pf_act_handler(const struct rte_flow_action *action_item __rte_unused, } /* Update the action properties */ ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_ACT_PORT_TYPE, intf_type); - return ulp_rte_parser_act_port_set(params, ifindex); + return ulp_rte_parser_act_port_set(params, ifindex, + BNXT_ULP_DIR_INVALID); } /* Function to handle the parsing of RTE Flow action VF. */ @@ -2293,31 +2306,62 @@ ulp_rte_vf_act_handler(const struct rte_flow_action *action_item, /* Update the action properties */ ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_ACT_PORT_TYPE, intf_type); - return ulp_rte_parser_act_port_set(params, ifindex); + return ulp_rte_parser_act_port_set(params, ifindex, + BNXT_ULP_DIR_INVALID); } -/* Function to handle the parsing of RTE Flow action port_id. */ +/* + * Function to handle the parsing of RTE Flow actions PORT_ID, ETHDEV and + * ESWITCH_PORT. + */ int32_t -ulp_rte_port_id_act_handler(const struct rte_flow_action *act_item, - struct ulp_rte_parser_params *param) +ulp_rte_port_act_handler(const struct rte_flow_action *act_item, + struct ulp_rte_parser_params *param) { - const struct rte_flow_action_port_id *port_id = act_item->conf; + uint32_t ethdev_id; uint32_t ifindex; enum bnxt_ulp_intf_type intf_type; + enum bnxt_ulp_direction_type act_dir; - if (!port_id) { + if (!act_item->conf) { BNXT_TF_DBG(ERR, "ParseErr: Invalid Argument\n"); return BNXT_TF_RC_PARSE_ERR; } - if (port_id->original) { - BNXT_TF_DBG(ERR, - "ParseErr:Portid Original not supported\n"); - return BNXT_TF_RC_PARSE_ERR; + switch (act_item->type) { + case RTE_FLOW_ACTION_TYPE_PORT_ID: { + const struct rte_flow_action_port_id *port_id = act_item->conf; + + if (port_id->original) { + BNXT_TF_DBG(ERR, + "ParseErr:Portid Original not supported\n"); + return BNXT_TF_RC_PARSE_ERR; + } + ethdev_id = port_id->id; + act_dir = BNXT_ULP_DIR_INVALID; + break; + } + case RTE_FLOW_ACTION_TYPE_ETHDEV: { + const struct rte_flow_action_ethdev *ethdev = act_item->conf; + + ethdev_id = ethdev->id; + act_dir = BNXT_ULP_DIR_INGRESS; + break; + } + case RTE_FLOW_ACTION_TYPE_ESWITCH_PORT: { + const struct rte_flow_action_ethdev *ethdev = act_item->conf; + + ethdev_id = ethdev->id; + act_dir = BNXT_ULP_DIR_EGRESS; + break; + } + default: + BNXT_TF_DBG(ERR, "Unknown port action\n"); + return BNXT_TF_RC_ERROR; } /* Get the port db ifindex */ - if (ulp_port_db_dev_port_to_ulp_index(param->ulp_ctx, port_id->id, + if (ulp_port_db_dev_port_to_ulp_index(param->ulp_ctx, ethdev_id, &ifindex)) { BNXT_TF_DBG(ERR, "Invalid port id\n"); return BNXT_TF_RC_ERROR; @@ -2332,7 +2376,7 @@ ulp_rte_port_id_act_handler(const struct rte_flow_action *act_item, /* Set the action port */ ULP_COMP_FLD_IDX_WR(param, BNXT_ULP_CF_IDX_ACT_PORT_TYPE, intf_type); - return ulp_rte_parser_act_port_set(param, ifindex); + return ulp_rte_parser_act_port_set(param, ifindex, act_dir); } /* Function to handle the parsing of RTE Flow action phy_port. */ diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h index 531596b00d..307bb5c75c 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h +++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h @@ -207,10 +207,13 @@ int32_t ulp_rte_vf_act_handler(const struct rte_flow_action *action_item, struct ulp_rte_parser_params *params); -/* Function to handle the parsing of RTE Flow action port_id. */ +/* + * Function to handle the parsing of RTE Flow actions PORT_ID, ETHDEV and + * ESWITCH_PORT. + */ int32_t -ulp_rte_port_id_act_handler(const struct rte_flow_action *act_item, - struct ulp_rte_parser_params *params); +ulp_rte_port_act_handler(const struct rte_flow_action *act_item, + struct ulp_rte_parser_params *params); /* Function to handle the parsing of RTE Flow action phy_port. */ int32_t -- 2.30.2