Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(C) 2021 Marvell.
3 : : */
4 : :
5 : : #include "roc_api.h"
6 : : #include "roc_priv.h"
7 : :
8 : : uint32_t soft_exp_consumer_cnt;
9 : : roc_nix_inl_meta_pool_cb_t meta_pool_cb;
10 : : roc_nix_inl_custom_meta_pool_cb_t custom_meta_pool_cb;
11 : :
12 : : PLT_STATIC_ASSERT(ROC_NIX_INL_ON_IPSEC_INB_SA_SZ ==
13 : : 1UL << ROC_NIX_INL_ON_IPSEC_INB_SA_SZ_LOG2);
14 : : PLT_STATIC_ASSERT(ROC_NIX_INL_ON_IPSEC_INB_SA_SZ == 1024);
15 : : PLT_STATIC_ASSERT(ROC_NIX_INL_ON_IPSEC_OUTB_SA_SZ ==
16 : : 1UL << ROC_NIX_INL_ON_IPSEC_OUTB_SA_SZ_LOG2);
17 : : PLT_STATIC_ASSERT(ROC_NIX_INL_OT_IPSEC_INB_SA_SZ ==
18 : : 1UL << ROC_NIX_INL_OT_IPSEC_INB_SA_SZ_LOG2);
19 : : PLT_STATIC_ASSERT(ROC_NIX_INL_OT_IPSEC_INB_SA_SZ == 1024);
20 : : PLT_STATIC_ASSERT(ROC_NIX_INL_OT_IPSEC_OUTB_SA_SZ ==
21 : : 1UL << ROC_NIX_INL_OT_IPSEC_OUTB_SA_SZ_LOG2);
22 : : PLT_STATIC_ASSERT(ROC_NIX_INL_OT_IPSEC_INB_SA_SZ == ROC_NIX_INL_OW_IPSEC_INB_SA_SZ);
23 : : PLT_STATIC_ASSERT(ROC_NIX_INL_OT_IPSEC_INB_SA_SZ == ROC_NIX_INL_ON_IPSEC_INB_SA_SZ);
24 : : PLT_STATIC_ASSERT(ROC_NIX_INL_OT_IPSEC_OUTB_SA_SZ == ROC_NIX_INL_OW_IPSEC_OUTB_SA_SZ);
25 : : PLT_STATIC_ASSERT(ROC_NIX_INL_OT_IPSEC_OUTB_SA_SZ == ROC_NIX_INL_ON_IPSEC_OUTB_SA_SZ);
26 : :
27 : : static int
28 : 0 : nix_inl_meta_aura_destroy(struct roc_nix *roc_nix)
29 : : {
30 : 0 : struct idev_cfg *idev = idev_get_cfg();
31 : : struct idev_nix_inl_cfg *inl_cfg;
32 : 0 : char mempool_name[24] = {'\0'};
33 : : char *mp_name = NULL;
34 : : uint64_t *meta_aura;
35 : : int rc;
36 : :
37 [ # # ]: 0 : if (!idev)
38 : : return -EINVAL;
39 : :
40 : : inl_cfg = &idev->inl_cfg;
41 : :
42 [ # # # # ]: 0 : if (!roc_nix->local_meta_aura_ena || roc_nix->custom_meta_aura_ena) {
43 : 0 : meta_aura = &inl_cfg->meta_aura;
44 : : } else {
45 : 0 : meta_aura = &roc_nix->meta_aura_handle;
46 : 0 : snprintf(mempool_name, sizeof(mempool_name), "NIX_INL_META_POOL_%d",
47 : 0 : roc_nix->port_id + 1);
48 : : mp_name = mempool_name;
49 : : }
50 : :
51 : : /* Destroy existing Meta aura */
52 [ # # ]: 0 : if (*meta_aura) {
53 : : uint64_t avail, limit;
54 : :
55 : : /* Check if all buffers are back to pool */
56 : : avail = roc_npa_aura_op_available(*meta_aura);
57 : : limit = roc_npa_aura_op_limit_get(*meta_aura);
58 : : if (avail != limit)
59 : : plt_warn("Not all buffers are back to meta pool,"
60 : : " %" PRIu64 " != %" PRIu64, avail, limit);
61 : :
62 : 0 : rc = meta_pool_cb(meta_aura, &roc_nix->meta_mempool, 0, 0, true, mp_name);
63 [ # # ]: 0 : if (rc) {
64 : 0 : plt_err("Failed to destroy meta aura, rc=%d", rc);
65 : 0 : return rc;
66 : : }
67 : :
68 [ # # ]: 0 : if (!roc_nix->local_meta_aura_ena) {
69 : 0 : inl_cfg->meta_aura = 0;
70 : 0 : inl_cfg->buf_sz = 0;
71 : 0 : inl_cfg->nb_bufs = 0;
72 : : } else
73 : 0 : roc_nix->buf_sz = 0;
74 : : }
75 : :
76 : : return 0;
77 : : }
78 : :
79 : : static int
80 : 0 : nix_inl_meta_aura_create(struct idev_cfg *idev, struct roc_nix *roc_nix, uint16_t first_skip,
81 : : uint64_t *meta_aura, bool is_local_metaaura)
82 : : {
83 : : uint64_t mask = BIT_ULL(ROC_NPA_BUF_TYPE_PACKET_IPSEC);
84 : : struct idev_nix_inl_cfg *inl_cfg;
85 : : struct nix_inl_dev *nix_inl_dev;
86 : 0 : int port_id = roc_nix->port_id;
87 : 0 : char mempool_name[24] = {'\0'};
88 : : struct roc_nix_rq *inl_rq;
89 : : uint32_t nb_bufs, buf_sz;
90 : : char *mp_name = NULL;
91 : : uint16_t inl_rq_id;
92 : : uintptr_t mp;
93 : : int rc;
94 : :
95 : : inl_cfg = &idev->inl_cfg;
96 : 0 : nix_inl_dev = idev->nix_inl_dev;
97 : :
98 [ # # ]: 0 : if (is_local_metaaura) {
99 : : /* Per LF Meta Aura */
100 : : inl_rq_id = nix_inl_dev->nb_rqs > 1 ? port_id : 0;
101 : : inl_rq = &nix_inl_dev->rqs[inl_rq_id];
102 : :
103 : : nb_bufs = roc_npa_aura_op_limit_get(inl_rq->aura_handle);
104 : : if (inl_rq->spb_ena)
105 : : nb_bufs += roc_npa_aura_op_limit_get(inl_rq->spb_aura_handle);
106 : :
107 : : /* Override meta buf size from NIX devargs if present */
108 [ # # ]: 0 : if (roc_nix->meta_buf_sz) {
109 : : buf_sz = roc_nix->meta_buf_sz;
110 : : } else {
111 : : buf_sz = NIX_INL_META_SIZE;
112 [ # # ]: 0 : buf_sz += roc_nix->def_first_skip ? roc_nix->def_first_skip : first_skip;
113 : : }
114 : :
115 : : /* Create Metapool name */
116 : 0 : snprintf(mempool_name, sizeof(mempool_name), "NIX_INL_META_POOL_%d",
117 : : roc_nix->port_id + 1);
118 : : mp_name = mempool_name;
119 : : } else {
120 : : /* Global Meta Aura (Aura 0) */
121 : : /* Override meta buf count from devargs if present */
122 [ # # # # ]: 0 : if (nix_inl_dev && nix_inl_dev->nb_meta_bufs)
123 : : nb_bufs = nix_inl_dev->nb_meta_bufs;
124 : : else
125 : 0 : nb_bufs = roc_npa_buf_type_limit_get(mask);
126 : :
127 : : /* Override meta buf size from devargs if present */
128 [ # # # # ]: 0 : if (nix_inl_dev && nix_inl_dev->meta_buf_sz)
129 : : buf_sz = nix_inl_dev->meta_buf_sz;
130 : : else
131 : 0 : buf_sz = first_skip + NIX_INL_META_SIZE;
132 : : }
133 : :
134 : : /* Allocate meta aura */
135 : 0 : rc = meta_pool_cb(meta_aura, &mp, buf_sz, nb_bufs, false, mp_name);
136 [ # # ]: 0 : if (rc) {
137 : 0 : plt_err("Failed to allocate meta aura, rc=%d", rc);
138 : 0 : return rc;
139 : : }
140 : 0 : roc_nix->meta_mempool = mp;
141 : :
142 : 0 : plt_nix_dbg("Created meta aura %p(%s)for port %d", (void *)*meta_aura, mp_name,
143 : : roc_nix->port_id);
144 : :
145 [ # # ]: 0 : if (!is_local_metaaura) {
146 : 0 : inl_cfg->buf_sz = buf_sz;
147 : 0 : inl_cfg->nb_bufs = nb_bufs;
148 : 0 : inl_cfg->meta_mempool = mp;
149 : : } else
150 : 0 : roc_nix->buf_sz = buf_sz;
151 : :
152 : : return 0;
153 : : }
154 : :
155 : : static int
156 : 0 : nix_inl_custom_meta_aura_destroy(struct roc_nix *roc_nix)
157 : : {
158 : 0 : struct idev_cfg *idev = idev_get_cfg();
159 : : struct idev_nix_inl_cfg *inl_cfg;
160 : 0 : char mempool_name[24] = {'\0'};
161 : : char *mp_name = NULL;
162 : : uint64_t *meta_aura;
163 : : int rc;
164 : :
165 [ # # ]: 0 : if (!idev)
166 : : return -EINVAL;
167 : :
168 : : inl_cfg = &idev->inl_cfg;
169 : 0 : meta_aura = &roc_nix->meta_aura_handle;
170 : 0 : snprintf(mempool_name, sizeof(mempool_name), "NIX_INL_META_POOL_%d",
171 [ # # ]: 0 : roc_nix->port_id + 1);
172 : : mp_name = mempool_name;
173 : :
174 : : /* Destroy existing Meta aura */
175 [ # # ]: 0 : if (*meta_aura) {
176 : : uint64_t avail, limit;
177 : :
178 : : /* Check if all buffers are back to pool */
179 : : avail = roc_npa_aura_op_available(*meta_aura);
180 : : limit = roc_npa_aura_op_limit_get(*meta_aura);
181 : : if (avail != limit)
182 : : plt_warn("Not all buffers are back to meta pool,"
183 : : " %" PRIu64 " != %" PRIu64, avail, limit);
184 : :
185 : 0 : rc = custom_meta_pool_cb(inl_cfg->meta_mempool, &roc_nix->meta_mempool, mp_name,
186 : : meta_aura, 0, 0, true);
187 [ # # ]: 0 : if (rc) {
188 : 0 : plt_err("Failed to destroy meta aura, rc=%d", rc);
189 : 0 : return rc;
190 : : }
191 : :
192 : 0 : roc_nix->buf_sz = 0;
193 : : }
194 : :
195 : : return 0;
196 : : }
197 : :
198 : : static int
199 : 0 : nix_inl_custom_meta_aura_create(struct idev_cfg *idev, struct roc_nix *roc_nix, uint16_t first_skip,
200 : : uint64_t *meta_aura)
201 : : {
202 : : uint64_t mask = BIT_ULL(ROC_NPA_BUF_TYPE_PACKET_IPSEC);
203 : : struct idev_nix_inl_cfg *inl_cfg;
204 : : struct nix_inl_dev *nix_inl_dev;
205 : 0 : char mempool_name[24] = {'\0'};
206 : : uint32_t nb_bufs, buf_sz;
207 : : char *mp_name = NULL;
208 : : uintptr_t mp;
209 : : int rc;
210 : :
211 : : inl_cfg = &idev->inl_cfg;
212 : 0 : nix_inl_dev = idev->nix_inl_dev;
213 : :
214 : : /* Override meta buf count from devargs if present */
215 [ # # # # ]: 0 : if (nix_inl_dev && nix_inl_dev->nb_meta_bufs)
216 : : nb_bufs = nix_inl_dev->nb_meta_bufs;
217 : : else
218 : 0 : nb_bufs = roc_npa_buf_type_limit_get(mask);
219 : :
220 : : /* Override meta buf size from devargs if present */
221 [ # # # # ]: 0 : if (nix_inl_dev && nix_inl_dev->meta_buf_sz)
222 : : buf_sz = nix_inl_dev->meta_buf_sz;
223 : : else
224 : 0 : buf_sz = first_skip + NIX_INL_META_SIZE;
225 : :
226 : : /* Create Metapool name */
227 : 0 : snprintf(mempool_name, sizeof(mempool_name), "NIX_INL_META_POOL_%d",
228 : 0 : roc_nix->port_id + 1);
229 : : mp_name = mempool_name;
230 : :
231 : : /* Allocate meta aura */
232 : 0 : rc = custom_meta_pool_cb(inl_cfg->meta_mempool, &mp, mp_name, meta_aura,
233 : : buf_sz, nb_bufs, false);
234 [ # # ]: 0 : if (rc) {
235 : 0 : plt_err("Failed to allocate meta aura, rc=%d", rc);
236 : 0 : return rc;
237 : : }
238 : :
239 : : /* Overwrite */
240 : 0 : roc_nix->meta_mempool = mp;
241 : 0 : roc_nix->buf_sz = buf_sz;
242 : :
243 : 0 : return 0;
244 : : }
245 : :
246 : : static int
247 : 0 : nix_inl_global_meta_buffer_validate(struct idev_cfg *idev, struct roc_nix_rq *rq)
248 : : {
249 : : struct idev_nix_inl_cfg *inl_cfg;
250 : : uint32_t actual, expected;
251 : : uint64_t mask, type_mask;
252 : :
253 : : inl_cfg = &idev->inl_cfg;
254 : : /* Validate if we have enough meta buffers */
255 : : mask = BIT_ULL(ROC_NPA_BUF_TYPE_PACKET_IPSEC);
256 : 0 : expected = roc_npa_buf_type_limit_get(mask);
257 : 0 : actual = inl_cfg->nb_bufs;
258 : :
259 [ # # ]: 0 : if (actual < expected) {
260 : 0 : plt_err("Insufficient buffers in meta aura %u < %u (expected)",
261 : : actual, expected);
262 : 0 : return -EIO;
263 : : }
264 : :
265 : : /* Validate if we have enough space for meta buffer */
266 [ # # ]: 0 : if (rq->first_skip + NIX_INL_META_SIZE > inl_cfg->buf_sz) {
267 : 0 : plt_err("Meta buffer size %u not sufficient to meet RQ first skip %u",
268 : : inl_cfg->buf_sz, rq->first_skip);
269 : 0 : return -EIO;
270 : : }
271 : :
272 : : /* Validate if we have enough VWQE buffers */
273 [ # # ]: 0 : if (rq->vwqe_ena) {
274 : 0 : actual = roc_npa_aura_op_limit_get(rq->vwqe_aura_handle);
275 : :
276 : 0 : type_mask = roc_npa_buf_type_mask(rq->vwqe_aura_handle);
277 [ # # ]: 0 : if (type_mask & BIT_ULL(ROC_NPA_BUF_TYPE_VWQE_IPSEC) &&
278 : : type_mask & BIT_ULL(ROC_NPA_BUF_TYPE_VWQE)) {
279 : : /* VWQE aura shared b/w Inline enabled and non Inline
280 : : * enabled ports needs enough buffers to store all the
281 : : * packet buffers, one per vwqe.
282 : : */
283 : : mask = (BIT_ULL(ROC_NPA_BUF_TYPE_PACKET_IPSEC) |
284 : : BIT_ULL(ROC_NPA_BUF_TYPE_PACKET));
285 : 0 : expected = roc_npa_buf_type_limit_get(mask);
286 : :
287 [ # # ]: 0 : if (actual < expected) {
288 : 0 : plt_err("VWQE aura shared b/w Inline inbound and non-Inline "
289 : : "ports needs vwqe bufs(%u) minimum of all pkt bufs (%u)",
290 : : actual, expected);
291 : 0 : return -EIO;
292 : : }
293 : : } else {
294 : : /* VWQE aura not shared b/w Inline and non Inline ports have relaxed
295 : : * requirement of match all the meta buffers.
296 : : */
297 : 0 : expected = inl_cfg->nb_bufs;
298 : :
299 [ # # ]: 0 : if (actual < expected) {
300 : 0 : plt_err("VWQE aura not shared b/w Inline inbound and non-Inline "
301 : : "ports needs vwqe bufs(%u) minimum of all meta bufs (%u)",
302 : : actual, expected);
303 : 0 : return -EIO;
304 : : }
305 : : }
306 : : }
307 : : return 0;
308 : : }
309 : :
310 : : static int
311 : 0 : nix_inl_local_meta_buffer_validate(struct roc_nix *roc_nix, struct roc_nix_rq *rq)
312 : : {
313 : : uint32_t buf_sz = NIX_INL_META_SIZE;
314 : :
315 [ # # ]: 0 : buf_sz += roc_nix->def_first_skip ? roc_nix->def_first_skip : rq->first_skip;
316 : :
317 : : /* Validate if we have enough space for meta buffer */
318 [ # # # # ]: 0 : if (roc_nix->buf_sz && (buf_sz > roc_nix->buf_sz)) {
319 : 0 : plt_err("Meta buffer size %u is not sufficient to meet minimum required %u",
320 : : roc_nix->buf_sz, buf_sz);
321 : 0 : return -EIO;
322 : : }
323 : :
324 : : /* TODO: Validate VWQE buffers */
325 : :
326 : : return 0;
327 : : }
328 : :
329 : : int
330 : 0 : roc_nix_inl_meta_aura_check(struct roc_nix *roc_nix, struct roc_nix_rq *rq)
331 : : {
332 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
333 : 0 : struct idev_cfg *idev = idev_get_cfg();
334 : : struct idev_nix_inl_cfg *inl_cfg;
335 : : bool is_local_metaaura;
336 : : bool aura_setup = false;
337 : : uint64_t *meta_aura;
338 : : int rc;
339 : :
340 [ # # # # ]: 0 : if (!idev || !meta_pool_cb)
341 : : return -EFAULT;
342 : :
343 : : inl_cfg = &idev->inl_cfg;
344 : :
345 : : /* Create meta aura if not present */
346 [ # # # # ]: 0 : if (!roc_nix->local_meta_aura_ena || roc_nix->custom_meta_aura_ena) {
347 : 0 : meta_aura = &inl_cfg->meta_aura;
348 : 0 : is_local_metaaura = false;
349 : : } else {
350 : 0 : meta_aura = &roc_nix->meta_aura_handle;
351 : : is_local_metaaura = true;
352 : : }
353 : :
354 [ # # ]: 0 : if (!(*meta_aura)) {
355 : 0 : rc = nix_inl_meta_aura_create(idev, roc_nix, rq->first_skip, meta_aura,
356 : : is_local_metaaura);
357 [ # # ]: 0 : if (rc)
358 : : return rc;
359 : :
360 : : aura_setup = true;
361 : : }
362 : :
363 [ # # ]: 0 : if (roc_nix->custom_meta_aura_ena) {
364 : : /* Create metaura for 1:N pool:aura */
365 [ # # ]: 0 : if (!custom_meta_pool_cb)
366 : : return -EFAULT;
367 : :
368 : 0 : meta_aura = &roc_nix->meta_aura_handle;
369 [ # # ]: 0 : if (!(*meta_aura)) {
370 : 0 : rc = nix_inl_custom_meta_aura_create(idev, roc_nix, rq->first_skip,
371 : : meta_aura);
372 [ # # ]: 0 : if (rc)
373 : : return rc;
374 : :
375 : : aura_setup = true;
376 : : }
377 : : }
378 : :
379 : : /* Update rq meta aura handle */
380 : 0 : rq->meta_aura_handle = *meta_aura;
381 : :
382 [ # # ]: 0 : if (roc_nix->local_meta_aura_ena) {
383 : 0 : rc = nix_inl_local_meta_buffer_validate(roc_nix, rq);
384 [ # # ]: 0 : if (rc)
385 : : return rc;
386 : :
387 : : /* Check for TC config on RQ 0 when local meta aura is used as
388 : : * inline meta aura creation is delayed.
389 : : */
390 [ # # # # : 0 : if (aura_setup && nix->rqs[0] && nix->rqs[0]->tc != ROC_NIX_PFC_CLASS_INVALID)
# # ]
391 : 0 : roc_nix_fc_npa_bp_cfg(roc_nix, roc_nix->meta_aura_handle,
392 : : true, false, nix->rqs[0]->tc, ROC_NIX_AURA_THRESH);
393 : : } else {
394 : 0 : rc = nix_inl_global_meta_buffer_validate(idev, rq);
395 [ # # ]: 0 : if (rc)
396 : 0 : return rc;
397 : : }
398 : :
399 : : return 0;
400 : : }
401 : :
402 : : static int
403 : 0 : nix_inl_inb_ipsec_sa_tbl_setup(struct roc_nix *roc_nix)
404 : : {
405 : 0 : uint32_t ipsec_in_min_spi = roc_nix->ipsec_in_min_spi;
406 : 0 : uint32_t ipsec_in_max_spi = roc_nix->ipsec_in_max_spi;
407 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
408 : 0 : struct idev_cfg *idev = idev_get_cfg();
409 : : struct nix_inl_dev *inl_dev = NULL;
410 : : uint64_t max_sa, i, sa_pow2_sz;
411 : : uint64_t sa_idx_w, lenm1_max;
412 : : uint64_t res_addr_offset = 0;
413 : : uint8_t profile_id = 0;
414 : : struct mbox *mbox;
415 : : size_t inb_sa_sz;
416 : : void *sa;
417 : : int rc;
418 : :
419 : : /* Setup default IPsec profile */
420 [ # # ]: 0 : if (roc_feature_nix_has_inl_profile()) {
421 : 0 : rc = nix_inl_setup_dflt_ipsec_profile(&nix->dev, &nix->ipsec_prof_id);
422 [ # # ]: 0 : if (rc)
423 : : return rc;
424 : 0 : profile_id = nix->ipsec_prof_id;
425 : : }
426 : :
427 : 0 : mbox = mbox_get(nix->dev.mbox);
428 : :
429 [ # # ]: 0 : max_sa = plt_align32pow2(ipsec_in_max_spi - ipsec_in_min_spi + 1);
430 : :
431 : : /* CN9K SA size is different */
432 [ # # ]: 0 : if (roc_nix->custom_inb_sa)
433 : : inb_sa_sz = ROC_NIX_INL_INB_CUSTOM_SA_SZ;
434 : : else
435 : : inb_sa_sz = ROC_NIX_INL_IPSEC_INB_SA_SZ;
436 : :
437 : : /* Alloc contiguous memory for Inbound SA's */
438 : 0 : nix->inb_sa_sz[profile_id] = inb_sa_sz;
439 : 0 : nix->inb_sa_max[profile_id] = max_sa;
440 : 0 : nix->inb_spi_mask = max_sa - 1;
441 : 0 : nix->inb_sa_base[profile_id] = plt_zmalloc(inb_sa_sz * max_sa, ROC_NIX_INL_SA_BASE_ALIGN);
442 [ # # ]: 0 : if (!nix->inb_sa_base[profile_id]) {
443 : : rc = -ENOMEM;
444 : 0 : plt_err("Failed to allocate memory for Inbound SA");
445 : 0 : goto exit;
446 : : }
447 : :
448 [ # # ]: 0 : sa_pow2_sz = plt_log2_u32(inb_sa_sz);
449 : 0 : sa_idx_w = plt_log2_u32(max_sa);
450 [ # # ]: 0 : lenm1_max = roc_nix_max_pkt_len(roc_nix) - 1;
451 : :
452 [ # # ]: 0 : if (!roc_model_is_cn9k()) {
453 [ # # ]: 0 : for (i = 0; i < max_sa; i++) {
454 [ # # ]: 0 : sa = ((uint8_t *)nix->inb_sa_base[profile_id]) + (i * inb_sa_sz);
455 [ # # ]: 0 : if (roc_model_is_cn10k())
456 : 0 : roc_ot_ipsec_inb_sa_init(sa);
457 : : else
458 : 0 : roc_ow_ipsec_inb_sa_init(sa);
459 : : }
460 : : }
461 : :
462 [ # # # # ]: 0 : if (roc_model_is_cn9k() || roc_model_is_cn10k()) {
463 : : struct nix_inline_ipsec_lf_cfg *lf_cfg;
464 : :
465 : : /* Setup device specific inb SA table */
466 : 0 : lf_cfg = mbox_alloc_msg_nix_inline_ipsec_lf_cfg(mbox);
467 [ # # ]: 0 : if (lf_cfg == NULL) {
468 : : rc = -ENOSPC;
469 : 0 : plt_err("Failed to alloc nix inline ipsec lf cfg mbox msg");
470 : 0 : goto free_mem;
471 : : }
472 : :
473 : 0 : lf_cfg->enable = 1;
474 : 0 : lf_cfg->sa_base_addr = (uintptr_t)nix->inb_sa_base[profile_id];
475 : 0 : lf_cfg->ipsec_cfg1.sa_idx_w = sa_idx_w;
476 : 0 : lf_cfg->ipsec_cfg0.lenm1_max = lenm1_max;
477 : 0 : lf_cfg->ipsec_cfg1.sa_idx_max = max_sa - 1;
478 : 0 : lf_cfg->ipsec_cfg0.sa_pow2_size = sa_pow2_sz;
479 : 0 : lf_cfg->ipsec_cfg0.tag_const = 0;
480 : 0 : lf_cfg->ipsec_cfg0.tt = SSO_TT_ORDERED;
481 [ # # ]: 0 : if (roc_nix->res_addr_offset) {
482 : 0 : lf_cfg->ipsec_cfg0_ext.res_addr_offset_valid = 1;
483 : 0 : lf_cfg->ipsec_cfg0_ext.res_addr_offset =
484 : 0 : (roc_nix->res_addr_offset & 0x80) | abs(roc_nix->res_addr_offset);
485 : : }
486 : : } else {
487 : : struct nix_rx_inl_lf_cfg_req *lf_cfg;
488 : : uint64_t def_cptq = 0;
489 : : uint64_t cpt_cq_ena = 0;
490 : :
491 : : /* Setup device specific inb SA table */
492 : 0 : lf_cfg = mbox_alloc_msg_nix_rx_inl_lf_cfg(mbox);
493 [ # # ]: 0 : if (lf_cfg == NULL) {
494 : : rc = -ENOSPC;
495 : 0 : plt_err("Failed to alloc nix inline ipsec lf cfg mbox msg");
496 : 0 : goto free_mem;
497 : : }
498 : :
499 : : /*TODO default cptq */
500 [ # # # # ]: 0 : if (idev && idev->nix_inl_dev) {
501 : : inl_dev = idev->nix_inl_dev;
502 [ # # ]: 0 : if (!inl_dev->nb_inb_cptlfs)
503 : : def_cptq = 0;
504 : : else
505 : 0 : def_cptq = inl_dev->nix_inb_qids[inl_dev->inb_cpt_lf_id];
506 : 0 : res_addr_offset = (uint64_t)(inl_dev->res_addr_offset & 0xFF) << 48;
507 [ # # ]: 0 : if (res_addr_offset)
508 : 0 : res_addr_offset |= (1UL << 56);
509 : 0 : cpt_cq_ena = (uint64_t)inl_dev->cpt_cq_ena << 63;
510 : : }
511 : :
512 : 0 : lf_cfg->enable = 1;
513 : 0 : lf_cfg->profile_id = profile_id; /* IPsec profile is 0th one */
514 : 0 : lf_cfg->rx_inline_sa_base = (uintptr_t)nix->inb_sa_base[profile_id] | cpt_cq_ena;
515 : 0 : lf_cfg->rx_inline_cfg0 =
516 : 0 : ((def_cptq << 57) | res_addr_offset | ((uint64_t)SSO_TT_ORDERED << 44) |
517 : 0 : (sa_pow2_sz << 16) | lenm1_max);
518 : 0 : lf_cfg->rx_inline_cfg1 = (max_sa - 1) | (sa_idx_w << 32);
519 : : }
520 : :
521 : 0 : rc = mbox_process(mbox);
522 [ # # ]: 0 : if (rc) {
523 : 0 : plt_err("Failed to setup NIX Inbound SA conf, rc=%d", rc);
524 : 0 : goto free_mem;
525 : : }
526 : :
527 : : mbox_put(mbox);
528 : 0 : return 0;
529 : 0 : free_mem:
530 : 0 : plt_free(nix->inb_sa_base[profile_id]);
531 : 0 : nix->inb_sa_base[profile_id] = NULL;
532 : 0 : exit:
533 : : mbox_put(mbox);
534 : 0 : return rc;
535 : : }
536 : :
537 : : static int
538 : 0 : nix_inl_ipsec_sa_tbl_release(struct roc_nix *roc_nix)
539 : : {
540 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
541 : 0 : struct mbox *mbox = mbox_get((&nix->dev)->mbox);
542 : : uint8_t profile_id = 0;
543 : : int rc;
544 : :
545 [ # # # # ]: 0 : if (roc_model_is_cn9k() || roc_model_is_cn10k()) {
546 : : struct nix_inline_ipsec_lf_cfg *lf_cfg;
547 : :
548 : 0 : lf_cfg = mbox_alloc_msg_nix_inline_ipsec_lf_cfg(mbox);
549 [ # # ]: 0 : if (lf_cfg == NULL) {
550 : : rc = -ENOSPC;
551 : 0 : goto exit;
552 : : }
553 : :
554 : 0 : lf_cfg->enable = 0;
555 : : } else {
556 : : struct nix_rx_inl_lf_cfg_req *lf_cfg;
557 : :
558 : 0 : profile_id = nix->ipsec_prof_id;
559 : 0 : lf_cfg = mbox_alloc_msg_nix_rx_inl_lf_cfg(mbox);
560 [ # # ]: 0 : if (!lf_cfg) {
561 : : rc = -ENOSPC;
562 : 0 : goto exit;
563 : : }
564 : :
565 : 0 : lf_cfg->enable = 0;
566 : 0 : lf_cfg->profile_id = profile_id; /* IPsec profile is 0th one */
567 : : }
568 : :
569 : 0 : rc = mbox_process(mbox);
570 [ # # ]: 0 : if (rc) {
571 : 0 : plt_err("Failed to cleanup NIX Inbound SA conf, rc=%d", rc);
572 : 0 : goto exit;
573 : : }
574 : :
575 : 0 : plt_free(nix->inb_sa_base[profile_id]);
576 : 0 : nix->inb_sa_base[profile_id] = NULL;
577 : 0 : exit:
578 : : mbox_put(mbox);
579 : 0 : return rc;
580 : : }
581 : :
582 : : static int
583 : 0 : nix_inl_reass_inb_sa_tbl_setup(struct roc_nix *roc_nix)
584 : : {
585 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
586 : 0 : struct idev_cfg *idev = idev_get_cfg();
587 : : struct nix_rx_inl_lf_cfg_req *lf_cfg;
588 : : struct nix_inl_dev *inl_dev = NULL;
589 : : uint64_t max_sa = 1, sa_pow2_sz;
590 : : uint64_t sa_idx_w, lenm1_max;
591 : : uint64_t res_addr_offset = 0;
592 : : uint64_t cpt_cq_ena = 0;
593 : : uint64_t def_cptq = 0;
594 : : size_t inb_sa_sz = ROC_NIX_INL_OW_IPSEC_INB_SA_SZ;
595 : : uint8_t profile_id;
596 : : struct mbox *mbox;
597 : : void *sa;
598 : : int rc;
599 : :
600 [ # # ]: 0 : if (!roc_nix->reass_ena)
601 : : return 0;
602 : :
603 : 0 : rc = nix_inl_setup_reass_profile(&nix->dev, &nix->reass_prof_id);
604 [ # # ]: 0 : if (rc)
605 : : return rc;
606 : :
607 : 0 : profile_id = nix->reass_prof_id;
608 : 0 : nix->inb_sa_sz[profile_id] = inb_sa_sz;
609 : 0 : nix->inb_sa_max[profile_id] = max_sa;
610 : 0 : nix->inb_spi_mask = 1;
611 : 0 : nix->inb_sa_base[profile_id] = plt_zmalloc(inb_sa_sz * max_sa, ROC_NIX_INL_SA_BASE_ALIGN);
612 [ # # ]: 0 : if (!nix->inb_sa_base[profile_id]) {
613 : 0 : plt_err("Failed to allocate memory for reassembly Inbound SA");
614 : 0 : return -ENOMEM;
615 : : }
616 : :
617 : : sa = ((uint8_t *)nix->inb_sa_base[profile_id]);
618 : 0 : roc_ow_reass_inb_sa_init(sa);
619 : :
620 : 0 : mbox = mbox_get(nix->dev.mbox);
621 : : /* Setup device specific inb SA table */
622 : 0 : lf_cfg = mbox_alloc_msg_nix_rx_inl_lf_cfg(mbox);
623 [ # # ]: 0 : if (lf_cfg == NULL) {
624 : : rc = -ENOSPC;
625 : 0 : plt_err("Failed to alloc nix inline reassembly lf cfg mbox msg");
626 : 0 : goto free_mem;
627 : : }
628 : :
629 : : sa_pow2_sz = plt_log2_u32(inb_sa_sz);
630 : : sa_idx_w = plt_log2_u32(max_sa);
631 : 0 : lenm1_max = roc_nix_max_pkt_len(roc_nix) - 1;
632 : :
633 [ # # # # ]: 0 : if (idev && idev->nix_inl_dev) {
634 : : inl_dev = idev->nix_inl_dev;
635 [ # # ]: 0 : if (inl_dev->nb_inb_cptlfs)
636 : 0 : def_cptq = inl_dev->nix_inb_qids[inl_dev->inb_cpt_lf_id];
637 : 0 : res_addr_offset = (uint64_t)(inl_dev->res_addr_offset & 0xFF) << 48;
638 [ # # ]: 0 : if (res_addr_offset)
639 : 0 : res_addr_offset |= (1UL << 56);
640 : 0 : cpt_cq_ena = (uint64_t)inl_dev->cpt_cq_ena << 63;
641 : : }
642 : 0 : lf_cfg->enable = 1;
643 : 0 : lf_cfg->profile_id = profile_id;
644 : 0 : lf_cfg->rx_inline_sa_base = (uintptr_t)nix->inb_sa_base[profile_id] | cpt_cq_ena;
645 : 0 : lf_cfg->rx_inline_cfg0 =
646 : 0 : ((def_cptq << 57) | res_addr_offset | ((uint64_t)SSO_TT_ORDERED << 44) |
647 : 0 : (sa_pow2_sz << 16) | lenm1_max);
648 : 0 : lf_cfg->rx_inline_cfg1 = (max_sa - 1) | (sa_idx_w << 32);
649 : :
650 : 0 : rc = mbox_process(mbox);
651 [ # # ]: 0 : if (rc) {
652 : 0 : plt_err("Failed to setup NIX Inbound reassembly SA conf, rc=%d", rc);
653 : 0 : goto free_mem;
654 : : }
655 : :
656 : : mbox_put(mbox);
657 : 0 : return 0;
658 : :
659 : 0 : free_mem:
660 : 0 : plt_free(nix->inb_sa_base[profile_id]);
661 : 0 : nix->inb_sa_base[profile_id] = NULL;
662 : : mbox_put(mbox);
663 : 0 : return rc;
664 : : }
665 : :
666 : : static int
667 : 0 : nix_inl_reass_sa_tbl_release(struct roc_nix *roc_nix)
668 : : {
669 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
670 : 0 : struct mbox *mbox = mbox_get((&nix->dev)->mbox);
671 : : struct nix_rx_inl_lf_cfg_req *lf_cfg;
672 : : uint8_t profile_id;
673 : : int rc;
674 : :
675 [ # # ]: 0 : if (!roc_nix->reass_ena)
676 : : return 0;
677 : :
678 : 0 : lf_cfg = mbox_alloc_msg_nix_rx_inl_lf_cfg(mbox);
679 [ # # ]: 0 : if (!lf_cfg) {
680 : : rc = -ENOSPC;
681 : 0 : goto exit;
682 : : }
683 : :
684 : 0 : profile_id = nix->reass_prof_id;
685 : :
686 : 0 : lf_cfg->enable = 0;
687 : 0 : lf_cfg->profile_id = profile_id;
688 : 0 : rc = mbox_process(mbox);
689 [ # # ]: 0 : if (rc) {
690 : 0 : plt_err("Failed to cleanup NIX Inbound Reassembly SA conf, rc=%d", rc);
691 : 0 : goto exit;
692 : : }
693 : :
694 : 0 : plt_free(nix->inb_sa_base[profile_id]);
695 : 0 : nix->inb_sa_base[profile_id] = NULL;
696 : 0 : exit:
697 : : mbox_put(mbox);
698 : 0 : return rc;
699 : : }
700 : :
701 : : struct roc_cpt_lf *
702 : 0 : roc_nix_inl_outb_lf_base_get(struct roc_nix *roc_nix)
703 : : {
704 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
705 : :
706 : : /* NIX Inline config needs to be done */
707 [ # # # # ]: 0 : if (!nix->inl_outb_ena || !nix->cpt_lf_base)
708 : 0 : return NULL;
709 : :
710 : : return (struct roc_cpt_lf *)nix->cpt_lf_base;
711 : : }
712 : :
713 : : struct roc_cpt_lf *
714 : 0 : roc_nix_inl_inb_inj_lf_get(struct roc_nix *roc_nix)
715 : : {
716 : : struct nix *nix;
717 : 0 : struct idev_cfg *idev = idev_get_cfg();
718 : : struct nix_inl_dev *inl_dev = NULL;
719 : : struct roc_cpt_lf *lf = NULL;
720 : :
721 [ # # ]: 0 : if (!idev)
722 : : return NULL;
723 : :
724 : 0 : inl_dev = idev->nix_inl_dev;
725 : :
726 [ # # ]: 0 : if (!inl_dev && roc_nix == NULL)
727 : : return NULL;
728 : :
729 : : nix = roc_nix_to_nix_priv(roc_nix);
730 : :
731 [ # # # # : 0 : if (nix->inb_inl_dev && inl_dev && inl_dev->attach_cptlf &&
# # ]
732 [ # # ]: 0 : inl_dev->rx_inj_ena)
733 : 0 : return &inl_dev->cpt_lf[inl_dev->nb_cptlf - 1];
734 : :
735 : 0 : lf = roc_nix_inl_outb_lf_base_get(roc_nix);
736 [ # # ]: 0 : if (lf)
737 : 0 : lf += roc_nix->outb_nb_crypto_qs;
738 : : return lf;
739 : : }
740 : :
741 : : uintptr_t
742 : 0 : roc_nix_inl_outb_sa_base_get(struct roc_nix *roc_nix)
743 : : {
744 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
745 : :
746 : 0 : return (uintptr_t)nix->outb_sa_base;
747 : : }
748 : :
749 : : uintptr_t
750 : 0 : roc_nix_inl_inb_sa_base_get(struct roc_nix *roc_nix, bool inb_inl_dev)
751 : : {
752 : 0 : struct idev_cfg *idev = idev_get_cfg();
753 : : struct nix_inl_dev *inl_dev;
754 : : struct nix *nix = NULL;
755 : :
756 [ # # ]: 0 : if (idev == NULL)
757 : : return 0;
758 : :
759 [ # # ]: 0 : if (!inb_inl_dev && roc_nix == NULL)
760 : : return -EINVAL;
761 : :
762 [ # # ]: 0 : if (roc_nix) {
763 : : nix = roc_nix_to_nix_priv(roc_nix);
764 [ # # ]: 0 : if (!nix->inl_inb_ena)
765 : : return 0;
766 : : }
767 : :
768 [ # # ]: 0 : if (inb_inl_dev) {
769 : 0 : inl_dev = idev->nix_inl_dev;
770 : : /* Return inline dev sa base */
771 [ # # ]: 0 : if (inl_dev)
772 : 0 : return (uintptr_t)inl_dev->inb_sa_base[inl_dev->ipsec_prof_id];
773 : : return 0;
774 : : }
775 : :
776 : 0 : return (uintptr_t)nix->inb_sa_base[nix->ipsec_prof_id];
777 : : }
778 : :
779 : : uintptr_t
780 : 0 : roc_nix_inl_inb_prof_sa_base_get(struct roc_nix *roc_nix, bool inb_inl_dev, uint16_t profile_id)
781 : : {
782 : 0 : struct idev_cfg *idev = idev_get_cfg();
783 : : struct nix_inl_dev *inl_dev;
784 : : struct nix *nix = NULL;
785 : :
786 : : /* Validate profile_id range */
787 [ # # ]: 0 : if (profile_id >= ROC_NIX_INL_PROFILE_CNT) {
788 : 0 : plt_err("Invalid profile_id %u, must be < %u", profile_id, ROC_NIX_INL_PROFILE_CNT);
789 : 0 : return 0;
790 : : }
791 : :
792 [ # # ]: 0 : if (idev == NULL)
793 : : return 0;
794 : :
795 [ # # ]: 0 : if (!inb_inl_dev && roc_nix == NULL)
796 : : return 0;
797 : :
798 [ # # ]: 0 : if (roc_nix) {
799 : : nix = roc_nix_to_nix_priv(roc_nix);
800 [ # # ]: 0 : if (!nix->inl_inb_ena)
801 : : return 0;
802 : : }
803 : :
804 [ # # ]: 0 : if (inb_inl_dev) {
805 : 0 : inl_dev = idev->nix_inl_dev;
806 : : /* Return inline dev sa base for the specified profile */
807 [ # # ]: 0 : if (inl_dev)
808 : 0 : return (uintptr_t)inl_dev->inb_sa_base[profile_id];
809 : : return 0;
810 : : }
811 : :
812 : : /* Return NIX sa base for the specified profile */
813 : 0 : return (uintptr_t)nix->inb_sa_base[profile_id];
814 : : }
815 : :
816 : : uint16_t
817 : 0 : roc_nix_inl_inb_ipsec_profile_id_get(struct roc_nix *roc_nix, bool inb_inl_dev)
818 : : {
819 : 0 : struct idev_cfg *idev = idev_get_cfg();
820 : : struct nix_inl_dev *inl_dev;
821 : : struct nix *nix = NULL;
822 : :
823 [ # # ]: 0 : if (idev == NULL)
824 : : return 0;
825 : :
826 [ # # ]: 0 : if (!inb_inl_dev && roc_nix == NULL)
827 : : return -EINVAL;
828 : :
829 [ # # ]: 0 : if (roc_nix) {
830 : : nix = roc_nix_to_nix_priv(roc_nix);
831 [ # # ]: 0 : if (!nix->inl_inb_ena)
832 : : return 0;
833 : : }
834 : :
835 [ # # ]: 0 : if (inb_inl_dev) {
836 : 0 : inl_dev = idev->nix_inl_dev;
837 : : /* Return inline Ipsec profile ID */
838 [ # # ]: 0 : if (inl_dev)
839 : 0 : return inl_dev->ipsec_prof_id;
840 : : return 0;
841 : : }
842 : :
843 : 0 : return nix->ipsec_prof_id;
844 : : }
845 : :
846 : : uint16_t
847 : 0 : roc_nix_inl_inb_reass_profile_id_get(struct roc_nix *roc_nix, bool inb_inl_dev)
848 : : {
849 : 0 : struct idev_cfg *idev = idev_get_cfg();
850 : : struct nix_inl_dev *inl_dev;
851 : : struct nix *nix = NULL;
852 : :
853 [ # # ]: 0 : if (idev == NULL)
854 : : return 0;
855 : :
856 [ # # ]: 0 : if (!inb_inl_dev && roc_nix == NULL)
857 : : return -EINVAL;
858 : :
859 [ # # ]: 0 : if (roc_nix) {
860 : : nix = roc_nix_to_nix_priv(roc_nix);
861 [ # # ]: 0 : if (!nix->inl_inb_ena)
862 : : return 0;
863 : : }
864 : :
865 [ # # ]: 0 : if (inb_inl_dev) {
866 : 0 : inl_dev = idev->nix_inl_dev;
867 : : /* Return inline reassembly profile ID */
868 [ # # ]: 0 : if (inl_dev)
869 : 0 : return inl_dev->reass_prof_id;
870 : : return 0;
871 : : }
872 : :
873 : 0 : return nix->reass_prof_id;
874 : : }
875 : :
876 : : static int
877 : 0 : nix_inl_custom_profile_sa_tbl_setup(struct roc_nix *roc_nix, uint32_t sa_size, uint32_t max_sa,
878 : : uint16_t profile_id)
879 : : {
880 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
881 : 0 : struct idev_cfg *idev = idev_get_cfg();
882 : : struct nix_inl_dev *inl_dev = NULL;
883 : : struct nix_rx_inl_lf_cfg_req *lf_cfg;
884 : : uint64_t res_addr_offset = 0;
885 : : uint64_t cpt_cq_ena = 0;
886 : : uint32_t inb_sa_sz;
887 : : uint32_t lenm1_max;
888 : : uint64_t def_cptq = 0;
889 : : struct mbox *mbox;
890 : : uint8_t sa_pow2_sz;
891 : : uint8_t sa_w;
892 : : int rc = 0;
893 : :
894 : : /* Validate profile_id range */
895 [ # # ]: 0 : if (profile_id >= ROC_NIX_INL_PROFILE_CNT) {
896 : 0 : plt_err("Invalid profile_id %u, must be < %u", profile_id, ROC_NIX_INL_PROFILE_CNT);
897 : 0 : return -EINVAL;
898 : : }
899 : :
900 : : /* Use sa_size parameter if provided, otherwise use default */
901 [ # # ]: 0 : if (sa_size > 0)
902 : : inb_sa_sz = sa_size;
903 : : else
904 : : inb_sa_sz = ROC_NIX_INL_OW_IPSEC_INB_SA_SZ;
905 : :
906 : : /* Validate max_sa is provided */
907 [ # # ]: 0 : if (max_sa == 0) {
908 : 0 : plt_err("max_sa must be greater than 0 for profile %u", profile_id);
909 : 0 : return -EINVAL;
910 : : }
911 : :
912 : : /* Update max_sa */
913 : 0 : nix->inb_sa_max[profile_id] = max_sa;
914 : :
915 : 0 : nix->inb_sa_sz[profile_id] = inb_sa_sz;
916 : 0 : nix->inb_sa_base[profile_id] = plt_zmalloc(inb_sa_sz * max_sa, ROC_NIX_INL_SA_BASE_ALIGN);
917 [ # # ]: 0 : if (!nix->inb_sa_base[profile_id]) {
918 : 0 : plt_err("Failed to allocate memory for Inbound SA for profile %u", profile_id);
919 : : rc = -ENOMEM;
920 : 0 : goto exit;
921 : : }
922 : :
923 : 0 : mbox = mbox_get(nix->dev.mbox);
924 : 0 : lf_cfg = mbox_alloc_msg_nix_rx_inl_lf_cfg(mbox);
925 [ # # ]: 0 : if (lf_cfg == NULL) {
926 : : rc = -ENOSPC;
927 : 0 : goto free_mem;
928 : : }
929 : :
930 : : lenm1_max = NIX_RPM_MAX_HW_FRS - 1;
931 : : sa_w = plt_log2_u32(max_sa);
932 : : sa_pow2_sz = plt_log2_u32(inb_sa_sz);
933 : :
934 : : /* Get default CPT queue from inline device if available */
935 [ # # # # ]: 0 : if (idev && idev->nix_inl_dev) {
936 : : inl_dev = idev->nix_inl_dev;
937 [ # # ]: 0 : if (!inl_dev->nb_inb_cptlfs)
938 : : def_cptq = 0;
939 : : else
940 : 0 : def_cptq = inl_dev->nix_inb_qids[inl_dev->inb_cpt_lf_id];
941 : :
942 : 0 : res_addr_offset = (uint64_t)(inl_dev->res_addr_offset & 0xFF) << 48;
943 [ # # ]: 0 : if (res_addr_offset)
944 : 0 : res_addr_offset |= (1UL << 56);
945 : :
946 : 0 : cpt_cq_ena = (uint64_t)inl_dev->cpt_cq_ena << 63;
947 : : }
948 : :
949 : 0 : lf_cfg->enable = 1;
950 : 0 : lf_cfg->profile_id = profile_id;
951 : 0 : lf_cfg->rx_inline_sa_base = (uintptr_t)nix->inb_sa_base[profile_id] | cpt_cq_ena;
952 : 0 : lf_cfg->rx_inline_cfg0 = ((uint64_t)def_cptq << 57) | res_addr_offset |
953 : 0 : ((uint64_t)SSO_TT_ORDERED << 44) | (sa_pow2_sz << 16) | lenm1_max;
954 : 0 : lf_cfg->rx_inline_cfg1 = (max_sa - 1) | ((uint64_t)sa_w << 32);
955 : :
956 : 0 : rc = mbox_process(mbox);
957 [ # # ]: 0 : if (rc) {
958 : 0 : plt_err("Failed to setup NIX Inbound SA conf of profile=%u, rc=%d", profile_id, rc);
959 : 0 : goto free_mem;
960 : : }
961 : :
962 : : mbox_put(mbox);
963 : 0 : return rc;
964 : :
965 : 0 : free_mem:
966 : : mbox_put(mbox);
967 : 0 : plt_free(nix->inb_sa_base[profile_id]);
968 : 0 : nix->inb_sa_base[profile_id] = NULL;
969 : : exit:
970 : : return rc;
971 : : }
972 : :
973 : : int
974 : 0 : roc_nix_inl_custom_profile_setup(struct roc_nix *roc_nix, uint64_t def_cfg, uint64_t gen_cfg,
975 : : uint64_t extract_cfg, const uint64_t *prot_field_cfg,
976 : : uint32_t sa_size, uint32_t max_sa, bool is_inline,
977 : : uint16_t *profile_id)
978 : : {
979 : : struct nix_rx_inl_profile_cfg_req *req;
980 : : struct nix_rx_inl_profile_cfg_rsp *rsp;
981 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
982 : 0 : struct idev_cfg *idev = idev_get_cfg();
983 : : struct nix_inl_dev *inl_dev = NULL;
984 : : struct mbox *mbox;
985 : : int rc = 0;
986 : : int i;
987 : :
988 [ # # ]: 0 : if (roc_nix == NULL || profile_id == NULL)
989 : : return -EINVAL;
990 : :
991 [ # # ]: 0 : if (!nix->inl_inb_ena)
992 : : return -ENOTSUP;
993 : :
994 : : /* Get inline device - required for custom profiles */
995 [ # # # # ]: 0 : if (!idev || !idev->nix_inl_dev) {
996 : 0 : plt_err("nix_inl_dev not available for custom profile setup");
997 : 0 : return -ENODEV;
998 : : }
999 : :
1000 : : inl_dev = idev->nix_inl_dev;
1001 : :
1002 : : /* Use inline device mbox if is_inline is true, otherwise use nix mbox */
1003 [ # # ]: 0 : if (is_inline)
1004 : 0 : mbox = mbox_get(inl_dev->dev.mbox);
1005 : : else
1006 : 0 : mbox = mbox_get(nix->dev.mbox);
1007 : :
1008 : 0 : req = mbox_alloc_msg_nix_rx_inl_profile_cfg(mbox);
1009 [ # # ]: 0 : if (req == NULL) {
1010 : : rc = -ENOSPC;
1011 [ # # ]: 0 : plt_err("Failed to alloc %s profile cfg mbox msg",
1012 : : is_inline ? "inline device" : "nix device");
1013 : : mbox_put(mbox);
1014 : 0 : goto exit;
1015 : : }
1016 : :
1017 : 0 : req->def_cfg = def_cfg;
1018 : 0 : req->gen_cfg = gen_cfg;
1019 : 0 : req->extract_cfg = extract_cfg;
1020 [ # # ]: 0 : for (i = 0; i < NIX_RX_INL_PROFILE_PROTO_CNT; i++)
1021 : 0 : req->prot_field_cfg[i] = prot_field_cfg[i];
1022 : :
1023 : : rc = mbox_process_msg(mbox, (void **)&rsp);
1024 [ # # ]: 0 : if (rc) {
1025 [ # # ]: 0 : plt_err("Failed to setup %s custom profile, rc=%d",
1026 : : is_inline ? "inline device" : "nix device", rc);
1027 : : mbox_put(mbox);
1028 : 0 : goto exit;
1029 : : }
1030 : :
1031 : 0 : *profile_id = rsp->profile_id;
1032 : :
1033 : : /* Validate returned profile_id */
1034 [ # # ]: 0 : if (*profile_id >= ROC_NIX_INL_PROFILE_CNT) {
1035 : 0 : plt_err("Hardware returned invalid profile_id %u", *profile_id);
1036 : : mbox_put(mbox);
1037 : : rc = -EINVAL;
1038 : 0 : goto exit;
1039 : : }
1040 : :
1041 [ # # ]: 0 : plt_info("%s custom profile %u created", is_inline ? "Inline device" : "NIX device",
1042 : : *profile_id);
1043 : : mbox_put(mbox);
1044 : :
1045 [ # # ]: 0 : if (is_inline)
1046 : 0 : rc = nix_inl_dev_profile_config(inl_dev, sa_size, max_sa, *profile_id);
1047 : : else
1048 : 0 : rc = nix_inl_custom_profile_sa_tbl_setup(roc_nix, sa_size, max_sa, *profile_id);
1049 : :
1050 [ # # ]: 0 : if (rc) {
1051 : 0 : plt_err("Failed to configure custom profile %u, rc=%d", *profile_id, rc);
1052 : : /* Release the allocated profile on failure */
1053 : 0 : roc_nix_inl_custom_profile_release(roc_nix, *profile_id, is_inline);
1054 : : }
1055 : :
1056 : 0 : exit:
1057 : : return rc;
1058 : : }
1059 : :
1060 : : int
1061 : 0 : roc_nix_inl_custom_profile_release(struct roc_nix *roc_nix, uint16_t profile_id, bool is_inline)
1062 : : {
1063 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
1064 : 0 : struct idev_cfg *idev = idev_get_cfg();
1065 : : struct nix_inl_dev *inl_dev = NULL;
1066 : : struct nix_rx_inl_lf_cfg_req *lf_cfg;
1067 : : struct mbox *mbox;
1068 : : int rc = 0;
1069 : :
1070 [ # # ]: 0 : if (roc_nix == NULL)
1071 : : return -EINVAL;
1072 : :
1073 [ # # ]: 0 : if (!nix->inl_inb_ena)
1074 : : return -ENOTSUP;
1075 : :
1076 : : /* Validate profile_id range */
1077 [ # # ]: 0 : if (profile_id >= ROC_NIX_INL_PROFILE_CNT) {
1078 : 0 : plt_err("Invalid profile_id %u, must be < %u", profile_id, ROC_NIX_INL_PROFILE_CNT);
1079 : 0 : return -EINVAL;
1080 : : }
1081 : :
1082 [ # # ]: 0 : if (is_inline) {
1083 : : /* Get inline device for inline mode */
1084 [ # # # # ]: 0 : if (!idev || !idev->nix_inl_dev) {
1085 : 0 : plt_err("nix_inl_dev not available for custom profile release");
1086 : 0 : return -ENODEV;
1087 : : }
1088 : : inl_dev = idev->nix_inl_dev;
1089 : 0 : mbox = mbox_get(inl_dev->dev.mbox);
1090 : : } else {
1091 : : /* Use NIX device mbox for non-inline mode */
1092 : 0 : mbox = mbox_get(nix->dev.mbox);
1093 : : }
1094 : :
1095 : 0 : lf_cfg = mbox_alloc_msg_nix_rx_inl_lf_cfg(mbox);
1096 [ # # ]: 0 : if (lf_cfg == NULL) {
1097 : : rc = -ENOSPC;
1098 : 0 : plt_err("Failed to alloc profile release mbox msg");
1099 : : mbox_put(mbox);
1100 : 0 : goto exit;
1101 : : }
1102 : :
1103 : 0 : lf_cfg->enable = 0;
1104 : 0 : lf_cfg->profile_id = profile_id;
1105 : 0 : rc = mbox_process(mbox);
1106 [ # # ]: 0 : if (rc) {
1107 : 0 : plt_err("Failed to cleanup NIX Inbound profile=%u SA conf, rc=%d", profile_id, rc);
1108 : : mbox_put(mbox);
1109 : 0 : goto exit;
1110 : : }
1111 : :
1112 : : /* Free SA base memory */
1113 [ # # ]: 0 : if (is_inline) {
1114 [ # # ]: 0 : if (inl_dev->inb_sa_base[profile_id]) {
1115 : 0 : plt_free(inl_dev->inb_sa_base[profile_id]);
1116 : 0 : inl_dev->inb_sa_base[profile_id] = NULL;
1117 : : }
1118 : : } else {
1119 [ # # ]: 0 : if (nix->inb_sa_base[profile_id]) {
1120 : 0 : plt_free(nix->inb_sa_base[profile_id]);
1121 : 0 : nix->inb_sa_base[profile_id] = NULL;
1122 : : }
1123 : : }
1124 : :
1125 : : mbox_put(mbox);
1126 [ # # ]: 0 : plt_info("%s custom profile %u released", is_inline ? "Inline device" : "NIX device",
1127 : : profile_id);
1128 : :
1129 : : exit:
1130 : : return rc;
1131 : : }
1132 : :
1133 : : bool
1134 : 0 : roc_nix_inl_inb_rx_inject_enable(struct roc_nix *roc_nix, bool inb_inl_dev)
1135 : : {
1136 : 0 : struct idev_cfg *idev = idev_get_cfg();
1137 : : struct nix_inl_dev *inl_dev;
1138 : : struct nix *nix = NULL;
1139 : :
1140 [ # # ]: 0 : if (idev == NULL)
1141 : : return 0;
1142 : :
1143 [ # # ]: 0 : if (!inb_inl_dev && roc_nix == NULL)
1144 : : return 0;
1145 : :
1146 [ # # ]: 0 : if (roc_nix) {
1147 : : nix = roc_nix_to_nix_priv(roc_nix);
1148 [ # # ]: 0 : if (!nix->inl_inb_ena)
1149 : : return 0;
1150 : : }
1151 : :
1152 [ # # ]: 0 : if (inb_inl_dev) {
1153 : 0 : inl_dev = idev->nix_inl_dev;
1154 [ # # # # : 0 : if (inl_dev && inl_dev->attach_cptlf && inl_dev->rx_inj_ena && roc_nix &&
# # # # ]
1155 [ # # ]: 0 : roc_nix->rx_inj_ena)
1156 : : return true;
1157 : : }
1158 : :
1159 [ # # # # ]: 0 : return roc_nix ? roc_nix->rx_inj_ena : 0;
1160 : : }
1161 : :
1162 : : uint32_t
1163 : 0 : roc_nix_inl_inb_spi_range(struct roc_nix *roc_nix, bool inb_inl_dev,
1164 : : uint32_t *min_spi, uint32_t *max_spi)
1165 : : {
1166 : 0 : struct idev_cfg *idev = idev_get_cfg();
1167 : : uint32_t min = 0, max = 0, mask = 0;
1168 : : struct nix_inl_dev *inl_dev;
1169 : : struct nix *nix = NULL;
1170 : :
1171 [ # # ]: 0 : if (idev == NULL)
1172 : : return 0;
1173 : :
1174 [ # # ]: 0 : if (!inb_inl_dev && roc_nix == NULL)
1175 : : return -EINVAL;
1176 : :
1177 : 0 : inl_dev = idev->nix_inl_dev;
1178 [ # # ]: 0 : if (inb_inl_dev) {
1179 [ # # ]: 0 : if (inl_dev == NULL)
1180 : 0 : goto exit;
1181 : 0 : min = inl_dev->ipsec_in_min_spi;
1182 : 0 : max = inl_dev->ipsec_in_max_spi;
1183 : 0 : mask = inl_dev->inb_spi_mask;
1184 : : } else {
1185 : : nix = roc_nix_to_nix_priv(roc_nix);
1186 [ # # ]: 0 : if (!nix->inl_inb_ena)
1187 : 0 : goto exit;
1188 : 0 : min = roc_nix->ipsec_in_min_spi;
1189 : 0 : max = roc_nix->ipsec_in_max_spi;
1190 : 0 : mask = nix->inb_spi_mask;
1191 : : }
1192 : 0 : exit:
1193 [ # # ]: 0 : if (min_spi)
1194 : 0 : *min_spi = min;
1195 [ # # ]: 0 : if (max_spi)
1196 : 0 : *max_spi = max;
1197 : : return mask;
1198 : : }
1199 : :
1200 : : uint32_t
1201 : 0 : roc_nix_inl_inb_sa_sz(struct roc_nix *roc_nix, bool inl_dev_sa)
1202 : : {
1203 : 0 : struct idev_cfg *idev = idev_get_cfg();
1204 : : struct nix_inl_dev *inl_dev;
1205 : : struct nix *nix;
1206 : :
1207 [ # # ]: 0 : if (idev == NULL)
1208 : : return 0;
1209 : :
1210 [ # # ]: 0 : if (!inl_dev_sa && roc_nix == NULL)
1211 : : return -EINVAL;
1212 : :
1213 [ # # ]: 0 : if (roc_nix) {
1214 : : nix = roc_nix_to_nix_priv(roc_nix);
1215 [ # # ]: 0 : if (!inl_dev_sa)
1216 : 0 : return nix->inb_sa_sz[nix->ipsec_prof_id];
1217 : : }
1218 : :
1219 [ # # ]: 0 : if (inl_dev_sa) {
1220 : 0 : inl_dev = idev->nix_inl_dev;
1221 [ # # ]: 0 : if (inl_dev)
1222 : 0 : return inl_dev->inb_sa_sz[inl_dev->ipsec_prof_id];
1223 : : }
1224 : :
1225 : : return 0;
1226 : : }
1227 : :
1228 : : uintptr_t
1229 : 0 : roc_nix_inl_inb_sa_get(struct roc_nix *roc_nix, bool inb_inl_dev, uint32_t spi)
1230 : : {
1231 : 0 : uint32_t max_spi = 0, min_spi = 0, mask;
1232 : : uintptr_t sa_base;
1233 : : uint64_t sz;
1234 : :
1235 : 0 : sa_base = roc_nix_inl_inb_sa_base_get(roc_nix, inb_inl_dev);
1236 : : /* Check if SA base exists */
1237 [ # # ]: 0 : if (!sa_base)
1238 : : return 0;
1239 : :
1240 : : /* Get SA size */
1241 : 0 : sz = roc_nix_inl_inb_sa_sz(roc_nix, inb_inl_dev);
1242 [ # # ]: 0 : if (!sz)
1243 : : return 0;
1244 : :
1245 [ # # # # ]: 0 : if (roc_nix && roc_nix->custom_sa_action)
1246 : 0 : return (sa_base + (spi * sz));
1247 : :
1248 : : /* Check if SPI is in range */
1249 : 0 : mask = roc_nix_inl_inb_spi_range(roc_nix, inb_inl_dev, &min_spi,
1250 : : &max_spi);
1251 [ # # # # ]: 0 : if (spi > max_spi || spi < min_spi)
1252 : 0 : plt_nix_dbg("Inbound SA SPI %u not in range (%u..%u)", spi,
1253 : : min_spi, max_spi);
1254 : :
1255 : : /* Basic logic of SPI->SA for now */
1256 : 0 : return (sa_base + ((spi & mask) * sz));
1257 : : }
1258 : :
1259 : : int
1260 : 0 : roc_nix_reassembly_configure(struct roc_cpt_rxc_time_cfg *req_cfg, uint32_t max_wait_time)
1261 : : {
1262 : 0 : struct idev_cfg *idev = idev_get_cfg();
1263 : : struct nix_inl_dev *inl_dev = NULL;
1264 : : struct cpt_rxc_time_cfg_req *req;
1265 : : struct roc_cpt_rxc_time_cfg cfg;
1266 : : struct roc_cpt *roc_cpt;
1267 : : struct mbox *mbox;
1268 : : uint32_t val;
1269 : : int rc;
1270 : :
1271 [ # # ]: 0 : if (!idev)
1272 : : return -EFAULT;
1273 : :
1274 : 0 : cfg.zombie_limit =
1275 [ # # ]: 0 : req_cfg->zombie_limit ? req_cfg->zombie_limit : ROC_NIX_INL_REAS_ZOMBIE_LIMIT;
1276 : 0 : cfg.zombie_thres =
1277 [ # # ]: 0 : req_cfg->zombie_thres ? req_cfg->zombie_thres : ROC_NIX_INL_REAS_ZOMBIE_THRESHOLD;
1278 [ # # ]: 0 : cfg.active_thres =
1279 [ # # ]: 0 : req_cfg->active_thres ? req_cfg->active_thres : ROC_NIX_INL_REAS_ACTIVE_THRESHOLD;
1280 : :
1281 [ # # ]: 0 : if (roc_model_is_cn10k()) {
1282 : 0 : roc_cpt = idev->cpt;
1283 [ # # ]: 0 : if (!roc_cpt) {
1284 : 0 : plt_err("Cryptodev not probed");
1285 : 0 : return -ENOTSUP;
1286 : : }
1287 : :
1288 [ # # ]: 0 : val = max_wait_time ? (max_wait_time * 1000 / ROC_NIX_INL_REAS_ACTIVE_LIMIT) : 0;
1289 [ # # ]: 0 : cfg.step = req_cfg->step ? req_cfg->step : val;
1290 [ # # ]: 0 : cfg.active_limit = req_cfg->active_limit ? req_cfg->active_limit :
1291 : : ROC_NIX_INL_REAS_ACTIVE_LIMIT;
1292 : :
1293 : 0 : return roc_cpt_rxc_time_cfg(roc_cpt, &cfg);
1294 : : }
1295 : :
1296 : 0 : inl_dev = idev->nix_inl_dev;
1297 [ # # ]: 0 : if (!inl_dev) {
1298 : 0 : plt_err("Cannot support RXC config, inlinedev is not probed");
1299 : 0 : return -ENOTSUP;
1300 : : }
1301 : :
1302 : 0 : mbox = mbox_get((&inl_dev->dev)->mbox);
1303 : :
1304 : 0 : req = mbox_alloc_msg_cpt_rxc_time_cfg(mbox);
1305 [ # # ]: 0 : if (req == NULL) {
1306 : : rc = -ENOSPC;
1307 : 0 : goto exit;
1308 : : }
1309 : :
1310 : : /* For CN20K, Configure step size fix and active limit per RXC queue,
1311 : : * Default CPT_AF_RXC_TIME_CFG::AGE_STEP will be 1ms, so max reassembly
1312 : : * timeout can be up to 4095 ms.
1313 : : */
1314 [ # # ]: 0 : cfg.step = req_cfg->step ? req_cfg->step : ROC_NIX_INL_REAS_STEP_DFLT;
1315 [ # # ]: 0 : val = max_wait_time ? (max_wait_time * 1000 / cfg.step) : 0;
1316 [ # # ]: 0 : cfg.active_limit = req_cfg->active_limit ? req_cfg->active_limit : val;
1317 [ # # ]: 0 : if (cfg.active_limit > ROC_NIX_INL_REAS_ACTIVE_LIMIT)
1318 : 0 : cfg.active_limit = ROC_NIX_INL_REAS_ACTIVE_LIMIT;
1319 : :
1320 : 0 : req->blkaddr = 0;
1321 : 0 : req->queue_id = inl_dev->nix_inb_qids[inl_dev->inb_cpt_lf_id];
1322 : 0 : req->step = cfg.step;
1323 : 0 : req->zombie_limit = cfg.zombie_limit;
1324 : 0 : req->zombie_thres = cfg.zombie_thres;
1325 : 0 : req->active_limit = cfg.active_limit;
1326 : 0 : req->active_thres = cfg.active_thres;
1327 : 0 : req->cpt_af_rxc_que_cfg = ROC_NIX_INL_RXC_QUE_BLK_THR << 32;
1328 : :
1329 : 0 : rc = mbox_process(mbox);
1330 : 0 : exit:
1331 : : mbox_put(mbox);
1332 : 0 : return rc;
1333 : : }
1334 : :
1335 : : static void
1336 : 0 : nix_inl_rq_mask_init(struct nix_rq_cpt_field_mask_cfg_req *msk_req, uint8_t first_skip)
1337 : : {
1338 : : int i;
1339 : :
1340 [ # # ]: 0 : for (i = 0; i < RQ_CTX_MASK_MAX; i++)
1341 : 0 : msk_req->rq_ctx_word_mask[i] = 0xFFFFFFFFFFFFFFFF;
1342 : :
1343 : 0 : msk_req->rq_set.len_ol3_dis = 1;
1344 : 0 : msk_req->rq_set.len_ol4_dis = 1;
1345 : 0 : msk_req->rq_set.len_il3_dis = 1;
1346 : :
1347 : 0 : msk_req->rq_set.len_il4_dis = 1;
1348 : 0 : msk_req->rq_set.csum_ol4_dis = 1;
1349 : 0 : msk_req->rq_set.csum_il4_dis = 1;
1350 : :
1351 : 0 : msk_req->rq_set.lenerr_dis = 1;
1352 : 0 : msk_req->rq_set.port_ol4_dis = 1;
1353 : 0 : msk_req->rq_set.port_il4_dis = 1;
1354 : :
1355 : 0 : msk_req->rq_set.lpb_drop_ena = 0;
1356 : 0 : msk_req->rq_set.spb_drop_ena = 0;
1357 : 0 : msk_req->rq_set.xqe_drop_ena = 0;
1358 : 0 : msk_req->rq_set.spb_ena = 1;
1359 [ # # ]: 0 : if (first_skip)
1360 : 0 : msk_req->rq_set.first_skip = first_skip;
1361 : :
1362 [ # # ]: 0 : if (!roc_feature_nix_has_second_pass_drop()) {
1363 : 0 : msk_req->rq_set.ena = 1;
1364 : 0 : msk_req->rq_set.rq_int_ena = 1;
1365 : 0 : msk_req->rq_mask.ena = 0;
1366 : 0 : msk_req->rq_mask.rq_int_ena = 0;
1367 : : }
1368 : :
1369 : 0 : msk_req->rq_mask.len_ol3_dis = 0;
1370 : 0 : msk_req->rq_mask.len_ol4_dis = 0;
1371 : 0 : msk_req->rq_mask.len_il3_dis = 0;
1372 : :
1373 : 0 : msk_req->rq_mask.len_il4_dis = 0;
1374 : 0 : msk_req->rq_mask.csum_ol4_dis = 0;
1375 : 0 : msk_req->rq_mask.csum_il4_dis = 0;
1376 : :
1377 : 0 : msk_req->rq_mask.lenerr_dis = 0;
1378 : 0 : msk_req->rq_mask.port_ol4_dis = 0;
1379 : 0 : msk_req->rq_mask.port_il4_dis = 0;
1380 : :
1381 : 0 : msk_req->rq_mask.lpb_drop_ena = 0;
1382 : 0 : msk_req->rq_mask.spb_drop_ena = 0;
1383 : 0 : msk_req->rq_mask.xqe_drop_ena = 0;
1384 : 0 : msk_req->rq_mask.spb_ena = 0;
1385 [ # # ]: 0 : if (first_skip)
1386 : 0 : msk_req->rq_mask.first_skip = 0;
1387 : 0 : }
1388 : :
1389 : : static int
1390 : 0 : nix_inl_legacy_rq_mask_setup(struct roc_nix *roc_nix, bool enable)
1391 : : {
1392 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
1393 : : struct nix_rq_cpt_field_mask_cfg_req *msk_req;
1394 : 0 : struct idev_cfg *idev = idev_get_cfg();
1395 : 0 : struct mbox *mbox = mbox_get((&nix->dev)->mbox);
1396 : : struct idev_nix_inl_cfg *inl_cfg;
1397 : : uint64_t aura_handle;
1398 : : int rc = -ENOSPC;
1399 : : uint32_t buf_sz;
1400 : :
1401 [ # # ]: 0 : if (!idev)
1402 : 0 : goto exit;
1403 : :
1404 : : inl_cfg = &idev->inl_cfg;
1405 : 0 : msk_req = mbox_alloc_msg_nix_lf_inline_rq_cfg(mbox);
1406 [ # # ]: 0 : if (msk_req == NULL)
1407 : 0 : goto exit;
1408 : :
1409 : 0 : nix_inl_rq_mask_init(msk_req, 0);
1410 [ # # ]: 0 : if (roc_nix->local_meta_aura_ena) {
1411 : 0 : aura_handle = roc_nix->meta_aura_handle;
1412 : 0 : buf_sz = roc_nix->buf_sz;
1413 [ # # ]: 0 : if (!aura_handle && enable) {
1414 : 0 : plt_err("NULL meta aura handle");
1415 : 0 : goto exit;
1416 : : }
1417 : : } else {
1418 : 0 : aura_handle = roc_npa_zero_aura_handle();
1419 : 0 : buf_sz = inl_cfg->buf_sz;
1420 : : }
1421 : :
1422 : 0 : msk_req->ipsec_cfg1_inline_replay.spb_cpt_aura = roc_npa_aura_handle_to_aura(aura_handle);
1423 : 0 : msk_req->ipsec_cfg1_inline_replay.rq_mask_enable = enable;
1424 : 0 : msk_req->ipsec_cfg1_inline_replay.spb_cpt_sizem1 = (buf_sz >> 7) - 1;
1425 : 0 : msk_req->ipsec_cfg1_inline_replay.spb_cpt_enable = enable;
1426 : :
1427 : 0 : rc = mbox_process(mbox);
1428 : 0 : exit:
1429 : : mbox_put(mbox);
1430 : 0 : return rc;
1431 : : }
1432 : :
1433 : : static int
1434 [ # # ]: 0 : nix_inl_rq_mask_cfg(struct roc_nix *roc_nix, bool enable)
1435 : : {
1436 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
1437 : : struct nix_rq_cpt_field_mask_cfg_req *msk_req;
1438 : : uint64_t aura_handle;
1439 : : uint8_t first_skip;
1440 : : struct mbox *mbox;
1441 : : int rc = -ENOSPC;
1442 : : uint64_t buf_sz;
1443 : :
1444 [ # # ]: 0 : if (roc_model_is_cn9k() | roc_model_is_cn10k())
1445 : 0 : return nix_inl_legacy_rq_mask_setup(roc_nix, enable);
1446 : :
1447 : 0 : mbox = mbox_get((&nix->dev)->mbox);
1448 : : /* RQ mask alloc and setup */
1449 : 0 : msk_req = mbox_alloc_msg_nix_lf_inline_rq_cfg(mbox);
1450 [ # # ]: 0 : if (msk_req == NULL)
1451 : 0 : goto exit;
1452 : :
1453 [ # # ]: 0 : first_skip = roc_nix->def_first_skip ? (roc_nix->def_first_skip / 8) : 0;
1454 : 0 : nix_inl_rq_mask_init(msk_req, first_skip);
1455 : :
1456 [ # # ]: 0 : if (roc_nix->local_meta_aura_ena) {
1457 : 0 : aura_handle = roc_nix->meta_aura_handle;
1458 : 0 : buf_sz = roc_nix->buf_sz;
1459 [ # # ]: 0 : if (!aura_handle && enable) {
1460 : 0 : plt_err("NULL meta aura handle");
1461 : : rc = -EINVAL;
1462 : 0 : goto exit;
1463 : : }
1464 : :
1465 : : /* SPB setup */
1466 : 0 : msk_req->ipsec_cfg1_inline_replay.spb_cpt_aura =
1467 : : roc_npa_aura_handle_to_aura(aura_handle);
1468 : 0 : msk_req->ipsec_cfg1_inline_replay.rq_mask_enable = enable;
1469 : 0 : msk_req->ipsec_cfg1_inline_replay.spb_cpt_sizem1 = (buf_sz >> 7) - 1;
1470 : 0 : msk_req->ipsec_cfg1_inline_replay.spb_cpt_enable = enable;
1471 : : }
1472 : :
1473 : 0 : rc = mbox_process(mbox);
1474 [ # # ]: 0 : if (rc)
1475 : 0 : plt_err("Failed to setup NIX Inline RQ mask, rc=%d", rc);
1476 : :
1477 : 0 : exit:
1478 : : mbox_put(mbox);
1479 : 0 : return rc;
1480 : : }
1481 : :
1482 : : static void
1483 : 0 : nix_inl_eng_caps_get(struct nix *nix)
1484 : : {
1485 : 0 : struct roc_cpt_lf *lf = nix->cpt_lf_base;
1486 : 0 : uintptr_t lmt_base = lf->lmt_base;
1487 : : union cpt_res_s res, *hw_res;
1488 : : struct cpt_inst_s inst;
1489 : : uint64_t *rptr;
1490 : :
1491 : 0 : hw_res = plt_zmalloc(sizeof(*hw_res), ROC_CPT_RES_ALIGN);
1492 [ # # ]: 0 : if (hw_res == NULL) {
1493 : 0 : plt_err("Couldn't allocate memory for result address");
1494 : 0 : return;
1495 : : }
1496 : :
1497 : 0 : rptr = plt_zmalloc(ROC_ALIGN, 0);
1498 [ # # ]: 0 : if (rptr == NULL) {
1499 : 0 : plt_err("Couldn't allocate memory for rptr");
1500 : 0 : plt_free(hw_res);
1501 : 0 : return;
1502 : : }
1503 : :
1504 : : /* Fill CPT_INST_S for LOAD_FVC/HW_CRYPTO_SUPPORT microcode op */
1505 : : memset(&inst, 0, sizeof(struct cpt_inst_s));
1506 : 0 : inst.res_addr = (uint64_t)hw_res;
1507 : 0 : inst.rptr = (uint64_t)rptr;
1508 : 0 : inst.w4.s.opcode_major = ROC_LOADFVC_MAJOR_OP;
1509 : 0 : inst.w4.s.opcode_minor = ROC_LOADFVC_MINOR_OP;
1510 : :
1511 : : /* SE engine group ID is same for all platform */
1512 : : inst.w7.s.egrp = ROC_CPT_DFLT_ENG_GRP_SE;
1513 : :
1514 : : /* Use 1 min timeout for the poll */
1515 [ # # ]: 0 : const uint64_t timeout = plt_tsc_cycles() + 60 * plt_tsc_hz();
1516 : :
1517 [ # # ]: 0 : if (roc_model_is_cn9k()) {
1518 : : uint64_t lmt_status;
1519 : :
1520 : 0 : hw_res->cn9k.compcode = CPT_COMP_NOT_DONE;
1521 : 0 : plt_io_wmb();
1522 : :
1523 : : do {
1524 : : roc_lmt_mov_seg((void *)lmt_base, &inst, 4);
1525 : : lmt_status = roc_lmt_submit_ldeor(lf->io_addr);
1526 : : } while (lmt_status == 0);
1527 : :
1528 : : /* Wait until CPT instruction completes */
1529 : : do {
1530 : : res.u64[0] = __atomic_load_n(&hw_res->u64[0], __ATOMIC_RELAXED);
1531 : : if (unlikely(plt_tsc_cycles() > timeout))
1532 : : break;
1533 : : } while (res.cn9k.compcode == CPT_COMP_NOT_DONE);
1534 : :
1535 : : if (res.cn9k.compcode != CPT_COMP_GOOD) {
1536 : : plt_err("LOAD FVC operation timed out");
1537 : : return;
1538 : : }
1539 [ # # ]: 0 : } else if (roc_model_is_cn10k()) {
1540 : : uint64_t lmt_arg, io_addr;
1541 : : uint16_t lmt_id;
1542 : :
1543 : 0 : hw_res->cn10k.compcode = CPT_COMP_NOT_DONE;
1544 : :
1545 : : /* Use this reserved LMT line as no one else is using it */
1546 : 0 : lmt_id = roc_plt_control_lmt_id_get();
1547 : 0 : lmt_base += ((uint64_t)lmt_id << ROC_LMT_LINE_SIZE_LOG2);
1548 : :
1549 : 0 : memcpy((void *)lmt_base, &inst, sizeof(inst));
1550 : :
1551 : : lmt_arg = ROC_CN10K_CPT_LMT_ARG | (uint64_t)lmt_id;
1552 : : io_addr = lf->io_addr | ROC_CN10K_CPT_INST_DW_M1 << 4;
1553 : :
1554 : : roc_lmt_submit_steorl(lmt_arg, io_addr);
1555 : 0 : plt_io_wmb();
1556 : :
1557 : : /* Wait until CPT instruction completes */
1558 : : do {
1559 : 0 : res.u64[0] = __atomic_load_n(&hw_res->u64[0], __ATOMIC_RELAXED);
1560 [ # # ]: 0 : if (unlikely(plt_tsc_cycles() > timeout))
1561 : : break;
1562 [ # # ]: 0 : } while (res.cn10k.compcode == CPT_COMP_NOT_DONE);
1563 : :
1564 [ # # ]: 0 : if (res.cn10k.compcode != CPT_COMP_GOOD || res.cn10k.uc_compcode) {
1565 : 0 : plt_err("LOAD FVC operation timed out");
1566 : 0 : goto exit;
1567 : : }
1568 : : } else {
1569 : : uint64_t lmt_arg, io_addr;
1570 : : uint16_t lmt_id;
1571 : :
1572 : 0 : hw_res->cn20k.compcode = CPT_COMP_NOT_DONE;
1573 : :
1574 : : /* Use this reserved LMT line as no one else is using it */
1575 : 0 : lmt_id = roc_plt_control_lmt_id_get();
1576 : 0 : lmt_base += ((uint64_t)lmt_id << ROC_LMT_LINE_SIZE_LOG2);
1577 : :
1578 : 0 : memcpy((void *)lmt_base, &inst, sizeof(inst));
1579 : :
1580 : : lmt_arg = ROC_CN20K_CPT_LMT_ARG | (uint64_t)lmt_id;
1581 : : io_addr = lf->io_addr | ROC_CN20K_CPT_INST_DW_M1 << 4;
1582 : :
1583 : : roc_lmt_submit_steorl(lmt_arg, io_addr);
1584 : 0 : plt_io_wmb();
1585 : :
1586 : : /* Wait until CPT instruction completes */
1587 : : do {
1588 : 0 : res.u64[0] = __atomic_load_n(&hw_res->u64[0], __ATOMIC_RELAXED);
1589 [ # # ]: 0 : if (unlikely(plt_tsc_cycles() > timeout))
1590 : : break;
1591 [ # # ]: 0 : } while (res.cn20k.compcode == CPT_COMP_NOT_DONE);
1592 : :
1593 [ # # ]: 0 : if (res.cn20k.compcode != CPT_COMP_GOOD || res.cn20k.uc_compcode) {
1594 : 0 : plt_err("LOAD FVC operation timed out");
1595 : 0 : goto exit;
1596 : : }
1597 : : }
1598 : :
1599 [ # # ]: 0 : nix->cpt_eng_caps = plt_be_to_cpu_64(*rptr);
1600 : 0 : exit:
1601 : 0 : plt_free(rptr);
1602 : 0 : plt_free(hw_res);
1603 : : }
1604 : :
1605 : : static int
1606 : 0 : nix_inl_legacy_inb_init(struct roc_nix *roc_nix)
1607 : : {
1608 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
1609 : 0 : struct roc_cpt_inline_ipsec_inb_cfg cfg = {0};
1610 : 0 : struct idev_cfg *idev = idev_get_cfg();
1611 : : uint16_t bpids[ROC_NIX_MAX_BPID_CNT];
1612 : : struct roc_cpt *roc_cpt;
1613 : : int rc;
1614 : :
1615 [ # # ]: 0 : if (idev == NULL)
1616 : : return -ENOTSUP;
1617 : :
1618 : : /* Unless we have another mechanism to trigger
1619 : : * onetime Inline config in CPTPF, we cannot
1620 : : * support without CPT being probed.
1621 : : */
1622 : 0 : roc_cpt = idev->cpt;
1623 [ # # ]: 0 : if (!roc_cpt) {
1624 : 0 : plt_err("Cannot support inline inbound, cryptodev not probed");
1625 : 0 : return -ENOTSUP;
1626 : : }
1627 : :
1628 [ # # ]: 0 : nix->ipsec_prof_id = 0;
1629 : : memset(&cfg, 0, sizeof(cfg));
1630 [ # # ]: 0 : if (roc_model_is_cn9k()) {
1631 : 0 : cfg.param1 = (ROC_ONF_IPSEC_INB_MAX_L2_SZ >> 3) & 0xf;
1632 : 0 : cfg.param2 = ROC_IE_ON_INB_IKEV2_SINGLE_SA_SUPPORT;
1633 : 0 : cfg.opcode =
1634 : : ((ROC_IE_ON_INB_MAX_CTX_LEN << 8) |
1635 : : (ROC_IE_ON_MAJOR_OP_PROCESS_INBOUND_IPSEC | (1 << 6)));
1636 : : } else {
1637 : : union roc_ot_ipsec_inb_param1 u;
1638 : :
1639 : : u.u16 = 0;
1640 : : u.s.esp_trailer_disable = 1;
1641 : 0 : cfg.param1 = u.u16;
1642 : : cfg.param2 = 0;
1643 : 0 : cfg.opcode = (ROC_IE_OT_MAJOR_OP_PROCESS_INBOUND_IPSEC | (1 << 6));
1644 : :
1645 [ # # ]: 0 : if (roc_nix->custom_inb_sa) {
1646 : 0 : cfg.param1 = roc_nix->inb_cfg_param1;
1647 : 0 : cfg.param2 = roc_nix->inb_cfg_param2;
1648 : : }
1649 : 0 : rc = roc_nix_bpids_alloc(roc_nix, ROC_NIX_INTF_TYPE_CPT_NIX, 1, bpids);
1650 [ # # ]: 0 : if (rc > 0) {
1651 : 0 : nix->cpt_nixbpid = bpids[0];
1652 : 0 : cfg.bpid = nix->cpt_nixbpid;
1653 : : }
1654 : :
1655 [ # # ]: 0 : if (roc_errata_cpt_has_ctx_fetch_issue()) {
1656 : 0 : cfg.ctx_ilen_valid = true;
1657 : 0 : cfg.ctx_ilen = (ROC_NIX_INL_OT_IPSEC_INB_HW_SZ / 128) - 1;
1658 : : }
1659 : : }
1660 : :
1661 : : /* Do onetime Inbound Inline config in CPTPF */
1662 : 0 : rc = roc_cpt_inline_ipsec_inb_cfg(roc_cpt, &cfg);
1663 [ # # ]: 0 : if (rc && rc != -EEXIST) {
1664 : 0 : plt_err("Failed to setup inbound lf, rc=%d", rc);
1665 : 0 : return rc;
1666 : : }
1667 : 0 : nix->cpt_eng_caps = roc_cpt->hw_caps[CPT_ENG_TYPE_SE].u;
1668 : :
1669 : : /* Setup Inbound SA table */
1670 : 0 : rc = nix_inl_inb_ipsec_sa_tbl_setup(roc_nix);
1671 [ # # ]: 0 : if (rc)
1672 : : return rc;
1673 : :
1674 [ # # # # ]: 0 : if (!roc_model_is_cn9k() && !roc_errata_nix_no_meta_aura()) {
1675 : 0 : nix->need_meta_aura = true;
1676 [ # # # # ]: 0 : if (!roc_nix->local_meta_aura_ena || roc_nix->custom_meta_aura_ena)
1677 : 0 : idev->inl_cfg.refs++;
1678 : : }
1679 : :
1680 : 0 : nix->inl_inb_ena = true;
1681 : 0 : return 0;
1682 : : }
1683 : :
1684 : : static int
1685 : 0 : nix_inl_inb_init(struct roc_nix *roc_nix)
1686 : : {
1687 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
1688 : 0 : struct idev_cfg *idev = idev_get_cfg();
1689 : : struct nix_inl_dev *inl_dev;
1690 : : int rc;
1691 : :
1692 [ # # ]: 0 : if (idev == NULL)
1693 : : return -ENOTSUP;
1694 : :
1695 : 0 : inl_dev = idev->nix_inl_dev;
1696 : :
1697 [ # # # # ]: 0 : if (!inl_dev || !inl_dev->nb_inb_cptlfs) {
1698 : 0 : plt_err("Cannot support inline inbound without inline dev");
1699 : 0 : return -ENOTSUP;
1700 : : }
1701 : :
1702 : : /* FIXME get engine caps from inline device */
1703 : 0 : nix->cpt_eng_caps = 0;
1704 : :
1705 : : /* Setup Inbound SA table */
1706 : 0 : rc = nix_inl_inb_ipsec_sa_tbl_setup(roc_nix);
1707 [ # # ]: 0 : if (rc)
1708 : : return rc;
1709 : :
1710 [ # # ]: 0 : if (roc_nix->reass_ena) {
1711 : 0 : rc = nix_inl_reass_inb_sa_tbl_setup(roc_nix);
1712 [ # # ]: 0 : if (rc)
1713 : : return rc;
1714 : : }
1715 : :
1716 [ # # # # ]: 0 : if (roc_nix->local_meta_aura_ena || roc_nix->custom_meta_aura_ena) {
1717 : 0 : nix->need_meta_aura = true;
1718 : :
1719 [ # # ]: 0 : if (roc_nix->custom_meta_aura_ena)
1720 : 0 : idev->inl_cfg.refs++;
1721 : : }
1722 : :
1723 : 0 : nix->inl_inb_ena = true;
1724 : 0 : return 0;
1725 : : }
1726 : :
1727 : : int
1728 [ # # ]: 0 : roc_nix_inl_inb_init(struct roc_nix *roc_nix)
1729 : : {
1730 [ # # # # ]: 0 : if (roc_model_is_cn9k() || roc_model_is_cn10k())
1731 : 0 : return nix_inl_legacy_inb_init(roc_nix);
1732 : :
1733 : 0 : return nix_inl_inb_init(roc_nix);
1734 : : }
1735 : : int
1736 : 0 : roc_nix_inl_inb_fini(struct roc_nix *roc_nix)
1737 : : {
1738 : 0 : struct idev_cfg *idev = idev_get_cfg();
1739 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
1740 : : int rc;
1741 : :
1742 [ # # ]: 0 : if (!nix->inl_inb_ena)
1743 : : return 0;
1744 : :
1745 [ # # ]: 0 : if (!idev)
1746 : : return -EFAULT;
1747 : :
1748 : 0 : nix->inl_inb_ena = false;
1749 : :
1750 [ # # ]: 0 : if (nix->need_meta_aura) {
1751 : 0 : nix->need_meta_aura = false;
1752 [ # # # # ]: 0 : if (!roc_nix->local_meta_aura_ena || roc_nix->custom_meta_aura_ena)
1753 : 0 : idev->inl_cfg.refs--;
1754 : :
1755 [ # # ]: 0 : if (roc_nix->custom_meta_aura_ena)
1756 : 0 : nix_inl_custom_meta_aura_destroy(roc_nix);
1757 : :
1758 [ # # ]: 0 : if (!idev->inl_cfg.refs)
1759 : 0 : nix_inl_meta_aura_destroy(roc_nix);
1760 : : }
1761 : :
1762 [ # # ]: 0 : if (roc_feature_nix_has_inl_rq_mask()) {
1763 : 0 : rc = nix_inl_rq_mask_cfg(roc_nix, false);
1764 [ # # ]: 0 : if (rc) {
1765 : 0 : plt_err("Failed to get rq mask rc=%d", rc);
1766 : 0 : return rc;
1767 : : }
1768 : : }
1769 : :
1770 : : /* Flush Inbound CTX cache entries */
1771 : 0 : roc_nix_cpt_ctx_cache_sync(roc_nix);
1772 : :
1773 [ # # ]: 0 : if (roc_nix->reass_ena)
1774 : 0 : nix_inl_reass_sa_tbl_release(roc_nix);
1775 : :
1776 : : /* Disable Inbound SA */
1777 : 0 : return nix_inl_ipsec_sa_tbl_release(roc_nix);
1778 : : }
1779 : :
1780 : : int
1781 : 0 : roc_nix_inl_outb_init(struct roc_nix *roc_nix)
1782 : : {
1783 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
1784 : 0 : struct idev_cfg *idev = idev_get_cfg();
1785 : : struct roc_cpt_lf *lf_base, *lf;
1786 : 0 : struct dev *dev = &nix->dev;
1787 : : struct msix_offset_rsp *rsp;
1788 : : struct nix_inl_dev *inl_dev;
1789 : : bool ctx_ilen_valid = false;
1790 : : size_t sa_sz, ring_sz;
1791 : : uint8_t ctx_ilen = 0;
1792 : : bool rx_inj = false;
1793 : : uint16_t sso_pffunc;
1794 : : uint8_t eng_grpmask;
1795 : : uint64_t blkaddr, i;
1796 : : uint64_t *ring_base;
1797 : : uint16_t nb_lf;
1798 : : void *sa_base;
1799 : : int j, rc;
1800 : : void *sa;
1801 : :
1802 [ # # ]: 0 : if (idev == NULL)
1803 : : return -ENOTSUP;
1804 : :
1805 : 0 : nb_lf = roc_nix->outb_nb_crypto_qs;
1806 [ # # ]: 0 : blkaddr = nix->is_nix1 ? RVU_BLOCK_ADDR_CPT1 : RVU_BLOCK_ADDR_CPT0;
1807 : :
1808 : : /* Retrieve inline device if present */
1809 : 0 : inl_dev = idev->nix_inl_dev;
1810 [ # # # # : 0 : if (roc_nix->rx_inj_ena && !(nix->inb_inl_dev && inl_dev && inl_dev->attach_cptlf &&
# # # # ]
1811 [ # # ]: 0 : inl_dev->rx_inj_ena)) {
1812 : 0 : nb_lf++;
1813 : : rx_inj = true;
1814 : : }
1815 : :
1816 [ # # ]: 0 : sso_pffunc = inl_dev ? inl_dev->dev.pf_func : idev_sso_pffunc_get();
1817 : : /* Use sso_pffunc if explicitly requested */
1818 [ # # ]: 0 : if (roc_nix->ipsec_out_sso_pffunc)
1819 : 0 : sso_pffunc = idev_sso_pffunc_get();
1820 : :
1821 [ # # ]: 0 : if (!sso_pffunc) {
1822 : 0 : plt_err("Failed to setup inline outb, need either "
1823 : : "inline device or sso device");
1824 : 0 : return -ENOTSUP;
1825 : : }
1826 : :
1827 : : /* Attach CPT LF for outbound */
1828 : 0 : rc = cpt_lfs_attach(dev, blkaddr, true, nb_lf);
1829 [ # # ]: 0 : if (rc) {
1830 : 0 : plt_err("Failed to attach CPT LF for inline outb, rc=%d", rc);
1831 : 0 : return rc;
1832 : : }
1833 : :
1834 [ # # # # ]: 0 : if (!roc_model_is_cn9k() && roc_errata_cpt_has_ctx_fetch_issue()) {
1835 : : ctx_ilen = (ROC_NIX_INL_OT_IPSEC_OUTB_HW_SZ / 128) - 1;
1836 : : ctx_ilen_valid = true;
1837 : : }
1838 : :
1839 [ # # # # ]: 0 : if (roc_model_is_cn9k() || roc_model_is_cn10k())
1840 : : eng_grpmask = (1ULL << ROC_LEGACY_CPT_DFLT_ENG_GRP_SE |
1841 : : 1ULL << ROC_LEGACY_CPT_DFLT_ENG_GRP_SE_IE |
1842 : : 1ULL << ROC_LEGACY_CPT_DFLT_ENG_GRP_AE);
1843 : : else
1844 : : eng_grpmask = (1ULL << ROC_CPT_DFLT_ENG_GRP_SE | 1ULL << ROC_CPT_DFLT_ENG_GRP_AE);
1845 : :
1846 : : /* Alloc CPT LF */
1847 : 0 : rc = cpt_lfs_alloc(dev, eng_grpmask, blkaddr,
1848 : 0 : !roc_nix->ipsec_out_sso_pffunc, ctx_ilen_valid, ctx_ilen,
1849 : 0 : rx_inj, nb_lf - 1);
1850 [ # # ]: 0 : if (rc) {
1851 : 0 : plt_err("Failed to alloc CPT LF resources, rc=%d", rc);
1852 : 0 : goto lf_detach;
1853 : : }
1854 : :
1855 : : /* Get msix offsets */
1856 : 0 : rc = cpt_get_msix_offset(dev, &rsp);
1857 [ # # ]: 0 : if (rc) {
1858 : 0 : plt_err("Failed to get CPT LF msix offset, rc=%d", rc);
1859 : 0 : goto lf_free;
1860 : : }
1861 : :
1862 : 0 : mbox_memcpy(nix->cpt_msixoff,
1863 [ # # ]: 0 : nix->is_nix1 ? rsp->cpt1_lf_msixoff : rsp->cptlf_msixoff,
1864 : : sizeof(nix->cpt_msixoff));
1865 : :
1866 : : /* Alloc required num of cpt lfs */
1867 : 0 : lf_base = plt_zmalloc(nb_lf * sizeof(struct roc_cpt_lf), 0);
1868 [ # # ]: 0 : if (!lf_base) {
1869 : 0 : plt_err("Failed to alloc cpt lf memory");
1870 : : rc = -ENOMEM;
1871 : 0 : goto lf_free;
1872 : : }
1873 : :
1874 : : /* Initialize CPT LF's */
1875 [ # # ]: 0 : for (i = 0; i < nb_lf; i++) {
1876 : 0 : lf = &lf_base[i];
1877 : :
1878 : 0 : lf->lf_id = i;
1879 : 0 : lf->nb_desc = roc_nix->outb_nb_desc;
1880 : 0 : lf->dev = &nix->dev;
1881 : 0 : lf->msixoff = nix->cpt_msixoff[i];
1882 [ # # ]: 0 : lf->pci_dev = nix->pci_dev;
1883 : :
1884 [ # # ]: 0 : if (roc_feature_nix_has_cpt_cq_support()) {
1885 [ # # # # ]: 0 : if (inl_dev && inl_dev->cpt_cq_ena) {
1886 : 0 : lf->dq_ack_ena = true;
1887 : 0 : lf->cpt_cq_ena = true;
1888 : 0 : lf->cq_entry_size = 0;
1889 : 0 : lf->cq_all = 0;
1890 : 0 : lf->cq_size = lf->nb_desc;
1891 : 0 : lf->cq_head = 1;
1892 : : }
1893 : : }
1894 : :
1895 : : /* Setup CPT LF instruction queue */
1896 : 0 : rc = cpt_lf_init(lf, lf->cpt_cq_ena);
1897 [ # # ]: 0 : if (rc) {
1898 : 0 : plt_err("Failed to initialize CPT LF, rc=%d", rc);
1899 : 0 : goto lf_fini;
1900 : : }
1901 : :
1902 : : /* Associate this CPT LF with NIX PFFUNC */
1903 : 0 : rc = cpt_lf_outb_cfg(dev, sso_pffunc, nix->dev.pf_func, i,
1904 : : true);
1905 [ # # ]: 0 : if (rc) {
1906 : 0 : plt_err("Failed to setup CPT LF->(NIX,SSO) link, rc=%d",
1907 : : rc);
1908 : 0 : goto lf_fini;
1909 : : }
1910 : :
1911 : : /* Enable IQ */
1912 : 0 : roc_cpt_iq_enable(lf);
1913 : : /* Enable CQ */
1914 [ # # ]: 0 : if (lf->cpt_cq_ena) {
1915 : 0 : rc = cpt_lf_register_irqs(lf, cpt_lf_misc_irq, nix_inl_cpt_done_irq);
1916 [ # # ]: 0 : if (rc)
1917 : 0 : goto lf_fini;
1918 : 0 : roc_cpt_cq_enable(lf);
1919 : : }
1920 : : }
1921 : :
1922 [ # # ]: 0 : if (!roc_nix->ipsec_out_max_sa)
1923 : 0 : goto skip_sa_alloc;
1924 : :
1925 : : sa_sz = ROC_NIX_INL_IPSEC_OUTB_SA_SZ;
1926 : :
1927 : : /* Alloc contiguous memory of outbound SA */
1928 : 0 : sa_base = plt_zmalloc(sa_sz * roc_nix->ipsec_out_max_sa,
1929 : : ROC_NIX_INL_SA_BASE_ALIGN);
1930 [ # # ]: 0 : if (!sa_base) {
1931 : 0 : plt_err("Outbound SA base alloc failed");
1932 : 0 : goto lf_fini;
1933 : : }
1934 : :
1935 [ # # ]: 0 : if (!roc_model_is_cn9k()) {
1936 [ # # ]: 0 : for (i = 0; i < roc_nix->ipsec_out_max_sa; i++) {
1937 [ # # ]: 0 : sa = ((uint8_t *)sa_base) + (i * sa_sz);
1938 [ # # ]: 0 : if (roc_model_is_cn10k())
1939 : 0 : roc_ot_ipsec_outb_sa_init(sa);
1940 : : else
1941 : 0 : roc_ow_ipsec_outb_sa_init(sa);
1942 : : }
1943 : : }
1944 : 0 : nix->outb_sa_base = sa_base;
1945 : 0 : nix->outb_sa_sz = sa_sz;
1946 : :
1947 : 0 : skip_sa_alloc:
1948 : :
1949 : 0 : nix->cpt_lf_base = lf_base;
1950 : 0 : nix->nb_cpt_lf = nb_lf;
1951 : 0 : nix->outb_err_sso_pffunc = sso_pffunc;
1952 : 0 : nix->inl_outb_ena = true;
1953 : 0 : nix->outb_se_ring_cnt =
1954 : 0 : roc_nix->ipsec_out_max_sa / ROC_IPSEC_ERR_RING_MAX_ENTRY + 1;
1955 : 0 : nix->outb_se_ring_base =
1956 : 0 : roc_nix->port_id * ROC_NIX_SOFT_EXP_PER_PORT_MAX_RINGS;
1957 : :
1958 : : /* Fetch engine capabilities */
1959 : 0 : nix_inl_eng_caps_get(nix);
1960 : :
1961 [ # # # # ]: 0 : if (inl_dev == NULL || !inl_dev->set_soft_exp_poll) {
1962 : 0 : nix->outb_se_ring_cnt = 0;
1963 : 0 : return 0;
1964 : : }
1965 : :
1966 : : /* Allocate memory to be used as a ring buffer to poll for
1967 : : * soft expiry event from ucode
1968 : : */
1969 : : ring_sz = (ROC_IPSEC_ERR_RING_MAX_ENTRY + 1) * sizeof(uint64_t);
1970 : 0 : ring_base = inl_dev->sa_soft_exp_ring;
1971 [ # # ]: 0 : for (i = 0; i < nix->outb_se_ring_cnt; i++) {
1972 : 0 : ring_base[nix->outb_se_ring_base + i] =
1973 : 0 : PLT_U64_CAST(plt_zmalloc(ring_sz, 0));
1974 [ # # ]: 0 : if (!ring_base[nix->outb_se_ring_base + i]) {
1975 : 0 : plt_err("Couldn't allocate memory for soft exp ring");
1976 [ # # ]: 0 : while (i--)
1977 : 0 : plt_free(PLT_PTR_CAST(
1978 : : ring_base[nix->outb_se_ring_base + i]));
1979 : : rc = -ENOMEM;
1980 : 0 : goto lf_fini;
1981 : : }
1982 : : }
1983 : :
1984 : : return 0;
1985 : :
1986 : 0 : lf_fini:
1987 [ # # ]: 0 : for (j = i - 1; j >= 0; j--) {
1988 : 0 : lf = &lf_base[j];
1989 : 0 : cpt_lf_fini(lf, lf->cpt_cq_ena);
1990 [ # # ]: 0 : if (lf->cpt_cq_ena)
1991 : 0 : cpt_lf_unregister_irqs(lf, cpt_lf_misc_irq, nix_inl_cpt_done_irq);
1992 : : }
1993 : 0 : plt_free(lf_base);
1994 : 0 : lf_free:
1995 : 0 : rc |= cpt_lfs_free(dev);
1996 : 0 : lf_detach:
1997 : 0 : rc |= cpt_lfs_detach(dev);
1998 : 0 : return rc;
1999 : : }
2000 : :
2001 : : int
2002 : 0 : roc_nix_inl_outb_fini(struct roc_nix *roc_nix)
2003 : : {
2004 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
2005 : 0 : struct roc_cpt_lf *lf_base = nix->cpt_lf_base;
2006 : 0 : struct idev_cfg *idev = idev_get_cfg();
2007 : 0 : struct dev *dev = &nix->dev;
2008 : : struct nix_inl_dev *inl_dev;
2009 : : struct roc_cpt_lf *lf;
2010 : : uint64_t *ring_base;
2011 : : int i, rc, ret = 0;
2012 : :
2013 [ # # ]: 0 : if (!nix->inl_outb_ena)
2014 : : return 0;
2015 : :
2016 : 0 : nix->inl_outb_ena = false;
2017 : :
2018 : : /* Cleanup CPT LF instruction queue */
2019 [ # # ]: 0 : for (i = 0; i < nix->nb_cpt_lf; i++) {
2020 : 0 : lf = &lf_base[i];
2021 : 0 : cpt_lf_fini(lf, lf->cpt_cq_ena);
2022 [ # # ]: 0 : if (lf->cpt_cq_ena)
2023 : 0 : cpt_lf_unregister_irqs(lf, cpt_lf_misc_irq, nix_inl_cpt_done_irq);
2024 : : }
2025 : : /* Free LF resources */
2026 : 0 : rc = cpt_lfs_free(dev);
2027 [ # # ]: 0 : if (rc)
2028 : 0 : plt_err("Failed to free CPT LF resources, rc=%d", rc);
2029 : : ret |= rc;
2030 : :
2031 : : /* Detach LF */
2032 : 0 : rc = cpt_lfs_detach(dev);
2033 [ # # ]: 0 : if (rc)
2034 : 0 : plt_err("Failed to detach CPT LF, rc=%d", rc);
2035 : :
2036 : : /* Free LF memory */
2037 : 0 : plt_free(lf_base);
2038 : 0 : nix->cpt_lf_base = NULL;
2039 : 0 : nix->nb_cpt_lf = 0;
2040 : :
2041 : : /* Free outbound SA base */
2042 : 0 : plt_free(nix->outb_sa_base);
2043 : 0 : nix->outb_sa_base = NULL;
2044 : :
2045 [ # # # # : 0 : if (idev && idev->nix_inl_dev && nix->outb_se_ring_cnt) {
# # ]
2046 : : inl_dev = idev->nix_inl_dev;
2047 : 0 : ring_base = inl_dev->sa_soft_exp_ring;
2048 : 0 : ring_base += nix->outb_se_ring_base;
2049 : :
2050 [ # # ]: 0 : for (i = 0; i < nix->outb_se_ring_cnt; i++) {
2051 [ # # ]: 0 : if (ring_base[i])
2052 : 0 : plt_free(PLT_PTR_CAST(ring_base[i]));
2053 : : }
2054 : : }
2055 : :
2056 : 0 : ret |= rc;
2057 : 0 : return ret;
2058 : : }
2059 : :
2060 : : bool
2061 : 0 : roc_nix_inl_dev_is_probed(void)
2062 : : {
2063 : 0 : struct idev_cfg *idev = idev_get_cfg();
2064 : :
2065 [ # # ]: 0 : if (idev == NULL)
2066 : : return 0;
2067 : :
2068 : 0 : return !!idev->nix_inl_dev;
2069 : : }
2070 : :
2071 : : bool
2072 : 0 : roc_nix_inl_dev_is_multi_channel(void)
2073 : : {
2074 : 0 : struct idev_cfg *idev = idev_get_cfg();
2075 : : struct nix_inl_dev *inl_dev;
2076 : :
2077 [ # # # # ]: 0 : if (idev == NULL || !idev->nix_inl_dev)
2078 : : return false;
2079 : :
2080 : : inl_dev = idev->nix_inl_dev;
2081 : 0 : return inl_dev->is_multi_channel;
2082 : : }
2083 : :
2084 : : bool
2085 : 0 : roc_nix_inl_inb_is_enabled(struct roc_nix *roc_nix)
2086 : : {
2087 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
2088 : :
2089 : 0 : return nix->inl_inb_ena;
2090 : : }
2091 : :
2092 : : bool
2093 : 0 : roc_nix_inl_outb_is_enabled(struct roc_nix *roc_nix)
2094 : : {
2095 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
2096 : :
2097 : 0 : return nix->inl_outb_ena;
2098 : : }
2099 : :
2100 : : int
2101 : 0 : roc_nix_inl_dev_rq_get(struct roc_nix_rq *rq, bool enable)
2102 : : {
2103 : 0 : struct nix *nix = roc_nix_to_nix_priv(rq->roc_nix);
2104 : 0 : struct idev_cfg *idev = idev_get_cfg();
2105 : 0 : int port_id = rq->roc_nix->port_id;
2106 : : struct nix_inl_dev *inl_dev;
2107 : : struct roc_nix_rq *inl_rq;
2108 : : uint16_t inl_rq_id;
2109 : : struct mbox *mbox;
2110 : : struct dev *dev;
2111 : : int rc;
2112 : :
2113 [ # # ]: 0 : if (idev == NULL)
2114 : : return 0;
2115 : :
2116 : : /* Update meta aura handle in RQ */
2117 [ # # ]: 0 : if (nix->need_meta_aura)
2118 : 0 : rq->meta_aura_handle = roc_npa_zero_aura_handle();
2119 : :
2120 : 0 : inl_dev = idev->nix_inl_dev;
2121 : : /* Nothing to do if no inline device */
2122 [ # # ]: 0 : if (!inl_dev)
2123 : : return 0;
2124 : :
2125 : : /* Check if this RQ is already holding reference */
2126 [ # # ]: 0 : if (rq->inl_dev_refs)
2127 : : return 0;
2128 : :
2129 [ # # ]: 0 : inl_rq_id = inl_dev->nb_rqs > 1 ? port_id : 0;
2130 : 0 : dev = &inl_dev->dev;
2131 : 0 : inl_rq = &inl_dev->rqs[inl_rq_id];
2132 : :
2133 : : /* Just take reference if already inited */
2134 [ # # ]: 0 : if (inl_rq->inl_dev_refs) {
2135 : 0 : inl_rq->inl_dev_refs++;
2136 : 0 : rq->inl_dev_refs = 1;
2137 : 0 : return 0;
2138 : : }
2139 : : memset(inl_rq, 0, sizeof(struct roc_nix_rq));
2140 : :
2141 : : /* Take RQ pool attributes from the first ethdev RQ */
2142 : 0 : inl_rq->qid = inl_rq_id;
2143 : 0 : inl_rq->aura_handle = rq->aura_handle;
2144 : 0 : inl_rq->first_skip = rq->first_skip;
2145 : 0 : inl_rq->later_skip = rq->later_skip;
2146 : 0 : inl_rq->lpb_size = rq->lpb_size;
2147 : 0 : inl_rq->spb_ena = rq->spb_ena;
2148 : 0 : inl_rq->spb_aura_handle = rq->spb_aura_handle;
2149 : 0 : inl_rq->spb_size = rq->spb_size;
2150 : 0 : inl_rq->pb_caching = rq->pb_caching;
2151 [ # # ]: 0 : inl_rq->wqe_caching = rq->wqe_caching;
2152 : :
2153 [ # # ]: 0 : if (roc_errata_nix_no_meta_aura()) {
2154 : : uint64_t aura_limit =
2155 : : roc_npa_aura_op_limit_get(inl_rq->aura_handle);
2156 : : uint64_t aura_shift = plt_log2_u32(aura_limit);
2157 : : uint64_t aura_drop, drop_pc;
2158 : :
2159 : 0 : inl_rq->lpb_drop_ena = true;
2160 : :
2161 : : if (aura_shift < 8)
2162 : : aura_shift = 0;
2163 : : else
2164 : : aura_shift = aura_shift - 8;
2165 : :
2166 : : /* Set first pass RQ to drop after part of buffers are in
2167 : : * use to avoid metabuf alloc failure. This is needed as long
2168 : : * as we cannot use different aura.
2169 : : */
2170 : : drop_pc = inl_dev->lpb_drop_pc;
2171 : : aura_drop = ((aura_limit * drop_pc) / 100) >> aura_shift;
2172 : 0 : roc_npa_aura_drop_set(inl_rq->aura_handle, aura_drop, true);
2173 : : }
2174 : :
2175 [ # # # # ]: 0 : if (roc_errata_nix_no_meta_aura() && inl_rq->spb_ena) {
2176 : : uint64_t aura_limit =
2177 : 0 : roc_npa_aura_op_limit_get(inl_rq->spb_aura_handle);
2178 : : uint64_t aura_shift = plt_log2_u32(aura_limit);
2179 : : uint64_t aura_drop, drop_pc;
2180 : :
2181 : 0 : inl_rq->spb_drop_ena = true;
2182 : :
2183 : : if (aura_shift < 8)
2184 : : aura_shift = 0;
2185 : : else
2186 : : aura_shift = aura_shift - 8;
2187 : :
2188 : : /* Set first pass RQ to drop after part of buffers are in
2189 : : * use to avoid metabuf alloc failure. This is needed as long
2190 : : * as we cannot use different aura.
2191 : : */
2192 : : drop_pc = inl_dev->spb_drop_pc;
2193 : : aura_drop = ((aura_limit * drop_pc) / 100) >> aura_shift;
2194 : 0 : roc_npa_aura_drop_set(inl_rq->spb_aura_handle, aura_drop, true);
2195 : : }
2196 : :
2197 : : /* Enable IPSec */
2198 : 0 : inl_rq->ipsech_ena = true;
2199 : :
2200 : 0 : inl_rq->flow_tag_width = 20;
2201 : : /* Special tag mask */
2202 : 0 : inl_rq->tag_mask = rq->tag_mask;
2203 : 0 : inl_rq->tt = SSO_TT_ORDERED;
2204 : 0 : inl_rq->hwgrp = 0;
2205 : 0 : inl_rq->wqe_skip = inl_dev->wqe_skip;
2206 : 0 : inl_rq->sso_ena = true;
2207 : :
2208 : : /* Prepare and send RQ init mbox */
2209 : 0 : mbox = mbox_get(dev->mbox);
2210 [ # # ]: 0 : if (roc_model_is_cn9k())
2211 : 0 : rc = nix_rq_cn9k_cfg(dev, inl_rq, inl_dev->qints, false, enable);
2212 [ # # ]: 0 : else if (roc_model_is_cn10k())
2213 : 0 : rc = nix_rq_cn10k_cfg(dev, inl_rq, inl_dev->qints, false, enable);
2214 : : else
2215 : 0 : rc = nix_rq_cfg(dev, inl_rq, inl_dev->qints, false, enable);
2216 [ # # ]: 0 : if (rc) {
2217 : 0 : plt_err("Failed to prepare aq_enq msg, rc=%d", rc);
2218 : : mbox_put(mbox);
2219 : 0 : return rc;
2220 : : }
2221 : :
2222 : 0 : rc = mbox_process(dev->mbox);
2223 [ # # ]: 0 : if (rc) {
2224 : 0 : plt_err("Failed to send aq_enq msg, rc=%d", rc);
2225 : : mbox_put(mbox);
2226 : 0 : return rc;
2227 : : }
2228 : : mbox_put(mbox);
2229 : :
2230 : : /* Check meta aura */
2231 [ # # # # ]: 0 : if (enable && nix->need_meta_aura) {
2232 : 0 : rc = roc_nix_inl_meta_aura_check(rq->roc_nix, rq);
2233 [ # # ]: 0 : if (rc)
2234 : : return rc;
2235 : : }
2236 : :
2237 : 0 : inl_rq->inl_dev_refs++;
2238 : 0 : rq->inl_dev_refs = 1;
2239 : 0 : return 0;
2240 : : }
2241 : :
2242 : : int
2243 : 0 : roc_nix_inl_dev_rq_put(struct roc_nix_rq *rq)
2244 : : {
2245 : 0 : struct idev_cfg *idev = idev_get_cfg();
2246 : 0 : int port_id = rq->roc_nix->port_id;
2247 : : struct nix_inl_dev *inl_dev;
2248 : : struct roc_nix_rq *inl_rq;
2249 : : uint16_t inl_rq_id;
2250 : : struct dev *dev;
2251 : : int rc;
2252 : :
2253 [ # # ]: 0 : if (idev == NULL)
2254 : : return 0;
2255 : :
2256 : 0 : rq->meta_aura_handle = 0;
2257 [ # # ]: 0 : if (!rq->inl_dev_refs)
2258 : : return 0;
2259 : :
2260 : 0 : inl_dev = idev->nix_inl_dev;
2261 : : /* Inline device should be there if we have ref */
2262 [ # # ]: 0 : if (!inl_dev) {
2263 : 0 : plt_err("Failed to find inline device with refs");
2264 : 0 : return -EFAULT;
2265 : : }
2266 : :
2267 : 0 : dev = &inl_dev->dev;
2268 [ # # ]: 0 : inl_rq_id = inl_dev->nb_rqs > 1 ? port_id : 0;
2269 : 0 : inl_rq = &inl_dev->rqs[inl_rq_id];
2270 : :
2271 : 0 : rq->inl_dev_refs = 0;
2272 : 0 : inl_rq->inl_dev_refs--;
2273 [ # # ]: 0 : if (inl_rq->inl_dev_refs)
2274 : : return 0;
2275 : :
2276 : : /* There are no more references, disable RQ */
2277 : 0 : rc = nix_rq_ena_dis(dev, inl_rq, false);
2278 [ # # ]: 0 : if (rc)
2279 : 0 : plt_err("Failed to disable inline device rq, rc=%d", rc);
2280 : :
2281 : 0 : roc_npa_aura_drop_set(inl_rq->aura_handle, 0, false);
2282 [ # # ]: 0 : if (inl_rq->spb_ena)
2283 : 0 : roc_npa_aura_drop_set(inl_rq->spb_aura_handle, 0, false);
2284 : :
2285 : : /* Flush NIX LF for CN10K */
2286 : 0 : nix_rq_vwqe_flush(rq, inl_dev->vwqe_interval);
2287 : :
2288 : 0 : return rc;
2289 : : }
2290 : :
2291 : : int
2292 : 0 : roc_nix_inl_rq_ena_dis(struct roc_nix *roc_nix, bool enable)
2293 : : {
2294 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
2295 : 0 : struct roc_nix_rq *inl_rq = roc_nix_inl_dev_rq(roc_nix);
2296 : 0 : struct idev_cfg *idev = idev_get_cfg();
2297 : : struct nix_inl_dev *inl_dev;
2298 : : int rc;
2299 : :
2300 [ # # ]: 0 : if (!idev)
2301 : : return -EFAULT;
2302 : :
2303 [ # # # # ]: 0 : if (roc_feature_nix_has_inl_rq_mask() && enable) {
2304 : 0 : rc = nix_inl_rq_mask_cfg(roc_nix, enable);
2305 [ # # ]: 0 : if (rc) {
2306 : 0 : plt_err("Failed to get rq mask rc=%d", rc);
2307 : 0 : return rc;
2308 : : }
2309 : : }
2310 : :
2311 [ # # ]: 0 : if (nix->inb_inl_dev) {
2312 [ # # # # ]: 0 : if (!inl_rq || !idev->nix_inl_dev)
2313 : : return -EFAULT;
2314 : :
2315 : : inl_dev = idev->nix_inl_dev;
2316 : :
2317 [ # # ]: 0 : if (!roc_model_is_cn10k()) {
2318 [ # # ]: 0 : if (inl_rq->spb_ena) {
2319 : : rc = -EINVAL;
2320 : 0 : plt_err("inline RQ enable is not supported rc=%d", rc);
2321 : 0 : return rc;
2322 : : }
2323 : : }
2324 : :
2325 : 0 : rc = nix_rq_ena_dis(&inl_dev->dev, inl_rq, enable);
2326 [ # # ]: 0 : if (rc)
2327 : : return rc;
2328 : :
2329 [ # # # # ]: 0 : if (enable && nix->need_meta_aura)
2330 : 0 : return roc_nix_inl_meta_aura_check(roc_nix, inl_rq);
2331 : : }
2332 : : return 0;
2333 : : }
2334 : :
2335 : : void
2336 : 0 : roc_nix_inb_mode_set(struct roc_nix *roc_nix, bool use_inl_dev)
2337 : : {
2338 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
2339 : :
2340 : : /* Info used by NPC flow rule add */
2341 : 0 : nix->inb_inl_dev = use_inl_dev;
2342 : 0 : }
2343 : :
2344 : : void
2345 : 0 : roc_nix_inl_inb_set(struct roc_nix *roc_nix, bool ena)
2346 : : {
2347 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
2348 : 0 : struct idev_cfg *idev = idev_get_cfg();
2349 : :
2350 [ # # ]: 0 : if (!idev)
2351 : : return;
2352 : : /* Need to set here for cases when inbound SA table is
2353 : : * managed outside RoC.
2354 : : */
2355 [ # # ]: 0 : nix->inl_inb_ena = ena;
2356 : :
2357 [ # # # # ]: 0 : if (roc_model_is_cn9k() || roc_errata_nix_no_meta_aura())
2358 : : return;
2359 : :
2360 [ # # ]: 0 : if (ena) {
2361 : 0 : nix->need_meta_aura = true;
2362 [ # # # # ]: 0 : if (!roc_nix->local_meta_aura_ena || roc_nix->custom_meta_aura_ena)
2363 : 0 : idev->inl_cfg.refs++;
2364 [ # # ]: 0 : } else if (nix->need_meta_aura) {
2365 : 0 : nix->need_meta_aura = false;
2366 [ # # # # ]: 0 : if (!roc_nix->local_meta_aura_ena || roc_nix->custom_meta_aura_ena)
2367 : 0 : idev->inl_cfg.refs--;
2368 : :
2369 [ # # ]: 0 : if (roc_nix->custom_meta_aura_ena)
2370 : 0 : nix_inl_custom_meta_aura_destroy(roc_nix);
2371 : :
2372 [ # # ]: 0 : if (!idev->inl_cfg.refs)
2373 : 0 : nix_inl_meta_aura_destroy(roc_nix);
2374 : : }
2375 : : }
2376 : :
2377 : : int
2378 : 0 : roc_nix_inl_outb_soft_exp_poll_switch(struct roc_nix *roc_nix, bool poll)
2379 : : {
2380 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
2381 : 0 : struct idev_cfg *idev = idev_get_cfg();
2382 : : struct nix_inl_dev *inl_dev;
2383 : : uint16_t ring_idx, i;
2384 : :
2385 [ # # # # ]: 0 : if (!idev || !idev->nix_inl_dev)
2386 : : return 0;
2387 : :
2388 : : inl_dev = idev->nix_inl_dev;
2389 : :
2390 [ # # ]: 0 : for (i = 0; i < nix->outb_se_ring_cnt; i++) {
2391 : 0 : ring_idx = nix->outb_se_ring_base + i;
2392 : :
2393 [ # # ]: 0 : if (poll)
2394 : 0 : plt_bitmap_set(inl_dev->soft_exp_ring_bmap, ring_idx);
2395 : : else
2396 : 0 : plt_bitmap_clear(inl_dev->soft_exp_ring_bmap, ring_idx);
2397 : : }
2398 : :
2399 [ # # ]: 0 : if (poll)
2400 : 0 : soft_exp_consumer_cnt++;
2401 : : else
2402 : 0 : soft_exp_consumer_cnt--;
2403 : :
2404 : : return 0;
2405 : : }
2406 : :
2407 : : bool
2408 : 0 : roc_nix_inb_is_with_inl_dev(struct roc_nix *roc_nix)
2409 : : {
2410 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
2411 : :
2412 : 0 : return nix->inb_inl_dev;
2413 : : }
2414 : :
2415 : : struct roc_nix_rq *
2416 : 0 : roc_nix_inl_dev_rq(struct roc_nix *roc_nix)
2417 : : {
2418 : 0 : struct idev_cfg *idev = idev_get_cfg();
2419 : 0 : int port_id = roc_nix->port_id;
2420 : : struct nix_inl_dev *inl_dev;
2421 : : struct roc_nix_rq *inl_rq;
2422 : : uint16_t inl_rq_id;
2423 : :
2424 [ # # ]: 0 : if (idev != NULL) {
2425 : 0 : inl_dev = idev->nix_inl_dev;
2426 [ # # ]: 0 : if (inl_dev != NULL) {
2427 [ # # ]: 0 : inl_rq_id = inl_dev->nb_rqs > 1 ? port_id : 0;
2428 : 0 : inl_rq = &inl_dev->rqs[inl_rq_id];
2429 [ # # ]: 0 : if (inl_rq->inl_dev_refs)
2430 : 0 : return inl_rq;
2431 : : }
2432 : : }
2433 : :
2434 : : return NULL;
2435 : : }
2436 : :
2437 : : uint16_t __roc_api
2438 : 0 : roc_nix_inl_outb_sso_pffunc_get(struct roc_nix *roc_nix)
2439 : : {
2440 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
2441 : :
2442 : 0 : return nix->outb_err_sso_pffunc;
2443 : : }
2444 : :
2445 : : int
2446 : 0 : roc_nix_inl_cb_register(roc_nix_inl_sso_work_cb_t cb, void *args)
2447 : : {
2448 : 0 : struct idev_cfg *idev = idev_get_cfg();
2449 : : struct nix_inl_dev *inl_dev;
2450 : :
2451 [ # # ]: 0 : if (idev == NULL)
2452 : : return -EIO;
2453 : :
2454 : 0 : inl_dev = idev->nix_inl_dev;
2455 [ # # ]: 0 : if (!inl_dev)
2456 : : return -EIO;
2457 : :
2458 : : /* Be silent if registration called with same cb and args */
2459 [ # # # # ]: 0 : if (inl_dev->work_cb == cb && inl_dev->cb_args == args)
2460 : : return 0;
2461 : :
2462 : : /* Don't allow registration again if registered with different cb */
2463 [ # # ]: 0 : if (inl_dev->work_cb)
2464 : : return -EBUSY;
2465 : :
2466 : 0 : inl_dev->work_cb = cb;
2467 : 0 : inl_dev->cb_args = args;
2468 : 0 : return 0;
2469 : : }
2470 : :
2471 : : int
2472 : 0 : roc_nix_inl_cb_unregister(roc_nix_inl_sso_work_cb_t cb, void *args)
2473 : : {
2474 : 0 : struct idev_cfg *idev = idev_get_cfg();
2475 : : struct nix_inl_dev *inl_dev;
2476 : :
2477 [ # # ]: 0 : if (idev == NULL)
2478 : : return -ENOENT;
2479 : :
2480 : 0 : inl_dev = idev->nix_inl_dev;
2481 [ # # ]: 0 : if (!inl_dev)
2482 : : return -ENOENT;
2483 : :
2484 [ # # # # ]: 0 : if (inl_dev->work_cb != cb || inl_dev->cb_args != args)
2485 : : return -EINVAL;
2486 : :
2487 : 0 : inl_dev->work_cb = NULL;
2488 : 0 : inl_dev->cb_args = NULL;
2489 : 0 : return 0;
2490 : : }
2491 : :
2492 : : int
2493 : 0 : roc_nix_inl_inb_tag_update(struct roc_nix *roc_nix, uint32_t tag_const,
2494 : : uint8_t tt)
2495 : : {
2496 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
2497 : : struct roc_nix_ipsec_cfg cfg;
2498 : :
2499 : : /* Be silent if inline inbound not enabled */
2500 [ # # ]: 0 : if (!nix->inl_inb_ena)
2501 : : return 0;
2502 : :
2503 : : memset(&cfg, 0, sizeof(cfg));
2504 : 0 : cfg.sa_size = nix->inb_sa_sz[nix->ipsec_prof_id];
2505 : 0 : cfg.iova = (uintptr_t)nix->inb_sa_base[nix->ipsec_prof_id];
2506 : 0 : cfg.max_sa = nix->inb_spi_mask + 1;
2507 : 0 : cfg.tt = tt;
2508 : 0 : cfg.tag_const = tag_const;
2509 [ # # ]: 0 : if (roc_nix->res_addr_offset)
2510 : 0 : cfg.res_addr_offset = roc_nix->res_addr_offset;
2511 : :
2512 : 0 : return roc_nix_lf_inl_ipsec_cfg(roc_nix, &cfg, true);
2513 : : }
2514 : :
2515 : : int
2516 : 0 : roc_nix_inl_sa_sync(struct roc_nix *roc_nix, void *sa, bool inb,
2517 : : enum roc_nix_inl_sa_sync_op op)
2518 : : {
2519 : 0 : struct idev_cfg *idev = idev_get_cfg();
2520 : : struct nix_inl_dev *inl_dev = NULL;
2521 : : struct roc_cpt_lf *outb_lf = NULL;
2522 : : union cpt_lf_ctx_reload reload;
2523 : : union cpt_lf_ctx_flush flush;
2524 : : union cpt_lf_ctx_err err;
2525 : : union cpt_lf_ctx_inval inval;
2526 : : bool get_inl_lf = true;
2527 : : uintptr_t rbase;
2528 : : struct nix *nix;
2529 : :
2530 : : /* Nothing much to do on cn9k */
2531 [ # # ]: 0 : if (roc_model_is_cn9k()) {
2532 : : plt_atomic_thread_fence(__ATOMIC_ACQ_REL);
2533 : 0 : return 0;
2534 : : }
2535 : :
2536 [ # # ]: 0 : if (idev)
2537 : 0 : inl_dev = idev->nix_inl_dev;
2538 : :
2539 [ # # # # ]: 0 : if ((!inl_dev && roc_nix == NULL) || sa == NULL)
2540 : : return -EINVAL;
2541 : :
2542 [ # # ]: 0 : if (roc_nix) {
2543 : : nix = roc_nix_to_nix_priv(roc_nix);
2544 : 0 : outb_lf = nix->cpt_lf_base;
2545 [ # # # # ]: 0 : if (inb && !nix->inb_inl_dev)
2546 : : get_inl_lf = false;
2547 : : }
2548 : :
2549 [ # # ]: 0 : if (inb && get_inl_lf) {
2550 : : outb_lf = NULL;
2551 [ # # # # ]: 0 : if (inl_dev && inl_dev->attach_cptlf)
2552 : 0 : outb_lf = &inl_dev->cpt_lf[0];
2553 : : }
2554 : :
2555 [ # # ]: 0 : if (outb_lf) {
2556 : 0 : rbase = outb_lf->rbase;
2557 : :
2558 : 0 : flush.u = 0;
2559 : 0 : reload.u = 0;
2560 : 0 : inval.u = 0;
2561 [ # # # # ]: 0 : switch (op) {
2562 : : case ROC_NIX_INL_SA_OP_FLUSH_INVAL:
2563 [ # # ]: 0 : if (!roc_model_is_cn10k()) {
2564 : 0 : inval.s.cptr = ((uintptr_t)sa) >> 7;
2565 : 0 : plt_write64(inval.u, rbase + CPT_LF_CTX_INVAL);
2566 : : break;
2567 : : }
2568 : :
2569 : 0 : flush.s.inval = 1;
2570 : : /* fall through */
2571 : 0 : case ROC_NIX_INL_SA_OP_FLUSH:
2572 : 0 : flush.s.cptr = ((uintptr_t)sa) >> 7;
2573 [ # # ]: 0 : plt_write64(flush.u, rbase + CPT_LF_CTX_FLUSH);
2574 : : plt_atomic_thread_fence(__ATOMIC_ACQ_REL);
2575 : : /* Read a CSR to ensure that the FLUSH operation is complete */
2576 [ # # ]: 0 : err.u = plt_read64(rbase + CPT_LF_CTX_ERR);
2577 : :
2578 [ # # ]: 0 : if (err.s.flush_st_flt) {
2579 : 0 : plt_warn("CTX flush could not complete");
2580 : 0 : return -EIO;
2581 : : }
2582 : : break;
2583 : 0 : case ROC_NIX_INL_SA_OP_RELOAD:
2584 : 0 : reload.s.cptr = ((uintptr_t)sa) >> 7;
2585 : 0 : plt_write64(reload.u, rbase + CPT_LF_CTX_RELOAD);
2586 : : break;
2587 : : default:
2588 : : return -EINVAL;
2589 : : }
2590 : 0 : return 0;
2591 : : }
2592 : 0 : plt_err("Could not get CPT LF for SA sync");
2593 : 0 : return -ENOTSUP;
2594 : : }
2595 : :
2596 : : int
2597 : 0 : roc_nix_inl_ctx_write(struct roc_nix *roc_nix, void *sa_dptr, void *sa_cptr,
2598 : : bool inb, uint16_t sa_len)
2599 : : {
2600 : 0 : struct idev_cfg *idev = idev_get_cfg();
2601 : : struct nix_inl_dev *inl_dev = NULL;
2602 : : struct roc_cpt_lf *outb_lf = NULL;
2603 : : union cpt_lf_ctx_flush flush;
2604 : : union cpt_lf_ctx_inval inval;
2605 : : union cpt_lf_ctx_err err;
2606 : : bool get_inl_lf = true;
2607 : : uintptr_t rbase;
2608 : : struct nix *nix;
2609 : : uint64_t *sa;
2610 : : int rc;
2611 : :
2612 : : /* Nothing much to do on cn9k */
2613 [ # # ]: 0 : if (roc_model_is_cn9k()) {
2614 : : return 0;
2615 : : }
2616 [ # # ]: 0 : if (idev)
2617 : 0 : inl_dev = idev->nix_inl_dev;
2618 : :
2619 [ # # # # ]: 0 : if ((!inl_dev && roc_nix == NULL) || sa_dptr == NULL || sa_cptr == NULL)
2620 : : return -EINVAL;
2621 : :
2622 [ # # ]: 0 : if (roc_nix) {
2623 [ # # # # : 0 : if (inb && roc_nix->custom_inb_sa && sa_len > ROC_NIX_INL_INB_CUSTOM_SA_SZ) {
# # ]
2624 : 0 : plt_nix_dbg("SA length: %u is more than allocated length: %u", sa_len,
2625 : : ROC_NIX_INL_INB_CUSTOM_SA_SZ);
2626 : 0 : return -EINVAL;
2627 : : }
2628 : : nix = roc_nix_to_nix_priv(roc_nix);
2629 : 0 : outb_lf = nix->cpt_lf_base;
2630 : :
2631 [ # # # # ]: 0 : if (inb && !nix->inb_inl_dev)
2632 : : get_inl_lf = false;
2633 : : }
2634 : :
2635 [ # # ]: 0 : if (inb && get_inl_lf) {
2636 : : outb_lf = NULL;
2637 [ # # # # ]: 0 : if (inl_dev && inl_dev->attach_cptlf)
2638 : 0 : outb_lf = &inl_dev->cpt_lf[0];
2639 : : }
2640 : :
2641 [ # # ]: 0 : if (outb_lf == NULL)
2642 : 0 : goto exit;
2643 : :
2644 [ # # # # : 0 : if (roc_model_is_cn10k() || (roc_nix && roc_nix->use_write_sa)) {
# # ]
2645 : 0 : rbase = outb_lf->rbase;
2646 : 0 : flush.u = 0;
2647 : :
2648 : 0 : rc = roc_cpt_ctx_write(outb_lf, sa_dptr, sa_cptr, sa_len);
2649 [ # # ]: 0 : if (rc)
2650 : : return rc;
2651 : : /* Trigger CTX flush to write dirty data back to DRAM */
2652 : 0 : flush.s.cptr = ((uintptr_t)sa_cptr) >> 7;
2653 [ # # ]: 0 : plt_write64(flush.u, rbase + CPT_LF_CTX_FLUSH);
2654 : :
2655 : : plt_atomic_thread_fence(__ATOMIC_ACQ_REL);
2656 : :
2657 : : /* Read a CSR to ensure that the FLUSH operation is complete */
2658 [ # # ]: 0 : err.u = plt_read64(rbase + CPT_LF_CTX_ERR);
2659 : :
2660 [ # # ]: 0 : if (err.s.flush_st_flt)
2661 : 0 : plt_warn("CTX flush could not complete");
2662 : 0 : return 0;
2663 : : } else {
2664 : : sa = sa_dptr;
2665 : :
2666 : : /* Clear bit 58 aop_valid */
2667 : 0 : sa[0] &= ~(1ULL << 58);
2668 : 0 : memcpy(sa_cptr, sa_dptr, sa_len);
2669 : 0 : plt_io_wmb();
2670 : :
2671 : : /* Trigger CTX invalidate */
2672 : 0 : rbase = outb_lf->rbase;
2673 : 0 : inval.u = 0;
2674 : 0 : inval.s.cptr = ((uintptr_t)sa_cptr) >> 7;
2675 : 0 : plt_write64(inval.u, rbase + CPT_LF_CTX_INVAL);
2676 : :
2677 : : /* Set bit 58 aop_valid */
2678 : : sa = sa_cptr;
2679 : 0 : sa[0] |= (1ULL << 58);
2680 : 0 : plt_io_wmb();
2681 : :
2682 : 0 : return 0;
2683 : : }
2684 : :
2685 : : exit:
2686 : 0 : plt_nix_dbg("Could not get CPT LF for CTX write");
2687 : 0 : return -ENOTSUP;
2688 : : }
2689 : :
2690 : : static inline int
2691 : 0 : nix_inl_dev_cpt_lf_stats_get(struct roc_nix *roc_nix, struct roc_nix_cpt_lf_stats *stats,
2692 : : uint16_t idx)
2693 : : {
2694 : 0 : struct idev_cfg *idev = idev_get_cfg();
2695 : : struct nix_inl_dev *inl_dev = NULL;
2696 : : struct roc_cpt_lf *lf = NULL;
2697 : :
2698 : : PLT_SET_USED(roc_nix);
2699 [ # # ]: 0 : if (idev)
2700 : 0 : inl_dev = idev->nix_inl_dev;
2701 : :
2702 [ # # # # ]: 0 : if (inl_dev && inl_dev->attach_cptlf) {
2703 [ # # ]: 0 : if (idx >= inl_dev->nb_cptlf) {
2704 : 0 : plt_err("Invalid idx: %u total lfs: %d", idx, inl_dev->nb_cptlf);
2705 : 0 : return -EINVAL;
2706 : : }
2707 : 0 : lf = &inl_dev->cpt_lf[idx];
2708 : : } else {
2709 : 0 : plt_err("No CPT LF(s) are found for Inline Device");
2710 : 0 : return -EINVAL;
2711 : : }
2712 : 0 : stats->enc_pkts = plt_read64(lf->rbase + CPT_LF_CTX_ENC_PKT_CNT);
2713 : 0 : stats->enc_bytes = plt_read64(lf->rbase + CPT_LF_CTX_ENC_BYTE_CNT);
2714 : 0 : stats->dec_pkts = plt_read64(lf->rbase + CPT_LF_CTX_DEC_PKT_CNT);
2715 : 0 : stats->dec_bytes = plt_read64(lf->rbase + CPT_LF_CTX_DEC_BYTE_CNT);
2716 : :
2717 : 0 : return 0;
2718 : : }
2719 : :
2720 : : static inline int
2721 : 0 : nix_eth_dev_cpt_lf_stats_get(struct roc_nix *roc_nix, struct roc_nix_cpt_lf_stats *stats,
2722 : : uint16_t idx)
2723 : : {
2724 : : struct roc_cpt_lf *lf;
2725 : : struct nix *nix;
2726 : :
2727 [ # # ]: 0 : if (!roc_nix)
2728 : : return -EINVAL;
2729 : : nix = roc_nix_to_nix_priv(roc_nix);
2730 [ # # ]: 0 : if (idx >= nix->nb_cpt_lf) {
2731 : 0 : plt_err("Invalid idx: %u total lfs: %d", idx, nix->nb_cpt_lf);
2732 : 0 : return -EINVAL;
2733 : : }
2734 : 0 : lf = &nix->cpt_lf_base[idx];
2735 : 0 : stats->enc_pkts = plt_read64(lf->rbase + CPT_LF_CTX_ENC_PKT_CNT);
2736 : 0 : stats->enc_bytes = plt_read64(lf->rbase + CPT_LF_CTX_ENC_BYTE_CNT);
2737 : 0 : stats->dec_pkts = plt_read64(lf->rbase + CPT_LF_CTX_DEC_PKT_CNT);
2738 : 0 : stats->dec_bytes = plt_read64(lf->rbase + CPT_LF_CTX_DEC_BYTE_CNT);
2739 : :
2740 : 0 : return 0;
2741 : : }
2742 : :
2743 : : int
2744 : 0 : roc_nix_inl_cpt_lf_stats_get(struct roc_nix *roc_nix, enum roc_nix_cpt_lf_stats_type type,
2745 : : struct roc_nix_cpt_lf_stats *stats, uint16_t idx)
2746 : : {
2747 [ # # # ]: 0 : switch (type) {
2748 : 0 : case ROC_NIX_CPT_LF_STATS_INL_DEV:
2749 : 0 : return nix_inl_dev_cpt_lf_stats_get(roc_nix, stats, idx);
2750 : 0 : case ROC_NIX_CPT_LF_STATS_ETHDEV:
2751 : 0 : return nix_eth_dev_cpt_lf_stats_get(roc_nix, stats, idx);
2752 : : default:
2753 : : return -EINVAL;
2754 : : }
2755 : : }
2756 : :
2757 : : static int
2758 : 0 : nix_inl_ts_pkind_set(struct roc_nix *roc_nix, bool ts_ena, bool inb_inl_dev, uint8_t profile_id)
2759 : : {
2760 : 0 : struct idev_cfg *idev = idev_get_cfg();
2761 : : struct nix_inl_dev *inl_dev = NULL;
2762 : : void *sa, *sa_base = NULL;
2763 : : struct nix *nix = NULL;
2764 : : uint32_t rq_refs = 0;
2765 : : uint16_t max_sa = 0;
2766 : : uint8_t pkind = 0;
2767 : : size_t inb_sa_sz;
2768 : : int i;
2769 : :
2770 [ # # ]: 0 : if (roc_model_is_cn9k())
2771 : : return 0;
2772 : :
2773 [ # # # # ]: 0 : if (!inb_inl_dev && (roc_nix == NULL) && profile_id >= ROC_NIX_INL_PROFILE_CNT)
2774 : : return -EINVAL;
2775 : :
2776 [ # # ]: 0 : if (inb_inl_dev) {
2777 [ # # # # ]: 0 : if ((idev == NULL) || (idev->nix_inl_dev == NULL))
2778 : : return 0;
2779 : : inl_dev = idev->nix_inl_dev;
2780 : : } else {
2781 : : nix = roc_nix_to_nix_priv(roc_nix);
2782 [ # # ]: 0 : if (!nix->inl_inb_ena)
2783 : : return 0;
2784 : :
2785 : 0 : sa_base = nix->inb_sa_base[profile_id];
2786 [ # # ]: 0 : if (sa_base == NULL)
2787 : : return 0;
2788 : 0 : inb_sa_sz = nix->inb_sa_sz[profile_id];
2789 : 0 : max_sa = nix->inb_sa_max[profile_id];
2790 : : }
2791 : :
2792 [ # # ]: 0 : if (inl_dev) {
2793 [ # # ]: 0 : for (i = 0; i < inl_dev->nb_rqs; i++)
2794 : 0 : rq_refs += inl_dev->rqs[i].inl_dev_refs;
2795 : :
2796 [ # # ]: 0 : if (rq_refs == 0) {
2797 : 0 : sa_base = inl_dev->inb_sa_base[profile_id];
2798 [ # # ]: 0 : if (sa_base == NULL)
2799 : : return 0;
2800 : 0 : inl_dev->ts_ena = ts_ena;
2801 : 0 : max_sa = inl_dev->inb_sa_max[profile_id];
2802 : 0 : inb_sa_sz = inl_dev->inb_sa_sz[profile_id];
2803 [ # # ]: 0 : } else if (inl_dev->ts_ena != ts_ena) {
2804 [ # # ]: 0 : if (inl_dev->ts_ena)
2805 : 0 : plt_err("Inline device is already configured with TS enable");
2806 : : else
2807 : 0 : plt_err("Inline device is already configured with TS disable");
2808 : 0 : return -ENOTSUP;
2809 : : } else {
2810 : : return 0;
2811 : : }
2812 : : }
2813 : :
2814 [ # # ]: 0 : pkind = ts_ena ? ROC_IE_OT_CPT_TS_PKIND : ROC_IE_OT_CPT_PKIND;
2815 : :
2816 : : sa = (uint8_t *)sa_base;
2817 [ # # ]: 0 : if (pkind == ((struct roc_ot_ipsec_inb_sa *)sa)->w0.s.pkind)
2818 : : return 0;
2819 : :
2820 [ # # ]: 0 : for (i = 0; i < max_sa; i++) {
2821 : 0 : sa = ((uint8_t *)sa_base) + (i * inb_sa_sz);
2822 : 0 : ((struct roc_ot_ipsec_inb_sa *)sa)->w0.s.pkind = pkind;
2823 : : }
2824 : : return 0;
2825 : : }
2826 : :
2827 : : int
2828 : 0 : roc_nix_inl_ts_pkind_set(struct roc_nix *roc_nix, bool ts_ena, bool inb_inl_dev, uint8_t profile_id)
2829 : : {
2830 : : int cnt = 0;
2831 : :
2832 [ # # ]: 0 : if (profile_id < ROC_NIX_INL_PROFILE_CNT) {
2833 : 0 : return nix_inl_ts_pkind_set(roc_nix, ts_ena, inb_inl_dev, profile_id);
2834 [ # # ]: 0 : } else if (profile_id == 0xFF) {
2835 : : /* Configure for all valid profiles */
2836 [ # # ]: 0 : for (cnt = 0; cnt < ROC_NIX_INL_PROFILE_CNT; cnt++)
2837 [ # # ]: 0 : if (nix_inl_ts_pkind_set(roc_nix, ts_ena, inb_inl_dev, cnt))
2838 : : return -EINVAL;
2839 : : return 0;
2840 : : }
2841 : :
2842 : 0 : plt_err("Invalid NIX inline profile_id: %u", profile_id);
2843 : 0 : return -EINVAL;
2844 : : }
2845 : :
2846 : : void
2847 : 0 : roc_nix_inl_dev_lock(void)
2848 : : {
2849 : 0 : struct idev_cfg *idev = idev_get_cfg();
2850 : :
2851 [ # # ]: 0 : if (idev != NULL)
2852 : 0 : plt_spinlock_lock(&idev->nix_inl_dev_lock);
2853 : 0 : }
2854 : :
2855 : : void
2856 : 0 : roc_nix_inl_dev_unlock(void)
2857 : : {
2858 : 0 : struct idev_cfg *idev = idev_get_cfg();
2859 : :
2860 [ # # ]: 0 : if (idev != NULL)
2861 : 0 : plt_spinlock_unlock(&idev->nix_inl_dev_lock);
2862 : 0 : }
2863 : :
2864 : : void
2865 : 0 : roc_nix_inl_meta_pool_cb_register(roc_nix_inl_meta_pool_cb_t cb)
2866 : : {
2867 : 0 : meta_pool_cb = cb;
2868 : 0 : }
2869 : :
2870 : : uint64_t
2871 : 0 : roc_nix_inl_eng_caps_get(struct roc_nix *roc_nix)
2872 : : {
2873 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
2874 : :
2875 : 0 : return nix->cpt_eng_caps;
2876 : : }
2877 : :
2878 : : void
2879 : 0 : roc_nix_inl_custom_meta_pool_cb_register(roc_nix_inl_custom_meta_pool_cb_t cb)
2880 : : {
2881 : 0 : custom_meta_pool_cb = cb;
2882 : 0 : }
2883 : :
2884 : : uint8_t
2885 : 0 : roc_nix_inl_is_cq_ena(struct roc_nix *roc_nix)
2886 : : {
2887 : 0 : struct idev_cfg *idev = idev_get_cfg();
2888 : : struct nix_inl_dev *inl_dev;
2889 : :
2890 : : PLT_SET_USED(roc_nix);
2891 [ # # ]: 0 : if (idev != NULL) {
2892 : 0 : inl_dev = idev->nix_inl_dev;
2893 [ # # ]: 0 : if (inl_dev)
2894 : 0 : return inl_dev->cpt_cq_ena;
2895 : : else
2896 : : return 0;
2897 : : } else {
2898 : : return 0;
2899 : : }
2900 : : }
|