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.
37 #define CMP_VALID(cmp, raw_cons, ring) \
38 (!!(((struct cmpl_base *)(cmp))->info3_v & CMPL_BASE_V) == \
39 !((raw_cons) & ((ring)->ring_size)))
41 #define CMP_TYPE(cmp) \
42 (((struct cmpl_base *)cmp)->type & CMPL_BASE_TYPE_MASK)
44 #define ADV_RAW_CMP(idx, n) ((idx) + (n))
45 #define NEXT_RAW_CMP(idx) ADV_RAW_CMP(idx, 1)
46 #define RING_CMP(ring, idx) ((idx) & (ring)->ring_mask)
47 #define NEXT_CMP(idx) RING_CMP(ADV_RAW_CMP(idx, 1))
49 #define DB_CP_REARM_FLAGS (DB_KEY_CP | DB_IDX_VALID)
50 #define DB_CP_FLAGS (DB_KEY_CP | DB_IDX_VALID | DB_IRQ_DIS)
52 #define B_CP_DB_REARM(cpr, raw_cons) \
53 (*(uint32_t *)((cpr)->cp_doorbell) = (DB_CP_REARM_FLAGS | \
54 RING_CMP(cpr->cp_ring_struct, raw_cons)))
56 #define B_CP_DIS_DB(cpr, raw_cons) \
58 (*(uint32_t *)((cpr)->cp_doorbell) = (DB_CP_FLAGS | \
59 RING_CMP(cpr->cp_ring_struct, raw_cons)))
62 struct bnxt_cp_ring_info {
66 struct cmpl_base *cp_desc_ring;
68 phys_addr_t cp_desc_mapping;
70 struct ctx_hw_stats *hw_stats;
71 phys_addr_t hw_stats_map;
72 uint32_t hw_stats_ctx_id;
74 struct bnxt_ring *cp_ring_struct;
77 #define RX_CMP_L2_ERRORS \
78 (RX_PKT_CMPL_ERRORS_BUFFER_ERROR_MASK | RX_PKT_CMPL_ERRORS_CRC_ERROR)
82 void bnxt_free_def_cp_ring(struct bnxt *bp);
83 int bnxt_init_def_ring_struct(struct bnxt *bp, unsigned int socket_id);
84 void bnxt_handle_async_event(struct bnxt *bp, struct cmpl_base *cmp);
85 void bnxt_handle_fwd_req(struct bnxt *bp, struct cmpl_base *cmp);