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_nix_flow_vec.h"
7 : : #include "roc_priv.h"
8 : :
9 : : bool
10 : 0 : roc_nix_is_lbk(struct roc_nix *roc_nix)
11 : : {
12 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
13 : :
14 : 0 : return nix->lbk_link;
15 : : }
16 : :
17 : : bool
18 : 0 : roc_nix_is_esw(struct roc_nix *roc_nix)
19 : : {
20 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
21 : :
22 : 0 : return nix->esw_link;
23 : : }
24 : :
25 : : int
26 : 0 : roc_nix_get_base_chan(struct roc_nix *roc_nix)
27 : : {
28 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
29 : :
30 : 0 : return nix->rx_chan_base;
31 : : }
32 : :
33 : : uint8_t
34 : 0 : roc_nix_get_rx_chan_cnt(struct roc_nix *roc_nix)
35 : : {
36 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
37 : :
38 : 0 : return nix->rx_chan_cnt;
39 : : }
40 : :
41 : : uint16_t
42 : 0 : roc_nix_get_vwqe_interval(struct roc_nix *roc_nix)
43 : : {
44 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
45 : :
46 : 0 : return nix->vwqe_interval;
47 : : }
48 : :
49 : : bool
50 : 0 : roc_nix_is_sdp(struct roc_nix *roc_nix)
51 : : {
52 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
53 : :
54 : 0 : return nix->sdp_link;
55 : : }
56 : :
57 : : bool
58 : 0 : roc_nix_is_pf(struct roc_nix *roc_nix)
59 : : {
60 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
61 : :
62 : 0 : return !dev_is_vf(&nix->dev);
63 : : }
64 : :
65 : : int
66 : 0 : roc_nix_get_pf(struct roc_nix *roc_nix)
67 : : {
68 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
69 : : struct dev *dev = &nix->dev;
70 : :
71 [ # # ]: 0 : return dev_get_pf(dev->pf_func);
72 : : }
73 : :
74 : : int
75 : 0 : roc_nix_get_vf(struct roc_nix *roc_nix)
76 : : {
77 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
78 : : struct dev *dev = &nix->dev;
79 : :
80 [ # # ]: 0 : return dev_get_vf(dev->pf_func);
81 : : }
82 : :
83 : : bool
84 : 0 : roc_nix_is_vf_or_sdp(struct roc_nix *roc_nix)
85 : : {
86 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
87 : :
88 [ # # # # ]: 0 : return (dev_is_vf(&nix->dev) != 0) || roc_nix_is_sdp(roc_nix);
89 : : }
90 : :
91 : : uint16_t
92 : 3 : roc_nix_get_pf_func(struct roc_nix *roc_nix)
93 : : {
94 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
95 : : struct dev *dev = &nix->dev;
96 : :
97 : 3 : return dev->pf_func;
98 : : }
99 : :
100 : : int
101 : 0 : roc_nix_lf_inl_ipsec_cfg(struct roc_nix *roc_nix, struct roc_nix_ipsec_cfg *cfg,
102 : : bool enb)
103 : : {
104 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
105 : : struct nix_inline_ipsec_lf_cfg *lf_cfg;
106 : 0 : struct mbox *mbox = mbox_get((&nix->dev)->mbox);
107 : : int rc;
108 : :
109 : 0 : lf_cfg = mbox_alloc_msg_nix_inline_ipsec_lf_cfg(mbox);
110 [ # # ]: 0 : if (lf_cfg == NULL) {
111 : : rc = -ENOSPC;
112 : 0 : goto exit;
113 : : }
114 : :
115 [ # # ]: 0 : if (enb) {
116 : 0 : lf_cfg->enable = 1;
117 : 0 : lf_cfg->sa_base_addr = cfg->iova;
118 [ # # ]: 0 : lf_cfg->ipsec_cfg1.sa_idx_w = plt_log2_u32(cfg->max_sa);
119 : 0 : lf_cfg->ipsec_cfg0.lenm1_max = roc_nix_max_pkt_len(roc_nix) - 1;
120 : 0 : lf_cfg->ipsec_cfg1.sa_idx_max = cfg->max_sa - 1;
121 [ # # ]: 0 : lf_cfg->ipsec_cfg0.sa_pow2_size = plt_log2_u32(cfg->sa_size);
122 : 0 : lf_cfg->ipsec_cfg0.tag_const = cfg->tag_const;
123 : 0 : lf_cfg->ipsec_cfg0.tt = cfg->tt;
124 [ # # ]: 0 : if (cfg->res_addr_offset) {
125 : 0 : lf_cfg->ipsec_cfg0_ext.res_addr_offset_valid = 1;
126 : 0 : lf_cfg->ipsec_cfg0_ext.res_addr_offset =
127 : 0 : (cfg->res_addr_offset & 0x80) | abs(cfg->res_addr_offset);
128 : : }
129 : : } else {
130 : 0 : lf_cfg->enable = 0;
131 : : }
132 : :
133 : 0 : rc = mbox_process(mbox);
134 : 0 : exit:
135 : : mbox_put(mbox);
136 : 0 : return rc;
137 : : }
138 : :
139 : : int
140 : 0 : roc_nix_cpt_ctx_cache_sync(struct roc_nix *roc_nix)
141 : : {
142 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
143 : 0 : struct mbox *mbox = mbox_get((&nix->dev)->mbox);
144 : : struct msg_req *req;
145 : : int rc;
146 : :
147 : 0 : req = mbox_alloc_msg_cpt_ctx_cache_sync(mbox);
148 [ # # ]: 0 : if (req == NULL) {
149 : : rc = -ENOSPC;
150 : 0 : goto exit;
151 : : }
152 : :
153 : 0 : rc = mbox_process(mbox);
154 : 0 : exit:
155 : : mbox_put(mbox);
156 : 0 : return rc;
157 : : }
158 : :
159 : : int
160 : 0 : roc_nix_max_pkt_len(struct roc_nix *roc_nix)
161 : : {
162 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
163 : :
164 [ # # ]: 0 : if (roc_nix_is_sdp(roc_nix)) {
165 [ # # ]: 0 : if (roc_errata_nix_sdp_send_has_mtu_size_16k())
166 : : return NIX_SDP_16K_HW_FRS;
167 : 0 : return NIX_SDP_MAX_HW_FRS;
168 : : }
169 : :
170 [ # # ]: 0 : if (roc_model_is_cn9k())
171 : : return NIX_CN9K_MAX_HW_FRS;
172 : :
173 [ # # ]: 0 : if (nix->lbk_link || nix->esw_link)
174 : 0 : return NIX_LBK_MAX_HW_FRS;
175 : :
176 : : return NIX_RPM_MAX_HW_FRS;
177 : : }
178 : :
179 : : int
180 : 0 : roc_nix_lf_alloc(struct roc_nix *roc_nix, uint32_t nb_rxq, uint32_t nb_txq,
181 : : uint64_t rx_cfg)
182 : : {
183 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
184 : 0 : struct mbox *mbox = mbox_get((&nix->dev)->mbox);
185 : : struct nix_lf_alloc_req *req;
186 : : struct nix_lf_alloc_rsp *rsp;
187 : : int rc = -ENOSPC;
188 : :
189 : 0 : req = mbox_alloc_msg_nix_lf_alloc(mbox);
190 [ # # ]: 0 : if (req == NULL)
191 : 0 : goto fail;
192 : 0 : req->rq_cnt = nb_rxq;
193 : 0 : req->sq_cnt = nb_txq;
194 [ # # ]: 0 : if (roc_nix->tx_compl_ena)
195 : 0 : req->cq_cnt = nb_rxq + nb_txq;
196 : : else
197 : 0 : req->cq_cnt = nb_rxq;
198 : : /* XQESZ can be W64 or W16 */
199 : 0 : req->xqe_sz = NIX_XQESZ_W16;
200 : 0 : req->rss_sz = nix->reta_sz;
201 : 0 : req->rss_grps = ROC_NIX_RSS_GRPS;
202 : 0 : req->npa_func = idev_npa_pffunc_get();
203 : 0 : req->sso_func = idev_sso_pffunc_get();
204 : 0 : req->rx_cfg = rx_cfg;
205 [ # # # # : 0 : if (roc_nix_is_lbk(roc_nix) && roc_nix->enable_loop &&
# # ]
206 : : roc_model_is_cn98xx())
207 : 0 : req->flags = NIX_LF_LBK_BLK_SEL;
208 : :
209 [ # # ]: 0 : if (!roc_nix->rss_tag_as_xor)
210 : 0 : req->flags |= NIX_LF_RSS_TAG_LSB_AS_ADDER;
211 : :
212 : : rc = mbox_process_msg(mbox, (void *)&rsp);
213 [ # # ]: 0 : if (rc)
214 : 0 : goto fail;
215 : :
216 : 0 : nix->rx_cfg = rx_cfg;
217 : 0 : nix->sqb_size = rsp->sqb_size;
218 : 0 : nix->tx_chan_base = rsp->tx_chan_base;
219 : 0 : nix->rx_chan_base = rsp->rx_chan_base;
220 [ # # # # ]: 0 : if (roc_nix_is_lbk(roc_nix) && roc_nix->enable_loop)
221 : 0 : nix->tx_chan_base = rsp->rx_chan_base;
222 : 0 : nix->rx_chan_cnt = rsp->rx_chan_cnt;
223 : 0 : nix->tx_chan_cnt = rsp->tx_chan_cnt;
224 : 0 : nix->lso_tsov4_idx = rsp->lso_tsov4_idx;
225 : 0 : nix->lso_tsov6_idx = rsp->lso_tsov6_idx;
226 : 0 : nix->lf_tx_stats = rsp->lf_tx_stats;
227 : 0 : nix->lf_rx_stats = rsp->lf_rx_stats;
228 : 0 : nix->cints = rsp->cints;
229 : 0 : roc_nix->cints = rsp->cints;
230 : 0 : nix->qints = rsp->qints;
231 : 0 : nix->ptp_en = rsp->hw_rx_tstamp_en;
232 : 0 : roc_nix->rx_ptp_ena = rsp->hw_rx_tstamp_en;
233 : 0 : nix->cgx_links = rsp->cgx_links;
234 : 0 : nix->lbk_links = rsp->lbk_links;
235 : 0 : nix->sdp_links = rsp->sdp_links;
236 : 0 : nix->tx_link = rsp->tx_link;
237 : 0 : nix->nb_rx_queues = nb_rxq;
238 : 0 : nix->nb_tx_queues = nb_txq;
239 : :
240 : 0 : roc_idev_nix_rx_chan_set(roc_nix->port_id, rsp->rx_chan_base);
241 : :
242 : 0 : nix->rqs = plt_zmalloc(sizeof(struct roc_nix_rq *) * nb_rxq, 0);
243 [ # # ]: 0 : if (!nix->rqs) {
244 : : rc = -ENOMEM;
245 : 0 : goto fail;
246 : : }
247 : :
248 : 0 : nix->sqs = plt_zmalloc(sizeof(struct roc_nix_sq *) * nb_txq, 0);
249 [ # # ]: 0 : if (!nix->sqs) {
250 : : rc = -ENOMEM;
251 : 0 : goto fail;
252 : : }
253 : :
254 : 0 : nix_tel_node_add(roc_nix);
255 : 0 : fail:
256 : : mbox_put(mbox);
257 : 0 : return rc;
258 : : }
259 : :
260 : : int
261 : 0 : roc_nix_lf_free(struct roc_nix *roc_nix)
262 : : {
263 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
264 : 0 : struct mbox *mbox = mbox_get((&nix->dev)->mbox);
265 : : struct nix_lf_free_req *req;
266 : : struct ndc_sync_op *ndc_req;
267 : : int rc = -ENOSPC;
268 : :
269 : 0 : plt_free(nix->rqs);
270 : 0 : plt_free(nix->sqs);
271 : 0 : nix->rqs = NULL;
272 : 0 : nix->sqs = NULL;
273 : :
274 : : /* Sync NDC-NIX for LF */
275 : 0 : ndc_req = mbox_alloc_msg_ndc_sync_op(mbox);
276 [ # # ]: 0 : if (ndc_req == NULL)
277 : 0 : goto exit;
278 : 0 : ndc_req->nix_lf_tx_sync = 1;
279 : 0 : ndc_req->nix_lf_rx_sync = 1;
280 : 0 : rc = mbox_process(mbox);
281 [ # # ]: 0 : if (rc)
282 : 0 : plt_err("Error on NDC-NIX-[TX, RX] LF sync, rc %d", rc);
283 : :
284 : 0 : req = mbox_alloc_msg_nix_lf_free(mbox);
285 [ # # ]: 0 : if (req == NULL) {
286 : : rc = -ENOSPC;
287 : 0 : goto exit;
288 : : }
289 : : /* Let AF driver free all this nix lf's
290 : : * NPC entries allocated using NPC MBOX.
291 : : */
292 : 0 : req->flags = 0;
293 : :
294 : 0 : rc = mbox_process(mbox);
295 : 0 : exit:
296 : : mbox_put(mbox);
297 : 0 : return rc;
298 : : }
299 : :
300 : : static inline int
301 : 0 : nix_lf_attach(struct dev *dev)
302 : : {
303 : 0 : struct mbox *mbox = mbox_get(dev->mbox);
304 : : struct rsrc_attach_req *req;
305 : : int rc = -ENOSPC;
306 : :
307 : : /* Attach NIX(lf) */
308 : 0 : req = mbox_alloc_msg_attach_resources(mbox);
309 [ # # ]: 0 : if (req == NULL)
310 : 0 : goto exit;
311 : 0 : req->modify = true;
312 : 0 : req->nixlf = true;
313 : :
314 : 0 : rc = mbox_process(mbox);
315 : 0 : exit:
316 : : mbox_put(mbox);
317 : 0 : return rc;
318 : : }
319 : :
320 : : static inline int
321 : 0 : nix_lf_get_msix_offset(struct dev *dev, struct nix *nix)
322 : : {
323 : : struct msix_offset_rsp *msix_rsp;
324 : 0 : struct mbox *mbox = mbox_get(dev->mbox);
325 : : int rc;
326 : :
327 : : /* Get MSIX vector offsets */
328 : 0 : mbox_alloc_msg_msix_offset(mbox);
329 : : rc = mbox_process_msg(mbox, (void *)&msix_rsp);
330 [ # # ]: 0 : if (rc == 0)
331 : 0 : nix->msixoff = msix_rsp->nix_msixoff;
332 : :
333 : : mbox_put(mbox);
334 : 0 : return rc;
335 : : }
336 : :
337 : : static inline int
338 : 0 : nix_lf_detach(struct nix *nix)
339 : : {
340 : 0 : struct mbox *mbox = mbox_get((&nix->dev)->mbox);
341 : : struct rsrc_detach_req *req;
342 : : int rc = -ENOSPC;
343 : :
344 : 0 : req = mbox_alloc_msg_detach_resources(mbox);
345 [ # # ]: 0 : if (req == NULL)
346 : 0 : goto exit;
347 : 0 : req->partial = true;
348 : 0 : req->nixlf = true;
349 : :
350 : 0 : rc = mbox_process(mbox);
351 : 0 : exit:
352 : : mbox_put(mbox);
353 : 0 : return rc;
354 : : }
355 : :
356 : : static int
357 : 0 : roc_nix_get_hw_info(struct roc_nix *roc_nix)
358 : : {
359 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
360 : 0 : struct mbox *mbox = mbox_get((&nix->dev)->mbox);
361 : : struct nix_hw_info *hw_info;
362 : : int rc;
363 : :
364 : 0 : mbox_alloc_msg_nix_get_hw_info(mbox);
365 : : rc = mbox_process_msg(mbox, (void *)&hw_info);
366 [ # # ]: 0 : if (rc == 0) {
367 : 0 : nix->vwqe_interval = hw_info->vwqe_delay;
368 [ # # ]: 0 : if (nix->lbk_link || nix->esw_link)
369 : 0 : roc_nix->dwrr_mtu = hw_info->lbk_dwrr_mtu;
370 [ # # ]: 0 : else if (nix->sdp_link)
371 : 0 : roc_nix->dwrr_mtu = hw_info->sdp_dwrr_mtu;
372 : : else
373 : 0 : roc_nix->dwrr_mtu = hw_info->rpm_dwrr_mtu;
374 : : }
375 : :
376 : : mbox_put(mbox);
377 : 0 : return rc;
378 : : }
379 : :
380 : : static void
381 : : sdp_lbk_id_update(struct plt_pci_device *pci_dev, struct nix *nix)
382 : : {
383 : 0 : nix->sdp_link = false;
384 : 0 : nix->lbk_link = false;
385 : 0 : nix->esw_link = false;
386 : :
387 : : /* Update SDP/LBK link based on PCI device id */
388 [ # # # # ]: 0 : switch (pci_dev->id.device_id) {
389 : 0 : case PCI_DEVID_CNXK_RVU_SDP_PF:
390 : : case PCI_DEVID_CNXK_RVU_SDP_VF:
391 : 0 : nix->sdp_link = true;
392 : 0 : break;
393 : 0 : case PCI_DEVID_CNXK_RVU_AF_VF:
394 : 0 : nix->lbk_link = true;
395 : 0 : break;
396 : 0 : case PCI_DEVID_CNXK_RVU_ESWITCH_VF:
397 : 0 : nix->esw_link = true;
398 : 0 : break;
399 : : default:
400 : : break;
401 : : }
402 : : }
403 : :
404 : : uint64_t
405 [ # # ]: 0 : nix_get_blkaddr(struct dev *dev)
406 : : {
407 : : uint64_t blkaddr;
408 : : uint64_t reg;
409 : :
410 : : /* Reading the discovery register to know which NIX is the LF
411 : : * attached to.
412 : : */
413 [ # # # # ]: 0 : if (roc_model_is_cn9k() || roc_model_is_cn10k()) {
414 [ # # ]: 0 : reg = plt_read64(dev->bar2 + RVU_PF_BLOCK_ADDRX_DISC(RVU_BLOCK_ADDR_NIX0));
415 [ # # ]: 0 : blkaddr = reg & 0x1FFULL ? RVU_BLOCK_ADDR_NIX0 : RVU_BLOCK_ADDR_NIX1;
416 : : } else {
417 : 0 : reg = plt_read64(dev->bar2 + RVU_PF_DISC);
418 : 0 : blkaddr = reg & BIT_ULL(RVU_BLOCK_ADDR_NIX0) ? RVU_BLOCK_ADDR_NIX0 :
419 : : RVU_BLOCK_ADDR_NIX1;
420 : : blkaddr = RVU_BLOCK_ADDR_NIX0;
421 : : }
422 : 0 : return blkaddr;
423 : : }
424 : :
425 : : int
426 : 0 : roc_nix_dev_init(struct roc_nix *roc_nix)
427 : : {
428 : : enum roc_nix_rss_reta_sz reta_sz;
429 : : struct plt_pci_device *pci_dev;
430 : : struct roc_nix_list *nix_list;
431 : : uint16_t max_sqb_count;
432 : : uint64_t blkaddr;
433 : : struct dev *dev;
434 : : struct nix *nix;
435 : : int rc;
436 : :
437 [ # # # # ]: 0 : if (roc_nix == NULL || roc_nix->pci_dev == NULL)
438 : : return NIX_ERR_PARAM;
439 : :
440 : 0 : reta_sz = roc_nix->reta_sz;
441 [ # # # # ]: 0 : if (reta_sz != 0 && reta_sz != 64 && reta_sz != 128 && reta_sz != 256)
442 : : return NIX_ERR_PARAM;
443 : :
444 [ # # ]: 0 : if (reta_sz == 0)
445 : : reta_sz = ROC_NIX_RSS_RETA_SZ_64;
446 : :
447 : 0 : max_sqb_count = roc_nix->max_sqb_count;
448 : 0 : max_sqb_count = PLT_MIN(max_sqb_count, NIX_MAX_SQB);
449 : 0 : max_sqb_count = PLT_MAX(max_sqb_count, NIX_MIN_SQB);
450 : 0 : roc_nix->max_sqb_count = max_sqb_count;
451 : :
452 : : PLT_STATIC_ASSERT(sizeof(struct nix) <= ROC_NIX_MEM_SZ);
453 : : nix = roc_nix_to_nix_priv(roc_nix);
454 : : pci_dev = roc_nix->pci_dev;
455 : 0 : dev = &nix->dev;
456 : :
457 : 0 : nix_list = roc_idev_nix_list_get();
458 [ # # ]: 0 : if (nix_list == NULL)
459 : : return -EINVAL;
460 : :
461 : 0 : TAILQ_INSERT_TAIL(nix_list, roc_nix, next);
462 : :
463 [ # # ]: 0 : if (nix->dev.drv_inited)
464 : : return 0;
465 : :
466 [ # # ]: 0 : if (dev->mbox_active)
467 : 0 : goto skip_dev_init;
468 : :
469 : : memset(nix, 0, sizeof(*nix));
470 : :
471 : : /* Since 0 is a valid BPID, use -1 to represent invalid value. */
472 : 0 : memset(nix->bpid, -1, sizeof(nix->bpid));
473 : :
474 : : /* Initialize device */
475 : 0 : rc = dev_init(dev, pci_dev);
476 [ # # ]: 0 : if (rc) {
477 : 0 : plt_err("Failed to init roc device");
478 : 0 : goto fail;
479 : : }
480 : :
481 : 0 : skip_dev_init:
482 : 0 : dev->roc_nix = roc_nix;
483 : :
484 : 0 : nix->lmt_base = dev->lmt_base;
485 : : /* Expose base LMT line address for
486 : : * "Per Core LMT line" mode.
487 : : */
488 : 0 : roc_nix->lmt_base = dev->lmt_base;
489 : :
490 : : /* Attach NIX LF */
491 : 0 : rc = nix_lf_attach(dev);
492 [ # # ]: 0 : if (rc)
493 : 0 : goto dev_fini;
494 : :
495 : 0 : blkaddr = nix_get_blkaddr(dev);
496 : 0 : nix->is_nix1 = (blkaddr == RVU_BLOCK_ADDR_NIX1);
497 : :
498 : : /* Calculating base address based on which NIX block LF
499 : : * is attached to.
500 : : */
501 : 0 : nix->base = dev->bar2 + (blkaddr << 20);
502 : :
503 : : /* Get NIX MSIX offset */
504 : 0 : rc = nix_lf_get_msix_offset(dev, nix);
505 [ # # ]: 0 : if (rc)
506 : 0 : goto lf_detach;
507 : :
508 : : /* Update nix context */
509 : : sdp_lbk_id_update(pci_dev, nix);
510 : 0 : nix->pci_dev = pci_dev;
511 : 0 : nix->reta_sz = reta_sz;
512 : 0 : nix->mtu = roc_nix_max_pkt_len(roc_nix);
513 : 0 : nix->dmac_flt_idx = -1;
514 : :
515 : : /* Register error and ras interrupts */
516 : 0 : rc = nix_register_irqs(nix);
517 [ # # ]: 0 : if (rc)
518 : 0 : goto lf_detach;
519 : :
520 : 0 : rc = nix_tm_conf_init(roc_nix);
521 [ # # ]: 0 : if (rc)
522 : 0 : goto unregister_irqs;
523 : :
524 : : /* Get NIX HW info */
525 : 0 : roc_nix_get_hw_info(roc_nix);
526 [ # # ]: 0 : nix->dev.drv_inited = true;
527 : :
528 [ # # ]: 0 : if (roc_model_is_cn20k()) {
529 : 0 : rc = roc_nix_af_rx_flow_vec_ctrl_set(roc_nix);
530 [ # # ]: 0 : if (rc)
531 : 0 : goto tm_conf_fini;
532 : : }
533 : :
534 : : return 0;
535 : : tm_conf_fini:
536 : 0 : nix_tm_conf_fini(roc_nix);
537 : 0 : unregister_irqs:
538 : 0 : nix_unregister_irqs(nix);
539 : 0 : lf_detach:
540 : 0 : nix_lf_detach(nix);
541 : 0 : dev_fini:
542 : 0 : rc |= dev_fini(dev, pci_dev);
543 : 0 : fail:
544 : 0 : nix_tel_node_del(roc_nix);
545 : 0 : return rc;
546 : : }
547 : :
548 : : int
549 [ # # ]: 0 : roc_nix_dev_fini(struct roc_nix *roc_nix)
550 : : {
551 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
552 : : int rc = 0;
553 : :
554 : : if (nix == NULL)
555 : : return NIX_ERR_PARAM;
556 : :
557 [ # # ]: 0 : if (!nix->dev.drv_inited)
558 : 0 : goto fini;
559 : :
560 : 0 : nix_tm_conf_fini(roc_nix);
561 : 0 : nix_unregister_irqs(nix);
562 : :
563 : 0 : rc = nix_lf_detach(nix);
564 : 0 : nix->dev.drv_inited = false;
565 : 0 : fini:
566 : 0 : rc |= dev_fini(&nix->dev, nix->pci_dev);
567 : : return rc;
568 : : }
569 : :
570 : : int
571 : 0 : roc_nix_max_rep_count(struct roc_nix *roc_nix)
572 : : {
573 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
574 : : struct dev *dev = &nix->dev;
575 : 0 : struct mbox *mbox = mbox_get(dev->mbox);
576 : : struct get_rep_cnt_rsp *rsp;
577 : : struct msg_req *req;
578 : : int rc, i;
579 : :
580 : 0 : req = mbox_alloc_msg_get_rep_cnt(mbox);
581 [ # # ]: 0 : if (!req) {
582 : : rc = -ENOSPC;
583 : 0 : goto exit;
584 : : }
585 : :
586 : 0 : req->hdr.pcifunc = roc_nix_get_pf_func(roc_nix);
587 : :
588 : : rc = mbox_process_msg(mbox, (void *)&rsp);
589 [ # # ]: 0 : if (rc)
590 : 0 : goto exit;
591 : :
592 : 0 : roc_nix->rep_cnt = rsp->rep_cnt;
593 [ # # ]: 0 : for (i = 0; i < rsp->rep_cnt; i++)
594 : 0 : roc_nix->rep_pfvf_map[i] = rsp->rep_pfvf_map[i];
595 : :
596 : 0 : exit:
597 : : mbox_put(mbox);
598 : 0 : return rc;
599 : : }
600 : :
601 : : static int
602 : 0 : nix_af_rx_flow_vec_ctrl_set(struct mbox *mbox)
603 : : {
604 : : struct nix_af_rx_flow_vec_ctrl_write_req *req;
605 : : struct nix_af_rx_flow_vec_ctrl_write_rsp *rsp;
606 : : int rc = -ENOSPC;
607 : :
608 : 0 : req = mbox_alloc_msg_nix_af_rx_flow_vec_ctrl_set(mbox_get(mbox));
609 [ # # ]: 0 : if (req == NULL)
610 : 0 : goto exit;
611 : :
612 : 0 : memcpy(&req->ctrl0x, nix_flow_ctrl0, sizeof(nix_flow_ctrl0));
613 : 0 : memcpy(&req->ctrl1x, nix_flow_ctrl1, sizeof(nix_flow_ctrl1));
614 : :
615 : : rc = mbox_process_msg(mbox, (void *)&rsp);
616 [ # # ]: 0 : if (rc)
617 : 0 : goto exit;
618 : :
619 : 0 : exit:
620 : : mbox_put(mbox);
621 : 0 : return rc;
622 : : }
623 : :
624 : : int
625 : 0 : roc_nix_af_rx_flow_vec_ctrl_set(struct roc_nix *roc_nix)
626 : : {
627 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
628 : : struct dev *dev = &nix->dev;
629 : :
630 : 0 : return nix_af_rx_flow_vec_ctrl_set(dev->mbox);
631 : : }
|