DPDK patches and discussions
 help / color / mirror / Atom feed
From: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
To: dev@dpdk.org
Cc: Kishore Padmanabha <kishore.padmanabha@broadcom.com>,
	Shahaji Bhosle <shahaji.bhosle@broadcom.com>,
	Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
Subject: [PATCH 14/47] net/bnxt: tf_ulp: add support for vf to vf flow offload
Date: Fri, 30 Aug 2024 19:30:16 +0530	[thread overview]
Message-ID: <20240830140049.1715230-15-sriharsha.basavapatna@broadcom.com> (raw)
In-Reply-To: <20240830140049.1715230-1-sriharsha.basavapatna@broadcom.com>

From: Kishore Padmanabha <kishore.padmanabha@broadcom.com>

Added support for the vf to vf flow offload for the whitney platform.
It includes the change of the pipeline from using vlan tags to using
custom L2 encap and decap of the packets.

Signed-off-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Reviewed-by: Shahaji Bhosle <shahaji.bhosle@broadcom.com>
Signed-off-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
---
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c      |  5 ++++
 drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c | 32 +++++++++++++++++++++++++
 drivers/net/bnxt/tf_ulp/ulp_def_rules.c | 26 ++++++++++++++++++++
 drivers/net/bnxt/tf_ulp/ulp_mapper.c    |  6 +++++
 drivers/net/bnxt/tf_ulp/ulp_port_db.c   | 32 +++++++++++++++++++++++++
 drivers/net/bnxt/tf_ulp/ulp_port_db.h   | 13 ++++++++++
 6 files changed, 114 insertions(+)

diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
index 912946303a..3f0a5f2300 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
@@ -1927,6 +1927,11 @@ bnxt_ulp_port_init(struct bnxt *bp)
 		}
 	}
 
+	/* setup the l2 etype tunnel for custom l2 encap/decap */
+	rc = ulp_l2_etype_tunnel_alloc(bp);
+	if (rc)
+		goto jump_to_error;
+
 	/* Update bnxt driver flags */
 	rc = ulp_dparms_dev_port_intf_update(bp, bp->ulp_ctx);
 	if (rc) {
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c
index ad04644db4..2f159ae486 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c
@@ -606,6 +606,38 @@ bnxt_ulp_action_handle_create(struct rte_eth_dev *dev,
 					    BNXT_ULP_DIR_EGRESS);
 	}
 
+	/* perform the conversion from dpdk port to bnxt ifindex */
+	if (ulp_port_db_dev_port_to_ulp_index(ulp_ctx,
+					      dev->data->port_id,
+					      &ifindex)) {
+		BNXT_TF_DBG(ERR, "Port id is not valid\n");
+		goto parse_error;
+	}
+	port_type = ulp_port_db_port_type_get(ulp_ctx, ifindex);
+	if (port_type == BNXT_ULP_INTF_TYPE_INVALID) {
+		BNXT_TF_DBG(ERR, "Port type is not valid\n");
+		goto parse_error;
+	}
+
+	bnxt_ulp_init_parser_cf_defaults(&params, dev->data->port_id);
+
+	/* Emulating the match port for direction processing */
+	ULP_COMP_FLD_IDX_WR(&params, BNXT_ULP_CF_IDX_MATCH_PORT_TYPE,
+			    port_type);
+
+	if ((params.dir_attr & BNXT_ULP_FLOW_ATTR_INGRESS) &&
+	    port_type == BNXT_ULP_INTF_TYPE_VF_REP) {
+		ULP_COMP_FLD_IDX_WR(&params, BNXT_ULP_CF_IDX_DIRECTION,
+				    BNXT_ULP_DIR_EGRESS);
+	} else {
+		/* Assign the input direction */
+		if (params.dir_attr & BNXT_ULP_FLOW_ATTR_INGRESS)
+			ULP_COMP_FLD_IDX_WR(&params, BNXT_ULP_CF_IDX_DIRECTION,
+					    BNXT_ULP_DIR_INGRESS);
+		else
+			ULP_COMP_FLD_IDX_WR(&params, BNXT_ULP_CF_IDX_DIRECTION,
+					    BNXT_ULP_DIR_EGRESS);
+	}
 	/* Parse the shared action */
 	ret = bnxt_ulp_rte_parser_act_parse(actions, &params);
 	if (ret != BNXT_TF_RC_SUCCESS)
diff --git a/drivers/net/bnxt/tf_ulp/ulp_def_rules.c b/drivers/net/bnxt/tf_ulp/ulp_def_rules.c
index 8237dbd294..e2d281130e 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_def_rules.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_def_rules.c
@@ -12,6 +12,10 @@
 #include "ulp_flow_db.h"
 #include "ulp_mapper.h"
 
