Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2014-2023 Broadcom
3 : : * All rights reserved.
4 : : */
5 : :
6 : : #include <unistd.h>
7 : :
8 : : #include <rte_byteorder.h>
9 : : #include <rte_common.h>
10 : : #include <rte_cycles.h>
11 : : #include <rte_malloc.h>
12 : : #include <rte_memzone.h>
13 : : #include <rte_version.h>
14 : : #include <rte_io.h>
15 : :
16 : : #include "bnxt.h"
17 : : #include "bnxt_filter.h"
18 : : #include "bnxt_hwrm.h"
19 : : #include "bnxt_rxq.h"
20 : : #include "bnxt_rxr.h"
21 : : #include "bnxt_ring.h"
22 : : #include "bnxt_txq.h"
23 : : #include "bnxt_txr.h"
24 : : #include "bnxt_vnic.h"
25 : : #include "hsi_struct_def_dpdk.h"
26 : :
27 : : #define HWRM_SPEC_CODE_1_8_3 0x10803
28 : : #define HWRM_VERSION_1_9_1 0x10901
29 : : #define HWRM_VERSION_1_9_2 0x10903
30 : : #define HWRM_VERSION_1_10_2_13 0x10a020d
31 : : struct bnxt_plcmodes_cfg {
32 : : uint32_t flags;
33 : : uint16_t jumbo_thresh;
34 : : uint16_t hds_offset;
35 : : uint16_t hds_threshold;
36 : : };
37 : :
38 : 0 : static int page_getenum(size_t size)
39 : : {
40 [ # # ]: 0 : if (size <= 1 << 4)
41 : : return 4;
42 [ # # ]: 0 : if (size <= 1 << 12)
43 : : return 12;
44 [ # # ]: 0 : if (size <= 1 << 13)
45 : : return 13;
46 [ # # ]: 0 : if (size <= 1 << 16)
47 : : return 16;
48 [ # # ]: 0 : if (size <= 1 << 21)
49 : : return 21;
50 [ # # ]: 0 : if (size <= 1 << 22)
51 : : return 22;
52 [ # # ]: 0 : if (size <= 1 << 30)
53 : : return 30;
54 : 0 : PMD_DRV_LOG(ERR, "Page size %zu out of range\n", size);
55 : 0 : return sizeof(int) * 8 - 1;
56 : : }
57 : :
58 : : static int page_roundup(size_t size)
59 : : {
60 : 0 : return 1 << page_getenum(size);
61 : : }
62 : :
63 : : static void bnxt_hwrm_set_pg_attr(struct bnxt_ring_mem_info *rmem,
64 : : uint8_t *pg_attr,
65 : : uint64_t *pg_dir)
66 : : {
67 : 0 : if (rmem->nr_pages == 0)
68 : : return;
69 : :
70 [ # # # # : 0 : if (rmem->nr_pages > 1) {
# # # # #
# # # #
# ]
71 : 0 : *pg_attr = 1;
72 : 0 : *pg_dir = rte_cpu_to_le_64(rmem->pg_tbl_map);
73 : : } else {
74 : 0 : *pg_dir = rte_cpu_to_le_64(rmem->dma_arr[0]);
75 : : }
76 : : }
77 : :
78 : : static struct bnxt_cp_ring_info*
79 : 0 : bnxt_get_ring_info_by_id(struct bnxt *bp, uint16_t rid, uint16_t type)
80 : : {
81 : : struct bnxt_cp_ring_info *cp_ring = NULL;
82 : : uint16_t i;
83 : :
84 [ # # # ]: 0 : switch (type) {
85 : : case HWRM_RING_FREE_INPUT_RING_TYPE_RX:
86 : : case HWRM_RING_FREE_INPUT_RING_TYPE_RX_AGG:
87 : : /* FALLTHROUGH */
88 [ # # ]: 0 : for (i = 0; i < bp->rx_cp_nr_rings; i++) {
89 : 0 : struct bnxt_rx_queue *rxq = bp->rx_queues[i];
90 : :
91 [ # # ]: 0 : if (rxq->cp_ring->cp_ring_struct->fw_ring_id ==
92 : : rte_cpu_to_le_16(rid)) {
93 : 0 : return rxq->cp_ring;
94 : : }
95 : : }
96 : : break;
97 : : case HWRM_RING_FREE_INPUT_RING_TYPE_TX:
98 [ # # ]: 0 : for (i = 0; i < bp->tx_cp_nr_rings; i++) {
99 : 0 : struct bnxt_tx_queue *txq = bp->tx_queues[i];
100 : :
101 [ # # ]: 0 : if (txq->cp_ring->cp_ring_struct->fw_ring_id ==
102 : : rte_cpu_to_le_16(rid)) {
103 : 0 : return txq->cp_ring;
104 : : }
105 : : }
106 : : break;
107 : : default:
108 : : return cp_ring;
109 : : }
110 : : return cp_ring;
111 : : }
112 : :
113 : : /* Complete a sweep of the CQ ring for the corresponding Tx/Rx/AGG ring.
114 : : * If the CMPL_BASE_TYPE_HWRM_DONE is not encountered by the last pass,
115 : : * before timeout, we force the done bit for the cleanup to proceed.
116 : : * Also if cpr is null, do nothing.. The HWRM command is not for a
117 : : * Tx/Rx/AGG ring cleanup.
118 : : */
119 : : static int
120 : 0 : bnxt_check_cq_hwrm_done(struct bnxt_cp_ring_info *cpr,
121 : : bool tx, bool rx, bool timeout)
122 : : {
123 : : int done = 0;
124 : :
125 [ # # ]: 0 : if (cpr != NULL) {
126 [ # # ]: 0 : if (tx)
127 : 0 : done = bnxt_flush_tx_cmp(cpr);
128 : :
129 [ # # ]: 0 : if (rx)
130 : 0 : done = bnxt_flush_rx_cmp(cpr);
131 : :
132 [ # # ]: 0 : if (done)
133 [ # # ]: 0 : PMD_DRV_LOG(DEBUG, "HWRM DONE for %s ring\n",
134 : : rx ? "Rx" : "Tx");
135 : :
136 : : /* We are about to timeout and still haven't seen the
137 : : * HWRM done for the Ring free. Force the cleanup.
138 : : */
139 [ # # ]: 0 : if (!done && timeout) {
140 : : done = 1;
141 [ # # ]: 0 : PMD_DRV_LOG(DEBUG, "Timing out for %s ring\n",
142 : : rx ? "Rx" : "Tx");
143 : : }
144 : : } else {
145 : : /* This HWRM command is not for a Tx/Rx/AGG ring cleanup.
146 : : * Otherwise the cpr would have been valid. So do nothing.
147 : : */
148 : : done = 1;
149 : : }
150 : :
151 : 0 : return done;
152 : : }
153 : :
154 : : /*
155 : : * HWRM Functions (sent to HWRM)
156 : : * These are named bnxt_hwrm_*() and return 0 on success or -110 if the
157 : : * HWRM command times out, or a negative error code if the HWRM
158 : : * command was failed by the FW.
159 : : */
160 : :
161 : 0 : static int bnxt_hwrm_send_message(struct bnxt *bp, void *msg,
162 : : uint32_t msg_len, bool use_kong_mb)
163 : : {
164 : : unsigned int i;
165 : : struct input *req = msg;
166 : 0 : struct output *resp = bp->hwrm_cmd_resp_addr;
167 : : uint32_t *data = msg;
168 : : uint8_t *bar;
169 : : uint8_t *valid;
170 : 0 : uint16_t max_req_len = bp->max_req_len;
171 : 0 : struct hwrm_short_input short_input = { 0 };
172 [ # # ]: 0 : uint16_t bar_offset = use_kong_mb ?
173 : : GRCPF_REG_KONG_CHANNEL_OFFSET : GRCPF_REG_CHIMP_CHANNEL_OFFSET;
174 [ # # ]: 0 : uint16_t mb_trigger_offset = use_kong_mb ?
175 : : GRCPF_REG_KONG_COMM_TRIGGER : GRCPF_REG_CHIMP_COMM_TRIGGER;
176 : : struct bnxt_cp_ring_info *cpr = NULL;
177 : : bool is_rx = false;
178 : : bool is_tx = false;
179 : : uint32_t timeout;
180 : :
181 : : /* Do not send HWRM commands to firmware in error state */
182 [ # # ]: 0 : if (bp->flags & BNXT_FLAG_FATAL_ERROR)
183 : : return 0;
184 : :
185 : 0 : timeout = bp->hwrm_cmd_timeout;
186 : :
187 : : /* Update the message length for backing store config for new FW. */
188 [ # # ]: 0 : if (bp->fw_ver >= HWRM_VERSION_1_10_2_13 &&
189 [ # # ]: 0 : rte_cpu_to_le_16(req->req_type) == HWRM_FUNC_BACKING_STORE_CFG)
190 : : msg_len = BNXT_BACKING_STORE_CFG_LEGACY_LEN;
191 : :
192 [ # # ]: 0 : if (bp->flags & BNXT_FLAG_SHORT_CMD ||
193 [ # # ]: 0 : msg_len > bp->max_req_len) {
194 : 0 : void *short_cmd_req = bp->hwrm_short_cmd_req_addr;
195 : :
196 : 0 : memset(short_cmd_req, 0, bp->hwrm_max_ext_req_len);
197 : 0 : memcpy(short_cmd_req, req, msg_len);
198 : :
199 : 0 : short_input.req_type = rte_cpu_to_le_16(req->req_type);
200 : 0 : short_input.signature = rte_cpu_to_le_16(
201 : : HWRM_SHORT_INPUT_SIGNATURE_SHORT_CMD);
202 : 0 : short_input.size = rte_cpu_to_le_16(msg_len);
203 : 0 : short_input.req_addr =
204 : 0 : rte_cpu_to_le_64(bp->hwrm_short_cmd_req_dma_addr);
205 : :
206 : : data = (uint32_t *)&short_input;
207 : : msg_len = sizeof(short_input);
208 : :
209 : : max_req_len = BNXT_HWRM_SHORT_REQ_LEN;
210 : : }
211 : :
212 : : /* Write request msg to hwrm channel */
213 [ # # ]: 0 : for (i = 0; i < msg_len; i += 4) {
214 : 0 : bar = (uint8_t *)bp->bar0 + bar_offset + i;
215 : 0 : rte_write32(*data, bar);
216 : 0 : data++;
217 : : }
218 : :
219 : : /* Zero the rest of the request space */
220 [ # # ]: 0 : for (; i < max_req_len; i += 4) {
221 : 0 : bar = (uint8_t *)bp->bar0 + bar_offset + i;
222 : : rte_write32(0, bar);
223 : : }
224 : :
225 : : /* Ring channel doorbell */
226 : 0 : bar = (uint8_t *)bp->bar0 + mb_trigger_offset;
227 : : rte_write32(1, bar);
228 : : /*
229 : : * Make sure the channel doorbell ring command complete before
230 : : * reading the response to avoid getting stale or invalid
231 : : * responses.
232 : : */
233 : : rte_io_mb();
234 : :
235 : : /* Check ring flush is done.
236 : : * This is valid only for Tx and Rx rings (including AGG rings).
237 : : * The Tx and Rx rings should be freed once the HW confirms all
238 : : * the internal buffers and BDs associated with the rings are
239 : : * consumed and the corresponding DMA is handled.
240 : : */
241 [ # # ]: 0 : if (rte_cpu_to_le_16(req->cmpl_ring) != INVALID_HW_RING_ID) {
242 : : /* Check if the TxCQ matches. If that fails check if RxCQ
243 : : * matches. And if neither match, is_rx = false, is_tx = false.
244 : : */
245 : 0 : cpr = bnxt_get_ring_info_by_id(bp, req->cmpl_ring,
246 : : HWRM_RING_FREE_INPUT_RING_TYPE_TX);
247 [ # # ]: 0 : if (cpr == NULL) {
248 : : /* Not a TxCQ. Check if the RxCQ matches. */
249 : : cpr =
250 : 0 : bnxt_get_ring_info_by_id(bp, req->cmpl_ring,
251 : : HWRM_RING_FREE_INPUT_RING_TYPE_RX);
252 [ # # ]: 0 : if (cpr != NULL)
253 : : is_rx = true;
254 : : } else {
255 : : is_tx = true;
256 : : }
257 : : }
258 : :
259 : : /* Poll for the valid bit */
260 [ # # ]: 0 : for (i = 0; i < timeout; i++) {
261 : : int done;
262 : :
263 : 0 : done = bnxt_check_cq_hwrm_done(cpr, is_tx, is_rx,
264 : 0 : i == timeout - 1);
265 : : /* Sanity check on the resp->resp_len */
266 : 0 : rte_io_rmb();
267 [ # # # # ]: 0 : if (resp->resp_len && resp->resp_len <= bp->max_resp_len) {
268 : : /* Last byte of resp contains the valid key */
269 : 0 : valid = (uint8_t *)resp + resp->resp_len - 1;
270 [ # # # # ]: 0 : if (*valid == HWRM_RESP_VALID_KEY && done)
271 : : break;
272 : : }
273 : 0 : rte_delay_us(1);
274 : : }
275 : :
276 [ # # ]: 0 : if (i >= timeout) {
277 : : /* Suppress VER_GET timeout messages during reset recovery */
278 [ # # ]: 0 : if (bp->flags & BNXT_FLAG_FW_RESET &&
279 [ # # ]: 0 : rte_cpu_to_le_16(req->req_type) == HWRM_VER_GET)
280 : : return -ETIMEDOUT;
281 : :
282 : 0 : PMD_DRV_LOG(ERR,
283 : : "Error(timeout) sending msg 0x%04x, seq_id %d\n",
284 : : req->req_type, req->seq_id);
285 : 0 : return -ETIMEDOUT;
286 : : }
287 : : return 0;
288 : : }
289 : :
290 : : /*
291 : : * HWRM_PREP() should be used to prepare *ALL* HWRM commands. It grabs the
292 : : * spinlock, and does initial processing.
293 : : *
294 : : * HWRM_CHECK_RESULT() returns errors on failure and may not be used. It
295 : : * releases the spinlock only if it returns. If the regular int return codes
296 : : * are not used by the function, HWRM_CHECK_RESULT() should not be used
297 : : * directly, rather it should be copied and modified to suit the function.
298 : : *
299 : : * HWRM_UNLOCK() must be called after all response processing is completed.
300 : : */
301 : : #define HWRM_PREP(req, type, kong) do { \
302 : : rte_spinlock_lock(&bp->hwrm_lock); \
303 : : if (bp->hwrm_cmd_resp_addr == NULL) { \
304 : : rte_spinlock_unlock(&bp->hwrm_lock); \
305 : : return -EACCES; \
306 : : } \
307 : : memset(bp->hwrm_cmd_resp_addr, 0, bp->max_resp_len); \
308 : : (req)->req_type = rte_cpu_to_le_16(type); \
309 : : (req)->cmpl_ring = rte_cpu_to_le_16(-1); \
310 : : (req)->seq_id = kong ? rte_cpu_to_le_16(bp->kong_cmd_seq++) :\
311 : : rte_cpu_to_le_16(bp->chimp_cmd_seq++); \
312 : : (req)->target_id = rte_cpu_to_le_16(0xffff); \
313 : : (req)->resp_addr = rte_cpu_to_le_64(bp->hwrm_cmd_resp_dma_addr); \
314 : : } while (0)
315 : :
316 : : #define HWRM_CHECK_RESULT_SILENT() do {\
317 : : if (rc) { \
318 : : rte_spinlock_unlock(&bp->hwrm_lock); \
319 : : return rc; \
320 : : } \
321 : : if (resp->error_code) { \
322 : : rc = rte_le_to_cpu_16(resp->error_code); \
323 : : rte_spinlock_unlock(&bp->hwrm_lock); \
324 : : return rc; \
325 : : } \
326 : : } while (0)
327 : :
328 : : #define HWRM_CHECK_RESULT() do {\
329 : : if (rc) { \
330 : : PMD_DRV_LOG(ERR, "failed rc:%d\n", rc); \
331 : : rte_spinlock_unlock(&bp->hwrm_lock); \
332 : : if (rc == HWRM_ERR_CODE_RESOURCE_ACCESS_DENIED) \
333 : : rc = -EACCES; \
334 : : else if (rc == HWRM_ERR_CODE_RESOURCE_ALLOC_ERROR) \
335 : : rc = -ENOSPC; \
336 : : else if (rc == HWRM_ERR_CODE_INVALID_PARAMS) \
337 : : rc = -EINVAL; \
338 : : else if (rc == HWRM_ERR_CODE_CMD_NOT_SUPPORTED) \
339 : : rc = -ENOTSUP; \
340 : : else if (rc == HWRM_ERR_CODE_HOT_RESET_PROGRESS) \
341 : : rc = -EAGAIN; \
342 : : else if (rc > 0) \
343 : : rc = -EIO; \
344 : : return rc; \
345 : : } \
346 : : if (resp->error_code) { \
347 : : rc = rte_le_to_cpu_16(resp->error_code); \
348 : : if (resp->resp_len >= 16) { \
349 : : struct hwrm_err_output *tmp_hwrm_err_op = \
350 : : (void *)resp; \
351 : : PMD_DRV_LOG(ERR, \
352 : : "error %d:%d:%08x:%04x\n", \
353 : : rc, tmp_hwrm_err_op->cmd_err, \
354 : : rte_le_to_cpu_32(\
355 : : tmp_hwrm_err_op->opaque_0), \
356 : : rte_le_to_cpu_16(\
357 : : tmp_hwrm_err_op->opaque_1)); \
358 : : } else { \
359 : : PMD_DRV_LOG(ERR, "error %d\n", rc); \
360 : : } \
361 : : rte_spinlock_unlock(&bp->hwrm_lock); \
362 : : if (rc == HWRM_ERR_CODE_RESOURCE_ACCESS_DENIED) \
363 : : rc = -EACCES; \
364 : : else if (rc == HWRM_ERR_CODE_RESOURCE_ALLOC_ERROR) \
365 : : rc = -ENOSPC; \
366 : : else if (rc == HWRM_ERR_CODE_INVALID_PARAMS) \
367 : : rc = -EINVAL; \
368 : : else if (rc == HWRM_ERR_CODE_CMD_NOT_SUPPORTED) \
369 : : rc = -ENOTSUP; \
370 : : else if (rc == HWRM_ERR_CODE_HOT_RESET_PROGRESS) \
371 : : rc = -EAGAIN; \
372 : : else if (rc > 0) \
373 : : rc = -EIO; \
374 : : return rc; \
375 : : } \
376 : : } while (0)
377 : :
378 : : #define HWRM_UNLOCK() rte_spinlock_unlock(&bp->hwrm_lock)
379 : :
380 : 0 : int bnxt_hwrm_tf_message_direct(struct bnxt *bp,
381 : : bool use_kong_mb,
382 : : uint16_t msg_type,
383 : : void *msg,
384 : : uint32_t msg_len,
385 : : void *resp_msg,
386 : : uint32_t resp_len)
387 : : {
388 : : int rc = 0;
389 : : bool mailbox = BNXT_USE_CHIMP_MB;
390 : : struct input *req = msg;
391 : 0 : struct output *resp = bp->hwrm_cmd_resp_addr;
392 : :
393 [ # # ]: 0 : if (use_kong_mb)
394 : 0 : mailbox = BNXT_USE_KONG(bp);
395 : :
396 [ # # # # ]: 0 : HWRM_PREP(req, msg_type, mailbox);
397 : :
398 : 0 : rc = bnxt_hwrm_send_message(bp, req, msg_len, mailbox);
399 : :
400 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
401 : :
402 [ # # ]: 0 : if (resp_msg)
403 : 0 : memcpy(resp_msg, resp, resp_len);
404 : :
405 : : HWRM_UNLOCK();
406 : :
407 : 0 : return rc;
408 : : }
409 : :
410 : 0 : int bnxt_hwrm_cfa_l2_clear_rx_mask(struct bnxt *bp, struct bnxt_vnic_info *vnic)
411 : : {
412 : : int rc = 0;
413 : 0 : struct hwrm_cfa_l2_set_rx_mask_input req = {.req_type = 0 };
414 : 0 : struct hwrm_cfa_l2_set_rx_mask_output *resp = bp->hwrm_cmd_resp_addr;
415 : :
416 [ # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_L2_SET_RX_MASK, BNXT_USE_CHIMP_MB);
417 : 0 : req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
418 : 0 : req.mask = 0;
419 : :
420 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
421 : :
422 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
423 : : HWRM_UNLOCK();
424 : :
425 : 0 : return rc;
426 : : }
427 : :
428 : 0 : int bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt *bp,
429 : : struct bnxt_vnic_info *vnic,
430 : : uint16_t vlan_count,
431 : : struct bnxt_vlan_table_entry *vlan_table)
432 : : {
433 : : int rc = 0;
434 : 0 : struct hwrm_cfa_l2_set_rx_mask_input req = {.req_type = 0 };
435 : 0 : struct hwrm_cfa_l2_set_rx_mask_output *resp = bp->hwrm_cmd_resp_addr;
436 : : uint32_t mask = 0;
437 : :
438 [ # # ]: 0 : if (vnic->fw_vnic_id == INVALID_HW_RING_ID)
439 : : return rc;
440 : :
441 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_L2_SET_RX_MASK, BNXT_USE_CHIMP_MB);
442 : 0 : req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
443 : :
444 [ # # ]: 0 : if (vnic->flags & BNXT_VNIC_INFO_BCAST)
445 : : mask |= HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_BCAST;
446 [ # # ]: 0 : if (vnic->flags & BNXT_VNIC_INFO_UNTAGGED)
447 : 0 : mask |= HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_VLAN_NONVLAN;
448 : :
449 [ # # ]: 0 : if (vnic->flags & BNXT_VNIC_INFO_PROMISC)
450 : 0 : mask |= HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_PROMISCUOUS;
451 : :
452 [ # # ]: 0 : if (vnic->flags & BNXT_VNIC_INFO_ALLMULTI) {
453 : 0 : mask |= HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ALL_MCAST;
454 [ # # ]: 0 : } else if (vnic->flags & BNXT_VNIC_INFO_MCAST) {
455 : 0 : mask |= HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_MCAST;
456 : 0 : req.num_mc_entries = rte_cpu_to_le_32(bp->nb_mc_addr);
457 : 0 : req.mc_tbl_addr = rte_cpu_to_le_64(bp->mc_list_dma_addr);
458 : : }
459 [ # # ]: 0 : if (vlan_table) {
460 [ # # ]: 0 : if (!(mask & HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_VLAN_NONVLAN))
461 : 0 : mask |= HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_VLANONLY;
462 : 0 : req.vlan_tag_tbl_addr =
463 : 0 : rte_cpu_to_le_64(rte_malloc_virt2iova(vlan_table));
464 : 0 : req.num_vlan_tags = rte_cpu_to_le_32((uint32_t)vlan_count);
465 : : }
466 : 0 : req.mask = rte_cpu_to_le_32(mask);
467 : :
468 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
469 : :
470 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
471 : : HWRM_UNLOCK();
472 : :
473 : 0 : return rc;
474 : : }
475 : :
476 : 0 : int bnxt_hwrm_cfa_vlan_antispoof_cfg(struct bnxt *bp, uint16_t fid,
477 : : uint16_t vlan_count,
478 : : struct bnxt_vlan_antispoof_table_entry *vlan_table)
479 : : {
480 : : int rc = 0;
481 : 0 : struct hwrm_cfa_vlan_antispoof_cfg_input req = {.req_type = 0 };
482 : 0 : struct hwrm_cfa_vlan_antispoof_cfg_output *resp =
483 : : bp->hwrm_cmd_resp_addr;
484 : :
485 : : /*
486 : : * Older HWRM versions did not support this command, and the set_rx_mask
487 : : * list was used for anti-spoof. In 1.8.0, the TX path configuration was
488 : : * removed from set_rx_mask call, and this command was added.
489 : : *
490 : : * This command is also present from 1.7.8.11 and higher,
491 : : * as well as 1.7.8.0
492 : : */
493 [ # # ]: 0 : if (bp->fw_ver < ((1 << 24) | (8 << 16))) {
494 [ # # ]: 0 : if (bp->fw_ver != ((1 << 24) | (7 << 16) | (8 << 8))) {
495 [ # # ]: 0 : if (bp->fw_ver < ((1 << 24) | (7 << 16) | (8 << 8) |
496 : : (11)))
497 : : return 0;
498 : : }
499 : : }
500 [ # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_VLAN_ANTISPOOF_CFG, BNXT_USE_CHIMP_MB);
501 : 0 : req.fid = rte_cpu_to_le_16(fid);
502 : :
503 : 0 : req.vlan_tag_mask_tbl_addr =
504 : 0 : rte_cpu_to_le_64(rte_malloc_virt2iova(vlan_table));
505 : 0 : req.num_vlan_entries = rte_cpu_to_le_32((uint32_t)vlan_count);
506 : :
507 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
508 : :
509 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
510 : : HWRM_UNLOCK();
511 : :
512 : 0 : return rc;
513 : : }
514 : :
515 : 0 : int bnxt_hwrm_clear_l2_filter(struct bnxt *bp,
516 : : struct bnxt_filter_info *filter)
517 : : {
518 : : int rc = 0;
519 : : struct bnxt_filter_info *l2_filter = filter;
520 : : struct bnxt_vnic_info *vnic = NULL;
521 : 0 : struct hwrm_cfa_l2_filter_free_input req = {.req_type = 0 };
522 : 0 : struct hwrm_cfa_l2_filter_free_output *resp = bp->hwrm_cmd_resp_addr;
523 : :
524 [ # # ]: 0 : if (filter->fw_l2_filter_id == UINT64_MAX)
525 : : return 0;
526 : :
527 [ # # ]: 0 : if (filter->matching_l2_fltr_ptr)
528 : : l2_filter = filter->matching_l2_fltr_ptr;
529 : :
530 : 0 : PMD_DRV_LOG(DEBUG, "filter: %p l2_filter: %p ref_cnt: %d\n",
531 : : filter, l2_filter, l2_filter->l2_ref_cnt);
532 : :
533 [ # # ]: 0 : if (l2_filter->l2_ref_cnt == 0)
534 : : return 0;
535 : :
536 : : if (l2_filter->l2_ref_cnt > 0)
537 : 0 : l2_filter->l2_ref_cnt--;
538 : :
539 [ # # ]: 0 : if (l2_filter->l2_ref_cnt > 0)
540 : : return 0;
541 : :
542 [ # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_L2_FILTER_FREE, BNXT_USE_CHIMP_MB);
543 : :
544 : 0 : req.l2_filter_id = rte_cpu_to_le_64(filter->fw_l2_filter_id);
545 : :
546 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
547 : :
548 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
549 : : HWRM_UNLOCK();
550 : :
551 : 0 : filter->fw_l2_filter_id = UINT64_MAX;
552 [ # # ]: 0 : if (l2_filter->l2_ref_cnt == 0) {
553 : 0 : vnic = l2_filter->vnic;
554 [ # # ]: 0 : if (vnic) {
555 [ # # # # : 0 : STAILQ_REMOVE(&vnic->filter, l2_filter,
# # # # ]
556 : : bnxt_filter_info, next);
557 : 0 : bnxt_free_filter(bp, l2_filter);
558 : : }
559 : : }
560 : :
561 : : return 0;
562 : : }
563 : :
564 : 0 : int bnxt_hwrm_set_l2_filter(struct bnxt *bp,
565 : : uint16_t dst_id,
566 : : struct bnxt_filter_info *filter)
567 : : {
568 : : int rc = 0;
569 : 0 : struct hwrm_cfa_l2_filter_alloc_input req = {.req_type = 0 };
570 : 0 : struct hwrm_cfa_l2_filter_alloc_output *resp = bp->hwrm_cmd_resp_addr;
571 : 0 : struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf;
572 : : const struct rte_eth_vmdq_rx_conf *conf =
573 : : &dev_conf->rx_adv_conf.vmdq_rx_conf;
574 : : uint32_t enables = 0;
575 : 0 : uint16_t j = dst_id - 1;
576 : :
577 : : //TODO: Is there a better way to add VLANs to each VNIC in case of VMDQ
578 [ # # ]: 0 : if ((dev_conf->rxmode.mq_mode & RTE_ETH_MQ_RX_VMDQ_FLAG) &&
579 [ # # ]: 0 : conf->pool_map[j].pools & (1UL << j)) {
580 : 0 : PMD_DRV_LOG(DEBUG,
581 : : "Add vlan %u to vmdq pool %u\n",
582 : : conf->pool_map[j].vlan_id, j);
583 : :
584 : 0 : filter->l2_ivlan = conf->pool_map[j].vlan_id;
585 : 0 : filter->enables |=
586 : : HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_IVLAN |
587 : : HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_IVLAN_MASK;
588 : : }
589 : :
590 [ # # ]: 0 : if (filter->fw_l2_filter_id != UINT64_MAX)
591 : 0 : bnxt_hwrm_clear_l2_filter(bp, filter);
592 : :
593 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_L2_FILTER_ALLOC, BNXT_USE_CHIMP_MB);
594 : :
595 : : /* PMD does not support XDP and RoCE */
596 : 0 : filter->flags |= HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_XDP_DISABLE |
597 : : HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_TRAFFIC_L2;
598 : 0 : req.flags = rte_cpu_to_le_32(filter->flags);
599 : :
600 : 0 : enables = filter->enables |
601 : : HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_DST_ID;
602 : 0 : req.dst_id = rte_cpu_to_le_16(dst_id);
603 : :
604 [ # # ]: 0 : if (enables &
605 : : HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR)
606 : : memcpy(req.l2_addr, filter->l2_addr,
607 : : RTE_ETHER_ADDR_LEN);
608 [ # # ]: 0 : if (enables &
609 : : HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR_MASK)
610 : : memcpy(req.l2_addr_mask, filter->l2_addr_mask,
611 : : RTE_ETHER_ADDR_LEN);
612 [ # # ]: 0 : if (enables &
613 : : HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_OVLAN)
614 : 0 : req.l2_ovlan = filter->l2_ovlan;
615 [ # # ]: 0 : if (enables &
616 : : HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_IVLAN)
617 : 0 : req.l2_ivlan = filter->l2_ivlan;
618 [ # # ]: 0 : if (enables &
619 : : HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_OVLAN_MASK)
620 : 0 : req.l2_ovlan_mask = filter->l2_ovlan_mask;
621 [ # # ]: 0 : if (enables &
622 : : HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_IVLAN_MASK)
623 : 0 : req.l2_ivlan_mask = filter->l2_ivlan_mask;
624 [ # # ]: 0 : if (enables & HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_SRC_ID)
625 : 0 : req.src_id = rte_cpu_to_le_32(filter->src_id);
626 [ # # ]: 0 : if (enables & HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_SRC_TYPE)
627 : 0 : req.src_type = filter->src_type;
628 [ # # ]: 0 : if (filter->pri_hint) {
629 : 0 : req.pri_hint = filter->pri_hint;
630 : 0 : req.l2_filter_id_hint =
631 : 0 : rte_cpu_to_le_64(filter->l2_filter_id_hint);
632 : : }
633 : :
634 : 0 : req.enables = rte_cpu_to_le_32(enables);
635 : :
636 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
637 : :
638 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
639 : :
640 : 0 : filter->fw_l2_filter_id = rte_le_to_cpu_64(resp->l2_filter_id);
641 : 0 : filter->flow_id = rte_le_to_cpu_32(resp->flow_id);
642 : : HWRM_UNLOCK();
643 : :
644 : 0 : filter->l2_ref_cnt++;
645 : :
646 : 0 : return rc;
647 : : }
648 : :
649 : 0 : int bnxt_hwrm_ptp_cfg(struct bnxt *bp)
650 : : {
651 : 0 : struct hwrm_port_mac_cfg_input req = {.req_type = 0};
652 : 0 : struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
653 : : uint32_t flags = 0;
654 : : int rc;
655 : :
656 [ # # ]: 0 : if (!ptp)
657 : : return 0;
658 : :
659 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_PORT_MAC_CFG, BNXT_USE_CHIMP_MB);
660 : :
661 [ # # ]: 0 : if (ptp->rx_filter)
662 : : flags |= HWRM_PORT_MAC_CFG_INPUT_FLAGS_PTP_RX_TS_CAPTURE_ENABLE;
663 : : else
664 : : flags |=
665 : : HWRM_PORT_MAC_CFG_INPUT_FLAGS_PTP_RX_TS_CAPTURE_DISABLE;
666 [ # # ]: 0 : if (ptp->tx_tstamp_en)
667 : 0 : flags |= HWRM_PORT_MAC_CFG_INPUT_FLAGS_PTP_TX_TS_CAPTURE_ENABLE;
668 : : else
669 : 0 : flags |=
670 : : HWRM_PORT_MAC_CFG_INPUT_FLAGS_PTP_TX_TS_CAPTURE_DISABLE;
671 : :
672 [ # # ]: 0 : if (ptp->filter_all)
673 : 0 : flags |= HWRM_PORT_MAC_CFG_INPUT_FLAGS_ALL_RX_TS_CAPTURE_ENABLE;
674 [ # # ]: 0 : else if (bp->fw_cap & BNXT_FW_CAP_RX_ALL_PKT_TS)
675 : 0 : flags |= HWRM_PORT_MAC_CFG_INPUT_FLAGS_ALL_RX_TS_CAPTURE_DISABLE;
676 : :
677 : 0 : req.flags = rte_cpu_to_le_32(flags);
678 : 0 : req.enables = rte_cpu_to_le_32
679 : : (HWRM_PORT_MAC_CFG_INPUT_ENABLES_RX_TS_CAPTURE_PTP_MSG_TYPE);
680 : 0 : req.rx_ts_capture_ptp_msg_type = rte_cpu_to_le_16(ptp->rxctl);
681 : :
682 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
683 : : HWRM_UNLOCK();
684 : :
685 : 0 : return rc;
686 : : }
687 : :
688 : 0 : static int bnxt_hwrm_ptp_qcfg(struct bnxt *bp)
689 : : {
690 : : int rc = 0;
691 : 0 : struct hwrm_port_mac_ptp_qcfg_input req = {.req_type = 0};
692 : 0 : struct hwrm_port_mac_ptp_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
693 : 0 : struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
694 : :
695 [ # # ]: 0 : if (ptp)
696 : : return 0;
697 : :
698 [ # # ]: 0 : HWRM_PREP(&req, HWRM_PORT_MAC_PTP_QCFG, BNXT_USE_CHIMP_MB);
699 : :
700 : 0 : req.port_id = rte_cpu_to_le_16(bp->pf->port_id);
701 : :
702 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
703 : :
704 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
705 : :
706 [ # # ]: 0 : if (BNXT_CHIP_P5(bp)) {
707 [ # # ]: 0 : if (!(resp->flags & HWRM_PORT_MAC_PTP_QCFG_OUTPUT_FLAGS_HWRM_ACCESS))
708 : : return 0;
709 : : } else {
710 [ # # ]: 0 : if (!(resp->flags & HWRM_PORT_MAC_PTP_QCFG_OUTPUT_FLAGS_DIRECT_ACCESS))
711 : : return 0;
712 : : }
713 : :
714 [ # # ]: 0 : if (resp->flags & HWRM_PORT_MAC_PTP_QCFG_OUTPUT_FLAGS_ONE_STEP_TX_TS)
715 : 0 : bp->flags |= BNXT_FLAG_FW_CAP_ONE_STEP_TX_TS;
716 : :
717 : 0 : ptp = rte_zmalloc("ptp_cfg", sizeof(*ptp), 0);
718 [ # # ]: 0 : if (!ptp)
719 : : return -ENOMEM;
720 : :
721 [ # # ]: 0 : if (!BNXT_CHIP_P5(bp)) {
722 : 0 : ptp->rx_regs[BNXT_PTP_RX_TS_L] =
723 : 0 : rte_le_to_cpu_32(resp->rx_ts_reg_off_lower);
724 : 0 : ptp->rx_regs[BNXT_PTP_RX_TS_H] =
725 : 0 : rte_le_to_cpu_32(resp->rx_ts_reg_off_upper);
726 : 0 : ptp->rx_regs[BNXT_PTP_RX_SEQ] =
727 : 0 : rte_le_to_cpu_32(resp->rx_ts_reg_off_seq_id);
728 : 0 : ptp->rx_regs[BNXT_PTP_RX_FIFO] =
729 : 0 : rte_le_to_cpu_32(resp->rx_ts_reg_off_fifo);
730 : 0 : ptp->rx_regs[BNXT_PTP_RX_FIFO_ADV] =
731 : 0 : rte_le_to_cpu_32(resp->rx_ts_reg_off_fifo_adv);
732 : 0 : ptp->tx_regs[BNXT_PTP_TX_TS_L] =
733 : 0 : rte_le_to_cpu_32(resp->tx_ts_reg_off_lower);
734 : 0 : ptp->tx_regs[BNXT_PTP_TX_TS_H] =
735 : 0 : rte_le_to_cpu_32(resp->tx_ts_reg_off_upper);
736 : 0 : ptp->tx_regs[BNXT_PTP_TX_SEQ] =
737 : 0 : rte_le_to_cpu_32(resp->tx_ts_reg_off_seq_id);
738 : 0 : ptp->tx_regs[BNXT_PTP_TX_FIFO] =
739 : 0 : rte_le_to_cpu_32(resp->tx_ts_reg_off_fifo);
740 : : }
741 : :
742 : 0 : ptp->bp = bp;
743 : 0 : bp->ptp_cfg = ptp;
744 : :
745 : 0 : return 0;
746 : : }
747 : :
748 : 0 : void bnxt_free_vf_info(struct bnxt *bp)
749 : : {
750 : : int i;
751 : :
752 [ # # ]: 0 : if (bp->pf == NULL)
753 : : return;
754 : :
755 [ # # ]: 0 : if (bp->pf->vf_info == NULL)
756 : : return;
757 : :
758 [ # # ]: 0 : for (i = 0; i < bp->pf->max_vfs; i++) {
759 : 0 : rte_free(bp->pf->vf_info[i].vlan_table);
760 : 0 : bp->pf->vf_info[i].vlan_table = NULL;
761 : 0 : rte_free(bp->pf->vf_info[i].vlan_as_table);
762 : 0 : bp->pf->vf_info[i].vlan_as_table = NULL;
763 : : }
764 : 0 : rte_free(bp->pf->vf_info);
765 : 0 : bp->pf->vf_info = NULL;
766 : : }
767 : :
768 : 0 : static int bnxt_alloc_vf_info(struct bnxt *bp, uint16_t max_vfs)
769 : : {
770 : 0 : struct bnxt_child_vf_info *vf_info = bp->pf->vf_info;
771 : : int i;
772 : :
773 [ # # ]: 0 : if (vf_info)
774 : 0 : bnxt_free_vf_info(bp);
775 : :
776 : 0 : vf_info = rte_zmalloc("bnxt_vf_info", sizeof(*vf_info) * max_vfs, 0);
777 [ # # ]: 0 : if (vf_info == NULL) {
778 : 0 : PMD_DRV_LOG(ERR, "Failed to alloc vf info\n");
779 : 0 : return -ENOMEM;
780 : : }
781 : :
782 : 0 : bp->pf->max_vfs = max_vfs;
783 [ # # ]: 0 : for (i = 0; i < max_vfs; i++) {
784 : 0 : vf_info[i].fid = bp->pf->first_vf_id + i;
785 : 0 : vf_info[i].vlan_table = rte_zmalloc("VF VLAN table",
786 : 0 : getpagesize(), getpagesize());
787 [ # # ]: 0 : if (vf_info[i].vlan_table == NULL) {
788 : 0 : PMD_DRV_LOG(ERR, "Failed to alloc VLAN table for VF %d\n", i);
789 : 0 : goto err;
790 : : }
791 : 0 : rte_mem_lock_page(vf_info[i].vlan_table);
792 : :
793 : 0 : vf_info[i].vlan_as_table = rte_zmalloc("VF VLAN AS table",
794 : : getpagesize(), getpagesize());
795 [ # # ]: 0 : if (vf_info[i].vlan_as_table == NULL) {
796 : 0 : PMD_DRV_LOG(ERR, "Failed to alloc VLAN AS table for VF %d\n", i);
797 : 0 : goto err;
798 : : }
799 : 0 : rte_mem_lock_page(vf_info[i].vlan_as_table);
800 : :
801 : 0 : STAILQ_INIT(&vf_info[i].filter);
802 : : }
803 : :
804 : 0 : bp->pf->vf_info = vf_info;
805 : :
806 : 0 : return 0;
807 : 0 : err:
808 : 0 : bnxt_free_vf_info(bp);
809 : 0 : return -ENOMEM;
810 : : }
811 : :
812 : 0 : static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
813 : : {
814 : : int rc = 0;
815 : 0 : struct hwrm_func_qcaps_input req = {.req_type = 0 };
816 : 0 : struct hwrm_func_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
817 : : uint16_t new_max_vfs;
818 : : uint32_t flags, flags_ext2;
819 : :
820 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_QCAPS, BNXT_USE_CHIMP_MB);
821 : :
822 : 0 : req.fid = rte_cpu_to_le_16(0xffff);
823 : :
824 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
825 : :
826 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
827 : :
828 : 0 : bp->max_ring_grps = rte_le_to_cpu_32(resp->max_hw_ring_grps);
829 : 0 : flags = rte_le_to_cpu_32(resp->flags);
830 [ # # ]: 0 : if (BNXT_PF(bp)) {
831 : 0 : bp->pf->port_id = resp->port_id;
832 : 0 : bp->pf->first_vf_id = rte_le_to_cpu_16(resp->first_vf_id);
833 : 0 : bp->pf->total_vfs = rte_le_to_cpu_16(resp->max_vfs);
834 : 0 : new_max_vfs = bp->pdev->max_vfs;
835 [ # # ]: 0 : if (new_max_vfs != bp->pf->max_vfs) {
836 : 0 : rc = bnxt_alloc_vf_info(bp, new_max_vfs);
837 [ # # ]: 0 : if (rc)
838 : 0 : goto unlock;
839 : : }
840 : : }
841 : :
842 : 0 : bp->fw_fid = rte_le_to_cpu_32(resp->fid);
843 [ # # ]: 0 : if (!bnxt_check_zero_bytes(resp->mac_address, RTE_ETHER_ADDR_LEN)) {
844 : 0 : bp->flags |= BNXT_FLAG_DFLT_MAC_SET;
845 : 0 : memcpy(bp->mac_addr, &resp->mac_address, RTE_ETHER_ADDR_LEN);
846 : : } else {
847 : 0 : bp->flags &= ~BNXT_FLAG_DFLT_MAC_SET;
848 : : }
849 : 0 : bp->max_rsscos_ctx = rte_le_to_cpu_16(resp->max_rsscos_ctx);
850 : 0 : bp->max_cp_rings = rte_le_to_cpu_16(resp->max_cmpl_rings);
851 : 0 : bp->max_tx_rings = rte_le_to_cpu_16(resp->max_tx_rings);
852 : 0 : bp->max_rx_rings = rte_le_to_cpu_16(resp->max_rx_rings);
853 : 0 : bp->first_vf_id = rte_le_to_cpu_16(resp->first_vf_id);
854 : 0 : bp->max_rx_em_flows = rte_le_to_cpu_16(resp->max_rx_em_flows);
855 : 0 : bp->max_l2_ctx = rte_le_to_cpu_16(resp->max_l2_ctxs);
856 [ # # # # ]: 0 : if (!BNXT_CHIP_P5(bp) && !bp->pdev->max_vfs)
857 : 0 : bp->max_l2_ctx += bp->max_rx_em_flows;
858 [ # # ]: 0 : if (bp->vnic_cap_flags & BNXT_VNIC_CAP_COS_CLASSIFY)
859 : 0 : bp->max_vnics = rte_le_to_cpu_16(BNXT_MAX_VNICS_COS_CLASSIFY);
860 : : else
861 : 0 : bp->max_vnics = rte_le_to_cpu_16(resp->max_vnics);
862 : 0 : PMD_DRV_LOG(DEBUG, "Max l2_cntxts is %d vnics is %d\n",
863 : : bp->max_l2_ctx, bp->max_vnics);
864 : 0 : bp->max_stat_ctx = rte_le_to_cpu_16(resp->max_stat_ctx);
865 : 0 : bp->max_mcast_addr = rte_le_to_cpu_32(resp->max_mcast_filters);
866 [ # # ]: 0 : memcpy(bp->dsn, resp->device_serial_number, sizeof(bp->dsn));
867 : :
868 [ # # ]: 0 : if (BNXT_PF(bp))
869 : 0 : bp->pf->total_vnics = rte_le_to_cpu_16(resp->max_vnics);
870 : :
871 [ # # ]: 0 : if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_PTP_SUPPORTED) {
872 [ # # ]: 0 : if (BNXT_CHIP_P5(bp) || BNXT_PF(bp)) {
873 : 0 : bp->flags |= BNXT_FLAG_PTP_SUPPORTED;
874 : 0 : PMD_DRV_LOG(DEBUG, "PTP SUPPORTED\n");
875 : : HWRM_UNLOCK();
876 : 0 : bnxt_hwrm_ptp_qcfg(bp);
877 : : }
878 : : }
879 : :
880 [ # # ]: 0 : if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_STATS_SUPPORTED)
881 : 0 : bp->flags |= BNXT_FLAG_EXT_STATS_SUPPORTED;
882 : :
883 [ # # ]: 0 : if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ERROR_RECOVERY_CAPABLE) {
884 : 0 : bp->fw_cap |= BNXT_FW_CAP_ERROR_RECOVERY;
885 : 0 : PMD_DRV_LOG(DEBUG, "Adapter Error recovery SUPPORTED\n");
886 : : }
887 : :
888 [ # # ]: 0 : if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ERR_RECOVER_RELOAD)
889 : 0 : bp->fw_cap |= BNXT_FW_CAP_ERR_RECOVER_RELOAD;
890 : :
891 [ # # ]: 0 : if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_HOT_RESET_CAPABLE)
892 : 0 : bp->fw_cap |= BNXT_FW_CAP_HOT_RESET;
893 : :
894 [ # # ]: 0 : if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_LINK_ADMIN_STATUS_SUPPORTED)
895 : 0 : bp->fw_cap |= BNXT_FW_CAP_LINK_ADMIN;
896 : :
897 [ # # ]: 0 : if (!(flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_VLAN_ACCELERATION_TX_DISABLED)) {
898 : 0 : bp->fw_cap |= BNXT_FW_CAP_VLAN_TX_INSERT;
899 : 0 : PMD_DRV_LOG(DEBUG, "VLAN acceleration for TX is enabled\n");
900 : : }
901 : :
902 : 0 : bp->tunnel_disable_flag = rte_le_to_cpu_16(resp->tunnel_disable_flag);
903 [ # # ]: 0 : if (bp->tunnel_disable_flag)
904 : 0 : PMD_DRV_LOG(DEBUG, "Tunnel parsing capability is disabled, flags : %#x\n",
905 : : bp->tunnel_disable_flag);
906 : :
907 : 0 : flags_ext2 = rte_le_to_cpu_32(resp->flags_ext2);
908 [ # # ]: 0 : if (flags_ext2 & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_RX_ALL_PKTS_TIMESTAMPS_SUPPORTED)
909 : 0 : bp->fw_cap |= BNXT_FW_CAP_RX_ALL_PKT_TS;
910 : :
911 : 0 : unlock:
912 : : HWRM_UNLOCK();
913 : :
914 : 0 : return rc;
915 : : }
916 : :
917 : 0 : int bnxt_hwrm_func_qcaps(struct bnxt *bp)
918 : : {
919 : : int rc;
920 : :
921 : 0 : rc = __bnxt_hwrm_func_qcaps(bp);
922 [ # # ]: 0 : if (rc == -ENOMEM)
923 : : return rc;
924 : :
925 [ # # # # ]: 0 : if (!rc && bp->hwrm_spec_code >= HWRM_SPEC_CODE_1_8_3) {
926 : 0 : rc = bnxt_alloc_ctx_mem(bp);
927 [ # # ]: 0 : if (rc)
928 : : return rc;
929 : :
930 : : /* On older FW,
931 : : * bnxt_hwrm_func_resc_qcaps can fail and cause init failure.
932 : : * But the error can be ignored. Return success.
933 : : */
934 : 0 : rc = bnxt_hwrm_func_resc_qcaps(bp);
935 [ # # ]: 0 : if (!rc)
936 : 0 : bp->flags |= BNXT_FLAG_NEW_RM;
937 : : }
938 : :
939 : : return 0;
940 : : }
941 : :
942 : : /* VNIC cap covers capability of all VNICs. So no need to pass vnic_id */
943 : 0 : int bnxt_hwrm_vnic_qcaps(struct bnxt *bp)
944 : : {
945 : : int rc = 0;
946 : : uint32_t flags;
947 : 0 : struct hwrm_vnic_qcaps_input req = {.req_type = 0 };
948 : 0 : struct hwrm_vnic_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
949 : :
950 [ # # ]: 0 : HWRM_PREP(&req, HWRM_VNIC_QCAPS, BNXT_USE_CHIMP_MB);
951 : :
952 : : req.target_id = rte_cpu_to_le_16(0xffff);
953 : :
954 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
955 : :
956 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
957 : :
958 : 0 : flags = rte_le_to_cpu_32(resp->flags);
959 : :
960 [ # # ]: 0 : if (flags & HWRM_VNIC_QCAPS_OUTPUT_FLAGS_COS_ASSIGNMENT_CAP) {
961 : 0 : bp->vnic_cap_flags |= BNXT_VNIC_CAP_COS_CLASSIFY;
962 : 0 : PMD_DRV_LOG(INFO, "CoS assignment capability enabled\n");
963 : : }
964 : :
965 [ # # ]: 0 : if (flags & HWRM_VNIC_QCAPS_OUTPUT_FLAGS_OUTERMOST_RSS_CAP)
966 : 0 : bp->vnic_cap_flags |= BNXT_VNIC_CAP_OUTER_RSS;
967 : :
968 [ # # ]: 0 : if (flags & HWRM_VNIC_QCAPS_OUTPUT_FLAGS_OUTERMOST_RSS_TRUSTED_VF_CAP) {
969 : 0 : bp->vnic_cap_flags |= BNXT_VNIC_CAP_OUTER_RSS_TRUSTED_VF;
970 : 0 : PMD_DRV_LOG(DEBUG, "Trusted VF's outer RSS capability is enabled\n");
971 : : }
972 : :
973 [ # # ]: 0 : if (flags & HWRM_VNIC_QCAPS_OUTPUT_FLAGS_RX_CMPL_V2_CAP)
974 : 0 : bp->vnic_cap_flags |= BNXT_VNIC_CAP_RX_CMPL_V2;
975 : :
976 [ # # ]: 0 : if (flags & HWRM_VNIC_QCAPS_OUTPUT_FLAGS_VLAN_STRIP_CAP) {
977 : 0 : bp->vnic_cap_flags |= BNXT_VNIC_CAP_VLAN_RX_STRIP;
978 : 0 : PMD_DRV_LOG(DEBUG, "Rx VLAN strip capability enabled\n");
979 : : }
980 : :
981 : 0 : bp->max_tpa_v2 = rte_le_to_cpu_16(resp->max_aggs_supported);
982 : :
983 : : HWRM_UNLOCK();
984 : :
985 : 0 : return rc;
986 : : }
987 : :
988 : 0 : int bnxt_hwrm_func_reset(struct bnxt *bp)
989 : : {
990 : : int rc = 0;
991 : 0 : struct hwrm_func_reset_input req = {.req_type = 0 };
992 : 0 : struct hwrm_func_reset_output *resp = bp->hwrm_cmd_resp_addr;
993 : :
994 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_RESET, BNXT_USE_CHIMP_MB);
995 : :
996 : 0 : req.enables = rte_cpu_to_le_32(0);
997 : :
998 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
999 : :
1000 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
1001 : : HWRM_UNLOCK();
1002 : :
1003 : 0 : return rc;
1004 : : }
1005 : :
1006 : 0 : int bnxt_hwrm_func_driver_register(struct bnxt *bp)
1007 : : {
1008 : : int rc;
1009 : : uint32_t flags = 0;
1010 : 0 : struct hwrm_func_drv_rgtr_input req = {.req_type = 0 };
1011 : 0 : struct hwrm_func_drv_rgtr_output *resp = bp->hwrm_cmd_resp_addr;
1012 : :
1013 [ # # ]: 0 : if (bp->flags & BNXT_FLAG_REGISTERED)
1014 : : return 0;
1015 : :
1016 [ # # ]: 0 : if (bp->fw_cap & BNXT_FW_CAP_HOT_RESET)
1017 : : flags = HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_HOT_RESET_SUPPORT;
1018 [ # # ]: 0 : if (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)
1019 : 0 : flags |= HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_ERROR_RECOVERY_SUPPORT;
1020 : :
1021 : : /* PFs and trusted VFs should indicate the support of the
1022 : : * Master capability on non Stingray platform
1023 : : */
1024 [ # # # # ]: 0 : if ((BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp)) && !BNXT_STINGRAY(bp))
1025 : 0 : flags |= HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_MASTER_SUPPORT;
1026 : :
1027 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_DRV_RGTR, BNXT_USE_CHIMP_MB);
1028 : 0 : req.enables = rte_cpu_to_le_32(HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_VER |
1029 : : HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_ASYNC_EVENT_FWD);
1030 : 0 : req.ver_maj_8b = RTE_VER_YEAR;
1031 : 0 : req.ver_min_8b = RTE_VER_MONTH;
1032 : 0 : req.ver_upd_8b = RTE_VER_MINOR;
1033 : :
1034 [ # # ]: 0 : if (BNXT_PF(bp)) {
1035 : 0 : req.enables |= rte_cpu_to_le_32(
1036 : : HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_VF_REQ_FWD);
1037 : 0 : memcpy(req.vf_req_fwd, bp->pf->vf_req_fwd,
1038 : : RTE_MIN(sizeof(req.vf_req_fwd),
1039 : : sizeof(bp->pf->vf_req_fwd)));
1040 : : }
1041 : :
1042 : 0 : req.flags = rte_cpu_to_le_32(flags);
1043 : :
1044 : 0 : req.async_event_fwd[0] |=
1045 : : rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_LINK_STATUS_CHANGE |
1046 : : ASYNC_CMPL_EVENT_ID_PORT_CONN_NOT_ALLOWED |
1047 : : ASYNC_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE |
1048 : : ASYNC_CMPL_EVENT_ID_LINK_SPEED_CHANGE |
1049 : : ASYNC_CMPL_EVENT_ID_RESET_NOTIFY);
1050 [ # # ]: 0 : if (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)
1051 : 0 : req.async_event_fwd[0] |=
1052 : : rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_ERROR_RECOVERY);
1053 : 0 : req.async_event_fwd[1] |=
1054 : : rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_PF_DRVR_UNLOAD |
1055 : : ASYNC_CMPL_EVENT_ID_VF_CFG_CHANGE);
1056 [ # # ]: 0 : if (BNXT_PF(bp))
1057 : 0 : req.async_event_fwd[1] |=
1058 : : rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_DBG_NOTIFICATION);
1059 : :
1060 [ # # ]: 0 : if (BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))
1061 : 0 : req.async_event_fwd[1] |=
1062 : : rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_DEFAULT_VNIC_CHANGE);
1063 : :
1064 : 0 : req.async_event_fwd[2] |=
1065 : : rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_ECHO_REQUEST |
1066 : : ASYNC_CMPL_EVENT_ID_ERROR_REPORT);
1067 : :
1068 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1069 : :
1070 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
1071 : :
1072 : 0 : flags = rte_le_to_cpu_32(resp->flags);
1073 [ # # ]: 0 : if (flags & HWRM_FUNC_DRV_RGTR_OUTPUT_FLAGS_IF_CHANGE_SUPPORTED)
1074 : 0 : bp->fw_cap |= BNXT_FW_CAP_IF_CHANGE;
1075 : :
1076 : : HWRM_UNLOCK();
1077 : :
1078 : 0 : bp->flags |= BNXT_FLAG_REGISTERED;
1079 : :
1080 : 0 : return rc;
1081 : : }
1082 : :
1083 : 0 : int bnxt_hwrm_check_vf_rings(struct bnxt *bp)
1084 : : {
1085 [ # # ]: 0 : if (!(BNXT_VF(bp) && (bp->flags & BNXT_FLAG_NEW_RM)))
1086 : : return 0;
1087 : :
1088 : 0 : return bnxt_hwrm_func_reserve_vf_resc(bp, true);
1089 : : }
1090 : :
1091 : 0 : int bnxt_hwrm_func_reserve_vf_resc(struct bnxt *bp, bool test)
1092 : : {
1093 : : int rc;
1094 : : uint32_t flags = 0;
1095 : : uint32_t enables;
1096 : 0 : struct hwrm_func_vf_cfg_output *resp = bp->hwrm_cmd_resp_addr;
1097 : 0 : struct hwrm_func_vf_cfg_input req = {0};
1098 : :
1099 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_VF_CFG, BNXT_USE_CHIMP_MB);
1100 : :
1101 : : enables = HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_RX_RINGS |
1102 : : HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_TX_RINGS |
1103 : : HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_STAT_CTXS |
1104 : : HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_CMPL_RINGS |
1105 : : HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_VNICS;
1106 : :
1107 [ # # ]: 0 : if (BNXT_HAS_RING_GRPS(bp)) {
1108 : : enables |= HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_HW_RING_GRPS;
1109 : 0 : req.num_hw_ring_grps = rte_cpu_to_le_16(bp->rx_nr_rings);
1110 : : }
1111 : :
1112 : 0 : req.num_tx_rings = rte_cpu_to_le_16(bp->tx_nr_rings);
1113 : 0 : req.num_rx_rings = rte_cpu_to_le_16(bp->rx_nr_rings *
1114 : : AGG_RING_MULTIPLIER);
1115 : 0 : req.num_stat_ctxs = rte_cpu_to_le_16(bp->rx_nr_rings + bp->tx_nr_rings);
1116 : 0 : req.num_cmpl_rings = rte_cpu_to_le_16(bp->rx_nr_rings +
1117 : : bp->tx_nr_rings +
1118 : : BNXT_NUM_ASYNC_CPR(bp));
1119 [ # # ]: 0 : if (BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp)) {
1120 : 0 : req.num_vnics = rte_cpu_to_le_16(RTE_MIN(BNXT_VNIC_MAX_SUPPORTED_ID,
1121 : : bp->max_vnics));
1122 : 0 : enables |= HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_RSSCOS_CTXS;
1123 : 0 : req.num_rsscos_ctxs = rte_cpu_to_le_16(RTE_MIN(BNXT_VNIC_MAX_SUPPORTED_ID,
1124 : : bp->max_rsscos_ctx));
1125 : : } else {
1126 : 0 : req.num_vnics = rte_cpu_to_le_16(bp->rx_nr_rings);
1127 : : }
1128 : :
1129 [ # # ]: 0 : if (bp->vf_resv_strategy ==
1130 : : HWRM_FUNC_RESOURCE_QCAPS_OUTPUT_VF_RESV_STRATEGY_MINIMAL_STATIC) {
1131 : 0 : enables |= HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_VNICS |
1132 : : HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_L2_CTXS |
1133 : : HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_RSSCOS_CTXS;
1134 : 0 : req.num_rsscos_ctxs = rte_cpu_to_le_16(BNXT_VF_RSV_NUM_RSS_CTX);
1135 : 0 : req.num_l2_ctxs = rte_cpu_to_le_16(BNXT_VF_RSV_NUM_L2_CTX);
1136 : 0 : req.num_vnics = rte_cpu_to_le_16(BNXT_VF_RSV_NUM_VNIC);
1137 [ # # ]: 0 : } else if (bp->vf_resv_strategy ==
1138 : : HWRM_FUNC_RESOURCE_QCAPS_OUTPUT_VF_RESV_STRATEGY_MAXIMAL) {
1139 : 0 : enables |= HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_RSSCOS_CTXS;
1140 : 0 : req.num_rsscos_ctxs = rte_cpu_to_le_16(bp->max_rsscos_ctx);
1141 : : }
1142 : :
1143 [ # # ]: 0 : if (test)
1144 : : flags = HWRM_FUNC_VF_CFG_INPUT_FLAGS_TX_ASSETS_TEST |
1145 : : HWRM_FUNC_VF_CFG_INPUT_FLAGS_RX_ASSETS_TEST |
1146 : : HWRM_FUNC_VF_CFG_INPUT_FLAGS_CMPL_ASSETS_TEST |
1147 : : HWRM_FUNC_VF_CFG_INPUT_FLAGS_RING_GRP_ASSETS_TEST |
1148 : : HWRM_FUNC_VF_CFG_INPUT_FLAGS_STAT_CTX_ASSETS_TEST |
1149 : : HWRM_FUNC_VF_CFG_INPUT_FLAGS_VNIC_ASSETS_TEST;
1150 : :
1151 [ # # # # ]: 0 : if (test && BNXT_HAS_RING_GRPS(bp))
1152 : 0 : flags |= HWRM_FUNC_VF_CFG_INPUT_FLAGS_RING_GRP_ASSETS_TEST;
1153 : :
1154 : 0 : req.flags = rte_cpu_to_le_32(flags);
1155 : 0 : req.enables |= rte_cpu_to_le_32(enables);
1156 : :
1157 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1158 : :
1159 [ # # ]: 0 : if (test)
1160 [ # # # # ]: 0 : HWRM_CHECK_RESULT_SILENT();
1161 : : else
1162 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
1163 : :
1164 : : HWRM_UNLOCK();
1165 : 0 : return rc;
1166 : : }
1167 : :
1168 : 0 : int bnxt_hwrm_func_resc_qcaps(struct bnxt *bp)
1169 : : {
1170 : : int rc;
1171 : 0 : struct hwrm_func_resource_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
1172 : 0 : struct hwrm_func_resource_qcaps_input req = {0};
1173 : :
1174 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_RESOURCE_QCAPS, BNXT_USE_CHIMP_MB);
1175 : 0 : req.fid = rte_cpu_to_le_16(0xffff);
1176 : :
1177 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1178 : :
1179 [ # # # # ]: 0 : HWRM_CHECK_RESULT_SILENT();
1180 : :
1181 : 0 : bp->max_rsscos_ctx = rte_le_to_cpu_16(resp->max_rsscos_ctx);
1182 : 0 : bp->max_cp_rings = rte_le_to_cpu_16(resp->max_cmpl_rings);
1183 : 0 : bp->max_tx_rings = rte_le_to_cpu_16(resp->max_tx_rings);
1184 : 0 : bp->max_rx_rings = rte_le_to_cpu_16(resp->max_rx_rings);
1185 : 0 : bp->max_ring_grps = rte_le_to_cpu_32(resp->max_hw_ring_grps);
1186 : : /* func_resource_qcaps does not return max_rx_em_flows.
1187 : : * So use the value provided by func_qcaps.
1188 : : */
1189 : 0 : bp->max_l2_ctx = rte_le_to_cpu_16(resp->max_l2_ctxs);
1190 [ # # # # ]: 0 : if (!BNXT_CHIP_P5(bp) && !bp->pdev->max_vfs)
1191 : 0 : bp->max_l2_ctx += bp->max_rx_em_flows;
1192 [ # # ]: 0 : if (bp->vnic_cap_flags & BNXT_VNIC_CAP_COS_CLASSIFY)
1193 : 0 : bp->max_vnics = rte_le_to_cpu_16(BNXT_MAX_VNICS_COS_CLASSIFY);
1194 : : else
1195 : 0 : bp->max_vnics = rte_le_to_cpu_16(resp->max_vnics);
1196 : 0 : bp->max_stat_ctx = rte_le_to_cpu_16(resp->max_stat_ctx);
1197 : 0 : bp->max_nq_rings = rte_le_to_cpu_16(resp->max_msix);
1198 : 0 : bp->vf_resv_strategy = rte_le_to_cpu_16(resp->vf_reservation_strategy);
1199 [ # # ]: 0 : if (bp->vf_resv_strategy >
1200 : : HWRM_FUNC_RESOURCE_QCAPS_OUTPUT_VF_RESV_STRATEGY_MINIMAL_STATIC)
1201 : 0 : bp->vf_resv_strategy =
1202 : : HWRM_FUNC_RESOURCE_QCAPS_OUTPUT_VF_RESERVATION_STRATEGY_MAXIMAL;
1203 : :
1204 : : HWRM_UNLOCK();
1205 : 0 : return rc;
1206 : : }
1207 : :
1208 : 0 : int bnxt_hwrm_ver_get(struct bnxt *bp, uint32_t timeout)
1209 : : {
1210 : : int rc = 0;
1211 : 0 : struct hwrm_ver_get_input req = {.req_type = 0 };
1212 : 0 : struct hwrm_ver_get_output *resp = bp->hwrm_cmd_resp_addr;
1213 : : uint32_t fw_version;
1214 : : uint16_t max_resp_len;
1215 : : char type[RTE_MEMZONE_NAMESIZE];
1216 : : uint32_t dev_caps_cfg;
1217 : :
1218 : 0 : bp->max_req_len = HWRM_MAX_REQ_LEN;
1219 : 0 : bp->hwrm_cmd_timeout = timeout;
1220 [ # # ]: 0 : HWRM_PREP(&req, HWRM_VER_GET, BNXT_USE_CHIMP_MB);
1221 : :
1222 : 0 : req.hwrm_intf_maj = HWRM_VERSION_MAJOR;
1223 : 0 : req.hwrm_intf_min = HWRM_VERSION_MINOR;
1224 : 0 : req.hwrm_intf_upd = HWRM_VERSION_UPDATE;
1225 : :
1226 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1227 : :
1228 [ # # ]: 0 : if (bp->flags & BNXT_FLAG_FW_RESET)
1229 [ # # # # ]: 0 : HWRM_CHECK_RESULT_SILENT();
1230 : : else
1231 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
1232 : :
1233 : 0 : PMD_DRV_LOG(INFO, "%d.%d.%d:%d.%d.%d.%d\n",
1234 : : resp->hwrm_intf_maj_8b, resp->hwrm_intf_min_8b,
1235 : : resp->hwrm_intf_upd_8b, resp->hwrm_fw_maj_8b,
1236 : : resp->hwrm_fw_min_8b, resp->hwrm_fw_bld_8b,
1237 : : resp->hwrm_fw_rsvd_8b);
1238 : 0 : bp->fw_ver = ((uint32_t)resp->hwrm_fw_maj_8b << 24) |
1239 : 0 : ((uint32_t)resp->hwrm_fw_min_8b << 16) |
1240 : 0 : ((uint32_t)resp->hwrm_fw_bld_8b << 8) |
1241 : 0 : resp->hwrm_fw_rsvd_8b;
1242 : 0 : PMD_DRV_LOG(INFO, "Driver HWRM version: %d.%d.%d\n",
1243 : : HWRM_VERSION_MAJOR, HWRM_VERSION_MINOR, HWRM_VERSION_UPDATE);
1244 : :
1245 : 0 : fw_version = resp->hwrm_intf_maj_8b << 16;
1246 : 0 : fw_version |= resp->hwrm_intf_min_8b << 8;
1247 : 0 : fw_version |= resp->hwrm_intf_upd_8b;
1248 : 0 : bp->hwrm_spec_code = fw_version;
1249 : :
1250 : : /* def_req_timeout value is in milliseconds */
1251 : 0 : bp->hwrm_cmd_timeout = rte_le_to_cpu_16(resp->def_req_timeout);
1252 : : /* convert timeout to usec */
1253 : 0 : bp->hwrm_cmd_timeout *= 1000;
1254 [ # # ]: 0 : if (!bp->hwrm_cmd_timeout)
1255 : 0 : bp->hwrm_cmd_timeout = DFLT_HWRM_CMD_TIMEOUT;
1256 : :
1257 [ # # ]: 0 : if (resp->hwrm_intf_maj_8b != HWRM_VERSION_MAJOR) {
1258 : 0 : PMD_DRV_LOG(ERR, "Unsupported firmware API version\n");
1259 : : rc = -EINVAL;
1260 : 0 : goto error;
1261 : : }
1262 : :
1263 [ # # ]: 0 : if (bp->max_req_len > resp->max_req_win_len) {
1264 : 0 : PMD_DRV_LOG(ERR, "Unsupported request length\n");
1265 : : rc = -EINVAL;
1266 : 0 : goto error;
1267 : : }
1268 : :
1269 : 0 : bp->chip_num = rte_le_to_cpu_16(resp->chip_num);
1270 : :
1271 : 0 : bp->max_req_len = rte_le_to_cpu_16(resp->max_req_win_len);
1272 : 0 : bp->hwrm_max_ext_req_len = rte_le_to_cpu_16(resp->max_ext_req_len);
1273 [ # # ]: 0 : if (bp->hwrm_max_ext_req_len < HWRM_MAX_REQ_LEN)
1274 : 0 : bp->hwrm_max_ext_req_len = HWRM_MAX_REQ_LEN;
1275 : :
1276 : 0 : max_resp_len = rte_le_to_cpu_16(resp->max_resp_len);
1277 : 0 : dev_caps_cfg = rte_le_to_cpu_32(resp->dev_caps_cfg);
1278 : :
1279 [ # # ]: 0 : RTE_VERIFY(max_resp_len <= bp->max_resp_len);
1280 : 0 : bp->max_resp_len = max_resp_len;
1281 : :
1282 : 0 : if ((dev_caps_cfg &
1283 [ # # ]: 0 : HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_SHORT_CMD_SUPPORTED) &&
1284 : : (dev_caps_cfg &
1285 : : HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_SHORT_CMD_REQUIRED)) {
1286 : 0 : PMD_DRV_LOG(DEBUG, "Short command supported\n");
1287 : 0 : bp->flags |= BNXT_FLAG_SHORT_CMD;
1288 : : }
1289 : :
1290 [ # # ]: 0 : if (((dev_caps_cfg &
1291 : : HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_SHORT_CMD_SUPPORTED) &&
1292 : : (dev_caps_cfg &
1293 : 0 : HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_SHORT_CMD_REQUIRED)) ||
1294 [ # # ]: 0 : bp->hwrm_max_ext_req_len > HWRM_MAX_REQ_LEN) {
1295 : 0 : sprintf(type, "bnxt_hwrm_short_" PCI_PRI_FMT,
1296 : 0 : bp->pdev->addr.domain, bp->pdev->addr.bus,
1297 : 0 : bp->pdev->addr.devid, bp->pdev->addr.function);
1298 : :
1299 : 0 : rte_free(bp->hwrm_short_cmd_req_addr);
1300 : :
1301 : 0 : bp->hwrm_short_cmd_req_addr =
1302 : 0 : rte_malloc(type, bp->hwrm_max_ext_req_len, 0);
1303 [ # # ]: 0 : if (bp->hwrm_short_cmd_req_addr == NULL) {
1304 : : rc = -ENOMEM;
1305 : 0 : goto error;
1306 : : }
1307 : 0 : bp->hwrm_short_cmd_req_dma_addr =
1308 : 0 : rte_malloc_virt2iova(bp->hwrm_short_cmd_req_addr);
1309 [ # # ]: 0 : if (bp->hwrm_short_cmd_req_dma_addr == RTE_BAD_IOVA) {
1310 : 0 : rte_free(bp->hwrm_short_cmd_req_addr);
1311 : 0 : PMD_DRV_LOG(ERR,
1312 : : "Unable to map buffer to physical memory.\n");
1313 : : rc = -ENOMEM;
1314 : 0 : goto error;
1315 : : }
1316 : : }
1317 [ # # ]: 0 : if (dev_caps_cfg &
1318 : : HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_KONG_MB_CHNL_SUPPORTED) {
1319 : 0 : bp->flags |= BNXT_FLAG_KONG_MB_EN;
1320 : 0 : PMD_DRV_LOG(DEBUG, "Kong mailbox channel enabled\n");
1321 : : }
1322 [ # # ]: 0 : if (dev_caps_cfg &
1323 : : HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_TRUSTED_VF_SUPPORTED)
1324 : 0 : PMD_DRV_LOG(DEBUG, "FW supports Trusted VFs\n");
1325 [ # # ]: 0 : if (dev_caps_cfg &
1326 : : HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_CFA_ADV_FLOW_MGNT_SUPPORTED) {
1327 : 0 : bp->fw_cap |= BNXT_FW_CAP_ADV_FLOW_MGMT;
1328 : 0 : PMD_DRV_LOG(DEBUG, "FW supports advanced flow management\n");
1329 : : }
1330 : :
1331 [ # # ]: 0 : if (dev_caps_cfg &
1332 : : HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_ADV_FLOW_COUNTERS_SUPPORTED) {
1333 : 0 : PMD_DRV_LOG(DEBUG, "FW supports advanced flow counters\n");
1334 : 0 : bp->fw_cap |= BNXT_FW_CAP_ADV_FLOW_COUNTERS;
1335 : : }
1336 : :
1337 [ # # ]: 0 : if (dev_caps_cfg &
1338 : : HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_CFA_TRUFLOW_SUPPORTED) {
1339 : 0 : PMD_DRV_LOG(DEBUG, "Host-based truflow feature enabled.\n");
1340 : 0 : bp->fw_cap |= BNXT_FW_CAP_TRUFLOW_EN;
1341 : : }
1342 : :
1343 : 0 : error:
1344 : : HWRM_UNLOCK();
1345 : 0 : return rc;
1346 : : }
1347 : :
1348 : 0 : int bnxt_hwrm_func_driver_unregister(struct bnxt *bp)
1349 : : {
1350 : : int rc;
1351 : 0 : struct hwrm_func_drv_unrgtr_input req = {.req_type = 0 };
1352 : 0 : struct hwrm_func_drv_unrgtr_output *resp = bp->hwrm_cmd_resp_addr;
1353 : :
1354 [ # # ]: 0 : if (!(bp->flags & BNXT_FLAG_REGISTERED))
1355 : : return 0;
1356 : :
1357 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_DRV_UNRGTR, BNXT_USE_CHIMP_MB);
1358 : :
1359 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1360 : :
1361 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
1362 : : HWRM_UNLOCK();
1363 : :
1364 : 0 : PMD_DRV_LOG(DEBUG, "Port %u: Unregistered with fw\n",
1365 : : bp->eth_dev->data->port_id);
1366 : :
1367 : 0 : return rc;
1368 : : }
1369 : :
1370 : 0 : static int bnxt_hwrm_port_phy_cfg(struct bnxt *bp, struct bnxt_link_info *conf)
1371 : : {
1372 : : int rc = 0;
1373 : 0 : struct hwrm_port_phy_cfg_input req = {0};
1374 : 0 : struct hwrm_port_phy_cfg_output *resp = bp->hwrm_cmd_resp_addr;
1375 : : uint32_t enables = 0;
1376 : :
1377 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_PORT_PHY_CFG, BNXT_USE_CHIMP_MB);
1378 : :
1379 [ # # ]: 0 : if (conf->link_up) {
1380 : : /* Setting Fixed Speed. But AutoNeg is ON, So disable it */
1381 [ # # # # ]: 0 : if (bp->link_info->auto_mode && conf->link_speed) {
1382 : 0 : req.auto_mode = HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_NONE;
1383 : 0 : PMD_DRV_LOG(DEBUG, "Disabling AutoNeg\n");
1384 : : }
1385 : :
1386 : 0 : req.flags = rte_cpu_to_le_32(conf->phy_flags);
1387 : : /*
1388 : : * Note, ChiMP FW 20.2.1 and 20.2.2 return an error when we set
1389 : : * any auto mode, even "none".
1390 : : */
1391 [ # # ]: 0 : if (!conf->link_speed) {
1392 : : /* No speeds specified. Enable AutoNeg - all speeds */
1393 : : enables |= HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_MODE;
1394 : 0 : req.auto_mode =
1395 : : HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_ALL_SPEEDS;
1396 : : } else {
1397 [ # # ]: 0 : if (bp->link_info->link_signal_mode) {
1398 : : enables |=
1399 : : HWRM_PORT_PHY_CFG_IN_EN_FORCE_PAM4_LINK_SPEED;
1400 : 0 : req.force_pam4_link_speed =
1401 : : rte_cpu_to_le_16(conf->link_speed);
1402 : : } else {
1403 : 0 : req.force_link_speed =
1404 : : rte_cpu_to_le_16(conf->link_speed);
1405 : : }
1406 : : }
1407 : : /* AutoNeg - Advertise speeds specified. */
1408 [ # # # # ]: 0 : if ((conf->auto_link_speed_mask || conf->auto_pam4_link_speed_mask) &&
1409 [ # # ]: 0 : !(conf->phy_flags & HWRM_PORT_PHY_CFG_INPUT_FLAGS_FORCE)) {
1410 : 0 : req.auto_mode =
1411 : : HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_SPEED_MASK;
1412 [ # # ]: 0 : if (conf->auto_pam4_link_speed_mask) {
1413 : 0 : enables |=
1414 : : HWRM_PORT_PHY_CFG_IN_EN_AUTO_PAM4_LINK_SPD_MASK;
1415 : 0 : req.auto_link_pam4_speed_mask =
1416 : : rte_cpu_to_le_16(conf->auto_pam4_link_speed_mask);
1417 : : }
1418 [ # # ]: 0 : if (conf->auto_link_speed_mask) {
1419 : 0 : enables |=
1420 : : HWRM_PORT_PHY_CFG_IN_EN_AUTO_LINK_SPEED_MASK;
1421 : 0 : req.auto_link_speed_mask =
1422 : : rte_cpu_to_le_16(conf->auto_link_speed_mask);
1423 : : }
1424 : : }
1425 [ # # ]: 0 : if (conf->auto_link_speed &&
1426 [ # # ]: 0 : !(conf->phy_flags & HWRM_PORT_PHY_CFG_INPUT_FLAGS_FORCE))
1427 : 0 : enables |=
1428 : : HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_LINK_SPEED;
1429 : :
1430 : 0 : req.auto_duplex = conf->duplex;
1431 : : enables |= HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_DUPLEX;
1432 : 0 : req.auto_pause = conf->auto_pause;
1433 : 0 : req.force_pause = conf->force_pause;
1434 : : /* Set force_pause if there is no auto or if there is a force */
1435 [ # # # # ]: 0 : if (req.auto_pause && !req.force_pause)
1436 : 0 : enables |= HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_PAUSE;
1437 : : else
1438 : 0 : enables |= HWRM_PORT_PHY_CFG_INPUT_ENABLES_FORCE_PAUSE;
1439 : :
1440 : 0 : req.enables = rte_cpu_to_le_32(enables);
1441 : : } else {
1442 : 0 : req.flags =
1443 : : rte_cpu_to_le_32(HWRM_PORT_PHY_CFG_INPUT_FLAGS_FORCE_LINK_DWN);
1444 : 0 : PMD_DRV_LOG(INFO, "Force Link Down\n");
1445 : : }
1446 : :
1447 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1448 : :
1449 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
1450 : : HWRM_UNLOCK();
1451 : :
1452 : 0 : return rc;
1453 : : }
1454 : :
1455 : 0 : static int bnxt_hwrm_port_phy_qcfg(struct bnxt *bp,
1456 : : struct bnxt_link_info *link_info)
1457 : : {
1458 : : int rc = 0;
1459 : 0 : struct hwrm_port_phy_qcfg_input req = {0};
1460 : 0 : struct hwrm_port_phy_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
1461 : :
1462 [ # # ]: 0 : HWRM_PREP(&req, HWRM_PORT_PHY_QCFG, BNXT_USE_CHIMP_MB);
1463 : :
1464 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1465 : :
1466 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
1467 : :
1468 : 0 : link_info->phy_link_status = resp->link;
1469 : 0 : link_info->link_up =
1470 : : (link_info->phy_link_status ==
1471 : 0 : HWRM_PORT_PHY_QCFG_OUTPUT_LINK_LINK) ? 1 : 0;
1472 : 0 : link_info->link_speed = rte_le_to_cpu_16(resp->link_speed);
1473 : 0 : link_info->duplex = resp->duplex_cfg;
1474 : 0 : link_info->pause = resp->pause;
1475 : 0 : link_info->auto_pause = resp->auto_pause;
1476 : 0 : link_info->force_pause = resp->force_pause;
1477 : 0 : link_info->auto_mode = resp->auto_mode;
1478 : 0 : link_info->phy_type = resp->phy_type;
1479 : 0 : link_info->media_type = resp->media_type;
1480 : :
1481 : 0 : link_info->support_speeds = rte_le_to_cpu_16(resp->support_speeds);
1482 : 0 : link_info->auto_link_speed = rte_le_to_cpu_16(resp->auto_link_speed);
1483 : 0 : link_info->auto_link_speed_mask = rte_le_to_cpu_16(resp->auto_link_speed_mask);
1484 : 0 : link_info->preemphasis = rte_le_to_cpu_32(resp->preemphasis);
1485 : 0 : link_info->force_link_speed = rte_le_to_cpu_16(resp->force_link_speed);
1486 : 0 : link_info->phy_ver[0] = resp->phy_maj;
1487 : 0 : link_info->phy_ver[1] = resp->phy_min;
1488 : 0 : link_info->phy_ver[2] = resp->phy_bld;
1489 : 0 : link_info->link_signal_mode =
1490 : 0 : resp->active_fec_signal_mode & HWRM_PORT_PHY_QCFG_OUTPUT_SIGNAL_MODE_MASK;
1491 : 0 : link_info->force_pam4_link_speed =
1492 : 0 : rte_le_to_cpu_16(resp->force_pam4_link_speed);
1493 : 0 : link_info->support_pam4_speeds =
1494 : 0 : rte_le_to_cpu_16(resp->support_pam4_speeds);
1495 : 0 : link_info->auto_pam4_link_speed_mask =
1496 : 0 : rte_le_to_cpu_16(resp->auto_pam4_link_speed_mask);
1497 : 0 : link_info->module_status = resp->module_status;
1498 : : HWRM_UNLOCK();
1499 : :
1500 : 0 : PMD_DRV_LOG(DEBUG, "Link Speed:%d,Auto:%d:%x:%x,Support:%x,Force:%x\n",
1501 : : link_info->link_speed, link_info->auto_mode,
1502 : : link_info->auto_link_speed, link_info->auto_link_speed_mask,
1503 : : link_info->support_speeds, link_info->force_link_speed);
1504 : 0 : PMD_DRV_LOG(DEBUG, "Link Signal:%d,PAM::Auto:%x,Support:%x,Force:%x\n",
1505 : : link_info->link_signal_mode,
1506 : : link_info->auto_pam4_link_speed_mask,
1507 : : link_info->support_pam4_speeds,
1508 : : link_info->force_pam4_link_speed);
1509 : 0 : return rc;
1510 : : }
1511 : :
1512 : 0 : int bnxt_hwrm_port_phy_qcaps(struct bnxt *bp)
1513 : : {
1514 : : int rc = 0;
1515 : 0 : struct hwrm_port_phy_qcaps_input req = {0};
1516 : 0 : struct hwrm_port_phy_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
1517 : 0 : struct bnxt_link_info *link_info = bp->link_info;
1518 : :
1519 [ # # ]: 0 : if (BNXT_VF(bp) && !BNXT_VF_IS_TRUSTED(bp))
1520 : : return 0;
1521 : :
1522 [ # # ]: 0 : HWRM_PREP(&req, HWRM_PORT_PHY_QCAPS, BNXT_USE_CHIMP_MB);
1523 : :
1524 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1525 : :
1526 [ # # # # ]: 0 : HWRM_CHECK_RESULT_SILENT();
1527 : :
1528 : 0 : bp->port_cnt = resp->port_cnt;
1529 [ # # ]: 0 : if (resp->supported_speeds_auto_mode)
1530 : 0 : link_info->support_auto_speeds =
1531 : : rte_le_to_cpu_16(resp->supported_speeds_auto_mode);
1532 [ # # ]: 0 : if (resp->supported_pam4_speeds_auto_mode)
1533 : 0 : link_info->support_pam4_auto_speeds =
1534 : : rte_le_to_cpu_16(resp->supported_pam4_speeds_auto_mode);
1535 : :
1536 : : HWRM_UNLOCK();
1537 : :
1538 : : /* Older firmware does not have supported_auto_speeds, so assume
1539 : : * that all supported speeds can be autonegotiated.
1540 : : */
1541 [ # # # # ]: 0 : if (link_info->auto_link_speed_mask && !link_info->support_auto_speeds)
1542 : 0 : link_info->support_auto_speeds = link_info->support_speeds;
1543 : :
1544 : : return 0;
1545 : : }
1546 : :
1547 : : static bool bnxt_find_lossy_profile(struct bnxt *bp)
1548 : : {
1549 : : int i = 0;
1550 : :
1551 [ # # ]: 0 : for (i = BNXT_COS_QUEUE_COUNT - 1; i >= 0; i--) {
1552 [ # # ]: 0 : if (bp->tx_cos_queue[i].profile ==
1553 : : HWRM_QUEUE_SERVICE_PROFILE_LOSSY) {
1554 : 0 : bp->tx_cosq_id[0] = bp->tx_cos_queue[i].id;
1555 : : return true;
1556 : : }
1557 : : }
1558 : : return false;
1559 : : }
1560 : :
1561 : : static void bnxt_find_first_valid_profile(struct bnxt *bp)
1562 : : {
1563 : : int i = 0;
1564 : :
1565 [ # # ]: 0 : for (i = BNXT_COS_QUEUE_COUNT - 1; i >= 0; i--) {
1566 [ # # ]: 0 : if (bp->tx_cos_queue[i].profile !=
1567 : 0 : HWRM_QUEUE_SERVICE_PROFILE_UNKNOWN &&
1568 [ # # ]: 0 : bp->tx_cos_queue[i].id !=
1569 : : HWRM_QUEUE_SERVICE_PROFILE_UNKNOWN) {
1570 : 0 : bp->tx_cosq_id[0] = bp->tx_cos_queue[i].id;
1571 : 0 : break;
1572 : : }
1573 : : }
1574 : : }
1575 : :
1576 : 0 : int bnxt_hwrm_queue_qportcfg(struct bnxt *bp)
1577 : : {
1578 : : int rc = 0;
1579 : 0 : struct hwrm_queue_qportcfg_input req = {.req_type = 0 };
1580 : 0 : struct hwrm_queue_qportcfg_output *resp = bp->hwrm_cmd_resp_addr;
1581 : : uint32_t dir = HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH_TX;
1582 : : int i;
1583 : :
1584 : 0 : get_rx_info:
1585 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_QUEUE_QPORTCFG, BNXT_USE_CHIMP_MB);
1586 : :
1587 : 0 : req.flags = rte_cpu_to_le_32(dir);
1588 : : /* HWRM Version >= 1.9.1 only if COS Classification is not required. */
1589 [ # # ]: 0 : if (bp->hwrm_spec_code >= HWRM_VERSION_1_9_1 &&
1590 [ # # ]: 0 : !(bp->vnic_cap_flags & BNXT_VNIC_CAP_COS_CLASSIFY))
1591 : 0 : req.drv_qmap_cap =
1592 : : HWRM_QUEUE_QPORTCFG_INPUT_DRV_QMAP_CAP_ENABLED;
1593 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1594 : :
1595 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
1596 : :
1597 [ # # ]: 0 : if (dir == HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH_TX) {
1598 : 0 : GET_TX_QUEUE_INFO(0);
1599 : 0 : GET_TX_QUEUE_INFO(1);
1600 : 0 : GET_TX_QUEUE_INFO(2);
1601 : 0 : GET_TX_QUEUE_INFO(3);
1602 : 0 : GET_TX_QUEUE_INFO(4);
1603 : 0 : GET_TX_QUEUE_INFO(5);
1604 : 0 : GET_TX_QUEUE_INFO(6);
1605 : 0 : GET_TX_QUEUE_INFO(7);
1606 : : } else {
1607 : 0 : GET_RX_QUEUE_INFO(0);
1608 : 0 : GET_RX_QUEUE_INFO(1);
1609 : 0 : GET_RX_QUEUE_INFO(2);
1610 : 0 : GET_RX_QUEUE_INFO(3);
1611 : 0 : GET_RX_QUEUE_INFO(4);
1612 : 0 : GET_RX_QUEUE_INFO(5);
1613 : 0 : GET_RX_QUEUE_INFO(6);
1614 : 0 : GET_RX_QUEUE_INFO(7);
1615 : : }
1616 : :
1617 : : HWRM_UNLOCK();
1618 : :
1619 [ # # ]: 0 : if (dir == HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH_RX)
1620 : 0 : goto done;
1621 : :
1622 [ # # ]: 0 : if (bp->hwrm_spec_code < HWRM_VERSION_1_9_1) {
1623 : 0 : bp->tx_cosq_id[0] = bp->tx_cos_queue[0].id;
1624 : : } else {
1625 : : int j;
1626 : :
1627 : : /* iterate and find the COSq profile to use for Tx */
1628 [ # # ]: 0 : if (bp->vnic_cap_flags & BNXT_VNIC_CAP_COS_CLASSIFY) {
1629 [ # # ]: 0 : for (j = 0, i = 0; i < BNXT_COS_QUEUE_COUNT; i++) {
1630 [ # # ]: 0 : if (bp->tx_cos_queue[i].id != 0xff)
1631 : 0 : bp->tx_cosq_id[j++] =
1632 : : bp->tx_cos_queue[i].id;
1633 : : }
1634 : : } else {
1635 : : /* When CoS classification is disabled, for normal NIC
1636 : : * operations, ideally we should look to use LOSSY.
1637 : : * If not found, fallback to the first valid profile
1638 : : */
1639 : : if (!bnxt_find_lossy_profile(bp))
1640 : : bnxt_find_first_valid_profile(bp);
1641 : :
1642 : : }
1643 : : }
1644 : :
1645 : 0 : bp->max_tc = resp->max_configurable_queues;
1646 : 0 : bp->max_lltc = resp->max_configurable_lossless_queues;
1647 [ # # ]: 0 : if (bp->max_tc > BNXT_MAX_QUEUE)
1648 : 0 : bp->max_tc = BNXT_MAX_QUEUE;
1649 : 0 : bp->max_q = bp->max_tc;
1650 : :
1651 : : if (dir == HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH_TX) {
1652 : : dir = HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH_RX;
1653 : 0 : goto get_rx_info;
1654 : : }
1655 : :
1656 : : done:
1657 : 0 : return rc;
1658 : : }
1659 : :
1660 : 0 : int bnxt_hwrm_ring_alloc(struct bnxt *bp,
1661 : : struct bnxt_ring *ring,
1662 : : uint32_t ring_type, uint32_t map_index,
1663 : : uint32_t stats_ctx_id, uint32_t cmpl_ring_id,
1664 : : uint16_t tx_cosq_id)
1665 : : {
1666 : : int rc = 0;
1667 : : uint32_t enables = 0;
1668 : 0 : struct hwrm_ring_alloc_input req = {.req_type = 0 };
1669 : 0 : struct hwrm_ring_alloc_output *resp = bp->hwrm_cmd_resp_addr;
1670 : : struct rte_mempool *mb_pool;
1671 : : uint16_t rx_buf_size;
1672 : :
1673 [ # # # # : 0 : HWRM_PREP(&req, HWRM_RING_ALLOC, BNXT_USE_CHIMP_MB);
# # # # ]
1674 : :
1675 : 0 : req.page_tbl_addr = rte_cpu_to_le_64(ring->bd_dma);
1676 : 0 : req.fbo = rte_cpu_to_le_32(0);
1677 : : /* Association of ring index with doorbell index */
1678 : 0 : req.logical_id = rte_cpu_to_le_16(map_index);
1679 : 0 : req.length = rte_cpu_to_le_32(ring->ring_size);
1680 : :
1681 [ # # # # : 0 : switch (ring_type) {
# # ]
1682 : 0 : case HWRM_RING_ALLOC_INPUT_RING_TYPE_TX:
1683 : 0 : req.ring_type = ring_type;
1684 : 0 : req.cmpl_ring_id = rte_cpu_to_le_16(cmpl_ring_id);
1685 : 0 : req.stat_ctx_id = rte_cpu_to_le_32(stats_ctx_id);
1686 : 0 : req.queue_id = rte_cpu_to_le_16(tx_cosq_id);
1687 [ # # ]: 0 : if (stats_ctx_id != INVALID_STATS_CTX_ID)
1688 : : enables |=
1689 : : HWRM_RING_ALLOC_INPUT_ENABLES_STAT_CTX_ID_VALID;
1690 : : break;
1691 : 0 : case HWRM_RING_ALLOC_INPUT_RING_TYPE_RX:
1692 : 0 : req.ring_type = ring_type;
1693 : 0 : req.cmpl_ring_id = rte_cpu_to_le_16(cmpl_ring_id);
1694 : 0 : req.stat_ctx_id = rte_cpu_to_le_32(stats_ctx_id);
1695 [ # # ]: 0 : if (BNXT_CHIP_P5(bp)) {
1696 [ # # ]: 0 : mb_pool = bp->rx_queues[0]->mb_pool;
1697 : 0 : rx_buf_size = rte_pktmbuf_data_room_size(mb_pool) -
1698 : : RTE_PKTMBUF_HEADROOM;
1699 : 0 : rx_buf_size = RTE_MIN(BNXT_MAX_PKT_LEN, rx_buf_size);
1700 : 0 : req.rx_buf_size = rte_cpu_to_le_16(rx_buf_size);
1701 : : enables |=
1702 : : HWRM_RING_ALLOC_INPUT_ENABLES_RX_BUF_SIZE_VALID;
1703 : : }
1704 [ # # ]: 0 : if (stats_ctx_id != INVALID_STATS_CTX_ID)
1705 : 0 : enables |=
1706 : : HWRM_RING_ALLOC_INPUT_ENABLES_STAT_CTX_ID_VALID;
1707 : : break;
1708 : 0 : case HWRM_RING_ALLOC_INPUT_RING_TYPE_L2_CMPL:
1709 : 0 : req.ring_type = ring_type;
1710 [ # # ]: 0 : if (BNXT_HAS_NQ(bp)) {
1711 : : /* Association of cp ring with nq */
1712 : 0 : req.nq_ring_id = rte_cpu_to_le_16(cmpl_ring_id);
1713 : : enables |=
1714 : : HWRM_RING_ALLOC_INPUT_ENABLES_NQ_RING_ID_VALID;
1715 : : }
1716 : 0 : req.int_mode = HWRM_RING_ALLOC_INPUT_INT_MODE_MSIX;
1717 : 0 : break;
1718 : 0 : case HWRM_RING_ALLOC_INPUT_RING_TYPE_NQ:
1719 : 0 : req.ring_type = ring_type;
1720 : 0 : req.page_size = BNXT_PAGE_SHFT;
1721 : 0 : req.int_mode = HWRM_RING_ALLOC_INPUT_INT_MODE_MSIX;
1722 : 0 : break;
1723 : 0 : case HWRM_RING_ALLOC_INPUT_RING_TYPE_RX_AGG:
1724 : 0 : req.ring_type = ring_type;
1725 : 0 : req.rx_ring_id = rte_cpu_to_le_16(ring->fw_rx_ring_id);
1726 : :
1727 [ # # ]: 0 : mb_pool = bp->rx_queues[0]->mb_pool;
1728 : 0 : rx_buf_size = rte_pktmbuf_data_room_size(mb_pool) -
1729 : : RTE_PKTMBUF_HEADROOM;
1730 : 0 : rx_buf_size = RTE_MIN(BNXT_MAX_PKT_LEN, rx_buf_size);
1731 : 0 : req.rx_buf_size = rte_cpu_to_le_16(rx_buf_size);
1732 : :
1733 : 0 : req.stat_ctx_id = rte_cpu_to_le_32(stats_ctx_id);
1734 : : enables |= HWRM_RING_ALLOC_INPUT_ENABLES_RX_RING_ID_VALID |
1735 : : HWRM_RING_ALLOC_INPUT_ENABLES_RX_BUF_SIZE_VALID |
1736 : : HWRM_RING_ALLOC_INPUT_ENABLES_STAT_CTX_ID_VALID;
1737 : 0 : break;
1738 : 0 : default:
1739 : 0 : PMD_DRV_LOG(ERR, "hwrm alloc invalid ring type %d\n",
1740 : : ring_type);
1741 : : HWRM_UNLOCK();
1742 : 0 : return -EINVAL;
1743 : : }
1744 : 0 : req.enables = rte_cpu_to_le_32(enables);
1745 : :
1746 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1747 : :
1748 [ # # # # ]: 0 : if (rc || resp->error_code) {
1749 [ # # # # ]: 0 : if (rc == 0 && resp->error_code)
1750 : 0 : rc = rte_le_to_cpu_16(resp->error_code);
1751 [ # # # # : 0 : switch (ring_type) {
# # ]
1752 : 0 : case HWRM_RING_ALLOC_INPUT_RING_TYPE_L2_CMPL:
1753 : 0 : PMD_DRV_LOG(ERR,
1754 : : "hwrm_ring_alloc cp failed. rc:%d\n", rc);
1755 : : HWRM_UNLOCK();
1756 : 0 : return rc;
1757 : 0 : case HWRM_RING_ALLOC_INPUT_RING_TYPE_RX:
1758 : 0 : PMD_DRV_LOG(ERR,
1759 : : "hwrm_ring_alloc rx failed. rc:%d\n", rc);
1760 : : HWRM_UNLOCK();
1761 : 0 : return rc;
1762 : 0 : case HWRM_RING_ALLOC_INPUT_RING_TYPE_RX_AGG:
1763 : 0 : PMD_DRV_LOG(ERR,
1764 : : "hwrm_ring_alloc rx agg failed. rc:%d\n",
1765 : : rc);
1766 : : HWRM_UNLOCK();
1767 : 0 : return rc;
1768 : 0 : case HWRM_RING_ALLOC_INPUT_RING_TYPE_TX:
1769 : 0 : PMD_DRV_LOG(ERR,
1770 : : "hwrm_ring_alloc tx failed. rc:%d\n", rc);
1771 : : HWRM_UNLOCK();
1772 : 0 : return rc;
1773 : 0 : case HWRM_RING_ALLOC_INPUT_RING_TYPE_NQ:
1774 : 0 : PMD_DRV_LOG(ERR,
1775 : : "hwrm_ring_alloc nq failed. rc:%d\n", rc);
1776 : : HWRM_UNLOCK();
1777 : 0 : return rc;
1778 : 0 : default:
1779 : 0 : PMD_DRV_LOG(ERR, "Invalid ring. rc:%d\n", rc);
1780 : : HWRM_UNLOCK();
1781 : 0 : return rc;
1782 : : }
1783 : : }
1784 : :
1785 : 0 : ring->fw_ring_id = rte_le_to_cpu_16(resp->ring_id);
1786 : : HWRM_UNLOCK();
1787 : 0 : return rc;
1788 : : }
1789 : :
1790 : 0 : int bnxt_hwrm_ring_free(struct bnxt *bp,
1791 : : struct bnxt_ring *ring, uint32_t ring_type,
1792 : : uint16_t cp_ring_id)
1793 : : {
1794 : : int rc;
1795 : 0 : struct hwrm_ring_free_input req = {.req_type = 0 };
1796 : 0 : struct hwrm_ring_free_output *resp = bp->hwrm_cmd_resp_addr;
1797 : :
1798 [ # # ]: 0 : if (ring->fw_ring_id == INVALID_HW_RING_ID)
1799 : : return -EINVAL;
1800 : :
1801 [ # # ]: 0 : HWRM_PREP(&req, HWRM_RING_FREE, BNXT_USE_CHIMP_MB);
1802 : :
1803 : 0 : req.ring_type = ring_type;
1804 : 0 : req.ring_id = rte_cpu_to_le_16(ring->fw_ring_id);
1805 : 0 : req.cmpl_ring = rte_cpu_to_le_16(cp_ring_id);
1806 : :
1807 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1808 : 0 : ring->fw_ring_id = INVALID_HW_RING_ID;
1809 : :
1810 [ # # # # ]: 0 : if (rc || resp->error_code) {
1811 [ # # # # ]: 0 : if (rc == 0 && resp->error_code)
1812 : 0 : rc = rte_le_to_cpu_16(resp->error_code);
1813 : : HWRM_UNLOCK();
1814 : :
1815 [ # # # # : 0 : switch (ring_type) {
# # ]
1816 : 0 : case HWRM_RING_FREE_INPUT_RING_TYPE_L2_CMPL:
1817 : 0 : PMD_DRV_LOG(ERR, "hwrm_ring_free cp failed. rc:%d\n",
1818 : : rc);
1819 : 0 : return rc;
1820 : 0 : case HWRM_RING_FREE_INPUT_RING_TYPE_RX:
1821 : 0 : PMD_DRV_LOG(ERR, "hwrm_ring_free rx failed. rc:%d\n",
1822 : : rc);
1823 : 0 : return rc;
1824 : 0 : case HWRM_RING_FREE_INPUT_RING_TYPE_TX:
1825 : 0 : PMD_DRV_LOG(ERR, "hwrm_ring_free tx failed. rc:%d\n",
1826 : : rc);
1827 : 0 : return rc;
1828 : 0 : case HWRM_RING_FREE_INPUT_RING_TYPE_NQ:
1829 : 0 : PMD_DRV_LOG(ERR,
1830 : : "hwrm_ring_free nq failed. rc:%d\n", rc);
1831 : 0 : return rc;
1832 : 0 : case HWRM_RING_FREE_INPUT_RING_TYPE_RX_AGG:
1833 : 0 : PMD_DRV_LOG(ERR,
1834 : : "hwrm_ring_free agg failed. rc:%d\n", rc);
1835 : 0 : return rc;
1836 : 0 : default:
1837 : 0 : PMD_DRV_LOG(ERR, "Invalid ring, rc:%d\n", rc);
1838 : 0 : return rc;
1839 : : }
1840 : : }
1841 : : HWRM_UNLOCK();
1842 : 0 : return 0;
1843 : : }
1844 : :
1845 : 0 : int bnxt_hwrm_ring_grp_alloc(struct bnxt *bp, unsigned int idx)
1846 : : {
1847 : : int rc = 0;
1848 : 0 : struct hwrm_ring_grp_alloc_input req = {.req_type = 0 };
1849 : 0 : struct hwrm_ring_grp_alloc_output *resp = bp->hwrm_cmd_resp_addr;
1850 : :
1851 : : /* Don't attempt to re-create the ring group if it is already created */
1852 [ # # ]: 0 : if (bp->grp_info[idx].fw_grp_id != INVALID_HW_RING_ID)
1853 : : return 0;
1854 : :
1855 [ # # ]: 0 : HWRM_PREP(&req, HWRM_RING_GRP_ALLOC, BNXT_USE_CHIMP_MB);
1856 : :
1857 : 0 : req.cr = rte_cpu_to_le_16(bp->grp_info[idx].cp_fw_ring_id);
1858 : 0 : req.rr = rte_cpu_to_le_16(bp->grp_info[idx].rx_fw_ring_id);
1859 : 0 : req.ar = rte_cpu_to_le_16(bp->grp_info[idx].ag_fw_ring_id);
1860 : 0 : req.sc = rte_cpu_to_le_16(bp->grp_info[idx].fw_stats_ctx);
1861 : :
1862 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1863 : :
1864 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
1865 : :
1866 : 0 : bp->grp_info[idx].fw_grp_id = rte_le_to_cpu_16(resp->ring_group_id);
1867 : :
1868 : : HWRM_UNLOCK();
1869 : :
1870 : 0 : return rc;
1871 : : }
1872 : :
1873 : 0 : int bnxt_hwrm_ring_grp_free(struct bnxt *bp, unsigned int idx)
1874 : : {
1875 : : int rc;
1876 : 0 : struct hwrm_ring_grp_free_input req = {.req_type = 0 };
1877 : 0 : struct hwrm_ring_grp_free_output *resp = bp->hwrm_cmd_resp_addr;
1878 : :
1879 [ # # ]: 0 : if (bp->grp_info[idx].fw_grp_id == INVALID_HW_RING_ID)
1880 : : return 0;
1881 : :
1882 [ # # ]: 0 : HWRM_PREP(&req, HWRM_RING_GRP_FREE, BNXT_USE_CHIMP_MB);
1883 : :
1884 : 0 : req.ring_group_id = rte_cpu_to_le_16(bp->grp_info[idx].fw_grp_id);
1885 : :
1886 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1887 : :
1888 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
1889 : : HWRM_UNLOCK();
1890 : :
1891 : 0 : bp->grp_info[idx].fw_grp_id = INVALID_HW_RING_ID;
1892 : 0 : return rc;
1893 : : }
1894 : :
1895 : 0 : int bnxt_hwrm_stat_clear(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)
1896 : : {
1897 : : int rc = 0;
1898 : 0 : struct hwrm_stat_ctx_clr_stats_input req = {.req_type = 0 };
1899 : 0 : struct hwrm_stat_ctx_clr_stats_output *resp = bp->hwrm_cmd_resp_addr;
1900 : :
1901 [ # # ]: 0 : if (cpr->hw_stats_ctx_id == HWRM_NA_SIGNATURE)
1902 : : return rc;
1903 : :
1904 [ # # ]: 0 : HWRM_PREP(&req, HWRM_STAT_CTX_CLR_STATS, BNXT_USE_CHIMP_MB);
1905 : :
1906 : 0 : req.stat_ctx_id = rte_cpu_to_le_32(cpr->hw_stats_ctx_id);
1907 : :
1908 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1909 : :
1910 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
1911 : : HWRM_UNLOCK();
1912 : :
1913 : 0 : return rc;
1914 : : }
1915 : :
1916 : 0 : int bnxt_hwrm_stat_ctx_alloc(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)
1917 : : {
1918 : : int rc;
1919 : 0 : struct hwrm_stat_ctx_alloc_input req = {.req_type = 0 };
1920 : 0 : struct hwrm_stat_ctx_alloc_output *resp = bp->hwrm_cmd_resp_addr;
1921 : :
1922 [ # # ]: 0 : if (cpr->hw_stats_ctx_id != HWRM_NA_SIGNATURE)
1923 : : return 0;
1924 : :
1925 [ # # ]: 0 : HWRM_PREP(&req, HWRM_STAT_CTX_ALLOC, BNXT_USE_CHIMP_MB);
1926 : :
1927 : 0 : req.update_period_ms = rte_cpu_to_le_32(0);
1928 : :
1929 : 0 : req.stats_dma_addr = rte_cpu_to_le_64(cpr->hw_stats_map);
1930 : :
1931 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1932 : :
1933 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
1934 : :
1935 : 0 : cpr->hw_stats_ctx_id = rte_le_to_cpu_32(resp->stat_ctx_id);
1936 : :
1937 : : HWRM_UNLOCK();
1938 : :
1939 : 0 : return rc;
1940 : : }
1941 : :
1942 : 0 : static int bnxt_hwrm_stat_ctx_free(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)
1943 : : {
1944 : : int rc;
1945 : 0 : struct hwrm_stat_ctx_free_input req = {.req_type = 0 };
1946 : 0 : struct hwrm_stat_ctx_free_output *resp = bp->hwrm_cmd_resp_addr;
1947 : :
1948 [ # # ]: 0 : if (cpr->hw_stats_ctx_id == HWRM_NA_SIGNATURE)
1949 : : return 0;
1950 : :
1951 [ # # ]: 0 : HWRM_PREP(&req, HWRM_STAT_CTX_FREE, BNXT_USE_CHIMP_MB);
1952 : :
1953 : 0 : req.stat_ctx_id = rte_cpu_to_le_32(cpr->hw_stats_ctx_id);
1954 : :
1955 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1956 : :
1957 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
1958 : : HWRM_UNLOCK();
1959 : :
1960 : 0 : cpr->hw_stats_ctx_id = HWRM_NA_SIGNATURE;
1961 : :
1962 : 0 : return rc;
1963 : : }
1964 : :
1965 : 0 : int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic)
1966 : : {
1967 : : int rc = 0;
1968 : 0 : struct hwrm_vnic_alloc_input req = { 0 };
1969 : 0 : struct hwrm_vnic_alloc_output *resp = bp->hwrm_cmd_resp_addr;
1970 : :
1971 : 0 : vnic->mru = BNXT_VNIC_MRU(bp->eth_dev->data->mtu);
1972 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_VNIC_ALLOC, BNXT_USE_CHIMP_MB);
1973 : :
1974 [ # # ]: 0 : if (vnic->func_default)
1975 : 0 : req.flags =
1976 : : rte_cpu_to_le_32(HWRM_VNIC_ALLOC_INPUT_FLAGS_DEFAULT);
1977 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1978 : :
1979 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
1980 : :
1981 : 0 : vnic->fw_vnic_id = rte_le_to_cpu_16(resp->vnic_id);
1982 : : HWRM_UNLOCK();
1983 : 0 : PMD_DRV_LOG(DEBUG, "VNIC ID %x\n", vnic->fw_vnic_id);
1984 : 0 : return rc;
1985 : : }
1986 : :
1987 : 0 : static int bnxt_hwrm_vnic_plcmodes_qcfg(struct bnxt *bp,
1988 : : struct bnxt_vnic_info *vnic,
1989 : : struct bnxt_plcmodes_cfg *pmode)
1990 : : {
1991 : : int rc = 0;
1992 : 0 : struct hwrm_vnic_plcmodes_qcfg_input req = {.req_type = 0 };
1993 : 0 : struct hwrm_vnic_plcmodes_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
1994 : :
1995 [ # # ]: 0 : HWRM_PREP(&req, HWRM_VNIC_PLCMODES_QCFG, BNXT_USE_CHIMP_MB);
1996 : :
1997 : 0 : req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
1998 : :
1999 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2000 : :
2001 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2002 : :
2003 : 0 : pmode->flags = rte_le_to_cpu_32(resp->flags);
2004 : : /* dflt_vnic bit doesn't exist in the _cfg command */
2005 : 0 : pmode->flags &= ~(HWRM_VNIC_PLCMODES_QCFG_OUTPUT_FLAGS_DFLT_VNIC);
2006 : 0 : pmode->jumbo_thresh = rte_le_to_cpu_16(resp->jumbo_thresh);
2007 : 0 : pmode->hds_offset = rte_le_to_cpu_16(resp->hds_offset);
2008 : 0 : pmode->hds_threshold = rte_le_to_cpu_16(resp->hds_threshold);
2009 : :
2010 : : HWRM_UNLOCK();
2011 : :
2012 : 0 : return rc;
2013 : : }
2014 : :
2015 : 0 : static int bnxt_hwrm_vnic_plcmodes_cfg(struct bnxt *bp,
2016 : : struct bnxt_vnic_info *vnic,
2017 : : struct bnxt_plcmodes_cfg *pmode)
2018 : : {
2019 : : int rc = 0;
2020 : 0 : struct hwrm_vnic_plcmodes_cfg_input req = {.req_type = 0 };
2021 : 0 : struct hwrm_vnic_plcmodes_cfg_output *resp = bp->hwrm_cmd_resp_addr;
2022 : :
2023 [ # # ]: 0 : if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
2024 : 0 : PMD_DRV_LOG(DEBUG, "VNIC ID %x\n", vnic->fw_vnic_id);
2025 : 0 : return rc;
2026 : : }
2027 : :
2028 [ # # ]: 0 : HWRM_PREP(&req, HWRM_VNIC_PLCMODES_CFG, BNXT_USE_CHIMP_MB);
2029 : :
2030 : 0 : req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
2031 : 0 : req.flags = rte_cpu_to_le_32(pmode->flags);
2032 : 0 : req.jumbo_thresh = rte_cpu_to_le_16(pmode->jumbo_thresh);
2033 : 0 : req.hds_offset = rte_cpu_to_le_16(pmode->hds_offset);
2034 : 0 : req.hds_threshold = rte_cpu_to_le_16(pmode->hds_threshold);
2035 : 0 : req.enables = rte_cpu_to_le_32(
2036 : : HWRM_VNIC_PLCMODES_CFG_INPUT_ENABLES_HDS_THRESHOLD_VALID |
2037 : : HWRM_VNIC_PLCMODES_CFG_INPUT_ENABLES_HDS_OFFSET_VALID |
2038 : : HWRM_VNIC_PLCMODES_CFG_INPUT_ENABLES_JUMBO_THRESH_VALID
2039 : : );
2040 : :
2041 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2042 : :
2043 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2044 : : HWRM_UNLOCK();
2045 : :
2046 : 0 : return rc;
2047 : : }
2048 : :
2049 : 0 : int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic)
2050 : : {
2051 : : int rc = 0;
2052 : 0 : struct hwrm_vnic_cfg_input req = {.req_type = 0 };
2053 : 0 : struct hwrm_vnic_cfg_output *resp = bp->hwrm_cmd_resp_addr;
2054 : 0 : struct bnxt_plcmodes_cfg pmodes = { 0 };
2055 : : uint32_t ctx_enable_flag = 0;
2056 : : uint32_t enables = 0;
2057 : :
2058 [ # # ]: 0 : if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
2059 : 0 : PMD_DRV_LOG(DEBUG, "VNIC ID %x\n", vnic->fw_vnic_id);
2060 : 0 : return rc;
2061 : : }
2062 : :
2063 : 0 : rc = bnxt_hwrm_vnic_plcmodes_qcfg(bp, vnic, &pmodes);
2064 [ # # ]: 0 : if (rc)
2065 : : return rc;
2066 : :
2067 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_VNIC_CFG, BNXT_USE_CHIMP_MB);
2068 : :
2069 [ # # ]: 0 : if (BNXT_CHIP_P5(bp)) {
2070 : 0 : int dflt_rxq = vnic->start_grp_id;
2071 : : struct bnxt_rx_ring_info *rxr;
2072 : : struct bnxt_cp_ring_info *cpr;
2073 : : struct bnxt_rx_queue *rxq;
2074 : : int i;
2075 : :
2076 : : /*
2077 : : * The first active receive ring is used as the VNIC
2078 : : * default receive ring. If there are no active receive
2079 : : * rings (all corresponding receive queues are stopped),
2080 : : * the first receive ring is used.
2081 : : */
2082 [ # # ]: 0 : for (i = vnic->start_grp_id; i < vnic->end_grp_id; i++) {
2083 : 0 : rxq = bp->eth_dev->data->rx_queues[i];
2084 [ # # # # ]: 0 : if (rxq->rx_started &&
2085 : 0 : bnxt_vnic_queue_id_is_valid(vnic, i)) {
2086 : : dflt_rxq = i;
2087 : : break;
2088 : : }
2089 : : }
2090 : :
2091 : 0 : rxq = bp->eth_dev->data->rx_queues[dflt_rxq];
2092 : 0 : rxr = rxq->rx_ring;
2093 : 0 : cpr = rxq->cp_ring;
2094 : :
2095 : 0 : req.default_rx_ring_id =
2096 : 0 : rte_cpu_to_le_16(rxr->rx_ring_struct->fw_ring_id);
2097 : 0 : req.default_cmpl_ring_id =
2098 : 0 : rte_cpu_to_le_16(cpr->cp_ring_struct->fw_ring_id);
2099 : : enables = HWRM_VNIC_CFG_INPUT_ENABLES_DEFAULT_RX_RING_ID |
2100 : : HWRM_VNIC_CFG_INPUT_ENABLES_DEFAULT_CMPL_RING_ID;
2101 [ # # ]: 0 : if (bp->vnic_cap_flags & BNXT_VNIC_CAP_RX_CMPL_V2) {
2102 : : enables |= HWRM_VNIC_CFG_INPUT_ENABLES_RX_CSUM_V2_MODE;
2103 : 0 : req.rx_csum_v2_mode =
2104 : : HWRM_VNIC_CFG_INPUT_RX_CSUM_V2_MODE_ALL_OK;
2105 : : }
2106 : 0 : goto config_mru;
2107 : : }
2108 : :
2109 : : /* Only RSS support for now TBD: COS & LB */
2110 : : enables = HWRM_VNIC_CFG_INPUT_ENABLES_DFLT_RING_GRP;
2111 [ # # ]: 0 : if (vnic->lb_rule != 0xffff)
2112 : : ctx_enable_flag |= HWRM_VNIC_CFG_INPUT_ENABLES_LB_RULE;
2113 [ # # ]: 0 : if (vnic->cos_rule != 0xffff)
2114 : 0 : ctx_enable_flag |= HWRM_VNIC_CFG_INPUT_ENABLES_COS_RULE;
2115 [ # # ]: 0 : if (vnic->rss_rule != (uint16_t)HWRM_NA_SIGNATURE) {
2116 : : ctx_enable_flag |= HWRM_VNIC_CFG_INPUT_ENABLES_MRU;
2117 : 0 : ctx_enable_flag |= HWRM_VNIC_CFG_INPUT_ENABLES_RSS_RULE;
2118 : : }
2119 [ # # ]: 0 : if (bp->vnic_cap_flags & BNXT_VNIC_CAP_COS_CLASSIFY) {
2120 : 0 : ctx_enable_flag |= HWRM_VNIC_CFG_INPUT_ENABLES_QUEUE_ID;
2121 : 0 : req.queue_id = rte_cpu_to_le_16(vnic->cos_queue_id);
2122 : : }
2123 : :
2124 : 0 : enables |= ctx_enable_flag;
2125 : 0 : req.dflt_ring_grp = rte_cpu_to_le_16(vnic->dflt_ring_grp);
2126 : 0 : req.rss_rule = rte_cpu_to_le_16(vnic->rss_rule);
2127 : 0 : req.cos_rule = rte_cpu_to_le_16(vnic->cos_rule);
2128 : 0 : req.lb_rule = rte_cpu_to_le_16(vnic->lb_rule);
2129 : :
2130 : 0 : config_mru:
2131 : 0 : req.enables = rte_cpu_to_le_32(enables);
2132 : 0 : req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
2133 : 0 : req.mru = rte_cpu_to_le_16(vnic->mru);
2134 : : /* Configure default VNIC only once. */
2135 [ # # # # ]: 0 : if (vnic->func_default && !(bp->flags & BNXT_FLAG_DFLT_VNIC_SET)) {
2136 : 0 : req.flags |=
2137 : : rte_cpu_to_le_32(HWRM_VNIC_CFG_INPUT_FLAGS_DEFAULT);
2138 : 0 : bp->flags |= BNXT_FLAG_DFLT_VNIC_SET;
2139 : : }
2140 [ # # ]: 0 : if (vnic->vlan_strip)
2141 : 0 : req.flags |=
2142 : : rte_cpu_to_le_32(HWRM_VNIC_CFG_INPUT_FLAGS_VLAN_STRIP_MODE);
2143 [ # # ]: 0 : if (vnic->bd_stall)
2144 : 0 : req.flags |=
2145 : : rte_cpu_to_le_32(HWRM_VNIC_CFG_INPUT_FLAGS_BD_STALL_MODE);
2146 [ # # ]: 0 : if (vnic->rss_dflt_cr)
2147 : 0 : req.flags |= rte_cpu_to_le_32(
2148 : : HWRM_VNIC_QCFG_OUTPUT_FLAGS_RSS_DFLT_CR_MODE);
2149 : :
2150 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2151 : :
2152 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2153 : : HWRM_UNLOCK();
2154 : :
2155 : 0 : rc = bnxt_hwrm_vnic_plcmodes_cfg(bp, vnic, &pmodes);
2156 : :
2157 : 0 : return rc;
2158 : : }
2159 : :
2160 : 0 : int bnxt_hwrm_vnic_qcfg(struct bnxt *bp, struct bnxt_vnic_info *vnic,
2161 : : int16_t fw_vf_id)
2162 : : {
2163 : : int rc = 0;
2164 : 0 : struct hwrm_vnic_qcfg_input req = {.req_type = 0 };
2165 : 0 : struct hwrm_vnic_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
2166 : :
2167 [ # # ]: 0 : if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
2168 : 0 : PMD_DRV_LOG(DEBUG, "VNIC QCFG ID %d\n", vnic->fw_vnic_id);
2169 : 0 : return rc;
2170 : : }
2171 [ # # ]: 0 : HWRM_PREP(&req, HWRM_VNIC_QCFG, BNXT_USE_CHIMP_MB);
2172 : :
2173 : 0 : req.enables =
2174 : : rte_cpu_to_le_32(HWRM_VNIC_QCFG_INPUT_ENABLES_VF_ID_VALID);
2175 : 0 : req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
2176 : 0 : req.vf_id = rte_cpu_to_le_16(fw_vf_id);
2177 : :
2178 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2179 : :
2180 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2181 : :
2182 : 0 : vnic->dflt_ring_grp = rte_le_to_cpu_16(resp->dflt_ring_grp);
2183 : 0 : vnic->rss_rule = rte_le_to_cpu_16(resp->rss_rule);
2184 : 0 : vnic->cos_rule = rte_le_to_cpu_16(resp->cos_rule);
2185 : 0 : vnic->lb_rule = rte_le_to_cpu_16(resp->lb_rule);
2186 : 0 : vnic->mru = rte_le_to_cpu_16(resp->mru);
2187 : 0 : vnic->func_default = rte_le_to_cpu_32(
2188 : 0 : resp->flags) & HWRM_VNIC_QCFG_OUTPUT_FLAGS_DEFAULT;
2189 : 0 : vnic->vlan_strip = rte_le_to_cpu_32(resp->flags) &
2190 : : HWRM_VNIC_QCFG_OUTPUT_FLAGS_VLAN_STRIP_MODE;
2191 : 0 : vnic->bd_stall = rte_le_to_cpu_32(resp->flags) &
2192 : : HWRM_VNIC_QCFG_OUTPUT_FLAGS_BD_STALL_MODE;
2193 : 0 : vnic->rss_dflt_cr = rte_le_to_cpu_32(resp->flags) &
2194 : : HWRM_VNIC_QCFG_OUTPUT_FLAGS_RSS_DFLT_CR_MODE;
2195 : :
2196 : : HWRM_UNLOCK();
2197 : :
2198 : 0 : return rc;
2199 : : }
2200 : :
2201 : 0 : int bnxt_hwrm_vnic_ctx_alloc(struct bnxt *bp,
2202 : : struct bnxt_vnic_info *vnic, uint16_t ctx_idx)
2203 : : {
2204 : : int rc = 0;
2205 : : uint16_t ctx_id;
2206 : 0 : struct hwrm_vnic_rss_cos_lb_ctx_alloc_input req = {.req_type = 0 };
2207 : 0 : struct hwrm_vnic_rss_cos_lb_ctx_alloc_output *resp =
2208 : : bp->hwrm_cmd_resp_addr;
2209 : :
2210 [ # # ]: 0 : HWRM_PREP(&req, HWRM_VNIC_RSS_COS_LB_CTX_ALLOC, BNXT_USE_CHIMP_MB);
2211 : :
2212 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2213 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2214 : :
2215 : 0 : ctx_id = rte_le_to_cpu_16(resp->rss_cos_lb_ctx_id);
2216 [ # # ]: 0 : if (!BNXT_HAS_RING_GRPS(bp))
2217 : 0 : vnic->fw_grp_ids[ctx_idx] = ctx_id;
2218 [ # # ]: 0 : else if (ctx_idx == 0)
2219 : 0 : vnic->rss_rule = ctx_id;
2220 : :
2221 : : HWRM_UNLOCK();
2222 : :
2223 : 0 : return rc;
2224 : : }
2225 : :
2226 : : static
2227 : 0 : int _bnxt_hwrm_vnic_ctx_free(struct bnxt *bp,
2228 : : struct bnxt_vnic_info *vnic, uint16_t ctx_idx)
2229 : : {
2230 : : int rc = 0;
2231 : 0 : struct hwrm_vnic_rss_cos_lb_ctx_free_input req = {.req_type = 0 };
2232 : 0 : struct hwrm_vnic_rss_cos_lb_ctx_free_output *resp =
2233 : : bp->hwrm_cmd_resp_addr;
2234 : :
2235 [ # # ]: 0 : if (ctx_idx == (uint16_t)HWRM_NA_SIGNATURE) {
2236 : 0 : PMD_DRV_LOG(DEBUG, "VNIC RSS Rule %x\n", vnic->rss_rule);
2237 : 0 : return rc;
2238 : : }
2239 [ # # ]: 0 : HWRM_PREP(&req, HWRM_VNIC_RSS_COS_LB_CTX_FREE, BNXT_USE_CHIMP_MB);
2240 : :
2241 : 0 : req.rss_cos_lb_ctx_id = rte_cpu_to_le_16(ctx_idx);
2242 : :
2243 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2244 : :
2245 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2246 : : HWRM_UNLOCK();
2247 : :
2248 : 0 : return rc;
2249 : : }
2250 : :
2251 : 0 : int bnxt_hwrm_vnic_ctx_free(struct bnxt *bp, struct bnxt_vnic_info *vnic)
2252 : : {
2253 : : int rc = 0;
2254 : :
2255 [ # # ]: 0 : if (BNXT_CHIP_P5(bp)) {
2256 : : int j;
2257 : :
2258 [ # # ]: 0 : for (j = 0; j < vnic->num_lb_ctxts; j++) {
2259 : 0 : rc = _bnxt_hwrm_vnic_ctx_free(bp,
2260 : : vnic,
2261 : 0 : vnic->fw_grp_ids[j]);
2262 : 0 : vnic->fw_grp_ids[j] = INVALID_HW_RING_ID;
2263 : : }
2264 : 0 : vnic->num_lb_ctxts = 0;
2265 : : } else {
2266 : 0 : rc = _bnxt_hwrm_vnic_ctx_free(bp, vnic, vnic->rss_rule);
2267 : 0 : vnic->rss_rule = INVALID_HW_RING_ID;
2268 : : }
2269 : :
2270 : 0 : return rc;
2271 : : }
2272 : :
2273 : 0 : int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic)
2274 : : {
2275 : : int rc = 0;
2276 : 0 : struct hwrm_vnic_free_input req = {.req_type = 0 };
2277 : 0 : struct hwrm_vnic_free_output *resp = bp->hwrm_cmd_resp_addr;
2278 : :
2279 [ # # ]: 0 : if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
2280 : 0 : PMD_DRV_LOG(DEBUG, "VNIC FREE ID %x\n", vnic->fw_vnic_id);
2281 : 0 : return rc;
2282 : : }
2283 : :
2284 [ # # ]: 0 : HWRM_PREP(&req, HWRM_VNIC_FREE, BNXT_USE_CHIMP_MB);
2285 : :
2286 : 0 : req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
2287 : :
2288 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2289 : :
2290 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2291 : : HWRM_UNLOCK();
2292 : :
2293 : 0 : vnic->fw_vnic_id = INVALID_HW_RING_ID;
2294 : : /* Configure default VNIC again if necessary. */
2295 [ # # # # ]: 0 : if (vnic->func_default && (bp->flags & BNXT_FLAG_DFLT_VNIC_SET))
2296 : 0 : bp->flags &= ~BNXT_FLAG_DFLT_VNIC_SET;
2297 : :
2298 : : return rc;
2299 : : }
2300 : :
2301 : : static int
2302 : 0 : bnxt_hwrm_vnic_rss_cfg_p5(struct bnxt *bp, struct bnxt_vnic_info *vnic)
2303 : : {
2304 : : int i;
2305 : : int rc = 0;
2306 : 0 : int nr_ctxs = vnic->num_lb_ctxts;
2307 : 0 : struct hwrm_vnic_rss_cfg_input req = {.req_type = 0 };
2308 : 0 : struct hwrm_vnic_rss_cfg_output *resp = bp->hwrm_cmd_resp_addr;
2309 : :
2310 [ # # ]: 0 : for (i = 0; i < nr_ctxs; i++) {
2311 [ # # ]: 0 : HWRM_PREP(&req, HWRM_VNIC_RSS_CFG, BNXT_USE_CHIMP_MB);
2312 : :
2313 : 0 : req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
2314 : 0 : req.hash_type = rte_cpu_to_le_32(vnic->hash_type);
2315 : : /* When the vnic_id in the request field is a valid
2316 : : * one, the hash_mode_flags in the request field must
2317 : : * be set to DEFAULT. And any request to change the
2318 : : * default behavior must be done in a separate call
2319 : : * to HWRM_VNIC_RSS_CFG by exclusively setting hash
2320 : : * mode and vnic_id, rss_ctx_idx to INVALID.
2321 : : */
2322 : 0 : req.hash_mode_flags = BNXT_HASH_MODE_DEFAULT;
2323 : :
2324 : 0 : req.hash_key_tbl_addr =
2325 : 0 : rte_cpu_to_le_64(vnic->rss_hash_key_dma_addr);
2326 : :
2327 : 0 : req.ring_grp_tbl_addr =
2328 : 0 : rte_cpu_to_le_64(vnic->rss_table_dma_addr +
2329 : : i * BNXT_RSS_ENTRIES_PER_CTX_P5 *
2330 : : 2 * sizeof(uint16_t));
2331 : 0 : req.ring_table_pair_index = i;
2332 : 0 : req.rss_ctx_idx = rte_cpu_to_le_16(vnic->fw_grp_ids[i]);
2333 : :
2334 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req),
2335 : : BNXT_USE_CHIMP_MB);
2336 : :
2337 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2338 : : HWRM_UNLOCK();
2339 : 0 : PMD_DRV_LOG(DEBUG, "RSS CFG: Hash level %d\n", req.hash_mode_flags);
2340 : : }
2341 : :
2342 : : return rc;
2343 : : }
2344 : :
2345 : : static int
2346 : 0 : bnxt_hwrm_vnic_rss_cfg_hash_mode_p5(struct bnxt *bp, struct bnxt_vnic_info *vnic)
2347 : : {
2348 : 0 : struct hwrm_vnic_rss_cfg_output *resp = bp->hwrm_cmd_resp_addr;
2349 : 0 : struct hwrm_vnic_rss_cfg_input req = {.req_type = 0 };
2350 : : int rc = 0;
2351 : :
2352 : : /* The reason we are returning success here is that this
2353 : : * call is in the context of user/stack RSS configuration.
2354 : : * Even though OUTER RSS is not supported, the normal RSS
2355 : : * configuration should continue to work.
2356 : : */
2357 [ # # # # : 0 : if ((BNXT_CHIP_P5(bp) && BNXT_VNIC_OUTER_RSS_UNSUPPORTED(bp)) ||
# # # # #
# # # #
# ]
2358 [ # # ]: 0 : (!BNXT_CHIP_P5(bp) && !(bp->vnic_cap_flags & BNXT_VNIC_CAP_OUTER_RSS)))
2359 : : return 0;
2360 : :
2361 : : /* Don't call RSS hash level configuration if the current
2362 : : * hash level is the same as the hash level that is requested.
2363 : : */
2364 [ # # ]: 0 : if (vnic->prev_hash_mode == vnic->hash_mode)
2365 : : return 0;
2366 : :
2367 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_VNIC_RSS_CFG, BNXT_USE_CHIMP_MB);
2368 : :
2369 : : /* For FW, hash_mode == DEFAULT means that
2370 : : * the FW is capable of doing INNER & OUTER RSS as well.
2371 : : * DEFAULT doesn't mean that the FW is
2372 : : * going to change the hash_mode to INNER. However, for
2373 : : * the USER, DEFAULT means, change the hash mode to the
2374 : : * NIC's DEFAULT hash mode which is INNER.
2375 : : *
2376 : : * Hence, driver should make the translation of hash_mode
2377 : : * to INNERMOST when hash_mode from the dpdk stack is
2378 : : * DEFAULT.
2379 : : */
2380 [ # # ]: 0 : if (vnic->hash_mode == BNXT_HASH_MODE_DEFAULT)
2381 : 0 : req.hash_mode_flags = BNXT_HASH_MODE_INNERMOST;
2382 : : else
2383 : 0 : req.hash_mode_flags = vnic->hash_mode;
2384 : 0 : req.vnic_id = rte_cpu_to_le_16(BNXT_DFLT_VNIC_ID_INVALID);
2385 : 0 : req.rss_ctx_idx = rte_cpu_to_le_16(BNXT_RSS_CTX_IDX_INVALID);
2386 : :
2387 : 0 : PMD_DRV_LOG(DEBUG, "RSS CFG: Hash level %d\n", req.hash_mode_flags);
2388 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req),
2389 : : BNXT_USE_CHIMP_MB);
2390 : :
2391 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2392 : : /* Store the programmed hash_mode in prev_hash_mode so that
2393 : : * it can checked against the next user requested hash mode.
2394 : : */
2395 : : if (!rc)
2396 : 0 : vnic->prev_hash_mode = vnic->hash_mode;
2397 : : HWRM_UNLOCK();
2398 : 0 : return rc;
2399 : : }
2400 : :
2401 : : static int
2402 : 0 : bnxt_hwrm_vnic_rss_cfg_non_p5(struct bnxt *bp, struct bnxt_vnic_info *vnic)
2403 : : {
2404 : 0 : struct hwrm_vnic_rss_cfg_input req = {.req_type = 0 };
2405 : 0 : struct hwrm_vnic_rss_cfg_output *resp = bp->hwrm_cmd_resp_addr;
2406 : : int rc = 0;
2407 : :
2408 [ # # ]: 0 : if (vnic->num_lb_ctxts == 0)
2409 : : return rc;
2410 : :
2411 [ # # ]: 0 : HWRM_PREP(&req, HWRM_VNIC_RSS_CFG, BNXT_USE_CHIMP_MB);
2412 : :
2413 : 0 : req.hash_type = rte_cpu_to_le_32(vnic->hash_type);
2414 : 0 : req.hash_mode_flags = vnic->hash_mode;
2415 : :
2416 : 0 : req.ring_grp_tbl_addr =
2417 : 0 : rte_cpu_to_le_64(vnic->rss_table_dma_addr);
2418 : 0 : req.hash_key_tbl_addr =
2419 : 0 : rte_cpu_to_le_64(vnic->rss_hash_key_dma_addr);
2420 : 0 : req.rss_ctx_idx = rte_cpu_to_le_16(vnic->rss_rule);
2421 : 0 : req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
2422 : :
2423 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2424 : :
2425 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2426 : : HWRM_UNLOCK();
2427 : :
2428 : 0 : return rc;
2429 : : }
2430 : :
2431 : 0 : int bnxt_hwrm_vnic_rss_cfg(struct bnxt *bp,
2432 : : struct bnxt_vnic_info *vnic)
2433 : : {
2434 : : int rc = 0;
2435 : :
2436 [ # # ]: 0 : if (!vnic->rss_table)
2437 : : return 0;
2438 : :
2439 [ # # ]: 0 : if (BNXT_CHIP_P5(bp)) {
2440 : 0 : rc = bnxt_hwrm_vnic_rss_cfg_p5(bp, vnic);
2441 [ # # ]: 0 : if (rc)
2442 : : return rc;
2443 : : /* Configuring the hash mode has to be done in a
2444 : : * different VNIC_RSS_CFG HWRM command by setting
2445 : : * vnic_id & rss_ctx_id to INVALID. The only
2446 : : * exception to this is if the USER doesn't want
2447 : : * to change the default behavior. So, ideally
2448 : : * bnxt_hwrm_vnic_rss_cfg_hash_mode_p5 should be
2449 : : * called when user is explicitly changing the hash
2450 : : * mode. However, this logic will unconditionally
2451 : : * call bnxt_hwrm_vnic_rss_cfg_hash_mode_p5 to
2452 : : * simplify the logic as there is no harm in calling
2453 : : * bnxt_hwrm_vnic_rss_cfg_hash_mode_p5 even when
2454 : : * user is not setting it explicitly. Because, this
2455 : : * routine will convert the default value to inner
2456 : : * which is our adapter's default behavior.
2457 : : */
2458 : 0 : return bnxt_hwrm_vnic_rss_cfg_hash_mode_p5(bp, vnic);
2459 : : }
2460 : :
2461 : 0 : return bnxt_hwrm_vnic_rss_cfg_non_p5(bp, vnic);
2462 : : }
2463 : :
2464 : 0 : int bnxt_hwrm_vnic_plcmode_cfg(struct bnxt *bp,
2465 : : struct bnxt_vnic_info *vnic)
2466 : : {
2467 : : int rc = 0;
2468 : 0 : struct hwrm_vnic_plcmodes_cfg_input req = {.req_type = 0 };
2469 : 0 : struct hwrm_vnic_plcmodes_cfg_output *resp = bp->hwrm_cmd_resp_addr;
2470 : : uint16_t size;
2471 : :
2472 [ # # ]: 0 : if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
2473 : 0 : PMD_DRV_LOG(DEBUG, "VNIC ID %x\n", vnic->fw_vnic_id);
2474 : 0 : return rc;
2475 : : }
2476 : :
2477 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_VNIC_PLCMODES_CFG, BNXT_USE_CHIMP_MB);
2478 : :
2479 : 0 : req.flags = rte_cpu_to_le_32(
2480 : : HWRM_VNIC_PLCMODES_CFG_INPUT_FLAGS_JUMBO_PLACEMENT);
2481 : :
2482 : 0 : req.enables = rte_cpu_to_le_32(
2483 : : HWRM_VNIC_PLCMODES_CFG_INPUT_ENABLES_JUMBO_THRESH_VALID);
2484 : :
2485 [ # # ]: 0 : size = rte_pktmbuf_data_room_size(bp->rx_queues[0]->mb_pool);
2486 : 0 : size -= RTE_PKTMBUF_HEADROOM;
2487 : 0 : size = RTE_MIN(BNXT_MAX_PKT_LEN, size);
2488 : :
2489 : 0 : req.jumbo_thresh = rte_cpu_to_le_16(size);
2490 : 0 : req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
2491 : :
2492 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2493 : :
2494 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2495 : : HWRM_UNLOCK();
2496 : :
2497 : 0 : return rc;
2498 : : }
2499 : :
2500 : 0 : int bnxt_hwrm_vnic_tpa_cfg(struct bnxt *bp,
2501 : : struct bnxt_vnic_info *vnic, bool enable)
2502 : : {
2503 : : int rc = 0;
2504 : 0 : struct hwrm_vnic_tpa_cfg_input req = {.req_type = 0 };
2505 : 0 : struct hwrm_vnic_tpa_cfg_output *resp = bp->hwrm_cmd_resp_addr;
2506 : :
2507 [ # # # # ]: 0 : if (BNXT_CHIP_P5(bp) && !bp->max_tpa_v2) {
2508 [ # # ]: 0 : if (enable)
2509 : 0 : PMD_DRV_LOG(ERR, "No HW support for LRO\n");
2510 : 0 : return -ENOTSUP;
2511 : : }
2512 : :
2513 [ # # ]: 0 : if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
2514 : 0 : PMD_DRV_LOG(DEBUG, "Invalid vNIC ID\n");
2515 : 0 : return 0;
2516 : : }
2517 : :
2518 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_VNIC_TPA_CFG, BNXT_USE_CHIMP_MB);
2519 : :
2520 [ # # ]: 0 : if (enable) {
2521 : 0 : req.enables = rte_cpu_to_le_32(
2522 : : HWRM_VNIC_TPA_CFG_INPUT_ENABLES_MAX_AGG_SEGS |
2523 : : HWRM_VNIC_TPA_CFG_INPUT_ENABLES_MAX_AGGS |
2524 : : HWRM_VNIC_TPA_CFG_INPUT_ENABLES_MIN_AGG_LEN);
2525 : 0 : req.flags = rte_cpu_to_le_32(
2526 : : HWRM_VNIC_TPA_CFG_INPUT_FLAGS_TPA |
2527 : : HWRM_VNIC_TPA_CFG_INPUT_FLAGS_ENCAP_TPA |
2528 : : HWRM_VNIC_TPA_CFG_INPUT_FLAGS_RSC_WND_UPDATE |
2529 : : HWRM_VNIC_TPA_CFG_INPUT_FLAGS_GRO |
2530 : : HWRM_VNIC_TPA_CFG_INPUT_FLAGS_AGG_WITH_ECN |
2531 : : HWRM_VNIC_TPA_CFG_INPUT_FLAGS_AGG_WITH_SAME_GRE_SEQ);
2532 [ # # ]: 0 : req.max_aggs = rte_cpu_to_le_16(BNXT_TPA_MAX_AGGS(bp));
2533 [ # # ]: 0 : req.max_agg_segs = rte_cpu_to_le_16(BNXT_TPA_MAX_SEGS(bp));
2534 : 0 : req.min_agg_len = rte_cpu_to_le_32(512);
2535 : : }
2536 : 0 : req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
2537 : :
2538 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2539 : :
2540 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2541 : : HWRM_UNLOCK();
2542 : :
2543 : 0 : return rc;
2544 : : }
2545 : :
2546 : 0 : int bnxt_hwrm_func_vf_mac(struct bnxt *bp, uint16_t vf, const uint8_t *mac_addr)
2547 : : {
2548 : 0 : struct hwrm_func_cfg_input req = {0};
2549 : 0 : struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
2550 : : int rc;
2551 : :
2552 : 0 : req.flags = rte_cpu_to_le_32(bp->pf->vf_info[vf].func_cfg_flags);
2553 : 0 : req.enables = rte_cpu_to_le_32(
2554 : : HWRM_FUNC_CFG_INPUT_ENABLES_DFLT_MAC_ADDR);
2555 : : memcpy(req.dflt_mac_addr, mac_addr, sizeof(req.dflt_mac_addr));
2556 : 0 : req.fid = rte_cpu_to_le_16(bp->pf->vf_info[vf].fid);
2557 : :
2558 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_CFG, BNXT_USE_CHIMP_MB);
2559 : :
2560 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2561 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2562 : : HWRM_UNLOCK();
2563 : :
2564 : 0 : bp->pf->vf_info[vf].random_mac = false;
2565 : :
2566 : 0 : return rc;
2567 : : }
2568 : :
2569 : 0 : int bnxt_hwrm_func_qstats_tx_drop(struct bnxt *bp, uint16_t fid,
2570 : : uint64_t *dropped)
2571 : : {
2572 : : int rc = 0;
2573 : 0 : struct hwrm_func_qstats_input req = {.req_type = 0};
2574 : 0 : struct hwrm_func_qstats_output *resp = bp->hwrm_cmd_resp_addr;
2575 : :
2576 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_QSTATS, BNXT_USE_CHIMP_MB);
2577 : :
2578 : 0 : req.fid = rte_cpu_to_le_16(fid);
2579 : :
2580 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2581 : :
2582 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2583 : :
2584 [ # # ]: 0 : if (dropped)
2585 : 0 : *dropped = rte_le_to_cpu_64(resp->tx_drop_pkts);
2586 : :
2587 : : HWRM_UNLOCK();
2588 : :
2589 : 0 : return rc;
2590 : : }
2591 : :
2592 : 0 : int bnxt_hwrm_func_qstats(struct bnxt *bp, uint16_t fid,
2593 : : struct rte_eth_stats *stats,
2594 : : struct hwrm_func_qstats_output *func_qstats)
2595 : : {
2596 : : int rc = 0;
2597 : 0 : struct hwrm_func_qstats_input req = {.req_type = 0};
2598 : 0 : struct hwrm_func_qstats_output *resp = bp->hwrm_cmd_resp_addr;
2599 : :
2600 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_QSTATS, BNXT_USE_CHIMP_MB);
2601 : :
2602 : 0 : req.fid = rte_cpu_to_le_16(fid);
2603 : :
2604 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2605 : :
2606 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2607 [ # # ]: 0 : if (func_qstats)
2608 : : memcpy(func_qstats, resp,
2609 : : sizeof(struct hwrm_func_qstats_output));
2610 : :
2611 [ # # ]: 0 : if (!stats)
2612 : 0 : goto exit;
2613 : :
2614 : 0 : stats->ipackets = rte_le_to_cpu_64(resp->rx_ucast_pkts);
2615 : 0 : stats->ipackets += rte_le_to_cpu_64(resp->rx_mcast_pkts);
2616 : 0 : stats->ipackets += rte_le_to_cpu_64(resp->rx_bcast_pkts);
2617 : 0 : stats->ibytes = rte_le_to_cpu_64(resp->rx_ucast_bytes);
2618 : 0 : stats->ibytes += rte_le_to_cpu_64(resp->rx_mcast_bytes);
2619 : 0 : stats->ibytes += rte_le_to_cpu_64(resp->rx_bcast_bytes);
2620 : :
2621 : 0 : stats->opackets = rte_le_to_cpu_64(resp->tx_ucast_pkts);
2622 : 0 : stats->opackets += rte_le_to_cpu_64(resp->tx_mcast_pkts);
2623 : 0 : stats->opackets += rte_le_to_cpu_64(resp->tx_bcast_pkts);
2624 : 0 : stats->obytes = rte_le_to_cpu_64(resp->tx_ucast_bytes);
2625 : 0 : stats->obytes += rte_le_to_cpu_64(resp->tx_mcast_bytes);
2626 : 0 : stats->obytes += rte_le_to_cpu_64(resp->tx_bcast_bytes);
2627 : :
2628 : 0 : stats->imissed = rte_le_to_cpu_64(resp->rx_discard_pkts);
2629 : 0 : stats->ierrors = rte_le_to_cpu_64(resp->rx_drop_pkts);
2630 : 0 : stats->oerrors = rte_le_to_cpu_64(resp->tx_discard_pkts);
2631 : :
2632 : 0 : exit:
2633 : : HWRM_UNLOCK();
2634 : :
2635 : 0 : return rc;
2636 : : }
2637 : :
2638 : 0 : int bnxt_hwrm_func_clr_stats(struct bnxt *bp, uint16_t fid)
2639 : : {
2640 : : int rc = 0;
2641 : 0 : struct hwrm_func_clr_stats_input req = {.req_type = 0};
2642 : 0 : struct hwrm_func_clr_stats_output *resp = bp->hwrm_cmd_resp_addr;
2643 : :
2644 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_CLR_STATS, BNXT_USE_CHIMP_MB);
2645 : :
2646 : 0 : req.fid = rte_cpu_to_le_16(fid);
2647 : :
2648 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2649 : :
2650 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2651 : : HWRM_UNLOCK();
2652 : :
2653 : 0 : return rc;
2654 : : }
2655 : :
2656 : 0 : int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp)
2657 : : {
2658 : : unsigned int i;
2659 : : int rc = 0;
2660 : :
2661 [ # # ]: 0 : for (i = 0; i < bp->rx_cp_nr_rings + bp->tx_cp_nr_rings; i++) {
2662 : : struct bnxt_tx_queue *txq;
2663 : : struct bnxt_rx_queue *rxq;
2664 : : struct bnxt_cp_ring_info *cpr;
2665 : :
2666 [ # # ]: 0 : if (i >= bp->rx_cp_nr_rings) {
2667 : 0 : txq = bp->tx_queues[i - bp->rx_cp_nr_rings];
2668 : 0 : cpr = txq->cp_ring;
2669 : : } else {
2670 : 0 : rxq = bp->rx_queues[i];
2671 : 0 : cpr = rxq->cp_ring;
2672 : : }
2673 : :
2674 : 0 : rc = bnxt_hwrm_stat_clear(bp, cpr);
2675 [ # # ]: 0 : if (rc)
2676 : 0 : return rc;
2677 : : }
2678 : : return 0;
2679 : : }
2680 : :
2681 : : static int
2682 : 0 : bnxt_free_all_hwrm_stat_ctxs(struct bnxt *bp)
2683 : : {
2684 : : int rc;
2685 : : unsigned int i;
2686 : : struct bnxt_cp_ring_info *cpr;
2687 : :
2688 [ # # ]: 0 : for (i = 0; i < bp->rx_cp_nr_rings; i++) {
2689 : :
2690 : 0 : cpr = bp->rx_queues[i]->cp_ring;
2691 [ # # ]: 0 : if (BNXT_HAS_RING_GRPS(bp))
2692 : 0 : bp->grp_info[i].fw_stats_ctx = -1;
2693 [ # # ]: 0 : if (cpr == NULL)
2694 : 0 : continue;
2695 : 0 : rc = bnxt_hwrm_stat_ctx_free(bp, cpr);
2696 [ # # ]: 0 : if (rc)
2697 : 0 : return rc;
2698 : : }
2699 : :
2700 [ # # ]: 0 : for (i = 0; i < bp->tx_cp_nr_rings; i++) {
2701 : 0 : cpr = bp->tx_queues[i]->cp_ring;
2702 [ # # ]: 0 : if (cpr == NULL)
2703 : 0 : continue;
2704 : 0 : rc = bnxt_hwrm_stat_ctx_free(bp, cpr);
2705 [ # # ]: 0 : if (rc)
2706 : 0 : return rc;
2707 : : }
2708 : :
2709 : : return 0;
2710 : : }
2711 : :
2712 : : static int
2713 : 0 : bnxt_free_all_hwrm_ring_grps(struct bnxt *bp)
2714 : : {
2715 : : uint16_t idx;
2716 : : uint32_t rc = 0;
2717 : :
2718 [ # # ]: 0 : if (!BNXT_HAS_RING_GRPS(bp))
2719 : : return 0;
2720 : :
2721 [ # # ]: 0 : for (idx = 0; idx < bp->rx_cp_nr_rings; idx++) {
2722 : :
2723 [ # # ]: 0 : if (bp->grp_info[idx].fw_grp_id == INVALID_HW_RING_ID)
2724 : 0 : continue;
2725 : :
2726 : 0 : rc = bnxt_hwrm_ring_grp_free(bp, idx);
2727 : :
2728 [ # # ]: 0 : if (rc)
2729 : 0 : return rc;
2730 : : }
2731 : 0 : return rc;
2732 : : }
2733 : :
2734 : 0 : void bnxt_free_nq_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)
2735 : : {
2736 : 0 : struct bnxt_ring *cp_ring = cpr->cp_ring_struct;
2737 : :
2738 : 0 : bnxt_hwrm_ring_free(bp, cp_ring,
2739 : : HWRM_RING_FREE_INPUT_RING_TYPE_NQ,
2740 : : INVALID_HW_RING_ID);
2741 : 0 : memset(cpr->cp_desc_ring, 0,
2742 : 0 : cpr->cp_ring_struct->ring_size * sizeof(*cpr->cp_desc_ring));
2743 : 0 : cpr->cp_raw_cons = 0;
2744 : 0 : }
2745 : :
2746 : 0 : void bnxt_free_cp_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)
2747 : : {
2748 : 0 : struct bnxt_ring *cp_ring = cpr->cp_ring_struct;
2749 : :
2750 : 0 : bnxt_hwrm_ring_free(bp, cp_ring,
2751 : : HWRM_RING_FREE_INPUT_RING_TYPE_L2_CMPL,
2752 : : INVALID_HW_RING_ID);
2753 : 0 : memset(cpr->cp_desc_ring, 0,
2754 : 0 : cpr->cp_ring_struct->ring_size * sizeof(*cpr->cp_desc_ring));
2755 : 0 : cpr->cp_raw_cons = 0;
2756 : 0 : }
2757 : :
2758 : 0 : void bnxt_free_hwrm_rx_ring(struct bnxt *bp, int queue_index)
2759 : : {
2760 : 0 : struct bnxt_rx_queue *rxq = bp->rx_queues[queue_index];
2761 [ # # ]: 0 : struct bnxt_rx_ring_info *rxr = rxq ? rxq->rx_ring : NULL;
2762 [ # # ]: 0 : struct bnxt_ring *ring = rxr ? rxr->rx_ring_struct : NULL;
2763 [ # # ]: 0 : struct bnxt_cp_ring_info *cpr = rxq ? rxq->cp_ring : NULL;
2764 : :
2765 [ # # ]: 0 : if (BNXT_HAS_RING_GRPS(bp))
2766 : 0 : bnxt_hwrm_ring_grp_free(bp, queue_index);
2767 : :
2768 [ # # ]: 0 : if (ring != NULL && cpr != NULL)
2769 : 0 : bnxt_hwrm_ring_free(bp, ring,
2770 : : HWRM_RING_FREE_INPUT_RING_TYPE_RX,
2771 : 0 : cpr->cp_ring_struct->fw_ring_id);
2772 [ # # ]: 0 : if (BNXT_HAS_RING_GRPS(bp))
2773 : 0 : bp->grp_info[queue_index].rx_fw_ring_id = INVALID_HW_RING_ID;
2774 : :
2775 : : /* Check agg ring struct explicitly.
2776 : : * bnxt_need_agg_ring() returns the current state of offload flags,
2777 : : * but we may have to deal with agg ring struct before the offload
2778 : : * flags are updated.
2779 : : */
2780 [ # # # # ]: 0 : if (!bnxt_need_agg_ring(bp->eth_dev) ||
2781 [ # # ]: 0 : (rxr && rxr->ag_ring_struct == NULL))
2782 : 0 : goto no_agg;
2783 : :
2784 [ # # ]: 0 : ring = rxr ? rxr->ag_ring_struct : NULL;
2785 [ # # ]: 0 : if (ring != NULL && cpr != NULL) {
2786 : 0 : bnxt_hwrm_ring_free(bp, ring,
2787 : 0 : BNXT_CHIP_P5(bp) ?
2788 : : HWRM_RING_FREE_INPUT_RING_TYPE_RX_AGG :
2789 : : HWRM_RING_FREE_INPUT_RING_TYPE_RX,
2790 [ # # ]: 0 : cpr->cp_ring_struct->fw_ring_id);
2791 : : }
2792 [ # # ]: 0 : if (BNXT_HAS_RING_GRPS(bp))
2793 : 0 : bp->grp_info[queue_index].ag_fw_ring_id = INVALID_HW_RING_ID;
2794 : :
2795 : 0 : no_agg:
2796 [ # # ]: 0 : if (cpr != NULL) {
2797 : 0 : bnxt_hwrm_stat_ctx_free(bp, cpr);
2798 : 0 : bnxt_free_cp_ring(bp, cpr);
2799 : : }
2800 : :
2801 [ # # ]: 0 : if (BNXT_HAS_RING_GRPS(bp))
2802 : 0 : bp->grp_info[queue_index].cp_fw_ring_id = INVALID_HW_RING_ID;
2803 : 0 : }
2804 : :
2805 : 0 : int bnxt_hwrm_rx_ring_reset(struct bnxt *bp, int queue_index)
2806 : : {
2807 : : int rc;
2808 : 0 : struct hwrm_ring_reset_input req = {.req_type = 0 };
2809 : 0 : struct hwrm_ring_reset_output *resp = bp->hwrm_cmd_resp_addr;
2810 : :
2811 [ # # ]: 0 : HWRM_PREP(&req, HWRM_RING_RESET, BNXT_USE_CHIMP_MB);
2812 : :
2813 : 0 : req.ring_type = HWRM_RING_RESET_INPUT_RING_TYPE_RX_RING_GRP;
2814 : 0 : req.ring_id = rte_cpu_to_le_16(bp->grp_info[queue_index].fw_grp_id);
2815 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2816 : :
2817 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
2818 : :
2819 : : HWRM_UNLOCK();
2820 : :
2821 : 0 : return rc;
2822 : : }
2823 : :
2824 : : static int
2825 : 0 : bnxt_free_all_hwrm_rings(struct bnxt *bp)
2826 : : {
2827 : : unsigned int i;
2828 : :
2829 [ # # ]: 0 : for (i = 0; i < bp->tx_cp_nr_rings; i++)
2830 : 0 : bnxt_free_hwrm_tx_ring(bp, i);
2831 : :
2832 [ # # ]: 0 : for (i = 0; i < bp->rx_cp_nr_rings; i++)
2833 : 0 : bnxt_free_hwrm_rx_ring(bp, i);
2834 : :
2835 : 0 : return 0;
2836 : : }
2837 : :
2838 : 0 : int bnxt_alloc_all_hwrm_ring_grps(struct bnxt *bp)
2839 : : {
2840 : : uint16_t i;
2841 : : uint32_t rc = 0;
2842 : :
2843 [ # # ]: 0 : if (!BNXT_HAS_RING_GRPS(bp))
2844 : : return 0;
2845 : :
2846 [ # # ]: 0 : for (i = 0; i < bp->rx_cp_nr_rings; i++) {
2847 : 0 : rc = bnxt_hwrm_ring_grp_alloc(bp, i);
2848 [ # # ]: 0 : if (rc)
2849 : 0 : return rc;
2850 : : }
2851 : : return rc;
2852 : : }
2853 : :
2854 : : /*
2855 : : * HWRM utility functions
2856 : : */
2857 : :
2858 : 0 : void bnxt_free_hwrm_resources(struct bnxt *bp)
2859 : : {
2860 : : /* Release memzone */
2861 : 0 : rte_free(bp->hwrm_cmd_resp_addr);
2862 : 0 : rte_free(bp->hwrm_short_cmd_req_addr);
2863 : 0 : bp->hwrm_cmd_resp_addr = NULL;
2864 : 0 : bp->hwrm_short_cmd_req_addr = NULL;
2865 : 0 : bp->hwrm_cmd_resp_dma_addr = 0;
2866 : 0 : bp->hwrm_short_cmd_req_dma_addr = 0;
2867 : 0 : }
2868 : :
2869 : 0 : int bnxt_alloc_hwrm_resources(struct bnxt *bp)
2870 : : {
2871 : 0 : struct rte_pci_device *pdev = bp->pdev;
2872 : : char type[RTE_MEMZONE_NAMESIZE];
2873 : :
2874 : 0 : sprintf(type, "bnxt_hwrm_" PCI_PRI_FMT, pdev->addr.domain,
2875 : 0 : pdev->addr.bus, pdev->addr.devid, pdev->addr.function);
2876 : 0 : bp->max_resp_len = BNXT_PAGE_SIZE;
2877 : 0 : bp->hwrm_cmd_resp_addr = rte_malloc(type, bp->max_resp_len, 0);
2878 [ # # ]: 0 : if (bp->hwrm_cmd_resp_addr == NULL)
2879 : : return -ENOMEM;
2880 : 0 : bp->hwrm_cmd_resp_dma_addr =
2881 : 0 : rte_malloc_virt2iova(bp->hwrm_cmd_resp_addr);
2882 [ # # ]: 0 : if (bp->hwrm_cmd_resp_dma_addr == RTE_BAD_IOVA) {
2883 : 0 : PMD_DRV_LOG(ERR,
2884 : : "unable to map response address to physical memory\n");
2885 : 0 : return -ENOMEM;
2886 : : }
2887 : : rte_spinlock_init(&bp->hwrm_lock);
2888 : :
2889 : 0 : return 0;
2890 : : }
2891 : :
2892 : : int
2893 : 0 : bnxt_clear_one_vnic_filter(struct bnxt *bp, struct bnxt_filter_info *filter)
2894 : : {
2895 : : int rc = 0;
2896 : :
2897 [ # # ]: 0 : if (filter->filter_type == HWRM_CFA_EM_FILTER) {
2898 : 0 : rc = bnxt_hwrm_clear_em_filter(bp, filter);
2899 [ # # ]: 0 : if (rc)
2900 : : return rc;
2901 [ # # ]: 0 : } else if (filter->filter_type == HWRM_CFA_NTUPLE_FILTER) {
2902 : 0 : rc = bnxt_hwrm_clear_ntuple_filter(bp, filter);
2903 [ # # ]: 0 : if (rc)
2904 : : return rc;
2905 : : }
2906 : :
2907 : 0 : rc = bnxt_hwrm_clear_l2_filter(bp, filter);
2908 : 0 : return rc;
2909 : : }
2910 : :
2911 : : static int
2912 : 0 : bnxt_clear_hwrm_vnic_filters(struct bnxt *bp, struct bnxt_vnic_info *vnic)
2913 : : {
2914 : : struct bnxt_filter_info *filter;
2915 : : int rc = 0;
2916 : :
2917 [ # # ]: 0 : STAILQ_FOREACH(filter, &vnic->filter, next) {
2918 : 0 : rc = bnxt_clear_one_vnic_filter(bp, filter);
2919 [ # # # # : 0 : STAILQ_REMOVE(&vnic->filter, filter, bnxt_filter_info, next);
# # # # ]
2920 : 0 : bnxt_free_filter(bp, filter);
2921 : : }
2922 : 0 : return rc;
2923 : : }
2924 : :
2925 : : static int
2926 : 0 : bnxt_clear_hwrm_vnic_flows(struct bnxt *bp, struct bnxt_vnic_info *vnic)
2927 : : {
2928 : : struct bnxt_filter_info *filter;
2929 : : struct rte_flow *flow;
2930 : : int rc = 0;
2931 : :
2932 [ # # ]: 0 : while (!STAILQ_EMPTY(&vnic->flow_list)) {
2933 : : flow = STAILQ_FIRST(&vnic->flow_list);
2934 : 0 : filter = flow->filter;
2935 : 0 : PMD_DRV_LOG(DEBUG, "filter type %d\n", filter->filter_type);
2936 : 0 : rc = bnxt_clear_one_vnic_filter(bp, filter);
2937 : :
2938 [ # # # # : 0 : STAILQ_REMOVE(&vnic->flow_list, flow, rte_flow, next);
# # # # ]
2939 : 0 : rte_free(flow);
2940 : : }
2941 : 0 : return rc;
2942 : : }
2943 : :
2944 : 0 : int bnxt_set_hwrm_vnic_filters(struct bnxt *bp, struct bnxt_vnic_info *vnic)
2945 : : {
2946 : : struct bnxt_filter_info *filter;
2947 : : int rc = 0;
2948 : :
2949 [ # # ]: 0 : STAILQ_FOREACH(filter, &vnic->filter, next) {
2950 [ # # ]: 0 : if (filter->filter_type == HWRM_CFA_EM_FILTER)
2951 : 0 : rc = bnxt_hwrm_set_em_filter(bp, filter->dst_id,
2952 : : filter);
2953 [ # # ]: 0 : else if (filter->filter_type == HWRM_CFA_NTUPLE_FILTER)
2954 : 0 : rc = bnxt_hwrm_set_ntuple_filter(bp, filter->dst_id,
2955 : : filter);
2956 : : else
2957 : 0 : rc = bnxt_hwrm_set_l2_filter(bp, vnic->fw_vnic_id,
2958 : : filter);
2959 [ # # ]: 0 : if (rc)
2960 : : break;
2961 : : }
2962 : 0 : return rc;
2963 : : }
2964 : :
2965 : : static void
2966 : 0 : bnxt_free_tunnel_ports(struct bnxt *bp)
2967 : : {
2968 [ # # ]: 0 : if (bp->vxlan_port_cnt)
2969 : 0 : bnxt_hwrm_tunnel_dst_port_free(bp, bp->vxlan_fw_dst_port_id,
2970 : : HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_VXLAN);
2971 : :
2972 [ # # ]: 0 : if (bp->geneve_port_cnt)
2973 : 0 : bnxt_hwrm_tunnel_dst_port_free(bp, bp->geneve_fw_dst_port_id,
2974 : : HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_GENEVE);
2975 : :
2976 [ # # ]: 0 : if (bp->ecpri_port_cnt)
2977 : 0 : bnxt_hwrm_tunnel_dst_port_free(bp, bp->ecpri_fw_dst_port_id,
2978 : : HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_ECPRI);
2979 : 0 : }
2980 : :
2981 : 0 : void bnxt_free_all_hwrm_resources(struct bnxt *bp)
2982 : : {
2983 : : int i;
2984 : :
2985 [ # # ]: 0 : if (bp->vnic_info == NULL)
2986 : : return;
2987 : :
2988 : : /*
2989 : : * Cleanup VNICs in reverse order, to make sure the L2 filter
2990 : : * from vnic0 is last to be cleaned up.
2991 : : */
2992 [ # # ]: 0 : for (i = bp->max_vnics - 1; i >= 0; i--) {
2993 : 0 : struct bnxt_vnic_info *vnic = &bp->vnic_info[i];
2994 : :
2995 [ # # ]: 0 : if (vnic->fw_vnic_id == INVALID_HW_RING_ID)
2996 : 0 : continue;
2997 : :
2998 : 0 : bnxt_clear_hwrm_vnic_flows(bp, vnic);
2999 : :
3000 : 0 : bnxt_clear_hwrm_vnic_filters(bp, vnic);
3001 : :
3002 : 0 : bnxt_hwrm_vnic_ctx_free(bp, vnic);
3003 : :
3004 : 0 : bnxt_hwrm_vnic_tpa_cfg(bp, vnic, false);
3005 : :
3006 : 0 : bnxt_hwrm_vnic_free(bp, vnic);
3007 : :
3008 : 0 : rte_free(vnic->fw_grp_ids);
3009 : 0 : vnic->fw_grp_ids = NULL;
3010 : : }
3011 : : /* Ring resources */
3012 : 0 : bnxt_free_all_hwrm_rings(bp);
3013 : 0 : bnxt_free_all_hwrm_ring_grps(bp);
3014 : 0 : bnxt_free_all_hwrm_stat_ctxs(bp);
3015 : 0 : bnxt_free_tunnel_ports(bp);
3016 : : }
3017 : :
3018 : : static uint16_t bnxt_parse_eth_link_duplex(uint32_t conf_link_speed)
3019 : : {
3020 : : uint8_t hw_link_duplex = HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_BOTH;
3021 : :
3022 : 0 : if ((conf_link_speed & RTE_ETH_LINK_SPEED_FIXED) == RTE_ETH_LINK_SPEED_AUTONEG)
3023 : : return HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_BOTH;
3024 : :
3025 [ # # ]: 0 : switch (conf_link_speed) {
3026 : : case RTE_ETH_LINK_SPEED_10M_HD:
3027 : : case RTE_ETH_LINK_SPEED_100M_HD:
3028 : : /* FALLTHROUGH */
3029 : : return HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_HALF;
3030 : : }
3031 : 0 : return hw_link_duplex;
3032 : : }
3033 : :
3034 : : static uint16_t bnxt_check_eth_link_autoneg(uint32_t conf_link)
3035 : : {
3036 : 0 : return !conf_link;
3037 : : }
3038 : :
3039 : 0 : static uint16_t bnxt_parse_eth_link_speed(uint32_t conf_link_speed,
3040 : : struct bnxt_link_info *link_info)
3041 : : {
3042 : : uint16_t eth_link_speed = 0;
3043 : :
3044 [ # # ]: 0 : if (conf_link_speed == RTE_ETH_LINK_SPEED_AUTONEG)
3045 : : return RTE_ETH_LINK_SPEED_AUTONEG;
3046 : :
3047 [ # # # # : 0 : switch (conf_link_speed & ~RTE_ETH_LINK_SPEED_FIXED) {
# # # # #
# # ]
3048 : : case RTE_ETH_LINK_SPEED_100M:
3049 : : case RTE_ETH_LINK_SPEED_100M_HD:
3050 : : /* FALLTHROUGH */
3051 : : eth_link_speed =
3052 : : HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_100MB;
3053 : : break;
3054 : 0 : case RTE_ETH_LINK_SPEED_1G:
3055 : : eth_link_speed =
3056 : : HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_1GB;
3057 : 0 : break;
3058 : 0 : case RTE_ETH_LINK_SPEED_2_5G:
3059 : : eth_link_speed =
3060 : : HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_2_5GB;
3061 : 0 : break;
3062 : 0 : case RTE_ETH_LINK_SPEED_10G:
3063 : : eth_link_speed =
3064 : : HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_10GB;
3065 : 0 : break;
3066 : 0 : case RTE_ETH_LINK_SPEED_20G:
3067 : : eth_link_speed =
3068 : : HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_20GB;
3069 : 0 : break;
3070 : 0 : case RTE_ETH_LINK_SPEED_25G:
3071 : : eth_link_speed =
3072 : : HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_25GB;
3073 : 0 : break;
3074 : 0 : case RTE_ETH_LINK_SPEED_40G:
3075 : : eth_link_speed =
3076 : : HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_40GB;
3077 : 0 : break;
3078 : 0 : case RTE_ETH_LINK_SPEED_50G:
3079 [ # # ]: 0 : if (link_info->support_pam4_speeds &
3080 : : HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_PAM4_SPEEDS_50G) {
3081 : : eth_link_speed = HWRM_PORT_PHY_CFG_INPUT_FORCE_PAM4_LINK_SPEED_50GB;
3082 : 0 : link_info->link_signal_mode = BNXT_SIG_MODE_PAM4;
3083 : : } else {
3084 : : eth_link_speed = HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_50GB;
3085 : 0 : link_info->link_signal_mode = BNXT_SIG_MODE_NRZ;
3086 : : }
3087 : : break;
3088 : 0 : case RTE_ETH_LINK_SPEED_100G:
3089 [ # # ]: 0 : if (link_info->support_pam4_speeds &
3090 : : HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_PAM4_SPEEDS_100G) {
3091 : : eth_link_speed = HWRM_PORT_PHY_CFG_INPUT_FORCE_PAM4_LINK_SPEED_100GB;
3092 : 0 : link_info->link_signal_mode = BNXT_SIG_MODE_PAM4;
3093 : : } else {
3094 : : eth_link_speed = HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_100GB;
3095 : 0 : link_info->link_signal_mode = BNXT_SIG_MODE_NRZ;
3096 : : }
3097 : : break;
3098 : 0 : case RTE_ETH_LINK_SPEED_200G:
3099 : : eth_link_speed =
3100 : : HWRM_PORT_PHY_CFG_INPUT_FORCE_PAM4_LINK_SPEED_200GB;
3101 : 0 : link_info->link_signal_mode = BNXT_SIG_MODE_PAM4;
3102 : 0 : break;
3103 : 0 : default:
3104 : 0 : PMD_DRV_LOG(ERR,
3105 : : "Unsupported link speed %d; default to AUTO\n",
3106 : : conf_link_speed);
3107 : 0 : break;
3108 : : }
3109 : : return eth_link_speed;
3110 : : }
3111 : :
3112 : : #define BNXT_SUPPORTED_SPEEDS (RTE_ETH_LINK_SPEED_100M | RTE_ETH_LINK_SPEED_100M_HD | \
3113 : : RTE_ETH_LINK_SPEED_1G | RTE_ETH_LINK_SPEED_2_5G | \
3114 : : RTE_ETH_LINK_SPEED_10G | RTE_ETH_LINK_SPEED_20G | RTE_ETH_LINK_SPEED_25G | \
3115 : : RTE_ETH_LINK_SPEED_40G | RTE_ETH_LINK_SPEED_50G | \
3116 : : RTE_ETH_LINK_SPEED_100G | RTE_ETH_LINK_SPEED_200G)
3117 : :
3118 : 0 : static int bnxt_validate_link_speed(struct bnxt *bp)
3119 : : {
3120 : 0 : uint32_t link_speed = bp->eth_dev->data->dev_conf.link_speeds;
3121 : 0 : uint16_t port_id = bp->eth_dev->data->port_id;
3122 : : uint32_t link_speed_capa;
3123 : : uint32_t one_speed;
3124 : :
3125 [ # # ]: 0 : if (link_speed == RTE_ETH_LINK_SPEED_AUTONEG)
3126 : : return 0;
3127 : :
3128 : 0 : link_speed_capa = bnxt_get_speed_capabilities(bp);
3129 : :
3130 [ # # ]: 0 : if (link_speed & RTE_ETH_LINK_SPEED_FIXED) {
3131 : 0 : one_speed = link_speed & ~RTE_ETH_LINK_SPEED_FIXED;
3132 : :
3133 [ # # ]: 0 : if (one_speed & (one_speed - 1)) {
3134 : 0 : PMD_DRV_LOG(ERR,
3135 : : "Invalid advertised speeds (%u) for port %u\n",
3136 : : link_speed, port_id);
3137 : 0 : return -EINVAL;
3138 : : }
3139 [ # # ]: 0 : if ((one_speed & link_speed_capa) != one_speed) {
3140 : 0 : PMD_DRV_LOG(ERR,
3141 : : "Unsupported advertised speed (%u) for port %u\n",
3142 : : link_speed, port_id);
3143 : 0 : return -EINVAL;
3144 : : }
3145 : : } else {
3146 [ # # ]: 0 : if (!(link_speed & link_speed_capa)) {
3147 : 0 : PMD_DRV_LOG(ERR,
3148 : : "Unsupported advertised speeds (%u) for port %u\n",
3149 : : link_speed, port_id);
3150 : 0 : return -EINVAL;
3151 : : }
3152 : : }
3153 : : return 0;
3154 : : }
3155 : :
3156 : : static uint16_t
3157 : 0 : bnxt_parse_eth_link_speed_mask(struct bnxt *bp, uint32_t link_speed)
3158 : : {
3159 : : uint16_t ret = 0;
3160 : :
3161 [ # # ]: 0 : if (link_speed == RTE_ETH_LINK_SPEED_AUTONEG) {
3162 [ # # ]: 0 : if (bp->link_info->support_speeds)
3163 : : return bp->link_info->support_speeds;
3164 : : link_speed = BNXT_SUPPORTED_SPEEDS;
3165 : : }
3166 : :
3167 [ # # ]: 0 : if (link_speed & RTE_ETH_LINK_SPEED_100M)
3168 : : ret |= HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_100MB;
3169 [ # # ]: 0 : if (link_speed & RTE_ETH_LINK_SPEED_100M_HD)
3170 : : ret |= HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_100MB;
3171 [ # # ]: 0 : if (link_speed & RTE_ETH_LINK_SPEED_1G)
3172 : 0 : ret |= HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_1GB;
3173 [ # # ]: 0 : if (link_speed & RTE_ETH_LINK_SPEED_2_5G)
3174 : 0 : ret |= HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_2_5GB;
3175 [ # # ]: 0 : if (link_speed & RTE_ETH_LINK_SPEED_10G)
3176 : 0 : ret |= HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_10GB;
3177 [ # # ]: 0 : if (link_speed & RTE_ETH_LINK_SPEED_20G)
3178 : 0 : ret |= HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_20GB;
3179 [ # # ]: 0 : if (link_speed & RTE_ETH_LINK_SPEED_25G)
3180 : 0 : ret |= HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_25GB;
3181 [ # # ]: 0 : if (link_speed & RTE_ETH_LINK_SPEED_40G)
3182 : 0 : ret |= HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_40GB;
3183 [ # # ]: 0 : if (link_speed & RTE_ETH_LINK_SPEED_50G)
3184 : 0 : ret |= HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_50GB;
3185 [ # # ]: 0 : if (link_speed & RTE_ETH_LINK_SPEED_100G)
3186 : 0 : ret |= HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_100GB;
3187 [ # # ]: 0 : if (link_speed & RTE_ETH_LINK_SPEED_200G)
3188 : 0 : ret |= HWRM_PORT_PHY_CFG_INPUT_FORCE_PAM4_LINK_SPEED_200GB;
3189 : : return ret;
3190 : : }
3191 : :
3192 : 0 : static uint32_t bnxt_parse_hw_link_speed(uint16_t hw_link_speed)
3193 : : {
3194 : : uint32_t eth_link_speed = RTE_ETH_SPEED_NUM_NONE;
3195 : :
3196 [ # # # # : 0 : switch (hw_link_speed) {
# # # # #
# # ]
3197 : : case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_100MB:
3198 : : eth_link_speed = RTE_ETH_SPEED_NUM_100M;
3199 : : break;
3200 : 0 : case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_1GB:
3201 : : eth_link_speed = RTE_ETH_SPEED_NUM_1G;
3202 : 0 : break;
3203 : 0 : case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_2_5GB:
3204 : : eth_link_speed = RTE_ETH_SPEED_NUM_2_5G;
3205 : 0 : break;
3206 : 0 : case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_10GB:
3207 : : eth_link_speed = RTE_ETH_SPEED_NUM_10G;
3208 : 0 : break;
3209 : 0 : case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_20GB:
3210 : : eth_link_speed = RTE_ETH_SPEED_NUM_20G;
3211 : 0 : break;
3212 : 0 : case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_25GB:
3213 : : eth_link_speed = RTE_ETH_SPEED_NUM_25G;
3214 : 0 : break;
3215 : 0 : case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_40GB:
3216 : : eth_link_speed = RTE_ETH_SPEED_NUM_40G;
3217 : 0 : break;
3218 : 0 : case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_50GB:
3219 : : eth_link_speed = RTE_ETH_SPEED_NUM_50G;
3220 : 0 : break;
3221 : 0 : case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_100GB:
3222 : : eth_link_speed = RTE_ETH_SPEED_NUM_100G;
3223 : 0 : break;
3224 : 0 : case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_200GB:
3225 : : eth_link_speed = RTE_ETH_SPEED_NUM_200G;
3226 : 0 : break;
3227 : 0 : case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_2GB:
3228 : : default:
3229 : 0 : PMD_DRV_LOG(ERR, "HWRM link speed %d not defined\n",
3230 : : hw_link_speed);
3231 : 0 : break;
3232 : : }
3233 : 0 : return eth_link_speed;
3234 : : }
3235 : :
3236 : 0 : static uint16_t bnxt_parse_hw_link_duplex(uint16_t hw_link_duplex)
3237 : : {
3238 : : uint16_t eth_link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
3239 : :
3240 [ # # # ]: 0 : switch (hw_link_duplex) {
3241 : : case HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_BOTH:
3242 : : case HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_FULL:
3243 : : /* FALLTHROUGH */
3244 : : eth_link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
3245 : : break;
3246 : 0 : case HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_HALF:
3247 : : eth_link_duplex = RTE_ETH_LINK_HALF_DUPLEX;
3248 : 0 : break;
3249 : 0 : default:
3250 : 0 : PMD_DRV_LOG(ERR, "HWRM link duplex %d not defined\n",
3251 : : hw_link_duplex);
3252 : 0 : break;
3253 : : }
3254 : 0 : return eth_link_duplex;
3255 : : }
3256 : :
3257 : 0 : int bnxt_get_hwrm_link_config(struct bnxt *bp, struct rte_eth_link *link)
3258 : : {
3259 : : int rc = 0;
3260 : 0 : struct bnxt_link_info *link_info = bp->link_info;
3261 : :
3262 : 0 : rc = bnxt_hwrm_port_phy_qcaps(bp);
3263 [ # # ]: 0 : if (rc)
3264 : 0 : PMD_DRV_LOG(ERR, "Get link config failed with rc %d\n", rc);
3265 : :
3266 : 0 : rc = bnxt_hwrm_port_phy_qcfg(bp, link_info);
3267 [ # # ]: 0 : if (rc) {
3268 : 0 : PMD_DRV_LOG(ERR, "Get link config failed with rc %d\n", rc);
3269 : 0 : goto exit;
3270 : : }
3271 : :
3272 [ # # ]: 0 : if (link_info->link_speed)
3273 : 0 : link->link_speed =
3274 : 0 : bnxt_parse_hw_link_speed(link_info->link_speed);
3275 : : else
3276 : 0 : link->link_speed = RTE_ETH_SPEED_NUM_NONE;
3277 : 0 : link->link_duplex = bnxt_parse_hw_link_duplex(link_info->duplex);
3278 : 0 : link->link_status = link_info->link_up;
3279 : 0 : link->link_autoneg = link_info->auto_mode ==
3280 : : HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_MODE_NONE ?
3281 : 0 : RTE_ETH_LINK_FIXED : RTE_ETH_LINK_AUTONEG;
3282 : 0 : exit:
3283 : 0 : return rc;
3284 : : }
3285 : :
3286 : 0 : int bnxt_set_hwrm_link_config(struct bnxt *bp, bool link_up)
3287 : : {
3288 : : int rc = 0;
3289 : 0 : struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf;
3290 : : struct bnxt_link_info link_req;
3291 : : uint16_t speed, autoneg;
3292 : :
3293 [ # # ]: 0 : if (!BNXT_SINGLE_PF(bp) || BNXT_VF(bp))
3294 : : return 0;
3295 : :
3296 : 0 : rc = bnxt_validate_link_speed(bp);
3297 [ # # ]: 0 : if (rc)
3298 : 0 : goto error;
3299 : :
3300 : : memset(&link_req, 0, sizeof(link_req));
3301 : 0 : link_req.link_up = link_up;
3302 [ # # ]: 0 : if (!link_up)
3303 : 0 : goto port_phy_cfg;
3304 : :
3305 : : /* Get user requested autoneg setting */
3306 : 0 : autoneg = bnxt_check_eth_link_autoneg(dev_conf->link_speeds);
3307 : :
3308 [ # # ]: 0 : if (BNXT_CHIP_P5(bp) &&
3309 [ # # ]: 0 : dev_conf->link_speeds & RTE_ETH_LINK_SPEED_40G) {
3310 : : /* 40G is not supported as part of media auto detect.
3311 : : * The speed should be forced and autoneg disabled
3312 : : * to configure 40G speed.
3313 : : */
3314 : 0 : PMD_DRV_LOG(INFO, "Disabling autoneg for 40G\n");
3315 : : autoneg = 0;
3316 : : }
3317 : :
3318 : : /* Override based on current Autoneg setting in PHY for 200G */
3319 [ # # # # : 0 : if (autoneg == 1 && BNXT_CHIP_P5(bp) && bp->link_info->auto_mode == 0 &&
# # ]
3320 [ # # ]: 0 : bp->link_info->force_pam4_link_speed ==
3321 : : HWRM_PORT_PHY_CFG_INPUT_FORCE_PAM4_LINK_SPEED_200GB) {
3322 : : autoneg = 0;
3323 : 0 : PMD_DRV_LOG(DEBUG, "Disabling autoneg for 200G\n");
3324 : : }
3325 : :
3326 : 0 : speed = bnxt_parse_eth_link_speed(dev_conf->link_speeds,
3327 : : bp->link_info);
3328 : 0 : link_req.phy_flags = HWRM_PORT_PHY_CFG_INPUT_FLAGS_RESET_PHY;
3329 : : /* Autoneg can be done only when the FW allows. */
3330 [ # # ]: 0 : if (autoneg == 1 &&
3331 [ # # # # ]: 0 : (bp->link_info->support_auto_speeds || bp->link_info->support_pam4_auto_speeds)) {
3332 : 0 : link_req.phy_flags |=
3333 : : HWRM_PORT_PHY_CFG_INPUT_FLAGS_RESTART_AUTONEG;
3334 : 0 : link_req.auto_link_speed_mask =
3335 : 0 : bnxt_parse_eth_link_speed_mask(bp,
3336 : : dev_conf->link_speeds);
3337 : 0 : link_req.auto_pam4_link_speed_mask =
3338 : 0 : bp->link_info->auto_pam4_link_speed_mask;
3339 : : } else {
3340 : 0 : if (bp->link_info->phy_type ==
3341 [ # # ]: 0 : HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASET ||
3342 : : bp->link_info->phy_type ==
3343 : 0 : HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASETE ||
3344 [ # # ]: 0 : bp->link_info->media_type ==
3345 : : HWRM_PORT_PHY_QCFG_OUTPUT_MEDIA_TYPE_TP) {
3346 : 0 : PMD_DRV_LOG(ERR, "10GBase-T devices must autoneg\n");
3347 : 0 : return -EINVAL;
3348 : : }
3349 : :
3350 : 0 : link_req.phy_flags |= HWRM_PORT_PHY_CFG_INPUT_FLAGS_FORCE;
3351 : : /* If user wants a particular speed try that first. */
3352 [ # # ]: 0 : if (speed)
3353 : 0 : link_req.link_speed = speed;
3354 [ # # ]: 0 : else if (bp->link_info->force_pam4_link_speed)
3355 : 0 : link_req.link_speed =
3356 : : bp->link_info->force_pam4_link_speed;
3357 [ # # ]: 0 : else if (bp->link_info->force_link_speed)
3358 : 0 : link_req.link_speed = bp->link_info->force_link_speed;
3359 [ # # ]: 0 : else if (bp->link_info->auto_pam4_link_speed_mask)
3360 : 0 : link_req.link_speed =
3361 : : bp->link_info->auto_pam4_link_speed_mask;
3362 [ # # ]: 0 : else if (bp->link_info->support_pam4_speeds)
3363 : 0 : link_req.link_speed =
3364 : : bp->link_info->support_pam4_speeds;
3365 : : else
3366 : 0 : link_req.link_speed = bp->link_info->auto_link_speed;
3367 : : /* Auto PAM4 link speed is zero, but auto_link_speed is not
3368 : : * zero. Use the auto_link_speed.
3369 : : */
3370 [ # # ]: 0 : if (bp->link_info->auto_link_speed != 0 &&
3371 [ # # ]: 0 : bp->link_info->auto_pam4_link_speed_mask == 0)
3372 : 0 : link_req.link_speed = bp->link_info->auto_link_speed;
3373 : : }
3374 [ # # ]: 0 : link_req.duplex = bnxt_parse_eth_link_duplex(dev_conf->link_speeds);
3375 : 0 : link_req.auto_pause = bp->link_info->auto_pause;
3376 : 0 : link_req.force_pause = bp->link_info->force_pause;
3377 : :
3378 : 0 : port_phy_cfg:
3379 : 0 : rc = bnxt_hwrm_port_phy_cfg(bp, &link_req);
3380 [ # # ]: 0 : if (rc) {
3381 : 0 : PMD_DRV_LOG(ERR,
3382 : : "Set link config failed with rc %d\n", rc);
3383 : : }
3384 : :
3385 : 0 : error:
3386 : : return rc;
3387 : : }
3388 : :
3389 : 0 : int bnxt_hwrm_func_qcfg(struct bnxt *bp, uint16_t *mtu)
3390 : : {
3391 : 0 : struct hwrm_func_qcfg_input req = {0};
3392 : 0 : struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
3393 : : uint16_t flags;
3394 : : int rc = 0;
3395 : 0 : bp->func_svif = BNXT_SVIF_INVALID;
3396 : : uint16_t svif_info;
3397 : :
3398 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_QCFG, BNXT_USE_CHIMP_MB);
3399 : 0 : req.fid = rte_cpu_to_le_16(0xffff);
3400 : :
3401 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3402 : :
3403 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
3404 : :
3405 : 0 : bp->vlan = rte_le_to_cpu_16(resp->vlan) & RTE_ETH_VLAN_ID_MAX;
3406 : :
3407 : 0 : svif_info = rte_le_to_cpu_16(resp->svif_info);
3408 [ # # ]: 0 : if (svif_info & HWRM_FUNC_QCFG_OUTPUT_SVIF_INFO_SVIF_VALID)
3409 : 0 : bp->func_svif = svif_info &
3410 : : HWRM_FUNC_QCFG_OUTPUT_SVIF_INFO_SVIF_MASK;
3411 : :
3412 : 0 : flags = rte_le_to_cpu_16(resp->flags);
3413 [ # # # # ]: 0 : if (BNXT_PF(bp) && (flags & HWRM_FUNC_QCFG_OUTPUT_FLAGS_MULTI_HOST))
3414 : 0 : bp->flags |= BNXT_FLAG_MULTI_HOST;
3415 : :
3416 [ # # ]: 0 : if (BNXT_VF(bp) &&
3417 [ # # ]: 0 : !BNXT_VF_IS_TRUSTED(bp) &&
3418 : : (flags & HWRM_FUNC_QCFG_OUTPUT_FLAGS_TRUSTED_VF)) {
3419 : 0 : bp->flags |= BNXT_FLAG_TRUSTED_VF_EN;
3420 : 0 : PMD_DRV_LOG(INFO, "Trusted VF cap enabled\n");
3421 [ # # ]: 0 : } else if (BNXT_VF(bp) &&
3422 [ # # ]: 0 : BNXT_VF_IS_TRUSTED(bp) &&
3423 : : !(flags & HWRM_FUNC_QCFG_OUTPUT_FLAGS_TRUSTED_VF)) {
3424 : 0 : bp->flags &= ~BNXT_FLAG_TRUSTED_VF_EN;
3425 : 0 : PMD_DRV_LOG(INFO, "Trusted VF cap disabled\n");
3426 : : }
3427 : :
3428 [ # # ]: 0 : if (mtu)
3429 : 0 : *mtu = rte_le_to_cpu_16(resp->admin_mtu);
3430 : :
3431 [ # # ]: 0 : switch (resp->port_partition_type) {
3432 : 0 : case HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_NPAR1_0:
3433 : : case HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_NPAR1_5:
3434 : : case HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_NPAR2_0:
3435 : : /* FALLTHROUGH */
3436 : 0 : bp->flags |= BNXT_FLAG_NPAR_PF;
3437 : 0 : break;
3438 : 0 : default:
3439 : 0 : bp->flags &= ~BNXT_FLAG_NPAR_PF;
3440 : 0 : break;
3441 : : }
3442 : :
3443 : 0 : bp->legacy_db_size =
3444 : 0 : rte_le_to_cpu_16(resp->legacy_l2_db_size_kb) * 1024;
3445 : :
3446 : : HWRM_UNLOCK();
3447 : :
3448 : 0 : return rc;
3449 : : }
3450 : :
3451 : 0 : int bnxt_hwrm_parent_pf_qcfg(struct bnxt *bp)
3452 : : {
3453 : 0 : struct hwrm_func_qcfg_input req = {0};
3454 : 0 : struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
3455 : : uint16_t flags;
3456 : : int rc;
3457 : :
3458 [ # # ]: 0 : if (!BNXT_VF_IS_TRUSTED(bp))
3459 : : return 0;
3460 : :
3461 [ # # ]: 0 : if (!bp->parent)
3462 : : return -EINVAL;
3463 : :
3464 : 0 : bp->parent->fid = BNXT_PF_FID_INVALID;
3465 : :
3466 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_QCFG, BNXT_USE_CHIMP_MB);
3467 : :
3468 : 0 : req.fid = rte_cpu_to_le_16(0xfffe); /* Request parent PF information. */
3469 : :
3470 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3471 : :
3472 [ # # # # ]: 0 : HWRM_CHECK_RESULT_SILENT();
3473 : :
3474 [ # # ]: 0 : memcpy(bp->parent->mac_addr, resp->mac_address, RTE_ETHER_ADDR_LEN);
3475 : 0 : bp->parent->vnic = rte_le_to_cpu_16(resp->dflt_vnic_id);
3476 : 0 : bp->parent->fid = rte_le_to_cpu_16(resp->fid);
3477 : 0 : bp->parent->port_id = rte_le_to_cpu_16(resp->port_id);
3478 : :
3479 : 0 : flags = rte_le_to_cpu_16(resp->flags);
3480 : : /* check for the multi-root support */
3481 [ # # ]: 0 : if (flags & HWRM_FUNC_QCFG_OUTPUT_FLAGS_MULTI_ROOT) {
3482 : 0 : bp->flags2 |= BNXT_FLAGS2_MULTIROOT_EN;
3483 : 0 : PMD_DRV_LOG(DEBUG, "PF enabled with multi root capability\n");
3484 : : }
3485 : :
3486 : : HWRM_UNLOCK();
3487 : :
3488 : 0 : return 0;
3489 : : }
3490 : :
3491 : 0 : int bnxt_hwrm_get_dflt_vnic_svif(struct bnxt *bp, uint16_t fid,
3492 : : uint16_t *vnic_id, uint16_t *svif)
3493 : : {
3494 : 0 : struct hwrm_func_qcfg_input req = {0};
3495 : 0 : struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
3496 : : uint16_t svif_info;
3497 : : int rc = 0;
3498 : :
3499 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_QCFG, BNXT_USE_CHIMP_MB);
3500 : 0 : req.fid = rte_cpu_to_le_16(fid);
3501 : :
3502 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3503 : :
3504 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
3505 : :
3506 [ # # ]: 0 : if (vnic_id)
3507 : 0 : *vnic_id = rte_le_to_cpu_16(resp->dflt_vnic_id);
3508 : :
3509 : 0 : svif_info = rte_le_to_cpu_16(resp->svif_info);
3510 [ # # ]: 0 : if (svif && (svif_info & HWRM_FUNC_QCFG_OUTPUT_SVIF_INFO_SVIF_VALID))
3511 : 0 : *svif = svif_info & HWRM_FUNC_QCFG_OUTPUT_SVIF_INFO_SVIF_MASK;
3512 : :
3513 : : HWRM_UNLOCK();
3514 : :
3515 : 0 : return rc;
3516 : : }
3517 : :
3518 : 0 : int bnxt_hwrm_port_mac_qcfg(struct bnxt *bp)
3519 : : {
3520 : 0 : struct hwrm_port_mac_qcfg_input req = {0};
3521 : 0 : struct hwrm_port_mac_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
3522 : : uint16_t port_svif_info;
3523 : : int rc;
3524 : :
3525 : 0 : bp->port_svif = BNXT_SVIF_INVALID;
3526 : :
3527 [ # # ]: 0 : if (BNXT_VF(bp) && !BNXT_VF_IS_TRUSTED(bp))
3528 : : return 0;
3529 : :
3530 [ # # ]: 0 : HWRM_PREP(&req, HWRM_PORT_MAC_QCFG, BNXT_USE_CHIMP_MB);
3531 : :
3532 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3533 : :
3534 [ # # # # ]: 0 : HWRM_CHECK_RESULT_SILENT();
3535 : :
3536 : 0 : port_svif_info = rte_le_to_cpu_16(resp->port_svif_info);
3537 [ # # ]: 0 : if (port_svif_info &
3538 : : HWRM_PORT_MAC_QCFG_OUTPUT_PORT_SVIF_INFO_PORT_SVIF_VALID)
3539 : 0 : bp->port_svif = port_svif_info &
3540 : : HWRM_PORT_MAC_QCFG_OUTPUT_PORT_SVIF_INFO_PORT_SVIF_MASK;
3541 : :
3542 : : HWRM_UNLOCK();
3543 : :
3544 : 0 : return 0;
3545 : : }
3546 : :
3547 : 0 : static int bnxt_hwrm_pf_func_cfg(struct bnxt *bp,
3548 : : struct bnxt_pf_resource_info *pf_resc)
3549 : : {
3550 : 0 : struct hwrm_func_cfg_input req = {0};
3551 : 0 : struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
3552 : : uint32_t enables;
3553 : : int rc;
3554 : :
3555 : : enables = HWRM_FUNC_CFG_INPUT_ENABLES_ADMIN_MTU |
3556 : : HWRM_FUNC_CFG_INPUT_ENABLES_HOST_MTU |
3557 : : HWRM_FUNC_CFG_INPUT_ENABLES_MRU |
3558 : : HWRM_FUNC_CFG_INPUT_ENABLES_NUM_RSSCOS_CTXS |
3559 : : HWRM_FUNC_CFG_INPUT_ENABLES_NUM_STAT_CTXS |
3560 : : HWRM_FUNC_CFG_INPUT_ENABLES_NUM_CMPL_RINGS |
3561 : : HWRM_FUNC_CFG_INPUT_ENABLES_NUM_TX_RINGS |
3562 : : HWRM_FUNC_CFG_INPUT_ENABLES_NUM_RX_RINGS |
3563 : : HWRM_FUNC_CFG_INPUT_ENABLES_NUM_L2_CTXS |
3564 : : HWRM_FUNC_CFG_INPUT_ENABLES_NUM_VNICS;
3565 : :
3566 [ # # ]: 0 : if (BNXT_HAS_RING_GRPS(bp)) {
3567 : : enables |= HWRM_FUNC_CFG_INPUT_ENABLES_NUM_HW_RING_GRPS;
3568 : 0 : req.num_hw_ring_grps =
3569 : 0 : rte_cpu_to_le_16(pf_resc->num_hw_ring_grps);
3570 : : } else if (BNXT_HAS_NQ(bp)) {
3571 : : enables |= HWRM_FUNC_CFG_INPUT_ENABLES_NUM_MSIX;
3572 : 0 : req.num_msix = rte_cpu_to_le_16(pf_resc->num_nq_rings);
3573 : : }
3574 : :
3575 : 0 : req.flags = rte_cpu_to_le_32(bp->pf->func_cfg_flags);
3576 : 0 : req.admin_mtu = rte_cpu_to_le_16(BNXT_MAX_MTU);
3577 : 0 : req.host_mtu = rte_cpu_to_le_16(bp->eth_dev->data->mtu);
3578 : 0 : req.mru = rte_cpu_to_le_16(BNXT_VNIC_MRU(bp->eth_dev->data->mtu));
3579 : 0 : req.num_rsscos_ctxs = rte_cpu_to_le_16(pf_resc->num_rsscos_ctxs);
3580 : 0 : req.num_stat_ctxs = rte_cpu_to_le_16(pf_resc->num_stat_ctxs);
3581 : 0 : req.num_cmpl_rings = rte_cpu_to_le_16(pf_resc->num_cp_rings);
3582 : 0 : req.num_tx_rings = rte_cpu_to_le_16(pf_resc->num_tx_rings);
3583 : 0 : req.num_rx_rings = rte_cpu_to_le_16(pf_resc->num_rx_rings);
3584 : 0 : req.num_l2_ctxs = rte_cpu_to_le_16(pf_resc->num_l2_ctxs);
3585 : 0 : req.num_vnics = rte_cpu_to_le_16(pf_resc->num_vnics);
3586 : 0 : req.fid = rte_cpu_to_le_16(0xffff);
3587 : 0 : req.enables = rte_cpu_to_le_32(enables);
3588 : :
3589 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_CFG, BNXT_USE_CHIMP_MB);
3590 : :
3591 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3592 : :
3593 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
3594 : : HWRM_UNLOCK();
3595 : :
3596 : 0 : return rc;
3597 : : }
3598 : :
3599 : : /* min values are the guaranteed resources and max values are subject
3600 : : * to availability. The strategy for now is to keep both min & max
3601 : : * values the same.
3602 : : */
3603 : : static void
3604 : 0 : bnxt_fill_vf_func_cfg_req_new(struct bnxt *bp,
3605 : : struct hwrm_func_vf_resource_cfg_input *req,
3606 : : int num_vfs)
3607 : : {
3608 : 0 : req->max_rsscos_ctx = rte_cpu_to_le_16(bp->max_rsscos_ctx /
3609 : : (num_vfs + 1));
3610 : 0 : req->min_rsscos_ctx = req->max_rsscos_ctx;
3611 : 0 : req->max_stat_ctx = rte_cpu_to_le_16(bp->max_stat_ctx / (num_vfs + 1));
3612 : 0 : req->min_stat_ctx = req->max_stat_ctx;
3613 : 0 : req->max_cmpl_rings = rte_cpu_to_le_16(bp->max_cp_rings /
3614 : : (num_vfs + 1));
3615 : 0 : req->min_cmpl_rings = req->max_cmpl_rings;
3616 : 0 : req->max_tx_rings = rte_cpu_to_le_16(bp->max_tx_rings / (num_vfs + 1));
3617 : 0 : req->min_tx_rings = req->max_tx_rings;
3618 : 0 : req->max_rx_rings = rte_cpu_to_le_16(bp->max_rx_rings / (num_vfs + 1));
3619 : 0 : req->min_rx_rings = req->max_rx_rings;
3620 : 0 : req->max_l2_ctxs = rte_cpu_to_le_16(bp->max_l2_ctx / (num_vfs + 1));
3621 : 0 : req->min_l2_ctxs = req->max_l2_ctxs;
3622 : 0 : req->max_vnics = rte_cpu_to_le_16(bp->max_vnics / (num_vfs + 1));
3623 : 0 : req->min_vnics = req->max_vnics;
3624 : 0 : req->max_hw_ring_grps = rte_cpu_to_le_16(bp->max_ring_grps /
3625 : : (num_vfs + 1));
3626 : 0 : req->min_hw_ring_grps = req->max_hw_ring_grps;
3627 : 0 : req->max_msix = rte_cpu_to_le_16(bp->max_nq_rings / (num_vfs + 1));
3628 : 0 : }
3629 : :
3630 : : static void
3631 : 0 : bnxt_fill_vf_func_cfg_req_old(struct bnxt *bp,
3632 : : struct hwrm_func_cfg_input *req,
3633 : : int num_vfs)
3634 : : {
3635 : 0 : req->enables = rte_cpu_to_le_32(HWRM_FUNC_CFG_INPUT_ENABLES_ADMIN_MTU |
3636 : : HWRM_FUNC_CFG_INPUT_ENABLES_MRU |
3637 : : HWRM_FUNC_CFG_INPUT_ENABLES_NUM_RSSCOS_CTXS |
3638 : : HWRM_FUNC_CFG_INPUT_ENABLES_NUM_STAT_CTXS |
3639 : : HWRM_FUNC_CFG_INPUT_ENABLES_NUM_CMPL_RINGS |
3640 : : HWRM_FUNC_CFG_INPUT_ENABLES_NUM_TX_RINGS |
3641 : : HWRM_FUNC_CFG_INPUT_ENABLES_NUM_RX_RINGS |
3642 : : HWRM_FUNC_CFG_INPUT_ENABLES_NUM_L2_CTXS |
3643 : : HWRM_FUNC_CFG_INPUT_ENABLES_NUM_VNICS |
3644 : : HWRM_FUNC_CFG_INPUT_ENABLES_NUM_HW_RING_GRPS);
3645 : :
3646 : 0 : req->admin_mtu = rte_cpu_to_le_16(bp->eth_dev->data->mtu + RTE_ETHER_HDR_LEN +
3647 : : RTE_ETHER_CRC_LEN + RTE_VLAN_HLEN *
3648 : : BNXT_NUM_VLANS);
3649 : 0 : req->mru = rte_cpu_to_le_16(BNXT_VNIC_MRU(bp->eth_dev->data->mtu));
3650 : 0 : req->num_rsscos_ctxs = rte_cpu_to_le_16(bp->max_rsscos_ctx /
3651 : : (num_vfs + 1));
3652 : 0 : req->num_stat_ctxs = rte_cpu_to_le_16(bp->max_stat_ctx / (num_vfs + 1));
3653 : 0 : req->num_cmpl_rings = rte_cpu_to_le_16(bp->max_cp_rings /
3654 : : (num_vfs + 1));
3655 : 0 : req->num_tx_rings = rte_cpu_to_le_16(bp->max_tx_rings / (num_vfs + 1));
3656 : 0 : req->num_rx_rings = rte_cpu_to_le_16(bp->max_rx_rings / (num_vfs + 1));
3657 : 0 : req->num_l2_ctxs = rte_cpu_to_le_16(bp->max_l2_ctx / (num_vfs + 1));
3658 : : /* TODO: For now, do not support VMDq/RFS on VFs. */
3659 : 0 : req->num_vnics = rte_cpu_to_le_16(1);
3660 : 0 : req->num_hw_ring_grps = rte_cpu_to_le_16(bp->max_ring_grps /
3661 : : (num_vfs + 1));
3662 : 0 : }
3663 : :
3664 : : /* Update the port wide resource values based on how many resources
3665 : : * got allocated to the VF.
3666 : : */
3667 : 0 : static int bnxt_update_max_resources(struct bnxt *bp,
3668 : : int vf)
3669 : : {
3670 : 0 : struct hwrm_func_qcfg_input req = {0};
3671 : 0 : struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
3672 : : int rc;
3673 : :
3674 : : /* Get the actual allocated values now */
3675 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_QCFG, BNXT_USE_CHIMP_MB);
3676 : 0 : req.fid = rte_cpu_to_le_16(bp->pf->vf_info[vf].fid);
3677 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3678 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
3679 : :
3680 : 0 : bp->max_rsscos_ctx -= rte_le_to_cpu_16(resp->alloc_rsscos_ctx);
3681 : 0 : bp->max_stat_ctx -= rte_le_to_cpu_16(resp->alloc_stat_ctx);
3682 : 0 : bp->max_cp_rings -= rte_le_to_cpu_16(resp->alloc_cmpl_rings);
3683 : 0 : bp->max_tx_rings -= rte_le_to_cpu_16(resp->alloc_tx_rings);
3684 : 0 : bp->max_rx_rings -= rte_le_to_cpu_16(resp->alloc_rx_rings);
3685 : 0 : bp->max_l2_ctx -= rte_le_to_cpu_16(resp->alloc_l2_ctx);
3686 : 0 : bp->max_ring_grps -= rte_le_to_cpu_16(resp->alloc_hw_ring_grps);
3687 : 0 : bp->max_nq_rings -= rte_le_to_cpu_16(resp->alloc_msix);
3688 : 0 : bp->max_vnics -= rte_le_to_cpu_16(resp->alloc_vnics);
3689 : :
3690 : : HWRM_UNLOCK();
3691 : :
3692 : 0 : return 0;
3693 : : }
3694 : :
3695 : : /* Update the PF resource values based on how many resources
3696 : : * got allocated to it.
3697 : : */
3698 : 0 : static int bnxt_update_max_resources_pf_only(struct bnxt *bp)
3699 : : {
3700 : 0 : struct hwrm_func_qcfg_input req = {0};
3701 : 0 : struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
3702 : : int rc;
3703 : :
3704 : : /* Get the actual allocated values now */
3705 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_QCFG, BNXT_USE_CHIMP_MB);
3706 : 0 : req.fid = rte_cpu_to_le_16(0xffff);
3707 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3708 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
3709 : :
3710 : 0 : bp->max_rsscos_ctx = rte_le_to_cpu_16(resp->alloc_rsscos_ctx);
3711 : 0 : bp->max_stat_ctx = rte_le_to_cpu_16(resp->alloc_stat_ctx);
3712 : 0 : bp->max_cp_rings = rte_le_to_cpu_16(resp->alloc_cmpl_rings);
3713 : 0 : bp->max_tx_rings = rte_le_to_cpu_16(resp->alloc_tx_rings);
3714 : 0 : bp->max_rx_rings = rte_le_to_cpu_16(resp->alloc_rx_rings);
3715 : 0 : bp->max_l2_ctx = rte_le_to_cpu_16(resp->alloc_l2_ctx);
3716 : 0 : bp->max_ring_grps = rte_le_to_cpu_16(resp->alloc_hw_ring_grps);
3717 : 0 : bp->max_vnics = rte_le_to_cpu_16(resp->alloc_vnics);
3718 : :
3719 : : HWRM_UNLOCK();
3720 : :
3721 : 0 : return 0;
3722 : : }
3723 : :
3724 : 0 : int bnxt_hwrm_func_qcfg_current_vf_vlan(struct bnxt *bp, int vf)
3725 : : {
3726 : 0 : struct hwrm_func_qcfg_input req = {0};
3727 : 0 : struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
3728 : : int rc;
3729 : :
3730 : : /* Check for zero MAC address */
3731 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_QCFG, BNXT_USE_CHIMP_MB);
3732 : 0 : req.fid = rte_cpu_to_le_16(bp->pf->vf_info[vf].fid);
3733 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3734 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
3735 : 0 : rc = rte_le_to_cpu_16(resp->vlan);
3736 : :
3737 : : HWRM_UNLOCK();
3738 : :
3739 : 0 : return rc;
3740 : : }
3741 : :
3742 : 0 : static int bnxt_query_pf_resources(struct bnxt *bp,
3743 : : struct bnxt_pf_resource_info *pf_resc)
3744 : : {
3745 : 0 : struct hwrm_func_qcfg_input req = {0};
3746 : 0 : struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
3747 : : int rc;
3748 : :
3749 : : /* And copy the allocated numbers into the pf struct */
3750 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_QCFG, BNXT_USE_CHIMP_MB);
3751 : 0 : req.fid = rte_cpu_to_le_16(0xffff);
3752 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3753 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
3754 : :
3755 : 0 : pf_resc->num_tx_rings = rte_le_to_cpu_16(resp->alloc_tx_rings);
3756 : 0 : pf_resc->num_rsscos_ctxs = rte_le_to_cpu_16(resp->alloc_rsscos_ctx);
3757 : 0 : pf_resc->num_stat_ctxs = rte_le_to_cpu_16(resp->alloc_stat_ctx);
3758 : 0 : pf_resc->num_cp_rings = rte_le_to_cpu_16(resp->alloc_cmpl_rings);
3759 : 0 : pf_resc->num_rx_rings = rte_le_to_cpu_16(resp->alloc_rx_rings);
3760 : 0 : pf_resc->num_l2_ctxs = rte_le_to_cpu_16(resp->alloc_l2_ctx);
3761 : 0 : pf_resc->num_hw_ring_grps = rte_le_to_cpu_32(resp->alloc_hw_ring_grps);
3762 : 0 : pf_resc->num_nq_rings = rte_le_to_cpu_32(resp->alloc_msix);
3763 : 0 : pf_resc->num_vnics = rte_le_to_cpu_16(resp->alloc_vnics);
3764 : 0 : bp->pf->evb_mode = resp->evb_mode;
3765 : :
3766 : : HWRM_UNLOCK();
3767 : :
3768 : 0 : return rc;
3769 : : }
3770 : :
3771 : : static void
3772 : 0 : bnxt_calculate_pf_resources(struct bnxt *bp,
3773 : : struct bnxt_pf_resource_info *pf_resc,
3774 : : int num_vfs)
3775 : : {
3776 [ # # ]: 0 : if (!num_vfs) {
3777 : 0 : pf_resc->num_rsscos_ctxs = bp->max_rsscos_ctx;
3778 : 0 : pf_resc->num_stat_ctxs = bp->max_stat_ctx;
3779 : 0 : pf_resc->num_cp_rings = bp->max_cp_rings;
3780 : 0 : pf_resc->num_tx_rings = bp->max_tx_rings;
3781 : 0 : pf_resc->num_rx_rings = bp->max_rx_rings;
3782 : 0 : pf_resc->num_l2_ctxs = bp->max_l2_ctx;
3783 : 0 : pf_resc->num_hw_ring_grps = bp->max_ring_grps;
3784 : 0 : pf_resc->num_nq_rings = bp->max_nq_rings;
3785 : 0 : pf_resc->num_vnics = bp->max_vnics;
3786 : :
3787 : 0 : return;
3788 : : }
3789 : :
3790 : 0 : pf_resc->num_rsscos_ctxs = bp->max_rsscos_ctx / (num_vfs + 1) +
3791 : 0 : bp->max_rsscos_ctx % (num_vfs + 1);
3792 : 0 : pf_resc->num_stat_ctxs = bp->max_stat_ctx / (num_vfs + 1) +
3793 : 0 : bp->max_stat_ctx % (num_vfs + 1);
3794 : 0 : pf_resc->num_cp_rings = bp->max_cp_rings / (num_vfs + 1) +
3795 : 0 : bp->max_cp_rings % (num_vfs + 1);
3796 : 0 : pf_resc->num_tx_rings = bp->max_tx_rings / (num_vfs + 1) +
3797 : 0 : bp->max_tx_rings % (num_vfs + 1);
3798 : 0 : pf_resc->num_rx_rings = bp->max_rx_rings / (num_vfs + 1) +
3799 : 0 : bp->max_rx_rings % (num_vfs + 1);
3800 : 0 : pf_resc->num_l2_ctxs = bp->max_l2_ctx / (num_vfs + 1) +
3801 : 0 : bp->max_l2_ctx % (num_vfs + 1);
3802 : 0 : pf_resc->num_hw_ring_grps = bp->max_ring_grps / (num_vfs + 1) +
3803 : 0 : bp->max_ring_grps % (num_vfs + 1);
3804 : 0 : pf_resc->num_nq_rings = bp->max_nq_rings / (num_vfs + 1) +
3805 : 0 : bp->max_nq_rings % (num_vfs + 1);
3806 : 0 : pf_resc->num_vnics = bp->max_vnics / (num_vfs + 1) +
3807 : 0 : bp->max_vnics % (num_vfs + 1);
3808 : : }
3809 : :
3810 : 0 : int bnxt_hwrm_allocate_pf_only(struct bnxt *bp)
3811 : : {
3812 : 0 : struct bnxt_pf_resource_info pf_resc = { 0 };
3813 : : int rc;
3814 : :
3815 [ # # ]: 0 : if (!BNXT_PF(bp)) {
3816 : 0 : PMD_DRV_LOG(ERR, "Attempt to allocate VFs on a VF!\n");
3817 : 0 : return -EINVAL;
3818 : : }
3819 : :
3820 : 0 : rc = bnxt_hwrm_func_qcaps(bp);
3821 [ # # ]: 0 : if (rc)
3822 : : return rc;
3823 : :
3824 : : bnxt_calculate_pf_resources(bp, &pf_resc, 0);
3825 : :
3826 : 0 : bp->pf->func_cfg_flags &=
3827 : : ~(HWRM_FUNC_CFG_INPUT_FLAGS_STD_TX_RING_MODE_ENABLE |
3828 : : HWRM_FUNC_CFG_INPUT_FLAGS_STD_TX_RING_MODE_DISABLE);
3829 : 0 : bp->pf->func_cfg_flags |=
3830 : : HWRM_FUNC_CFG_INPUT_FLAGS_STD_TX_RING_MODE_DISABLE;
3831 : :
3832 : 0 : rc = bnxt_hwrm_pf_func_cfg(bp, &pf_resc);
3833 [ # # ]: 0 : if (rc)
3834 : : return rc;
3835 : :
3836 : 0 : rc = bnxt_update_max_resources_pf_only(bp);
3837 : :
3838 : 0 : return rc;
3839 : : }
3840 : :
3841 : : static int
3842 : 0 : bnxt_configure_vf_req_buf(struct bnxt *bp, int num_vfs)
3843 : : {
3844 : : size_t req_buf_sz, sz;
3845 : : int i, rc;
3846 : :
3847 : 0 : req_buf_sz = num_vfs * HWRM_MAX_REQ_LEN;
3848 : 0 : bp->pf->vf_req_buf = rte_malloc("bnxt_vf_fwd", req_buf_sz,
3849 : : page_roundup(num_vfs * HWRM_MAX_REQ_LEN));
3850 [ # # ]: 0 : if (bp->pf->vf_req_buf == NULL) {
3851 : : return -ENOMEM;
3852 : : }
3853 : :
3854 [ # # ]: 0 : for (sz = 0; sz < req_buf_sz; sz += getpagesize())
3855 : 0 : rte_mem_lock_page(((char *)bp->pf->vf_req_buf) + sz);
3856 : :
3857 [ # # ]: 0 : for (i = 0; i < num_vfs; i++)
3858 : 0 : bp->pf->vf_info[i].req_buf = ((char *)bp->pf->vf_req_buf) +
3859 : 0 : (i * HWRM_MAX_REQ_LEN);
3860 : :
3861 : 0 : rc = bnxt_hwrm_func_buf_rgtr(bp, num_vfs);
3862 [ # # ]: 0 : if (rc)
3863 : 0 : rte_free(bp->pf->vf_req_buf);
3864 : :
3865 : : return rc;
3866 : : }
3867 : :
3868 : : static int
3869 : 0 : bnxt_process_vf_resc_config_new(struct bnxt *bp, int num_vfs)
3870 : : {
3871 : 0 : struct hwrm_func_vf_resource_cfg_output *resp = bp->hwrm_cmd_resp_addr;
3872 : 0 : struct hwrm_func_vf_resource_cfg_input req = {0};
3873 : : int i, rc = 0;
3874 : :
3875 : 0 : bnxt_fill_vf_func_cfg_req_new(bp, &req, num_vfs);
3876 : 0 : bp->pf->active_vfs = 0;
3877 [ # # ]: 0 : for (i = 0; i < num_vfs; i++) {
3878 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_VF_RESOURCE_CFG, BNXT_USE_CHIMP_MB);
3879 : 0 : req.vf_id = rte_cpu_to_le_16(bp->pf->vf_info[i].fid);
3880 : 0 : rc = bnxt_hwrm_send_message(bp,
3881 : : &req,
3882 : : sizeof(req),
3883 : : BNXT_USE_CHIMP_MB);
3884 [ # # # # ]: 0 : if (rc || resp->error_code) {
3885 : 0 : PMD_DRV_LOG(ERR,
3886 : : "Failed to initialize VF %d\n", i);
3887 : 0 : PMD_DRV_LOG(ERR,
3888 : : "Not all VFs available. (%d, %d)\n",
3889 : : rc, resp->error_code);
3890 : : HWRM_UNLOCK();
3891 : :
3892 : : /* If the first VF configuration itself fails,
3893 : : * unregister the vf_fwd_request buffer.
3894 : : */
3895 [ # # ]: 0 : if (i == 0)
3896 : 0 : bnxt_hwrm_func_buf_unrgtr(bp);
3897 : : break;
3898 : : }
3899 : : HWRM_UNLOCK();
3900 : :
3901 : : /* Update the max resource values based on the resource values
3902 : : * allocated to the VF.
3903 : : */
3904 : 0 : bnxt_update_max_resources(bp, i);
3905 : 0 : bp->pf->active_vfs++;
3906 : 0 : bnxt_hwrm_func_clr_stats(bp, bp->pf->vf_info[i].fid);
3907 : : }
3908 : :
3909 : : return 0;
3910 : : }
3911 : :
3912 : : static int
3913 : 0 : bnxt_process_vf_resc_config_old(struct bnxt *bp, int num_vfs)
3914 : : {
3915 : 0 : struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
3916 : 0 : struct hwrm_func_cfg_input req = {0};
3917 : : int i, rc;
3918 : :
3919 : 0 : bnxt_fill_vf_func_cfg_req_old(bp, &req, num_vfs);
3920 : :
3921 : 0 : bp->pf->active_vfs = 0;
3922 [ # # ]: 0 : for (i = 0; i < num_vfs; i++) {
3923 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_CFG, BNXT_USE_CHIMP_MB);
3924 : 0 : req.flags = rte_cpu_to_le_32(bp->pf->vf_info[i].func_cfg_flags);
3925 : 0 : req.fid = rte_cpu_to_le_16(bp->pf->vf_info[i].fid);
3926 : 0 : rc = bnxt_hwrm_send_message(bp,
3927 : : &req,
3928 : : sizeof(req),
3929 : : BNXT_USE_CHIMP_MB);
3930 : :
3931 : : /* Clear enable flag for next pass */
3932 : 0 : req.enables &= ~rte_cpu_to_le_32(
3933 : : HWRM_FUNC_CFG_INPUT_ENABLES_DFLT_MAC_ADDR);
3934 : :
3935 [ # # # # ]: 0 : if (rc || resp->error_code) {
3936 : 0 : PMD_DRV_LOG(ERR,
3937 : : "Failed to initialize VF %d\n", i);
3938 : 0 : PMD_DRV_LOG(ERR,
3939 : : "Not all VFs available. (%d, %d)\n",
3940 : : rc, resp->error_code);
3941 : : HWRM_UNLOCK();
3942 : :
3943 : : /* If the first VF configuration itself fails,
3944 : : * unregister the vf_fwd_request buffer.
3945 : : */
3946 [ # # ]: 0 : if (i == 0)
3947 : 0 : bnxt_hwrm_func_buf_unrgtr(bp);
3948 : : break;
3949 : : }
3950 : :
3951 : : HWRM_UNLOCK();
3952 : :
3953 : : /* Update the max resource values based on the resource values
3954 : : * allocated to the VF.
3955 : : */
3956 : 0 : bnxt_update_max_resources(bp, i);
3957 : 0 : bp->pf->active_vfs++;
3958 : 0 : bnxt_hwrm_func_clr_stats(bp, bp->pf->vf_info[i].fid);
3959 : : }
3960 : :
3961 : : return 0;
3962 : : }
3963 : :
3964 : : static void
3965 : 0 : bnxt_configure_vf_resources(struct bnxt *bp, int num_vfs)
3966 : : {
3967 [ # # ]: 0 : if (bp->flags & BNXT_FLAG_NEW_RM)
3968 : 0 : bnxt_process_vf_resc_config_new(bp, num_vfs);
3969 : : else
3970 : 0 : bnxt_process_vf_resc_config_old(bp, num_vfs);
3971 : 0 : }
3972 : :
3973 : : static void
3974 : : bnxt_update_pf_resources(struct bnxt *bp,
3975 : : struct bnxt_pf_resource_info *pf_resc)
3976 : : {
3977 : 0 : bp->max_rsscos_ctx = pf_resc->num_rsscos_ctxs;
3978 : 0 : bp->max_stat_ctx = pf_resc->num_stat_ctxs;
3979 : 0 : bp->max_cp_rings = pf_resc->num_cp_rings;
3980 : 0 : bp->max_tx_rings = pf_resc->num_tx_rings;
3981 : 0 : bp->max_rx_rings = pf_resc->num_rx_rings;
3982 : 0 : bp->max_ring_grps = pf_resc->num_hw_ring_grps;
3983 : 0 : bp->max_nq_rings = pf_resc->num_nq_rings;
3984 : 0 : bp->max_vnics = pf_resc->num_vnics;
3985 : : }
3986 : :
3987 : : static int32_t
3988 : : bnxt_configure_pf_resources(struct bnxt *bp,
3989 : : struct bnxt_pf_resource_info *pf_resc)
3990 : : {
3991 : : /*
3992 : : * We're using STD_TX_RING_MODE here which will limit the TX
3993 : : * rings. This will allow QoS to function properly. Not setting this
3994 : : * will cause PF rings to break bandwidth settings.
3995 : : */
3996 : 0 : bp->pf->func_cfg_flags &=
3997 : : ~(HWRM_FUNC_CFG_INPUT_FLAGS_STD_TX_RING_MODE_ENABLE |
3998 : : HWRM_FUNC_CFG_INPUT_FLAGS_STD_TX_RING_MODE_DISABLE);
3999 : 0 : bp->pf->func_cfg_flags |=
4000 : : HWRM_FUNC_CFG_INPUT_FLAGS_STD_TX_RING_MODE_ENABLE;
4001 : 0 : return bnxt_hwrm_pf_func_cfg(bp, pf_resc);
4002 : : }
4003 : :
4004 : 0 : int bnxt_hwrm_allocate_vfs(struct bnxt *bp, int num_vfs)
4005 : : {
4006 : 0 : struct bnxt_pf_resource_info pf_resc = { 0 };
4007 : : int rc;
4008 : :
4009 [ # # ]: 0 : if (!BNXT_PF(bp)) {
4010 : 0 : PMD_DRV_LOG(ERR, "Attempt to allocate VFs on a VF!\n");
4011 : 0 : return -EINVAL;
4012 : : }
4013 : :
4014 : 0 : rc = bnxt_hwrm_func_qcaps(bp);
4015 [ # # ]: 0 : if (rc)
4016 : : return rc;
4017 : :
4018 : 0 : bnxt_calculate_pf_resources(bp, &pf_resc, num_vfs);
4019 : :
4020 : : rc = bnxt_configure_pf_resources(bp, &pf_resc);
4021 [ # # ]: 0 : if (rc)
4022 : : return rc;
4023 : :
4024 : 0 : rc = bnxt_query_pf_resources(bp, &pf_resc);
4025 [ # # ]: 0 : if (rc)
4026 : : return rc;
4027 : :
4028 : : /*
4029 : : * Now, create and register a buffer to hold forwarded VF requests
4030 : : */
4031 : 0 : rc = bnxt_configure_vf_req_buf(bp, num_vfs);
4032 [ # # ]: 0 : if (rc)
4033 : : return rc;
4034 : :
4035 : 0 : bnxt_configure_vf_resources(bp, num_vfs);
4036 : :
4037 : : bnxt_update_pf_resources(bp, &pf_resc);
4038 : :
4039 : 0 : return 0;
4040 : : }
4041 : :
4042 : 0 : int bnxt_hwrm_pf_evb_mode(struct bnxt *bp)
4043 : : {
4044 : 0 : struct hwrm_func_cfg_input req = {0};
4045 : 0 : struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
4046 : : int rc;
4047 : :
4048 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_CFG, BNXT_USE_CHIMP_MB);
4049 : :
4050 : 0 : req.fid = rte_cpu_to_le_16(0xffff);
4051 : 0 : req.enables = rte_cpu_to_le_32(HWRM_FUNC_CFG_INPUT_ENABLES_EVB_MODE);
4052 : 0 : req.evb_mode = bp->pf->evb_mode;
4053 : :
4054 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4055 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4056 : : HWRM_UNLOCK();
4057 : :
4058 : 0 : return rc;
4059 : : }
4060 : :
4061 : 0 : int bnxt_hwrm_tunnel_dst_port_alloc(struct bnxt *bp, uint16_t port,
4062 : : uint8_t tunnel_type)
4063 : : {
4064 : 0 : struct hwrm_tunnel_dst_port_alloc_input req = {0};
4065 : 0 : struct hwrm_tunnel_dst_port_alloc_output *resp = bp->hwrm_cmd_resp_addr;
4066 : : int rc = 0;
4067 : :
4068 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_TUNNEL_DST_PORT_ALLOC, BNXT_USE_CHIMP_MB);
4069 : 0 : req.tunnel_type = tunnel_type;
4070 [ # # ]: 0 : req.tunnel_dst_port_val = rte_cpu_to_be_16(port);
4071 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4072 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4073 : :
4074 [ # # # # ]: 0 : switch (tunnel_type) {
4075 : 0 : case HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_VXLAN:
4076 : 0 : bp->vxlan_fw_dst_port_id =
4077 : 0 : rte_le_to_cpu_16(resp->tunnel_dst_port_id);
4078 : 0 : bp->vxlan_port = port;
4079 : 0 : break;
4080 : 0 : case HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_GENEVE:
4081 : 0 : bp->geneve_fw_dst_port_id =
4082 : 0 : rte_le_to_cpu_16(resp->tunnel_dst_port_id);
4083 : 0 : bp->geneve_port = port;
4084 : 0 : break;
4085 : 0 : case HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_ECPRI:
4086 : 0 : bp->ecpri_fw_dst_port_id =
4087 : 0 : rte_le_to_cpu_16(resp->tunnel_dst_port_id);
4088 : 0 : bp->ecpri_port = port;
4089 : 0 : bp->ecpri_upar_in_use = resp->upar_in_use;
4090 : 0 : break;
4091 : : default:
4092 : : break;
4093 : : }
4094 : :
4095 : : HWRM_UNLOCK();
4096 : :
4097 : 0 : return rc;
4098 : : }
4099 : :
4100 : 0 : int bnxt_hwrm_tunnel_upar_id_get(struct bnxt *bp, uint8_t *upar_id,
4101 : : uint8_t tunnel_type)
4102 : : {
4103 : 0 : struct hwrm_tunnel_dst_port_query_input req = {0};
4104 : 0 : struct hwrm_tunnel_dst_port_query_output *resp = bp->hwrm_cmd_resp_addr;
4105 : : int rc = 0;
4106 : :
4107 [ # # ]: 0 : HWRM_PREP(&req, HWRM_TUNNEL_DST_PORT_QUERY, BNXT_USE_CHIMP_MB);
4108 : 0 : req.tunnel_type = tunnel_type;
4109 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4110 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4111 : :
4112 [ # # # ]: 0 : switch (tunnel_type) {
4113 : 0 : case HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_ECPRI:
4114 : 0 : *upar_id = resp->upar_in_use;
4115 : 0 : break;
4116 : 0 : case HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_SRV6:
4117 : 0 : *upar_id = resp->upar_in_use;
4118 : 0 : break;
4119 : 0 : default:
4120 : : /* INVALID UPAR Id if another tunnel type tries to retrieve */
4121 : 0 : *upar_id = 0xff;
4122 : 0 : break;
4123 : : }
4124 : :
4125 : : HWRM_UNLOCK();
4126 : :
4127 : 0 : return rc;
4128 : : }
4129 : :
4130 : 0 : int bnxt_hwrm_tunnel_dst_port_free(struct bnxt *bp, uint16_t port,
4131 : : uint8_t tunnel_type)
4132 : : {
4133 : 0 : struct hwrm_tunnel_dst_port_free_input req = {0};
4134 : 0 : struct hwrm_tunnel_dst_port_free_output *resp = bp->hwrm_cmd_resp_addr;
4135 : : int rc = 0;
4136 : :
4137 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_TUNNEL_DST_PORT_FREE, BNXT_USE_CHIMP_MB);
4138 : :
4139 : 0 : req.tunnel_type = tunnel_type;
4140 [ # # ]: 0 : req.tunnel_dst_port_id = rte_cpu_to_be_16(port);
4141 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4142 : :
4143 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4144 : : HWRM_UNLOCK();
4145 : :
4146 [ # # ]: 0 : if (tunnel_type ==
4147 : : HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_VXLAN) {
4148 : 0 : bp->vxlan_port = 0;
4149 : 0 : bp->vxlan_port_cnt = 0;
4150 : : }
4151 : :
4152 [ # # ]: 0 : if (tunnel_type ==
4153 : : HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_GENEVE) {
4154 : 0 : bp->geneve_port = 0;
4155 : 0 : bp->geneve_port_cnt = 0;
4156 : : }
4157 : :
4158 [ # # ]: 0 : if (tunnel_type ==
4159 : : HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_ECPRI) {
4160 : 0 : bp->ecpri_port = 0;
4161 : 0 : bp->ecpri_upar_in_use = 0;
4162 : 0 : bp->ecpri_port_cnt = 0;
4163 : : }
4164 : :
4165 : : return rc;
4166 : : }
4167 : :
4168 : 0 : int bnxt_hwrm_func_cfg_vf_set_flags(struct bnxt *bp, uint16_t vf,
4169 : : uint32_t flags)
4170 : : {
4171 : 0 : struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
4172 : 0 : struct hwrm_func_cfg_input req = {0};
4173 : : int rc;
4174 : :
4175 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_CFG, BNXT_USE_CHIMP_MB);
4176 : :
4177 : 0 : req.fid = rte_cpu_to_le_16(bp->pf->vf_info[vf].fid);
4178 : 0 : req.flags = rte_cpu_to_le_32(flags);
4179 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4180 : :
4181 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4182 : : HWRM_UNLOCK();
4183 : :
4184 : 0 : return rc;
4185 : : }
4186 : :
4187 : 0 : void vf_vnic_set_rxmask_cb(struct bnxt_vnic_info *vnic, void *flagp)
4188 : : {
4189 : : uint32_t *flag = flagp;
4190 : :
4191 : 0 : vnic->flags = *flag;
4192 : 0 : }
4193 : :
4194 : 0 : int bnxt_set_rx_mask_no_vlan(struct bnxt *bp, struct bnxt_vnic_info *vnic)
4195 : : {
4196 : 0 : return bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic, 0, NULL);
4197 : : }
4198 : :
4199 : 0 : int bnxt_hwrm_func_buf_rgtr(struct bnxt *bp, int num_vfs)
4200 : : {
4201 : 0 : struct hwrm_func_buf_rgtr_output *resp = bp->hwrm_cmd_resp_addr;
4202 : 0 : struct hwrm_func_buf_rgtr_input req = {.req_type = 0 };
4203 : : int rc;
4204 : :
4205 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_BUF_RGTR, BNXT_USE_CHIMP_MB);
4206 : :
4207 : 0 : req.req_buf_num_pages = rte_cpu_to_le_16(1);
4208 : 0 : req.req_buf_page_size =
4209 : 0 : rte_cpu_to_le_16(page_getenum(num_vfs * HWRM_MAX_REQ_LEN));
4210 : 0 : req.req_buf_len = rte_cpu_to_le_16(HWRM_MAX_REQ_LEN);
4211 : 0 : req.req_buf_page_addr0 =
4212 : 0 : rte_cpu_to_le_64(rte_malloc_virt2iova(bp->pf->vf_req_buf));
4213 [ # # ]: 0 : if (req.req_buf_page_addr0 == RTE_BAD_IOVA) {
4214 : 0 : PMD_DRV_LOG(ERR,
4215 : : "unable to map buffer address to physical memory\n");
4216 : : HWRM_UNLOCK();
4217 : 0 : return -ENOMEM;
4218 : : }
4219 : :
4220 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4221 : :
4222 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4223 : : HWRM_UNLOCK();
4224 : :
4225 : 0 : return rc;
4226 : : }
4227 : :
4228 : 0 : int bnxt_hwrm_func_buf_unrgtr(struct bnxt *bp)
4229 : : {
4230 : : int rc = 0;
4231 : 0 : struct hwrm_func_buf_unrgtr_input req = {.req_type = 0 };
4232 : 0 : struct hwrm_func_buf_unrgtr_output *resp = bp->hwrm_cmd_resp_addr;
4233 : :
4234 [ # # # # ]: 0 : if (!(BNXT_PF(bp) && bp->pdev->max_vfs))
4235 : : return 0;
4236 : :
4237 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_BUF_UNRGTR, BNXT_USE_CHIMP_MB);
4238 : :
4239 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4240 : :
4241 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4242 : : HWRM_UNLOCK();
4243 : :
4244 : 0 : return rc;
4245 : : }
4246 : :
4247 : 0 : int bnxt_hwrm_func_cfg_def_cp(struct bnxt *bp)
4248 : : {
4249 : 0 : struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
4250 : 0 : struct hwrm_func_cfg_input req = {0};
4251 : : int rc;
4252 : :
4253 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_CFG, BNXT_USE_CHIMP_MB);
4254 : :
4255 : 0 : req.fid = rte_cpu_to_le_16(0xffff);
4256 : 0 : req.flags = rte_cpu_to_le_32(bp->pf->func_cfg_flags);
4257 : 0 : req.enables = rte_cpu_to_le_32(
4258 : : HWRM_FUNC_CFG_INPUT_ENABLES_ASYNC_EVENT_CR);
4259 : 0 : req.async_event_cr = rte_cpu_to_le_16(
4260 : : bp->async_cp_ring->cp_ring_struct->fw_ring_id);
4261 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4262 : :
4263 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4264 : : HWRM_UNLOCK();
4265 : :
4266 : 0 : return rc;
4267 : : }
4268 : :
4269 : 0 : int bnxt_hwrm_vf_func_cfg_def_cp(struct bnxt *bp)
4270 : : {
4271 : 0 : struct hwrm_func_vf_cfg_output *resp = bp->hwrm_cmd_resp_addr;
4272 : 0 : struct hwrm_func_vf_cfg_input req = {0};
4273 : : int rc;
4274 : :
4275 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_VF_CFG, BNXT_USE_CHIMP_MB);
4276 : :
4277 : 0 : req.enables = rte_cpu_to_le_32(
4278 : : HWRM_FUNC_VF_CFG_INPUT_ENABLES_ASYNC_EVENT_CR);
4279 : 0 : req.async_event_cr = rte_cpu_to_le_16(
4280 : : bp->async_cp_ring->cp_ring_struct->fw_ring_id);
4281 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4282 : :
4283 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4284 : : HWRM_UNLOCK();
4285 : :
4286 : 0 : return rc;
4287 : : }
4288 : :
4289 : 0 : int bnxt_hwrm_set_default_vlan(struct bnxt *bp, int vf, uint8_t is_vf)
4290 : : {
4291 : 0 : struct hwrm_func_cfg_input req = {0};
4292 : 0 : struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
4293 : : uint16_t dflt_vlan, fid;
4294 : : uint32_t func_cfg_flags;
4295 : : int rc = 0;
4296 : :
4297 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_CFG, BNXT_USE_CHIMP_MB);
4298 : :
4299 [ # # ]: 0 : if (is_vf) {
4300 : 0 : dflt_vlan = bp->pf->vf_info[vf].dflt_vlan;
4301 : 0 : fid = bp->pf->vf_info[vf].fid;
4302 : 0 : func_cfg_flags = bp->pf->vf_info[vf].func_cfg_flags;
4303 : : } else {
4304 : : fid = rte_cpu_to_le_16(0xffff);
4305 : 0 : func_cfg_flags = bp->pf->func_cfg_flags;
4306 : 0 : dflt_vlan = bp->vlan;
4307 : : }
4308 : :
4309 : 0 : req.flags = rte_cpu_to_le_32(func_cfg_flags);
4310 : 0 : req.fid = rte_cpu_to_le_16(fid);
4311 : 0 : req.enables |= rte_cpu_to_le_32(HWRM_FUNC_CFG_INPUT_ENABLES_DFLT_VLAN);
4312 : 0 : req.dflt_vlan = rte_cpu_to_le_16(dflt_vlan);
4313 : :
4314 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4315 : :
4316 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4317 : : HWRM_UNLOCK();
4318 : :
4319 : 0 : return rc;
4320 : : }
4321 : :
4322 : 0 : int bnxt_hwrm_func_bw_cfg(struct bnxt *bp, uint16_t vf,
4323 : : uint16_t max_bw, uint16_t enables)
4324 : : {
4325 : 0 : struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
4326 : 0 : struct hwrm_func_cfg_input req = {0};
4327 : : int rc;
4328 : :
4329 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_CFG, BNXT_USE_CHIMP_MB);
4330 : :
4331 : 0 : req.fid = rte_cpu_to_le_16(bp->pf->vf_info[vf].fid);
4332 : 0 : req.enables |= rte_cpu_to_le_32(enables);
4333 : 0 : req.flags = rte_cpu_to_le_32(bp->pf->vf_info[vf].func_cfg_flags);
4334 : 0 : req.max_bw = rte_cpu_to_le_32(max_bw);
4335 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4336 : :
4337 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4338 : : HWRM_UNLOCK();
4339 : :
4340 : 0 : return rc;
4341 : : }
4342 : :
4343 : 0 : int bnxt_hwrm_set_vf_vlan(struct bnxt *bp, int vf)
4344 : : {
4345 : 0 : struct hwrm_func_cfg_input req = {0};
4346 : 0 : struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
4347 : : int rc = 0;
4348 : :
4349 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_CFG, BNXT_USE_CHIMP_MB);
4350 : :
4351 : 0 : req.flags = rte_cpu_to_le_32(bp->pf->vf_info[vf].func_cfg_flags);
4352 : 0 : req.fid = rte_cpu_to_le_16(bp->pf->vf_info[vf].fid);
4353 : 0 : req.enables |= rte_cpu_to_le_32(HWRM_FUNC_CFG_INPUT_ENABLES_DFLT_VLAN);
4354 : 0 : req.dflt_vlan = rte_cpu_to_le_16(bp->pf->vf_info[vf].dflt_vlan);
4355 : :
4356 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4357 : :
4358 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4359 : : HWRM_UNLOCK();
4360 : :
4361 : 0 : return rc;
4362 : : }
4363 : :
4364 : 0 : int bnxt_hwrm_set_async_event_cr(struct bnxt *bp)
4365 : : {
4366 : : int rc;
4367 : :
4368 [ # # ]: 0 : if (BNXT_PF(bp))
4369 : 0 : rc = bnxt_hwrm_func_cfg_def_cp(bp);
4370 : : else
4371 : 0 : rc = bnxt_hwrm_vf_func_cfg_def_cp(bp);
4372 : :
4373 : 0 : return rc;
4374 : : }
4375 : :
4376 : 0 : int bnxt_hwrm_reject_fwd_resp(struct bnxt *bp, uint16_t target_id,
4377 : : void *encaped, size_t ec_size)
4378 : : {
4379 : : int rc = 0;
4380 : 0 : struct hwrm_reject_fwd_resp_input req = {.req_type = 0};
4381 : 0 : struct hwrm_reject_fwd_resp_output *resp = bp->hwrm_cmd_resp_addr;
4382 : :
4383 [ # # ]: 0 : if (ec_size > sizeof(req.encap_request))
4384 : : return -1;
4385 : :
4386 [ # # ]: 0 : HWRM_PREP(&req, HWRM_REJECT_FWD_RESP, BNXT_USE_CHIMP_MB);
4387 : :
4388 : 0 : req.encap_resp_target_id = rte_cpu_to_le_16(target_id);
4389 : : memcpy(req.encap_request, encaped, ec_size);
4390 : :
4391 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4392 : :
4393 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4394 : : HWRM_UNLOCK();
4395 : :
4396 : 0 : return rc;
4397 : : }
4398 : :
4399 : 0 : int bnxt_hwrm_func_qcfg_vf_default_mac(struct bnxt *bp, uint16_t vf,
4400 : : struct rte_ether_addr *mac)
4401 : : {
4402 : 0 : struct hwrm_func_qcfg_input req = {0};
4403 : 0 : struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
4404 : : int rc;
4405 : :
4406 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_QCFG, BNXT_USE_CHIMP_MB);
4407 : :
4408 : 0 : req.fid = rte_cpu_to_le_16(bp->pf->vf_info[vf].fid);
4409 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4410 : :
4411 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4412 : :
4413 : 0 : memcpy(mac->addr_bytes, resp->mac_address, RTE_ETHER_ADDR_LEN);
4414 : :
4415 : : HWRM_UNLOCK();
4416 : :
4417 : 0 : return rc;
4418 : : }
4419 : :
4420 : 0 : int bnxt_hwrm_exec_fwd_resp(struct bnxt *bp, uint16_t target_id,
4421 : : void *encaped, size_t ec_size)
4422 : : {
4423 : : int rc = 0;
4424 : 0 : struct hwrm_exec_fwd_resp_input req = {.req_type = 0};
4425 : 0 : struct hwrm_exec_fwd_resp_output *resp = bp->hwrm_cmd_resp_addr;
4426 : :
4427 [ # # ]: 0 : if (ec_size > sizeof(req.encap_request))
4428 : : return -1;
4429 : :
4430 [ # # ]: 0 : HWRM_PREP(&req, HWRM_EXEC_FWD_RESP, BNXT_USE_CHIMP_MB);
4431 : :
4432 : 0 : req.encap_resp_target_id = rte_cpu_to_le_16(target_id);
4433 : : memcpy(req.encap_request, encaped, ec_size);
4434 : :
4435 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4436 : :
4437 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4438 : : HWRM_UNLOCK();
4439 : :
4440 : 0 : return rc;
4441 : : }
4442 : :
4443 : : static void bnxt_update_prev_stat(uint64_t *cntr, uint64_t *prev_cntr)
4444 : : {
4445 : : /* One of the HW stat values that make up this counter was zero as
4446 : : * returned by HW in this iteration, so use the previous
4447 : : * iteration's counter value
4448 : : */
4449 [ # # # # : 0 : if (*prev_cntr && *cntr == 0)
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # ]
4450 : 0 : *cntr = *prev_cntr;
4451 : : else
4452 : 0 : *prev_cntr = *cntr;
4453 : : }
4454 : :
4455 : 0 : int bnxt_hwrm_ring_stats(struct bnxt *bp, uint32_t cid, int idx,
4456 : : struct bnxt_ring_stats *ring_stats, bool rx)
4457 : : {
4458 : : int rc = 0;
4459 : 0 : struct hwrm_stat_ctx_query_input req = {.req_type = 0};
4460 : 0 : struct hwrm_stat_ctx_query_output *resp = bp->hwrm_cmd_resp_addr;
4461 : :
4462 [ # # ]: 0 : HWRM_PREP(&req, HWRM_STAT_CTX_QUERY, BNXT_USE_CHIMP_MB);
4463 : :
4464 : 0 : req.stat_ctx_id = rte_cpu_to_le_32(cid);
4465 : :
4466 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4467 : :
4468 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4469 : :
4470 [ # # ]: 0 : if (rx) {
4471 : 0 : struct bnxt_ring_stats *prev_stats = &bp->prev_rx_ring_stats[idx];
4472 : :
4473 [ # # ]: 0 : ring_stats->rx_ucast_pkts = rte_le_to_cpu_64(resp->rx_ucast_pkts);
4474 : : bnxt_update_prev_stat(&ring_stats->rx_ucast_pkts,
4475 : : &prev_stats->rx_ucast_pkts);
4476 : :
4477 [ # # ]: 0 : ring_stats->rx_mcast_pkts = rte_le_to_cpu_64(resp->rx_mcast_pkts);
4478 : : bnxt_update_prev_stat(&ring_stats->rx_mcast_pkts,
4479 : : &prev_stats->rx_mcast_pkts);
4480 : :
4481 [ # # ]: 0 : ring_stats->rx_bcast_pkts = rte_le_to_cpu_64(resp->rx_bcast_pkts);
4482 : : bnxt_update_prev_stat(&ring_stats->rx_bcast_pkts,
4483 : : &prev_stats->rx_bcast_pkts);
4484 : :
4485 [ # # ]: 0 : ring_stats->rx_ucast_bytes = rte_le_to_cpu_64(resp->rx_ucast_bytes);
4486 : : bnxt_update_prev_stat(&ring_stats->rx_ucast_bytes,
4487 : : &prev_stats->rx_ucast_bytes);
4488 : :
4489 [ # # ]: 0 : ring_stats->rx_mcast_bytes = rte_le_to_cpu_64(resp->rx_mcast_bytes);
4490 : : bnxt_update_prev_stat(&ring_stats->rx_mcast_bytes,
4491 : : &prev_stats->rx_mcast_bytes);
4492 : :
4493 [ # # ]: 0 : ring_stats->rx_bcast_bytes = rte_le_to_cpu_64(resp->rx_bcast_bytes);
4494 : : bnxt_update_prev_stat(&ring_stats->rx_bcast_bytes,
4495 : : &prev_stats->rx_bcast_bytes);
4496 : :
4497 [ # # ]: 0 : ring_stats->rx_discard_pkts = rte_le_to_cpu_64(resp->rx_discard_pkts);
4498 : : bnxt_update_prev_stat(&ring_stats->rx_discard_pkts,
4499 : : &prev_stats->rx_discard_pkts);
4500 : :
4501 [ # # ]: 0 : ring_stats->rx_error_pkts = rte_le_to_cpu_64(resp->rx_error_pkts);
4502 : : bnxt_update_prev_stat(&ring_stats->rx_error_pkts,
4503 : : &prev_stats->rx_error_pkts);
4504 : :
4505 [ # # ]: 0 : ring_stats->rx_agg_pkts = rte_le_to_cpu_64(resp->rx_agg_pkts);
4506 : : bnxt_update_prev_stat(&ring_stats->rx_agg_pkts,
4507 : : &prev_stats->rx_agg_pkts);
4508 : :
4509 [ # # ]: 0 : ring_stats->rx_agg_bytes = rte_le_to_cpu_64(resp->rx_agg_bytes);
4510 : : bnxt_update_prev_stat(&ring_stats->rx_agg_bytes,
4511 : : &prev_stats->rx_agg_bytes);
4512 : :
4513 [ # # ]: 0 : ring_stats->rx_agg_events = rte_le_to_cpu_64(resp->rx_agg_events);
4514 : : bnxt_update_prev_stat(&ring_stats->rx_agg_events,
4515 : : &prev_stats->rx_agg_events);
4516 : :
4517 [ # # ]: 0 : ring_stats->rx_agg_aborts = rte_le_to_cpu_64(resp->rx_agg_aborts);
4518 : : bnxt_update_prev_stat(&ring_stats->rx_agg_aborts,
4519 : : &prev_stats->rx_agg_aborts);
4520 : : } else {
4521 : 0 : struct bnxt_ring_stats *prev_stats = &bp->prev_tx_ring_stats[idx];
4522 : :
4523 [ # # ]: 0 : ring_stats->tx_ucast_pkts = rte_le_to_cpu_64(resp->tx_ucast_pkts);
4524 : : bnxt_update_prev_stat(&ring_stats->tx_ucast_pkts,
4525 : : &prev_stats->tx_ucast_pkts);
4526 : :
4527 [ # # ]: 0 : ring_stats->tx_mcast_pkts = rte_le_to_cpu_64(resp->tx_mcast_pkts);
4528 : : bnxt_update_prev_stat(&ring_stats->tx_mcast_pkts,
4529 : : &prev_stats->tx_mcast_pkts);
4530 : :
4531 [ # # ]: 0 : ring_stats->tx_bcast_pkts = rte_le_to_cpu_64(resp->tx_bcast_pkts);
4532 : : bnxt_update_prev_stat(&ring_stats->tx_bcast_pkts,
4533 : : &prev_stats->tx_bcast_pkts);
4534 : :
4535 [ # # ]: 0 : ring_stats->tx_ucast_bytes = rte_le_to_cpu_64(resp->tx_ucast_bytes);
4536 : : bnxt_update_prev_stat(&ring_stats->tx_ucast_bytes,
4537 : : &prev_stats->tx_ucast_bytes);
4538 : :
4539 [ # # ]: 0 : ring_stats->tx_mcast_bytes = rte_le_to_cpu_64(resp->tx_mcast_bytes);
4540 : : bnxt_update_prev_stat(&ring_stats->tx_mcast_bytes,
4541 : : &prev_stats->tx_mcast_bytes);
4542 : :
4543 [ # # ]: 0 : ring_stats->tx_bcast_bytes = rte_le_to_cpu_64(resp->tx_bcast_bytes);
4544 : : bnxt_update_prev_stat(&ring_stats->tx_bcast_bytes,
4545 : : &prev_stats->tx_bcast_bytes);
4546 : :
4547 [ # # ]: 0 : ring_stats->tx_discard_pkts = rte_le_to_cpu_64(resp->tx_discard_pkts);
4548 : : bnxt_update_prev_stat(&ring_stats->tx_discard_pkts,
4549 : : &prev_stats->tx_discard_pkts);
4550 : : }
4551 : :
4552 : : HWRM_UNLOCK();
4553 : :
4554 : 0 : return rc;
4555 : : }
4556 : :
4557 : 0 : int bnxt_hwrm_port_qstats(struct bnxt *bp)
4558 : : {
4559 : 0 : struct hwrm_port_qstats_input req = {0};
4560 : 0 : struct hwrm_port_qstats_output *resp = bp->hwrm_cmd_resp_addr;
4561 : 0 : struct bnxt_pf_info *pf = bp->pf;
4562 : : int rc;
4563 : :
4564 [ # # ]: 0 : HWRM_PREP(&req, HWRM_PORT_QSTATS, BNXT_USE_CHIMP_MB);
4565 : :
4566 : 0 : req.port_id = rte_cpu_to_le_16(pf->port_id);
4567 : 0 : req.tx_stat_host_addr = rte_cpu_to_le_64(bp->hw_tx_port_stats_map);
4568 : 0 : req.rx_stat_host_addr = rte_cpu_to_le_64(bp->hw_rx_port_stats_map);
4569 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4570 : :
4571 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4572 : : HWRM_UNLOCK();
4573 : :
4574 : 0 : return rc;
4575 : : }
4576 : :
4577 : 0 : int bnxt_hwrm_port_clr_stats(struct bnxt *bp)
4578 : : {
4579 : 0 : struct hwrm_port_clr_stats_input req = {0};
4580 : 0 : struct hwrm_port_clr_stats_output *resp = bp->hwrm_cmd_resp_addr;
4581 : 0 : struct bnxt_pf_info *pf = bp->pf;
4582 : : int rc;
4583 : :
4584 : : /* Not allowed on NS2 device, NPAR, MultiHost, VF */
4585 [ # # ]: 0 : if (!(bp->flags & BNXT_FLAG_PORT_STATS) || BNXT_VF(bp) ||
4586 [ # # ]: 0 : BNXT_NPAR(bp) || BNXT_MH(bp) || BNXT_TOTAL_VFS(bp))
4587 : : return 0;
4588 : :
4589 [ # # ]: 0 : HWRM_PREP(&req, HWRM_PORT_CLR_STATS, BNXT_USE_CHIMP_MB);
4590 : :
4591 : 0 : req.port_id = rte_cpu_to_le_16(pf->port_id);
4592 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4593 : :
4594 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4595 : : HWRM_UNLOCK();
4596 : :
4597 : 0 : return rc;
4598 : : }
4599 : :
4600 : 0 : int bnxt_hwrm_port_led_qcaps(struct bnxt *bp)
4601 : : {
4602 : 0 : struct hwrm_port_led_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
4603 : 0 : struct hwrm_port_led_qcaps_input req = {0};
4604 : : int rc;
4605 : :
4606 [ # # ]: 0 : if (BNXT_VF(bp))
4607 : : return 0;
4608 : :
4609 [ # # ]: 0 : HWRM_PREP(&req, HWRM_PORT_LED_QCAPS, BNXT_USE_CHIMP_MB);
4610 : 0 : req.port_id = bp->pf->port_id;
4611 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4612 : :
4613 [ # # # # ]: 0 : HWRM_CHECK_RESULT_SILENT();
4614 : :
4615 [ # # ]: 0 : if (resp->num_leds > 0 && resp->num_leds < BNXT_MAX_LED) {
4616 : : unsigned int i;
4617 : :
4618 : 0 : bp->leds->num_leds = resp->num_leds;
4619 : 0 : memcpy(bp->leds, &resp->led0_id,
4620 : 0 : sizeof(bp->leds[0]) * bp->leds->num_leds);
4621 [ # # ]: 0 : for (i = 0; i < bp->leds->num_leds; i++) {
4622 : 0 : struct bnxt_led_info *led = &bp->leds[i];
4623 : :
4624 : 0 : uint16_t caps = led->led_state_caps;
4625 : :
4626 [ # # # # ]: 0 : if (!led->led_group_id ||
4627 : : !BNXT_LED_ALT_BLINK_CAP(caps)) {
4628 : 0 : bp->leds->num_leds = 0;
4629 : 0 : break;
4630 : : }
4631 : : }
4632 : : }
4633 : :
4634 : : HWRM_UNLOCK();
4635 : :
4636 : 0 : return rc;
4637 : : }
4638 : :
4639 : 0 : int bnxt_hwrm_port_led_cfg(struct bnxt *bp, bool led_on)
4640 : : {
4641 : 0 : struct hwrm_port_led_cfg_output *resp = bp->hwrm_cmd_resp_addr;
4642 : 0 : struct hwrm_port_led_cfg_input req = {0};
4643 : : struct bnxt_led_cfg *led_cfg;
4644 : : uint8_t led_state = HWRM_PORT_LED_QCFG_OUTPUT_LED0_STATE_DEFAULT;
4645 : : uint16_t duration = 0;
4646 : : int rc, i;
4647 : :
4648 [ # # # # : 0 : if (BNXT_VF(bp) || !bp->leds || !bp->leds->num_leds)
# # ]
4649 : : return -EOPNOTSUPP;
4650 : :
4651 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_PORT_LED_CFG, BNXT_USE_CHIMP_MB);
4652 : :
4653 [ # # ]: 0 : if (led_on) {
4654 : : led_state = HWRM_PORT_LED_CFG_INPUT_LED0_STATE_BLINKALT;
4655 : : duration = rte_cpu_to_le_16(500);
4656 : : }
4657 : 0 : req.port_id = bp->pf->port_id;
4658 : 0 : req.num_leds = bp->leds->num_leds;
4659 : : led_cfg = (struct bnxt_led_cfg *)&req.led0_id;
4660 [ # # ]: 0 : for (i = 0; i < bp->leds->num_leds; i++, led_cfg++) {
4661 : 0 : req.enables |= BNXT_LED_DFLT_ENABLES(i);
4662 : 0 : led_cfg->led_id = bp->leds[i].led_id;
4663 : 0 : led_cfg->led_state = led_state;
4664 : 0 : led_cfg->led_blink_on = duration;
4665 : 0 : led_cfg->led_blink_off = duration;
4666 : 0 : led_cfg->led_group_id = bp->leds[i].led_group_id;
4667 : : }
4668 : :
4669 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4670 : :
4671 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4672 : : HWRM_UNLOCK();
4673 : :
4674 : 0 : return rc;
4675 : : }
4676 : :
4677 : 0 : int bnxt_hwrm_nvm_get_dir_info(struct bnxt *bp, uint32_t *entries,
4678 : : uint32_t *length)
4679 : : {
4680 : : int rc;
4681 : 0 : struct hwrm_nvm_get_dir_info_input req = {0};
4682 : 0 : struct hwrm_nvm_get_dir_info_output *resp = bp->hwrm_cmd_resp_addr;
4683 : :
4684 [ # # ]: 0 : HWRM_PREP(&req, HWRM_NVM_GET_DIR_INFO, BNXT_USE_CHIMP_MB);
4685 : :
4686 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4687 : :
4688 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4689 : :
4690 : 0 : *entries = rte_le_to_cpu_32(resp->entries);
4691 : 0 : *length = rte_le_to_cpu_32(resp->entry_length);
4692 : :
4693 : : HWRM_UNLOCK();
4694 : 0 : return rc;
4695 : : }
4696 : :
4697 : 0 : int bnxt_get_nvram_directory(struct bnxt *bp, uint32_t len, uint8_t *data)
4698 : : {
4699 : : int rc;
4700 : : uint32_t dir_entries;
4701 : : uint32_t entry_length;
4702 : : uint8_t *buf;
4703 : : size_t buflen;
4704 : : rte_iova_t dma_handle;
4705 : 0 : struct hwrm_nvm_get_dir_entries_input req = {0};
4706 : 0 : struct hwrm_nvm_get_dir_entries_output *resp = bp->hwrm_cmd_resp_addr;
4707 : :
4708 : 0 : rc = bnxt_hwrm_nvm_get_dir_info(bp, &dir_entries, &entry_length);
4709 [ # # ]: 0 : if (rc != 0)
4710 : : return rc;
4711 : :
4712 : 0 : *data++ = dir_entries;
4713 : 0 : *data++ = entry_length;
4714 : 0 : len -= 2;
4715 : 0 : memset(data, 0xff, len);
4716 : :
4717 : 0 : buflen = dir_entries * entry_length;
4718 : 0 : buf = rte_malloc("nvm_dir", buflen, 0);
4719 [ # # ]: 0 : if (buf == NULL)
4720 : : return -ENOMEM;
4721 : 0 : dma_handle = rte_malloc_virt2iova(buf);
4722 [ # # ]: 0 : if (dma_handle == RTE_BAD_IOVA) {
4723 : 0 : rte_free(buf);
4724 : 0 : PMD_DRV_LOG(ERR,
4725 : : "unable to map response address to physical memory\n");
4726 : 0 : return -ENOMEM;
4727 : : }
4728 [ # # ]: 0 : HWRM_PREP(&req, HWRM_NVM_GET_DIR_ENTRIES, BNXT_USE_CHIMP_MB);
4729 : 0 : req.host_dest_addr = rte_cpu_to_le_64(dma_handle);
4730 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4731 : :
4732 [ # # ]: 0 : if (rc == 0)
4733 : 0 : memcpy(data, buf, len > buflen ? buflen : len);
4734 : :
4735 : 0 : rte_free(buf);
4736 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4737 : : HWRM_UNLOCK();
4738 : :
4739 : 0 : return rc;
4740 : : }
4741 : :
4742 : 0 : int bnxt_hwrm_get_nvram_item(struct bnxt *bp, uint32_t index,
4743 : : uint32_t offset, uint32_t length,
4744 : : uint8_t *data)
4745 : : {
4746 : : int rc;
4747 : : uint8_t *buf;
4748 : : rte_iova_t dma_handle;
4749 : 0 : struct hwrm_nvm_read_input req = {0};
4750 : 0 : struct hwrm_nvm_read_output *resp = bp->hwrm_cmd_resp_addr;
4751 : :
4752 : 0 : buf = rte_malloc("nvm_item", length, 0);
4753 [ # # ]: 0 : if (!buf)
4754 : : return -ENOMEM;
4755 : :
4756 : 0 : dma_handle = rte_malloc_virt2iova(buf);
4757 [ # # ]: 0 : if (dma_handle == RTE_BAD_IOVA) {
4758 : 0 : rte_free(buf);
4759 : 0 : PMD_DRV_LOG(ERR,
4760 : : "unable to map response address to physical memory\n");
4761 : 0 : return -ENOMEM;
4762 : : }
4763 [ # # ]: 0 : HWRM_PREP(&req, HWRM_NVM_READ, BNXT_USE_CHIMP_MB);
4764 : 0 : req.host_dest_addr = rte_cpu_to_le_64(dma_handle);
4765 : 0 : req.dir_idx = rte_cpu_to_le_16(index);
4766 : 0 : req.offset = rte_cpu_to_le_32(offset);
4767 : 0 : req.len = rte_cpu_to_le_32(length);
4768 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4769 [ # # ]: 0 : if (rc == 0)
4770 : : memcpy(data, buf, length);
4771 : :
4772 : 0 : rte_free(buf);
4773 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4774 : : HWRM_UNLOCK();
4775 : :
4776 : 0 : return rc;
4777 : : }
4778 : :
4779 : 0 : int bnxt_hwrm_erase_nvram_directory(struct bnxt *bp, uint8_t index)
4780 : : {
4781 : : int rc;
4782 : 0 : struct hwrm_nvm_erase_dir_entry_input req = {0};
4783 : 0 : struct hwrm_nvm_erase_dir_entry_output *resp = bp->hwrm_cmd_resp_addr;
4784 : :
4785 [ # # ]: 0 : HWRM_PREP(&req, HWRM_NVM_ERASE_DIR_ENTRY, BNXT_USE_CHIMP_MB);
4786 : 0 : req.dir_idx = rte_cpu_to_le_16(index);
4787 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4788 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4789 : : HWRM_UNLOCK();
4790 : :
4791 : 0 : return rc;
4792 : : }
4793 : :
4794 : 0 : int bnxt_hwrm_flash_nvram(struct bnxt *bp, uint16_t dir_type,
4795 : : uint16_t dir_ordinal, uint16_t dir_ext,
4796 : : uint16_t dir_attr, const uint8_t *data,
4797 : : size_t data_len)
4798 : : {
4799 : : int rc;
4800 : 0 : struct hwrm_nvm_write_input req = {0};
4801 : 0 : struct hwrm_nvm_write_output *resp = bp->hwrm_cmd_resp_addr;
4802 : : rte_iova_t dma_handle;
4803 : : uint8_t *buf;
4804 : :
4805 : 0 : buf = rte_malloc("nvm_write", data_len, 0);
4806 [ # # ]: 0 : if (!buf)
4807 : : return -ENOMEM;
4808 : :
4809 : 0 : dma_handle = rte_malloc_virt2iova(buf);
4810 [ # # ]: 0 : if (dma_handle == RTE_BAD_IOVA) {
4811 : 0 : rte_free(buf);
4812 : 0 : PMD_DRV_LOG(ERR,
4813 : : "unable to map response address to physical memory\n");
4814 : 0 : return -ENOMEM;
4815 : : }
4816 : : memcpy(buf, data, data_len);
4817 : :
4818 [ # # ]: 0 : HWRM_PREP(&req, HWRM_NVM_WRITE, BNXT_USE_CHIMP_MB);
4819 : :
4820 : 0 : req.dir_type = rte_cpu_to_le_16(dir_type);
4821 : 0 : req.dir_ordinal = rte_cpu_to_le_16(dir_ordinal);
4822 : 0 : req.dir_ext = rte_cpu_to_le_16(dir_ext);
4823 : 0 : req.dir_attr = rte_cpu_to_le_16(dir_attr);
4824 : 0 : req.dir_data_length = rte_cpu_to_le_32(data_len);
4825 : 0 : req.host_src_addr = rte_cpu_to_le_64(dma_handle);
4826 : :
4827 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4828 : :
4829 : 0 : rte_free(buf);
4830 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4831 : : HWRM_UNLOCK();
4832 : :
4833 : 0 : return rc;
4834 : : }
4835 : :
4836 : : static void
4837 : 0 : bnxt_vnic_count(struct bnxt_vnic_info *vnic __rte_unused, void *cbdata)
4838 : : {
4839 : : uint32_t *count = cbdata;
4840 : :
4841 : 0 : *count = *count + 1;
4842 : 0 : }
4843 : :
4844 : 0 : static int bnxt_vnic_count_hwrm_stub(struct bnxt *bp __rte_unused,
4845 : : struct bnxt_vnic_info *vnic __rte_unused)
4846 : : {
4847 : 0 : return 0;
4848 : : }
4849 : :
4850 : 0 : int bnxt_vf_vnic_count(struct bnxt *bp, uint16_t vf)
4851 : : {
4852 : 0 : uint32_t count = 0;
4853 : :
4854 : 0 : bnxt_hwrm_func_vf_vnic_query_and_config(bp, vf, bnxt_vnic_count,
4855 : : &count, bnxt_vnic_count_hwrm_stub);
4856 : :
4857 : 0 : return count;
4858 : : }
4859 : :
4860 : 0 : static int bnxt_hwrm_func_vf_vnic_query(struct bnxt *bp, uint16_t vf,
4861 : : uint16_t *vnic_ids)
4862 : : {
4863 : 0 : struct hwrm_func_vf_vnic_ids_query_input req = {0};
4864 : 0 : struct hwrm_func_vf_vnic_ids_query_output *resp =
4865 : : bp->hwrm_cmd_resp_addr;
4866 : : int rc;
4867 : :
4868 : : /* First query all VNIC ids */
4869 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_VF_VNIC_IDS_QUERY, BNXT_USE_CHIMP_MB);
4870 : :
4871 : 0 : req.vf_id = rte_cpu_to_le_16(bp->pf->first_vf_id + vf);
4872 : 0 : req.max_vnic_id_cnt = rte_cpu_to_le_32(bp->pf->total_vnics);
4873 : 0 : req.vnic_id_tbl_addr = rte_cpu_to_le_64(rte_malloc_virt2iova(vnic_ids));
4874 : :
4875 [ # # ]: 0 : if (req.vnic_id_tbl_addr == RTE_BAD_IOVA) {
4876 : : HWRM_UNLOCK();
4877 : 0 : PMD_DRV_LOG(ERR,
4878 : : "unable to map VNIC ID table address to physical memory\n");
4879 : 0 : return -ENOMEM;
4880 : : }
4881 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4882 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4883 : 0 : rc = rte_le_to_cpu_32(resp->vnic_id_cnt);
4884 : :
4885 : : HWRM_UNLOCK();
4886 : :
4887 : 0 : return rc;
4888 : : }
4889 : :
4890 : : /*
4891 : : * This function queries the VNIC IDs for a specified VF. It then calls
4892 : : * the vnic_cb to update the necessary field in vnic_info with cbdata.
4893 : : * Then it calls the hwrm_cb function to program this new vnic configuration.
4894 : : */
4895 : 0 : int bnxt_hwrm_func_vf_vnic_query_and_config(struct bnxt *bp, uint16_t vf,
4896 : : void (*vnic_cb)(struct bnxt_vnic_info *, void *), void *cbdata,
4897 : : int (*hwrm_cb)(struct bnxt *bp, struct bnxt_vnic_info *vnic))
4898 : : {
4899 : : struct bnxt_vnic_info vnic;
4900 : : int rc = 0;
4901 : : int i, num_vnic_ids;
4902 : : uint16_t *vnic_ids;
4903 : : size_t vnic_id_sz;
4904 : : size_t sz;
4905 : :
4906 : : /* First query all VNIC ids */
4907 : 0 : vnic_id_sz = bp->pf->total_vnics * sizeof(*vnic_ids);
4908 : 0 : vnic_ids = rte_malloc("bnxt_hwrm_vf_vnic_ids_query", vnic_id_sz,
4909 : : RTE_CACHE_LINE_SIZE);
4910 [ # # ]: 0 : if (vnic_ids == NULL)
4911 : : return -ENOMEM;
4912 : :
4913 [ # # ]: 0 : for (sz = 0; sz < vnic_id_sz; sz += getpagesize())
4914 : 0 : rte_mem_lock_page(((char *)vnic_ids) + sz);
4915 : :
4916 : 0 : num_vnic_ids = bnxt_hwrm_func_vf_vnic_query(bp, vf, vnic_ids);
4917 : :
4918 [ # # ]: 0 : if (num_vnic_ids < 0)
4919 : : return num_vnic_ids;
4920 : :
4921 : : /* Retrieve VNIC, update bd_stall then update */
4922 : :
4923 [ # # ]: 0 : for (i = 0; i < num_vnic_ids; i++) {
4924 : : memset(&vnic, 0, sizeof(struct bnxt_vnic_info));
4925 : 0 : vnic.fw_vnic_id = rte_le_to_cpu_16(vnic_ids[i]);
4926 : 0 : rc = bnxt_hwrm_vnic_qcfg(bp, &vnic, bp->pf->first_vf_id + vf);
4927 [ # # ]: 0 : if (rc)
4928 : : break;
4929 [ # # ]: 0 : if (vnic.mru <= 4) /* Indicates unallocated */
4930 : 0 : continue;
4931 : :
4932 : 0 : vnic_cb(&vnic, cbdata);
4933 : :
4934 : 0 : rc = hwrm_cb(bp, &vnic);
4935 [ # # ]: 0 : if (rc)
4936 : : break;
4937 : : }
4938 : :
4939 : 0 : rte_free(vnic_ids);
4940 : :
4941 : 0 : return rc;
4942 : : }
4943 : :
4944 : 0 : int bnxt_hwrm_func_cfg_vf_set_vlan_anti_spoof(struct bnxt *bp, uint16_t vf,
4945 : : bool on)
4946 : : {
4947 : 0 : struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
4948 : 0 : struct hwrm_func_cfg_input req = {0};
4949 : : int rc;
4950 : :
4951 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_CFG, BNXT_USE_CHIMP_MB);
4952 : :
4953 : 0 : req.fid = rte_cpu_to_le_16(bp->pf->vf_info[vf].fid);
4954 : 0 : req.enables |= rte_cpu_to_le_32(
4955 : : HWRM_FUNC_CFG_INPUT_ENABLES_VLAN_ANTISPOOF_MODE);
4956 [ # # ]: 0 : req.vlan_antispoof_mode = on ?
4957 : : HWRM_FUNC_CFG_INPUT_VLAN_ANTISPOOF_MODE_VALIDATE_VLAN :
4958 : : HWRM_FUNC_CFG_INPUT_VLAN_ANTISPOOF_MODE_NOCHECK;
4959 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4960 : :
4961 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
4962 : : HWRM_UNLOCK();
4963 : :
4964 : 0 : return rc;
4965 : : }
4966 : :
4967 : 0 : int bnxt_hwrm_func_qcfg_vf_dflt_vnic_id(struct bnxt *bp, int vf)
4968 : : {
4969 : : struct bnxt_vnic_info vnic;
4970 : : uint16_t *vnic_ids;
4971 : : size_t vnic_id_sz;
4972 : : int num_vnic_ids, i;
4973 : : size_t sz;
4974 : : int rc;
4975 : :
4976 : 0 : vnic_id_sz = bp->pf->total_vnics * sizeof(*vnic_ids);
4977 : 0 : vnic_ids = rte_malloc("bnxt_hwrm_vf_vnic_ids_query", vnic_id_sz,
4978 : : RTE_CACHE_LINE_SIZE);
4979 [ # # ]: 0 : if (vnic_ids == NULL)
4980 : : return -ENOMEM;
4981 : :
4982 [ # # ]: 0 : for (sz = 0; sz < vnic_id_sz; sz += getpagesize())
4983 : 0 : rte_mem_lock_page(((char *)vnic_ids) + sz);
4984 : :
4985 : 0 : rc = bnxt_hwrm_func_vf_vnic_query(bp, vf, vnic_ids);
4986 [ # # ]: 0 : if (rc <= 0)
4987 : 0 : goto exit;
4988 : : num_vnic_ids = rc;
4989 : :
4990 : : /*
4991 : : * Loop through to find the default VNIC ID.
4992 : : * TODO: The easier way would be to obtain the resp->dflt_vnic_id
4993 : : * by sending the hwrm_func_qcfg command to the firmware.
4994 : : */
4995 [ # # ]: 0 : for (i = 0; i < num_vnic_ids; i++) {
4996 : : memset(&vnic, 0, sizeof(struct bnxt_vnic_info));
4997 : 0 : vnic.fw_vnic_id = rte_le_to_cpu_16(vnic_ids[i]);
4998 : 0 : rc = bnxt_hwrm_vnic_qcfg(bp, &vnic,
4999 : 0 : bp->pf->first_vf_id + vf);
5000 [ # # ]: 0 : if (rc)
5001 : 0 : goto exit;
5002 [ # # ]: 0 : if (vnic.func_default) {
5003 : 0 : rte_free(vnic_ids);
5004 : 0 : return vnic.fw_vnic_id;
5005 : : }
5006 : : }
5007 : : /* Could not find a default VNIC. */
5008 : 0 : PMD_DRV_LOG(ERR, "No default VNIC\n");
5009 : 0 : exit:
5010 : 0 : rte_free(vnic_ids);
5011 : 0 : return rc;
5012 : : }
5013 : :
5014 : 0 : int bnxt_hwrm_set_em_filter(struct bnxt *bp,
5015 : : uint16_t dst_id,
5016 : : struct bnxt_filter_info *filter)
5017 : : {
5018 : : int rc = 0;
5019 : 0 : struct hwrm_cfa_em_flow_alloc_input req = {.req_type = 0 };
5020 : 0 : struct hwrm_cfa_em_flow_alloc_output *resp = bp->hwrm_cmd_resp_addr;
5021 : : uint32_t enables = 0;
5022 : :
5023 [ # # ]: 0 : if (filter->fw_em_filter_id != UINT64_MAX)
5024 : 0 : bnxt_hwrm_clear_em_filter(bp, filter);
5025 : :
5026 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_EM_FLOW_ALLOC, BNXT_USE_KONG(bp));
5027 : :
5028 : 0 : req.flags = rte_cpu_to_le_32(filter->flags);
5029 : :
5030 : 0 : enables = filter->enables |
5031 : : HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_DST_ID;
5032 : 0 : req.dst_id = rte_cpu_to_le_16(dst_id);
5033 : :
5034 [ # # ]: 0 : if (filter->ip_addr_type) {
5035 : 0 : req.ip_addr_type = filter->ip_addr_type;
5036 : 0 : enables |= HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_IPADDR_TYPE;
5037 : : }
5038 [ # # ]: 0 : if (enables &
5039 : : HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_L2_FILTER_ID)
5040 : 0 : req.l2_filter_id = rte_cpu_to_le_64(filter->fw_l2_filter_id);
5041 [ # # ]: 0 : if (enables &
5042 : : HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_SRC_MACADDR)
5043 : : memcpy(req.src_macaddr, filter->src_macaddr,
5044 : : RTE_ETHER_ADDR_LEN);
5045 [ # # ]: 0 : if (enables &
5046 : : HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_DST_MACADDR)
5047 : : memcpy(req.dst_macaddr, filter->dst_macaddr,
5048 : : RTE_ETHER_ADDR_LEN);
5049 [ # # ]: 0 : if (enables &
5050 : : HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_OVLAN_VID)
5051 : 0 : req.ovlan_vid = filter->l2_ovlan;
5052 [ # # ]: 0 : if (enables &
5053 : : HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_IVLAN_VID)
5054 : 0 : req.ivlan_vid = filter->l2_ivlan;
5055 [ # # ]: 0 : if (enables &
5056 : : HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_ETHERTYPE)
5057 [ # # ]: 0 : req.ethertype = rte_cpu_to_be_16(filter->ethertype);
5058 [ # # ]: 0 : if (enables &
5059 : : HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_IP_PROTOCOL)
5060 : 0 : req.ip_protocol = filter->ip_protocol;
5061 [ # # ]: 0 : if (enables &
5062 : : HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_SRC_IPADDR)
5063 [ # # ]: 0 : req.src_ipaddr[0] = rte_cpu_to_be_32(filter->src_ipaddr[0]);
5064 [ # # ]: 0 : if (enables &
5065 : : HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_DST_IPADDR)
5066 [ # # ]: 0 : req.dst_ipaddr[0] = rte_cpu_to_be_32(filter->dst_ipaddr[0]);
5067 [ # # ]: 0 : if (enables &
5068 : : HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_SRC_PORT)
5069 [ # # ]: 0 : req.src_port = rte_cpu_to_be_16(filter->src_port);
5070 [ # # ]: 0 : if (enables &
5071 : : HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_DST_PORT)
5072 [ # # ]: 0 : req.dst_port = rte_cpu_to_be_16(filter->dst_port);
5073 [ # # ]: 0 : if (enables &
5074 : : HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_MIRROR_VNIC_ID)
5075 : 0 : req.mirror_vnic_id = filter->mirror_vnic_id;
5076 : :
5077 : 0 : req.enables = rte_cpu_to_le_32(enables);
5078 : :
5079 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_KONG(bp));
5080 : :
5081 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5082 : :
5083 : 0 : filter->fw_em_filter_id = rte_le_to_cpu_64(resp->em_filter_id);
5084 : : HWRM_UNLOCK();
5085 : :
5086 : 0 : return rc;
5087 : : }
5088 : :
5089 : 0 : int bnxt_hwrm_clear_em_filter(struct bnxt *bp, struct bnxt_filter_info *filter)
5090 : : {
5091 : : int rc = 0;
5092 : 0 : struct hwrm_cfa_em_flow_free_input req = {.req_type = 0 };
5093 : 0 : struct hwrm_cfa_em_flow_free_output *resp = bp->hwrm_cmd_resp_addr;
5094 : :
5095 [ # # ]: 0 : if (filter->fw_em_filter_id == UINT64_MAX)
5096 : : return 0;
5097 : :
5098 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_EM_FLOW_FREE, BNXT_USE_KONG(bp));
5099 : :
5100 : 0 : req.em_filter_id = rte_cpu_to_le_64(filter->fw_em_filter_id);
5101 : :
5102 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_KONG(bp));
5103 : :
5104 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5105 : : HWRM_UNLOCK();
5106 : :
5107 : 0 : filter->fw_em_filter_id = UINT64_MAX;
5108 : 0 : filter->fw_l2_filter_id = UINT64_MAX;
5109 : :
5110 : 0 : return 0;
5111 : : }
5112 : :
5113 : 0 : int bnxt_hwrm_set_ntuple_filter(struct bnxt *bp,
5114 : : uint16_t dst_id,
5115 : : struct bnxt_filter_info *filter)
5116 : : {
5117 : : int rc = 0;
5118 : 0 : struct hwrm_cfa_ntuple_filter_alloc_input req = {.req_type = 0 };
5119 : 0 : struct hwrm_cfa_ntuple_filter_alloc_output *resp =
5120 : : bp->hwrm_cmd_resp_addr;
5121 : : uint32_t enables = 0;
5122 : :
5123 [ # # ]: 0 : if (filter->fw_ntuple_filter_id != UINT64_MAX)
5124 : 0 : bnxt_hwrm_clear_ntuple_filter(bp, filter);
5125 : :
5126 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_NTUPLE_FILTER_ALLOC, BNXT_USE_CHIMP_MB);
5127 : :
5128 : 0 : req.flags = rte_cpu_to_le_32(filter->flags);
5129 : :
5130 : 0 : enables = filter->enables |
5131 : : HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_DST_ID;
5132 : 0 : req.dst_id = rte_cpu_to_le_16(dst_id);
5133 : :
5134 [ # # ]: 0 : if (filter->ip_addr_type) {
5135 : 0 : req.ip_addr_type = filter->ip_addr_type;
5136 : 0 : enables |=
5137 : : HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_IPADDR_TYPE;
5138 : : }
5139 [ # # ]: 0 : if (enables &
5140 : : HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_L2_FILTER_ID)
5141 : 0 : req.l2_filter_id = rte_cpu_to_le_64(filter->fw_l2_filter_id);
5142 [ # # ]: 0 : if (enables &
5143 : : HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_SRC_MACADDR)
5144 : : memcpy(req.src_macaddr, filter->src_macaddr,
5145 : : RTE_ETHER_ADDR_LEN);
5146 [ # # ]: 0 : if (enables &
5147 : : HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_ETHERTYPE)
5148 [ # # ]: 0 : req.ethertype = rte_cpu_to_be_16(filter->ethertype);
5149 [ # # ]: 0 : if (enables &
5150 : : HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_IP_PROTOCOL)
5151 : 0 : req.ip_protocol = filter->ip_protocol;
5152 [ # # ]: 0 : if (enables &
5153 : : HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_SRC_IPADDR)
5154 : 0 : req.src_ipaddr[0] = rte_cpu_to_le_32(filter->src_ipaddr[0]);
5155 [ # # ]: 0 : if (enables &
5156 : : HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_SRC_IPADDR_MASK)
5157 : 0 : req.src_ipaddr_mask[0] =
5158 : 0 : rte_cpu_to_le_32(filter->src_ipaddr_mask[0]);
5159 [ # # ]: 0 : if (enables &
5160 : : HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_DST_IPADDR)
5161 : 0 : req.dst_ipaddr[0] = rte_cpu_to_le_32(filter->dst_ipaddr[0]);
5162 [ # # ]: 0 : if (enables &
5163 : : HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_DST_IPADDR_MASK)
5164 : 0 : req.dst_ipaddr_mask[0] =
5165 [ # # ]: 0 : rte_cpu_to_be_32(filter->dst_ipaddr_mask[0]);
5166 [ # # ]: 0 : if (enables &
5167 : : HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_SRC_PORT)
5168 : 0 : req.src_port = rte_cpu_to_le_16(filter->src_port);
5169 [ # # ]: 0 : if (enables &
5170 : : HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_SRC_PORT_MASK)
5171 : 0 : req.src_port_mask = rte_cpu_to_le_16(filter->src_port_mask);
5172 [ # # ]: 0 : if (enables &
5173 : : HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_DST_PORT)
5174 : 0 : req.dst_port = rte_cpu_to_le_16(filter->dst_port);
5175 [ # # ]: 0 : if (enables &
5176 : : HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_DST_PORT_MASK)
5177 : 0 : req.dst_port_mask = rte_cpu_to_le_16(filter->dst_port_mask);
5178 [ # # ]: 0 : if (enables &
5179 : : HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_MIRROR_VNIC_ID)
5180 : 0 : req.mirror_vnic_id = filter->mirror_vnic_id;
5181 : :
5182 : 0 : req.enables = rte_cpu_to_le_32(enables);
5183 : :
5184 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5185 : :
5186 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5187 : :
5188 : 0 : filter->fw_ntuple_filter_id = rte_le_to_cpu_64(resp->ntuple_filter_id);
5189 : 0 : filter->flow_id = rte_le_to_cpu_32(resp->flow_id);
5190 : : HWRM_UNLOCK();
5191 : :
5192 : 0 : return rc;
5193 : : }
5194 : :
5195 : 0 : int bnxt_hwrm_clear_ntuple_filter(struct bnxt *bp,
5196 : : struct bnxt_filter_info *filter)
5197 : : {
5198 : : int rc = 0;
5199 : 0 : struct hwrm_cfa_ntuple_filter_free_input req = {.req_type = 0 };
5200 : 0 : struct hwrm_cfa_ntuple_filter_free_output *resp =
5201 : : bp->hwrm_cmd_resp_addr;
5202 : :
5203 [ # # ]: 0 : if (filter->fw_ntuple_filter_id == UINT64_MAX)
5204 : : return 0;
5205 : :
5206 [ # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_NTUPLE_FILTER_FREE, BNXT_USE_CHIMP_MB);
5207 : :
5208 : 0 : req.ntuple_filter_id = rte_cpu_to_le_64(filter->fw_ntuple_filter_id);
5209 : :
5210 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5211 : :
5212 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5213 : : HWRM_UNLOCK();
5214 : :
5215 : 0 : filter->fw_ntuple_filter_id = UINT64_MAX;
5216 : :
5217 : 0 : return 0;
5218 : : }
5219 : :
5220 : : static int
5221 : 0 : bnxt_vnic_rss_configure_p5(struct bnxt *bp, struct bnxt_vnic_info *vnic)
5222 : : {
5223 : 0 : struct hwrm_vnic_rss_cfg_output *resp = bp->hwrm_cmd_resp_addr;
5224 : 0 : uint8_t *rxq_state = bp->eth_dev->data->rx_queue_state;
5225 : 0 : struct hwrm_vnic_rss_cfg_input req = {.req_type = 0 };
5226 : 0 : struct bnxt_rx_queue **rxqs = bp->rx_queues;
5227 : 0 : uint16_t *ring_tbl = vnic->rss_table;
5228 : 0 : int nr_ctxs = vnic->num_lb_ctxts;
5229 : 0 : int max_rings = bp->rx_nr_rings;
5230 : : int i, j, k, cnt;
5231 : : int rc = 0;
5232 : :
5233 [ # # ]: 0 : for (i = 0, k = 0; i < nr_ctxs; i++) {
5234 : : struct bnxt_rx_ring_info *rxr;
5235 : : struct bnxt_cp_ring_info *cpr;
5236 : :
5237 [ # # ]: 0 : HWRM_PREP(&req, HWRM_VNIC_RSS_CFG, BNXT_USE_CHIMP_MB);
5238 : :
5239 : 0 : req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
5240 : 0 : req.hash_type = rte_cpu_to_le_32(vnic->hash_type);
5241 : 0 : req.hash_mode_flags = vnic->hash_mode;
5242 : :
5243 : 0 : req.ring_grp_tbl_addr =
5244 : 0 : rte_cpu_to_le_64(vnic->rss_table_dma_addr +
5245 : : i * BNXT_RSS_ENTRIES_PER_CTX_P5 *
5246 : : 2 * sizeof(*ring_tbl));
5247 : 0 : req.hash_key_tbl_addr =
5248 : 0 : rte_cpu_to_le_64(vnic->rss_hash_key_dma_addr);
5249 : :
5250 : 0 : req.ring_table_pair_index = i;
5251 : 0 : req.rss_ctx_idx = rte_cpu_to_le_16(vnic->fw_grp_ids[i]);
5252 : :
5253 [ # # ]: 0 : for (j = 0; j < 64; j++) {
5254 : : uint16_t ring_id;
5255 : :
5256 : : /* Find next active ring. */
5257 [ # # ]: 0 : for (cnt = 0; cnt < max_rings; cnt++) {
5258 [ # # ]: 0 : if (rxq_state[k] != RTE_ETH_QUEUE_STATE_STOPPED)
5259 : : break;
5260 [ # # ]: 0 : if (++k == max_rings)
5261 : : k = 0;
5262 : : }
5263 : :
5264 : : /* Return if no rings are active. */
5265 [ # # ]: 0 : if (cnt == max_rings) {
5266 : : HWRM_UNLOCK();
5267 : 0 : return 0;
5268 : : }
5269 : :
5270 : : /* Add rx/cp ring pair to RSS table. */
5271 : 0 : rxr = rxqs[k]->rx_ring;
5272 : 0 : cpr = rxqs[k]->cp_ring;
5273 : :
5274 : 0 : ring_id = rxr->rx_ring_struct->fw_ring_id;
5275 : 0 : *ring_tbl++ = rte_cpu_to_le_16(ring_id);
5276 : 0 : ring_id = cpr->cp_ring_struct->fw_ring_id;
5277 : 0 : *ring_tbl++ = rte_cpu_to_le_16(ring_id);
5278 : :
5279 [ # # ]: 0 : if (++k == max_rings)
5280 : : k = 0;
5281 : : }
5282 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req),
5283 : : BNXT_USE_CHIMP_MB);
5284 : :
5285 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5286 : : HWRM_UNLOCK();
5287 : : }
5288 : :
5289 : : return rc;
5290 : : }
5291 : :
5292 : 0 : int bnxt_vnic_rss_configure(struct bnxt *bp, struct bnxt_vnic_info *vnic)
5293 : : {
5294 : : unsigned int rss_idx, fw_idx, i;
5295 : :
5296 [ # # ]: 0 : if (vnic->fw_vnic_id == INVALID_HW_RING_ID)
5297 : : return 0;
5298 : :
5299 [ # # # # ]: 0 : if (!(vnic->rss_table && vnic->hash_type))
5300 : : return 0;
5301 : :
5302 [ # # ]: 0 : if (BNXT_CHIP_P5(bp))
5303 : 0 : return bnxt_vnic_rss_configure_p5(bp, vnic);
5304 : :
5305 : : /*
5306 : : * Fill the RSS hash & redirection table with
5307 : : * ring group ids for all VNICs
5308 : : */
5309 [ # # ]: 0 : for (rss_idx = 0, fw_idx = 0; rss_idx < HW_HASH_INDEX_SIZE;
5310 : 0 : rss_idx++, fw_idx++) {
5311 [ # # ]: 0 : for (i = 0; i < bp->rx_cp_nr_rings; i++) {
5312 : 0 : fw_idx %= bp->rx_cp_nr_rings;
5313 [ # # ]: 0 : if (vnic->fw_grp_ids[fw_idx] != INVALID_HW_RING_ID)
5314 : : break;
5315 : 0 : fw_idx++;
5316 : : }
5317 : :
5318 [ # # ]: 0 : if (i == bp->rx_cp_nr_rings)
5319 : : return 0;
5320 : :
5321 : 0 : vnic->rss_table[rss_idx] = vnic->fw_grp_ids[fw_idx];
5322 : : }
5323 : :
5324 : 0 : return bnxt_hwrm_vnic_rss_cfg(bp, vnic);
5325 : : }
5326 : :
5327 : : static void bnxt_hwrm_set_coal_params(struct bnxt_coal *hw_coal,
5328 : : struct hwrm_ring_cmpl_ring_cfg_aggint_params_input *req)
5329 : : {
5330 : : uint16_t flags;
5331 : :
5332 : 0 : req->num_cmpl_aggr_int = rte_cpu_to_le_16(hw_coal->num_cmpl_aggr_int);
5333 : :
5334 : : /* This is a 6-bit value and must not be 0, or we'll get non stop IRQ */
5335 : 0 : req->num_cmpl_dma_aggr = rte_cpu_to_le_16(hw_coal->num_cmpl_dma_aggr);
5336 : :
5337 : : /* This is a 6-bit value and must not be 0, or we'll get non stop IRQ */
5338 : 0 : req->num_cmpl_dma_aggr_during_int =
5339 : 0 : rte_cpu_to_le_16(hw_coal->num_cmpl_dma_aggr_during_int);
5340 : :
5341 : 0 : req->int_lat_tmr_max = rte_cpu_to_le_16(hw_coal->int_lat_tmr_max);
5342 : :
5343 : : /* min timer set to 1/2 of interrupt timer */
5344 : 0 : req->int_lat_tmr_min = rte_cpu_to_le_16(hw_coal->int_lat_tmr_min);
5345 : :
5346 : : /* buf timer set to 1/4 of interrupt timer */
5347 : 0 : req->cmpl_aggr_dma_tmr = rte_cpu_to_le_16(hw_coal->cmpl_aggr_dma_tmr);
5348 : :
5349 : 0 : req->cmpl_aggr_dma_tmr_during_int =
5350 : 0 : rte_cpu_to_le_16(hw_coal->cmpl_aggr_dma_tmr_during_int);
5351 : :
5352 : : flags = HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_FLAGS_TIMER_RESET |
5353 : : HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_FLAGS_RING_IDLE;
5354 : 0 : req->flags = rte_cpu_to_le_16(flags);
5355 : 0 : }
5356 : :
5357 : 0 : static int bnxt_hwrm_set_coal_params_p5(struct bnxt *bp,
5358 : : struct hwrm_ring_cmpl_ring_cfg_aggint_params_input *agg_req)
5359 : : {
5360 : 0 : struct hwrm_ring_aggint_qcaps_input req = {0};
5361 : 0 : struct hwrm_ring_aggint_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
5362 : : uint32_t enables;
5363 : : uint16_t flags;
5364 : : int rc;
5365 : :
5366 [ # # ]: 0 : HWRM_PREP(&req, HWRM_RING_AGGINT_QCAPS, BNXT_USE_CHIMP_MB);
5367 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5368 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5369 : :
5370 : 0 : agg_req->num_cmpl_dma_aggr = resp->num_cmpl_dma_aggr_max;
5371 : 0 : agg_req->cmpl_aggr_dma_tmr = resp->cmpl_aggr_dma_tmr_min;
5372 : :
5373 : : flags = HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_FLAGS_TIMER_RESET |
5374 : : HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_FLAGS_RING_IDLE;
5375 : 0 : agg_req->flags = rte_cpu_to_le_16(flags);
5376 : : enables =
5377 : : HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_ENABLES_CMPL_AGGR_DMA_TMR |
5378 : : HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_ENABLES_NUM_CMPL_DMA_AGGR;
5379 : 0 : agg_req->enables = rte_cpu_to_le_32(enables);
5380 : :
5381 : : HWRM_UNLOCK();
5382 : 0 : return rc;
5383 : : }
5384 : :
5385 : 0 : int bnxt_hwrm_set_ring_coal(struct bnxt *bp,
5386 : : struct bnxt_coal *coal, uint16_t ring_id)
5387 : : {
5388 : 0 : struct hwrm_ring_cmpl_ring_cfg_aggint_params_input req = {0};
5389 : 0 : struct hwrm_ring_cmpl_ring_cfg_aggint_params_output *resp =
5390 : : bp->hwrm_cmd_resp_addr;
5391 : : int rc;
5392 : :
5393 : : /* Set ring coalesce parameters only for 100G NICs */
5394 [ # # ]: 0 : if (BNXT_CHIP_P5(bp)) {
5395 [ # # ]: 0 : if (bnxt_hwrm_set_coal_params_p5(bp, &req))
5396 : : return -1;
5397 [ # # ]: 0 : } else if (bnxt_stratus_device(bp)) {
5398 : : bnxt_hwrm_set_coal_params(coal, &req);
5399 : : } else {
5400 : : return 0;
5401 : : }
5402 : :
5403 [ # # ]: 0 : HWRM_PREP(&req,
5404 : : HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS,
5405 : : BNXT_USE_CHIMP_MB);
5406 : 0 : req.ring_id = rte_cpu_to_le_16(ring_id);
5407 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5408 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5409 : : HWRM_UNLOCK();
5410 : 0 : return 0;
5411 : : }
5412 : :
5413 : : #define BNXT_RTE_MEMZONE_FLAG (RTE_MEMZONE_1GB | RTE_MEMZONE_IOVA_CONTIG)
5414 : 0 : int bnxt_hwrm_func_backing_store_qcaps(struct bnxt *bp)
5415 : : {
5416 : 0 : struct hwrm_func_backing_store_qcaps_input req = {0};
5417 : 0 : struct hwrm_func_backing_store_qcaps_output *resp =
5418 : : bp->hwrm_cmd_resp_addr;
5419 : : struct bnxt_ctx_pg_info *ctx_pg;
5420 : : struct bnxt_ctx_mem_info *ctx;
5421 : : int total_alloc_len;
5422 : : int rc, i, tqm_rings;
5423 : :
5424 [ # # ]: 0 : if (!BNXT_CHIP_P5(bp) ||
5425 [ # # # # ]: 0 : bp->hwrm_spec_code < HWRM_VERSION_1_9_2 ||
5426 : 0 : BNXT_VF(bp) ||
5427 [ # # ]: 0 : bp->ctx)
5428 : : return 0;
5429 : :
5430 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_BACKING_STORE_QCAPS, BNXT_USE_CHIMP_MB);
5431 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5432 [ # # # # ]: 0 : HWRM_CHECK_RESULT_SILENT();
5433 : :
5434 : : total_alloc_len = sizeof(*ctx);
5435 : 0 : ctx = rte_zmalloc("bnxt_ctx_mem", total_alloc_len,
5436 : : RTE_CACHE_LINE_SIZE);
5437 [ # # ]: 0 : if (!ctx) {
5438 : : rc = -ENOMEM;
5439 : 0 : goto ctx_err;
5440 : : }
5441 : :
5442 : 0 : ctx->qp_max_entries = rte_le_to_cpu_32(resp->qp_max_entries);
5443 : 0 : ctx->qp_min_qp1_entries =
5444 : 0 : rte_le_to_cpu_16(resp->qp_min_qp1_entries);
5445 : 0 : ctx->qp_max_l2_entries =
5446 : 0 : rte_le_to_cpu_16(resp->qp_max_l2_entries);
5447 : 0 : ctx->qp_entry_size = rte_le_to_cpu_16(resp->qp_entry_size);
5448 : 0 : ctx->srq_max_l2_entries =
5449 : 0 : rte_le_to_cpu_16(resp->srq_max_l2_entries);
5450 : 0 : ctx->srq_max_entries = rte_le_to_cpu_32(resp->srq_max_entries);
5451 : 0 : ctx->srq_entry_size = rte_le_to_cpu_16(resp->srq_entry_size);
5452 : 0 : ctx->cq_max_l2_entries =
5453 : 0 : rte_le_to_cpu_16(resp->cq_max_l2_entries);
5454 : 0 : ctx->cq_max_entries = rte_le_to_cpu_32(resp->cq_max_entries);
5455 : 0 : ctx->cq_entry_size = rte_le_to_cpu_16(resp->cq_entry_size);
5456 : 0 : ctx->vnic_max_vnic_entries =
5457 : 0 : rte_le_to_cpu_16(resp->vnic_max_vnic_entries);
5458 : 0 : ctx->vnic_max_ring_table_entries =
5459 : 0 : rte_le_to_cpu_16(resp->vnic_max_ring_table_entries);
5460 : 0 : ctx->vnic_entry_size = rte_le_to_cpu_16(resp->vnic_entry_size);
5461 : 0 : ctx->stat_max_entries =
5462 : 0 : rte_le_to_cpu_32(resp->stat_max_entries);
5463 : 0 : ctx->stat_entry_size = rte_le_to_cpu_16(resp->stat_entry_size);
5464 : 0 : ctx->tqm_entry_size = rte_le_to_cpu_16(resp->tqm_entry_size);
5465 : 0 : ctx->tqm_min_entries_per_ring =
5466 : 0 : rte_le_to_cpu_32(resp->tqm_min_entries_per_ring);
5467 : 0 : ctx->tqm_max_entries_per_ring =
5468 : 0 : rte_le_to_cpu_32(resp->tqm_max_entries_per_ring);
5469 : 0 : ctx->tqm_entries_multiple = resp->tqm_entries_multiple;
5470 [ # # ]: 0 : if (!ctx->tqm_entries_multiple)
5471 : 0 : ctx->tqm_entries_multiple = 1;
5472 : 0 : ctx->mrav_max_entries =
5473 : 0 : rte_le_to_cpu_32(resp->mrav_max_entries);
5474 : 0 : ctx->mrav_entry_size = rte_le_to_cpu_16(resp->mrav_entry_size);
5475 : 0 : ctx->tim_entry_size = rte_le_to_cpu_16(resp->tim_entry_size);
5476 : 0 : ctx->tim_max_entries = rte_le_to_cpu_32(resp->tim_max_entries);
5477 : 0 : ctx->tqm_fp_rings_count = resp->tqm_fp_rings_count;
5478 : :
5479 [ # # ]: 0 : ctx->tqm_fp_rings_count = ctx->tqm_fp_rings_count ?
5480 : 0 : RTE_MIN(ctx->tqm_fp_rings_count,
5481 : : BNXT_MAX_TQM_FP_LEGACY_RINGS) :
5482 : : bp->max_q;
5483 : :
5484 : : /* Check if the ext ring count needs to be counted.
5485 : : * Ext ring count is available only with new FW so we should not
5486 : : * look at the field on older FW.
5487 : : */
5488 [ # # ]: 0 : if (ctx->tqm_fp_rings_count == BNXT_MAX_TQM_FP_LEGACY_RINGS &&
5489 [ # # ]: 0 : bp->hwrm_max_ext_req_len >= BNXT_BACKING_STORE_CFG_LEN) {
5490 : 0 : ctx->tqm_fp_rings_count += resp->tqm_fp_rings_count_ext;
5491 : 0 : ctx->tqm_fp_rings_count = RTE_MIN(BNXT_MAX_TQM_FP_RINGS,
5492 : : ctx->tqm_fp_rings_count);
5493 : : }
5494 : :
5495 : 0 : tqm_rings = ctx->tqm_fp_rings_count + 1;
5496 : :
5497 : 0 : ctx_pg = rte_malloc("bnxt_ctx_pg_mem",
5498 : : sizeof(*ctx_pg) * tqm_rings,
5499 : : RTE_CACHE_LINE_SIZE);
5500 [ # # ]: 0 : if (!ctx_pg) {
5501 : : rc = -ENOMEM;
5502 : 0 : goto ctx_err;
5503 : : }
5504 [ # # ]: 0 : for (i = 0; i < tqm_rings; i++, ctx_pg++)
5505 : 0 : ctx->tqm_mem[i] = ctx_pg;
5506 : :
5507 : 0 : bp->ctx = ctx;
5508 : 0 : ctx_err:
5509 : : HWRM_UNLOCK();
5510 : 0 : return rc;
5511 : : }
5512 : :
5513 : 0 : int bnxt_hwrm_func_backing_store_cfg(struct bnxt *bp, uint32_t enables)
5514 : : {
5515 : 0 : struct hwrm_func_backing_store_cfg_input req = {0};
5516 : 0 : struct hwrm_func_backing_store_cfg_output *resp =
5517 : : bp->hwrm_cmd_resp_addr;
5518 : 0 : struct bnxt_ctx_mem_info *ctx = bp->ctx;
5519 : : struct bnxt_ctx_pg_info *ctx_pg;
5520 : : uint32_t *num_entries;
5521 : : uint64_t *pg_dir;
5522 : : uint8_t *pg_attr;
5523 : : uint32_t ena;
5524 : : int i, rc;
5525 : :
5526 [ # # ]: 0 : if (!ctx)
5527 : : return 0;
5528 : :
5529 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_BACKING_STORE_CFG, BNXT_USE_CHIMP_MB);
5530 : 0 : req.enables = rte_cpu_to_le_32(enables);
5531 : :
5532 [ # # ]: 0 : if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_QP) {
5533 : : ctx_pg = &ctx->qp_mem;
5534 : 0 : req.qp_num_entries = rte_cpu_to_le_32(ctx_pg->entries);
5535 : 0 : req.qp_num_qp1_entries =
5536 : 0 : rte_cpu_to_le_16(ctx->qp_min_qp1_entries);
5537 : 0 : req.qp_num_l2_entries =
5538 : 0 : rte_cpu_to_le_16(ctx->qp_max_l2_entries);
5539 [ # # ]: 0 : req.qp_entry_size = rte_cpu_to_le_16(ctx->qp_entry_size);
5540 : : bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem,
5541 : : &req.qpc_pg_size_qpc_lvl,
5542 : : &req.qpc_page_dir);
5543 : : }
5544 : :
5545 [ # # ]: 0 : if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_SRQ) {
5546 : : ctx_pg = &ctx->srq_mem;
5547 : 0 : req.srq_num_entries = rte_cpu_to_le_32(ctx_pg->entries);
5548 : 0 : req.srq_num_l2_entries =
5549 : 0 : rte_cpu_to_le_16(ctx->srq_max_l2_entries);
5550 [ # # ]: 0 : req.srq_entry_size = rte_cpu_to_le_16(ctx->srq_entry_size);
5551 : : bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem,
5552 : : &req.srq_pg_size_srq_lvl,
5553 : : &req.srq_page_dir);
5554 : : }
5555 : :
5556 [ # # ]: 0 : if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_CQ) {
5557 : : ctx_pg = &ctx->cq_mem;
5558 : 0 : req.cq_num_entries = rte_cpu_to_le_32(ctx_pg->entries);
5559 : 0 : req.cq_num_l2_entries =
5560 : 0 : rte_cpu_to_le_16(ctx->cq_max_l2_entries);
5561 [ # # ]: 0 : req.cq_entry_size = rte_cpu_to_le_16(ctx->cq_entry_size);
5562 : : bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem,
5563 : : &req.cq_pg_size_cq_lvl,
5564 : : &req.cq_page_dir);
5565 : : }
5566 : :
5567 [ # # ]: 0 : if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_VNIC) {
5568 : : ctx_pg = &ctx->vnic_mem;
5569 : 0 : req.vnic_num_vnic_entries =
5570 : 0 : rte_cpu_to_le_16(ctx->vnic_max_vnic_entries);
5571 : 0 : req.vnic_num_ring_table_entries =
5572 : 0 : rte_cpu_to_le_16(ctx->vnic_max_ring_table_entries);
5573 [ # # ]: 0 : req.vnic_entry_size = rte_cpu_to_le_16(ctx->vnic_entry_size);
5574 : : bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem,
5575 : : &req.vnic_pg_size_vnic_lvl,
5576 : : &req.vnic_page_dir);
5577 : : }
5578 : :
5579 [ # # ]: 0 : if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_STAT) {
5580 : : ctx_pg = &ctx->stat_mem;
5581 : 0 : req.stat_num_entries = rte_cpu_to_le_16(ctx->stat_max_entries);
5582 [ # # ]: 0 : req.stat_entry_size = rte_cpu_to_le_16(ctx->stat_entry_size);
5583 : : bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem,
5584 : : &req.stat_pg_size_stat_lvl,
5585 : : &req.stat_page_dir);
5586 : : }
5587 : :
5588 : 0 : req.tqm_entry_size = rte_cpu_to_le_16(ctx->tqm_entry_size);
5589 : : num_entries = &req.tqm_sp_num_entries;
5590 : : pg_attr = &req.tqm_sp_pg_size_tqm_sp_lvl;
5591 : : pg_dir = &req.tqm_sp_page_dir;
5592 : : ena = HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_SP;
5593 [ # # ]: 0 : for (i = 0; i < 9; i++, num_entries++, pg_attr++, pg_dir++, ena <<= 1) {
5594 [ # # ]: 0 : if (!(enables & ena))
5595 : 0 : continue;
5596 : :
5597 : 0 : req.tqm_entry_size = rte_cpu_to_le_16(ctx->tqm_entry_size);
5598 : :
5599 : 0 : ctx_pg = ctx->tqm_mem[i];
5600 [ # # ]: 0 : *num_entries = rte_cpu_to_le_16(ctx_pg->entries);
5601 : : bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, pg_attr, pg_dir);
5602 : : }
5603 : :
5604 [ # # ]: 0 : if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_RING8) {
5605 : : /* DPDK does not need to configure MRAV and TIM type.
5606 : : * So we are skipping over MRAV and TIM. Skip to configure
5607 : : * HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_RING8.
5608 : : */
5609 : 0 : ctx_pg = ctx->tqm_mem[BNXT_MAX_TQM_LEGACY_RINGS];
5610 [ # # ]: 0 : req.tqm_ring8_num_entries = rte_cpu_to_le_16(ctx_pg->entries);
5611 : : bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem,
5612 : : &req.tqm_ring8_pg_size_tqm_ring_lvl,
5613 : : &req.tqm_ring8_page_dir);
5614 : : }
5615 : :
5616 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5617 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5618 : : HWRM_UNLOCK();
5619 : :
5620 : 0 : return rc;
5621 : : }
5622 : :
5623 : 0 : int bnxt_hwrm_ext_port_qstats(struct bnxt *bp)
5624 : : {
5625 : 0 : struct hwrm_port_qstats_ext_input req = {0};
5626 : 0 : struct hwrm_port_qstats_ext_output *resp = bp->hwrm_cmd_resp_addr;
5627 : 0 : struct bnxt_pf_info *pf = bp->pf;
5628 : : int rc;
5629 : :
5630 [ # # ]: 0 : if (!(bp->flags & BNXT_FLAG_EXT_RX_PORT_STATS ||
5631 : : bp->flags & BNXT_FLAG_EXT_TX_PORT_STATS))
5632 : : return 0;
5633 : :
5634 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_PORT_QSTATS_EXT, BNXT_USE_CHIMP_MB);
5635 : :
5636 : 0 : req.port_id = rte_cpu_to_le_16(pf->port_id);
5637 [ # # ]: 0 : if (bp->flags & BNXT_FLAG_EXT_TX_PORT_STATS) {
5638 : 0 : req.tx_stat_host_addr =
5639 : 0 : rte_cpu_to_le_64(bp->hw_tx_port_stats_ext_map);
5640 : 0 : req.tx_stat_size =
5641 : : rte_cpu_to_le_16(sizeof(struct tx_port_stats_ext));
5642 : : }
5643 [ # # ]: 0 : if (bp->flags & BNXT_FLAG_EXT_RX_PORT_STATS) {
5644 : 0 : req.rx_stat_host_addr =
5645 : 0 : rte_cpu_to_le_64(bp->hw_rx_port_stats_ext_map);
5646 : 0 : req.rx_stat_size =
5647 : : rte_cpu_to_le_16(sizeof(struct rx_port_stats_ext));
5648 : : }
5649 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5650 : :
5651 [ # # ]: 0 : if (rc) {
5652 : 0 : bp->fw_rx_port_stats_ext_size = 0;
5653 : 0 : bp->fw_tx_port_stats_ext_size = 0;
5654 : : } else {
5655 : 0 : bp->fw_rx_port_stats_ext_size =
5656 : 0 : rte_le_to_cpu_16(resp->rx_stat_size);
5657 : 0 : bp->fw_tx_port_stats_ext_size =
5658 : 0 : rte_le_to_cpu_16(resp->tx_stat_size);
5659 : : }
5660 : :
5661 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5662 : : HWRM_UNLOCK();
5663 : :
5664 : 0 : return rc;
5665 : : }
5666 : :
5667 : : int
5668 : 0 : bnxt_hwrm_tunnel_redirect(struct bnxt *bp, uint8_t type)
5669 : : {
5670 : 0 : struct hwrm_cfa_redirect_tunnel_type_alloc_input req = {0};
5671 : 0 : struct hwrm_cfa_redirect_tunnel_type_alloc_output *resp =
5672 : : bp->hwrm_cmd_resp_addr;
5673 : : int rc = 0;
5674 : :
5675 [ # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC, BNXT_USE_CHIMP_MB);
5676 : 0 : req.tunnel_type = type;
5677 : 0 : req.dest_fid = bp->fw_fid;
5678 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5679 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5680 : :
5681 : : HWRM_UNLOCK();
5682 : :
5683 : 0 : return rc;
5684 : : }
5685 : :
5686 : : int
5687 : 0 : bnxt_hwrm_tunnel_redirect_free(struct bnxt *bp, uint8_t type)
5688 : : {
5689 : 0 : struct hwrm_cfa_redirect_tunnel_type_free_input req = {0};
5690 : 0 : struct hwrm_cfa_redirect_tunnel_type_free_output *resp =
5691 : : bp->hwrm_cmd_resp_addr;
5692 : : int rc = 0;
5693 : :
5694 [ # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE, BNXT_USE_CHIMP_MB);
5695 : 0 : req.tunnel_type = type;
5696 : 0 : req.dest_fid = bp->fw_fid;
5697 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5698 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5699 : :
5700 : : HWRM_UNLOCK();
5701 : :
5702 : 0 : return rc;
5703 : : }
5704 : :
5705 : 0 : int bnxt_hwrm_tunnel_redirect_query(struct bnxt *bp, uint32_t *type)
5706 : : {
5707 : 0 : struct hwrm_cfa_redirect_query_tunnel_type_input req = {0};
5708 : 0 : struct hwrm_cfa_redirect_query_tunnel_type_output *resp =
5709 : : bp->hwrm_cmd_resp_addr;
5710 : : int rc = 0;
5711 : :
5712 [ # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_REDIRECT_QUERY_TUNNEL_TYPE, BNXT_USE_CHIMP_MB);
5713 : 0 : req.src_fid = bp->fw_fid;
5714 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5715 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5716 : :
5717 [ # # ]: 0 : if (type)
5718 : 0 : *type = rte_le_to_cpu_32(resp->tunnel_mask);
5719 : :
5720 : : HWRM_UNLOCK();
5721 : :
5722 : 0 : return rc;
5723 : : }
5724 : :
5725 : 0 : int bnxt_hwrm_tunnel_redirect_info(struct bnxt *bp, uint8_t tun_type,
5726 : : uint16_t *dst_fid)
5727 : : {
5728 : 0 : struct hwrm_cfa_redirect_tunnel_type_info_input req = {0};
5729 : 0 : struct hwrm_cfa_redirect_tunnel_type_info_output *resp =
5730 : : bp->hwrm_cmd_resp_addr;
5731 : : int rc = 0;
5732 : :
5733 [ # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO, BNXT_USE_CHIMP_MB);
5734 : 0 : req.src_fid = bp->fw_fid;
5735 : 0 : req.tunnel_type = tun_type;
5736 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5737 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5738 : :
5739 [ # # ]: 0 : if (dst_fid)
5740 : 0 : *dst_fid = rte_le_to_cpu_16(resp->dest_fid);
5741 : :
5742 : 0 : PMD_DRV_LOG(DEBUG, "dst_fid: %x\n", resp->dest_fid);
5743 : :
5744 : : HWRM_UNLOCK();
5745 : :
5746 : 0 : return rc;
5747 : : }
5748 : :
5749 : 0 : int bnxt_hwrm_set_mac(struct bnxt *bp)
5750 : : {
5751 : 0 : struct hwrm_func_vf_cfg_output *resp = bp->hwrm_cmd_resp_addr;
5752 : 0 : struct hwrm_func_vf_cfg_input req = {0};
5753 : : int rc = 0;
5754 : :
5755 [ # # ]: 0 : if (!BNXT_VF(bp))
5756 : : return 0;
5757 : :
5758 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_VF_CFG, BNXT_USE_CHIMP_MB);
5759 : :
5760 : 0 : req.enables =
5761 : : rte_cpu_to_le_32(HWRM_FUNC_VF_CFG_INPUT_ENABLES_DFLT_MAC_ADDR);
5762 : : memcpy(req.dflt_mac_addr, bp->mac_addr, RTE_ETHER_ADDR_LEN);
5763 : :
5764 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5765 : :
5766 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5767 : :
5768 : : HWRM_UNLOCK();
5769 : :
5770 : 0 : return rc;
5771 : : }
5772 : :
5773 : 0 : int bnxt_hwrm_if_change(struct bnxt *bp, bool up)
5774 : : {
5775 : 0 : struct hwrm_func_drv_if_change_output *resp = bp->hwrm_cmd_resp_addr;
5776 : 0 : struct hwrm_func_drv_if_change_input req = {0};
5777 : : uint32_t flags;
5778 : : int rc;
5779 : :
5780 [ # # ]: 0 : if (!(bp->fw_cap & BNXT_FW_CAP_IF_CHANGE))
5781 : : return 0;
5782 : :
5783 : : /* Do not issue FUNC_DRV_IF_CHANGE during reset recovery.
5784 : : * If we issue FUNC_DRV_IF_CHANGE with flags down before
5785 : : * FUNC_DRV_UNRGTR, FW resets before FUNC_DRV_UNRGTR
5786 : : */
5787 [ # # # # ]: 0 : if (!up && (bp->flags & BNXT_FLAG_FW_RESET))
5788 : : return 0;
5789 : :
5790 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_DRV_IF_CHANGE, BNXT_USE_CHIMP_MB);
5791 : :
5792 [ # # ]: 0 : if (up)
5793 : 0 : req.flags =
5794 : : rte_cpu_to_le_32(HWRM_FUNC_DRV_IF_CHANGE_INPUT_FLAGS_UP);
5795 : :
5796 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5797 : :
5798 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5799 : 0 : flags = rte_le_to_cpu_32(resp->flags);
5800 : : HWRM_UNLOCK();
5801 : :
5802 [ # # ]: 0 : if (!up)
5803 : : return 0;
5804 : :
5805 [ # # ]: 0 : if (flags & HWRM_FUNC_DRV_IF_CHANGE_OUTPUT_FLAGS_HOT_FW_RESET_DONE) {
5806 : 0 : PMD_DRV_LOG(INFO, "FW reset happened while port was down\n");
5807 : 0 : bp->flags |= BNXT_FLAG_IF_CHANGE_HOT_FW_RESET_DONE;
5808 : : }
5809 : :
5810 : : return 0;
5811 : : }
5812 : :
5813 : 0 : int bnxt_hwrm_error_recovery_qcfg(struct bnxt *bp)
5814 : : {
5815 : 0 : struct hwrm_error_recovery_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
5816 : 0 : struct bnxt_error_recovery_info *info = bp->recovery_info;
5817 : 0 : struct hwrm_error_recovery_qcfg_input req = {0};
5818 : : uint32_t flags = 0;
5819 : : unsigned int i;
5820 : : int rc;
5821 : :
5822 : : /* Older FW does not have error recovery support */
5823 [ # # ]: 0 : if (!(bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY))
5824 : : return 0;
5825 : :
5826 [ # # ]: 0 : HWRM_PREP(&req, HWRM_ERROR_RECOVERY_QCFG, BNXT_USE_CHIMP_MB);
5827 : :
5828 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5829 : :
5830 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5831 : :
5832 : 0 : flags = rte_le_to_cpu_32(resp->flags);
5833 [ # # ]: 0 : if (flags & HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FLAGS_HOST)
5834 : 0 : info->flags |= BNXT_FLAG_ERROR_RECOVERY_HOST;
5835 [ # # ]: 0 : else if (flags & HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FLAGS_CO_CPU)
5836 : 0 : info->flags |= BNXT_FLAG_ERROR_RECOVERY_CO_CPU;
5837 : :
5838 [ # # ]: 0 : if ((info->flags & BNXT_FLAG_ERROR_RECOVERY_CO_CPU) &&
5839 [ # # ]: 0 : !(bp->flags & BNXT_FLAG_KONG_MB_EN)) {
5840 : : rc = -EINVAL;
5841 : 0 : goto err;
5842 : : }
5843 : :
5844 : : /* FW returned values are in units of 100msec */
5845 : 0 : info->driver_polling_freq =
5846 : 0 : rte_le_to_cpu_32(resp->driver_polling_freq) * 100;
5847 : 0 : info->primary_func_wait_period =
5848 : 0 : rte_le_to_cpu_32(resp->master_func_wait_period) * 100;
5849 : 0 : info->normal_func_wait_period =
5850 : 0 : rte_le_to_cpu_32(resp->normal_func_wait_period) * 100;
5851 : 0 : info->primary_func_wait_period_after_reset =
5852 : 0 : rte_le_to_cpu_32(resp->master_func_wait_period_after_reset) * 100;
5853 : 0 : info->max_bailout_time_after_reset =
5854 : 0 : rte_le_to_cpu_32(resp->max_bailout_time_after_reset) * 100;
5855 : 0 : info->status_regs[BNXT_FW_STATUS_REG] =
5856 : 0 : rte_le_to_cpu_32(resp->fw_health_status_reg);
5857 : 0 : info->status_regs[BNXT_FW_HEARTBEAT_CNT_REG] =
5858 : 0 : rte_le_to_cpu_32(resp->fw_heartbeat_reg);
5859 : 0 : info->status_regs[BNXT_FW_RECOVERY_CNT_REG] =
5860 : 0 : rte_le_to_cpu_32(resp->fw_reset_cnt_reg);
5861 : 0 : info->status_regs[BNXT_FW_RESET_INPROG_REG] =
5862 : 0 : rte_le_to_cpu_32(resp->reset_inprogress_reg);
5863 : 0 : info->reg_array_cnt =
5864 : 0 : rte_le_to_cpu_32(resp->reg_array_cnt);
5865 : :
5866 [ # # ]: 0 : if (info->reg_array_cnt >= BNXT_NUM_RESET_REG) {
5867 : : rc = -EINVAL;
5868 : 0 : goto err;
5869 : : }
5870 : :
5871 [ # # ]: 0 : for (i = 0; i < info->reg_array_cnt; i++) {
5872 : 0 : info->reset_reg[i] =
5873 : 0 : rte_le_to_cpu_32(resp->reset_reg[i]);
5874 : 0 : info->reset_reg_val[i] =
5875 : 0 : rte_le_to_cpu_32(resp->reset_reg_val[i]);
5876 : 0 : info->delay_after_reset[i] =
5877 : 0 : resp->delay_after_reset[i];
5878 : : }
5879 : 0 : err:
5880 : : HWRM_UNLOCK();
5881 : :
5882 : : /* Map the FW status registers */
5883 [ # # ]: 0 : if (!rc)
5884 : 0 : rc = bnxt_map_fw_health_status_regs(bp);
5885 : :
5886 [ # # ]: 0 : if (rc) {
5887 : 0 : rte_free(bp->recovery_info);
5888 : 0 : bp->recovery_info = NULL;
5889 : : }
5890 : : return rc;
5891 : : }
5892 : :
5893 : 0 : int bnxt_hwrm_fw_reset(struct bnxt *bp)
5894 : : {
5895 : 0 : struct hwrm_fw_reset_output *resp = bp->hwrm_cmd_resp_addr;
5896 : 0 : struct hwrm_fw_reset_input req = {0};
5897 : : int rc;
5898 : :
5899 [ # # ]: 0 : if (!BNXT_PF(bp))
5900 : : return -EOPNOTSUPP;
5901 : :
5902 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_FW_RESET, BNXT_USE_KONG(bp));
5903 : :
5904 : 0 : req.embedded_proc_type =
5905 : : HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_CHIP;
5906 : 0 : req.selfrst_status =
5907 : : HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTASAP;
5908 : 0 : req.flags = HWRM_FW_RESET_INPUT_FLAGS_RESET_GRACEFUL;
5909 : :
5910 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req),
5911 : : BNXT_USE_KONG(bp));
5912 : :
5913 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5914 : : HWRM_UNLOCK();
5915 : :
5916 : 0 : return rc;
5917 : : }
5918 : :
5919 : 0 : int bnxt_hwrm_port_ts_query(struct bnxt *bp, uint8_t path, uint64_t *timestamp)
5920 : : {
5921 : 0 : struct hwrm_port_ts_query_output *resp = bp->hwrm_cmd_resp_addr;
5922 : 0 : struct hwrm_port_ts_query_input req = {0};
5923 : 0 : struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
5924 : : uint32_t flags = 0;
5925 : : int rc;
5926 : :
5927 [ # # ]: 0 : if (!ptp)
5928 : : return 0;
5929 : :
5930 [ # # # # : 0 : HWRM_PREP(&req, HWRM_PORT_TS_QUERY, BNXT_USE_CHIMP_MB);
# ]
5931 : :
5932 [ # # # ]: 0 : switch (path) {
5933 : : case BNXT_PTP_FLAGS_PATH_TX:
5934 : : flags |= HWRM_PORT_TS_QUERY_INPUT_FLAGS_PATH_TX;
5935 : : break;
5936 : 0 : case BNXT_PTP_FLAGS_PATH_RX:
5937 : : flags |= HWRM_PORT_TS_QUERY_INPUT_FLAGS_PATH_RX;
5938 : 0 : break;
5939 : 0 : case BNXT_PTP_FLAGS_CURRENT_TIME:
5940 : : flags |= HWRM_PORT_TS_QUERY_INPUT_FLAGS_CURRENT_TIME;
5941 : 0 : break;
5942 : : }
5943 : :
5944 : 0 : req.flags = rte_cpu_to_le_32(flags);
5945 : 0 : req.port_id = rte_cpu_to_le_16(bp->pf->port_id);
5946 : :
5947 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5948 : :
5949 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5950 : :
5951 [ # # ]: 0 : if (timestamp) {
5952 : 0 : *timestamp = rte_le_to_cpu_32(resp->ptp_msg_ts[0]);
5953 : 0 : *timestamp |=
5954 : 0 : (uint64_t)(rte_le_to_cpu_32(resp->ptp_msg_ts[1])) << 32;
5955 : : }
5956 : : HWRM_UNLOCK();
5957 : :
5958 : 0 : return rc;
5959 : : }
5960 : :
5961 : 0 : int bnxt_hwrm_cfa_counter_qcaps(struct bnxt *bp, uint16_t *max_fc)
5962 : : {
5963 : : int rc = 0;
5964 : :
5965 : 0 : struct hwrm_cfa_counter_qcaps_input req = {0};
5966 : 0 : struct hwrm_cfa_counter_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
5967 : :
5968 [ # # ]: 0 : if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) {
5969 : 0 : PMD_DRV_LOG(DEBUG,
5970 : : "Not a PF or trusted VF. Command not supported\n");
5971 : 0 : return 0;
5972 : : }
5973 : :
5974 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_COUNTER_QCAPS, BNXT_USE_KONG(bp));
5975 : 0 : req.target_id = rte_cpu_to_le_16(bp->fw_fid);
5976 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_KONG(bp));
5977 : :
5978 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
5979 [ # # ]: 0 : if (max_fc)
5980 : 0 : *max_fc = rte_le_to_cpu_16(resp->max_rx_fc);
5981 : : HWRM_UNLOCK();
5982 : :
5983 : 0 : return 0;
5984 : : }
5985 : :
5986 : 0 : int bnxt_hwrm_ctx_rgtr(struct bnxt *bp, rte_iova_t dma_addr, uint16_t *ctx_id)
5987 : : {
5988 : : int rc = 0;
5989 : 0 : struct hwrm_cfa_ctx_mem_rgtr_input req = {.req_type = 0 };
5990 : 0 : struct hwrm_cfa_ctx_mem_rgtr_output *resp = bp->hwrm_cmd_resp_addr;
5991 : :
5992 [ # # ]: 0 : if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) {
5993 : 0 : PMD_DRV_LOG(DEBUG,
5994 : : "Not a PF or trusted VF. Command not supported\n");
5995 : 0 : return 0;
5996 : : }
5997 : :
5998 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_CTX_MEM_RGTR, BNXT_USE_KONG(bp));
5999 : :
6000 : 0 : req.page_level = HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_LEVEL_LVL_0;
6001 : 0 : req.page_size = HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_SIZE_2M;
6002 : 0 : req.page_dir = rte_cpu_to_le_64(dma_addr);
6003 : :
6004 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_KONG(bp));
6005 : :
6006 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
6007 [ # # ]: 0 : if (ctx_id) {
6008 : 0 : *ctx_id = rte_le_to_cpu_16(resp->ctx_id);
6009 : 0 : PMD_DRV_LOG(DEBUG, "ctx_id = %d\n", *ctx_id);
6010 : : }
6011 : : HWRM_UNLOCK();
6012 : :
6013 : 0 : return 0;
6014 : : }
6015 : :
6016 : 0 : int bnxt_hwrm_ctx_unrgtr(struct bnxt *bp, uint16_t ctx_id)
6017 : : {
6018 : : int rc = 0;
6019 : 0 : struct hwrm_cfa_ctx_mem_unrgtr_input req = {.req_type = 0 };
6020 : 0 : struct hwrm_cfa_ctx_mem_unrgtr_output *resp = bp->hwrm_cmd_resp_addr;
6021 : :
6022 [ # # ]: 0 : if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) {
6023 : 0 : PMD_DRV_LOG(DEBUG,
6024 : : "Not a PF or trusted VF. Command not supported\n");
6025 : 0 : return 0;
6026 : : }
6027 : :
6028 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_CTX_MEM_UNRGTR, BNXT_USE_KONG(bp));
6029 : :
6030 : 0 : req.ctx_id = rte_cpu_to_le_16(ctx_id);
6031 : :
6032 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_KONG(bp));
6033 : :
6034 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
6035 : : HWRM_UNLOCK();
6036 : :
6037 : 0 : return rc;
6038 : : }
6039 : :
6040 : 0 : int bnxt_hwrm_cfa_counter_cfg(struct bnxt *bp, enum bnxt_flow_dir dir,
6041 : : uint16_t cntr, uint16_t ctx_id,
6042 : : uint32_t num_entries, bool enable)
6043 : : {
6044 : 0 : struct hwrm_cfa_counter_cfg_input req = {0};
6045 : 0 : struct hwrm_cfa_counter_cfg_output *resp = bp->hwrm_cmd_resp_addr;
6046 : : uint16_t flags = 0;
6047 : : int rc;
6048 : :
6049 [ # # ]: 0 : if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) {
6050 : 0 : PMD_DRV_LOG(DEBUG,
6051 : : "Not a PF or trusted VF. Command not supported\n");
6052 : 0 : return 0;
6053 : : }
6054 : :
6055 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_COUNTER_CFG, BNXT_USE_KONG(bp));
6056 : :
6057 : 0 : req.target_id = rte_cpu_to_le_16(bp->fw_fid);
6058 : 0 : req.counter_type = rte_cpu_to_le_16(cntr);
6059 [ # # ]: 0 : flags = enable ? HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_CFG_MODE_ENABLE :
6060 : : HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_CFG_MODE_DISABLE;
6061 : 0 : flags |= HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_DATA_TRANSFER_MODE_PULL;
6062 [ # # ]: 0 : if (dir == BNXT_DIR_RX)
6063 : 0 : flags |= HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_PATH_RX;
6064 : : else if (dir == BNXT_DIR_TX)
6065 : : flags |= HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_PATH_TX;
6066 : 0 : req.flags = rte_cpu_to_le_16(flags);
6067 : 0 : req.ctx_id = rte_cpu_to_le_16(ctx_id);
6068 : 0 : req.num_entries = rte_cpu_to_le_32(num_entries);
6069 : :
6070 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_KONG(bp));
6071 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
6072 : : HWRM_UNLOCK();
6073 : :
6074 : 0 : return 0;
6075 : : }
6076 : :
6077 : 0 : int bnxt_hwrm_cfa_counter_qstats(struct bnxt *bp,
6078 : : enum bnxt_flow_dir dir,
6079 : : uint16_t cntr,
6080 : : uint16_t num_entries)
6081 : : {
6082 : 0 : struct hwrm_cfa_counter_qstats_output *resp = bp->hwrm_cmd_resp_addr;
6083 : 0 : struct hwrm_cfa_counter_qstats_input req = {0};
6084 : : uint16_t flow_ctx_id = 0;
6085 : : uint16_t flags = 0;
6086 : : int rc = 0;
6087 : :
6088 [ # # ]: 0 : if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) {
6089 : 0 : PMD_DRV_LOG(DEBUG,
6090 : : "Not a PF or trusted VF. Command not supported\n");
6091 : 0 : return 0;
6092 : : }
6093 : :
6094 [ # # ]: 0 : if (dir == BNXT_DIR_RX) {
6095 : 0 : flow_ctx_id = bp->flow_stat->rx_fc_in_tbl.ctx_id;
6096 : : flags = HWRM_CFA_COUNTER_QSTATS_INPUT_FLAGS_PATH_RX;
6097 [ # # ]: 0 : } else if (dir == BNXT_DIR_TX) {
6098 : 0 : flow_ctx_id = bp->flow_stat->tx_fc_in_tbl.ctx_id;
6099 : : flags = HWRM_CFA_COUNTER_QSTATS_INPUT_FLAGS_PATH_TX;
6100 : : }
6101 : :
6102 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_COUNTER_QSTATS, BNXT_USE_KONG(bp));
6103 : 0 : req.target_id = rte_cpu_to_le_16(bp->fw_fid);
6104 : 0 : req.counter_type = rte_cpu_to_le_16(cntr);
6105 : 0 : req.input_flow_ctx_id = rte_cpu_to_le_16(flow_ctx_id);
6106 : 0 : req.num_entries = rte_cpu_to_le_16(num_entries);
6107 : 0 : req.flags = rte_cpu_to_le_16(flags);
6108 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_KONG(bp));
6109 : :
6110 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
6111 : : HWRM_UNLOCK();
6112 : :
6113 : 0 : return 0;
6114 : : }
6115 : :
6116 : 0 : int bnxt_hwrm_first_vf_id_query(struct bnxt *bp, uint16_t fid,
6117 : : uint16_t *first_vf_id)
6118 : : {
6119 : : int rc = 0;
6120 : 0 : struct hwrm_func_qcaps_input req = {.req_type = 0 };
6121 : 0 : struct hwrm_func_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
6122 : :
6123 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_QCAPS, BNXT_USE_CHIMP_MB);
6124 : :
6125 : 0 : req.fid = rte_cpu_to_le_16(fid);
6126 : :
6127 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
6128 : :
6129 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
6130 : :
6131 [ # # ]: 0 : if (first_vf_id)
6132 : 0 : *first_vf_id = rte_le_to_cpu_16(resp->first_vf_id);
6133 : :
6134 : : HWRM_UNLOCK();
6135 : :
6136 : 0 : return rc;
6137 : : }
6138 : :
6139 : 0 : int bnxt_hwrm_cfa_pair_exists(struct bnxt *bp, struct bnxt_representor *rep_bp)
6140 : : {
6141 : 0 : struct hwrm_cfa_pair_info_output *resp = bp->hwrm_cmd_resp_addr;
6142 : 0 : struct hwrm_cfa_pair_info_input req = {0};
6143 : : int rc = 0;
6144 : :
6145 [ # # ]: 0 : if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) {
6146 : 0 : PMD_DRV_LOG(DEBUG,
6147 : : "Not a PF or trusted VF. Command not supported\n");
6148 : 0 : return 0;
6149 : : }
6150 : :
6151 [ # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_PAIR_INFO, BNXT_USE_CHIMP_MB);
6152 : 0 : snprintf(req.pair_name, sizeof(req.pair_name), "%svfr%d",
6153 : 0 : bp->eth_dev->data->name, rep_bp->vf_id);
6154 : 0 : req.flags =
6155 : : rte_cpu_to_le_32(HWRM_CFA_PAIR_INFO_INPUT_FLAGS_LOOKUP_TYPE);
6156 : :
6157 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
6158 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
6159 [ # # ]: 0 : if (rc == HWRM_ERR_CODE_SUCCESS && strlen(resp->pair_name)) {
6160 : : HWRM_UNLOCK();
6161 : 0 : return !rc;
6162 : : }
6163 : : HWRM_UNLOCK();
6164 : 0 : return rc;
6165 : : }
6166 : :
6167 : 0 : int bnxt_hwrm_cfa_pair_alloc(struct bnxt *bp, struct bnxt_representor *rep_bp)
6168 : : {
6169 : 0 : struct hwrm_cfa_pair_alloc_output *resp = bp->hwrm_cmd_resp_addr;
6170 : 0 : struct hwrm_cfa_pair_alloc_input req = {0};
6171 : : int rc;
6172 : :
6173 [ # # ]: 0 : if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) {
6174 : 0 : PMD_DRV_LOG(DEBUG,
6175 : : "Not a PF or trusted VF. Command not supported\n");
6176 : 0 : return 0;
6177 : : }
6178 : :
6179 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_PAIR_ALLOC, BNXT_USE_CHIMP_MB);
6180 : 0 : req.pair_mode = HWRM_CFA_PAIR_FREE_INPUT_PAIR_MODE_REP2FN_TRUFLOW;
6181 : 0 : snprintf(req.pair_name, sizeof(req.pair_name), "%svfr%d",
6182 [ # # ]: 0 : bp->eth_dev->data->name, rep_bp->vf_id);
6183 : :
6184 : 0 : req.pf_b_id = rep_bp->parent_pf_idx;
6185 [ # # ]: 0 : req.vf_b_id = BNXT_REP_PF(rep_bp) ? rte_cpu_to_le_16(((uint16_t)-1)) :
6186 : : rte_cpu_to_le_16(rep_bp->vf_id);
6187 : 0 : req.vf_a_id = rte_cpu_to_le_16(bp->fw_fid);
6188 : 0 : req.host_b_id = 1; /* TBD - Confirm if this is OK */
6189 : :
6190 : 0 : req.enables |= rep_bp->flags & BNXT_REP_Q_R2F_VALID ?
6191 : 0 : HWRM_CFA_PAIR_ALLOC_INPUT_ENABLES_Q_AB_VALID : 0;
6192 : 0 : req.enables |= rep_bp->flags & BNXT_REP_Q_F2R_VALID ?
6193 : 0 : HWRM_CFA_PAIR_ALLOC_INPUT_ENABLES_Q_BA_VALID : 0;
6194 : 0 : req.enables |= rep_bp->flags & BNXT_REP_FC_R2F_VALID ?
6195 : 0 : HWRM_CFA_PAIR_ALLOC_INPUT_ENABLES_FC_AB_VALID : 0;
6196 : 0 : req.enables |= rep_bp->flags & BNXT_REP_FC_F2R_VALID ?
6197 : 0 : HWRM_CFA_PAIR_ALLOC_INPUT_ENABLES_FC_BA_VALID : 0;
6198 : :
6199 : 0 : req.q_ab = rep_bp->rep_q_r2f;
6200 : 0 : req.q_ba = rep_bp->rep_q_f2r;
6201 : 0 : req.fc_ab = rep_bp->rep_fc_r2f;
6202 : 0 : req.fc_ba = rep_bp->rep_fc_f2r;
6203 : :
6204 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
6205 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
6206 : :
6207 : : HWRM_UNLOCK();
6208 [ # # ]: 0 : PMD_DRV_LOG(DEBUG, "%s %d allocated\n",
6209 : : BNXT_REP_PF(rep_bp) ? "PFR" : "VFR", rep_bp->vf_id);
6210 : 0 : return rc;
6211 : : }
6212 : :
6213 : 0 : int bnxt_hwrm_cfa_pair_free(struct bnxt *bp, struct bnxt_representor *rep_bp)
6214 : : {
6215 : 0 : struct hwrm_cfa_pair_free_output *resp = bp->hwrm_cmd_resp_addr;
6216 : 0 : struct hwrm_cfa_pair_free_input req = {0};
6217 : : int rc;
6218 : :
6219 [ # # ]: 0 : if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) {
6220 : 0 : PMD_DRV_LOG(DEBUG,
6221 : : "Not a PF or trusted VF. Command not supported\n");
6222 : 0 : return 0;
6223 : : }
6224 : :
6225 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_CFA_PAIR_FREE, BNXT_USE_CHIMP_MB);
6226 : 0 : snprintf(req.pair_name, sizeof(req.pair_name), "%svfr%d",
6227 [ # # ]: 0 : bp->eth_dev->data->name, rep_bp->vf_id);
6228 : 0 : req.pf_b_id = rep_bp->parent_pf_idx;
6229 : 0 : req.pair_mode = HWRM_CFA_PAIR_FREE_INPUT_PAIR_MODE_REP2FN_TRUFLOW;
6230 [ # # ]: 0 : req.vf_id = BNXT_REP_PF(rep_bp) ? rte_cpu_to_le_16(((uint16_t)-1)) :
6231 : : rte_cpu_to_le_16(rep_bp->vf_id);
6232 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
6233 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
6234 : : HWRM_UNLOCK();
6235 [ # # ]: 0 : PMD_DRV_LOG(DEBUG, "%s %d freed\n", BNXT_REP_PF(rep_bp) ? "PFR" : "VFR",
6236 : : rep_bp->vf_id);
6237 : 0 : return rc;
6238 : : }
6239 : :
6240 : 0 : int bnxt_hwrm_fw_echo_reply(struct bnxt *bp, uint32_t echo_req_data1,
6241 : : uint32_t echo_req_data2)
6242 : : {
6243 : 0 : struct hwrm_func_echo_response_input req = {0};
6244 : 0 : struct hwrm_func_echo_response_output *resp = bp->hwrm_cmd_resp_addr;
6245 : : int rc;
6246 : :
6247 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_ECHO_RESPONSE, BNXT_USE_CHIMP_MB);
6248 : 0 : req.event_data1 = rte_cpu_to_le_32(echo_req_data1);
6249 : 0 : req.event_data2 = rte_cpu_to_le_32(echo_req_data2);
6250 : :
6251 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
6252 : :
6253 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
6254 : : HWRM_UNLOCK();
6255 : :
6256 : 0 : return rc;
6257 : : }
6258 : :
6259 : 0 : int bnxt_hwrm_poll_ver_get(struct bnxt *bp)
6260 : : {
6261 : 0 : struct hwrm_ver_get_input req = {.req_type = 0 };
6262 : 0 : struct hwrm_ver_get_output *resp = bp->hwrm_cmd_resp_addr;
6263 : : int rc = 0;
6264 : :
6265 : 0 : bp->max_req_len = HWRM_MAX_REQ_LEN;
6266 : 0 : bp->max_resp_len = BNXT_PAGE_SIZE;
6267 : 0 : bp->hwrm_cmd_timeout = SHORT_HWRM_CMD_TIMEOUT;
6268 : :
6269 [ # # ]: 0 : HWRM_PREP(&req, HWRM_VER_GET, BNXT_USE_CHIMP_MB);
6270 : 0 : req.hwrm_intf_maj = HWRM_VERSION_MAJOR;
6271 : 0 : req.hwrm_intf_min = HWRM_VERSION_MINOR;
6272 : 0 : req.hwrm_intf_upd = HWRM_VERSION_UPDATE;
6273 : :
6274 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
6275 : :
6276 [ # # # # ]: 0 : HWRM_CHECK_RESULT_SILENT();
6277 : : HWRM_UNLOCK();
6278 : :
6279 : 0 : return rc;
6280 : : }
6281 : :
6282 : 0 : int bnxt_hwrm_read_sfp_module_eeprom_info(struct bnxt *bp, uint16_t i2c_addr,
6283 : : uint16_t page_number, uint16_t start_addr,
6284 : : uint16_t data_length, uint8_t *buf)
6285 : : {
6286 : 0 : struct hwrm_port_phy_i2c_read_output *resp = bp->hwrm_cmd_resp_addr;
6287 : 0 : struct hwrm_port_phy_i2c_read_input req = {0};
6288 : : uint32_t enables = HWRM_PORT_PHY_I2C_READ_INPUT_ENABLES_PAGE_OFFSET;
6289 : : int rc, byte_offset = 0;
6290 : :
6291 : : do {
6292 : : uint16_t xfer_size;
6293 : :
6294 [ # # # # ]: 0 : HWRM_PREP(&req, HWRM_PORT_PHY_I2C_READ, BNXT_USE_CHIMP_MB);
6295 : 0 : req.i2c_slave_addr = i2c_addr;
6296 : 0 : req.page_number = rte_cpu_to_le_16(page_number);
6297 : 0 : req.port_id = rte_cpu_to_le_16(bp->pf->port_id);
6298 : :
6299 : 0 : xfer_size = RTE_MIN(data_length, BNXT_MAX_PHY_I2C_RESP_SIZE);
6300 : 0 : req.page_offset = rte_cpu_to_le_16(start_addr + byte_offset);
6301 : 0 : req.data_length = xfer_size;
6302 [ # # ]: 0 : req.enables = rte_cpu_to_le_32(start_addr + byte_offset ? enables : 0);
6303 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
6304 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
6305 : :
6306 : 0 : memcpy(buf + byte_offset, resp->data, xfer_size);
6307 : :
6308 : 0 : data_length -= xfer_size;
6309 : 0 : byte_offset += xfer_size;
6310 : :
6311 : : HWRM_UNLOCK();
6312 [ # # ]: 0 : } while (data_length > 0);
6313 : :
6314 : : return rc;
6315 : : }
6316 : :
6317 : 0 : void bnxt_free_hwrm_tx_ring(struct bnxt *bp, int queue_index)
6318 : : {
6319 : 0 : struct bnxt_tx_queue *txq = bp->tx_queues[queue_index];
6320 : 0 : struct bnxt_tx_ring_info *txr = txq->tx_ring;
6321 : 0 : struct bnxt_ring *ring = txr->tx_ring_struct;
6322 : 0 : struct bnxt_cp_ring_info *cpr = txq->cp_ring;
6323 : :
6324 : 0 : bnxt_hwrm_ring_free(bp, ring,
6325 : : HWRM_RING_FREE_INPUT_RING_TYPE_TX,
6326 : 0 : cpr->cp_ring_struct->fw_ring_id);
6327 : 0 : txr->tx_raw_prod = 0;
6328 : 0 : txr->tx_raw_cons = 0;
6329 : 0 : memset(txr->tx_desc_ring, 0,
6330 : 0 : txr->tx_ring_struct->ring_size * sizeof(*txr->tx_desc_ring));
6331 : 0 : memset(txr->tx_buf_ring, 0,
6332 : 0 : txr->tx_ring_struct->ring_size * sizeof(*txr->tx_buf_ring));
6333 : :
6334 : 0 : bnxt_hwrm_stat_ctx_free(bp, cpr);
6335 : :
6336 : 0 : bnxt_free_cp_ring(bp, cpr);
6337 : 0 : }
6338 : :
6339 : 0 : int bnxt_hwrm_config_host_mtu(struct bnxt *bp)
6340 : : {
6341 : 0 : struct hwrm_func_cfg_input req = {0};
6342 : 0 : struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
6343 : : int rc;
6344 : :
6345 [ # # ]: 0 : if (!BNXT_PF(bp))
6346 : : return 0;
6347 : :
6348 [ # # ]: 0 : HWRM_PREP(&req, HWRM_FUNC_CFG, BNXT_USE_CHIMP_MB);
6349 : :
6350 : 0 : req.fid = rte_cpu_to_le_16(0xffff);
6351 : 0 : req.enables = rte_cpu_to_le_32(HWRM_FUNC_CFG_INPUT_ENABLES_HOST_MTU);
6352 : 0 : req.host_mtu = rte_cpu_to_le_16(bp->eth_dev->data->mtu);
6353 : :
6354 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
6355 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
6356 : : HWRM_UNLOCK();
6357 : :
6358 : 0 : return rc;
6359 : : }
6360 : :
6361 : : int
6362 : 0 : bnxt_vnic_rss_clear_p5(struct bnxt *bp, struct bnxt_vnic_info *vnic)
6363 : : {
6364 : 0 : struct hwrm_vnic_rss_cfg_output *resp = bp->hwrm_cmd_resp_addr;
6365 : 0 : struct hwrm_vnic_rss_cfg_input req = {0};
6366 : 0 : int nr_ctxs = vnic->num_lb_ctxts;
6367 : : int i, rc = 0;
6368 : :
6369 [ # # ]: 0 : for (i = 0; i < nr_ctxs; i++) {
6370 [ # # ]: 0 : HWRM_PREP(&req, HWRM_VNIC_RSS_CFG, BNXT_USE_CHIMP_MB);
6371 : :
6372 : 0 : req.rss_ctx_idx = rte_cpu_to_le_16(vnic->fw_grp_ids[i]);
6373 : 0 : req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
6374 : :
6375 : 0 : rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
6376 : :
6377 [ # # # # : 0 : HWRM_CHECK_RESULT();
# # # # #
# # # ]
6378 : : HWRM_UNLOCK();
6379 : : }
6380 : :
6381 : : return rc;
6382 : : }
|