net/bnxt: add SVIF changes for port id
authorMike Baucom <michael.baucom@broadcom.com>
Wed, 15 Apr 2020 14:49:06 +0000 (20:19 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 21 Apr 2020 11:57:09 +0000 (13:57 +0200)
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
drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
drivers/net/bnxt/tf_ulp/ulp_rte_parser.h

index 4958895..6203a49 100644 (file)
@@ -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);
 
index 7a31b43..4339032 100644 (file)
@@ -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);
 
index 0ab43d2..0d571bb 100644 (file)
 #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.