common/cnxk: add lower bound check for SSO resources
[dpdk.git] / drivers / common / cnxk / roc_idev.c
index 63cc040..a08c7ce 100644 (file)
@@ -36,6 +36,10 @@ idev_set_defaults(struct idev_cfg *idev)
        idev->lmt_pf_func = 0;
        idev->lmt_base_addr = 0;
        idev->num_lmtlines = 0;
+       idev->bphy = NULL;
+       idev->cpt = NULL;
+       idev->nix_inl_dev = NULL;
+       plt_spinlock_init(&idev->nix_inl_dev_lock);
        __atomic_store_n(&idev->npa_refcnt, 0, __ATOMIC_RELEASE);
 }
 
@@ -170,6 +174,41 @@ 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;
+}
+
+uint64_t *
+roc_nix_inl_outb_ring_base_get(struct roc_nix *roc_nix)
+{
+       struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+       struct idev_cfg *idev = idev_get_cfg();
+       struct nix_inl_dev *inl_dev;
+
+       if (!idev || !idev->nix_inl_dev)
+               return NULL;
+
+       inl_dev = idev->nix_inl_dev;
+
+       return (uint64_t *)&inl_dev->sa_soft_exp_ring[nix->outb_se_ring_base];
+}
+
+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)
 {
@@ -182,3 +221,23 @@ roc_idev_npa_nix_get(void)
        dev = container_of(npa_lf, struct dev, npa);
        return dev->roc_nix;
 }
+
+struct roc_sso *
+idev_sso_get(void)
+{
+       struct idev_cfg *idev = idev_get_cfg();
+
+       if (idev != NULL)
+               return __atomic_load_n(&idev->sso, __ATOMIC_ACQUIRE);
+
+       return NULL;
+}
+
+void
+idev_sso_set(struct roc_sso *sso)
+{
+       struct idev_cfg *idev = idev_get_cfg();
+
+       if (idev != NULL)
+               __atomic_store_n(&idev->sso, sso, __ATOMIC_RELEASE);
+}