1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2014-2018 Broadcom
6 #include <rte_malloc.h>
10 #include "bnxt_hwrm.h"
11 #include "bnxt_ring.h"
12 #include "hsi_struct_def_dpdk.h"
15 * Async event handling
17 void bnxt_handle_async_event(struct bnxt *bp,
18 struct cmpl_base *cmp)
20 struct hwrm_async_event_cmpl *async_cmp =
21 (struct hwrm_async_event_cmpl *)cmp;
22 uint16_t event_id = rte_le_to_cpu_16(async_cmp->event_id);
24 /* TODO: HWRM async events are not defined yet */
25 /* Needs to handle: link events, error events, etc. */
27 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE:
28 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CHANGE:
29 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE:
31 bnxt_link_update_op(bp->eth_dev, 1);
33 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_UNLOAD:
34 PMD_DRV_LOG(INFO, "Async event: PF driver unloaded\n");
36 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_VF_CFG_CHANGE:
37 PMD_DRV_LOG(INFO, "Async event: VF config changed\n");
38 bnxt_hwrm_func_qcfg(bp);
40 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PORT_CONN_NOT_ALLOWED:
41 PMD_DRV_LOG(INFO, "Port conn async event\n");
44 PMD_DRV_LOG(INFO, "handle_async_event id = 0x%x\n", event_id);
49 void bnxt_handle_fwd_req(struct bnxt *bp, struct cmpl_base *cmpl)
51 struct hwrm_exec_fwd_resp_input *fwreq;
52 struct hwrm_fwd_req_cmpl *fwd_cmpl = (struct hwrm_fwd_req_cmpl *)cmpl;
53 struct input *fwd_cmd;
59 if (bp->pf.active_vfs <= 0) {
60 PMD_DRV_LOG(ERR, "Forwarded VF with no active VFs\n");
64 /* Qualify the fwd request */
65 fw_vf_id = rte_le_to_cpu_16(fwd_cmpl->source_id);
66 vf_id = fw_vf_id - bp->pf.first_vf_id;
68 req_len = (rte_le_to_cpu_16(fwd_cmpl->req_len_type) &
69 HWRM_FWD_REQ_CMPL_REQ_LEN_MASK) >>
70 HWRM_FWD_REQ_CMPL_REQ_LEN_SFT;
71 if (req_len > sizeof(fwreq->encap_request))
72 req_len = sizeof(fwreq->encap_request);
74 /* Locate VF's forwarded command */
75 fwd_cmd = (struct input *)bp->pf.vf_info[vf_id].req_buf;
77 if (fw_vf_id < bp->pf.first_vf_id ||
78 fw_vf_id >= (bp->pf.first_vf_id) + bp->pf.active_vfs) {
80 "FWD req's source_id 0x%x out of range 0x%x - 0x%x (%d %d)\n",
81 fw_vf_id, bp->pf.first_vf_id,
82 (bp->pf.first_vf_id) + bp->pf.active_vfs - 1,
83 bp->pf.first_vf_id, bp->pf.active_vfs);
87 if (bnxt_rcv_msg_from_vf(bp, vf_id, fwd_cmd) == true) {
89 * In older firmware versions, the MAC had to be all zeros for
90 * the VF to set it's MAC via hwrm_func_vf_cfg. Set to all
91 * zeros if it's being configured and has been ok'd by caller.
93 if (fwd_cmd->req_type == HWRM_FUNC_VF_CFG) {
94 struct hwrm_func_vf_cfg_input *vfc = (void *)fwd_cmd;
97 HWRM_FUNC_VF_CFG_INPUT_ENABLES_DFLT_MAC_ADDR) {
98 bnxt_hwrm_func_vf_mac(bp, vf_id,
99 (const uint8_t *)"\x00\x00\x00\x00\x00");
102 if (fwd_cmd->req_type == HWRM_CFA_L2_SET_RX_MASK) {
103 struct hwrm_cfa_l2_set_rx_mask_input *srm =
106 srm->vlan_tag_tbl_addr = rte_cpu_to_le_64(0);
107 srm->num_vlan_tags = rte_cpu_to_le_32(0);
108 srm->mask &= ~rte_cpu_to_le_32(
109 HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_VLANONLY |
110 HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_VLAN_NONVLAN |
111 HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ANYVLAN_NONVLAN);
114 rc = bnxt_hwrm_exec_fwd_resp(bp, fw_vf_id, fwd_cmd, req_len);
117 "Failed to send FWD req VF 0x%x, type 0x%x.\n",
118 fw_vf_id - bp->pf.first_vf_id,
119 rte_le_to_cpu_16(fwd_cmd->req_type));
125 rc = bnxt_hwrm_reject_fwd_resp(bp, fw_vf_id, fwd_cmd, req_len);
128 "Failed to send REJECT req VF 0x%x, type 0x%x.\n",
129 fw_vf_id - bp->pf.first_vf_id,
130 rte_le_to_cpu_16(fwd_cmd->req_type));
136 int bnxt_event_hwrm_resp_handler(struct bnxt *bp, struct cmpl_base *cmp)
140 if (bp == NULL || cmp == NULL) {
141 PMD_DRV_LOG(ERR, "invalid NULL argument\n");
145 switch (CMP_TYPE(cmp)) {
146 case CMPL_BASE_TYPE_HWRM_ASYNC_EVENT:
147 /* Handle any async event */
148 bnxt_handle_async_event(bp, cmp);
151 case CMPL_BASE_TYPE_HWRM_FWD_RESP:
152 /* Handle HWRM forwarded responses */
153 bnxt_handle_fwd_req(bp, cmp);
157 /* Ignore any other events */
158 PMD_DRV_LOG(INFO, "Ignoring %02x completion\n", CMP_TYPE(cmp));