From patchwork Fri Aug 30 14:00:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sriharsha Basavapatna X-Patchwork-Id: 143477 X-Patchwork-Delegate: ajit.khaparde@broadcom.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C5314458A8; Fri, 30 Aug 2024 15:53:03 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EFDF542ECE; Fri, 30 Aug 2024 15:52:14 +0200 (CEST) Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by mails.dpdk.org (Postfix) with ESMTP id 21CDE42EA5 for ; Fri, 30 Aug 2024 15:52:13 +0200 (CEST) Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2021c03c13aso16140755ad.1 for ; Fri, 30 Aug 2024 06:52:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1725025932; x=1725630732; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ufL6EXdhIMUSLbqNO5ULIgNQzB5hYqkyyaPSgiHlplk=; b=eMCChVbuSUWhaMExqsePPePX+Dokx2Koy+jlVxHQvR7ZX+OeWcz40WfkoGJOmXivzF 9XBGgapJYyv9LcP4NqMqj75X27Y/Jt+x1To5AzpejB2FiiYE5VpA5yG1jxnJpixfKfh6 06dSMehREdIJJUjyfb+WX0jvQAdU5n0u5nYSk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725025932; x=1725630732; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ufL6EXdhIMUSLbqNO5ULIgNQzB5hYqkyyaPSgiHlplk=; b=AjWOmIaEiUb13s3hP3GcX4bZZXZ2YIWXjf40vK5omfMyYuATvx3xXarG9G7HFCeXMq 0LL5I/fOw1ig1uq/cnz9h6bZkMcGgZ/W3JEUNiLWhX8RJq5Vg7nygPhOb3/3U2+T8mNV 21JhocPNZ4YtdjiKS/ZOn0BoCS/ufR1b7u226MYkfDxnGScC13su0OhFuzu8wOwGDxwE EdAo8xfeYEbKXwbUhfShxJ3lSvf4J90FxvZqYV1dGPVOi1X3bOlEms/vm+Bb7//XwCBp 9jgYi6UatpBweoag79w6Ya2JH3Y2zNHFbBlOdw9Ynua8P6xwB/mpE6OYQ4Td4keNCNfk DDIg== X-Gm-Message-State: AOJu0YyiTVeBPG30GV9Rt8NV4797B4NuoDHWC2JiX1lURcBtIuyuQy84 xgMf5a+91LxOG/dqhSTyAsfCyG2sLGZUpcnqp4V9VVMGwzzwK9CT69+a9uAvmcFrDYXbu3pS96a bb+ADOqRIdiU6MsZ1dyRFwuMLEYszql+VSvS8jMGGXo6nfvfcCEBMCKtp7ibVy0ZvInCMwBQ82m veGuYN4xa7SY2v6WCBfRtxZ6ykaKdE1NNCCzjQrYXmvnQZ X-Google-Smtp-Source: AGHT+IGaXVqsvrw8I5w1PgFFG9yDmKtz7SqAhAtYh9EUuih04YFB7dCSGVTqDANQv2fkFC9zD1wU6g== X-Received: by 2002:a17:902:c40c:b0:201:dcb0:9fbf with SMTP id d9443c01a7336-2050e98d58bmr101425725ad.15.1725025931628; Fri, 30 Aug 2024 06:52:11 -0700 (PDT) Received: from dhcp-10-123-154-23.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-205155658dfsm27067145ad.297.2024.08.30.06.52.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2024 06:52:11 -0700 (PDT) From: Sriharsha Basavapatna To: dev@dpdk.org Cc: Manish Kurup , Kishore Padmanabha , Sriharsha Basavapatna Subject: [PATCH 15/47] net/bnxt: tf_ulp: Wh+ mirroring support Date: Fri, 30 Aug 2024 19:30:17 +0530 Message-Id: <20240830140049.1715230-16-sriharsha.basavapatna@broadcom.com> X-Mailer: git-send-email 2.39.0.189.g4dbebc36b0 In-Reply-To: <20240830140049.1715230-1-sriharsha.basavapatna@broadcom.com> References: <20240830140049.1715230-1-sriharsha.basavapatna@broadcom.com> MIME-Version: 1.0 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: Manish Kurup 1. ULP fixes to enable primitives to support mirroring 2. RTE parser changes to support and use multiple ports in RTE input msgs 3. Template changes required to support ingress mirroring 4. Template changes required to support egress mirroring (using VFR pipeline) Signed-off-by: Manish Kurup Reviewed-by: Kishore Padmanabha Signed-off-by: Sriharsha Basavapatna --- drivers/net/bnxt/tf_ulp/ulp_mapper.c | 8 + drivers/net/bnxt/tf_ulp/ulp_rte_parser.c | 179 ++++++++++++++++++++--- 2 files changed, 167 insertions(+), 20 deletions(-) diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c b/drivers/net/bnxt/tf_ulp/ulp_mapper.c index 9dda70d75b..eb0f95cfee 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c +++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c @@ -3789,6 +3789,8 @@ ulp_mapper_func_info_process(struct bnxt_ulp_mapper_parms *parms, case BNXT_ULP_FUNC_OPC_GT: case BNXT_ULP_FUNC_OPC_LE: case BNXT_ULP_FUNC_OPC_LT: + case BNXT_ULP_FUNC_OPC_ADD: + case BNXT_ULP_FUNC_OPC_SUB: process_src1 = 1; process_src2 = 1; break; @@ -3841,6 +3843,12 @@ ulp_mapper_func_info_process(struct bnxt_ulp_mapper_parms *parms, if (res1 < res2) res = 1; break; + case BNXT_ULP_FUNC_OPC_ADD: + res = res1 + res2; + break; + case BNXT_ULP_FUNC_OPC_SUB: + res = res1 - res2; + break; case BNXT_ULP_FUNC_OPC_COPY_SRC1_TO_RF: res = res1; break; diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c index 013d8b0a59..da20b41c72 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c +++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c @@ -330,9 +330,21 @@ ulp_post_process_normal_flow(struct ulp_rte_parser_params *params) /* Evaluate the VF to VF flag */ if (act_port_set && act_port_type == BNXT_ULP_INTF_TYPE_VF_REP && - match_port_type == BNXT_ULP_INTF_TYPE_VF_REP) - ULP_BITMAP_SET(params->act_bitmap.bits, - BNXT_ULP_ACT_BIT_VF_TO_VF); + match_port_type == BNXT_ULP_INTF_TYPE_VF_REP) { + if (!ULP_BITMAP_ISSET(params->act_bitmap.bits, + BNXT_ULP_ACT_BIT_MULTIPLE_PORT)) { + ULP_BITMAP_SET(params->act_bitmap.bits, + BNXT_ULP_ACT_BIT_VF_TO_VF); + } else { + if (ULP_COMP_FLD_IDX_RD(params, BNXT_ULP_CF_IDX_MP_A_IS_VFREP) && + ULP_COMP_FLD_IDX_RD(params, BNXT_ULP_CF_IDX_MP_B_IS_VFREP)) + ULP_BITMAP_SET(params->act_bitmap.bits, + BNXT_ULP_ACT_BIT_VF_TO_VF); + else + ULP_BITMAP_RESET(params->act_bitmap.bits, + BNXT_ULP_ACT_BIT_VF_TO_VF); + } + } /* Update the decrement ttl computational fields */ if (ULP_BITMAP_ISSET(params->act_bitmap.bits, @@ -2349,15 +2361,74 @@ ulp_rte_count_act_handler(const struct rte_flow_action *action_item, return BNXT_TF_RC_SUCCESS; } +static bool ulp_rte_parser_is_portb_vfrep(struct ulp_rte_parser_params *param) +{ + return ULP_COMP_FLD_IDX_RD(param, BNXT_ULP_CF_IDX_MP_B_IS_VFREP); +} + +/* + * Swaps info related to multi-port: + * common: + * BNXT_ULP_CF_IDX_MP_B_IS_VFREP, BNXT_ULP_CF_IDX_MP_A_IS_VFREP + * BNXT_ULP_CF_IDX_MP_PORT_A, BNXT_ULP_CF_IDX_MP_PORT_B + * + * ingress: + * BNXT_ULP_CF_IDX_MP_VNIC_B, BNXT_ULP_CF_IDX_MP_VNIC_A + * + * egress: + * BNXT_ULP_CF_IDX_MP_MDATA_B, BNXT_ULP_CF_IDX_MP_MDATA_A + * BNXT_ULP_CF_IDX_MP_VPORT_B, BNXT_ULP_CF_IDX_MP_VPORT_A + * + * Note: This is done as OVS could give us a non-VFREP port in port B, and we + * cannot use that to mirror, so we swap out the ports so that a VFREP is now + * in port B instead. + */ +static int32_t +ulp_rte_parser_normalize_port_info(struct ulp_rte_parser_params *param) +{ + uint16_t mp_port_a, mp_port_b, mp_mdata_a, mp_mdata_b, + mp_vport_a, mp_vport_b, mp_vnic_a, mp_vnic_b, + mp_is_vfrep_a, mp_is_vfrep_b; + + mp_is_vfrep_a = ULP_COMP_FLD_IDX_RD(param, BNXT_ULP_CF_IDX_MP_A_IS_VFREP); + mp_is_vfrep_b = ULP_COMP_FLD_IDX_RD(param, BNXT_ULP_CF_IDX_MP_B_IS_VFREP); + ULP_COMP_FLD_IDX_WR(param, BNXT_ULP_CF_IDX_MP_B_IS_VFREP, mp_is_vfrep_a); + ULP_COMP_FLD_IDX_WR(param, BNXT_ULP_CF_IDX_MP_A_IS_VFREP, mp_is_vfrep_b); + + mp_port_a = ULP_COMP_FLD_IDX_RD(param, BNXT_ULP_CF_IDX_MP_PORT_A); + mp_port_b = ULP_COMP_FLD_IDX_RD(param, BNXT_ULP_CF_IDX_MP_PORT_B); + ULP_COMP_FLD_IDX_WR(param, BNXT_ULP_CF_IDX_MP_PORT_B, mp_port_a); + ULP_COMP_FLD_IDX_WR(param, BNXT_ULP_CF_IDX_MP_PORT_A, mp_port_b); + + mp_vport_a = ULP_COMP_FLD_IDX_RD(param, BNXT_ULP_CF_IDX_MP_VPORT_A); + mp_vport_b = ULP_COMP_FLD_IDX_RD(param, BNXT_ULP_CF_IDX_MP_VPORT_B); + ULP_COMP_FLD_IDX_WR(param, BNXT_ULP_CF_IDX_MP_VPORT_B, mp_vport_a); + ULP_COMP_FLD_IDX_WR(param, BNXT_ULP_CF_IDX_MP_VPORT_A, mp_vport_b); + + mp_vnic_a = ULP_COMP_FLD_IDX_RD(param, BNXT_ULP_CF_IDX_MP_VNIC_A); + mp_vnic_b = ULP_COMP_FLD_IDX_RD(param, BNXT_ULP_CF_IDX_MP_VNIC_B); + ULP_COMP_FLD_IDX_WR(param, BNXT_ULP_CF_IDX_MP_VNIC_B, mp_vnic_a); + ULP_COMP_FLD_IDX_WR(param, BNXT_ULP_CF_IDX_MP_VNIC_A, mp_vnic_b); + + mp_mdata_a = ULP_COMP_FLD_IDX_RD(param, BNXT_ULP_CF_IDX_MP_MDATA_A); + mp_mdata_b = ULP_COMP_FLD_IDX_RD(param, BNXT_ULP_CF_IDX_MP_MDATA_B); + ULP_COMP_FLD_IDX_WR(param, BNXT_ULP_CF_IDX_MP_MDATA_B, mp_mdata_a); + ULP_COMP_FLD_IDX_WR(param, BNXT_ULP_CF_IDX_MP_MDATA_A, mp_mdata_b); + + return BNXT_TF_RC_SUCCESS; +} + + /* 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, bool multi_port, enum bnxt_ulp_direction_type act_dir) { enum bnxt_ulp_direction_type dir; uint16_t pid_s; - uint32_t pid; + uint8_t *p_mdata; + uint32_t pid, port_index; struct ulp_rte_act_prop *act = ¶m->act_prop; enum bnxt_ulp_intf_type port_type; uint32_t vnic_type; @@ -2367,27 +2438,63 @@ ulp_rte_parser_act_port_set(struct ulp_rte_parser_params *param, 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) { + + port_type = ULP_COMP_FLD_IDX_RD(param, + BNXT_ULP_CF_IDX_ACT_PORT_TYPE); + + /* Update flag if Port A/B type is VF-REP */ + ULP_COMP_FLD_IDX_WR(param, multi_port ? + BNXT_ULP_CF_IDX_MP_B_IS_VFREP : + BNXT_ULP_CF_IDX_MP_A_IS_VFREP, + (port_type == BNXT_ULP_INTF_TYPE_VF_REP) ? 1 : 0); + if (dir == BNXT_ULP_DIR_EGRESS) { /* For egress direction, fill vport */ if (ulp_port_db_vport_get(param->ulp_ctx, ifindex, &pid_s)) return BNXT_TF_RC_ERROR; pid = pid_s; pid = rte_cpu_to_be_32(pid); - memcpy(&act->act_details[BNXT_ULP_ACT_PROP_IDX_VPORT], - &pid, BNXT_ULP_ACT_PROP_SZ_VPORT); + if (!multi_port) + memcpy(&act->act_details[BNXT_ULP_ACT_PROP_IDX_VPORT], + &pid, BNXT_ULP_ACT_PROP_SZ_VPORT); + + /* Fill metadata */ + if (port_type == BNXT_ULP_INTF_TYPE_VF_REP) { + port_index = ULP_COMP_FLD_IDX_RD(param, multi_port ? + BNXT_ULP_CF_IDX_MP_PORT_B : + BNXT_ULP_CF_IDX_MP_PORT_A); + if (ulp_port_db_port_meta_data_get(param->ulp_ctx, + port_index, &p_mdata)) + return BNXT_TF_RC_ERROR; + /* + * Update appropriate port (A/B) metadata based on multi-port + * indication + */ + ULP_COMP_FLD_IDX_WR(param, + multi_port ? + BNXT_ULP_CF_IDX_MP_MDATA_B : + BNXT_ULP_CF_IDX_MP_MDATA_A, + rte_cpu_to_be_16(*((uint16_t *)p_mdata))); + } + /* + * Update appropriate port (A/B) VPORT based on multi-port + * indication. + */ + ULP_COMP_FLD_IDX_WR(param, + multi_port ? + BNXT_ULP_CF_IDX_MP_VPORT_B : + BNXT_ULP_CF_IDX_MP_VPORT_A, + pid_s); } else { /* For ingress direction, fill vnic */ /* - * Action Destination + * Action Destination * ------------------------------------ - * PORT_REPRESENTOR Driver Function + * PORT_REPRESENTOR Driver Function * ------------------------------------ - * REPRESENTED_PORT VF + * REPRESENTED_PORT VF * ------------------------------------ - * PORT_ID VF + * PORT_ID VF */ if (act_dir != BNXT_ULP_DIR_INGRESS && port_type == BNXT_ULP_INTF_TYPE_VF_REP) @@ -2401,10 +2508,23 @@ ulp_rte_parser_act_port_set(struct ulp_rte_parser_params *param, pid = pid_s; pid = rte_cpu_to_be_32(pid); - memcpy(&act->act_details[BNXT_ULP_ACT_PROP_IDX_VNIC], - &pid, BNXT_ULP_ACT_PROP_SZ_VNIC); + if (!multi_port) + memcpy(&act->act_details[BNXT_ULP_ACT_PROP_IDX_VNIC], + &pid, BNXT_ULP_ACT_PROP_SZ_VNIC); + /* + * Update appropriate port (A/B) VNIC based on multi-port + * indication. + */ + ULP_COMP_FLD_IDX_WR(param, + multi_port ? + BNXT_ULP_CF_IDX_MP_VNIC_B : + BNXT_ULP_CF_IDX_MP_VNIC_A, + pid_s); } + if (multi_port && !ulp_rte_parser_is_portb_vfrep(param)) + ulp_rte_parser_normalize_port_info(param); + /* Update the action port set bit */ ULP_COMP_FLD_IDX_WR(param, BNXT_ULP_CF_IDX_ACT_PORT_IS_SET, 1); return BNXT_TF_RC_SUCCESS; @@ -2437,7 +2557,7 @@ 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, false, BNXT_ULP_DIR_INVALID); } @@ -2489,7 +2609,7 @@ 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, false, BNXT_ULP_DIR_INVALID); } @@ -2500,12 +2620,14 @@ ulp_rte_port_act_handler(const struct rte_flow_action *act_item, { uint32_t ethdev_id; uint32_t ifindex; + const struct rte_flow_action_port_id *port_id = act_item->conf; + uint32_t num_ports; enum bnxt_ulp_intf_type intf_type; enum bnxt_ulp_direction_type act_dir; if (!act_item->conf) { BNXT_TF_DBG(ERR, - "ParseErr: Invalid Argument\n"); + "ParseErr: Invalid Argument\n"); return BNXT_TF_RC_PARSE_ERR; } switch (act_item->type) { @@ -2540,6 +2662,18 @@ ulp_rte_port_act_handler(const struct rte_flow_action *act_item, return BNXT_TF_RC_ERROR; } + num_ports = ULP_COMP_FLD_IDX_RD(param, BNXT_ULP_CF_IDX_MP_NPORTS); + + if (num_ports) { + ULP_COMP_FLD_IDX_WR(param, BNXT_ULP_CF_IDX_MP_PORT_B, + port_id->id); + ULP_BITMAP_SET(param->act_bitmap.bits, + BNXT_ULP_ACT_BIT_MULTIPLE_PORT); + } else { + ULP_COMP_FLD_IDX_WR(param, BNXT_ULP_CF_IDX_MP_PORT_A, + port_id->id); + } + /* Get the port db ifindex */ if (ulp_port_db_dev_port_to_ulp_index(param->ulp_ctx, ethdev_id, &ifindex)) { @@ -2558,7 +2692,12 @@ ulp_rte_port_act_handler(const struct rte_flow_action *act_item, ULP_COMP_FLD_IDX_WR(param, BNXT_ULP_CF_IDX_ACT_PORT_TYPE, intf_type); ULP_COMP_FLD_IDX_WR(param, BNXT_ULP_CF_IDX_DEV_ACT_PORT_ID, ethdev_id); - return ulp_rte_parser_act_port_set(param, ifindex, act_dir); + + ULP_COMP_FLD_IDX_WR(param, BNXT_ULP_CF_IDX_MP_NPORTS, ++num_ports); + return ulp_rte_parser_act_port_set(param, ifindex, + ULP_BITMAP_ISSET(param->act_bitmap.bits, + BNXT_ULP_ACT_BIT_MULTIPLE_PORT), + act_dir); } /* Function to handle the parsing of RTE Flow action pop vlan. */