net/bnxt: add table scope to PF mapping
authorFarah Smith <farah.smith@broadcom.com>
Mon, 26 Oct 2020 03:56:04 +0000 (20:56 -0700)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 3 Nov 2020 22:35:03 +0000 (23:35 +0100)
Add table scope to PF Mapping for SR and Wh+ devices.
Legacy devices require PF set of base addresses for EEM operation.
A table scope id is a logical construct and is mapped to the PF
associated with the communications channel used.
In the case of a VF, the parent PF is used.

Signed-off-by: Farah Smith <farah.smith@broadcom.com>
Reviewed-by: Randy Schacher <stuart.schacher@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
drivers/net/bnxt/tf_core/tf_device.h
drivers/net/bnxt/tf_core/tf_device_p4.c
drivers/net/bnxt/tf_core/tf_em_common.c
drivers/net/bnxt/tf_core/tf_em_host.c
drivers/net/bnxt/tf_core/tf_tbl.h
drivers/net/bnxt/tf_core/tfp.c
drivers/net/bnxt/tf_core/tfp.h

index cf7c36e..b5fc695 100644 (file)
@@ -579,8 +579,11 @@ struct tf_dev_ops {
         * [in] tfp
         *   Pointer to TF handle
         *
-        * [in] parms
-        *   Pointer to table scope map parameters
+        * [in] pf
+        * PF associated with the table scope
+        *
+        * [in] parif_bitmask
+        * Bitmask of PARIFs to enable
         *
         * [in/out] pointer to the parif_2_pf data to be updated
         *
@@ -593,7 +596,8 @@ struct tf_dev_ops {
         *    -EINVAL - Error
         */
        int (*tf_dev_map_parif)(struct tf *tfp,
-                               struct tf_map_tbl_scope_parms *parms,
+                               uint16_t parif_bitmask,
+                               uint16_t pf,
                                uint8_t *data,
                                uint8_t *mask,
                                uint16_t sz_in_bytes);
index 07c8d02..b35e65a 100644 (file)
@@ -103,7 +103,8 @@ tf_dev_p4_get_tcam_slice_info(struct tf *tfp __rte_unused,
 
 static int
 tf_dev_p4_map_parif(struct tf *tfp __rte_unused,
-                   struct tf_map_tbl_scope_parms *parms,
+                   uint16_t parif_bitmask,
+                   uint16_t pf,
                    uint8_t *data,
                    uint8_t *mask,
                    uint16_t sz_in_bytes)
@@ -112,21 +113,20 @@ tf_dev_p4_map_parif(struct tf *tfp __rte_unused,
        uint32_t parif_pf_mask[2] = { 0 };
        uint32_t parif;
        uint32_t shift;
-       uint32_t scope_id = (uint32_t)(parms->tbl_scope_id);
 
        if (sz_in_bytes != sizeof(uint64_t))
                return -ENOTSUP;
 
        for (parif = 0; parif < TF_DEV_P4_PARIF_MAX; parif++) {
-               if (parms->parif_bitmask & (1UL << parif)) {
+               if (parif_bitmask & (1UL << parif)) {
                        if (parif < 8) {
                                shift = 4 * parif;
                                parif_pf_mask[0] |= TF_DEV_P4_PF_MASK << shift;
-                               parif_pf[0] |= scope_id << shift;
+                               parif_pf[0] |= pf << shift;
                        } else {
                                shift = 4 * (parif - 8);
                                parif_pf_mask[1] |= TF_DEV_P4_PF_MASK << shift;
-                               parif_pf[1] |= scope_id << shift;
+                               parif_pf[1] |= pf << shift;
                        }
                }
        }
index d4e8469..ad92cbd 100644 (file)
@@ -1104,8 +1104,10 @@ int tf_em_ext_map_tbl_scope(struct tf *tfp,
        }
        mask = aparms.mem_va;
 
-       rc = dev->ops->tf_dev_map_parif(tfp, parms, (uint8_t *)data,
-                                       (uint8_t *)mask, sz_in_bytes);
+       rc = dev->ops->tf_dev_map_parif(tfp, parms->parif_bitmask,
+                                       tbl_scope_cb->pf,
+                                       (uint8_t *)data, (uint8_t *)mask,
+                                       sz_in_bytes);
 
        if (rc) {
                TFP_DRV_LOG(ERR,
index b5db94f..a106bdf 100644 (file)
@@ -392,6 +392,14 @@ tf_em_ext_alloc(struct tf *tfp, struct tf_alloc_tbl_scope_parms *parms)
        tbl_scope_cb->index = parms->tbl_scope_id;
        tbl_scope_cb->tbl_scope_id = parms->tbl_scope_id;
 
+       rc = tfp_get_pf(tfp, &tbl_scope_cb->pf);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "EEM: PF query error rc:%s\n",
+                           strerror(-rc));
+               goto cleanup;
+       }
+
        for (dir = 0; dir < TF_DIR_MAX; dir++) {
                rc = tf_msg_em_qcaps(tfp,
                                     dir,
index 2a5d24c..230338c 100644 (file)
@@ -38,6 +38,9 @@ struct tf_em_caps {
  */
 struct tf_tbl_scope_cb {
        uint32_t tbl_scope_id;
+       /** The pf or parent pf of the vf used for table scope creation
+       */
+       uint16_t pf;
        int index;
        struct hcapi_cfa_em_ctx_mem_info em_ctx_info[TF_DIR_MAX];
        struct tf_em_caps em_caps[TF_DIR_MAX];
index 426a182..0f6d63c 100644 (file)
@@ -178,3 +178,22 @@ tfp_get_fid(struct tf *tfp, uint16_t *fw_fid)
 
        return 0;
 }
+
+int
+tfp_get_pf(struct tf *tfp, uint16_t *pf)
+{
+       struct bnxt *bp = NULL;
+
+       if (tfp == NULL || pf == NULL)
+               return -EINVAL;
+
+       bp = container_of(tfp, struct bnxt, tfp);
+       if (BNXT_VF(bp) && bp->parent) {
+               *pf = bp->parent->fid - 1;
+               return 0;
+       } else if (BNXT_PF(bp)) {
+               *pf = bp->fw_fid - 1;
+               return 0;
+       }
+       return -EINVAL;
+}
index 421a7d9..551b9c5 100644 (file)
@@ -268,4 +268,20 @@ int tfp_get_fid(struct tf *tfp, uint16_t *fw_fid);
  */
 int tfp_get_fid(struct tf *tfp, uint16_t *fw_fid);
 
+/**
+ * Get the PF associated with the fw communications channel.
+ *
+ * [in] session
+ *   Pointer to session handle
+ *
+ * [out] pf
+ *   Pointer to the pf id
+ *
+ * Returns:
+ *   0       - Success
+ *   -EINVAL - Failure
+ *
+ */
+int tfp_get_pf(struct tf *tfp, uint16_t *pf);
+
 #endif /* _TFP_H_ */