net/bnxt: add CFA subdirectory of HCAPI
[dpdk.git] / drivers / net / bnxt / tf_core / tfp.c
index 3bce3ad..b88affc 100644 (file)
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * see the individual elements.
- * Copyright(c) 2019-2020 Broadcom
+ * Copyright(c) 2019-2021 Broadcom
  * All rights reserved.
  */
 
@@ -102,13 +102,13 @@ tfp_calloc(struct tfp_calloc_parms *parms)
                                    (parms->nitems * parms->size),
                                    parms->alignment);
        if (parms->mem_va == NULL) {
-               PMD_DRV_LOG(ERR, "Allocate failed mem_va\n");
+               TFP_DRV_LOG(ERR, "Allocate failed mem_va\n");
                return -ENOMEM;
        }
 
        parms->mem_pa = (void *)((uintptr_t)rte_mem_virt2iova(parms->mem_va));
        if (parms->mem_pa == (void *)((uintptr_t)RTE_BAD_IOVA)) {
-               PMD_DRV_LOG(ERR, "Allocate failed mem_pa\n");
+               TFP_DRV_LOG(ERR, "Allocate failed mem_pa\n");
                return -ENOMEM;
        }
 
@@ -161,3 +161,39 @@ tfp_spinlock_unlock(struct tfp_spinlock_parms *parms)
 {
        rte_spinlock_unlock(&parms->slock);
 }
+
+int
+tfp_get_fid(struct tf *tfp, uint16_t *fw_fid)
+{
+       struct bnxt *bp = NULL;
+
+       if (tfp == NULL || fw_fid == NULL)
+               return -EINVAL;
+
+       bp = container_of(tfp, struct bnxt, tfp);
+       if (bp == NULL)
+               return -EINVAL;
+
+       *fw_fid = bp->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;
+}