+static void
+ulp_l2_custom_tunnel_id_update(struct bnxt *bp,
+			       struct bnxt_ulp_mapper_create_parms *params);
+
 struct bnxt_ulp_def_param_handler {
 	int32_t (*vfr_func)(struct bnxt_ulp_context *ulp_ctx,
 			    struct ulp_tlv_param *param,
@@ -306,6 +310,7 @@ ulp_default_flow_create(struct rte_eth_dev *eth_dev,
 	struct ulp_rte_act_bitmap	act = { 0 };
 	struct bnxt_ulp_context		*ulp_ctx;
 	uint32_t type, ulp_flags = 0, fid;
+	struct bnxt *bp = eth_dev->data->dev_private;
 	int rc = 0;
 
 	memset(&mapper_params, 0, sizeof(mapper_params));
@@ -366,6 +371,9 @@ ulp_default_flow_create(struct rte_eth_dev *eth_dev,
 	ULP_COMP_FLD_IDX_WR(&mapper_params, BNXT_ULP_CF_IDX_VF_META_FID,
 			    BNXT_ULP_META_VF_FLAG | mapper_params.func_id);
 
+	/* update the upar id */
+	ulp_l2_custom_tunnel_id_update(bp, &mapper_params);
+
 	BNXT_TF_DBG(DEBUG, "Creating default flow with template id: %u\n",
 		    ulp_class_tid);
 
@@ -641,3 +649,21 @@ bnxt_ulp_delete_vfr_default_rules(struct bnxt_representor *vfr)
 	memset(info, 0, sizeof(struct bnxt_ulp_vfr_rule_info));
 	return 0;
 }
+
+static void
+ulp_l2_custom_tunnel_id_update(struct bnxt *bp,
+			       struct bnxt_ulp_mapper_create_parms *params)
+{
+	if (!bp->l2_etype_tunnel_cnt)
+		return;
+
+	if (bp->l2_etype_upar_in_use &
+	    HWRM_TUNNEL_DST_PORT_QUERY_OUTPUT_UPAR_IN_USE_UPAR0) {
+		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_L2_CUSTOM_UPAR_ID,
+				    ULP_WP_SYM_TUN_HDR_TYPE_UPAR1);
+	} else if (bp->l2_etype_upar_in_use &
+		   HWRM_TUNNEL_DST_PORT_QUERY_OUTPUT_UPAR_IN_USE_UPAR1) {
+		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_L2_CUSTOM_UPAR_ID,
+				    ULP_WP_SYM_TUN_HDR_TYPE_UPAR2);
+	}
+}
diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
index ea1311c0c4..9dda70d75b 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
@@ -1073,6 +1073,12 @@ ulp_mapper_field_port_db_process(struct bnxt_ulp_mapper_parms *parms,
 			return -EINVAL;
 		}
 		break;
+	case BNXT_ULP_PORT_TABLE_VF_FUNC_FID:
+		if (ulp_port_db_port_vf_fid_get(parms->ulp_ctx, port_id, val)) {
+			BNXT_TF_DBG(ERR, "Invalid port id %u\n", port_id);
+			return -EINVAL;
+		}
+		break;
 	default:
 		BNXT_TF_DBG(ERR, "Invalid port_data %d\n", port_data);
 		return -EINVAL;
diff --git a/drivers/net/bnxt/tf_ulp/ulp_port_db.c b/drivers/net/bnxt/tf_ulp/ulp_port_db.c
index ba1f966ec3..bc0a7a95e6 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_port_db.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_port_db.c
@@ -760,3 +760,35 @@ ulp_port_db_port_meta_data_get(struct bnxt_ulp_context *ulp_ctxt,
 	}
 	return -EINVAL;
 }
