DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ajit Khaparde <ajit.khaparde@broadcom.com>
To: dev@dpdk.org
Cc: Mike Baucom <michael.baucom@broadcom.com>,
	Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>,
	Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Subject: [dpdk-dev] [PATCH v2 01/12] net/bnxt: add SVIF changes for dpdk port id
Date: Fri, 17 Apr 2020 09:19:09 -0700	[thread overview]
Message-ID: <20200417161920.85858-2-ajit.khaparde@broadcom.com> (raw)
In-Reply-To: <20200417161920.85858-1-ajit.khaparde@broadcom.com>

From: Mike Baucom <michael.baucom@broadcom.com>

Modification of the parser to get the SVIF from the driver for matches
on port_id, pf, and phy_port.

Signed-off-by: Mike Baucom <michael.baucom@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c  | 31 ++++----
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.c | 92 +++++++++++++++++++-----
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.h |  5 ++
 3 files changed, 90 insertions(+), 38 deletions(-)

diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c
index 49588953c..6203a495c 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c
@@ -72,14 +72,14 @@ bnxt_ulp_flow_create(struct rte_eth_dev			*dev,
 	struct ulp_rte_act_bitmap act_bitmap;
 	struct ulp_rte_act_prop act_prop;
 	enum ulp_direction_type dir = ULP_DIR_INGRESS;
-	uint32_t class_id, act_tmpl;
-	uint32_t app_priority;
-	int ret;
 	struct bnxt_ulp_context *ulp_ctx = NULL;
-	uint32_t vnic;
-	uint8_t svif;
+	uint32_t class_id, act_tmpl;
 	struct rte_flow *flow_id;
+	uint32_t app_priority;
 	uint32_t fid;
+	uint8_t	*buffer;
+	uint32_t vnic;
+	int ret;
 
 	if (bnxt_ulp_flow_validate_args(attr,
 					pattern, actions,
@@ -100,19 +100,15 @@ bnxt_ulp_flow_create(struct rte_eth_dev			*dev,
 	memset(&act_bitmap, 0, sizeof(act_bitmap));
 	memset(&act_prop, 0, sizeof(act_prop));
 
-	svif = bnxt_get_svif(dev->data->port_id, false);
-	BNXT_TF_DBG(ERR, "SVIF for port[%d][port]=0x%08x\n",
-		    dev->data->port_id, svif);
+	if (attr->egress)
+		dir = ULP_DIR_EGRESS;
 
-	hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].size = sizeof(svif);
-	hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].spec[0] = svif;
-	hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].mask[0] = -1;
-	ULP_BITMAP_SET(hdr_bitmap.bits, BNXT_ULP_HDR_BIT_SVIF);
+	/* copy the device port id and direction in svif for further process */
+	buffer = hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].spec;
+	rte_memcpy(buffer, &dev->data->port_id, sizeof(uint16_t));
+	rte_memcpy(buffer + sizeof(uint16_t), &dir, sizeof(uint32_t));
 
-	/*
-	 * VNIC is being pushed as 32bit and the pop will take care of
-	 * proper size
-	 */
+	/* Set the implicit vnic in the action property */
 	vnic = (uint32_t)bnxt_get_vnic_id(dev->data->port_id);
 	vnic = htonl(vnic);
 	rte_memcpy(&act_prop.act_details[BNXT_ULP_ACT_PROP_IDX_VNIC],
@@ -132,9 +128,6 @@ bnxt_ulp_flow_create(struct rte_eth_dev			*dev,
 	if (ret != BNXT_TF_RC_SUCCESS)
 		goto parse_error;
 
-	if (attr->egress)
-		dir = ULP_DIR_EGRESS;
-
 	ret = ulp_matcher_pattern_match(dir, &hdr_bitmap, hdr_field,
 					&act_bitmap, &class_id);
 
diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
index 7a31b4360..4339032a7 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
@@ -85,6 +85,8 @@ bnxt_ulp_rte_parser_hdr_parse(const struct rte_flow_item pattern[],
 		}
 		item++;
 	}
+	/* update the implied SVIF */
+	(void)ulp_rte_parser_svif_process(hdr_bitmap, hdr_field);
 	return BNXT_TF_RC_SUCCESS;
 }
 
