Add APIs to set & get CPT device.
Signed-off-by: Anoob Joseph <anoobj@marvell.com>
Acked-by: Akhil Goyal <gakhil@marvell.com>
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:
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;
idev->lmt_base_addr = 0;
idev->num_lmtlines = 0;
idev->bphy = NULL;
+ idev->cpt = NULL;
__atomic_store_n(&idev->npa_refcnt, 0, __ATOMIC_RELEASE);
}
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)
{
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_ */
/* 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;
uint16_t num_lmtlines;
uint64_t lmt_base_addr;
struct roc_bphy *bphy;
+ struct roc_cpt *cpt;
};
/* Generic */
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;