From: Anoob Joseph Date: Fri, 25 Jun 2021 05:36:36 +0000 (+0530) Subject: common/cnxk: add CPT get/set X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=0a2879b2e89dc01ecca20c2917ffd11318ab8eeb;p=dpdk.git common/cnxk: add CPT get/set Add APIs to set & get CPT device. Signed-off-by: Anoob Joseph Acked-by: Akhil Goyal --- diff --git a/drivers/common/cnxk/roc_cpt.c b/drivers/common/cnxk/roc_cpt.c index 23761251f7..d891a3b442 100644 --- a/drivers/common/cnxk/roc_cpt.c +++ b/drivers/common/cnxk/roc_cpt.c @@ -230,6 +230,10 @@ roc_cpt_dev_init(struct roc_cpt *roc_cpt) dev->roc_cpt = roc_cpt; + /* Set it to idev if not already present */ + if (!roc_idev_cpt_get()) + roc_idev_cpt_set(roc_cpt); + return 0; fail: @@ -244,6 +248,10 @@ roc_cpt_dev_fini(struct roc_cpt *roc_cpt) if (cpt == NULL) return -EINVAL; + /* Remove idev references */ + if (roc_idev_cpt_get() == roc_cpt) + roc_idev_cpt_set(NULL); + roc_cpt->nb_lf_avail = 0; roc_cpt->lmt_base = 0; diff --git a/drivers/common/cnxk/roc_idev.c b/drivers/common/cnxk/roc_idev.c index 4d7b53422b..1494187e3b 100644 --- a/drivers/common/cnxk/roc_idev.c +++ b/drivers/common/cnxk/roc_idev.c @@ -37,6 +37,7 @@ idev_set_defaults(struct idev_cfg *idev) idev->lmt_base_addr = 0; idev->num_lmtlines = 0; idev->bphy = NULL; + idev->cpt = NULL; __atomic_store_n(&idev->npa_refcnt, 0, __ATOMIC_RELEASE); } @@ -171,6 +172,26 @@ roc_idev_num_lmtlines_get(void) return num_lmtlines; } +struct roc_cpt * +roc_idev_cpt_get(void) +{ + struct idev_cfg *idev = idev_get_cfg(); + + if (idev != NULL) + return idev->cpt; + + return NULL; +} + +void +roc_idev_cpt_set(struct roc_cpt *cpt) +{ + struct idev_cfg *idev = idev_get_cfg(); + + if (idev != NULL) + __atomic_store_n(&idev->cpt, cpt, __ATOMIC_RELEASE); +} + struct roc_nix * roc_idev_npa_nix_get(void) { diff --git a/drivers/common/cnxk/roc_idev.h b/drivers/common/cnxk/roc_idev.h index 043e8afd35..16793c2828 100644 --- a/drivers/common/cnxk/roc_idev.h +++ b/drivers/common/cnxk/roc_idev.h @@ -12,6 +12,9 @@ void __roc_api roc_idev_npa_maxpools_set(uint32_t max_pools); uint64_t __roc_api roc_idev_lmt_base_addr_get(void); uint16_t __roc_api roc_idev_num_lmtlines_get(void); +struct roc_cpt *__roc_api roc_idev_cpt_get(void); +void __roc_api roc_idev_cpt_set(struct roc_cpt *cpt); + struct roc_nix *__roc_api roc_idev_npa_nix_get(void); #endif /* _ROC_IDEV_H_ */ diff --git a/drivers/common/cnxk/roc_idev_priv.h b/drivers/common/cnxk/roc_idev_priv.h index 384f667ea6..84e6f1ef2d 100644 --- a/drivers/common/cnxk/roc_idev_priv.h +++ b/drivers/common/cnxk/roc_idev_priv.h @@ -8,6 +8,7 @@ /* Intra device related functions */ struct npa_lf; struct roc_bphy; +struct roc_cpt; struct idev_cfg { uint16_t sso_pf_func; uint16_t npa_pf_func; @@ -18,6 +19,7 @@ struct idev_cfg { uint16_t num_lmtlines; uint64_t lmt_base_addr; struct roc_bphy *bphy; + struct roc_cpt *cpt; }; /* Generic */ diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map index 67894bfbbc..133a25010f 100644 --- a/drivers/common/cnxk/version.map +++ b/drivers/common/cnxk/version.map @@ -39,6 +39,8 @@ INTERNAL { roc_cpt_dev_init; roc_cpt_eng_grp_add; roc_error_msg_get; + roc_idev_cpt_get; + roc_idev_cpt_set; roc_idev_lmt_base_addr_get; roc_idev_npa_maxpools_get; roc_idev_npa_maxpools_set;