From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9FF82A0597; Fri, 17 Apr 2020 18:19:59 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 636241EA05; Fri, 17 Apr 2020 18:19:33 +0200 (CEST) Received: from rnd-relay.smtp.broadcom.com (rnd-relay.smtp.broadcom.com [192.19.229.170]) by dpdk.org (Postfix) with ESMTP id 6D8001E9D9 for ; Fri, 17 Apr 2020 18:19:26 +0200 (CEST) Received: from mail-irv-17.broadcom.com (mail-irv-17.lvn.broadcom.net [10.75.242.48]) by rnd-relay.smtp.broadcom.com (Postfix) with ESMTP id B6CAE30C1D0; Fri, 17 Apr 2020 09:08:04 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 rnd-relay.smtp.broadcom.com B6CAE30C1D0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1587139684; bh=4p6JgPsZazS/IOTY7pl6eF+JM7AZG6gO0usHev9OEGU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cx9JSWoWwH6enRW5wJjnVIP9TSjZID2a+PX82TX9Jg/FOCv4XOsyIsnq4whku0UGR Xpxk9HEZtyGWjwCDvEys5/TVBe7cbukzat4frapuk+lt2LBAhbuGDJeTfLVHx98oUM LgIGi7pdwf4vtpwn1sKy46n4WWMvyigS1RCVOUnw= Received: from localhost.localdomain (unknown [10.230.185.215]) by mail-irv-17.broadcom.com (Postfix) with ESMTP id 0761514008D; Fri, 17 Apr 2020 09:19:24 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Cc: Mike Baucom , Venkat Duvvuru , Kishore Padmanabha Date: Fri, 17 Apr 2020 09:19:09 -0700 Message-Id: <20200417161920.85858-2-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200417161920.85858-1-ajit.khaparde@broadcom.com> References: <1586962156-11179-1-git-send-email-venkatkumar.duvvuru@broadcom.com> <20200417161920.85858-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 01/12] net/bnxt: add SVIF changes for dpdk port id X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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: Mike Baucom 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 Signed-off-by: Venkat Duvvuru Reviewed-by: Kishore Padmanabha Reviewed-by: Ajit Khaparde --- 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)