net/bnxt: remove dead code
[dpdk.git] / drivers / net / bnxt / bnxt_cpr.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2014-2021 Broadcom
3  * All rights reserved.
4  */
5
6 #ifndef _BNXT_CPR_H_
7 #define _BNXT_CPR_H_
8 #include <stdbool.h>
9
10 #include <rte_io.h>
11
12 struct bnxt_db_info;
13
14 #define CMP_VALID(cmp, raw_cons, ring)                                  \
15         (!!(rte_le_to_cpu_32(((struct cmpl_base *)(cmp))->info3_v) &    \
16             CMPL_BASE_V) == !((raw_cons) & ((ring)->ring_size)))
17
18 #define CMP_TYPE(cmp)                                           \
19         (((struct cmpl_base *)cmp)->type & CMPL_BASE_TYPE_MASK)
20
21 /* Get completion length from completion type, in 16-byte units. */
22 #define CMP_LEN(cmp_type) (((cmp_type) & 1) + 1)
23
24
25 #define ADV_RAW_CMP(idx, n)     ((idx) + (n))
26 #define NEXT_RAW_CMP(idx)       ADV_RAW_CMP(idx, 1)
27 #define RING_CMP(ring, idx)     ((idx) & (ring)->ring_mask)
28 #define RING_CMPL(ring_mask, idx)       ((idx) & (ring_mask))
29 #define NEXT_CMP(idx)           RING_CMP(ADV_RAW_CMP(idx, 1))
30
31 #define DB_CP_REARM_FLAGS       (DB_KEY_CP | DB_IDX_VALID)
32 #define DB_CP_FLAGS             (DB_KEY_CP | DB_IDX_VALID | DB_IRQ_DIS)
33
34 #define B_CP_DB_REARM(cpr, raw_cons)                                    \
35         rte_write32((DB_CP_REARM_FLAGS |                                \
36                     DB_RING_IDX(&((cpr)->cp_db), raw_cons)),            \
37                     ((cpr)->cp_db.doorbell))
38
39 #define B_CP_DB_ARM(cpr)        rte_write32((DB_KEY_CP),                \
40                                             ((cpr)->cp_db.doorbell))
41
42 #define B_CP_DB_DISARM(cpr)     (*(uint32_t *)((cpr)->cp_db.doorbell) = \
43                                  DB_KEY_CP | DB_IRQ_DIS)
44
45 #define B_CP_DB_IDX_ARM(cpr, cons)                                      \
46                 (*(uint32_t *)((cpr)->cp_db.doorbell) = (DB_CP_REARM_FLAGS | \
47                                 (cons)))
48
49 #define B_CP_DB_IDX_DISARM(cpr, cons)   do {                            \
50                 rte_smp_wmb();                                          \
51                 (*(uint32_t *)((cpr)->cp_db.doorbell) = (DB_CP_FLAGS |  \
52                                 (cons));                                \
53 } while (0)
54 #define B_CP_DIS_DB(cpr, raw_cons)                                      \
55         rte_write32_relaxed((DB_CP_FLAGS |                              \
56                     DB_RING_IDX(&((cpr)->cp_db), raw_cons)),            \
57                     ((cpr)->cp_db.doorbell))
58
59 #define B_CP_DB(cpr, raw_cons, ring_mask)                               \
60         rte_write32((DB_CP_FLAGS |                                      \
61                     RING_CMPL((ring_mask), raw_cons)),  \
62                     ((cpr)->cp_db.doorbell))
63
64 struct bnxt_db_info {
65         void                    *doorbell;
66         union {
67                 uint64_t        db_key64;
68                 uint32_t        db_key32;
69         };
70         bool                    db_64;
71         uint32_t                db_ring_mask;
72         uint32_t                db_epoch_mask;
73         uint32_t                db_epoch_shift;
74 };
75
76 #define DB_EPOCH(db, idx)       (((idx) & (db)->db_epoch_mask) <<       \
77                                  ((db)->db_epoch_shift))
78 #define DB_RING_IDX(db, idx)    (((idx) & (db)->db_ring_mask) |         \
79                                  DB_EPOCH(db, idx))
80
81 struct bnxt_ring;
82 struct bnxt_cp_ring_info {
83         uint32_t                cp_raw_cons;
84
85         struct cmpl_base        *cp_desc_ring;
86         struct bnxt_db_info     cp_db;
87         rte_iova_t              cp_desc_mapping;
88
89         struct ctx_hw_stats     *hw_stats;
90         rte_iova_t              hw_stats_map;
91         uint32_t                hw_stats_ctx_id;
92
93         struct bnxt_ring        *cp_ring_struct;
94 };
95
96 #define RX_CMP_L2_ERRORS                                                \
97         (RX_PKT_CMPL_ERRORS_BUFFER_ERROR_MASK | RX_PKT_CMPL_ERRORS_CRC_ERROR)
98
99 struct bnxt;
100 void bnxt_handle_async_event(struct bnxt *bp, struct cmpl_base *cmp);
101 void bnxt_handle_fwd_req(struct bnxt *bp, struct cmpl_base *cmp);
102 int bnxt_event_hwrm_resp_handler(struct bnxt *bp, struct cmpl_base *cmp);
103 void bnxt_dev_reset_and_resume(void *arg);
104 void bnxt_wait_for_device_shutdown(struct bnxt *bp);
105
106 #define EVENT_DATA1_REASON_CODE_FW_EXCEPTION_FATAL     \
107         HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_FW_EXCEPTION_FATAL
108 #define EVENT_DATA1_REASON_CODE_MASK                   \
109         HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_MASK
110
111 #define EVENT_DATA1_FLAGS_MASK                         \
112         HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_DATA1_FLAGS_MASK
113
114 #define EVENT_DATA1_FLAGS_MASTER_FUNC                  \
115         HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_DATA1_FLAGS_MASTER_FUNC
116
117 #define EVENT_DATA1_FLAGS_RECOVERY_ENABLED             \
118         HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_DATA1_FLAGS_RECOVERY_ENABLED
119
120 bool bnxt_is_recovery_enabled(struct bnxt *bp);
121 bool bnxt_is_master_func(struct bnxt *bp);
122
123 void bnxt_stop_rxtx(struct bnxt *bp);
124 #endif