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.
40 #define CMP_VALID(cmp, raw_cons, ring) \
41 (!!(((struct cmpl_base *)(cmp))->info3_v & CMPL_BASE_V) == \
42 !((raw_cons) & ((ring)->ring_size)))
44 #define CMP_TYPE(cmp) \
45 (((struct cmpl_base *)cmp)->type & CMPL_BASE_TYPE_MASK)
47 #define ADV_RAW_CMP(idx, n) ((idx) + (n))
48 #define NEXT_RAW_CMP(idx) ADV_RAW_CMP(idx, 1)
49 #define RING_CMP(ring, idx) ((idx) & (ring)->ring_mask)
50 #define NEXT_CMP(idx) RING_CMP(ADV_RAW_CMP(idx, 1))
52 #define DB_CP_REARM_FLAGS (DB_KEY_CP | DB_IDX_VALID)
53 #define DB_CP_FLAGS (DB_KEY_CP | DB_IDX_VALID | DB_IRQ_DIS)
55 #define B_CP_DB_REARM(cpr, raw_cons) \
56 rte_write32((DB_CP_REARM_FLAGS | \
57 RING_CMP(((cpr)->cp_ring_struct), raw_cons)), \
60 #define B_CP_DB_ARM(cpr) rte_write32((DB_KEY_CP), ((cpr)->cp_doorbell))
61 #define B_CP_DB_DISARM(cpr) (*(uint32_t *)((cpr)->cp_doorbell) = \
62 DB_KEY_CP | DB_IRQ_DIS)
64 #define B_CP_DB_IDX_ARM(cpr, cons) \
65 (*(uint32_t *)((cpr)->cp_doorbell) = (DB_CP_REARM_FLAGS | \
68 #define B_CP_DB_IDX_DISARM(cpr, cons) do { \
70 (*(uint32_t *)((cpr)->cp_doorbell) = (DB_CP_FLAGS | \
73 #define B_CP_DIS_DB(cpr, raw_cons) \
74 rte_write32((DB_CP_FLAGS | \
75 RING_CMP(((cpr)->cp_ring_struct), raw_cons)), \
79 struct bnxt_cp_ring_info {
83 struct cmpl_base *cp_desc_ring;
85 phys_addr_t cp_desc_mapping;
87 struct ctx_hw_stats *hw_stats;
88 phys_addr_t hw_stats_map;
89 uint32_t hw_stats_ctx_id;
91 struct bnxt_ring *cp_ring_struct;
96 #define RX_CMP_L2_ERRORS \
97 (RX_PKT_CMPL_ERRORS_BUFFER_ERROR_MASK | RX_PKT_CMPL_ERRORS_CRC_ERROR)
101 int bnxt_alloc_def_cp_ring(struct bnxt *bp);
102 void bnxt_free_def_cp_ring(struct bnxt *bp);
103 int bnxt_init_def_ring_struct(struct bnxt *bp, unsigned int socket_id);
104 void bnxt_handle_async_event(struct bnxt *bp, struct cmpl_base *cmp);
105 void bnxt_handle_fwd_req(struct bnxt *bp, struct cmpl_base *cmp);