+
+/* Api to get the function id for a given port id
+ *
+ * ulp_ctxt [in] Ptr to ulp context
+ * port_id [in] dpdk port id
+ * fid_data [out] the function id of the given port
+ *
+ * Returns 0 on success or negative number on failure.
+ */
+int32_t
+ulp_port_db_port_vf_fid_get(struct bnxt_ulp_context *ulp_ctxt,
+			    uint16_t port_id, uint8_t **fid_data)
+{
+	struct bnxt_ulp_port_db *port_db;
+	uint32_t ifindex;
+
+	port_db = bnxt_ulp_cntxt_ptr2_port_db_get(ulp_ctxt);
+	if (!port_db || port_id >= RTE_MAX_ETHPORTS) {
+		BNXT_TF_DBG(ERR, "Invalid Arguments\n");
+		return -EINVAL;
+	}
+	ifindex = port_db->dev_port_list[port_id];
+	if (!ifindex)
+		return -ENOENT;
+
+	if (port_db->ulp_intf_list[ifindex].type != BNXT_ULP_INTF_TYPE_VF &&
+	    port_db->ulp_intf_list[ifindex].type != BNXT_ULP_INTF_TYPE_VF_REP)
+		return -EINVAL;
+
+	*fid_data = (uint8_t *)&port_db->ulp_intf_list[ifindex].vf_func_id;
+	return 0;
+}
diff --git a/drivers/net/bnxt/tf_ulp/ulp_port_db.h b/drivers/net/bnxt/tf_ulp/ulp_port_db.h
index d4efe0a3d5..9d7ab02ad7 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_port_db.h
+++ b/drivers/net/bnxt/tf_ulp/ulp_port_db.h
@@ -354,4 +354,17 @@ ulp_port_db_port_is_pf_get(struct bnxt_ulp_context *ulp_ctxt,
 int32_t
 ulp_port_db_port_meta_data_get(struct bnxt_ulp_context *ulp_ctxt,
 			       uint16_t port_id, uint8_t **meta_data);
+
+/* Api to get the function id for a given port id
+ *
+ * ulp_ctxt [in] Ptr to ulp context
+ * port_id [in] dpdk port id
+ * fid_data [out] the function id of the given port
+ *
+ * Returns 0 on success or negative number on failure.
+ */
+int32_t
+ulp_port_db_port_vf_fid_get(struct bnxt_ulp_context *ulp_ctxt,
+			    uint16_t port_id, uint8_t **fid_data);
+
 #endif /* _ULP_PORT_DB_H_ */
-- 
2.39.3


  parent reply	other threads:[~2024-08-30 13:52 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-30 14:00 [PATCH 00/47] TruFlow update for Thor2 Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 01/47] net/bnxt: tf_core: fix wc tcam multi slice delete issue Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 02/47] net/bnxt: tf_core: tcam manager data corruption Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 03/47] net/bnxt: tf_core: External EM support cleanup Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 04/47] net/bnxt: tf_core: Thor TF EM key size check Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 05/47] net/bnxt: tf_core: flow scale improvement Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 06/47] net/bnxt: tf_core: TF support flow scale query Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 07/47] net/bnxt: tf_core: fix slice count in case of HA entry move Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 08/47] net/bnxt: tf_core: convert priority based TCAM manager to dynamic allocation Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 09/47] net/bnxt: tf_core: remove dead AFM code from session-based priority TCAM mgr Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 10/47] net/bnxt: tf_core: remove dead " Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 11/47] net/bnxt: tfc: support tf-core for Thor2 Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 12/47] net/bnxt: tf_ulp: add vxlan-gpe base support Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 13/47] net/bnxt: tf_ulp: add custom l2 etype tunnel support Sriharsha Basavapatna
2024-08-30 14:00 ` Sriharsha Basavapatna [this message]
2024-08-30 14:00 ` [PATCH 15/47] net/bnxt: tf_ulp: Wh+ mirroring support Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 16/47] net/bnxt: tf_ulp: miscellaneous fixes Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 17/47] net/bnxt: tf_ulp: support for Thor2 ulp layer Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 18/47] net/bnxt: tf_ulp: add support for overlapping flows Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 19/47] net/bnxt: tf_ulp: convert recipe table to dynamic memory Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 20/47] net/bnxt: tf_ulp: add feature bit support Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 21/47] net/bnxt: tf_ulp: add action read and clear support Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 22/47] net/bnxt: tf_ulp: update template files Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 23/47] net/bnxt: tf_ulp: VFR updates for Thor 2 Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 24/47] net/bnxt: tf_ulp: add support for tunnel flow stats Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 25/47] net/bnxt: tf_ulp: update template files Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 26/47] net/bnxt: tf_ulp: enable recipe id generation Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 27/47] net/bnxt: tf_ulp: fixed parent child db counters Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 28/47] net/bnxt: tf_ulp: modify return values to adhere to C coding standard Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 29/47] net/bnxt: tf_ulp: update template files Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 30/47] net/bnxt: tf_ulp: add mask defaults when mask is not specified Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 31/47] net/bnxt: tf_ulp: add jump action support Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 32/47] net/bnxt: tf_ulp: add support for flow priority Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 33/47] net/bnxt: tf_ulp: support for dynamic tunnel ports Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 34/47] net/bnxt: tf_ulp: add rte_mtr support for Thor2 Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 35/47] net/bnxt: tf_ulp: TF support flow scale query Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 36/47] net/bnxt: tf_ulp: add support for rss flow query to ULP Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 37/47] net/bnxt: tf_ulp: add track type feature to tables Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 38/47] net/bnxt: tf_ulp: inline utility functions and use likely/unlikely Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 39/47] net/bnxt: tf_ulp: switch ulp to use rte crc32 hash Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 40/47] net/bnxt: tf_ulp: update template files Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 41/47] net/bnxt: tf_ulp: support a few generic template items Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 42/47] net/bnxt: tf_ulp: TFC support flow scale query for Thor2 Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 43/47] net/bnxt: tf_ulp: update template files Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 44/47] net/bnxt: tf_ulp: enable support for truflow feature configuration Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 45/47] net/bnxt: tf_ulp: support a few feature extensions Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 46/47] net/bnxt: update template files Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 47/47] net/bnxt: tf_ulp: add stats cache for thor2 Sriharsha Basavapatna
2024-09-25 12:02 ` [PATCH 00/47] TruFlow update for Thor2 Ajit Khaparde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240830140049.1715230-15-sriharsha.basavapatna@broadcom.com \
    --to=sriharsha.basavapatna@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=kishore.padmanabha@broadcom.com \
    --cc=shahaji.bhosle@broadcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).