@@ -132,9 +134,12 @@ static int32_t
 ulp_rte_parser_svif_set(struct ulp_rte_hdr_bitmap *hdr_bitmap,
 			struct ulp_rte_hdr_field *hdr_field,
 			enum rte_flow_item_type proto,
-			uint32_t svif,
-			uint32_t mask)
+			uint32_t dir,
+			uint16_t svif,
+			uint16_t mask)
 {
+	uint16_t port_id = svif;
+
 	if (ULP_BITMAP_ISSET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_SVIF)) {
 		BNXT_TF_DBG(ERR,
 			    "SVIF already set,"
@@ -142,21 +147,51 @@ ulp_rte_parser_svif_set(struct ulp_rte_hdr_bitmap *hdr_bitmap,
 		return BNXT_TF_RC_ERROR;
 	}
 
-	/* TBD: Check for any mapping errors for svif */
 	/* Update the hdr_bitmap with BNXT_ULP_HDR_PROTO_SVIF. */
 	ULP_BITMAP_SET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_SVIF);
 
-	if (proto != RTE_FLOW_ITEM_TYPE_PF) {
-		memcpy(hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].spec,
-		       &svif, sizeof(svif));
-		memcpy(hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].mask,
-		       &mask, sizeof(mask));
-		hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].size = sizeof(svif);
+	if (proto == RTE_FLOW_ITEM_TYPE_PORT_ID) {
+		/* perform the conversion from dpdk port to svif */
+		if (dir == ULP_DIR_EGRESS)
+			svif = bnxt_get_svif(port_id, true);
+		else
+			svif = bnxt_get_svif(port_id, false);
 	}
 
+	memcpy(hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].spec,
+	       &svif, sizeof(svif));
+	memcpy(hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].mask,
+	       &mask, sizeof(mask));
+	hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].size = sizeof(svif);
 	return BNXT_TF_RC_SUCCESS;
 }
 
+/* Function to handle the parsing of the RTE port id
+ */
+int32_t
+ulp_rte_parser_svif_process(struct ulp_rte_hdr_bitmap	*hdr_bitmap,
+			    struct ulp_rte_hdr_field	*hdr_field)
+{
+	uint16_t port_id = 0;
+	uint32_t dir = 0;
+	uint8_t	*buffer;
+	uint16_t svif_mask = 0xFFFF;
+
+	if (ULP_BITMAP_ISSET(hdr_bitmap->bits, BNXT_ULP_HDR_BIT_SVIF))
+		return BNXT_TF_RC_SUCCESS;
+
+	/* SVIF not set. So get the port id and direction */
+	buffer = hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].spec;
+	memcpy(&port_id, buffer, sizeof(port_id));
+	memcpy(&dir, buffer + sizeof(port_id), sizeof(dir));
+	memset(hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].spec, 0,
+	       RTE_PARSER_FLOW_HDR_FIELD_SIZE);
+
+	return ulp_rte_parser_svif_set(hdr_bitmap, hdr_field,
+				       RTE_FLOW_ITEM_TYPE_PORT_ID,
+				       dir, port_id, svif_mask);
+}
+
 /* Function to handle the parsing of RTE Flow item PF Header. */
 int32_t
 ulp_rte_pf_hdr_handler(const struct rte_flow_item *item,
@@ -165,8 +200,20 @@ ulp_rte_pf_hdr_handler(const struct rte_flow_item *item,
 		       uint32_t *field_idx __rte_unused,
 		       uint32_t *vlan_idx __rte_unused)
 {
+	uint16_t port_id = 0;
+	uint32_t dir = 0;
+	uint8_t	*buffer;
+	uint16_t svif_mask = 0xFFFF;
+
+	buffer = hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].spec;
+	memcpy(&port_id, buffer, sizeof(port_id));
+	memcpy(&dir, buffer + sizeof(port_id), sizeof(dir));
+	memset(hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].spec, 0,
+	       RTE_PARSER_FLOW_HDR_FIELD_SIZE);
+
 	return ulp_rte_parser_svif_set(hdr_bitmap, hdr_field,
-				       item->type, 0, 0);
+				       item->type,
+				       dir, port_id, svif_mask);
 }
 
 /* Function to handle the parsing of RTE Flow item VF Header. */
