4 * Copyright(c) Broadcom Limited.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Broadcom Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 #include "bnxt_hwrm.h"
37 #include "bnxt_ring.h"
40 * Async event handling
42 void bnxt_handle_async_event(struct bnxt *bp __rte_unused,
43 struct cmpl_base *cmp)
45 struct hwrm_async_event_cmpl *async_cmp =
46 (struct hwrm_async_event_cmpl *)cmp;
48 /* TODO: HWRM async events are not defined yet */
49 /* Needs to handle: link events, error events, etc. */
50 switch (async_cmp->event_id) {
52 /* Assume LINK_CHANGE == 0 */
53 RTE_LOG(INFO, PMD, "Link change event\n");
55 /* Can just prompt the update_op routine to do a qcfg
56 * instead of doing the actual qcfg
62 RTE_LOG(ERR, PMD, "handle_async_event id = 0x%x\n",
68 void bnxt_handle_fwd_req(struct bnxt *bp, struct cmpl_base *cmpl)
70 struct hwrm_fwd_req_cmpl *fwd_cmpl = (struct hwrm_fwd_req_cmpl *)cmpl;
71 struct input *fwd_cmd;
72 uint16_t logical_vf_id, error_code;
74 /* Qualify the fwd request */
75 if (fwd_cmpl->source_id < bp->pf.first_vf_id) {
77 "FWD req's source_id 0x%x > first_vf_id 0x%x\n",
78 fwd_cmpl->source_id, bp->pf.first_vf_id);
79 error_code = HWRM_ERR_CODE_RESOURCE_ACCESS_DENIED;
81 } else if (fwd_cmpl->req_len_type >> HWRM_FWD_REQ_CMPL_REQ_LEN_SFT >
82 128 - sizeof(struct input)) {
84 "FWD req's cmd len 0x%x > 108 bytes allowed\n",
85 fwd_cmpl->req_len_type >> HWRM_FWD_REQ_CMPL_REQ_LEN_SFT);
86 error_code = HWRM_ERR_CODE_INVALID_PARAMS;
90 /* Locate VF's forwarded command */
91 logical_vf_id = fwd_cmpl->source_id - bp->pf.first_vf_id;
92 fwd_cmd = (struct input *)((uint8_t *)bp->pf.vf_req_buf +
93 (logical_vf_id * 128));
95 /* Provision the request */
96 switch (fwd_cmd->req_type) {
97 case HWRM_CFA_L2_FILTER_ALLOC:
98 case HWRM_CFA_L2_FILTER_FREE:
99 case HWRM_CFA_L2_FILTER_CFG:
100 case HWRM_CFA_L2_SET_RX_MASK:
103 error_code = HWRM_ERR_CODE_INVALID_PARAMS;
108 fwd_cmd->target_id = fwd_cmpl->source_id;
109 bnxt_hwrm_exec_fwd_resp(bp, fwd_cmd);
113 /* TODO: Encap the reject error resp into the hwrm_err_iput? */
114 /* Use the error_code for the reject cmd */
116 "Error 0x%x found in the forward request\n", error_code);
119 /* For the default completion ring only */
120 void bnxt_free_def_cp_ring(struct bnxt *bp)
122 struct bnxt_cp_ring_info *cpr = bp->def_cp_ring;
123 struct bnxt_ring *ring = cpr->cp_ring_struct;
125 bnxt_free_ring(ring);
128 /* For the default completion ring only */
129 void bnxt_init_def_ring_struct(struct bnxt *bp)
131 struct bnxt_cp_ring_info *cpr = bp->def_cp_ring;
132 struct bnxt_ring *ring = cpr->cp_ring_struct;
134 ring->bd = (void *)cpr->cp_desc_ring;
135 ring->bd_dma = cpr->cp_desc_mapping;
136 ring->ring_size = rte_align32pow2(DEFAULT_CP_RING_SIZE);
137 ring->ring_mask = ring->ring_size - 1;