1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2021 Marvell.
11 static const char name[] = "roc_cn10k_intra_device_conf";
12 const struct plt_memzone *mz;
13 struct idev_cfg *idev;
15 mz = plt_memzone_lookup(name);
19 /* Request for the first time */
20 mz = plt_memzone_reserve_cache_align(name, sizeof(struct idev_cfg));
23 idev_set_defaults(idev);
30 idev_set_defaults(struct idev_cfg *idev)
32 idev->sso_pf_func = 0;
34 idev->npa_pf_func = 0;
35 idev->max_pools = 128;
36 idev->lmt_pf_func = 0;
37 idev->lmt_base_addr = 0;
38 idev->num_lmtlines = 0;
41 __atomic_store_n(&idev->npa_refcnt, 0, __ATOMIC_RELEASE);
45 idev_sso_pffunc_get(void)
47 struct idev_cfg *idev;
50 idev = idev_get_cfg();
53 sso_pf_func = __atomic_load_n(&idev->sso_pf_func,
60 idev_sso_pffunc_set(uint16_t sso_pf_func)
62 struct idev_cfg *idev;
64 idev = idev_get_cfg();
66 __atomic_store_n(&idev->sso_pf_func, sso_pf_func,
71 idev_npa_pffunc_get(void)
73 struct idev_cfg *idev;
76 idev = idev_get_cfg();
79 npa_pf_func = idev->npa_pf_func;
85 idev_npa_obj_get(void)
87 struct idev_cfg *idev;
89 idev = idev_get_cfg();
90 if (idev && __atomic_load_n(&idev->npa_refcnt, __ATOMIC_ACQUIRE))
97 roc_idev_npa_maxpools_get(void)
99 struct idev_cfg *idev;
102 idev = idev_get_cfg();
105 max_pools = idev->max_pools;
111 roc_idev_npa_maxpools_set(uint32_t max_pools)
113 struct idev_cfg *idev;
115 idev = idev_get_cfg();
117 __atomic_store_n(&idev->max_pools, max_pools, __ATOMIC_RELEASE);
121 idev_npa_lf_active(struct dev *dev)
123 struct idev_cfg *idev;
125 /* Check if npalf is actively used on this dev */
126 idev = idev_get_cfg();
127 if (!idev || !idev->npa || idev->npa->mbox != dev->mbox)
130 return __atomic_load_n(&idev->npa_refcnt, __ATOMIC_ACQUIRE);
134 idev_lmt_pffunc_get(void)
136 struct idev_cfg *idev;
137 uint16_t lmt_pf_func;
139 idev = idev_get_cfg();
142 lmt_pf_func = idev->lmt_pf_func;
148 roc_idev_lmt_base_addr_get(void)
150 uint64_t lmt_base_addr;
151 struct idev_cfg *idev;
153 idev = idev_get_cfg();
156 lmt_base_addr = idev->lmt_base_addr;
158 return lmt_base_addr;
162 roc_idev_num_lmtlines_get(void)
164 struct idev_cfg *idev;
165 uint16_t num_lmtlines;
167 idev = idev_get_cfg();
170 num_lmtlines = idev->num_lmtlines;
176 roc_idev_cpt_get(void)
178 struct idev_cfg *idev = idev_get_cfg();
187 roc_idev_cpt_set(struct roc_cpt *cpt)
189 struct idev_cfg *idev = idev_get_cfg();
192 __atomic_store_n(&idev->cpt, cpt, __ATOMIC_RELEASE);
196 roc_idev_npa_nix_get(void)
198 struct npa_lf *npa_lf = idev_npa_obj_get();
204 dev = container_of(npa_lf, struct dev, npa);