@@ -178,7 +225,7 @@ ulp_rte_vf_hdr_handler(const struct rte_flow_item *item,
 		       uint32_t *vlan_idx __rte_unused)
 {
 	const struct rte_flow_item_vf *vf_spec, *vf_mask;
-	uint32_t svif = 0, mask = 0;
+	uint16_t svif = 0, mask = 0;
 
 	vf_spec = item->spec;
 	vf_mask = item->mask;
@@ -188,12 +235,12 @@ ulp_rte_vf_hdr_handler(const struct rte_flow_item *item,
 	 * header fields.
 	 */
 	if (vf_spec)
-		svif = vf_spec->id;
+		svif = (uint16_t)vf_spec->id;
 	if (vf_mask)
-		mask = vf_mask->id;
+		mask = (uint16_t)vf_mask->id;
 
 	return ulp_rte_parser_svif_set(hdr_bitmap, hdr_field,
-				       item->type, svif, mask);
+				       item->type, 0, svif, mask);
 }
 
 /* Function to handle the parsing of RTE Flow item port id  Header. */
@@ -205,7 +252,9 @@ ulp_rte_port_id_hdr_handler(const struct rte_flow_item *item,
 			    uint32_t *vlan_idx __rte_unused)
 {
 	const struct rte_flow_item_port_id *port_spec, *port_mask;
-	uint32_t svif = 0, mask = 0;
+	uint16_t svif = 0, mask = 0;
+	uint32_t dir;
+	uint8_t	*buffer;
 
 	port_spec = item->spec;
 	port_mask = item->mask;
@@ -215,12 +264,15 @@ ulp_rte_port_id_hdr_handler(const struct rte_flow_item *item,
 	 * header fields.
 	 */
 	if (port_spec)
-		svif = port_spec->id;
+		svif = (uint16_t)port_spec->id;
 	if (port_mask)
-		mask = port_mask->id;
+		mask = (uint16_t)port_mask->id;
+
+	buffer = hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].spec;
+	memcpy(&dir, buffer + sizeof(uint16_t), sizeof(uint16_t));
 
 	return ulp_rte_parser_svif_set(hdr_bitmap, hdr_field,
-				       item->type, svif, mask);
+				       item->type, dir, svif, mask);
 }
 
 /* Function to handle the parsing of RTE Flow item phy port Header. */
@@ -244,7 +296,7 @@ ulp_rte_phy_port_hdr_handler(const struct rte_flow_item *item,
 		mask = port_mask->index;
 
 	return ulp_rte_parser_svif_set(hdr_bitmap, hdr_field,
-				       item->type, svif, mask);
+				       item->type, 0, svif, mask);
 }
 
 /* Function to handle the parsing of RTE Flow item Ethernet Header. */
