1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2014-2018 Broadcom
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>
17 #include "bnxt_filter.h"
18 #include "bnxt_hwrm.h"
21 #include "bnxt_ring.h"
24 #include "bnxt_vnic.h"
25 #include "hsi_struct_def_dpdk.h"
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
31 struct bnxt_plcmodes_cfg {
33 uint16_t jumbo_thresh;
35 uint16_t hds_threshold;
38 static int page_getenum(size_t size)
54 PMD_DRV_LOG(ERR, "Page size %zu out of range\n", size);
55 return sizeof(int) * 8 - 1;
58 static int page_roundup(size_t size)
60 return 1 << page_getenum(size);
63 static void bnxt_hwrm_set_pg_attr(struct bnxt_ring_mem_info *rmem,
67 if (rmem->nr_pages > 1) {
69 *pg_dir = rte_cpu_to_le_64(rmem->pg_tbl_map);
71 *pg_dir = rte_cpu_to_le_64(rmem->dma_arr[0]);
76 * HWRM Functions (sent to HWRM)
77 * These are named bnxt_hwrm_*() and return 0 on success or -110 if the
78 * HWRM command times out, or a negative error code if the HWRM
79 * command was failed by the FW.
82 static int bnxt_hwrm_send_message(struct bnxt *bp, void *msg,
83 uint32_t msg_len, bool use_kong_mb)
86 struct input *req = msg;
87 struct output *resp = bp->hwrm_cmd_resp_addr;
91 uint16_t max_req_len = bp->max_req_len;
92 struct hwrm_short_input short_input = { 0 };
93 uint16_t bar_offset = use_kong_mb ?
94 GRCPF_REG_KONG_CHANNEL_OFFSET : GRCPF_REG_CHIMP_CHANNEL_OFFSET;
95 uint16_t mb_trigger_offset = use_kong_mb ?
96 GRCPF_REG_KONG_COMM_TRIGGER : GRCPF_REG_CHIMP_COMM_TRIGGER;
99 /* Do not send HWRM commands to firmware in error state */
100 if (bp->flags & BNXT_FLAG_FATAL_ERROR)
103 timeout = bp->hwrm_cmd_timeout;
105 if (bp->flags & BNXT_FLAG_SHORT_CMD ||
106 msg_len > bp->max_req_len) {
107 void *short_cmd_req = bp->hwrm_short_cmd_req_addr;
109 memset(short_cmd_req, 0, bp->hwrm_max_ext_req_len);
110 memcpy(short_cmd_req, req, msg_len);
112 short_input.req_type = rte_cpu_to_le_16(req->req_type);
113 short_input.signature = rte_cpu_to_le_16(
114 HWRM_SHORT_INPUT_SIGNATURE_SHORT_CMD);
115 short_input.size = rte_cpu_to_le_16(msg_len);
116 short_input.req_addr =
117 rte_cpu_to_le_64(bp->hwrm_short_cmd_req_dma_addr);
119 data = (uint32_t *)&short_input;
120 msg_len = sizeof(short_input);
122 max_req_len = BNXT_HWRM_SHORT_REQ_LEN;
125 /* Write request msg to hwrm channel */
126 for (i = 0; i < msg_len; i += 4) {
127 bar = (uint8_t *)bp->bar0 + bar_offset + i;
128 rte_write32(*data, bar);
132 /* Zero the rest of the request space */
133 for (; i < max_req_len; i += 4) {
134 bar = (uint8_t *)bp->bar0 + bar_offset + i;
138 /* Ring channel doorbell */
139 bar = (uint8_t *)bp->bar0 + mb_trigger_offset;
142 * Make sure the channel doorbell ring command complete before
143 * reading the response to avoid getting stale or invalid
148 /* Poll for the valid bit */
149 for (i = 0; i < timeout; i++) {
150 /* Sanity check on the resp->resp_len */
152 if (resp->resp_len && resp->resp_len <= bp->max_resp_len) {
153 /* Last byte of resp contains the valid key */
154 valid = (uint8_t *)resp + resp->resp_len - 1;
155 if (*valid == HWRM_RESP_VALID_KEY)
162 /* Suppress VER_GET timeout messages during reset recovery */
163 if (bp->flags & BNXT_FLAG_FW_RESET &&
164 rte_cpu_to_le_16(req->req_type) == HWRM_VER_GET)
168 "Error(timeout) sending msg 0x%04x, seq_id %d\n",
169 req->req_type, req->seq_id);
176 * HWRM_PREP() should be used to prepare *ALL* HWRM commands. It grabs the
177 * spinlock, and does initial processing.
179 * HWRM_CHECK_RESULT() returns errors on failure and may not be used. It
180 * releases the spinlock only if it returns. If the regular int return codes
181 * are not used by the function, HWRM_CHECK_RESULT() should not be used
182 * directly, rather it should be copied and modified to suit the function.
184 * HWRM_UNLOCK() must be called after all response processing is completed.
186 #define HWRM_PREP(req, type, kong) do { \
187 rte_spinlock_lock(&bp->hwrm_lock); \
188 if (bp->hwrm_cmd_resp_addr == NULL) { \
189 rte_spinlock_unlock(&bp->hwrm_lock); \
192 memset(bp->hwrm_cmd_resp_addr, 0, bp->max_resp_len); \
193 (req)->req_type = rte_cpu_to_le_16(type); \
194 (req)->cmpl_ring = rte_cpu_to_le_16(-1); \
195 (req)->seq_id = kong ? rte_cpu_to_le_16(bp->kong_cmd_seq++) :\
196 rte_cpu_to_le_16(bp->chimp_cmd_seq++); \
197 (req)->target_id = rte_cpu_to_le_16(0xffff); \
198 (req)->resp_addr = rte_cpu_to_le_64(bp->hwrm_cmd_resp_dma_addr); \
201 #define HWRM_CHECK_RESULT_SILENT() do {\
203 rte_spinlock_unlock(&bp->hwrm_lock); \
206 if (resp->error_code) { \
207 rc = rte_le_to_cpu_16(resp->error_code); \
208 rte_spinlock_unlock(&bp->hwrm_lock); \
213 #define HWRM_CHECK_RESULT() do {\
215 PMD_DRV_LOG(ERR, "failed rc:%d\n", rc); \
216 rte_spinlock_unlock(&bp->hwrm_lock); \
217 if (rc == HWRM_ERR_CODE_RESOURCE_ACCESS_DENIED) \
219 else if (rc == HWRM_ERR_CODE_RESOURCE_ALLOC_ERROR) \
221 else if (rc == HWRM_ERR_CODE_INVALID_PARAMS) \
223 else if (rc == HWRM_ERR_CODE_CMD_NOT_SUPPORTED) \
225 else if (rc == HWRM_ERR_CODE_HOT_RESET_PROGRESS) \
231 if (resp->error_code) { \
232 rc = rte_le_to_cpu_16(resp->error_code); \
233 if (resp->resp_len >= 16) { \
234 struct hwrm_err_output *tmp_hwrm_err_op = \
237 "error %d:%d:%08x:%04x\n", \
238 rc, tmp_hwrm_err_op->cmd_err, \
240 tmp_hwrm_err_op->opaque_0), \
242 tmp_hwrm_err_op->opaque_1)); \
244 PMD_DRV_LOG(ERR, "error %d\n", rc); \
246 rte_spinlock_unlock(&bp->hwrm_lock); \
247 if (rc == HWRM_ERR_CODE_RESOURCE_ACCESS_DENIED) \
249 else if (rc == HWRM_ERR_CODE_RESOURCE_ALLOC_ERROR) \
251 else if (rc == HWRM_ERR_CODE_INVALID_PARAMS) \
253 else if (rc == HWRM_ERR_CODE_CMD_NOT_SUPPORTED) \
255 else if (rc == HWRM_ERR_CODE_HOT_RESET_PROGRESS) \
263 #define HWRM_UNLOCK() rte_spinlock_unlock(&bp->hwrm_lock)
265 int bnxt_hwrm_tf_message_direct(struct bnxt *bp,
274 bool mailbox = BNXT_USE_CHIMP_MB;
275 struct input *req = msg;
276 struct output *resp = bp->hwrm_cmd_resp_addr;
279 mailbox = BNXT_USE_KONG(bp);
281 HWRM_PREP(req, msg_type, mailbox);
283 rc = bnxt_hwrm_send_message(bp, req, msg_len, mailbox);
288 memcpy(resp_msg, resp, resp_len);
295 int bnxt_hwrm_tf_message_tunneled(struct bnxt *bp,
299 uint32_t *tf_response_code,
303 uint32_t response_len)
306 struct hwrm_cfa_tflib_input req = { .req_type = 0 };
307 struct hwrm_cfa_tflib_output *resp = bp->hwrm_cmd_resp_addr;
308 bool mailbox = BNXT_USE_CHIMP_MB;
310 if (msg_len > sizeof(req.tf_req))
314 mailbox = BNXT_USE_KONG(bp);
316 HWRM_PREP(&req, HWRM_TF, mailbox);
317 /* Build request using the user supplied request payload.
318 * TLV request size is checked at build time against HWRM
319 * request max size, thus no checking required.
321 req.tf_type = tf_type;
322 req.tf_subtype = tf_subtype;
323 memcpy(req.tf_req, msg, msg_len);
325 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), mailbox);
328 /* Copy the resp to user provided response buffer */
329 if (response != NULL)
330 /* Post process response data. We need to copy only
331 * the 'payload' as the HWRM data structure really is
332 * HWRM header + msg header + payload and the TFLIB
333 * only provided a payload place holder.
335 if (response_len != 0) {
341 /* Extract the internal tflib response code */
342 *tf_response_code = resp->tf_resp_code;
348 int bnxt_hwrm_cfa_l2_clear_rx_mask(struct bnxt *bp, struct bnxt_vnic_info *vnic)
351 struct hwrm_cfa_l2_set_rx_mask_input req = {.req_type = 0 };
352 struct hwrm_cfa_l2_set_rx_mask_output *resp = bp->hwrm_cmd_resp_addr;
354 HWRM_PREP(&req, HWRM_CFA_L2_SET_RX_MASK, BNXT_USE_CHIMP_MB);
355 req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
358 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
366 int bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt *bp,
367 struct bnxt_vnic_info *vnic,
369 struct bnxt_vlan_table_entry *vlan_table)
372 struct hwrm_cfa_l2_set_rx_mask_input req = {.req_type = 0 };
373 struct hwrm_cfa_l2_set_rx_mask_output *resp = bp->hwrm_cmd_resp_addr;
376 if (vnic->fw_vnic_id == INVALID_HW_RING_ID)
379 HWRM_PREP(&req, HWRM_CFA_L2_SET_RX_MASK, BNXT_USE_CHIMP_MB);
380 req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
382 if (vnic->flags & BNXT_VNIC_INFO_BCAST)
383 mask |= HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_BCAST;
384 if (vnic->flags & BNXT_VNIC_INFO_UNTAGGED)
385 mask |= HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_VLAN_NONVLAN;
387 if (vnic->flags & BNXT_VNIC_INFO_PROMISC)
388 mask |= HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_PROMISCUOUS;
390 if (vnic->flags & BNXT_VNIC_INFO_ALLMULTI) {
391 mask |= HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ALL_MCAST;
392 } else if (vnic->flags & BNXT_VNIC_INFO_MCAST) {
393 mask |= HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_MCAST;
394 req.num_mc_entries = rte_cpu_to_le_32(vnic->mc_addr_cnt);
395 req.mc_tbl_addr = rte_cpu_to_le_64(vnic->mc_list_dma_addr);
398 if (!(mask & HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_VLAN_NONVLAN))
399 mask |= HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_VLANONLY;
400 req.vlan_tag_tbl_addr =
401 rte_cpu_to_le_64(rte_malloc_virt2iova(vlan_table));
402 req.num_vlan_tags = rte_cpu_to_le_32((uint32_t)vlan_count);
404 req.mask = rte_cpu_to_le_32(mask);
406 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
414 int bnxt_hwrm_cfa_vlan_antispoof_cfg(struct bnxt *bp, uint16_t fid,
416 struct bnxt_vlan_antispoof_table_entry *vlan_table)
419 struct hwrm_cfa_vlan_antispoof_cfg_input req = {.req_type = 0 };
420 struct hwrm_cfa_vlan_antispoof_cfg_output *resp =
421 bp->hwrm_cmd_resp_addr;
424 * Older HWRM versions did not support this command, and the set_rx_mask
425 * list was used for anti-spoof. In 1.8.0, the TX path configuration was
426 * removed from set_rx_mask call, and this command was added.
428 * This command is also present from 1.7.8.11 and higher,
431 if (bp->fw_ver < ((1 << 24) | (8 << 16))) {
432 if (bp->fw_ver != ((1 << 24) | (7 << 16) | (8 << 8))) {
433 if (bp->fw_ver < ((1 << 24) | (7 << 16) | (8 << 8) |
438 HWRM_PREP(&req, HWRM_CFA_VLAN_ANTISPOOF_CFG, BNXT_USE_CHIMP_MB);
439 req.fid = rte_cpu_to_le_16(fid);
441 req.vlan_tag_mask_tbl_addr =
442 rte_cpu_to_le_64(rte_malloc_virt2iova(vlan_table));
443 req.num_vlan_entries = rte_cpu_to_le_32((uint32_t)vlan_count);
445 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
453 int bnxt_hwrm_clear_l2_filter(struct bnxt *bp,
454 struct bnxt_filter_info *filter)
457 struct bnxt_filter_info *l2_filter = filter;
458 struct bnxt_vnic_info *vnic = NULL;
459 struct hwrm_cfa_l2_filter_free_input req = {.req_type = 0 };
460 struct hwrm_cfa_l2_filter_free_output *resp = bp->hwrm_cmd_resp_addr;
462 if (filter->fw_l2_filter_id == UINT64_MAX)
465 if (filter->matching_l2_fltr_ptr)
466 l2_filter = filter->matching_l2_fltr_ptr;
468 PMD_DRV_LOG(DEBUG, "filter: %p l2_filter: %p ref_cnt: %d\n",
469 filter, l2_filter, l2_filter->l2_ref_cnt);
471 if (l2_filter->l2_ref_cnt == 0)
474 if (l2_filter->l2_ref_cnt > 0)
475 l2_filter->l2_ref_cnt--;
477 if (l2_filter->l2_ref_cnt > 0)
480 HWRM_PREP(&req, HWRM_CFA_L2_FILTER_FREE, BNXT_USE_CHIMP_MB);
482 req.l2_filter_id = rte_cpu_to_le_64(filter->fw_l2_filter_id);
484 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
489 filter->fw_l2_filter_id = UINT64_MAX;
490 if (l2_filter->l2_ref_cnt == 0) {
491 vnic = l2_filter->vnic;
493 STAILQ_REMOVE(&vnic->filter, l2_filter,
494 bnxt_filter_info, next);
495 bnxt_free_filter(bp, l2_filter);
502 int bnxt_hwrm_set_l2_filter(struct bnxt *bp,
504 struct bnxt_filter_info *filter)
507 struct hwrm_cfa_l2_filter_alloc_input req = {.req_type = 0 };
508 struct hwrm_cfa_l2_filter_alloc_output *resp = bp->hwrm_cmd_resp_addr;
509 struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf;
510 const struct rte_eth_vmdq_rx_conf *conf =
511 &dev_conf->rx_adv_conf.vmdq_rx_conf;
512 uint32_t enables = 0;
513 uint16_t j = dst_id - 1;
515 //TODO: Is there a better way to add VLANs to each VNIC in case of VMDQ
516 if ((dev_conf->rxmode.mq_mode & ETH_MQ_RX_VMDQ_FLAG) &&
517 conf->pool_map[j].pools & (1UL << j)) {
519 "Add vlan %u to vmdq pool %u\n",
520 conf->pool_map[j].vlan_id, j);
522 filter->l2_ivlan = conf->pool_map[j].vlan_id;
524 HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_IVLAN |
525 HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_IVLAN_MASK;
528 if (filter->fw_l2_filter_id != UINT64_MAX)
529 bnxt_hwrm_clear_l2_filter(bp, filter);
531 HWRM_PREP(&req, HWRM_CFA_L2_FILTER_ALLOC, BNXT_USE_CHIMP_MB);
533 /* PMD does not support XDP and RoCE */
534 filter->flags |= HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_XDP_DISABLE |
535 HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_TRAFFIC_L2;
536 req.flags = rte_cpu_to_le_32(filter->flags);
538 enables = filter->enables |
539 HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_DST_ID;
540 req.dst_id = rte_cpu_to_le_16(dst_id);
543 HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR)
544 memcpy(req.l2_addr, filter->l2_addr,
547 HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR_MASK)
548 memcpy(req.l2_addr_mask, filter->l2_addr_mask,
551 HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_OVLAN)
552 req.l2_ovlan = filter->l2_ovlan;
554 HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_IVLAN)
555 req.l2_ivlan = filter->l2_ivlan;
557 HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_OVLAN_MASK)
558 req.l2_ovlan_mask = filter->l2_ovlan_mask;
560 HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_IVLAN_MASK)
561 req.l2_ivlan_mask = filter->l2_ivlan_mask;
562 if (enables & HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_SRC_ID)
563 req.src_id = rte_cpu_to_le_32(filter->src_id);
564 if (enables & HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_SRC_TYPE)
565 req.src_type = filter->src_type;
566 if (filter->pri_hint) {
567 req.pri_hint = filter->pri_hint;
568 req.l2_filter_id_hint =
569 rte_cpu_to_le_64(filter->l2_filter_id_hint);
572 req.enables = rte_cpu_to_le_32(enables);
574 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
578 filter->fw_l2_filter_id = rte_le_to_cpu_64(resp->l2_filter_id);
579 filter->flow_id = rte_le_to_cpu_32(resp->flow_id);
582 filter->l2_ref_cnt++;
587 int bnxt_hwrm_ptp_cfg(struct bnxt *bp)
589 struct hwrm_port_mac_cfg_input req = {.req_type = 0};
590 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
597 HWRM_PREP(&req, HWRM_PORT_MAC_CFG, BNXT_USE_CHIMP_MB);
600 flags |= HWRM_PORT_MAC_CFG_INPUT_FLAGS_PTP_RX_TS_CAPTURE_ENABLE;
603 HWRM_PORT_MAC_CFG_INPUT_FLAGS_PTP_RX_TS_CAPTURE_DISABLE;
604 if (ptp->tx_tstamp_en)
605 flags |= HWRM_PORT_MAC_CFG_INPUT_FLAGS_PTP_TX_TS_CAPTURE_ENABLE;
608 HWRM_PORT_MAC_CFG_INPUT_FLAGS_PTP_TX_TS_CAPTURE_DISABLE;
609 req.flags = rte_cpu_to_le_32(flags);
610 req.enables = rte_cpu_to_le_32
611 (HWRM_PORT_MAC_CFG_INPUT_ENABLES_RX_TS_CAPTURE_PTP_MSG_TYPE);
612 req.rx_ts_capture_ptp_msg_type = rte_cpu_to_le_16(ptp->rxctl);
614 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
620 static int bnxt_hwrm_ptp_qcfg(struct bnxt *bp)
623 struct hwrm_port_mac_ptp_qcfg_input req = {.req_type = 0};
624 struct hwrm_port_mac_ptp_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
625 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
630 HWRM_PREP(&req, HWRM_PORT_MAC_PTP_QCFG, BNXT_USE_CHIMP_MB);
632 req.port_id = rte_cpu_to_le_16(bp->pf->port_id);
634 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
638 if (!BNXT_CHIP_P5(bp) &&
639 !(resp->flags & HWRM_PORT_MAC_PTP_QCFG_OUTPUT_FLAGS_DIRECT_ACCESS))
642 if (resp->flags & HWRM_PORT_MAC_PTP_QCFG_OUTPUT_FLAGS_ONE_STEP_TX_TS)
643 bp->flags |= BNXT_FLAG_FW_CAP_ONE_STEP_TX_TS;
645 ptp = rte_zmalloc("ptp_cfg", sizeof(*ptp), 0);
649 if (!BNXT_CHIP_P5(bp)) {
650 ptp->rx_regs[BNXT_PTP_RX_TS_L] =
651 rte_le_to_cpu_32(resp->rx_ts_reg_off_lower);
652 ptp->rx_regs[BNXT_PTP_RX_TS_H] =
653 rte_le_to_cpu_32(resp->rx_ts_reg_off_upper);
654 ptp->rx_regs[BNXT_PTP_RX_SEQ] =
655 rte_le_to_cpu_32(resp->rx_ts_reg_off_seq_id);
656 ptp->rx_regs[BNXT_PTP_RX_FIFO] =
657 rte_le_to_cpu_32(resp->rx_ts_reg_off_fifo);
658 ptp->rx_regs[BNXT_PTP_RX_FIFO_ADV] =
659 rte_le_to_cpu_32(resp->rx_ts_reg_off_fifo_adv);
660 ptp->tx_regs[BNXT_PTP_TX_TS_L] =
661 rte_le_to_cpu_32(resp->tx_ts_reg_off_lower);
662 ptp->tx_regs[BNXT_PTP_TX_TS_H] =
663 rte_le_to_cpu_32(resp->tx_ts_reg_off_upper);
664 ptp->tx_regs[BNXT_PTP_TX_SEQ] =
665 rte_le_to_cpu_32(resp->tx_ts_reg_off_seq_id);
666 ptp->tx_regs[BNXT_PTP_TX_FIFO] =
667 rte_le_to_cpu_32(resp->tx_ts_reg_off_fifo);
676 void bnxt_hwrm_free_vf_info(struct bnxt *bp)
680 for (i = 0; i < bp->pf->max_vfs; i++) {
681 rte_free(bp->pf->vf_info[i].vlan_table);
682 bp->pf->vf_info[i].vlan_table = NULL;
683 rte_free(bp->pf->vf_info[i].vlan_as_table);
684 bp->pf->vf_info[i].vlan_as_table = NULL;
686 rte_free(bp->pf->vf_info);
687 bp->pf->vf_info = NULL;
690 static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
693 struct hwrm_func_qcaps_input req = {.req_type = 0 };
694 struct hwrm_func_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
695 uint16_t new_max_vfs;
699 HWRM_PREP(&req, HWRM_FUNC_QCAPS, BNXT_USE_CHIMP_MB);
701 req.fid = rte_cpu_to_le_16(0xffff);
703 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
707 bp->max_ring_grps = rte_le_to_cpu_32(resp->max_hw_ring_grps);
708 flags = rte_le_to_cpu_32(resp->flags);
710 bp->pf->port_id = resp->port_id;
711 bp->pf->first_vf_id = rte_le_to_cpu_16(resp->first_vf_id);
712 bp->pf->total_vfs = rte_le_to_cpu_16(resp->max_vfs);
713 new_max_vfs = bp->pdev->max_vfs;
714 if (new_max_vfs != bp->pf->max_vfs) {
716 bnxt_hwrm_free_vf_info(bp);
717 bp->pf->vf_info = rte_zmalloc("bnxt_vf_info",
718 sizeof(bp->pf->vf_info[0]) * new_max_vfs, 0);
719 if (bp->pf->vf_info == NULL) {
720 PMD_DRV_LOG(ERR, "Alloc vf info fail\n");
724 bp->pf->max_vfs = new_max_vfs;
725 for (i = 0; i < new_max_vfs; i++) {
726 bp->pf->vf_info[i].fid =
727 bp->pf->first_vf_id + i;
728 bp->pf->vf_info[i].vlan_table =
729 rte_zmalloc("VF VLAN table",
732 if (bp->pf->vf_info[i].vlan_table == NULL)
734 "Fail to alloc VLAN table for VF %d\n",
738 bp->pf->vf_info[i].vlan_table);
739 bp->pf->vf_info[i].vlan_as_table =
740 rte_zmalloc("VF VLAN AS table",
743 if (bp->pf->vf_info[i].vlan_as_table == NULL)
745 "Alloc VLAN AS table for VF %d fail\n",
749 bp->pf->vf_info[i].vlan_as_table);
750 STAILQ_INIT(&bp->pf->vf_info[i].filter);
755 bp->fw_fid = rte_le_to_cpu_32(resp->fid);
756 if (!bnxt_check_zero_bytes(resp->mac_address, RTE_ETHER_ADDR_LEN)) {
757 bp->flags |= BNXT_FLAG_DFLT_MAC_SET;
758 memcpy(bp->mac_addr, &resp->mac_address, RTE_ETHER_ADDR_LEN);
760 bp->flags &= ~BNXT_FLAG_DFLT_MAC_SET;
762 bp->max_rsscos_ctx = rte_le_to_cpu_16(resp->max_rsscos_ctx);
763 bp->max_cp_rings = rte_le_to_cpu_16(resp->max_cmpl_rings);
764 bp->max_tx_rings = rte_le_to_cpu_16(resp->max_tx_rings);
765 bp->max_rx_rings = rte_le_to_cpu_16(resp->max_rx_rings);
766 bp->first_vf_id = rte_le_to_cpu_16(resp->first_vf_id);
767 bp->max_rx_em_flows = rte_le_to_cpu_16(resp->max_rx_em_flows);
768 bp->max_l2_ctx = rte_le_to_cpu_16(resp->max_l2_ctxs);
769 if (!BNXT_CHIP_P5(bp) && !bp->pdev->max_vfs)
770 bp->max_l2_ctx += bp->max_rx_em_flows;
771 /* TODO: For now, do not support VMDq/RFS on VFs. */
776 bp->max_vnics = rte_le_to_cpu_16(resp->max_vnics);
780 PMD_DRV_LOG(DEBUG, "Max l2_cntxts is %d vnics is %d\n",
781 bp->max_l2_ctx, bp->max_vnics);
782 bp->max_stat_ctx = rte_le_to_cpu_16(resp->max_stat_ctx);
784 bp->pf->total_vnics = rte_le_to_cpu_16(resp->max_vnics);
785 if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_PTP_SUPPORTED) {
786 bp->flags |= BNXT_FLAG_PTP_SUPPORTED;
787 PMD_DRV_LOG(DEBUG, "PTP SUPPORTED\n");
789 bnxt_hwrm_ptp_qcfg(bp);
793 if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_STATS_SUPPORTED)
794 bp->flags |= BNXT_FLAG_EXT_STATS_SUPPORTED;
796 if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ERROR_RECOVERY_CAPABLE) {
797 bp->fw_cap |= BNXT_FW_CAP_ERROR_RECOVERY;
798 PMD_DRV_LOG(DEBUG, "Adapter Error recovery SUPPORTED\n");
801 if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ERR_RECOVER_RELOAD)
802 bp->fw_cap |= BNXT_FW_CAP_ERR_RECOVER_RELOAD;
804 if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_HOT_RESET_CAPABLE)
805 bp->fw_cap |= BNXT_FW_CAP_HOT_RESET;
807 if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_LINK_ADMIN_STATUS_SUPPORTED)
808 bp->fw_cap |= BNXT_FW_CAP_LINK_ADMIN;
815 int bnxt_hwrm_func_qcaps(struct bnxt *bp)
819 rc = __bnxt_hwrm_func_qcaps(bp);
820 if (!rc && bp->hwrm_spec_code >= HWRM_SPEC_CODE_1_8_3) {
821 rc = bnxt_alloc_ctx_mem(bp);
826 * bnxt_hwrm_func_resc_qcaps can fail and cause init failure.
827 * But the error can be ignored. Return success.
829 rc = bnxt_hwrm_func_resc_qcaps(bp);
831 bp->flags |= BNXT_FLAG_NEW_RM;
837 /* VNIC cap covers capability of all VNICs. So no need to pass vnic_id */
838 int bnxt_hwrm_vnic_qcaps(struct bnxt *bp)
842 struct hwrm_vnic_qcaps_input req = {.req_type = 0 };
843 struct hwrm_vnic_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
845 HWRM_PREP(&req, HWRM_VNIC_QCAPS, BNXT_USE_CHIMP_MB);
847 req.target_id = rte_cpu_to_le_16(0xffff);
849 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
853 flags = rte_le_to_cpu_32(resp->flags);
855 if (flags & HWRM_VNIC_QCAPS_OUTPUT_FLAGS_COS_ASSIGNMENT_CAP) {
856 bp->vnic_cap_flags |= BNXT_VNIC_CAP_COS_CLASSIFY;
857 PMD_DRV_LOG(INFO, "CoS assignment capability enabled\n");
860 if (flags & HWRM_VNIC_QCAPS_OUTPUT_FLAGS_OUTERMOST_RSS_CAP)
861 bp->vnic_cap_flags |= BNXT_VNIC_CAP_OUTER_RSS;
863 bp->max_tpa_v2 = rte_le_to_cpu_16(resp->max_aggs_supported);
870 int bnxt_hwrm_func_reset(struct bnxt *bp)
873 struct hwrm_func_reset_input req = {.req_type = 0 };
874 struct hwrm_func_reset_output *resp = bp->hwrm_cmd_resp_addr;
876 HWRM_PREP(&req, HWRM_FUNC_RESET, BNXT_USE_CHIMP_MB);
878 req.enables = rte_cpu_to_le_32(0);
880 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
888 int bnxt_hwrm_func_driver_register(struct bnxt *bp)
892 struct hwrm_func_drv_rgtr_input req = {.req_type = 0 };
893 struct hwrm_func_drv_rgtr_output *resp = bp->hwrm_cmd_resp_addr;
895 if (bp->flags & BNXT_FLAG_REGISTERED)
898 if (bp->fw_cap & BNXT_FW_CAP_HOT_RESET)
899 flags = HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_HOT_RESET_SUPPORT;
900 if (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)
901 flags |= HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_ERROR_RECOVERY_SUPPORT;
903 /* PFs and trusted VFs should indicate the support of the
904 * Master capability on non Stingray platform
906 if ((BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp)) && !BNXT_STINGRAY(bp))
907 flags |= HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_MASTER_SUPPORT;
909 HWRM_PREP(&req, HWRM_FUNC_DRV_RGTR, BNXT_USE_CHIMP_MB);
910 req.enables = rte_cpu_to_le_32(HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_VER |
911 HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_ASYNC_EVENT_FWD);
912 req.ver_maj = RTE_VER_YEAR;
913 req.ver_min = RTE_VER_MONTH;
914 req.ver_upd = RTE_VER_MINOR;
917 req.enables |= rte_cpu_to_le_32(
918 HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_VF_REQ_FWD);
919 memcpy(req.vf_req_fwd, bp->pf->vf_req_fwd,
920 RTE_MIN(sizeof(req.vf_req_fwd),
921 sizeof(bp->pf->vf_req_fwd)));
924 req.flags = rte_cpu_to_le_32(flags);
926 req.async_event_fwd[0] |=
927 rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_LINK_STATUS_CHANGE |
928 ASYNC_CMPL_EVENT_ID_PORT_CONN_NOT_ALLOWED |
929 ASYNC_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE |
930 ASYNC_CMPL_EVENT_ID_LINK_SPEED_CHANGE |
931 ASYNC_CMPL_EVENT_ID_RESET_NOTIFY);
932 if (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)
933 req.async_event_fwd[0] |=
934 rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_ERROR_RECOVERY);
935 req.async_event_fwd[1] |=
936 rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_PF_DRVR_UNLOAD |
937 ASYNC_CMPL_EVENT_ID_VF_CFG_CHANGE);
939 req.async_event_fwd[1] |=
940 rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_DBG_NOTIFICATION);
942 if (BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))
943 req.async_event_fwd[1] |=
944 rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_DEFAULT_VNIC_CHANGE);
946 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
950 flags = rte_le_to_cpu_32(resp->flags);
951 if (flags & HWRM_FUNC_DRV_RGTR_OUTPUT_FLAGS_IF_CHANGE_SUPPORTED)
952 bp->fw_cap |= BNXT_FW_CAP_IF_CHANGE;
956 bp->flags |= BNXT_FLAG_REGISTERED;
961 int bnxt_hwrm_check_vf_rings(struct bnxt *bp)
963 if (!(BNXT_VF(bp) && (bp->flags & BNXT_FLAG_NEW_RM)))
966 return bnxt_hwrm_func_reserve_vf_resc(bp, true);
969 int bnxt_hwrm_func_reserve_vf_resc(struct bnxt *bp, bool test)
974 struct hwrm_func_vf_cfg_output *resp = bp->hwrm_cmd_resp_addr;
975 struct hwrm_func_vf_cfg_input req = {0};
977 HWRM_PREP(&req, HWRM_FUNC_VF_CFG, BNXT_USE_CHIMP_MB);
979 enables = HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_RX_RINGS |
980 HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_TX_RINGS |
981 HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_STAT_CTXS |
982 HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_CMPL_RINGS |
983 HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_VNICS;
985 if (BNXT_HAS_RING_GRPS(bp)) {
986 enables |= HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_HW_RING_GRPS;
987 req.num_hw_ring_grps = rte_cpu_to_le_16(bp->rx_nr_rings);
990 req.num_tx_rings = rte_cpu_to_le_16(bp->tx_nr_rings);
991 req.num_rx_rings = rte_cpu_to_le_16(bp->rx_nr_rings *
992 AGG_RING_MULTIPLIER);
993 req.num_stat_ctxs = rte_cpu_to_le_16(bp->rx_nr_rings + bp->tx_nr_rings);
994 req.num_cmpl_rings = rte_cpu_to_le_16(bp->rx_nr_rings +
996 BNXT_NUM_ASYNC_CPR(bp));
997 req.num_vnics = rte_cpu_to_le_16(bp->rx_nr_rings);
998 if (bp->vf_resv_strategy ==
999 HWRM_FUNC_RESOURCE_QCAPS_OUTPUT_VF_RESV_STRATEGY_MINIMAL_STATIC) {
1000 enables |= HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_VNICS |
1001 HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_L2_CTXS |
1002 HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_RSSCOS_CTXS;
1003 req.num_rsscos_ctxs = rte_cpu_to_le_16(BNXT_VF_RSV_NUM_RSS_CTX);
1004 req.num_l2_ctxs = rte_cpu_to_le_16(BNXT_VF_RSV_NUM_L2_CTX);
1005 req.num_vnics = rte_cpu_to_le_16(BNXT_VF_RSV_NUM_VNIC);
1006 } else if (bp->vf_resv_strategy ==
1007 HWRM_FUNC_RESOURCE_QCAPS_OUTPUT_VF_RESV_STRATEGY_MAXIMAL) {
1008 enables |= HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_RSSCOS_CTXS;
1009 req.num_rsscos_ctxs = rte_cpu_to_le_16(bp->max_rsscos_ctx);
1013 flags = HWRM_FUNC_VF_CFG_INPUT_FLAGS_TX_ASSETS_TEST |
1014 HWRM_FUNC_VF_CFG_INPUT_FLAGS_RX_ASSETS_TEST |
1015 HWRM_FUNC_VF_CFG_INPUT_FLAGS_CMPL_ASSETS_TEST |
1016 HWRM_FUNC_VF_CFG_INPUT_FLAGS_RING_GRP_ASSETS_TEST |
1017 HWRM_FUNC_VF_CFG_INPUT_FLAGS_STAT_CTX_ASSETS_TEST |
1018 HWRM_FUNC_VF_CFG_INPUT_FLAGS_VNIC_ASSETS_TEST;
1020 if (test && BNXT_HAS_RING_GRPS(bp))
1021 flags |= HWRM_FUNC_VF_CFG_INPUT_FLAGS_RING_GRP_ASSETS_TEST;
1023 req.flags = rte_cpu_to_le_32(flags);
1024 req.enables |= rte_cpu_to_le_32(enables);
1026 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1029 HWRM_CHECK_RESULT_SILENT();
1031 HWRM_CHECK_RESULT();
1037 int bnxt_hwrm_func_resc_qcaps(struct bnxt *bp)
1040 struct hwrm_func_resource_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
1041 struct hwrm_func_resource_qcaps_input req = {0};
1043 HWRM_PREP(&req, HWRM_FUNC_RESOURCE_QCAPS, BNXT_USE_CHIMP_MB);
1044 req.fid = rte_cpu_to_le_16(0xffff);
1046 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1048 HWRM_CHECK_RESULT_SILENT();
1050 bp->max_rsscos_ctx = rte_le_to_cpu_16(resp->max_rsscos_ctx);
1051 bp->max_cp_rings = rte_le_to_cpu_16(resp->max_cmpl_rings);
1052 bp->max_tx_rings = rte_le_to_cpu_16(resp->max_tx_rings);
1053 bp->max_rx_rings = rte_le_to_cpu_16(resp->max_rx_rings);
1054 bp->max_ring_grps = rte_le_to_cpu_32(resp->max_hw_ring_grps);
1055 /* func_resource_qcaps does not return max_rx_em_flows.
1056 * So use the value provided by func_qcaps.
1058 bp->max_l2_ctx = rte_le_to_cpu_16(resp->max_l2_ctxs);
1059 if (!BNXT_CHIP_P5(bp) && !bp->pdev->max_vfs)
1060 bp->max_l2_ctx += bp->max_rx_em_flows;
1061 bp->max_vnics = rte_le_to_cpu_16(resp->max_vnics);
1062 bp->max_stat_ctx = rte_le_to_cpu_16(resp->max_stat_ctx);
1063 bp->max_nq_rings = rte_le_to_cpu_16(resp->max_msix);
1064 bp->vf_resv_strategy = rte_le_to_cpu_16(resp->vf_reservation_strategy);
1065 if (bp->vf_resv_strategy >
1066 HWRM_FUNC_RESOURCE_QCAPS_OUTPUT_VF_RESV_STRATEGY_MINIMAL_STATIC)
1067 bp->vf_resv_strategy =
1068 HWRM_FUNC_RESOURCE_QCAPS_OUTPUT_VF_RESERVATION_STRATEGY_MAXIMAL;
1074 int bnxt_hwrm_ver_get(struct bnxt *bp, uint32_t timeout)
1077 struct hwrm_ver_get_input req = {.req_type = 0 };
1078 struct hwrm_ver_get_output *resp = bp->hwrm_cmd_resp_addr;
1079 uint32_t fw_version;
1080 uint16_t max_resp_len;
1081 char type[RTE_MEMZONE_NAMESIZE];
1082 uint32_t dev_caps_cfg;
1084 bp->max_req_len = HWRM_MAX_REQ_LEN;
1085 bp->hwrm_cmd_timeout = timeout;
1086 HWRM_PREP(&req, HWRM_VER_GET, BNXT_USE_CHIMP_MB);
1088 req.hwrm_intf_maj = HWRM_VERSION_MAJOR;
1089 req.hwrm_intf_min = HWRM_VERSION_MINOR;
1090 req.hwrm_intf_upd = HWRM_VERSION_UPDATE;
1092 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1094 if (bp->flags & BNXT_FLAG_FW_RESET)
1095 HWRM_CHECK_RESULT_SILENT();
1097 HWRM_CHECK_RESULT();
1099 PMD_DRV_LOG(INFO, "%d.%d.%d:%d.%d.%d\n",
1100 resp->hwrm_intf_maj_8b, resp->hwrm_intf_min_8b,
1101 resp->hwrm_intf_upd_8b, resp->hwrm_fw_maj_8b,
1102 resp->hwrm_fw_min_8b, resp->hwrm_fw_bld_8b);
1103 bp->fw_ver = (resp->hwrm_fw_maj_8b << 24) |
1104 (resp->hwrm_fw_min_8b << 16) |
1105 (resp->hwrm_fw_bld_8b << 8) |
1106 resp->hwrm_fw_rsvd_8b;
1107 PMD_DRV_LOG(INFO, "Driver HWRM version: %d.%d.%d\n",
1108 HWRM_VERSION_MAJOR, HWRM_VERSION_MINOR, HWRM_VERSION_UPDATE);
1110 fw_version = resp->hwrm_intf_maj_8b << 16;
1111 fw_version |= resp->hwrm_intf_min_8b << 8;
1112 fw_version |= resp->hwrm_intf_upd_8b;
1113 bp->hwrm_spec_code = fw_version;
1115 /* def_req_timeout value is in milliseconds */
1116 bp->hwrm_cmd_timeout = rte_le_to_cpu_16(resp->def_req_timeout);
1117 /* convert timeout to usec */
1118 bp->hwrm_cmd_timeout *= 1000;
1119 if (!bp->hwrm_cmd_timeout)
1120 bp->hwrm_cmd_timeout = DFLT_HWRM_CMD_TIMEOUT;
1122 if (resp->hwrm_intf_maj_8b != HWRM_VERSION_MAJOR) {
1123 PMD_DRV_LOG(ERR, "Unsupported firmware API version\n");
1128 if (bp->max_req_len > resp->max_req_win_len) {
1129 PMD_DRV_LOG(ERR, "Unsupported request length\n");
1133 bp->chip_num = rte_le_to_cpu_16(resp->chip_num);
1135 bp->max_req_len = rte_le_to_cpu_16(resp->max_req_win_len);
1136 bp->hwrm_max_ext_req_len = rte_le_to_cpu_16(resp->max_ext_req_len);
1137 if (bp->hwrm_max_ext_req_len < HWRM_MAX_REQ_LEN)
1138 bp->hwrm_max_ext_req_len = HWRM_MAX_REQ_LEN;
1140 max_resp_len = rte_le_to_cpu_16(resp->max_resp_len);
1141 dev_caps_cfg = rte_le_to_cpu_32(resp->dev_caps_cfg);
1143 if (bp->max_resp_len != max_resp_len) {
1144 sprintf(type, "bnxt_hwrm_" PCI_PRI_FMT,
1145 bp->pdev->addr.domain, bp->pdev->addr.bus,
1146 bp->pdev->addr.devid, bp->pdev->addr.function);
1148 rte_free(bp->hwrm_cmd_resp_addr);
1150 bp->hwrm_cmd_resp_addr = rte_malloc(type, max_resp_len, 0);
1151 if (bp->hwrm_cmd_resp_addr == NULL) {
1155 bp->hwrm_cmd_resp_dma_addr =
1156 rte_malloc_virt2iova(bp->hwrm_cmd_resp_addr);
1157 if (bp->hwrm_cmd_resp_dma_addr == RTE_BAD_IOVA) {
1159 "Unable to map response buffer to physical memory.\n");
1163 bp->max_resp_len = max_resp_len;
1167 HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_SHORT_CMD_SUPPORTED) &&
1169 HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_SHORT_CMD_REQUIRED)) {
1170 PMD_DRV_LOG(DEBUG, "Short command supported\n");
1171 bp->flags |= BNXT_FLAG_SHORT_CMD;
1174 if (((dev_caps_cfg &
1175 HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_SHORT_CMD_SUPPORTED) &&
1177 HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_SHORT_CMD_REQUIRED)) ||
1178 bp->hwrm_max_ext_req_len > HWRM_MAX_REQ_LEN) {
1179 sprintf(type, "bnxt_hwrm_short_" PCI_PRI_FMT,
1180 bp->pdev->addr.domain, bp->pdev->addr.bus,
1181 bp->pdev->addr.devid, bp->pdev->addr.function);
1183 rte_free(bp->hwrm_short_cmd_req_addr);
1185 bp->hwrm_short_cmd_req_addr =
1186 rte_malloc(type, bp->hwrm_max_ext_req_len, 0);
1187 if (bp->hwrm_short_cmd_req_addr == NULL) {
1191 bp->hwrm_short_cmd_req_dma_addr =
1192 rte_malloc_virt2iova(bp->hwrm_short_cmd_req_addr);
1193 if (bp->hwrm_short_cmd_req_dma_addr == RTE_BAD_IOVA) {
1194 rte_free(bp->hwrm_short_cmd_req_addr);
1196 "Unable to map buffer to physical memory.\n");
1202 HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_KONG_MB_CHNL_SUPPORTED) {
1203 bp->flags |= BNXT_FLAG_KONG_MB_EN;
1204 PMD_DRV_LOG(DEBUG, "Kong mailbox channel enabled\n");
1207 HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_TRUSTED_VF_SUPPORTED)
1208 PMD_DRV_LOG(DEBUG, "FW supports Trusted VFs\n");
1210 HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_CFA_ADV_FLOW_MGNT_SUPPORTED) {
1211 bp->fw_cap |= BNXT_FW_CAP_ADV_FLOW_MGMT;
1212 PMD_DRV_LOG(DEBUG, "FW supports advanced flow management\n");
1216 HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_ADV_FLOW_COUNTERS_SUPPORTED) {
1217 PMD_DRV_LOG(DEBUG, "FW supports advanced flow counters\n");
1218 bp->fw_cap |= BNXT_FW_CAP_ADV_FLOW_COUNTERS;
1227 int bnxt_hwrm_func_driver_unregister(struct bnxt *bp, uint32_t flags)
1230 struct hwrm_func_drv_unrgtr_input req = {.req_type = 0 };
1231 struct hwrm_func_drv_unrgtr_output *resp = bp->hwrm_cmd_resp_addr;
1233 if (!(bp->flags & BNXT_FLAG_REGISTERED))
1236 HWRM_PREP(&req, HWRM_FUNC_DRV_UNRGTR, BNXT_USE_CHIMP_MB);
1239 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1241 HWRM_CHECK_RESULT();
1247 static int bnxt_hwrm_port_phy_cfg(struct bnxt *bp, struct bnxt_link_info *conf)
1250 struct hwrm_port_phy_cfg_input req = {0};
1251 struct hwrm_port_phy_cfg_output *resp = bp->hwrm_cmd_resp_addr;
1252 uint32_t enables = 0;
1254 HWRM_PREP(&req, HWRM_PORT_PHY_CFG, BNXT_USE_CHIMP_MB);
1256 if (conf->link_up) {
1257 /* Setting Fixed Speed. But AutoNeg is ON, So disable it */
1258 if (bp->link_info->auto_mode && conf->link_speed) {
1259 req.auto_mode = HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_NONE;
1260 PMD_DRV_LOG(DEBUG, "Disabling AutoNeg\n");
1263 req.flags = rte_cpu_to_le_32(conf->phy_flags);
1265 * Note, ChiMP FW 20.2.1 and 20.2.2 return an error when we set
1266 * any auto mode, even "none".
1268 if (!conf->link_speed) {
1269 /* No speeds specified. Enable AutoNeg - all speeds */
1270 enables |= HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_MODE;
1272 HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_ALL_SPEEDS;
1274 if (bp->link_info->link_signal_mode) {
1276 HWRM_PORT_PHY_CFG_IN_EN_FORCE_PAM4_LINK_SPEED;
1277 req.force_pam4_link_speed =
1278 rte_cpu_to_le_16(conf->link_speed);
1280 req.force_link_speed =
1281 rte_cpu_to_le_16(conf->link_speed);
1284 /* AutoNeg - Advertise speeds specified. */
1285 if (conf->auto_link_speed_mask &&
1286 !(conf->phy_flags & HWRM_PORT_PHY_CFG_INPUT_FLAGS_FORCE)) {
1288 HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_SPEED_MASK;
1289 req.auto_link_speed_mask =
1290 conf->auto_link_speed_mask;
1291 if (conf->auto_pam4_link_speeds) {
1293 HWRM_PORT_PHY_CFG_IN_EN_AUTO_PAM4_LINK_SPD_MASK;
1294 req.auto_link_pam4_speed_mask =
1295 conf->auto_pam4_link_speeds;
1298 HWRM_PORT_PHY_CFG_IN_EN_AUTO_LINK_SPEED_MASK;
1301 if (conf->auto_link_speed &&
1302 !(conf->phy_flags & HWRM_PORT_PHY_CFG_INPUT_FLAGS_FORCE))
1304 HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_LINK_SPEED;
1306 req.auto_duplex = conf->duplex;
1307 enables |= HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_DUPLEX;
1308 req.auto_pause = conf->auto_pause;
1309 req.force_pause = conf->force_pause;
1310 /* Set force_pause if there is no auto or if there is a force */
1311 if (req.auto_pause && !req.force_pause)
1312 enables |= HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_PAUSE;
1314 enables |= HWRM_PORT_PHY_CFG_INPUT_ENABLES_FORCE_PAUSE;
1316 req.enables = rte_cpu_to_le_32(enables);
1319 rte_cpu_to_le_32(HWRM_PORT_PHY_CFG_INPUT_FLAGS_FORCE_LINK_DWN);
1320 PMD_DRV_LOG(INFO, "Force Link Down\n");
1323 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1325 HWRM_CHECK_RESULT();
1331 static int bnxt_hwrm_port_phy_qcfg(struct bnxt *bp,
1332 struct bnxt_link_info *link_info)
1335 struct hwrm_port_phy_qcfg_input req = {0};
1336 struct hwrm_port_phy_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
1338 HWRM_PREP(&req, HWRM_PORT_PHY_QCFG, BNXT_USE_CHIMP_MB);
1340 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1342 HWRM_CHECK_RESULT();
1344 link_info->phy_link_status = resp->link;
1345 link_info->link_up =
1346 (link_info->phy_link_status ==
1347 HWRM_PORT_PHY_QCFG_OUTPUT_LINK_LINK) ? 1 : 0;
1348 link_info->link_speed = rte_le_to_cpu_16(resp->link_speed);
1349 link_info->duplex = resp->duplex_cfg;
1350 link_info->pause = resp->pause;
1351 link_info->auto_pause = resp->auto_pause;
1352 link_info->force_pause = resp->force_pause;
1353 link_info->auto_mode = resp->auto_mode;
1354 link_info->phy_type = resp->phy_type;
1355 link_info->media_type = resp->media_type;
1357 link_info->support_speeds = rte_le_to_cpu_16(resp->support_speeds);
1358 link_info->auto_link_speed = rte_le_to_cpu_16(resp->auto_link_speed);
1359 link_info->preemphasis = rte_le_to_cpu_32(resp->preemphasis);
1360 link_info->force_link_speed = rte_le_to_cpu_16(resp->force_link_speed);
1361 link_info->phy_ver[0] = resp->phy_maj;
1362 link_info->phy_ver[1] = resp->phy_min;
1363 link_info->phy_ver[2] = resp->phy_bld;
1364 link_info->link_signal_mode =
1365 rte_le_to_cpu_16(resp->active_fec_signal_mode);
1366 link_info->force_pam4_link_speed =
1367 rte_le_to_cpu_16(resp->force_pam4_link_speed);
1368 link_info->support_pam4_speeds =
1369 rte_le_to_cpu_16(resp->support_pam4_speeds);
1370 link_info->auto_pam4_link_speeds =
1371 rte_le_to_cpu_16(resp->auto_pam4_link_speed_mask);
1374 PMD_DRV_LOG(DEBUG, "Link Speed:%d,Auto:%d:%x:%x,Support:%x,Force:%x\n",
1375 link_info->link_speed, link_info->auto_mode,
1376 link_info->auto_link_speed, link_info->auto_link_speed_mask,
1377 link_info->support_speeds, link_info->force_link_speed);
1378 PMD_DRV_LOG(DEBUG, "Link Signal:%d,PAM::Auto:%x,Support:%x,Force:%x\n",
1379 link_info->link_signal_mode,
1380 link_info->auto_pam4_link_speeds,
1381 link_info->support_pam4_speeds,
1382 link_info->force_pam4_link_speed);
1386 int bnxt_hwrm_port_phy_qcaps(struct bnxt *bp)
1389 struct hwrm_port_phy_qcaps_input req = {0};
1390 struct hwrm_port_phy_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
1391 struct bnxt_link_info *link_info = bp->link_info;
1393 if (BNXT_VF(bp) && !BNXT_VF_IS_TRUSTED(bp))
1396 HWRM_PREP(&req, HWRM_PORT_PHY_QCAPS, BNXT_USE_CHIMP_MB);
1398 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1400 HWRM_CHECK_RESULT();
1402 bp->port_cnt = resp->port_cnt;
1403 if (resp->supported_speeds_auto_mode)
1404 link_info->support_auto_speeds =
1405 rte_le_to_cpu_16(resp->supported_speeds_auto_mode);
1406 if (resp->supported_pam4_speeds_auto_mode)
1407 link_info->support_pam4_auto_speeds =
1408 rte_le_to_cpu_16(resp->supported_pam4_speeds_auto_mode);
1415 static bool bnxt_find_lossy_profile(struct bnxt *bp)
1419 for (i = BNXT_COS_QUEUE_COUNT - 1; i >= 0; i--) {
1420 if (bp->tx_cos_queue[i].profile ==
1421 HWRM_QUEUE_SERVICE_PROFILE_LOSSY) {
1422 bp->tx_cosq_id[0] = bp->tx_cos_queue[i].id;
1429 static void bnxt_find_first_valid_profile(struct bnxt *bp)
1433 for (i = BNXT_COS_QUEUE_COUNT - 1; i >= 0; i--) {
1434 if (bp->tx_cos_queue[i].profile !=
1435 HWRM_QUEUE_SERVICE_PROFILE_UNKNOWN &&
1436 bp->tx_cos_queue[i].id !=
1437 HWRM_QUEUE_SERVICE_PROFILE_UNKNOWN) {
1438 bp->tx_cosq_id[0] = bp->tx_cos_queue[i].id;
1444 int bnxt_hwrm_queue_qportcfg(struct bnxt *bp)
1447 struct hwrm_queue_qportcfg_input req = {.req_type = 0 };
1448 struct hwrm_queue_qportcfg_output *resp = bp->hwrm_cmd_resp_addr;
1449 uint32_t dir = HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH_TX;
1453 HWRM_PREP(&req, HWRM_QUEUE_QPORTCFG, BNXT_USE_CHIMP_MB);
1455 req.flags = rte_cpu_to_le_32(dir);
1456 /* HWRM Version >= 1.9.1 only if COS Classification is not required. */
1457 if (bp->hwrm_spec_code >= HWRM_VERSION_1_9_1 &&
1458 !(bp->vnic_cap_flags & BNXT_VNIC_CAP_COS_CLASSIFY))
1460 HWRM_QUEUE_QPORTCFG_INPUT_DRV_QMAP_CAP_ENABLED;
1461 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1463 HWRM_CHECK_RESULT();
1465 if (dir == HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH_TX) {
1466 GET_TX_QUEUE_INFO(0);
1467 GET_TX_QUEUE_INFO(1);
1468 GET_TX_QUEUE_INFO(2);
1469 GET_TX_QUEUE_INFO(3);
1470 GET_TX_QUEUE_INFO(4);
1471 GET_TX_QUEUE_INFO(5);
1472 GET_TX_QUEUE_INFO(6);
1473 GET_TX_QUEUE_INFO(7);
1475 GET_RX_QUEUE_INFO(0);
1476 GET_RX_QUEUE_INFO(1);
1477 GET_RX_QUEUE_INFO(2);
1478 GET_RX_QUEUE_INFO(3);
1479 GET_RX_QUEUE_INFO(4);
1480 GET_RX_QUEUE_INFO(5);
1481 GET_RX_QUEUE_INFO(6);
1482 GET_RX_QUEUE_INFO(7);
1487 if (dir == HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH_RX)
1490 if (bp->hwrm_spec_code < HWRM_VERSION_1_9_1) {
1491 bp->tx_cosq_id[0] = bp->tx_cos_queue[0].id;
1495 /* iterate and find the COSq profile to use for Tx */
1496 if (bp->vnic_cap_flags & BNXT_VNIC_CAP_COS_CLASSIFY) {
1497 for (j = 0, i = 0; i < BNXT_COS_QUEUE_COUNT; i++) {
1498 if (bp->tx_cos_queue[i].id != 0xff)
1499 bp->tx_cosq_id[j++] =
1500 bp->tx_cos_queue[i].id;
1503 /* When CoS classification is disabled, for normal NIC
1504 * operations, ideally we should look to use LOSSY.
1505 * If not found, fallback to the first valid profile
1507 if (!bnxt_find_lossy_profile(bp))
1508 bnxt_find_first_valid_profile(bp);
1513 bp->max_tc = resp->max_configurable_queues;
1514 bp->max_lltc = resp->max_configurable_lossless_queues;
1515 if (bp->max_tc > BNXT_MAX_QUEUE)
1516 bp->max_tc = BNXT_MAX_QUEUE;
1517 bp->max_q = bp->max_tc;
1519 if (dir == HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH_TX) {
1520 dir = HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH_RX;
1528 int bnxt_hwrm_ring_alloc(struct bnxt *bp,
1529 struct bnxt_ring *ring,
1530 uint32_t ring_type, uint32_t map_index,
1531 uint32_t stats_ctx_id, uint32_t cmpl_ring_id,
1532 uint16_t tx_cosq_id)
1535 uint32_t enables = 0;
1536 struct hwrm_ring_alloc_input req = {.req_type = 0 };
1537 struct hwrm_ring_alloc_output *resp = bp->hwrm_cmd_resp_addr;
1538 struct rte_mempool *mb_pool;
1539 uint16_t rx_buf_size;
1541 HWRM_PREP(&req, HWRM_RING_ALLOC, BNXT_USE_CHIMP_MB);
1543 req.page_tbl_addr = rte_cpu_to_le_64(ring->bd_dma);
1544 req.fbo = rte_cpu_to_le_32(0);
1545 /* Association of ring index with doorbell index */
1546 req.logical_id = rte_cpu_to_le_16(map_index);
1547 req.length = rte_cpu_to_le_32(ring->ring_size);
1549 switch (ring_type) {
1550 case HWRM_RING_ALLOC_INPUT_RING_TYPE_TX:
1551 req.ring_type = ring_type;
1552 req.cmpl_ring_id = rte_cpu_to_le_16(cmpl_ring_id);
1553 req.stat_ctx_id = rte_cpu_to_le_32(stats_ctx_id);
1554 req.queue_id = rte_cpu_to_le_16(tx_cosq_id);
1555 if (stats_ctx_id != INVALID_STATS_CTX_ID)
1557 HWRM_RING_ALLOC_INPUT_ENABLES_STAT_CTX_ID_VALID;
1559 case HWRM_RING_ALLOC_INPUT_RING_TYPE_RX:
1560 req.ring_type = ring_type;
1561 req.cmpl_ring_id = rte_cpu_to_le_16(cmpl_ring_id);
1562 req.stat_ctx_id = rte_cpu_to_le_32(stats_ctx_id);
1563 if (BNXT_CHIP_P5(bp)) {
1564 mb_pool = bp->rx_queues[0]->mb_pool;
1565 rx_buf_size = rte_pktmbuf_data_room_size(mb_pool) -
1566 RTE_PKTMBUF_HEADROOM;
1567 rx_buf_size = RTE_MIN(BNXT_MAX_PKT_LEN, rx_buf_size);
1568 req.rx_buf_size = rte_cpu_to_le_16(rx_buf_size);
1570 HWRM_RING_ALLOC_INPUT_ENABLES_RX_BUF_SIZE_VALID;
1572 if (stats_ctx_id != INVALID_STATS_CTX_ID)
1574 HWRM_RING_ALLOC_INPUT_ENABLES_STAT_CTX_ID_VALID;
1576 case HWRM_RING_ALLOC_INPUT_RING_TYPE_L2_CMPL:
1577 req.ring_type = ring_type;
1578 if (BNXT_HAS_NQ(bp)) {
1579 /* Association of cp ring with nq */
1580 req.nq_ring_id = rte_cpu_to_le_16(cmpl_ring_id);
1582 HWRM_RING_ALLOC_INPUT_ENABLES_NQ_RING_ID_VALID;
1584 req.int_mode = HWRM_RING_ALLOC_INPUT_INT_MODE_MSIX;
1586 case HWRM_RING_ALLOC_INPUT_RING_TYPE_NQ:
1587 req.ring_type = ring_type;
1588 req.page_size = BNXT_PAGE_SHFT;
1589 req.int_mode = HWRM_RING_ALLOC_INPUT_INT_MODE_MSIX;
1591 case HWRM_RING_ALLOC_INPUT_RING_TYPE_RX_AGG:
1592 req.ring_type = ring_type;
1593 req.rx_ring_id = rte_cpu_to_le_16(ring->fw_rx_ring_id);
1595 mb_pool = bp->rx_queues[0]->mb_pool;
1596 rx_buf_size = rte_pktmbuf_data_room_size(mb_pool) -
1597 RTE_PKTMBUF_HEADROOM;
1598 rx_buf_size = RTE_MIN(BNXT_MAX_PKT_LEN, rx_buf_size);
1599 req.rx_buf_size = rte_cpu_to_le_16(rx_buf_size);
1601 req.stat_ctx_id = rte_cpu_to_le_32(stats_ctx_id);
1602 enables |= HWRM_RING_ALLOC_INPUT_ENABLES_RX_RING_ID_VALID |
1603 HWRM_RING_ALLOC_INPUT_ENABLES_RX_BUF_SIZE_VALID |
1604 HWRM_RING_ALLOC_INPUT_ENABLES_STAT_CTX_ID_VALID;
1607 PMD_DRV_LOG(ERR, "hwrm alloc invalid ring type %d\n",
1612 req.enables = rte_cpu_to_le_32(enables);
1614 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1616 if (rc || resp->error_code) {
1617 if (rc == 0 && resp->error_code)
1618 rc = rte_le_to_cpu_16(resp->error_code);
1619 switch (ring_type) {
1620 case HWRM_RING_ALLOC_INPUT_RING_TYPE_L2_CMPL:
1622 "hwrm_ring_alloc cp failed. rc:%d\n", rc);
1625 case HWRM_RING_ALLOC_INPUT_RING_TYPE_RX:
1627 "hwrm_ring_alloc rx failed. rc:%d\n", rc);
1630 case HWRM_RING_ALLOC_INPUT_RING_TYPE_RX_AGG:
1632 "hwrm_ring_alloc rx agg failed. rc:%d\n",
1636 case HWRM_RING_ALLOC_INPUT_RING_TYPE_TX:
1638 "hwrm_ring_alloc tx failed. rc:%d\n", rc);
1641 case HWRM_RING_ALLOC_INPUT_RING_TYPE_NQ:
1643 "hwrm_ring_alloc nq failed. rc:%d\n", rc);
1647 PMD_DRV_LOG(ERR, "Invalid ring. rc:%d\n", rc);
1653 ring->fw_ring_id = rte_le_to_cpu_16(resp->ring_id);
1658 int bnxt_hwrm_ring_free(struct bnxt *bp,
1659 struct bnxt_ring *ring, uint32_t ring_type)
1662 struct hwrm_ring_free_input req = {.req_type = 0 };
1663 struct hwrm_ring_free_output *resp = bp->hwrm_cmd_resp_addr;
1665 HWRM_PREP(&req, HWRM_RING_FREE, BNXT_USE_CHIMP_MB);
1667 req.ring_type = ring_type;
1668 req.ring_id = rte_cpu_to_le_16(ring->fw_ring_id);
1670 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1672 if (rc || resp->error_code) {
1673 if (rc == 0 && resp->error_code)
1674 rc = rte_le_to_cpu_16(resp->error_code);
1677 switch (ring_type) {
1678 case HWRM_RING_FREE_INPUT_RING_TYPE_L2_CMPL:
1679 PMD_DRV_LOG(ERR, "hwrm_ring_free cp failed. rc:%d\n",
1682 case HWRM_RING_FREE_INPUT_RING_TYPE_RX:
1683 PMD_DRV_LOG(ERR, "hwrm_ring_free rx failed. rc:%d\n",
1686 case HWRM_RING_FREE_INPUT_RING_TYPE_TX:
1687 PMD_DRV_LOG(ERR, "hwrm_ring_free tx failed. rc:%d\n",
1690 case HWRM_RING_FREE_INPUT_RING_TYPE_NQ:
1692 "hwrm_ring_free nq failed. rc:%d\n", rc);
1694 case HWRM_RING_FREE_INPUT_RING_TYPE_RX_AGG:
1696 "hwrm_ring_free agg failed. rc:%d\n", rc);
1699 PMD_DRV_LOG(ERR, "Invalid ring, rc:%d\n", rc);
1707 int bnxt_hwrm_ring_grp_alloc(struct bnxt *bp, unsigned int idx)
1710 struct hwrm_ring_grp_alloc_input req = {.req_type = 0 };
1711 struct hwrm_ring_grp_alloc_output *resp = bp->hwrm_cmd_resp_addr;
1713 HWRM_PREP(&req, HWRM_RING_GRP_ALLOC, BNXT_USE_CHIMP_MB);
1715 req.cr = rte_cpu_to_le_16(bp->grp_info[idx].cp_fw_ring_id);
1716 req.rr = rte_cpu_to_le_16(bp->grp_info[idx].rx_fw_ring_id);
1717 req.ar = rte_cpu_to_le_16(bp->grp_info[idx].ag_fw_ring_id);
1718 req.sc = rte_cpu_to_le_16(bp->grp_info[idx].fw_stats_ctx);
1720 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1722 HWRM_CHECK_RESULT();
1724 bp->grp_info[idx].fw_grp_id = rte_le_to_cpu_16(resp->ring_group_id);
1731 int bnxt_hwrm_ring_grp_free(struct bnxt *bp, unsigned int idx)
1734 struct hwrm_ring_grp_free_input req = {.req_type = 0 };
1735 struct hwrm_ring_grp_free_output *resp = bp->hwrm_cmd_resp_addr;
1737 HWRM_PREP(&req, HWRM_RING_GRP_FREE, BNXT_USE_CHIMP_MB);
1739 req.ring_group_id = rte_cpu_to_le_16(bp->grp_info[idx].fw_grp_id);
1741 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1743 HWRM_CHECK_RESULT();
1746 bp->grp_info[idx].fw_grp_id = INVALID_HW_RING_ID;
1750 int bnxt_hwrm_stat_clear(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)
1753 struct hwrm_stat_ctx_clr_stats_input req = {.req_type = 0 };
1754 struct hwrm_stat_ctx_clr_stats_output *resp = bp->hwrm_cmd_resp_addr;
1756 if (cpr->hw_stats_ctx_id == (uint32_t)HWRM_NA_SIGNATURE)
1759 HWRM_PREP(&req, HWRM_STAT_CTX_CLR_STATS, BNXT_USE_CHIMP_MB);
1761 req.stat_ctx_id = rte_cpu_to_le_32(cpr->hw_stats_ctx_id);
1763 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1765 HWRM_CHECK_RESULT();
1771 int bnxt_hwrm_stat_ctx_alloc(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
1772 unsigned int idx __rte_unused)
1775 struct hwrm_stat_ctx_alloc_input req = {.req_type = 0 };
1776 struct hwrm_stat_ctx_alloc_output *resp = bp->hwrm_cmd_resp_addr;
1778 HWRM_PREP(&req, HWRM_STAT_CTX_ALLOC, BNXT_USE_CHIMP_MB);
1780 req.update_period_ms = rte_cpu_to_le_32(0);
1782 req.stats_dma_addr = rte_cpu_to_le_64(cpr->hw_stats_map);
1784 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1786 HWRM_CHECK_RESULT();
1788 cpr->hw_stats_ctx_id = rte_le_to_cpu_32(resp->stat_ctx_id);
1795 int bnxt_hwrm_stat_ctx_free(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
1796 unsigned int idx __rte_unused)
1799 struct hwrm_stat_ctx_free_input req = {.req_type = 0 };
1800 struct hwrm_stat_ctx_free_output *resp = bp->hwrm_cmd_resp_addr;
1802 HWRM_PREP(&req, HWRM_STAT_CTX_FREE, BNXT_USE_CHIMP_MB);
1804 req.stat_ctx_id = rte_cpu_to_le_32(cpr->hw_stats_ctx_id);
1806 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1808 HWRM_CHECK_RESULT();
1814 int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic)
1817 struct hwrm_vnic_alloc_input req = { 0 };
1818 struct hwrm_vnic_alloc_output *resp = bp->hwrm_cmd_resp_addr;
1820 if (!BNXT_HAS_RING_GRPS(bp))
1821 goto skip_ring_grps;
1823 /* map ring groups to this vnic */
1824 PMD_DRV_LOG(DEBUG, "Alloc VNIC. Start %x, End %x\n",
1825 vnic->start_grp_id, vnic->end_grp_id);
1826 for (i = vnic->start_grp_id, j = 0; i < vnic->end_grp_id; i++, j++)
1827 vnic->fw_grp_ids[j] = bp->grp_info[i].fw_grp_id;
1829 vnic->dflt_ring_grp = bp->grp_info[vnic->start_grp_id].fw_grp_id;
1830 vnic->rss_rule = (uint16_t)HWRM_NA_SIGNATURE;
1831 vnic->cos_rule = (uint16_t)HWRM_NA_SIGNATURE;
1832 vnic->lb_rule = (uint16_t)HWRM_NA_SIGNATURE;
1835 vnic->mru = BNXT_VNIC_MRU(bp->eth_dev->data->mtu);
1836 HWRM_PREP(&req, HWRM_VNIC_ALLOC, BNXT_USE_CHIMP_MB);
1838 if (vnic->func_default)
1840 rte_cpu_to_le_32(HWRM_VNIC_ALLOC_INPUT_FLAGS_DEFAULT);
1841 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1843 HWRM_CHECK_RESULT();
1845 vnic->fw_vnic_id = rte_le_to_cpu_16(resp->vnic_id);
1847 PMD_DRV_LOG(DEBUG, "VNIC ID %x\n", vnic->fw_vnic_id);
1851 static int bnxt_hwrm_vnic_plcmodes_qcfg(struct bnxt *bp,
1852 struct bnxt_vnic_info *vnic,
1853 struct bnxt_plcmodes_cfg *pmode)
1856 struct hwrm_vnic_plcmodes_qcfg_input req = {.req_type = 0 };
1857 struct hwrm_vnic_plcmodes_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
1859 HWRM_PREP(&req, HWRM_VNIC_PLCMODES_QCFG, BNXT_USE_CHIMP_MB);
1861 req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
1863 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1865 HWRM_CHECK_RESULT();
1867 pmode->flags = rte_le_to_cpu_32(resp->flags);
1868 /* dflt_vnic bit doesn't exist in the _cfg command */
1869 pmode->flags &= ~(HWRM_VNIC_PLCMODES_QCFG_OUTPUT_FLAGS_DFLT_VNIC);
1870 pmode->jumbo_thresh = rte_le_to_cpu_16(resp->jumbo_thresh);
1871 pmode->hds_offset = rte_le_to_cpu_16(resp->hds_offset);
1872 pmode->hds_threshold = rte_le_to_cpu_16(resp->hds_threshold);
1879 static int bnxt_hwrm_vnic_plcmodes_cfg(struct bnxt *bp,
1880 struct bnxt_vnic_info *vnic,
1881 struct bnxt_plcmodes_cfg *pmode)
1884 struct hwrm_vnic_plcmodes_cfg_input req = {.req_type = 0 };
1885 struct hwrm_vnic_plcmodes_cfg_output *resp = bp->hwrm_cmd_resp_addr;
1887 if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
1888 PMD_DRV_LOG(DEBUG, "VNIC ID %x\n", vnic->fw_vnic_id);
1892 HWRM_PREP(&req, HWRM_VNIC_PLCMODES_CFG, BNXT_USE_CHIMP_MB);
1894 req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
1895 req.flags = rte_cpu_to_le_32(pmode->flags);
1896 req.jumbo_thresh = rte_cpu_to_le_16(pmode->jumbo_thresh);
1897 req.hds_offset = rte_cpu_to_le_16(pmode->hds_offset);
1898 req.hds_threshold = rte_cpu_to_le_16(pmode->hds_threshold);
1899 req.enables = rte_cpu_to_le_32(
1900 HWRM_VNIC_PLCMODES_CFG_INPUT_ENABLES_HDS_THRESHOLD_VALID |
1901 HWRM_VNIC_PLCMODES_CFG_INPUT_ENABLES_HDS_OFFSET_VALID |
1902 HWRM_VNIC_PLCMODES_CFG_INPUT_ENABLES_JUMBO_THRESH_VALID
1905 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
1907 HWRM_CHECK_RESULT();
1913 int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic)
1916 struct hwrm_vnic_cfg_input req = {.req_type = 0 };
1917 struct hwrm_vnic_cfg_output *resp = bp->hwrm_cmd_resp_addr;
1918 struct bnxt_plcmodes_cfg pmodes = { 0 };
1919 uint32_t ctx_enable_flag = 0;
1920 uint32_t enables = 0;
1922 if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
1923 PMD_DRV_LOG(DEBUG, "VNIC ID %x\n", vnic->fw_vnic_id);
1927 rc = bnxt_hwrm_vnic_plcmodes_qcfg(bp, vnic, &pmodes);
1931 HWRM_PREP(&req, HWRM_VNIC_CFG, BNXT_USE_CHIMP_MB);
1933 if (BNXT_CHIP_P5(bp)) {
1934 int dflt_rxq = vnic->start_grp_id;
1935 struct bnxt_rx_ring_info *rxr;
1936 struct bnxt_cp_ring_info *cpr;
1937 struct bnxt_rx_queue *rxq;
1941 * The first active receive ring is used as the VNIC
1942 * default receive ring. If there are no active receive
1943 * rings (all corresponding receive queues are stopped),
1944 * the first receive ring is used.
1946 for (i = vnic->start_grp_id; i < vnic->end_grp_id; i++) {
1947 rxq = bp->eth_dev->data->rx_queues[i];
1948 if (rxq->rx_started) {
1954 rxq = bp->eth_dev->data->rx_queues[dflt_rxq];
1958 req.default_rx_ring_id =
1959 rte_cpu_to_le_16(rxr->rx_ring_struct->fw_ring_id);
1960 req.default_cmpl_ring_id =
1961 rte_cpu_to_le_16(cpr->cp_ring_struct->fw_ring_id);
1962 enables = HWRM_VNIC_CFG_INPUT_ENABLES_DEFAULT_RX_RING_ID |
1963 HWRM_VNIC_CFG_INPUT_ENABLES_DEFAULT_CMPL_RING_ID;
1967 /* Only RSS support for now TBD: COS & LB */
1968 enables = HWRM_VNIC_CFG_INPUT_ENABLES_DFLT_RING_GRP;
1969 if (vnic->lb_rule != 0xffff)
1970 ctx_enable_flag |= HWRM_VNIC_CFG_INPUT_ENABLES_LB_RULE;
1971 if (vnic->cos_rule != 0xffff)
1972 ctx_enable_flag |= HWRM_VNIC_CFG_INPUT_ENABLES_COS_RULE;
1973 if (vnic->rss_rule != (uint16_t)HWRM_NA_SIGNATURE) {
1974 ctx_enable_flag |= HWRM_VNIC_CFG_INPUT_ENABLES_MRU;
1975 ctx_enable_flag |= HWRM_VNIC_CFG_INPUT_ENABLES_RSS_RULE;
1977 if (bp->vnic_cap_flags & BNXT_VNIC_CAP_COS_CLASSIFY) {
1978 ctx_enable_flag |= HWRM_VNIC_CFG_INPUT_ENABLES_QUEUE_ID;
1979 req.queue_id = rte_cpu_to_le_16(vnic->cos_queue_id);
1982 enables |= ctx_enable_flag;
1983 req.dflt_ring_grp = rte_cpu_to_le_16(vnic->dflt_ring_grp);
1984 req.rss_rule = rte_cpu_to_le_16(vnic->rss_rule);
1985 req.cos_rule = rte_cpu_to_le_16(vnic->cos_rule);
1986 req.lb_rule = rte_cpu_to_le_16(vnic->lb_rule);
1989 req.enables = rte_cpu_to_le_32(enables);
1990 req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
1991 req.mru = rte_cpu_to_le_16(vnic->mru);
1992 /* Configure default VNIC only once. */
1993 if (vnic->func_default && !(bp->flags & BNXT_FLAG_DFLT_VNIC_SET)) {
1995 rte_cpu_to_le_32(HWRM_VNIC_CFG_INPUT_FLAGS_DEFAULT);
1996 bp->flags |= BNXT_FLAG_DFLT_VNIC_SET;
1998 if (vnic->vlan_strip)
2000 rte_cpu_to_le_32(HWRM_VNIC_CFG_INPUT_FLAGS_VLAN_STRIP_MODE);
2003 rte_cpu_to_le_32(HWRM_VNIC_CFG_INPUT_FLAGS_BD_STALL_MODE);
2004 if (vnic->roce_dual)
2005 req.flags |= rte_cpu_to_le_32(
2006 HWRM_VNIC_QCFG_OUTPUT_FLAGS_ROCE_DUAL_VNIC_MODE);
2007 if (vnic->roce_only)
2008 req.flags |= rte_cpu_to_le_32(
2009 HWRM_VNIC_QCFG_OUTPUT_FLAGS_ROCE_ONLY_VNIC_MODE);
2010 if (vnic->rss_dflt_cr)
2011 req.flags |= rte_cpu_to_le_32(
2012 HWRM_VNIC_QCFG_OUTPUT_FLAGS_RSS_DFLT_CR_MODE);
2014 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2016 HWRM_CHECK_RESULT();
2019 rc = bnxt_hwrm_vnic_plcmodes_cfg(bp, vnic, &pmodes);
2024 int bnxt_hwrm_vnic_qcfg(struct bnxt *bp, struct bnxt_vnic_info *vnic,
2028 struct hwrm_vnic_qcfg_input req = {.req_type = 0 };
2029 struct hwrm_vnic_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
2031 if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
2032 PMD_DRV_LOG(DEBUG, "VNIC QCFG ID %d\n", vnic->fw_vnic_id);
2035 HWRM_PREP(&req, HWRM_VNIC_QCFG, BNXT_USE_CHIMP_MB);
2038 rte_cpu_to_le_32(HWRM_VNIC_QCFG_INPUT_ENABLES_VF_ID_VALID);
2039 req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
2040 req.vf_id = rte_cpu_to_le_16(fw_vf_id);
2042 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2044 HWRM_CHECK_RESULT();
2046 vnic->dflt_ring_grp = rte_le_to_cpu_16(resp->dflt_ring_grp);
2047 vnic->rss_rule = rte_le_to_cpu_16(resp->rss_rule);
2048 vnic->cos_rule = rte_le_to_cpu_16(resp->cos_rule);
2049 vnic->lb_rule = rte_le_to_cpu_16(resp->lb_rule);
2050 vnic->mru = rte_le_to_cpu_16(resp->mru);
2051 vnic->func_default = rte_le_to_cpu_32(
2052 resp->flags) & HWRM_VNIC_QCFG_OUTPUT_FLAGS_DEFAULT;
2053 vnic->vlan_strip = rte_le_to_cpu_32(resp->flags) &
2054 HWRM_VNIC_QCFG_OUTPUT_FLAGS_VLAN_STRIP_MODE;
2055 vnic->bd_stall = rte_le_to_cpu_32(resp->flags) &
2056 HWRM_VNIC_QCFG_OUTPUT_FLAGS_BD_STALL_MODE;
2057 vnic->roce_dual = rte_le_to_cpu_32(resp->flags) &
2058 HWRM_VNIC_QCFG_OUTPUT_FLAGS_ROCE_DUAL_VNIC_MODE;
2059 vnic->roce_only = rte_le_to_cpu_32(resp->flags) &
2060 HWRM_VNIC_QCFG_OUTPUT_FLAGS_ROCE_ONLY_VNIC_MODE;
2061 vnic->rss_dflt_cr = rte_le_to_cpu_32(resp->flags) &
2062 HWRM_VNIC_QCFG_OUTPUT_FLAGS_RSS_DFLT_CR_MODE;
2069 int bnxt_hwrm_vnic_ctx_alloc(struct bnxt *bp,
2070 struct bnxt_vnic_info *vnic, uint16_t ctx_idx)
2074 struct hwrm_vnic_rss_cos_lb_ctx_alloc_input req = {.req_type = 0 };
2075 struct hwrm_vnic_rss_cos_lb_ctx_alloc_output *resp =
2076 bp->hwrm_cmd_resp_addr;
2078 HWRM_PREP(&req, HWRM_VNIC_RSS_COS_LB_CTX_ALLOC, BNXT_USE_CHIMP_MB);
2080 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2081 HWRM_CHECK_RESULT();
2083 ctx_id = rte_le_to_cpu_16(resp->rss_cos_lb_ctx_id);
2084 if (!BNXT_HAS_RING_GRPS(bp))
2085 vnic->fw_grp_ids[ctx_idx] = ctx_id;
2086 else if (ctx_idx == 0)
2087 vnic->rss_rule = ctx_id;
2095 int _bnxt_hwrm_vnic_ctx_free(struct bnxt *bp,
2096 struct bnxt_vnic_info *vnic, uint16_t ctx_idx)
2099 struct hwrm_vnic_rss_cos_lb_ctx_free_input req = {.req_type = 0 };
2100 struct hwrm_vnic_rss_cos_lb_ctx_free_output *resp =
2101 bp->hwrm_cmd_resp_addr;
2103 if (ctx_idx == (uint16_t)HWRM_NA_SIGNATURE) {
2104 PMD_DRV_LOG(DEBUG, "VNIC RSS Rule %x\n", vnic->rss_rule);
2107 HWRM_PREP(&req, HWRM_VNIC_RSS_COS_LB_CTX_FREE, BNXT_USE_CHIMP_MB);
2109 req.rss_cos_lb_ctx_id = rte_cpu_to_le_16(ctx_idx);
2111 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2113 HWRM_CHECK_RESULT();
2119 int bnxt_hwrm_vnic_ctx_free(struct bnxt *bp, struct bnxt_vnic_info *vnic)
2123 if (BNXT_CHIP_P5(bp)) {
2126 for (j = 0; j < vnic->num_lb_ctxts; j++) {
2127 rc = _bnxt_hwrm_vnic_ctx_free(bp,
2129 vnic->fw_grp_ids[j]);
2130 vnic->fw_grp_ids[j] = INVALID_HW_RING_ID;
2132 vnic->num_lb_ctxts = 0;
2134 rc = _bnxt_hwrm_vnic_ctx_free(bp, vnic, vnic->rss_rule);
2135 vnic->rss_rule = INVALID_HW_RING_ID;
2141 int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic)
2144 struct hwrm_vnic_free_input req = {.req_type = 0 };
2145 struct hwrm_vnic_free_output *resp = bp->hwrm_cmd_resp_addr;
2147 if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
2148 PMD_DRV_LOG(DEBUG, "VNIC FREE ID %x\n", vnic->fw_vnic_id);
2152 HWRM_PREP(&req, HWRM_VNIC_FREE, BNXT_USE_CHIMP_MB);
2154 req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
2156 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2158 HWRM_CHECK_RESULT();
2161 vnic->fw_vnic_id = INVALID_HW_RING_ID;
2162 /* Configure default VNIC again if necessary. */
2163 if (vnic->func_default && (bp->flags & BNXT_FLAG_DFLT_VNIC_SET))
2164 bp->flags &= ~BNXT_FLAG_DFLT_VNIC_SET;
2170 bnxt_hwrm_vnic_rss_cfg_p5(struct bnxt *bp, struct bnxt_vnic_info *vnic)
2174 int nr_ctxs = vnic->num_lb_ctxts;
2175 struct hwrm_vnic_rss_cfg_input req = {.req_type = 0 };
2176 struct hwrm_vnic_rss_cfg_output *resp = bp->hwrm_cmd_resp_addr;
2178 for (i = 0; i < nr_ctxs; i++) {
2179 HWRM_PREP(&req, HWRM_VNIC_RSS_CFG, BNXT_USE_CHIMP_MB);
2181 req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
2182 req.hash_type = rte_cpu_to_le_32(vnic->hash_type);
2183 req.hash_mode_flags = vnic->hash_mode;
2185 req.hash_key_tbl_addr =
2186 rte_cpu_to_le_64(vnic->rss_hash_key_dma_addr);
2188 req.ring_grp_tbl_addr =
2189 rte_cpu_to_le_64(vnic->rss_table_dma_addr +
2190 i * HW_HASH_INDEX_SIZE);
2191 req.ring_table_pair_index = i;
2192 req.rss_ctx_idx = rte_cpu_to_le_16(vnic->fw_grp_ids[i]);
2194 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req),
2197 HWRM_CHECK_RESULT();
2204 int bnxt_hwrm_vnic_rss_cfg(struct bnxt *bp,
2205 struct bnxt_vnic_info *vnic)
2208 struct hwrm_vnic_rss_cfg_input req = {.req_type = 0 };
2209 struct hwrm_vnic_rss_cfg_output *resp = bp->hwrm_cmd_resp_addr;
2211 if (!vnic->rss_table)
2214 if (BNXT_CHIP_P5(bp))
2215 return bnxt_hwrm_vnic_rss_cfg_p5(bp, vnic);
2217 HWRM_PREP(&req, HWRM_VNIC_RSS_CFG, BNXT_USE_CHIMP_MB);
2219 req.hash_type = rte_cpu_to_le_32(vnic->hash_type);
2220 req.hash_mode_flags = vnic->hash_mode;
2222 req.ring_grp_tbl_addr =
2223 rte_cpu_to_le_64(vnic->rss_table_dma_addr);
2224 req.hash_key_tbl_addr =
2225 rte_cpu_to_le_64(vnic->rss_hash_key_dma_addr);
2226 req.rss_ctx_idx = rte_cpu_to_le_16(vnic->rss_rule);
2227 req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
2229 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2231 HWRM_CHECK_RESULT();
2237 int bnxt_hwrm_vnic_plcmode_cfg(struct bnxt *bp,
2238 struct bnxt_vnic_info *vnic)
2241 struct hwrm_vnic_plcmodes_cfg_input req = {.req_type = 0 };
2242 struct hwrm_vnic_plcmodes_cfg_output *resp = bp->hwrm_cmd_resp_addr;
2245 if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
2246 PMD_DRV_LOG(DEBUG, "VNIC ID %x\n", vnic->fw_vnic_id);
2250 HWRM_PREP(&req, HWRM_VNIC_PLCMODES_CFG, BNXT_USE_CHIMP_MB);
2252 req.flags = rte_cpu_to_le_32(
2253 HWRM_VNIC_PLCMODES_CFG_INPUT_FLAGS_JUMBO_PLACEMENT);
2255 req.enables = rte_cpu_to_le_32(
2256 HWRM_VNIC_PLCMODES_CFG_INPUT_ENABLES_JUMBO_THRESH_VALID);
2258 size = rte_pktmbuf_data_room_size(bp->rx_queues[0]->mb_pool);
2259 size -= RTE_PKTMBUF_HEADROOM;
2260 size = RTE_MIN(BNXT_MAX_PKT_LEN, size);
2262 req.jumbo_thresh = rte_cpu_to_le_16(size);
2263 req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
2265 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2267 HWRM_CHECK_RESULT();
2273 int bnxt_hwrm_vnic_tpa_cfg(struct bnxt *bp,
2274 struct bnxt_vnic_info *vnic, bool enable)
2277 struct hwrm_vnic_tpa_cfg_input req = {.req_type = 0 };
2278 struct hwrm_vnic_tpa_cfg_output *resp = bp->hwrm_cmd_resp_addr;
2280 if (BNXT_CHIP_P5(bp) && !bp->max_tpa_v2) {
2282 PMD_DRV_LOG(ERR, "No HW support for LRO\n");
2286 if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
2287 PMD_DRV_LOG(DEBUG, "Invalid vNIC ID\n");
2291 HWRM_PREP(&req, HWRM_VNIC_TPA_CFG, BNXT_USE_CHIMP_MB);
2294 req.enables = rte_cpu_to_le_32(
2295 HWRM_VNIC_TPA_CFG_INPUT_ENABLES_MAX_AGG_SEGS |
2296 HWRM_VNIC_TPA_CFG_INPUT_ENABLES_MAX_AGGS |
2297 HWRM_VNIC_TPA_CFG_INPUT_ENABLES_MIN_AGG_LEN);
2298 req.flags = rte_cpu_to_le_32(
2299 HWRM_VNIC_TPA_CFG_INPUT_FLAGS_TPA |
2300 HWRM_VNIC_TPA_CFG_INPUT_FLAGS_ENCAP_TPA |
2301 HWRM_VNIC_TPA_CFG_INPUT_FLAGS_RSC_WND_UPDATE |
2302 HWRM_VNIC_TPA_CFG_INPUT_FLAGS_GRO |
2303 HWRM_VNIC_TPA_CFG_INPUT_FLAGS_AGG_WITH_ECN |
2304 HWRM_VNIC_TPA_CFG_INPUT_FLAGS_AGG_WITH_SAME_GRE_SEQ);
2305 req.max_aggs = rte_cpu_to_le_16(BNXT_TPA_MAX_AGGS(bp));
2306 req.max_agg_segs = rte_cpu_to_le_16(BNXT_TPA_MAX_SEGS(bp));
2307 req.min_agg_len = rte_cpu_to_le_32(512);
2309 req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
2311 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2313 HWRM_CHECK_RESULT();
2319 int bnxt_hwrm_func_vf_mac(struct bnxt *bp, uint16_t vf, const uint8_t *mac_addr)
2321 struct hwrm_func_cfg_input req = {0};
2322 struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
2325 req.flags = rte_cpu_to_le_32(bp->pf->vf_info[vf].func_cfg_flags);
2326 req.enables = rte_cpu_to_le_32(
2327 HWRM_FUNC_CFG_INPUT_ENABLES_DFLT_MAC_ADDR);
2328 memcpy(req.dflt_mac_addr, mac_addr, sizeof(req.dflt_mac_addr));
2329 req.fid = rte_cpu_to_le_16(bp->pf->vf_info[vf].fid);
2331 HWRM_PREP(&req, HWRM_FUNC_CFG, BNXT_USE_CHIMP_MB);
2333 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2334 HWRM_CHECK_RESULT();
2337 bp->pf->vf_info[vf].random_mac = false;
2342 int bnxt_hwrm_func_qstats_tx_drop(struct bnxt *bp, uint16_t fid,
2346 struct hwrm_func_qstats_input req = {.req_type = 0};
2347 struct hwrm_func_qstats_output *resp = bp->hwrm_cmd_resp_addr;
2349 HWRM_PREP(&req, HWRM_FUNC_QSTATS, BNXT_USE_CHIMP_MB);
2351 req.fid = rte_cpu_to_le_16(fid);
2353 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2355 HWRM_CHECK_RESULT();
2358 *dropped = rte_le_to_cpu_64(resp->tx_drop_pkts);
2365 int bnxt_hwrm_func_qstats(struct bnxt *bp, uint16_t fid,
2366 struct rte_eth_stats *stats,
2367 struct hwrm_func_qstats_output *func_qstats)
2370 struct hwrm_func_qstats_input req = {.req_type = 0};
2371 struct hwrm_func_qstats_output *resp = bp->hwrm_cmd_resp_addr;
2373 HWRM_PREP(&req, HWRM_FUNC_QSTATS, BNXT_USE_CHIMP_MB);
2375 req.fid = rte_cpu_to_le_16(fid);
2377 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2379 HWRM_CHECK_RESULT();
2381 memcpy(func_qstats, resp,
2382 sizeof(struct hwrm_func_qstats_output));
2387 stats->ipackets = rte_le_to_cpu_64(resp->rx_ucast_pkts);
2388 stats->ipackets += rte_le_to_cpu_64(resp->rx_mcast_pkts);
2389 stats->ipackets += rte_le_to_cpu_64(resp->rx_bcast_pkts);
2390 stats->ibytes = rte_le_to_cpu_64(resp->rx_ucast_bytes);
2391 stats->ibytes += rte_le_to_cpu_64(resp->rx_mcast_bytes);
2392 stats->ibytes += rte_le_to_cpu_64(resp->rx_bcast_bytes);
2394 stats->opackets = rte_le_to_cpu_64(resp->tx_ucast_pkts);
2395 stats->opackets += rte_le_to_cpu_64(resp->tx_mcast_pkts);
2396 stats->opackets += rte_le_to_cpu_64(resp->tx_bcast_pkts);
2397 stats->obytes = rte_le_to_cpu_64(resp->tx_ucast_bytes);
2398 stats->obytes += rte_le_to_cpu_64(resp->tx_mcast_bytes);
2399 stats->obytes += rte_le_to_cpu_64(resp->tx_bcast_bytes);
2401 stats->imissed = rte_le_to_cpu_64(resp->rx_discard_pkts);
2402 stats->ierrors = rte_le_to_cpu_64(resp->rx_drop_pkts);
2403 stats->oerrors = rte_le_to_cpu_64(resp->tx_discard_pkts);
2411 int bnxt_hwrm_func_clr_stats(struct bnxt *bp, uint16_t fid)
2414 struct hwrm_func_clr_stats_input req = {.req_type = 0};
2415 struct hwrm_func_clr_stats_output *resp = bp->hwrm_cmd_resp_addr;
2417 HWRM_PREP(&req, HWRM_FUNC_CLR_STATS, BNXT_USE_CHIMP_MB);
2419 req.fid = rte_cpu_to_le_16(fid);
2421 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
2423 HWRM_CHECK_RESULT();
2429 int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp)
2434 for (i = 0; i < bp->rx_cp_nr_rings + bp->tx_cp_nr_rings; i++) {
2435 struct bnxt_tx_queue *txq;
2436 struct bnxt_rx_queue *rxq;
2437 struct bnxt_cp_ring_info *cpr;
2439 if (i >= bp->rx_cp_nr_rings) {
2440 txq = bp->tx_queues[i - bp->rx_cp_nr_rings];
2443 rxq = bp->rx_queues[i];
2447 rc = bnxt_hwrm_stat_clear(bp, cpr);
2455 bnxt_free_all_hwrm_stat_ctxs(struct bnxt *bp)
2459 struct bnxt_cp_ring_info *cpr;
2461 for (i = 0; i < bp->rx_cp_nr_rings + bp->tx_cp_nr_rings; i++) {
2463 if (i >= bp->rx_cp_nr_rings) {
2464 cpr = bp->tx_queues[i - bp->rx_cp_nr_rings]->cp_ring;
2466 cpr = bp->rx_queues[i]->cp_ring;
2467 if (BNXT_HAS_RING_GRPS(bp))
2468 bp->grp_info[i].fw_stats_ctx = -1;
2470 if (cpr->hw_stats_ctx_id != HWRM_NA_SIGNATURE) {
2471 rc = bnxt_hwrm_stat_ctx_free(bp, cpr, i);
2472 cpr->hw_stats_ctx_id = HWRM_NA_SIGNATURE;
2480 int bnxt_alloc_all_hwrm_stat_ctxs(struct bnxt *bp)
2485 for (i = 0; i < bp->rx_cp_nr_rings + bp->tx_cp_nr_rings; i++) {
2486 struct bnxt_tx_queue *txq;
2487 struct bnxt_rx_queue *rxq;
2488 struct bnxt_cp_ring_info *cpr;
2490 if (i >= bp->rx_cp_nr_rings) {
2491 txq = bp->tx_queues[i - bp->rx_cp_nr_rings];
2494 rxq = bp->rx_queues[i];
2498 rc = bnxt_hwrm_stat_ctx_alloc(bp, cpr, i);
2507 bnxt_free_all_hwrm_ring_grps(struct bnxt *bp)
2512 if (!BNXT_HAS_RING_GRPS(bp))
2515 for (idx = 0; idx < bp->rx_cp_nr_rings; idx++) {
2517 if (bp->grp_info[idx].fw_grp_id == INVALID_HW_RING_ID)
2520 rc = bnxt_hwrm_ring_grp_free(bp, idx);
2528 void bnxt_free_nq_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)
2530 struct bnxt_ring *cp_ring = cpr->cp_ring_struct;
2532 bnxt_hwrm_ring_free(bp, cp_ring,
2533 HWRM_RING_FREE_INPUT_RING_TYPE_NQ);
2534 cp_ring->fw_ring_id = INVALID_HW_RING_ID;
2535 memset(cpr->cp_desc_ring, 0, cpr->cp_ring_struct->ring_size *
2536 sizeof(*cpr->cp_desc_ring));
2537 cpr->cp_raw_cons = 0;
2541 void bnxt_free_cp_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)
2543 struct bnxt_ring *cp_ring = cpr->cp_ring_struct;
2545 bnxt_hwrm_ring_free(bp, cp_ring,
2546 HWRM_RING_FREE_INPUT_RING_TYPE_L2_CMPL);
2547 cp_ring->fw_ring_id = INVALID_HW_RING_ID;
2548 memset(cpr->cp_desc_ring, 0, cpr->cp_ring_struct->ring_size *
2549 sizeof(*cpr->cp_desc_ring));
2550 cpr->cp_raw_cons = 0;
2554 void bnxt_free_hwrm_rx_ring(struct bnxt *bp, int queue_index)
2556 struct bnxt_rx_queue *rxq = bp->rx_queues[queue_index];
2557 struct bnxt_rx_ring_info *rxr = rxq->rx_ring;
2558 struct bnxt_ring *ring = rxr->rx_ring_struct;
2559 struct bnxt_cp_ring_info *cpr = rxq->cp_ring;
2561 if (ring->fw_ring_id != INVALID_HW_RING_ID) {
2562 bnxt_hwrm_ring_free(bp, ring,
2563 HWRM_RING_FREE_INPUT_RING_TYPE_RX);
2564 ring->fw_ring_id = INVALID_HW_RING_ID;
2565 if (BNXT_HAS_RING_GRPS(bp))
2566 bp->grp_info[queue_index].rx_fw_ring_id =
2569 ring = rxr->ag_ring_struct;
2570 if (ring->fw_ring_id != INVALID_HW_RING_ID) {
2571 bnxt_hwrm_ring_free(bp, ring,
2573 HWRM_RING_FREE_INPUT_RING_TYPE_RX_AGG :
2574 HWRM_RING_FREE_INPUT_RING_TYPE_RX);
2575 if (BNXT_HAS_RING_GRPS(bp))
2576 bp->grp_info[queue_index].ag_fw_ring_id =
2579 if (cpr->cp_ring_struct->fw_ring_id != INVALID_HW_RING_ID)
2580 bnxt_free_cp_ring(bp, cpr);
2582 if (BNXT_HAS_RING_GRPS(bp))
2583 bp->grp_info[queue_index].cp_fw_ring_id = INVALID_HW_RING_ID;
2587 bnxt_free_all_hwrm_rings(struct bnxt *bp)
2591 for (i = 0; i < bp->tx_cp_nr_rings; i++) {
2592 struct bnxt_tx_queue *txq = bp->tx_queues[i];
2593 struct bnxt_tx_ring_info *txr = txq->tx_ring;
2594 struct bnxt_ring *ring = txr->tx_ring_struct;
2595 struct bnxt_cp_ring_info *cpr = txq->cp_ring;
2597 if (ring->fw_ring_id != INVALID_HW_RING_ID) {
2598 bnxt_hwrm_ring_free(bp, ring,
2599 HWRM_RING_FREE_INPUT_RING_TYPE_TX);
2600 ring->fw_ring_id = INVALID_HW_RING_ID;
2601 memset(txr->tx_desc_ring, 0,
2602 txr->tx_ring_struct->ring_size *
2603 sizeof(*txr->tx_desc_ring));
2604 memset(txr->tx_buf_ring, 0,
2605 txr->tx_ring_struct->ring_size *
2606 sizeof(*txr->tx_buf_ring));
2607 txr->tx_raw_prod = 0;
2608 txr->tx_raw_cons = 0;
2610 if (cpr->cp_ring_struct->fw_ring_id != INVALID_HW_RING_ID) {
2611 bnxt_free_cp_ring(bp, cpr);
2612 cpr->cp_ring_struct->fw_ring_id = INVALID_HW_RING_ID;
2616 for (i = 0; i < bp->rx_cp_nr_rings; i++)
2617 bnxt_free_hwrm_rx_ring(bp, i);
2622 int bnxt_alloc_all_hwrm_ring_grps(struct bnxt *bp)
2627 if (!BNXT_HAS_RING_GRPS(bp))
2630 for (i = 0; i < bp->rx_cp_nr_rings; i++) {
2631 rc = bnxt_hwrm_ring_grp_alloc(bp, i);
2639 * HWRM utility functions
2642 void bnxt_free_hwrm_resources(struct bnxt *bp)
2644 /* Release memzone */
2645 rte_free(bp->hwrm_cmd_resp_addr);
2646 rte_free(bp->hwrm_short_cmd_req_addr);
2647 bp->hwrm_cmd_resp_addr = NULL;
2648 bp->hwrm_short_cmd_req_addr = NULL;
2649 bp->hwrm_cmd_resp_dma_addr = 0;
2650 bp->hwrm_short_cmd_req_dma_addr = 0;
2653 int bnxt_alloc_hwrm_resources(struct bnxt *bp)
2655 struct rte_pci_device *pdev = bp->pdev;
2656 char type[RTE_MEMZONE_NAMESIZE];
2658 sprintf(type, "bnxt_hwrm_" PCI_PRI_FMT, pdev->addr.domain,
2659 pdev->addr.bus, pdev->addr.devid, pdev->addr.function);
2660 bp->max_resp_len = HWRM_MAX_RESP_LEN;
2661 bp->hwrm_cmd_resp_addr = rte_malloc(type, bp->max_resp_len, 0);
2662 if (bp->hwrm_cmd_resp_addr == NULL)
2664 bp->hwrm_cmd_resp_dma_addr =
2665 rte_malloc_virt2iova(bp->hwrm_cmd_resp_addr);
2666 if (bp->hwrm_cmd_resp_dma_addr == RTE_BAD_IOVA) {
2668 "unable to map response address to physical memory\n");
2671 rte_spinlock_init(&bp->hwrm_lock);
2677 bnxt_clear_one_vnic_filter(struct bnxt *bp, struct bnxt_filter_info *filter)
2681 if (filter->filter_type == HWRM_CFA_EM_FILTER) {
2682 rc = bnxt_hwrm_clear_em_filter(bp, filter);
2685 } else if (filter->filter_type == HWRM_CFA_NTUPLE_FILTER) {
2686 rc = bnxt_hwrm_clear_ntuple_filter(bp, filter);
2691 rc = bnxt_hwrm_clear_l2_filter(bp, filter);
2696 bnxt_clear_hwrm_vnic_filters(struct bnxt *bp, struct bnxt_vnic_info *vnic)
2698 struct bnxt_filter_info *filter;
2701 STAILQ_FOREACH(filter, &vnic->filter, next) {
2702 rc = bnxt_clear_one_vnic_filter(bp, filter);
2703 STAILQ_REMOVE(&vnic->filter, filter, bnxt_filter_info, next);
2704 bnxt_free_filter(bp, filter);
2710 bnxt_clear_hwrm_vnic_flows(struct bnxt *bp, struct bnxt_vnic_info *vnic)
2712 struct bnxt_filter_info *filter;
2713 struct rte_flow *flow;
2716 while (!STAILQ_EMPTY(&vnic->flow_list)) {
2717 flow = STAILQ_FIRST(&vnic->flow_list);
2718 filter = flow->filter;
2719 PMD_DRV_LOG(DEBUG, "filter type %d\n", filter->filter_type);
2720 rc = bnxt_clear_one_vnic_filter(bp, filter);
2722 STAILQ_REMOVE(&vnic->flow_list, flow, rte_flow, next);
2728 int bnxt_set_hwrm_vnic_filters(struct bnxt *bp, struct bnxt_vnic_info *vnic)
2730 struct bnxt_filter_info *filter;
2733 STAILQ_FOREACH(filter, &vnic->filter, next) {
2734 if (filter->filter_type == HWRM_CFA_EM_FILTER)
2735 rc = bnxt_hwrm_set_em_filter(bp, filter->dst_id,
2737 else if (filter->filter_type == HWRM_CFA_NTUPLE_FILTER)
2738 rc = bnxt_hwrm_set_ntuple_filter(bp, filter->dst_id,
2741 rc = bnxt_hwrm_set_l2_filter(bp, vnic->fw_vnic_id,
2750 bnxt_free_tunnel_ports(struct bnxt *bp)
2752 if (bp->vxlan_port_cnt)
2753 bnxt_hwrm_tunnel_dst_port_free(bp, bp->vxlan_fw_dst_port_id,
2754 HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_VXLAN);
2756 if (bp->geneve_port_cnt)
2757 bnxt_hwrm_tunnel_dst_port_free(bp, bp->geneve_fw_dst_port_id,
2758 HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_GENEVE);
2761 void bnxt_free_all_hwrm_resources(struct bnxt *bp)
2765 if (bp->vnic_info == NULL)
2769 * Cleanup VNICs in reverse order, to make sure the L2 filter
2770 * from vnic0 is last to be cleaned up.
2772 for (i = bp->max_vnics - 1; i >= 0; i--) {
2773 struct bnxt_vnic_info *vnic = &bp->vnic_info[i];
2775 if (vnic->fw_vnic_id == INVALID_HW_RING_ID)
2778 bnxt_clear_hwrm_vnic_flows(bp, vnic);
2780 bnxt_clear_hwrm_vnic_filters(bp, vnic);
2782 bnxt_hwrm_vnic_ctx_free(bp, vnic);
2784 bnxt_hwrm_vnic_tpa_cfg(bp, vnic, false);
2786 bnxt_hwrm_vnic_free(bp, vnic);
2788 rte_free(vnic->fw_grp_ids);
2790 /* Ring resources */
2791 bnxt_free_all_hwrm_rings(bp);
2792 bnxt_free_all_hwrm_ring_grps(bp);
2793 bnxt_free_all_hwrm_stat_ctxs(bp);
2794 bnxt_free_tunnel_ports(bp);
2797 static uint16_t bnxt_parse_eth_link_duplex(uint32_t conf_link_speed)
2799 uint8_t hw_link_duplex = HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_BOTH;
2801 if ((conf_link_speed & ETH_LINK_SPEED_FIXED) == ETH_LINK_SPEED_AUTONEG)
2802 return HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_BOTH;
2804 switch (conf_link_speed) {
2805 case ETH_LINK_SPEED_10M_HD:
2806 case ETH_LINK_SPEED_100M_HD:
2808 return HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_HALF;
2810 return hw_link_duplex;
2813 static uint16_t bnxt_check_eth_link_autoneg(uint32_t conf_link)
2818 static uint16_t bnxt_parse_eth_link_speed(uint32_t conf_link_speed,
2821 uint16_t eth_link_speed = 0;
2823 if (conf_link_speed == ETH_LINK_SPEED_AUTONEG)
2824 return ETH_LINK_SPEED_AUTONEG;
2826 switch (conf_link_speed & ~ETH_LINK_SPEED_FIXED) {
2827 case ETH_LINK_SPEED_100M:
2828 case ETH_LINK_SPEED_100M_HD:
2831 HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_100MB;
2833 case ETH_LINK_SPEED_1G:
2835 HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_1GB;
2837 case ETH_LINK_SPEED_2_5G:
2839 HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_2_5GB;
2841 case ETH_LINK_SPEED_10G:
2843 HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_10GB;
2845 case ETH_LINK_SPEED_20G:
2847 HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_20GB;
2849 case ETH_LINK_SPEED_25G:
2851 HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_25GB;
2853 case ETH_LINK_SPEED_40G:
2855 HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_40GB;
2857 case ETH_LINK_SPEED_50G:
2858 eth_link_speed = pam4_link ?
2859 HWRM_PORT_PHY_CFG_INPUT_FORCE_PAM4_LINK_SPEED_50GB :
2860 HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_50GB;
2862 case ETH_LINK_SPEED_100G:
2863 eth_link_speed = pam4_link ?
2864 HWRM_PORT_PHY_CFG_INPUT_FORCE_PAM4_LINK_SPEED_100GB :
2865 HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_100GB;
2867 case ETH_LINK_SPEED_200G:
2869 HWRM_PORT_PHY_CFG_INPUT_FORCE_PAM4_LINK_SPEED_200GB;
2873 "Unsupported link speed %d; default to AUTO\n",
2877 return eth_link_speed;
2880 #define BNXT_SUPPORTED_SPEEDS (ETH_LINK_SPEED_100M | ETH_LINK_SPEED_100M_HD | \
2881 ETH_LINK_SPEED_1G | ETH_LINK_SPEED_2_5G | \
2882 ETH_LINK_SPEED_10G | ETH_LINK_SPEED_20G | ETH_LINK_SPEED_25G | \
2883 ETH_LINK_SPEED_40G | ETH_LINK_SPEED_50G | \
2884 ETH_LINK_SPEED_100G | ETH_LINK_SPEED_200G)
2886 static int bnxt_validate_link_speed(struct bnxt *bp)
2888 uint32_t link_speed = bp->eth_dev->data->dev_conf.link_speeds;
2889 uint16_t port_id = bp->eth_dev->data->port_id;
2890 uint32_t link_speed_capa;
2893 if (link_speed == ETH_LINK_SPEED_AUTONEG)
2896 link_speed_capa = bnxt_get_speed_capabilities(bp);
2898 if (link_speed & ETH_LINK_SPEED_FIXED) {
2899 one_speed = link_speed & ~ETH_LINK_SPEED_FIXED;
2901 if (one_speed & (one_speed - 1)) {
2903 "Invalid advertised speeds (%u) for port %u\n",
2904 link_speed, port_id);
2907 if ((one_speed & link_speed_capa) != one_speed) {
2909 "Unsupported advertised speed (%u) for port %u\n",
2910 link_speed, port_id);
2914 if (!(link_speed & link_speed_capa)) {
2916 "Unsupported advertised speeds (%u) for port %u\n",
2917 link_speed, port_id);
2925 bnxt_parse_eth_link_speed_mask(struct bnxt *bp, uint32_t link_speed)
2929 if (link_speed == ETH_LINK_SPEED_AUTONEG) {
2930 if (bp->link_info->support_speeds)
2931 return bp->link_info->support_speeds;
2932 link_speed = BNXT_SUPPORTED_SPEEDS;
2935 if (link_speed & ETH_LINK_SPEED_100M)
2936 ret |= HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_100MB;
2937 if (link_speed & ETH_LINK_SPEED_100M_HD)
2938 ret |= HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_100MB;
2939 if (link_speed & ETH_LINK_SPEED_1G)
2940 ret |= HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_1GB;
2941 if (link_speed & ETH_LINK_SPEED_2_5G)
2942 ret |= HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_2_5GB;
2943 if (link_speed & ETH_LINK_SPEED_10G)
2944 ret |= HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_10GB;
2945 if (link_speed & ETH_LINK_SPEED_20G)
2946 ret |= HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_20GB;
2947 if (link_speed & ETH_LINK_SPEED_25G)
2948 ret |= HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_25GB;
2949 if (link_speed & ETH_LINK_SPEED_40G)
2950 ret |= HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_40GB;
2951 if (link_speed & ETH_LINK_SPEED_50G)
2952 ret |= HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_50GB;
2953 if (link_speed & ETH_LINK_SPEED_100G)
2954 ret |= HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_100GB;
2955 if (link_speed & ETH_LINK_SPEED_200G)
2956 ret |= HWRM_PORT_PHY_CFG_INPUT_FORCE_PAM4_LINK_SPEED_200GB;
2960 static uint32_t bnxt_parse_hw_link_speed(uint16_t hw_link_speed)
2962 uint32_t eth_link_speed = ETH_SPEED_NUM_NONE;
2964 switch (hw_link_speed) {
2965 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_100MB:
2966 eth_link_speed = ETH_SPEED_NUM_100M;
2968 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_1GB:
2969 eth_link_speed = ETH_SPEED_NUM_1G;
2971 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_2_5GB:
2972 eth_link_speed = ETH_SPEED_NUM_2_5G;
2974 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_10GB:
2975 eth_link_speed = ETH_SPEED_NUM_10G;
2977 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_20GB:
2978 eth_link_speed = ETH_SPEED_NUM_20G;
2980 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_25GB:
2981 eth_link_speed = ETH_SPEED_NUM_25G;
2983 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_40GB:
2984 eth_link_speed = ETH_SPEED_NUM_40G;
2986 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_50GB:
2987 eth_link_speed = ETH_SPEED_NUM_50G;
2989 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_100GB:
2990 eth_link_speed = ETH_SPEED_NUM_100G;
2992 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_200GB:
2993 eth_link_speed = ETH_SPEED_NUM_200G;
2995 case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_2GB:
2997 PMD_DRV_LOG(ERR, "HWRM link speed %d not defined\n",
3001 return eth_link_speed;
3004 static uint16_t bnxt_parse_hw_link_duplex(uint16_t hw_link_duplex)
3006 uint16_t eth_link_duplex = ETH_LINK_FULL_DUPLEX;
3008 switch (hw_link_duplex) {
3009 case HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_BOTH:
3010 case HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_FULL:
3012 eth_link_duplex = ETH_LINK_FULL_DUPLEX;
3014 case HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_HALF:
3015 eth_link_duplex = ETH_LINK_HALF_DUPLEX;
3018 PMD_DRV_LOG(ERR, "HWRM link duplex %d not defined\n",
3022 return eth_link_duplex;
3025 int bnxt_get_hwrm_link_config(struct bnxt *bp, struct rte_eth_link *link)
3028 struct bnxt_link_info *link_info = bp->link_info;
3030 rc = bnxt_hwrm_port_phy_qcaps(bp);
3032 PMD_DRV_LOG(ERR, "Get link config failed with rc %d\n", rc);
3034 rc = bnxt_hwrm_port_phy_qcfg(bp, link_info);
3036 PMD_DRV_LOG(ERR, "Get link config failed with rc %d\n", rc);
3040 if (link_info->link_speed)
3042 bnxt_parse_hw_link_speed(link_info->link_speed);
3044 link->link_speed = ETH_SPEED_NUM_NONE;
3045 link->link_duplex = bnxt_parse_hw_link_duplex(link_info->duplex);
3046 link->link_status = link_info->link_up;
3047 link->link_autoneg = link_info->auto_mode ==
3048 HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_MODE_NONE ?
3049 ETH_LINK_FIXED : ETH_LINK_AUTONEG;
3054 int bnxt_set_hwrm_link_config(struct bnxt *bp, bool link_up)
3057 struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf;
3058 struct bnxt_link_info link_req;
3059 uint16_t speed, autoneg;
3061 if (!BNXT_SINGLE_PF(bp) || BNXT_VF(bp))
3064 rc = bnxt_validate_link_speed(bp);
3068 memset(&link_req, 0, sizeof(link_req));
3069 link_req.link_up = link_up;
3073 autoneg = bnxt_check_eth_link_autoneg(dev_conf->link_speeds);
3074 if (BNXT_CHIP_P5(bp) &&
3075 dev_conf->link_speeds == ETH_LINK_SPEED_40G) {
3076 /* 40G is not supported as part of media auto detect.
3077 * The speed should be forced and autoneg disabled
3078 * to configure 40G speed.
3080 PMD_DRV_LOG(INFO, "Disabling autoneg for 40G\n");
3084 /* No auto speeds and no auto_pam4_link. Disable autoneg */
3085 if (bp->link_info->auto_link_speed == 0 &&
3086 bp->link_info->link_signal_mode &&
3087 bp->link_info->auto_pam4_link_speeds == 0)
3090 speed = bnxt_parse_eth_link_speed(dev_conf->link_speeds,
3091 bp->link_info->link_signal_mode);
3092 link_req.phy_flags = HWRM_PORT_PHY_CFG_INPUT_FLAGS_RESET_PHY;
3093 /* Autoneg can be done only when the FW allows.
3094 * When user configures fixed speed of 40G and later changes to
3095 * any other speed, auto_link_speed/force_link_speed is still set
3096 * to 40G until link comes up at new speed.
3099 !(!BNXT_CHIP_P5(bp) &&
3100 (bp->link_info->auto_link_speed ||
3101 bp->link_info->force_link_speed))) {
3102 link_req.phy_flags |=
3103 HWRM_PORT_PHY_CFG_INPUT_FLAGS_RESTART_AUTONEG;
3104 link_req.auto_link_speed_mask =
3105 bnxt_parse_eth_link_speed_mask(bp,
3106 dev_conf->link_speeds);
3108 if (bp->link_info->phy_type ==
3109 HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASET ||
3110 bp->link_info->phy_type ==
3111 HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASETE ||
3112 bp->link_info->media_type ==
3113 HWRM_PORT_PHY_QCFG_OUTPUT_MEDIA_TYPE_TP) {
3114 PMD_DRV_LOG(ERR, "10GBase-T devices must autoneg\n");
3118 link_req.phy_flags |= HWRM_PORT_PHY_CFG_INPUT_FLAGS_FORCE;
3119 /* If user wants a particular speed try that first. */
3121 link_req.link_speed = speed;
3122 else if (bp->link_info->force_pam4_link_speed)
3123 link_req.link_speed =
3124 bp->link_info->force_pam4_link_speed;
3125 else if (bp->link_info->auto_pam4_link_speeds)
3126 link_req.link_speed =
3127 bp->link_info->auto_pam4_link_speeds;
3128 else if (bp->link_info->support_pam4_speeds)
3129 link_req.link_speed =
3130 bp->link_info->support_pam4_speeds;
3131 else if (bp->link_info->force_link_speed)
3132 link_req.link_speed = bp->link_info->force_link_speed;
3134 link_req.link_speed = bp->link_info->auto_link_speed;
3135 /* Auto PAM4 link speed is zero, but auto_link_speed is not
3136 * zero. Use the auto_link_speed.
3138 if (bp->link_info->auto_link_speed != 0 &&
3139 bp->link_info->auto_pam4_link_speeds == 0)
3140 link_req.link_speed = bp->link_info->auto_link_speed;
3142 link_req.duplex = bnxt_parse_eth_link_duplex(dev_conf->link_speeds);
3143 link_req.auto_pause = bp->link_info->auto_pause;
3144 link_req.force_pause = bp->link_info->force_pause;
3147 rc = bnxt_hwrm_port_phy_cfg(bp, &link_req);
3150 "Set link config failed with rc %d\n", rc);
3158 int bnxt_hwrm_func_qcfg(struct bnxt *bp, uint16_t *mtu)
3160 struct hwrm_func_qcfg_input req = {0};
3161 struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
3164 bp->func_svif = BNXT_SVIF_INVALID;
3167 HWRM_PREP(&req, HWRM_FUNC_QCFG, BNXT_USE_CHIMP_MB);
3168 req.fid = rte_cpu_to_le_16(0xffff);
3170 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3172 HWRM_CHECK_RESULT();
3174 /* Hard Coded.. 0xfff VLAN ID mask */
3175 bp->vlan = rte_le_to_cpu_16(resp->vlan) & 0xfff;
3177 svif_info = rte_le_to_cpu_16(resp->svif_info);
3178 if (svif_info & HWRM_FUNC_QCFG_OUTPUT_SVIF_INFO_SVIF_VALID)
3179 bp->func_svif = svif_info &
3180 HWRM_FUNC_QCFG_OUTPUT_SVIF_INFO_SVIF_MASK;
3182 flags = rte_le_to_cpu_16(resp->flags);
3183 if (BNXT_PF(bp) && (flags & HWRM_FUNC_QCFG_OUTPUT_FLAGS_MULTI_HOST))
3184 bp->flags |= BNXT_FLAG_MULTI_HOST;
3187 !BNXT_VF_IS_TRUSTED(bp) &&
3188 (flags & HWRM_FUNC_QCFG_OUTPUT_FLAGS_TRUSTED_VF)) {
3189 bp->flags |= BNXT_FLAG_TRUSTED_VF_EN;
3190 PMD_DRV_LOG(INFO, "Trusted VF cap enabled\n");
3191 } else if (BNXT_VF(bp) &&
3192 BNXT_VF_IS_TRUSTED(bp) &&
3193 !(flags & HWRM_FUNC_QCFG_OUTPUT_FLAGS_TRUSTED_VF)) {
3194 bp->flags &= ~BNXT_FLAG_TRUSTED_VF_EN;
3195 PMD_DRV_LOG(INFO, "Trusted VF cap disabled\n");
3199 *mtu = rte_le_to_cpu_16(resp->mtu);
3201 switch (resp->port_partition_type) {
3202 case HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_NPAR1_0:
3203 case HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_NPAR1_5:
3204 case HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_NPAR2_0:
3206 bp->flags |= BNXT_FLAG_NPAR_PF;
3209 bp->flags &= ~BNXT_FLAG_NPAR_PF;
3213 bp->legacy_db_size =
3214 rte_le_to_cpu_16(resp->legacy_l2_db_size_kb) * 1024;
3221 int bnxt_hwrm_parent_pf_qcfg(struct bnxt *bp)
3223 struct hwrm_func_qcfg_input req = {0};
3224 struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
3227 if (!BNXT_VF_IS_TRUSTED(bp))
3233 bp->parent->fid = BNXT_PF_FID_INVALID;
3235 HWRM_PREP(&req, HWRM_FUNC_QCFG, BNXT_USE_CHIMP_MB);
3237 req.fid = rte_cpu_to_le_16(0xfffe); /* Request parent PF information. */
3239 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3241 HWRM_CHECK_RESULT();
3243 memcpy(bp->parent->mac_addr, resp->mac_address, RTE_ETHER_ADDR_LEN);
3244 bp->parent->vnic = rte_le_to_cpu_16(resp->dflt_vnic_id);
3245 bp->parent->fid = rte_le_to_cpu_16(resp->fid);
3246 bp->parent->port_id = rte_le_to_cpu_16(resp->port_id);
3248 /* FIXME: Temporary workaround - remove when firmware issue is fixed. */
3249 if (bp->parent->vnic == 0) {
3250 PMD_DRV_LOG(ERR, "Error: parent VNIC unavailable.\n");
3251 /* Use hard-coded values appropriate for current Wh+ fw. */
3252 if (bp->parent->fid == 2)
3253 bp->parent->vnic = 0x100;
3255 bp->parent->vnic = 1;
3263 int bnxt_hwrm_get_dflt_vnic_svif(struct bnxt *bp, uint16_t fid,
3264 uint16_t *vnic_id, uint16_t *svif)
3266 struct hwrm_func_qcfg_input req = {0};
3267 struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
3271 HWRM_PREP(&req, HWRM_FUNC_QCFG, BNXT_USE_CHIMP_MB);
3272 req.fid = rte_cpu_to_le_16(fid);
3274 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3276 HWRM_CHECK_RESULT();
3279 *vnic_id = rte_le_to_cpu_16(resp->dflt_vnic_id);
3281 svif_info = rte_le_to_cpu_16(resp->svif_info);
3282 if (svif && (svif_info & HWRM_FUNC_QCFG_OUTPUT_SVIF_INFO_SVIF_VALID))
3283 *svif = svif_info & HWRM_FUNC_QCFG_OUTPUT_SVIF_INFO_SVIF_MASK;
3290 int bnxt_hwrm_port_mac_qcfg(struct bnxt *bp)
3292 struct hwrm_port_mac_qcfg_input req = {0};
3293 struct hwrm_port_mac_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
3294 uint16_t port_svif_info;
3297 bp->port_svif = BNXT_SVIF_INVALID;
3299 if (BNXT_VF(bp) && !BNXT_VF_IS_TRUSTED(bp))
3302 HWRM_PREP(&req, HWRM_PORT_MAC_QCFG, BNXT_USE_CHIMP_MB);
3304 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3306 HWRM_CHECK_RESULT_SILENT();
3308 port_svif_info = rte_le_to_cpu_16(resp->port_svif_info);
3309 if (port_svif_info &
3310 HWRM_PORT_MAC_QCFG_OUTPUT_PORT_SVIF_INFO_PORT_SVIF_VALID)
3311 bp->port_svif = port_svif_info &
3312 HWRM_PORT_MAC_QCFG_OUTPUT_PORT_SVIF_INFO_PORT_SVIF_MASK;
3319 static int bnxt_hwrm_pf_func_cfg(struct bnxt *bp,
3320 struct bnxt_pf_resource_info *pf_resc)
3322 struct hwrm_func_cfg_input req = {0};
3323 struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
3327 enables = HWRM_FUNC_CFG_INPUT_ENABLES_MTU |
3328 HWRM_FUNC_CFG_INPUT_ENABLES_MRU |
3329 HWRM_FUNC_CFG_INPUT_ENABLES_NUM_RSSCOS_CTXS |
3330 HWRM_FUNC_CFG_INPUT_ENABLES_NUM_STAT_CTXS |
3331 HWRM_FUNC_CFG_INPUT_ENABLES_NUM_CMPL_RINGS |
3332 HWRM_FUNC_CFG_INPUT_ENABLES_NUM_TX_RINGS |
3333 HWRM_FUNC_CFG_INPUT_ENABLES_NUM_RX_RINGS |
3334 HWRM_FUNC_CFG_INPUT_ENABLES_NUM_L2_CTXS |
3335 HWRM_FUNC_CFG_INPUT_ENABLES_NUM_VNICS;
3337 if (BNXT_HAS_RING_GRPS(bp)) {
3338 enables |= HWRM_FUNC_CFG_INPUT_ENABLES_NUM_HW_RING_GRPS;
3339 req.num_hw_ring_grps =
3340 rte_cpu_to_le_16(pf_resc->num_hw_ring_grps);
3341 } else if (BNXT_HAS_NQ(bp)) {
3342 enables |= HWRM_FUNC_CFG_INPUT_ENABLES_NUM_MSIX;
3343 req.num_msix = rte_cpu_to_le_16(bp->max_nq_rings);
3346 req.flags = rte_cpu_to_le_32(bp->pf->func_cfg_flags);
3347 req.mtu = rte_cpu_to_le_16(BNXT_MAX_MTU);
3348 req.mru = rte_cpu_to_le_16(BNXT_VNIC_MRU(bp->eth_dev->data->mtu));
3349 req.num_rsscos_ctxs = rte_cpu_to_le_16(pf_resc->num_rsscos_ctxs);
3350 req.num_stat_ctxs = rte_cpu_to_le_16(pf_resc->num_stat_ctxs);
3351 req.num_cmpl_rings = rte_cpu_to_le_16(pf_resc->num_cp_rings);
3352 req.num_tx_rings = rte_cpu_to_le_16(pf_resc->num_tx_rings);
3353 req.num_rx_rings = rte_cpu_to_le_16(pf_resc->num_rx_rings);
3354 req.num_l2_ctxs = rte_cpu_to_le_16(pf_resc->num_l2_ctxs);
3355 req.num_vnics = rte_cpu_to_le_16(bp->max_vnics);
3356 req.fid = rte_cpu_to_le_16(0xffff);
3357 req.enables = rte_cpu_to_le_32(enables);
3359 HWRM_PREP(&req, HWRM_FUNC_CFG, BNXT_USE_CHIMP_MB);
3361 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3363 HWRM_CHECK_RESULT();
3369 /* min values are the guaranteed resources and max values are subject
3370 * to availability. The strategy for now is to keep both min & max
3374 bnxt_fill_vf_func_cfg_req_new(struct bnxt *bp,
3375 struct hwrm_func_vf_resource_cfg_input *req,
3378 req->max_rsscos_ctx = rte_cpu_to_le_16(bp->max_rsscos_ctx /
3380 req->min_rsscos_ctx = req->max_rsscos_ctx;
3381 req->max_stat_ctx = rte_cpu_to_le_16(bp->max_stat_ctx / (num_vfs + 1));
3382 req->min_stat_ctx = req->max_stat_ctx;
3383 req->max_cmpl_rings = rte_cpu_to_le_16(bp->max_cp_rings /
3385 req->min_cmpl_rings = req->max_cmpl_rings;
3386 req->max_tx_rings = rte_cpu_to_le_16(bp->max_tx_rings / (num_vfs + 1));
3387 req->min_tx_rings = req->max_tx_rings;
3388 req->max_rx_rings = rte_cpu_to_le_16(bp->max_rx_rings / (num_vfs + 1));
3389 req->min_rx_rings = req->max_rx_rings;
3390 req->max_l2_ctxs = rte_cpu_to_le_16(bp->max_l2_ctx / (num_vfs + 1));
3391 req->min_l2_ctxs = req->max_l2_ctxs;
3392 /* TODO: For now, do not support VMDq/RFS on VFs. */
3393 req->max_vnics = rte_cpu_to_le_16(1);
3394 req->min_vnics = req->max_vnics;
3395 req->max_hw_ring_grps = rte_cpu_to_le_16(bp->max_ring_grps /
3397 req->min_hw_ring_grps = req->max_hw_ring_grps;
3399 rte_cpu_to_le_16(HWRM_FUNC_VF_RESOURCE_CFG_INPUT_FLAGS_MIN_GUARANTEED);
3403 bnxt_fill_vf_func_cfg_req_old(struct bnxt *bp,
3404 struct hwrm_func_cfg_input *req,
3407 req->enables = rte_cpu_to_le_32(HWRM_FUNC_CFG_INPUT_ENABLES_MTU |
3408 HWRM_FUNC_CFG_INPUT_ENABLES_MRU |
3409 HWRM_FUNC_CFG_INPUT_ENABLES_NUM_RSSCOS_CTXS |
3410 HWRM_FUNC_CFG_INPUT_ENABLES_NUM_STAT_CTXS |
3411 HWRM_FUNC_CFG_INPUT_ENABLES_NUM_CMPL_RINGS |
3412 HWRM_FUNC_CFG_INPUT_ENABLES_NUM_TX_RINGS |
3413 HWRM_FUNC_CFG_INPUT_ENABLES_NUM_RX_RINGS |
3414 HWRM_FUNC_CFG_INPUT_ENABLES_NUM_L2_CTXS |
3415 HWRM_FUNC_CFG_INPUT_ENABLES_NUM_VNICS |
3416 HWRM_FUNC_CFG_INPUT_ENABLES_NUM_HW_RING_GRPS);
3418 req->mtu = rte_cpu_to_le_16(bp->eth_dev->data->mtu + RTE_ETHER_HDR_LEN +
3419 RTE_ETHER_CRC_LEN + VLAN_TAG_SIZE *
3421 req->mru = rte_cpu_to_le_16(BNXT_VNIC_MRU(bp->eth_dev->data->mtu));
3422 req->num_rsscos_ctxs = rte_cpu_to_le_16(bp->max_rsscos_ctx /
3424 req->num_stat_ctxs = rte_cpu_to_le_16(bp->max_stat_ctx / (num_vfs + 1));
3425 req->num_cmpl_rings = rte_cpu_to_le_16(bp->max_cp_rings /
3427 req->num_tx_rings = rte_cpu_to_le_16(bp->max_tx_rings / (num_vfs + 1));
3428 req->num_rx_rings = rte_cpu_to_le_16(bp->max_rx_rings / (num_vfs + 1));
3429 req->num_l2_ctxs = rte_cpu_to_le_16(bp->max_l2_ctx / (num_vfs + 1));
3430 /* TODO: For now, do not support VMDq/RFS on VFs. */
3431 req->num_vnics = rte_cpu_to_le_16(1);
3432 req->num_hw_ring_grps = rte_cpu_to_le_16(bp->max_ring_grps /
3436 /* Update the port wide resource values based on how many resources
3437 * got allocated to the VF.
3439 static int bnxt_update_max_resources(struct bnxt *bp,
3442 struct hwrm_func_qcfg_input req = {0};
3443 struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
3446 /* Get the actual allocated values now */
3447 HWRM_PREP(&req, HWRM_FUNC_QCFG, BNXT_USE_CHIMP_MB);
3448 req.fid = rte_cpu_to_le_16(bp->pf->vf_info[vf].fid);
3449 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3450 HWRM_CHECK_RESULT();
3452 bp->max_rsscos_ctx -= rte_le_to_cpu_16(resp->alloc_rsscos_ctx);
3453 bp->max_stat_ctx -= rte_le_to_cpu_16(resp->alloc_stat_ctx);
3454 bp->max_cp_rings -= rte_le_to_cpu_16(resp->alloc_cmpl_rings);
3455 bp->max_tx_rings -= rte_le_to_cpu_16(resp->alloc_tx_rings);
3456 bp->max_rx_rings -= rte_le_to_cpu_16(resp->alloc_rx_rings);
3457 bp->max_l2_ctx -= rte_le_to_cpu_16(resp->alloc_l2_ctx);
3458 bp->max_ring_grps -= rte_le_to_cpu_16(resp->alloc_hw_ring_grps);
3465 /* Update the PF resource values based on how many resources
3466 * got allocated to it.
3468 static int bnxt_update_max_resources_pf_only(struct bnxt *bp)
3470 struct hwrm_func_qcfg_input req = {0};
3471 struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
3474 /* Get the actual allocated values now */
3475 HWRM_PREP(&req, HWRM_FUNC_QCFG, BNXT_USE_CHIMP_MB);
3476 req.fid = rte_cpu_to_le_16(0xffff);
3477 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3478 HWRM_CHECK_RESULT();
3480 bp->max_rsscos_ctx = rte_le_to_cpu_16(resp->alloc_rsscos_ctx);
3481 bp->max_stat_ctx = rte_le_to_cpu_16(resp->alloc_stat_ctx);
3482 bp->max_cp_rings = rte_le_to_cpu_16(resp->alloc_cmpl_rings);
3483 bp->max_tx_rings = rte_le_to_cpu_16(resp->alloc_tx_rings);
3484 bp->max_rx_rings = rte_le_to_cpu_16(resp->alloc_rx_rings);
3485 bp->max_l2_ctx = rte_le_to_cpu_16(resp->alloc_l2_ctx);
3486 bp->max_ring_grps = rte_le_to_cpu_16(resp->alloc_hw_ring_grps);
3487 bp->max_vnics = rte_le_to_cpu_16(resp->alloc_vnics);
3494 int bnxt_hwrm_func_qcfg_current_vf_vlan(struct bnxt *bp, int vf)
3496 struct hwrm_func_qcfg_input req = {0};
3497 struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
3500 /* Check for zero MAC address */
3501 HWRM_PREP(&req, HWRM_FUNC_QCFG, BNXT_USE_CHIMP_MB);
3502 req.fid = rte_cpu_to_le_16(bp->pf->vf_info[vf].fid);
3503 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3504 HWRM_CHECK_RESULT();
3505 rc = rte_le_to_cpu_16(resp->vlan);
3512 static int bnxt_query_pf_resources(struct bnxt *bp,
3513 struct bnxt_pf_resource_info *pf_resc)
3515 struct hwrm_func_qcfg_input req = {0};
3516 struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
3519 /* And copy the allocated numbers into the pf struct */
3520 HWRM_PREP(&req, HWRM_FUNC_QCFG, BNXT_USE_CHIMP_MB);
3521 req.fid = rte_cpu_to_le_16(0xffff);
3522 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3523 HWRM_CHECK_RESULT();
3525 pf_resc->num_tx_rings = rte_le_to_cpu_16(resp->alloc_tx_rings);
3526 pf_resc->num_rsscos_ctxs = rte_le_to_cpu_16(resp->alloc_rsscos_ctx);
3527 pf_resc->num_stat_ctxs = rte_le_to_cpu_16(resp->alloc_stat_ctx);
3528 pf_resc->num_cp_rings = rte_le_to_cpu_16(resp->alloc_cmpl_rings);
3529 pf_resc->num_rx_rings = rte_le_to_cpu_16(resp->alloc_rx_rings);
3530 pf_resc->num_l2_ctxs = rte_le_to_cpu_16(resp->alloc_l2_ctx);
3531 pf_resc->num_hw_ring_grps = rte_le_to_cpu_32(resp->alloc_hw_ring_grps);
3532 bp->pf->evb_mode = resp->evb_mode;
3540 bnxt_calculate_pf_resources(struct bnxt *bp,
3541 struct bnxt_pf_resource_info *pf_resc,
3545 pf_resc->num_rsscos_ctxs = bp->max_rsscos_ctx;
3546 pf_resc->num_stat_ctxs = bp->max_stat_ctx;
3547 pf_resc->num_cp_rings = bp->max_cp_rings;
3548 pf_resc->num_tx_rings = bp->max_tx_rings;
3549 pf_resc->num_rx_rings = bp->max_rx_rings;
3550 pf_resc->num_l2_ctxs = bp->max_l2_ctx;
3551 pf_resc->num_hw_ring_grps = bp->max_ring_grps;
3556 pf_resc->num_rsscos_ctxs = bp->max_rsscos_ctx / (num_vfs + 1) +
3557 bp->max_rsscos_ctx % (num_vfs + 1);
3558 pf_resc->num_stat_ctxs = bp->max_stat_ctx / (num_vfs + 1) +
3559 bp->max_stat_ctx % (num_vfs + 1);
3560 pf_resc->num_cp_rings = bp->max_cp_rings / (num_vfs + 1) +
3561 bp->max_cp_rings % (num_vfs + 1);
3562 pf_resc->num_tx_rings = bp->max_tx_rings / (num_vfs + 1) +
3563 bp->max_tx_rings % (num_vfs + 1);
3564 pf_resc->num_rx_rings = bp->max_rx_rings / (num_vfs + 1) +
3565 bp->max_rx_rings % (num_vfs + 1);
3566 pf_resc->num_l2_ctxs = bp->max_l2_ctx / (num_vfs + 1) +
3567 bp->max_l2_ctx % (num_vfs + 1);
3568 pf_resc->num_hw_ring_grps = bp->max_ring_grps / (num_vfs + 1) +
3569 bp->max_ring_grps % (num_vfs + 1);
3572 int bnxt_hwrm_allocate_pf_only(struct bnxt *bp)
3574 struct bnxt_pf_resource_info pf_resc = { 0 };
3578 PMD_DRV_LOG(ERR, "Attempt to allcoate VFs on a VF!\n");
3582 rc = bnxt_hwrm_func_qcaps(bp);
3586 bnxt_calculate_pf_resources(bp, &pf_resc, 0);
3588 bp->pf->func_cfg_flags &=
3589 ~(HWRM_FUNC_CFG_INPUT_FLAGS_STD_TX_RING_MODE_ENABLE |
3590 HWRM_FUNC_CFG_INPUT_FLAGS_STD_TX_RING_MODE_DISABLE);
3591 bp->pf->func_cfg_flags |=
3592 HWRM_FUNC_CFG_INPUT_FLAGS_STD_TX_RING_MODE_DISABLE;
3594 rc = bnxt_hwrm_pf_func_cfg(bp, &pf_resc);
3598 rc = bnxt_update_max_resources_pf_only(bp);
3604 bnxt_configure_vf_req_buf(struct bnxt *bp, int num_vfs)
3606 size_t req_buf_sz, sz;
3609 req_buf_sz = num_vfs * HWRM_MAX_REQ_LEN;
3610 bp->pf->vf_req_buf = rte_malloc("bnxt_vf_fwd", req_buf_sz,
3611 page_roundup(num_vfs * HWRM_MAX_REQ_LEN));
3612 if (bp->pf->vf_req_buf == NULL) {
3616 for (sz = 0; sz < req_buf_sz; sz += getpagesize())
3617 rte_mem_lock_page(((char *)bp->pf->vf_req_buf) + sz);
3619 for (i = 0; i < num_vfs; i++)
3620 bp->pf->vf_info[i].req_buf = ((char *)bp->pf->vf_req_buf) +
3621 (i * HWRM_MAX_REQ_LEN);
3623 rc = bnxt_hwrm_func_buf_rgtr(bp, num_vfs);
3625 rte_free(bp->pf->vf_req_buf);
3631 bnxt_process_vf_resc_config_new(struct bnxt *bp, int num_vfs)
3633 struct hwrm_func_vf_resource_cfg_output *resp = bp->hwrm_cmd_resp_addr;
3634 struct hwrm_func_vf_resource_cfg_input req = {0};
3637 bnxt_fill_vf_func_cfg_req_new(bp, &req, num_vfs);
3638 bp->pf->active_vfs = 0;
3639 for (i = 0; i < num_vfs; i++) {
3640 HWRM_PREP(&req, HWRM_FUNC_VF_RESOURCE_CFG, BNXT_USE_CHIMP_MB);
3641 req.vf_id = rte_cpu_to_le_16(bp->pf->vf_info[i].fid);
3642 rc = bnxt_hwrm_send_message(bp,
3646 if (rc || resp->error_code) {
3648 "Failed to initialize VF %d\n", i);
3650 "Not all VFs available. (%d, %d)\n",
3651 rc, resp->error_code);
3654 /* If the first VF configuration itself fails,
3655 * unregister the vf_fwd_request buffer.
3658 bnxt_hwrm_func_buf_unrgtr(bp);
3663 /* Update the max resource values based on the resource values
3664 * allocated to the VF.
3666 bnxt_update_max_resources(bp, i);
3667 bp->pf->active_vfs++;
3668 bnxt_hwrm_func_clr_stats(bp, bp->pf->vf_info[i].fid);
3675 bnxt_process_vf_resc_config_old(struct bnxt *bp, int num_vfs)
3677 struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
3678 struct hwrm_func_cfg_input req = {0};
3681 bnxt_fill_vf_func_cfg_req_old(bp, &req, num_vfs);
3683 bp->pf->active_vfs = 0;
3684 for (i = 0; i < num_vfs; i++) {
3685 HWRM_PREP(&req, HWRM_FUNC_CFG, BNXT_USE_CHIMP_MB);
3686 req.flags = rte_cpu_to_le_32(bp->pf->vf_info[i].func_cfg_flags);
3687 req.fid = rte_cpu_to_le_16(bp->pf->vf_info[i].fid);
3688 rc = bnxt_hwrm_send_message(bp,
3693 /* Clear enable flag for next pass */
3694 req.enables &= ~rte_cpu_to_le_32(
3695 HWRM_FUNC_CFG_INPUT_ENABLES_DFLT_MAC_ADDR);
3697 if (rc || resp->error_code) {
3699 "Failed to initialize VF %d\n", i);
3701 "Not all VFs available. (%d, %d)\n",
3702 rc, resp->error_code);
3705 /* If the first VF configuration itself fails,
3706 * unregister the vf_fwd_request buffer.
3709 bnxt_hwrm_func_buf_unrgtr(bp);
3715 /* Update the max resource values based on the resource values
3716 * allocated to the VF.
3718 bnxt_update_max_resources(bp, i);
3719 bp->pf->active_vfs++;
3720 bnxt_hwrm_func_clr_stats(bp, bp->pf->vf_info[i].fid);
3727 bnxt_configure_vf_resources(struct bnxt *bp, int num_vfs)
3729 if (bp->flags & BNXT_FLAG_NEW_RM)
3730 bnxt_process_vf_resc_config_new(bp, num_vfs);
3732 bnxt_process_vf_resc_config_old(bp, num_vfs);
3736 bnxt_update_pf_resources(struct bnxt *bp,
3737 struct bnxt_pf_resource_info *pf_resc)
3739 bp->max_rsscos_ctx = pf_resc->num_rsscos_ctxs;
3740 bp->max_stat_ctx = pf_resc->num_stat_ctxs;
3741 bp->max_cp_rings = pf_resc->num_cp_rings;
3742 bp->max_tx_rings = pf_resc->num_tx_rings;
3743 bp->max_rx_rings = pf_resc->num_rx_rings;
3744 bp->max_ring_grps = pf_resc->num_hw_ring_grps;
3748 bnxt_configure_pf_resources(struct bnxt *bp,
3749 struct bnxt_pf_resource_info *pf_resc)
3752 * We're using STD_TX_RING_MODE here which will limit the TX
3753 * rings. This will allow QoS to function properly. Not setting this
3754 * will cause PF rings to break bandwidth settings.
3756 bp->pf->func_cfg_flags &=
3757 ~(HWRM_FUNC_CFG_INPUT_FLAGS_STD_TX_RING_MODE_ENABLE |
3758 HWRM_FUNC_CFG_INPUT_FLAGS_STD_TX_RING_MODE_DISABLE);
3759 bp->pf->func_cfg_flags |=
3760 HWRM_FUNC_CFG_INPUT_FLAGS_STD_TX_RING_MODE_ENABLE;
3761 return bnxt_hwrm_pf_func_cfg(bp, pf_resc);
3764 int bnxt_hwrm_allocate_vfs(struct bnxt *bp, int num_vfs)
3766 struct bnxt_pf_resource_info pf_resc = { 0 };
3770 PMD_DRV_LOG(ERR, "Attempt to allocate VFs on a VF!\n");
3774 rc = bnxt_hwrm_func_qcaps(bp);
3778 bnxt_calculate_pf_resources(bp, &pf_resc, num_vfs);
3780 rc = bnxt_configure_pf_resources(bp, &pf_resc);
3784 rc = bnxt_query_pf_resources(bp, &pf_resc);
3789 * Now, create and register a buffer to hold forwarded VF requests
3791 rc = bnxt_configure_vf_req_buf(bp, num_vfs);
3795 bnxt_configure_vf_resources(bp, num_vfs);
3797 bnxt_update_pf_resources(bp, &pf_resc);
3802 int bnxt_hwrm_pf_evb_mode(struct bnxt *bp)
3804 struct hwrm_func_cfg_input req = {0};
3805 struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
3808 HWRM_PREP(&req, HWRM_FUNC_CFG, BNXT_USE_CHIMP_MB);
3810 req.fid = rte_cpu_to_le_16(0xffff);
3811 req.enables = rte_cpu_to_le_32(HWRM_FUNC_CFG_INPUT_ENABLES_EVB_MODE);
3812 req.evb_mode = bp->pf->evb_mode;
3814 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3815 HWRM_CHECK_RESULT();
3821 int bnxt_hwrm_tunnel_dst_port_alloc(struct bnxt *bp, uint16_t port,
3822 uint8_t tunnel_type)
3824 struct hwrm_tunnel_dst_port_alloc_input req = {0};
3825 struct hwrm_tunnel_dst_port_alloc_output *resp = bp->hwrm_cmd_resp_addr;
3828 HWRM_PREP(&req, HWRM_TUNNEL_DST_PORT_ALLOC, BNXT_USE_CHIMP_MB);
3829 req.tunnel_type = tunnel_type;
3830 req.tunnel_dst_port_val = rte_cpu_to_be_16(port);
3831 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3832 HWRM_CHECK_RESULT();
3834 switch (tunnel_type) {
3835 case HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_VXLAN:
3836 bp->vxlan_fw_dst_port_id =
3837 rte_le_to_cpu_16(resp->tunnel_dst_port_id);
3838 bp->vxlan_port = port;
3840 case HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_GENEVE:
3841 bp->geneve_fw_dst_port_id =
3842 rte_le_to_cpu_16(resp->tunnel_dst_port_id);
3843 bp->geneve_port = port;
3854 int bnxt_hwrm_tunnel_dst_port_free(struct bnxt *bp, uint16_t port,
3855 uint8_t tunnel_type)
3857 struct hwrm_tunnel_dst_port_free_input req = {0};
3858 struct hwrm_tunnel_dst_port_free_output *resp = bp->hwrm_cmd_resp_addr;
3861 HWRM_PREP(&req, HWRM_TUNNEL_DST_PORT_FREE, BNXT_USE_CHIMP_MB);
3863 req.tunnel_type = tunnel_type;
3864 req.tunnel_dst_port_id = rte_cpu_to_be_16(port);
3865 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3867 HWRM_CHECK_RESULT();
3871 HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_VXLAN) {
3873 bp->vxlan_port_cnt = 0;
3877 HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_GENEVE) {
3878 bp->geneve_port = 0;
3879 bp->geneve_port_cnt = 0;
3885 int bnxt_hwrm_func_cfg_vf_set_flags(struct bnxt *bp, uint16_t vf,
3888 struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
3889 struct hwrm_func_cfg_input req = {0};
3892 HWRM_PREP(&req, HWRM_FUNC_CFG, BNXT_USE_CHIMP_MB);
3894 req.fid = rte_cpu_to_le_16(bp->pf->vf_info[vf].fid);
3895 req.flags = rte_cpu_to_le_32(flags);
3896 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3898 HWRM_CHECK_RESULT();
3904 void vf_vnic_set_rxmask_cb(struct bnxt_vnic_info *vnic, void *flagp)
3906 uint32_t *flag = flagp;
3908 vnic->flags = *flag;
3911 int bnxt_set_rx_mask_no_vlan(struct bnxt *bp, struct bnxt_vnic_info *vnic)
3913 return bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic, 0, NULL);
3916 int bnxt_hwrm_func_buf_rgtr(struct bnxt *bp, int num_vfs)
3918 struct hwrm_func_buf_rgtr_output *resp = bp->hwrm_cmd_resp_addr;
3919 struct hwrm_func_buf_rgtr_input req = {.req_type = 0 };
3922 HWRM_PREP(&req, HWRM_FUNC_BUF_RGTR, BNXT_USE_CHIMP_MB);
3924 req.req_buf_num_pages = rte_cpu_to_le_16(1);
3925 req.req_buf_page_size =
3926 rte_cpu_to_le_16(page_getenum(num_vfs * HWRM_MAX_REQ_LEN));
3927 req.req_buf_len = rte_cpu_to_le_16(HWRM_MAX_REQ_LEN);
3928 req.req_buf_page_addr0 =
3929 rte_cpu_to_le_64(rte_malloc_virt2iova(bp->pf->vf_req_buf));
3930 if (req.req_buf_page_addr0 == RTE_BAD_IOVA) {
3932 "unable to map buffer address to physical memory\n");
3937 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3939 HWRM_CHECK_RESULT();
3945 int bnxt_hwrm_func_buf_unrgtr(struct bnxt *bp)
3948 struct hwrm_func_buf_unrgtr_input req = {.req_type = 0 };
3949 struct hwrm_func_buf_unrgtr_output *resp = bp->hwrm_cmd_resp_addr;
3951 if (!(BNXT_PF(bp) && bp->pdev->max_vfs))
3954 HWRM_PREP(&req, HWRM_FUNC_BUF_UNRGTR, BNXT_USE_CHIMP_MB);
3956 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3958 HWRM_CHECK_RESULT();
3964 int bnxt_hwrm_func_cfg_def_cp(struct bnxt *bp)
3966 struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
3967 struct hwrm_func_cfg_input req = {0};
3970 HWRM_PREP(&req, HWRM_FUNC_CFG, BNXT_USE_CHIMP_MB);
3972 req.fid = rte_cpu_to_le_16(0xffff);
3973 req.flags = rte_cpu_to_le_32(bp->pf->func_cfg_flags);
3974 req.enables = rte_cpu_to_le_32(
3975 HWRM_FUNC_CFG_INPUT_ENABLES_ASYNC_EVENT_CR);
3976 req.async_event_cr = rte_cpu_to_le_16(
3977 bp->async_cp_ring->cp_ring_struct->fw_ring_id);
3978 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
3980 HWRM_CHECK_RESULT();
3986 int bnxt_hwrm_vf_func_cfg_def_cp(struct bnxt *bp)
3988 struct hwrm_func_vf_cfg_output *resp = bp->hwrm_cmd_resp_addr;
3989 struct hwrm_func_vf_cfg_input req = {0};
3992 HWRM_PREP(&req, HWRM_FUNC_VF_CFG, BNXT_USE_CHIMP_MB);
3994 req.enables = rte_cpu_to_le_32(
3995 HWRM_FUNC_VF_CFG_INPUT_ENABLES_ASYNC_EVENT_CR);
3996 req.async_event_cr = rte_cpu_to_le_16(
3997 bp->async_cp_ring->cp_ring_struct->fw_ring_id);
3998 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4000 HWRM_CHECK_RESULT();
4006 int bnxt_hwrm_set_default_vlan(struct bnxt *bp, int vf, uint8_t is_vf)
4008 struct hwrm_func_cfg_input req = {0};
4009 struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
4010 uint16_t dflt_vlan, fid;
4011 uint32_t func_cfg_flags;
4014 HWRM_PREP(&req, HWRM_FUNC_CFG, BNXT_USE_CHIMP_MB);
4017 dflt_vlan = bp->pf->vf_info[vf].dflt_vlan;
4018 fid = bp->pf->vf_info[vf].fid;
4019 func_cfg_flags = bp->pf->vf_info[vf].func_cfg_flags;
4021 fid = rte_cpu_to_le_16(0xffff);
4022 func_cfg_flags = bp->pf->func_cfg_flags;
4023 dflt_vlan = bp->vlan;
4026 req.flags = rte_cpu_to_le_32(func_cfg_flags);
4027 req.fid = rte_cpu_to_le_16(fid);
4028 req.enables |= rte_cpu_to_le_32(HWRM_FUNC_CFG_INPUT_ENABLES_DFLT_VLAN);
4029 req.dflt_vlan = rte_cpu_to_le_16(dflt_vlan);
4031 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4033 HWRM_CHECK_RESULT();
4039 int bnxt_hwrm_func_bw_cfg(struct bnxt *bp, uint16_t vf,
4040 uint16_t max_bw, uint16_t enables)
4042 struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
4043 struct hwrm_func_cfg_input req = {0};
4046 HWRM_PREP(&req, HWRM_FUNC_CFG, BNXT_USE_CHIMP_MB);
4048 req.fid = rte_cpu_to_le_16(bp->pf->vf_info[vf].fid);
4049 req.enables |= rte_cpu_to_le_32(enables);
4050 req.flags = rte_cpu_to_le_32(bp->pf->vf_info[vf].func_cfg_flags);
4051 req.max_bw = rte_cpu_to_le_32(max_bw);
4052 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4054 HWRM_CHECK_RESULT();
4060 int bnxt_hwrm_set_vf_vlan(struct bnxt *bp, int vf)
4062 struct hwrm_func_cfg_input req = {0};
4063 struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
4066 HWRM_PREP(&req, HWRM_FUNC_CFG, BNXT_USE_CHIMP_MB);
4068 req.flags = rte_cpu_to_le_32(bp->pf->vf_info[vf].func_cfg_flags);
4069 req.fid = rte_cpu_to_le_16(bp->pf->vf_info[vf].fid);
4070 req.enables |= rte_cpu_to_le_32(HWRM_FUNC_CFG_INPUT_ENABLES_DFLT_VLAN);
4071 req.dflt_vlan = rte_cpu_to_le_16(bp->pf->vf_info[vf].dflt_vlan);
4073 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4075 HWRM_CHECK_RESULT();
4081 int bnxt_hwrm_set_async_event_cr(struct bnxt *bp)
4086 rc = bnxt_hwrm_func_cfg_def_cp(bp);
4088 rc = bnxt_hwrm_vf_func_cfg_def_cp(bp);
4093 int bnxt_hwrm_reject_fwd_resp(struct bnxt *bp, uint16_t target_id,
4094 void *encaped, size_t ec_size)
4097 struct hwrm_reject_fwd_resp_input req = {.req_type = 0};
4098 struct hwrm_reject_fwd_resp_output *resp = bp->hwrm_cmd_resp_addr;
4100 if (ec_size > sizeof(req.encap_request))
4103 HWRM_PREP(&req, HWRM_REJECT_FWD_RESP, BNXT_USE_CHIMP_MB);
4105 req.encap_resp_target_id = rte_cpu_to_le_16(target_id);
4106 memcpy(req.encap_request, encaped, ec_size);
4108 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4110 HWRM_CHECK_RESULT();
4116 int bnxt_hwrm_func_qcfg_vf_default_mac(struct bnxt *bp, uint16_t vf,
4117 struct rte_ether_addr *mac)
4119 struct hwrm_func_qcfg_input req = {0};
4120 struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
4123 HWRM_PREP(&req, HWRM_FUNC_QCFG, BNXT_USE_CHIMP_MB);
4125 req.fid = rte_cpu_to_le_16(bp->pf->vf_info[vf].fid);
4126 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4128 HWRM_CHECK_RESULT();
4130 memcpy(mac->addr_bytes, resp->mac_address, RTE_ETHER_ADDR_LEN);
4137 int bnxt_hwrm_exec_fwd_resp(struct bnxt *bp, uint16_t target_id,
4138 void *encaped, size_t ec_size)
4141 struct hwrm_exec_fwd_resp_input req = {.req_type = 0};
4142 struct hwrm_exec_fwd_resp_output *resp = bp->hwrm_cmd_resp_addr;
4144 if (ec_size > sizeof(req.encap_request))
4147 HWRM_PREP(&req, HWRM_EXEC_FWD_RESP, BNXT_USE_CHIMP_MB);
4149 req.encap_resp_target_id = rte_cpu_to_le_16(target_id);
4150 memcpy(req.encap_request, encaped, ec_size);
4152 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4154 HWRM_CHECK_RESULT();
4160 int bnxt_hwrm_ctx_qstats(struct bnxt *bp, uint32_t cid, int idx,
4161 struct rte_eth_stats *stats, uint8_t rx)
4164 struct hwrm_stat_ctx_query_input req = {.req_type = 0};
4165 struct hwrm_stat_ctx_query_output *resp = bp->hwrm_cmd_resp_addr;
4167 HWRM_PREP(&req, HWRM_STAT_CTX_QUERY, BNXT_USE_CHIMP_MB);
4169 req.stat_ctx_id = rte_cpu_to_le_32(cid);
4171 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4173 HWRM_CHECK_RESULT();
4176 stats->q_ipackets[idx] = rte_le_to_cpu_64(resp->rx_ucast_pkts);
4177 stats->q_ipackets[idx] += rte_le_to_cpu_64(resp->rx_mcast_pkts);
4178 stats->q_ipackets[idx] += rte_le_to_cpu_64(resp->rx_bcast_pkts);
4179 stats->q_ibytes[idx] = rte_le_to_cpu_64(resp->rx_ucast_bytes);
4180 stats->q_ibytes[idx] += rte_le_to_cpu_64(resp->rx_mcast_bytes);
4181 stats->q_ibytes[idx] += rte_le_to_cpu_64(resp->rx_bcast_bytes);
4182 stats->q_errors[idx] = rte_le_to_cpu_64(resp->rx_discard_pkts);
4183 stats->q_errors[idx] += rte_le_to_cpu_64(resp->rx_error_pkts);
4185 stats->q_opackets[idx] = rte_le_to_cpu_64(resp->tx_ucast_pkts);
4186 stats->q_opackets[idx] += rte_le_to_cpu_64(resp->tx_mcast_pkts);
4187 stats->q_opackets[idx] += rte_le_to_cpu_64(resp->tx_bcast_pkts);
4188 stats->q_obytes[idx] = rte_le_to_cpu_64(resp->tx_ucast_bytes);
4189 stats->q_obytes[idx] += rte_le_to_cpu_64(resp->tx_mcast_bytes);
4190 stats->q_obytes[idx] += rte_le_to_cpu_64(resp->tx_bcast_bytes);
4198 int bnxt_hwrm_port_qstats(struct bnxt *bp)
4200 struct hwrm_port_qstats_input req = {0};
4201 struct hwrm_port_qstats_output *resp = bp->hwrm_cmd_resp_addr;
4202 struct bnxt_pf_info *pf = bp->pf;
4205 HWRM_PREP(&req, HWRM_PORT_QSTATS, BNXT_USE_CHIMP_MB);
4207 req.port_id = rte_cpu_to_le_16(pf->port_id);
4208 req.tx_stat_host_addr = rte_cpu_to_le_64(bp->hw_tx_port_stats_map);
4209 req.rx_stat_host_addr = rte_cpu_to_le_64(bp->hw_rx_port_stats_map);
4210 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4212 HWRM_CHECK_RESULT();
4218 int bnxt_hwrm_port_clr_stats(struct bnxt *bp)
4220 struct hwrm_port_clr_stats_input req = {0};
4221 struct hwrm_port_clr_stats_output *resp = bp->hwrm_cmd_resp_addr;
4222 struct bnxt_pf_info *pf = bp->pf;
4225 /* Not allowed on NS2 device, NPAR, MultiHost, VF */
4226 if (!(bp->flags & BNXT_FLAG_PORT_STATS) || BNXT_VF(bp) ||
4227 BNXT_NPAR(bp) || BNXT_MH(bp) || BNXT_TOTAL_VFS(bp))
4230 HWRM_PREP(&req, HWRM_PORT_CLR_STATS, BNXT_USE_CHIMP_MB);
4232 req.port_id = rte_cpu_to_le_16(pf->port_id);
4233 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4235 HWRM_CHECK_RESULT();
4241 int bnxt_hwrm_port_led_qcaps(struct bnxt *bp)
4243 struct hwrm_port_led_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
4244 struct hwrm_port_led_qcaps_input req = {0};
4250 HWRM_PREP(&req, HWRM_PORT_LED_QCAPS, BNXT_USE_CHIMP_MB);
4251 req.port_id = bp->pf->port_id;
4252 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4254 HWRM_CHECK_RESULT();
4256 if (resp->num_leds > 0 && resp->num_leds < BNXT_MAX_LED) {
4259 bp->leds->num_leds = resp->num_leds;
4260 memcpy(bp->leds, &resp->led0_id,
4261 sizeof(bp->leds[0]) * bp->leds->num_leds);
4262 for (i = 0; i < bp->leds->num_leds; i++) {
4263 struct bnxt_led_info *led = &bp->leds[i];
4265 uint16_t caps = led->led_state_caps;
4267 if (!led->led_group_id ||
4268 !BNXT_LED_ALT_BLINK_CAP(caps)) {
4269 bp->leds->num_leds = 0;
4280 int bnxt_hwrm_port_led_cfg(struct bnxt *bp, bool led_on)
4282 struct hwrm_port_led_cfg_output *resp = bp->hwrm_cmd_resp_addr;
4283 struct hwrm_port_led_cfg_input req = {0};
4284 struct bnxt_led_cfg *led_cfg;
4285 uint8_t led_state = HWRM_PORT_LED_QCFG_OUTPUT_LED0_STATE_DEFAULT;
4286 uint16_t duration = 0;
4289 if (!bp->leds->num_leds || BNXT_VF(bp))
4292 HWRM_PREP(&req, HWRM_PORT_LED_CFG, BNXT_USE_CHIMP_MB);
4295 led_state = HWRM_PORT_LED_CFG_INPUT_LED0_STATE_BLINKALT;
4296 duration = rte_cpu_to_le_16(500);
4298 req.port_id = bp->pf->port_id;
4299 req.num_leds = bp->leds->num_leds;
4300 led_cfg = (struct bnxt_led_cfg *)&req.led0_id;
4301 for (i = 0; i < bp->leds->num_leds; i++, led_cfg++) {
4302 req.enables |= BNXT_LED_DFLT_ENABLES(i);
4303 led_cfg->led_id = bp->leds[i].led_id;
4304 led_cfg->led_state = led_state;
4305 led_cfg->led_blink_on = duration;
4306 led_cfg->led_blink_off = duration;
4307 led_cfg->led_group_id = bp->leds[i].led_group_id;
4310 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4312 HWRM_CHECK_RESULT();
4318 int bnxt_hwrm_nvm_get_dir_info(struct bnxt *bp, uint32_t *entries,
4322 struct hwrm_nvm_get_dir_info_input req = {0};
4323 struct hwrm_nvm_get_dir_info_output *resp = bp->hwrm_cmd_resp_addr;
4325 HWRM_PREP(&req, HWRM_NVM_GET_DIR_INFO, BNXT_USE_CHIMP_MB);
4327 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4329 HWRM_CHECK_RESULT();
4331 *entries = rte_le_to_cpu_32(resp->entries);
4332 *length = rte_le_to_cpu_32(resp->entry_length);
4338 int bnxt_get_nvram_directory(struct bnxt *bp, uint32_t len, uint8_t *data)
4341 uint32_t dir_entries;
4342 uint32_t entry_length;
4345 rte_iova_t dma_handle;
4346 struct hwrm_nvm_get_dir_entries_input req = {0};
4347 struct hwrm_nvm_get_dir_entries_output *resp = bp->hwrm_cmd_resp_addr;
4349 rc = bnxt_hwrm_nvm_get_dir_info(bp, &dir_entries, &entry_length);
4353 *data++ = dir_entries;
4354 *data++ = entry_length;
4356 memset(data, 0xff, len);
4358 buflen = dir_entries * entry_length;
4359 buf = rte_malloc("nvm_dir", buflen, 0);
4362 dma_handle = rte_malloc_virt2iova(buf);
4363 if (dma_handle == RTE_BAD_IOVA) {
4366 "unable to map response address to physical memory\n");
4369 HWRM_PREP(&req, HWRM_NVM_GET_DIR_ENTRIES, BNXT_USE_CHIMP_MB);
4370 req.host_dest_addr = rte_cpu_to_le_64(dma_handle);
4371 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4374 memcpy(data, buf, len > buflen ? buflen : len);
4377 HWRM_CHECK_RESULT();
4383 int bnxt_hwrm_get_nvram_item(struct bnxt *bp, uint32_t index,
4384 uint32_t offset, uint32_t length,
4389 rte_iova_t dma_handle;
4390 struct hwrm_nvm_read_input req = {0};
4391 struct hwrm_nvm_read_output *resp = bp->hwrm_cmd_resp_addr;
4393 buf = rte_malloc("nvm_item", length, 0);
4397 dma_handle = rte_malloc_virt2iova(buf);
4398 if (dma_handle == RTE_BAD_IOVA) {
4401 "unable to map response address to physical memory\n");
4404 HWRM_PREP(&req, HWRM_NVM_READ, BNXT_USE_CHIMP_MB);
4405 req.host_dest_addr = rte_cpu_to_le_64(dma_handle);
4406 req.dir_idx = rte_cpu_to_le_16(index);
4407 req.offset = rte_cpu_to_le_32(offset);
4408 req.len = rte_cpu_to_le_32(length);
4409 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4411 memcpy(data, buf, length);
4414 HWRM_CHECK_RESULT();
4420 int bnxt_hwrm_erase_nvram_directory(struct bnxt *bp, uint8_t index)
4423 struct hwrm_nvm_erase_dir_entry_input req = {0};
4424 struct hwrm_nvm_erase_dir_entry_output *resp = bp->hwrm_cmd_resp_addr;
4426 HWRM_PREP(&req, HWRM_NVM_ERASE_DIR_ENTRY, BNXT_USE_CHIMP_MB);
4427 req.dir_idx = rte_cpu_to_le_16(index);
4428 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4429 HWRM_CHECK_RESULT();
4436 int bnxt_hwrm_flash_nvram(struct bnxt *bp, uint16_t dir_type,
4437 uint16_t dir_ordinal, uint16_t dir_ext,
4438 uint16_t dir_attr, const uint8_t *data,
4442 struct hwrm_nvm_write_input req = {0};
4443 struct hwrm_nvm_write_output *resp = bp->hwrm_cmd_resp_addr;
4444 rte_iova_t dma_handle;
4447 buf = rte_malloc("nvm_write", data_len, 0);
4451 dma_handle = rte_malloc_virt2iova(buf);
4452 if (dma_handle == RTE_BAD_IOVA) {
4455 "unable to map response address to physical memory\n");
4458 memcpy(buf, data, data_len);
4460 HWRM_PREP(&req, HWRM_NVM_WRITE, BNXT_USE_CHIMP_MB);
4462 req.dir_type = rte_cpu_to_le_16(dir_type);
4463 req.dir_ordinal = rte_cpu_to_le_16(dir_ordinal);
4464 req.dir_ext = rte_cpu_to_le_16(dir_ext);
4465 req.dir_attr = rte_cpu_to_le_16(dir_attr);
4466 req.dir_data_length = rte_cpu_to_le_32(data_len);
4467 req.host_src_addr = rte_cpu_to_le_64(dma_handle);
4469 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4472 HWRM_CHECK_RESULT();
4479 bnxt_vnic_count(struct bnxt_vnic_info *vnic __rte_unused, void *cbdata)
4481 uint32_t *count = cbdata;
4483 *count = *count + 1;
4486 static int bnxt_vnic_count_hwrm_stub(struct bnxt *bp __rte_unused,
4487 struct bnxt_vnic_info *vnic __rte_unused)
4492 int bnxt_vf_vnic_count(struct bnxt *bp, uint16_t vf)
4496 bnxt_hwrm_func_vf_vnic_query_and_config(bp, vf, bnxt_vnic_count,
4497 &count, bnxt_vnic_count_hwrm_stub);
4502 static int bnxt_hwrm_func_vf_vnic_query(struct bnxt *bp, uint16_t vf,
4505 struct hwrm_func_vf_vnic_ids_query_input req = {0};
4506 struct hwrm_func_vf_vnic_ids_query_output *resp =
4507 bp->hwrm_cmd_resp_addr;
4510 /* First query all VNIC ids */
4511 HWRM_PREP(&req, HWRM_FUNC_VF_VNIC_IDS_QUERY, BNXT_USE_CHIMP_MB);
4513 req.vf_id = rte_cpu_to_le_16(bp->pf->first_vf_id + vf);
4514 req.max_vnic_id_cnt = rte_cpu_to_le_32(bp->pf->total_vnics);
4515 req.vnic_id_tbl_addr = rte_cpu_to_le_64(rte_malloc_virt2iova(vnic_ids));
4517 if (req.vnic_id_tbl_addr == RTE_BAD_IOVA) {
4520 "unable to map VNIC ID table address to physical memory\n");
4523 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4524 HWRM_CHECK_RESULT();
4525 rc = rte_le_to_cpu_32(resp->vnic_id_cnt);
4533 * This function queries the VNIC IDs for a specified VF. It then calls
4534 * the vnic_cb to update the necessary field in vnic_info with cbdata.
4535 * Then it calls the hwrm_cb function to program this new vnic configuration.
4537 int bnxt_hwrm_func_vf_vnic_query_and_config(struct bnxt *bp, uint16_t vf,
4538 void (*vnic_cb)(struct bnxt_vnic_info *, void *), void *cbdata,
4539 int (*hwrm_cb)(struct bnxt *bp, struct bnxt_vnic_info *vnic))
4541 struct bnxt_vnic_info vnic;
4543 int i, num_vnic_ids;
4548 /* First query all VNIC ids */
4549 vnic_id_sz = bp->pf->total_vnics * sizeof(*vnic_ids);
4550 vnic_ids = rte_malloc("bnxt_hwrm_vf_vnic_ids_query", vnic_id_sz,
4551 RTE_CACHE_LINE_SIZE);
4552 if (vnic_ids == NULL)
4555 for (sz = 0; sz < vnic_id_sz; sz += getpagesize())
4556 rte_mem_lock_page(((char *)vnic_ids) + sz);
4558 num_vnic_ids = bnxt_hwrm_func_vf_vnic_query(bp, vf, vnic_ids);
4560 if (num_vnic_ids < 0)
4561 return num_vnic_ids;
4563 /* Retrieve VNIC, update bd_stall then update */
4565 for (i = 0; i < num_vnic_ids; i++) {
4566 memset(&vnic, 0, sizeof(struct bnxt_vnic_info));
4567 vnic.fw_vnic_id = rte_le_to_cpu_16(vnic_ids[i]);
4568 rc = bnxt_hwrm_vnic_qcfg(bp, &vnic, bp->pf->first_vf_id + vf);
4571 if (vnic.mru <= 4) /* Indicates unallocated */
4574 vnic_cb(&vnic, cbdata);
4576 rc = hwrm_cb(bp, &vnic);
4586 int bnxt_hwrm_func_cfg_vf_set_vlan_anti_spoof(struct bnxt *bp, uint16_t vf,
4589 struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
4590 struct hwrm_func_cfg_input req = {0};
4593 HWRM_PREP(&req, HWRM_FUNC_CFG, BNXT_USE_CHIMP_MB);
4595 req.fid = rte_cpu_to_le_16(bp->pf->vf_info[vf].fid);
4596 req.enables |= rte_cpu_to_le_32(
4597 HWRM_FUNC_CFG_INPUT_ENABLES_VLAN_ANTISPOOF_MODE);
4598 req.vlan_antispoof_mode = on ?
4599 HWRM_FUNC_CFG_INPUT_VLAN_ANTISPOOF_MODE_VALIDATE_VLAN :
4600 HWRM_FUNC_CFG_INPUT_VLAN_ANTISPOOF_MODE_NOCHECK;
4601 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4603 HWRM_CHECK_RESULT();
4609 int bnxt_hwrm_func_qcfg_vf_dflt_vnic_id(struct bnxt *bp, int vf)
4611 struct bnxt_vnic_info vnic;
4614 int num_vnic_ids, i;
4618 vnic_id_sz = bp->pf->total_vnics * sizeof(*vnic_ids);
4619 vnic_ids = rte_malloc("bnxt_hwrm_vf_vnic_ids_query", vnic_id_sz,
4620 RTE_CACHE_LINE_SIZE);
4621 if (vnic_ids == NULL)
4624 for (sz = 0; sz < vnic_id_sz; sz += getpagesize())
4625 rte_mem_lock_page(((char *)vnic_ids) + sz);
4627 rc = bnxt_hwrm_func_vf_vnic_query(bp, vf, vnic_ids);
4633 * Loop through to find the default VNIC ID.
4634 * TODO: The easier way would be to obtain the resp->dflt_vnic_id
4635 * by sending the hwrm_func_qcfg command to the firmware.
4637 for (i = 0; i < num_vnic_ids; i++) {
4638 memset(&vnic, 0, sizeof(struct bnxt_vnic_info));
4639 vnic.fw_vnic_id = rte_le_to_cpu_16(vnic_ids[i]);
4640 rc = bnxt_hwrm_vnic_qcfg(bp, &vnic,
4641 bp->pf->first_vf_id + vf);
4644 if (vnic.func_default) {
4646 return vnic.fw_vnic_id;
4649 /* Could not find a default VNIC. */
4650 PMD_DRV_LOG(ERR, "No default VNIC\n");
4656 int bnxt_hwrm_set_em_filter(struct bnxt *bp,
4658 struct bnxt_filter_info *filter)
4661 struct hwrm_cfa_em_flow_alloc_input req = {.req_type = 0 };
4662 struct hwrm_cfa_em_flow_alloc_output *resp = bp->hwrm_cmd_resp_addr;
4663 uint32_t enables = 0;
4665 if (filter->fw_em_filter_id != UINT64_MAX)
4666 bnxt_hwrm_clear_em_filter(bp, filter);
4668 HWRM_PREP(&req, HWRM_CFA_EM_FLOW_ALLOC, BNXT_USE_KONG(bp));
4670 req.flags = rte_cpu_to_le_32(filter->flags);
4672 enables = filter->enables |
4673 HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_DST_ID;
4674 req.dst_id = rte_cpu_to_le_16(dst_id);
4676 if (filter->ip_addr_type) {
4677 req.ip_addr_type = filter->ip_addr_type;
4678 enables |= HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_IPADDR_TYPE;
4681 HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_L2_FILTER_ID)
4682 req.l2_filter_id = rte_cpu_to_le_64(filter->fw_l2_filter_id);
4684 HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_SRC_MACADDR)
4685 memcpy(req.src_macaddr, filter->src_macaddr,
4686 RTE_ETHER_ADDR_LEN);
4688 HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_DST_MACADDR)
4689 memcpy(req.dst_macaddr, filter->dst_macaddr,
4690 RTE_ETHER_ADDR_LEN);
4692 HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_OVLAN_VID)
4693 req.ovlan_vid = filter->l2_ovlan;
4695 HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_IVLAN_VID)
4696 req.ivlan_vid = filter->l2_ivlan;
4698 HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_ETHERTYPE)
4699 req.ethertype = rte_cpu_to_be_16(filter->ethertype);
4701 HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_IP_PROTOCOL)
4702 req.ip_protocol = filter->ip_protocol;
4704 HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_SRC_IPADDR)
4705 req.src_ipaddr[0] = rte_cpu_to_be_32(filter->src_ipaddr[0]);
4707 HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_DST_IPADDR)
4708 req.dst_ipaddr[0] = rte_cpu_to_be_32(filter->dst_ipaddr[0]);
4710 HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_SRC_PORT)
4711 req.src_port = rte_cpu_to_be_16(filter->src_port);
4713 HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_DST_PORT)
4714 req.dst_port = rte_cpu_to_be_16(filter->dst_port);
4716 HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_MIRROR_VNIC_ID)
4717 req.mirror_vnic_id = filter->mirror_vnic_id;
4719 req.enables = rte_cpu_to_le_32(enables);
4721 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_KONG(bp));
4723 HWRM_CHECK_RESULT();
4725 filter->fw_em_filter_id = rte_le_to_cpu_64(resp->em_filter_id);
4731 int bnxt_hwrm_clear_em_filter(struct bnxt *bp, struct bnxt_filter_info *filter)
4734 struct hwrm_cfa_em_flow_free_input req = {.req_type = 0 };
4735 struct hwrm_cfa_em_flow_free_output *resp = bp->hwrm_cmd_resp_addr;
4737 if (filter->fw_em_filter_id == UINT64_MAX)
4740 HWRM_PREP(&req, HWRM_CFA_EM_FLOW_FREE, BNXT_USE_KONG(bp));
4742 req.em_filter_id = rte_cpu_to_le_64(filter->fw_em_filter_id);
4744 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_KONG(bp));
4746 HWRM_CHECK_RESULT();
4749 filter->fw_em_filter_id = UINT64_MAX;
4750 filter->fw_l2_filter_id = UINT64_MAX;
4755 int bnxt_hwrm_set_ntuple_filter(struct bnxt *bp,
4757 struct bnxt_filter_info *filter)
4760 struct hwrm_cfa_ntuple_filter_alloc_input req = {.req_type = 0 };
4761 struct hwrm_cfa_ntuple_filter_alloc_output *resp =
4762 bp->hwrm_cmd_resp_addr;
4763 uint32_t enables = 0;
4765 if (filter->fw_ntuple_filter_id != UINT64_MAX)
4766 bnxt_hwrm_clear_ntuple_filter(bp, filter);
4768 HWRM_PREP(&req, HWRM_CFA_NTUPLE_FILTER_ALLOC, BNXT_USE_CHIMP_MB);
4770 req.flags = rte_cpu_to_le_32(filter->flags);
4772 enables = filter->enables |
4773 HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_DST_ID;
4774 req.dst_id = rte_cpu_to_le_16(dst_id);
4776 if (filter->ip_addr_type) {
4777 req.ip_addr_type = filter->ip_addr_type;
4779 HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_IPADDR_TYPE;
4782 HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_L2_FILTER_ID)
4783 req.l2_filter_id = rte_cpu_to_le_64(filter->fw_l2_filter_id);
4785 HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_SRC_MACADDR)
4786 memcpy(req.src_macaddr, filter->src_macaddr,
4787 RTE_ETHER_ADDR_LEN);
4789 HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_ETHERTYPE)
4790 req.ethertype = rte_cpu_to_be_16(filter->ethertype);
4792 HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_IP_PROTOCOL)
4793 req.ip_protocol = filter->ip_protocol;
4795 HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_SRC_IPADDR)
4796 req.src_ipaddr[0] = rte_cpu_to_le_32(filter->src_ipaddr[0]);
4798 HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_SRC_IPADDR_MASK)
4799 req.src_ipaddr_mask[0] =
4800 rte_cpu_to_le_32(filter->src_ipaddr_mask[0]);
4802 HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_DST_IPADDR)
4803 req.dst_ipaddr[0] = rte_cpu_to_le_32(filter->dst_ipaddr[0]);
4805 HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_DST_IPADDR_MASK)
4806 req.dst_ipaddr_mask[0] =
4807 rte_cpu_to_be_32(filter->dst_ipaddr_mask[0]);
4809 HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_SRC_PORT)
4810 req.src_port = rte_cpu_to_le_16(filter->src_port);
4812 HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_SRC_PORT_MASK)
4813 req.src_port_mask = rte_cpu_to_le_16(filter->src_port_mask);
4815 HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_DST_PORT)
4816 req.dst_port = rte_cpu_to_le_16(filter->dst_port);
4818 HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_DST_PORT_MASK)
4819 req.dst_port_mask = rte_cpu_to_le_16(filter->dst_port_mask);
4821 HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_MIRROR_VNIC_ID)
4822 req.mirror_vnic_id = filter->mirror_vnic_id;
4824 req.enables = rte_cpu_to_le_32(enables);
4826 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4828 HWRM_CHECK_RESULT();
4830 filter->fw_ntuple_filter_id = rte_le_to_cpu_64(resp->ntuple_filter_id);
4831 filter->flow_id = rte_le_to_cpu_32(resp->flow_id);
4837 int bnxt_hwrm_clear_ntuple_filter(struct bnxt *bp,
4838 struct bnxt_filter_info *filter)
4841 struct hwrm_cfa_ntuple_filter_free_input req = {.req_type = 0 };
4842 struct hwrm_cfa_ntuple_filter_free_output *resp =
4843 bp->hwrm_cmd_resp_addr;
4845 if (filter->fw_ntuple_filter_id == UINT64_MAX)
4848 HWRM_PREP(&req, HWRM_CFA_NTUPLE_FILTER_FREE, BNXT_USE_CHIMP_MB);
4850 req.ntuple_filter_id = rte_cpu_to_le_64(filter->fw_ntuple_filter_id);
4852 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
4854 HWRM_CHECK_RESULT();
4857 filter->fw_ntuple_filter_id = UINT64_MAX;
4863 bnxt_vnic_rss_configure_p5(struct bnxt *bp, struct bnxt_vnic_info *vnic)
4865 struct hwrm_vnic_rss_cfg_output *resp = bp->hwrm_cmd_resp_addr;
4866 uint8_t *rx_queue_state = bp->eth_dev->data->rx_queue_state;
4867 struct hwrm_vnic_rss_cfg_input req = {.req_type = 0 };
4868 struct bnxt_rx_queue **rxqs = bp->rx_queues;
4869 uint16_t *ring_tbl = vnic->rss_table;
4870 int nr_ctxs = vnic->num_lb_ctxts;
4871 int max_rings = bp->rx_nr_rings;
4875 for (i = 0, k = 0; i < nr_ctxs; i++) {
4876 struct bnxt_rx_ring_info *rxr;
4877 struct bnxt_cp_ring_info *cpr;
4879 HWRM_PREP(&req, HWRM_VNIC_RSS_CFG, BNXT_USE_CHIMP_MB);
4881 req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
4882 req.hash_type = rte_cpu_to_le_32(vnic->hash_type);
4883 req.hash_mode_flags = vnic->hash_mode;
4885 req.ring_grp_tbl_addr =
4886 rte_cpu_to_le_64(vnic->rss_table_dma_addr +
4887 i * BNXT_RSS_ENTRIES_PER_CTX_P5 *
4888 2 * sizeof(*ring_tbl));
4889 req.hash_key_tbl_addr =
4890 rte_cpu_to_le_64(vnic->rss_hash_key_dma_addr);
4892 req.ring_table_pair_index = i;
4893 req.rss_ctx_idx = rte_cpu_to_le_16(vnic->fw_grp_ids[i]);
4895 for (j = 0; j < 64; j++) {
4898 /* Find next active ring. */
4899 for (cnt = 0; cnt < max_rings; cnt++) {
4900 if (rx_queue_state[k] !=
4901 RTE_ETH_QUEUE_STATE_STOPPED)
4903 if (++k == max_rings)
4907 /* Return if no rings are active. */
4908 if (cnt == max_rings) {
4913 /* Add rx/cp ring pair to RSS table. */
4914 rxr = rxqs[k]->rx_ring;
4915 cpr = rxqs[k]->cp_ring;
4917 ring_id = rxr->rx_ring_struct->fw_ring_id;
4918 *ring_tbl++ = rte_cpu_to_le_16(ring_id);
4919 ring_id = cpr->cp_ring_struct->fw_ring_id;
4920 *ring_tbl++ = rte_cpu_to_le_16(ring_id);
4922 if (++k == max_rings)
4925 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req),
4928 HWRM_CHECK_RESULT();
4935 int bnxt_vnic_rss_configure(struct bnxt *bp, struct bnxt_vnic_info *vnic)
4937 unsigned int rss_idx, fw_idx, i;
4939 if (vnic->fw_vnic_id == INVALID_HW_RING_ID)
4942 if (!(vnic->rss_table && vnic->hash_type))
4945 if (BNXT_CHIP_P5(bp))
4946 return bnxt_vnic_rss_configure_p5(bp, vnic);
4949 * Fill the RSS hash & redirection table with
4950 * ring group ids for all VNICs
4952 for (rss_idx = 0, fw_idx = 0; rss_idx < HW_HASH_INDEX_SIZE;
4953 rss_idx++, fw_idx++) {
4954 for (i = 0; i < bp->rx_cp_nr_rings; i++) {
4955 fw_idx %= bp->rx_cp_nr_rings;
4956 if (vnic->fw_grp_ids[fw_idx] != INVALID_HW_RING_ID)
4961 if (i == bp->rx_cp_nr_rings)
4964 vnic->rss_table[rss_idx] = vnic->fw_grp_ids[fw_idx];
4967 return bnxt_hwrm_vnic_rss_cfg(bp, vnic);
4970 static void bnxt_hwrm_set_coal_params(struct bnxt_coal *hw_coal,
4971 struct hwrm_ring_cmpl_ring_cfg_aggint_params_input *req)
4975 req->num_cmpl_aggr_int = rte_cpu_to_le_16(hw_coal->num_cmpl_aggr_int);
4977 /* This is a 6-bit value and must not be 0, or we'll get non stop IRQ */
4978 req->num_cmpl_dma_aggr = rte_cpu_to_le_16(hw_coal->num_cmpl_dma_aggr);
4980 /* This is a 6-bit value and must not be 0, or we'll get non stop IRQ */
4981 req->num_cmpl_dma_aggr_during_int =
4982 rte_cpu_to_le_16(hw_coal->num_cmpl_dma_aggr_during_int);
4984 req->int_lat_tmr_max = rte_cpu_to_le_16(hw_coal->int_lat_tmr_max);
4986 /* min timer set to 1/2 of interrupt timer */
4987 req->int_lat_tmr_min = rte_cpu_to_le_16(hw_coal->int_lat_tmr_min);
4989 /* buf timer set to 1/4 of interrupt timer */
4990 req->cmpl_aggr_dma_tmr = rte_cpu_to_le_16(hw_coal->cmpl_aggr_dma_tmr);
4992 req->cmpl_aggr_dma_tmr_during_int =
4993 rte_cpu_to_le_16(hw_coal->cmpl_aggr_dma_tmr_during_int);
4995 flags = HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_FLAGS_TIMER_RESET |
4996 HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_FLAGS_RING_IDLE;
4997 req->flags = rte_cpu_to_le_16(flags);
5000 static int bnxt_hwrm_set_coal_params_p5(struct bnxt *bp,
5001 struct hwrm_ring_cmpl_ring_cfg_aggint_params_input *agg_req)
5003 struct hwrm_ring_aggint_qcaps_input req = {0};
5004 struct hwrm_ring_aggint_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
5009 HWRM_PREP(&req, HWRM_RING_AGGINT_QCAPS, BNXT_USE_CHIMP_MB);
5010 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5011 HWRM_CHECK_RESULT();
5013 agg_req->num_cmpl_dma_aggr = resp->num_cmpl_dma_aggr_max;
5014 agg_req->cmpl_aggr_dma_tmr = resp->cmpl_aggr_dma_tmr_min;
5016 flags = HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_FLAGS_TIMER_RESET |
5017 HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_FLAGS_RING_IDLE;
5018 agg_req->flags = rte_cpu_to_le_16(flags);
5020 HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_ENABLES_CMPL_AGGR_DMA_TMR |
5021 HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_ENABLES_NUM_CMPL_DMA_AGGR;
5022 agg_req->enables = rte_cpu_to_le_32(enables);
5028 int bnxt_hwrm_set_ring_coal(struct bnxt *bp,
5029 struct bnxt_coal *coal, uint16_t ring_id)
5031 struct hwrm_ring_cmpl_ring_cfg_aggint_params_input req = {0};
5032 struct hwrm_ring_cmpl_ring_cfg_aggint_params_output *resp =
5033 bp->hwrm_cmd_resp_addr;
5036 /* Set ring coalesce parameters only for 100G NICs */
5037 if (BNXT_CHIP_P5(bp)) {
5038 if (bnxt_hwrm_set_coal_params_p5(bp, &req))
5040 } else if (bnxt_stratus_device(bp)) {
5041 bnxt_hwrm_set_coal_params(coal, &req);
5047 HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS,
5049 req.ring_id = rte_cpu_to_le_16(ring_id);
5050 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5051 HWRM_CHECK_RESULT();
5056 #define BNXT_RTE_MEMZONE_FLAG (RTE_MEMZONE_1GB | RTE_MEMZONE_IOVA_CONTIG)
5057 int bnxt_hwrm_func_backing_store_qcaps(struct bnxt *bp)
5059 struct hwrm_func_backing_store_qcaps_input req = {0};
5060 struct hwrm_func_backing_store_qcaps_output *resp =
5061 bp->hwrm_cmd_resp_addr;
5062 struct bnxt_ctx_pg_info *ctx_pg;
5063 struct bnxt_ctx_mem_info *ctx;
5064 int total_alloc_len;
5065 int rc, i, tqm_rings;
5067 if (!BNXT_CHIP_P5(bp) ||
5068 bp->hwrm_spec_code < HWRM_VERSION_1_9_2 ||
5073 HWRM_PREP(&req, HWRM_FUNC_BACKING_STORE_QCAPS, BNXT_USE_CHIMP_MB);
5074 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5075 HWRM_CHECK_RESULT_SILENT();
5077 total_alloc_len = sizeof(*ctx);
5078 ctx = rte_zmalloc("bnxt_ctx_mem", total_alloc_len,
5079 RTE_CACHE_LINE_SIZE);
5085 ctx->qp_max_entries = rte_le_to_cpu_32(resp->qp_max_entries);
5086 ctx->qp_min_qp1_entries =
5087 rte_le_to_cpu_16(resp->qp_min_qp1_entries);
5088 ctx->qp_max_l2_entries =
5089 rte_le_to_cpu_16(resp->qp_max_l2_entries);
5090 ctx->qp_entry_size = rte_le_to_cpu_16(resp->qp_entry_size);
5091 ctx->srq_max_l2_entries =
5092 rte_le_to_cpu_16(resp->srq_max_l2_entries);
5093 ctx->srq_max_entries = rte_le_to_cpu_32(resp->srq_max_entries);
5094 ctx->srq_entry_size = rte_le_to_cpu_16(resp->srq_entry_size);
5095 ctx->cq_max_l2_entries =
5096 rte_le_to_cpu_16(resp->cq_max_l2_entries);
5097 ctx->cq_max_entries = rte_le_to_cpu_32(resp->cq_max_entries);
5098 ctx->cq_entry_size = rte_le_to_cpu_16(resp->cq_entry_size);
5099 ctx->vnic_max_vnic_entries =
5100 rte_le_to_cpu_16(resp->vnic_max_vnic_entries);
5101 ctx->vnic_max_ring_table_entries =
5102 rte_le_to_cpu_16(resp->vnic_max_ring_table_entries);
5103 ctx->vnic_entry_size = rte_le_to_cpu_16(resp->vnic_entry_size);
5104 ctx->stat_max_entries =
5105 rte_le_to_cpu_32(resp->stat_max_entries);
5106 ctx->stat_entry_size = rte_le_to_cpu_16(resp->stat_entry_size);
5107 ctx->tqm_entry_size = rte_le_to_cpu_16(resp->tqm_entry_size);
5108 ctx->tqm_min_entries_per_ring =
5109 rte_le_to_cpu_32(resp->tqm_min_entries_per_ring);
5110 ctx->tqm_max_entries_per_ring =
5111 rte_le_to_cpu_32(resp->tqm_max_entries_per_ring);
5112 ctx->tqm_entries_multiple = resp->tqm_entries_multiple;
5113 if (!ctx->tqm_entries_multiple)
5114 ctx->tqm_entries_multiple = 1;
5115 ctx->mrav_max_entries =
5116 rte_le_to_cpu_32(resp->mrav_max_entries);
5117 ctx->mrav_entry_size = rte_le_to_cpu_16(resp->mrav_entry_size);
5118 ctx->tim_entry_size = rte_le_to_cpu_16(resp->tim_entry_size);
5119 ctx->tim_max_entries = rte_le_to_cpu_32(resp->tim_max_entries);
5120 ctx->tqm_fp_rings_count = resp->tqm_fp_rings_count;
5122 if (!ctx->tqm_fp_rings_count)
5123 ctx->tqm_fp_rings_count = bp->max_q;
5125 tqm_rings = ctx->tqm_fp_rings_count + 1;
5127 ctx_pg = rte_malloc("bnxt_ctx_pg_mem",
5128 sizeof(*ctx_pg) * tqm_rings,
5129 RTE_CACHE_LINE_SIZE);
5134 for (i = 0; i < tqm_rings; i++, ctx_pg++)
5135 ctx->tqm_mem[i] = ctx_pg;
5143 int bnxt_hwrm_func_backing_store_cfg(struct bnxt *bp, uint32_t enables)
5145 struct hwrm_func_backing_store_cfg_input req = {0};
5146 struct hwrm_func_backing_store_cfg_output *resp =
5147 bp->hwrm_cmd_resp_addr;
5148 struct bnxt_ctx_mem_info *ctx = bp->ctx;
5149 struct bnxt_ctx_pg_info *ctx_pg;
5150 uint32_t *num_entries;
5159 HWRM_PREP(&req, HWRM_FUNC_BACKING_STORE_CFG, BNXT_USE_CHIMP_MB);
5160 req.enables = rte_cpu_to_le_32(enables);
5162 if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_QP) {
5163 ctx_pg = &ctx->qp_mem;
5164 req.qp_num_entries = rte_cpu_to_le_32(ctx_pg->entries);
5165 req.qp_num_qp1_entries =
5166 rte_cpu_to_le_16(ctx->qp_min_qp1_entries);
5167 req.qp_num_l2_entries =
5168 rte_cpu_to_le_16(ctx->qp_max_l2_entries);
5169 req.qp_entry_size = rte_cpu_to_le_16(ctx->qp_entry_size);
5170 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem,
5171 &req.qpc_pg_size_qpc_lvl,
5175 if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_SRQ) {
5176 ctx_pg = &ctx->srq_mem;
5177 req.srq_num_entries = rte_cpu_to_le_32(ctx_pg->entries);
5178 req.srq_num_l2_entries =
5179 rte_cpu_to_le_16(ctx->srq_max_l2_entries);
5180 req.srq_entry_size = rte_cpu_to_le_16(ctx->srq_entry_size);
5181 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem,
5182 &req.srq_pg_size_srq_lvl,
5186 if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_CQ) {
5187 ctx_pg = &ctx->cq_mem;
5188 req.cq_num_entries = rte_cpu_to_le_32(ctx_pg->entries);
5189 req.cq_num_l2_entries =
5190 rte_cpu_to_le_16(ctx->cq_max_l2_entries);
5191 req.cq_entry_size = rte_cpu_to_le_16(ctx->cq_entry_size);
5192 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem,
5193 &req.cq_pg_size_cq_lvl,
5197 if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_VNIC) {
5198 ctx_pg = &ctx->vnic_mem;
5199 req.vnic_num_vnic_entries =
5200 rte_cpu_to_le_16(ctx->vnic_max_vnic_entries);
5201 req.vnic_num_ring_table_entries =
5202 rte_cpu_to_le_16(ctx->vnic_max_ring_table_entries);
5203 req.vnic_entry_size = rte_cpu_to_le_16(ctx->vnic_entry_size);
5204 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem,
5205 &req.vnic_pg_size_vnic_lvl,
5206 &req.vnic_page_dir);
5209 if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_STAT) {
5210 ctx_pg = &ctx->stat_mem;
5211 req.stat_num_entries = rte_cpu_to_le_16(ctx->stat_max_entries);
5212 req.stat_entry_size = rte_cpu_to_le_16(ctx->stat_entry_size);
5213 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem,
5214 &req.stat_pg_size_stat_lvl,
5215 &req.stat_page_dir);
5218 req.tqm_entry_size = rte_cpu_to_le_16(ctx->tqm_entry_size);
5219 num_entries = &req.tqm_sp_num_entries;
5220 pg_attr = &req.tqm_sp_pg_size_tqm_sp_lvl;
5221 pg_dir = &req.tqm_sp_page_dir;
5222 ena = HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_SP;
5223 for (i = 0; i < 9; i++, num_entries++, pg_attr++, pg_dir++, ena <<= 1) {
5224 if (!(enables & ena))
5227 req.tqm_entry_size = rte_cpu_to_le_16(ctx->tqm_entry_size);
5229 ctx_pg = ctx->tqm_mem[i];
5230 *num_entries = rte_cpu_to_le_16(ctx_pg->entries);
5231 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, pg_attr, pg_dir);
5234 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5235 HWRM_CHECK_RESULT();
5241 int bnxt_hwrm_ext_port_qstats(struct bnxt *bp)
5243 struct hwrm_port_qstats_ext_input req = {0};
5244 struct hwrm_port_qstats_ext_output *resp = bp->hwrm_cmd_resp_addr;
5245 struct bnxt_pf_info *pf = bp->pf;
5248 if (!(bp->flags & BNXT_FLAG_EXT_RX_PORT_STATS ||
5249 bp->flags & BNXT_FLAG_EXT_TX_PORT_STATS))
5252 HWRM_PREP(&req, HWRM_PORT_QSTATS_EXT, BNXT_USE_CHIMP_MB);
5254 req.port_id = rte_cpu_to_le_16(pf->port_id);
5255 if (bp->flags & BNXT_FLAG_EXT_TX_PORT_STATS) {
5256 req.tx_stat_host_addr =
5257 rte_cpu_to_le_64(bp->hw_tx_port_stats_ext_map);
5259 rte_cpu_to_le_16(sizeof(struct tx_port_stats_ext));
5261 if (bp->flags & BNXT_FLAG_EXT_RX_PORT_STATS) {
5262 req.rx_stat_host_addr =
5263 rte_cpu_to_le_64(bp->hw_rx_port_stats_ext_map);
5265 rte_cpu_to_le_16(sizeof(struct rx_port_stats_ext));
5267 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5270 bp->fw_rx_port_stats_ext_size = 0;
5271 bp->fw_tx_port_stats_ext_size = 0;
5273 bp->fw_rx_port_stats_ext_size =
5274 rte_le_to_cpu_16(resp->rx_stat_size);
5275 bp->fw_tx_port_stats_ext_size =
5276 rte_le_to_cpu_16(resp->tx_stat_size);
5279 HWRM_CHECK_RESULT();
5286 bnxt_hwrm_tunnel_redirect(struct bnxt *bp, uint8_t type)
5288 struct hwrm_cfa_redirect_tunnel_type_alloc_input req = {0};
5289 struct hwrm_cfa_redirect_tunnel_type_alloc_output *resp =
5290 bp->hwrm_cmd_resp_addr;
5293 HWRM_PREP(&req, HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC, BNXT_USE_CHIMP_MB);
5294 req.tunnel_type = type;
5295 req.dest_fid = bp->fw_fid;
5296 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5297 HWRM_CHECK_RESULT();
5305 bnxt_hwrm_tunnel_redirect_free(struct bnxt *bp, uint8_t type)
5307 struct hwrm_cfa_redirect_tunnel_type_free_input req = {0};
5308 struct hwrm_cfa_redirect_tunnel_type_free_output *resp =
5309 bp->hwrm_cmd_resp_addr;
5312 HWRM_PREP(&req, HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE, BNXT_USE_CHIMP_MB);
5313 req.tunnel_type = type;
5314 req.dest_fid = bp->fw_fid;
5315 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5316 HWRM_CHECK_RESULT();
5323 int bnxt_hwrm_tunnel_redirect_query(struct bnxt *bp, uint32_t *type)
5325 struct hwrm_cfa_redirect_query_tunnel_type_input req = {0};
5326 struct hwrm_cfa_redirect_query_tunnel_type_output *resp =
5327 bp->hwrm_cmd_resp_addr;
5330 HWRM_PREP(&req, HWRM_CFA_REDIRECT_QUERY_TUNNEL_TYPE, BNXT_USE_CHIMP_MB);
5331 req.src_fid = bp->fw_fid;
5332 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5333 HWRM_CHECK_RESULT();
5336 *type = rte_le_to_cpu_32(resp->tunnel_mask);
5343 int bnxt_hwrm_tunnel_redirect_info(struct bnxt *bp, uint8_t tun_type,
5346 struct hwrm_cfa_redirect_tunnel_type_info_input req = {0};
5347 struct hwrm_cfa_redirect_tunnel_type_info_output *resp =
5348 bp->hwrm_cmd_resp_addr;
5351 HWRM_PREP(&req, HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO, BNXT_USE_CHIMP_MB);
5352 req.src_fid = bp->fw_fid;
5353 req.tunnel_type = tun_type;
5354 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5355 HWRM_CHECK_RESULT();
5358 *dst_fid = rte_le_to_cpu_16(resp->dest_fid);
5360 PMD_DRV_LOG(DEBUG, "dst_fid: %x\n", resp->dest_fid);
5367 int bnxt_hwrm_set_mac(struct bnxt *bp)
5369 struct hwrm_func_vf_cfg_output *resp = bp->hwrm_cmd_resp_addr;
5370 struct hwrm_func_vf_cfg_input req = {0};
5376 HWRM_PREP(&req, HWRM_FUNC_VF_CFG, BNXT_USE_CHIMP_MB);
5379 rte_cpu_to_le_32(HWRM_FUNC_VF_CFG_INPUT_ENABLES_DFLT_MAC_ADDR);
5380 memcpy(req.dflt_mac_addr, bp->mac_addr, RTE_ETHER_ADDR_LEN);
5382 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5384 HWRM_CHECK_RESULT();
5391 int bnxt_hwrm_if_change(struct bnxt *bp, bool up)
5393 struct hwrm_func_drv_if_change_output *resp = bp->hwrm_cmd_resp_addr;
5394 struct hwrm_func_drv_if_change_input req = {0};
5398 if (!(bp->fw_cap & BNXT_FW_CAP_IF_CHANGE))
5401 /* Do not issue FUNC_DRV_IF_CHANGE during reset recovery.
5402 * If we issue FUNC_DRV_IF_CHANGE with flags down before
5403 * FUNC_DRV_UNRGTR, FW resets before FUNC_DRV_UNRGTR
5405 if (!up && (bp->flags & BNXT_FLAG_FW_RESET))
5408 HWRM_PREP(&req, HWRM_FUNC_DRV_IF_CHANGE, BNXT_USE_CHIMP_MB);
5412 rte_cpu_to_le_32(HWRM_FUNC_DRV_IF_CHANGE_INPUT_FLAGS_UP);
5414 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5416 HWRM_CHECK_RESULT();
5417 flags = rte_le_to_cpu_32(resp->flags);
5423 if (flags & HWRM_FUNC_DRV_IF_CHANGE_OUTPUT_FLAGS_HOT_FW_RESET_DONE) {
5424 PMD_DRV_LOG(INFO, "FW reset happened while port was down\n");
5425 bp->flags |= BNXT_FLAG_IF_CHANGE_HOT_FW_RESET_DONE;
5431 int bnxt_hwrm_error_recovery_qcfg(struct bnxt *bp)
5433 struct hwrm_error_recovery_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
5434 struct bnxt_error_recovery_info *info = bp->recovery_info;
5435 struct hwrm_error_recovery_qcfg_input req = {0};
5440 /* Older FW does not have error recovery support */
5441 if (!(bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY))
5444 HWRM_PREP(&req, HWRM_ERROR_RECOVERY_QCFG, BNXT_USE_CHIMP_MB);
5446 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5448 HWRM_CHECK_RESULT();
5450 flags = rte_le_to_cpu_32(resp->flags);
5451 if (flags & HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FLAGS_HOST)
5452 info->flags |= BNXT_FLAG_ERROR_RECOVERY_HOST;
5453 else if (flags & HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FLAGS_CO_CPU)
5454 info->flags |= BNXT_FLAG_ERROR_RECOVERY_CO_CPU;
5456 if ((info->flags & BNXT_FLAG_ERROR_RECOVERY_CO_CPU) &&
5457 !(bp->flags & BNXT_FLAG_KONG_MB_EN)) {
5462 /* FW returned values are in units of 100msec */
5463 info->driver_polling_freq =
5464 rte_le_to_cpu_32(resp->driver_polling_freq) * 100;
5465 info->master_func_wait_period =
5466 rte_le_to_cpu_32(resp->master_func_wait_period) * 100;
5467 info->normal_func_wait_period =
5468 rte_le_to_cpu_32(resp->normal_func_wait_period) * 100;
5469 info->master_func_wait_period_after_reset =
5470 rte_le_to_cpu_32(resp->master_func_wait_period_after_reset) * 100;
5471 info->max_bailout_time_after_reset =
5472 rte_le_to_cpu_32(resp->max_bailout_time_after_reset) * 100;
5473 info->status_regs[BNXT_FW_STATUS_REG] =
5474 rte_le_to_cpu_32(resp->fw_health_status_reg);
5475 info->status_regs[BNXT_FW_HEARTBEAT_CNT_REG] =
5476 rte_le_to_cpu_32(resp->fw_heartbeat_reg);
5477 info->status_regs[BNXT_FW_RECOVERY_CNT_REG] =
5478 rte_le_to_cpu_32(resp->fw_reset_cnt_reg);
5479 info->status_regs[BNXT_FW_RESET_INPROG_REG] =
5480 rte_le_to_cpu_32(resp->reset_inprogress_reg);
5481 info->reg_array_cnt =
5482 rte_le_to_cpu_32(resp->reg_array_cnt);
5484 if (info->reg_array_cnt >= BNXT_NUM_RESET_REG) {
5489 for (i = 0; i < info->reg_array_cnt; i++) {
5490 info->reset_reg[i] =
5491 rte_le_to_cpu_32(resp->reset_reg[i]);
5492 info->reset_reg_val[i] =
5493 rte_le_to_cpu_32(resp->reset_reg_val[i]);
5494 info->delay_after_reset[i] =
5495 resp->delay_after_reset[i];
5500 /* Map the FW status registers */
5502 rc = bnxt_map_fw_health_status_regs(bp);
5505 rte_free(bp->recovery_info);
5506 bp->recovery_info = NULL;
5511 int bnxt_hwrm_fw_reset(struct bnxt *bp)
5513 struct hwrm_fw_reset_output *resp = bp->hwrm_cmd_resp_addr;
5514 struct hwrm_fw_reset_input req = {0};
5520 HWRM_PREP(&req, HWRM_FW_RESET, BNXT_USE_KONG(bp));
5522 req.embedded_proc_type =
5523 HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_CHIP;
5524 req.selfrst_status =
5525 HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTASAP;
5526 req.flags = HWRM_FW_RESET_INPUT_FLAGS_RESET_GRACEFUL;
5528 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req),
5531 HWRM_CHECK_RESULT();
5537 int bnxt_hwrm_port_ts_query(struct bnxt *bp, uint8_t path, uint64_t *timestamp)
5539 struct hwrm_port_ts_query_output *resp = bp->hwrm_cmd_resp_addr;
5540 struct hwrm_port_ts_query_input req = {0};
5541 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
5548 HWRM_PREP(&req, HWRM_PORT_TS_QUERY, BNXT_USE_CHIMP_MB);
5551 case BNXT_PTP_FLAGS_PATH_TX:
5552 flags |= HWRM_PORT_TS_QUERY_INPUT_FLAGS_PATH_TX;
5554 case BNXT_PTP_FLAGS_PATH_RX:
5555 flags |= HWRM_PORT_TS_QUERY_INPUT_FLAGS_PATH_RX;
5557 case BNXT_PTP_FLAGS_CURRENT_TIME:
5558 flags |= HWRM_PORT_TS_QUERY_INPUT_FLAGS_CURRENT_TIME;
5562 req.flags = rte_cpu_to_le_32(flags);
5563 req.port_id = rte_cpu_to_le_16(bp->pf->port_id);
5565 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5567 HWRM_CHECK_RESULT();
5570 *timestamp = rte_le_to_cpu_32(resp->ptp_msg_ts[0]);
5572 (uint64_t)(rte_le_to_cpu_32(resp->ptp_msg_ts[1])) << 32;
5579 int bnxt_hwrm_cfa_counter_qcaps(struct bnxt *bp, uint16_t *max_fc)
5583 struct hwrm_cfa_counter_qcaps_input req = {0};
5584 struct hwrm_cfa_counter_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
5586 if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) {
5588 "Not a PF or trusted VF. Command not supported\n");
5592 HWRM_PREP(&req, HWRM_CFA_COUNTER_QCAPS, BNXT_USE_KONG(bp));
5593 req.target_id = rte_cpu_to_le_16(bp->fw_fid);
5594 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_KONG(bp));
5596 HWRM_CHECK_RESULT();
5598 *max_fc = rte_le_to_cpu_16(resp->max_rx_fc);
5604 int bnxt_hwrm_ctx_rgtr(struct bnxt *bp, rte_iova_t dma_addr, uint16_t *ctx_id)
5607 struct hwrm_cfa_ctx_mem_rgtr_input req = {.req_type = 0 };
5608 struct hwrm_cfa_ctx_mem_rgtr_output *resp = bp->hwrm_cmd_resp_addr;
5610 if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) {
5612 "Not a PF or trusted VF. Command not supported\n");
5616 HWRM_PREP(&req, HWRM_CFA_CTX_MEM_RGTR, BNXT_USE_KONG(bp));
5618 req.page_level = HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_LEVEL_LVL_0;
5619 req.page_size = HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_SIZE_2M;
5620 req.page_dir = rte_cpu_to_le_64(dma_addr);
5622 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_KONG(bp));
5624 HWRM_CHECK_RESULT();
5626 *ctx_id = rte_le_to_cpu_16(resp->ctx_id);
5627 PMD_DRV_LOG(DEBUG, "ctx_id = %d\n", *ctx_id);
5634 int bnxt_hwrm_ctx_unrgtr(struct bnxt *bp, uint16_t ctx_id)
5637 struct hwrm_cfa_ctx_mem_unrgtr_input req = {.req_type = 0 };
5638 struct hwrm_cfa_ctx_mem_unrgtr_output *resp = bp->hwrm_cmd_resp_addr;
5640 if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) {
5642 "Not a PF or trusted VF. Command not supported\n");
5646 HWRM_PREP(&req, HWRM_CFA_CTX_MEM_UNRGTR, BNXT_USE_KONG(bp));
5648 req.ctx_id = rte_cpu_to_le_16(ctx_id);
5650 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_KONG(bp));
5652 HWRM_CHECK_RESULT();
5658 int bnxt_hwrm_cfa_counter_cfg(struct bnxt *bp, enum bnxt_flow_dir dir,
5659 uint16_t cntr, uint16_t ctx_id,
5660 uint32_t num_entries, bool enable)
5662 struct hwrm_cfa_counter_cfg_input req = {0};
5663 struct hwrm_cfa_counter_cfg_output *resp = bp->hwrm_cmd_resp_addr;
5667 if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) {
5669 "Not a PF or trusted VF. Command not supported\n");
5673 HWRM_PREP(&req, HWRM_CFA_COUNTER_CFG, BNXT_USE_KONG(bp));
5675 req.target_id = rte_cpu_to_le_16(bp->fw_fid);
5676 req.counter_type = rte_cpu_to_le_16(cntr);
5677 flags = enable ? HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_CFG_MODE_ENABLE :
5678 HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_CFG_MODE_DISABLE;
5679 flags |= HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_DATA_TRANSFER_MODE_PULL;
5680 if (dir == BNXT_DIR_RX)
5681 flags |= HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_PATH_RX;
5682 else if (dir == BNXT_DIR_TX)
5683 flags |= HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_PATH_TX;
5684 req.flags = rte_cpu_to_le_16(flags);
5685 req.ctx_id = rte_cpu_to_le_16(ctx_id);
5686 req.num_entries = rte_cpu_to_le_32(num_entries);
5688 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_KONG(bp));
5689 HWRM_CHECK_RESULT();
5695 int bnxt_hwrm_cfa_counter_qstats(struct bnxt *bp,
5696 enum bnxt_flow_dir dir,
5698 uint16_t num_entries)
5700 struct hwrm_cfa_counter_qstats_output *resp = bp->hwrm_cmd_resp_addr;
5701 struct hwrm_cfa_counter_qstats_input req = {0};
5702 uint16_t flow_ctx_id = 0;
5706 if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) {
5708 "Not a PF or trusted VF. Command not supported\n");
5712 if (dir == BNXT_DIR_RX) {
5713 flow_ctx_id = bp->flow_stat->rx_fc_in_tbl.ctx_id;
5714 flags = HWRM_CFA_COUNTER_QSTATS_INPUT_FLAGS_PATH_RX;
5715 } else if (dir == BNXT_DIR_TX) {
5716 flow_ctx_id = bp->flow_stat->tx_fc_in_tbl.ctx_id;
5717 flags = HWRM_CFA_COUNTER_QSTATS_INPUT_FLAGS_PATH_TX;
5720 HWRM_PREP(&req, HWRM_CFA_COUNTER_QSTATS, BNXT_USE_KONG(bp));
5721 req.target_id = rte_cpu_to_le_16(bp->fw_fid);
5722 req.counter_type = rte_cpu_to_le_16(cntr);
5723 req.input_flow_ctx_id = rte_cpu_to_le_16(flow_ctx_id);
5724 req.num_entries = rte_cpu_to_le_16(num_entries);
5725 req.flags = rte_cpu_to_le_16(flags);
5726 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_KONG(bp));
5728 HWRM_CHECK_RESULT();
5734 int bnxt_hwrm_first_vf_id_query(struct bnxt *bp, uint16_t fid,
5735 uint16_t *first_vf_id)
5738 struct hwrm_func_qcaps_input req = {.req_type = 0 };
5739 struct hwrm_func_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
5741 HWRM_PREP(&req, HWRM_FUNC_QCAPS, BNXT_USE_CHIMP_MB);
5743 req.fid = rte_cpu_to_le_16(fid);
5745 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5747 HWRM_CHECK_RESULT();
5750 *first_vf_id = rte_le_to_cpu_16(resp->first_vf_id);
5757 int bnxt_hwrm_cfa_pair_alloc(struct bnxt *bp, struct bnxt_representor *rep_bp)
5759 struct hwrm_cfa_pair_alloc_output *resp = bp->hwrm_cmd_resp_addr;
5760 struct hwrm_cfa_pair_alloc_input req = {0};
5763 if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) {
5765 "Not a PF or trusted VF. Command not supported\n");
5769 HWRM_PREP(&req, HWRM_CFA_PAIR_ALLOC, BNXT_USE_CHIMP_MB);
5770 req.pair_mode = HWRM_CFA_PAIR_FREE_INPUT_PAIR_MODE_REP2FN_TRUFLOW;
5771 snprintf(req.pair_name, sizeof(req.pair_name), "%svfr%d",
5772 bp->eth_dev->data->name, rep_bp->vf_id);
5774 req.pf_b_id = rep_bp->parent_pf_idx;
5775 req.vf_b_id = BNXT_REP_PF(rep_bp) ? rte_cpu_to_le_16(((uint16_t)-1)) :
5776 rte_cpu_to_le_16(rep_bp->vf_id);
5777 req.vf_a_id = rte_cpu_to_le_16(bp->fw_fid);
5778 req.host_b_id = 1; /* TBD - Confirm if this is OK */
5780 req.enables |= rep_bp->flags & BNXT_REP_Q_R2F_VALID ?
5781 HWRM_CFA_PAIR_ALLOC_INPUT_ENABLES_Q_AB_VALID : 0;
5782 req.enables |= rep_bp->flags & BNXT_REP_Q_F2R_VALID ?
5783 HWRM_CFA_PAIR_ALLOC_INPUT_ENABLES_Q_BA_VALID : 0;
5784 req.enables |= rep_bp->flags & BNXT_REP_FC_R2F_VALID ?
5785 HWRM_CFA_PAIR_ALLOC_INPUT_ENABLES_FC_AB_VALID : 0;
5786 req.enables |= rep_bp->flags & BNXT_REP_FC_F2R_VALID ?
5787 HWRM_CFA_PAIR_ALLOC_INPUT_ENABLES_FC_BA_VALID : 0;
5789 req.q_ab = rep_bp->rep_q_r2f;
5790 req.q_ba = rep_bp->rep_q_f2r;
5791 req.fc_ab = rep_bp->rep_fc_r2f;
5792 req.fc_ba = rep_bp->rep_fc_f2r;
5794 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5795 HWRM_CHECK_RESULT();
5798 PMD_DRV_LOG(DEBUG, "%s %d allocated\n",
5799 BNXT_REP_PF(rep_bp) ? "PFR" : "VFR", rep_bp->vf_id);
5803 int bnxt_hwrm_cfa_pair_free(struct bnxt *bp, struct bnxt_representor *rep_bp)
5805 struct hwrm_cfa_pair_free_output *resp = bp->hwrm_cmd_resp_addr;
5806 struct hwrm_cfa_pair_free_input req = {0};
5809 if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) {
5811 "Not a PF or trusted VF. Command not supported\n");
5815 HWRM_PREP(&req, HWRM_CFA_PAIR_FREE, BNXT_USE_CHIMP_MB);
5816 snprintf(req.pair_name, sizeof(req.pair_name), "%svfr%d",
5817 bp->eth_dev->data->name, rep_bp->vf_id);
5818 req.pf_b_id = rep_bp->parent_pf_idx;
5819 req.pair_mode = HWRM_CFA_PAIR_FREE_INPUT_PAIR_MODE_REP2FN_TRUFLOW;
5820 req.vf_id = BNXT_REP_PF(rep_bp) ? rte_cpu_to_le_16(((uint16_t)-1)) :
5821 rte_cpu_to_le_16(rep_bp->vf_id);
5822 rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
5823 HWRM_CHECK_RESULT();
5825 PMD_DRV_LOG(DEBUG, "%s %d freed\n", BNXT_REP_PF(rep_bp) ? "PFR" : "VFR",