@@ -1124,6 +1176,8 @@ ulp_rte_pf_act_handler(const struct rte_flow_action *action_item __rte_unused,
 	/* copy the PF of the current device into VNIC Property */
 	svif_buf = &act_prop->act_details[BNXT_ULP_ACT_PROP_IDX_VNIC];
 	ulp_util_field_int_read(svif_buf, &svif);
+	svif = (uint32_t)bnxt_get_vnic_id(svif);
+	svif = htonl(svif);
 	vnic_buffer = &act_prop->act_details[BNXT_ULP_ACT_PROP_IDX_VNIC];
 	ulp_util_field_int_write(vnic_buffer, svif);
 
diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h
index 0ab43d2a6..0d571bbba 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h
+++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h
@@ -20,6 +20,11 @@
 #define BNXT_ULP_ENCAP_IPV6_SIZE		8
 #define BNXT_ULP_ENCAP_UDP_SIZE			4
 
+/* Function to handle the parsing of the RTE port id. */
+int32_t
+ulp_rte_parser_svif_process(struct ulp_rte_hdr_bitmap	*hdr_bitmap,
+			    struct ulp_rte_hdr_field	*hdr_field);
+
 /*
  * Function to handle the parsing of RTE Flows and placing
  * the RTE flow items into the ulp structures.
-- 
2.21.1 (Apple Git-122.3)


  reply	other threads:[~2020-04-17 16:19 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-15 14:49 [dpdk-dev] [PATCH 00/11] enhancements to host based flow table management Venkat Duvvuru
2020-04-15 14:49 ` [dpdk-dev] [PATCH 01/11] net/bnxt: SVIF changes for dpdk port id Venkat Duvvuru
2020-04-15 14:49 ` [dpdk-dev] [PATCH 02/11] net/bnxt: allow usage of more resources in flow db Venkat Duvvuru
2020-04-15 14:49 ` [dpdk-dev] [PATCH 03/11] net/bnxt: Added flow database resource iteration API Venkat Duvvuru
2020-04-15 14:49 ` [dpdk-dev] [PATCH 04/11] net/bnxt: added type of resource name to debug messages Venkat Duvvuru
2020-04-15 14:49 ` [dpdk-dev] [PATCH 05/11] net/bnxt: aggregated ulp rte parser arguments to single structure Venkat Duvvuru
2020-04-15 14:49 ` [dpdk-dev] [PATCH 06/11] net/bnxt: aggregated ulp mapper create " Venkat Duvvuru
2020-04-15 14:49 ` [dpdk-dev] [PATCH 07/11] net/bnxt: use hashing for flow template matching Venkat Duvvuru
2020-04-15 14:49 ` [dpdk-dev] [PATCH 08/11] net/bnxt: addition of session and function flow flush Venkat Duvvuru
2020-04-15 14:49 ` [dpdk-dev] [PATCH 09/11] net/bnxt: default identifiers added to ulp mapper Venkat Duvvuru
2020-04-15 14:49 ` [dpdk-dev] [PATCH 10/11] net/bnxt: cache table type added for tcam lookups Venkat Duvvuru
2020-04-15 14:49 ` [dpdk-dev] [PATCH 11/11] net/bnxt: addition of the port database Venkat Duvvuru
2020-04-17 16:19 ` [dpdk-dev] [PATCH v2 00/12] enhancements to host based flow table management Ajit Khaparde
2020-04-17 16:19   ` Ajit Khaparde [this message]
2020-04-17 16:19   ` [dpdk-dev] [PATCH v2 02/12] net/bnxt: allow usage of more resources in flow db Ajit Khaparde
2020-04-17 16:19   ` [dpdk-dev] [PATCH v2 03/12] net/bnxt: add flow database resource iteration API Ajit Khaparde
2020-04-17 16:19   ` [dpdk-dev] [PATCH v2 04/12] net/bnxt: add resource name type to debug messages Ajit Khaparde
2020-04-17 16:19   ` [dpdk-dev] [PATCH v2 05/12] net/bnxt: aggregate ulp rte parser arguments Ajit Khaparde
2020-04-17 16:19   ` [dpdk-dev] [PATCH v2 06/12] net/bnxt: aggregate ulp mapper create arguments Ajit Khaparde
2020-04-17 16:19   ` [dpdk-dev] [PATCH v2 07/12] net/bnxt: use hashing for flow template match Ajit Khaparde
2020-04-17 16:19   ` [dpdk-dev] [PATCH v2 08/12] net/bnxt: add session and function flow flush Ajit Khaparde
2020-04-17 16:19   ` [dpdk-dev] [PATCH v2 09/12] net/bnxt: add default identifiers to ulp mapper Ajit Khaparde
2020-04-17 16:19   ` [dpdk-dev] [PATCH v2 10/12] net/bnxt: add cache table type for TCAM lookup Ajit Khaparde
2020-04-17 16:19   ` [dpdk-dev] [PATCH v2 11/12] net/bnxt: add port database Ajit Khaparde
2020-04-17 16:19   ` [dpdk-dev] [PATCH v2 12/12] net/bnxt: remove redefinition of page size Ajit Khaparde
2020-04-17 21:00   ` [dpdk-dev] [PATCH v2 00/12] enhancements to host based flow table management 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=20200417161920.85858-2-ajit.khaparde@broadcom.com \
    --to=ajit.khaparde@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=kishore.padmanabha@broadcom.com \
    --cc=michael.baucom@broadcom.com \
    --cc=venkatkumar.duvvuru@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).