.. | .. |
---|
55 | 55 | do { \ |
---|
56 | 56 | memset(&(req), 0, sizeof((req))); \ |
---|
57 | 57 | (req).opcode = CMDQ_BASE_OPCODE_##CMD; \ |
---|
58 | | - (req).cmd_size = (sizeof((req)) + \ |
---|
59 | | - BNXT_QPLIB_CMDQE_UNITS - 1) / \ |
---|
60 | | - BNXT_QPLIB_CMDQE_UNITS; \ |
---|
| 58 | + (req).cmd_size = sizeof((req)); \ |
---|
61 | 59 | (req).flags = cpu_to_le16(cmd_flags); \ |
---|
62 | 60 | } while (0) |
---|
63 | 61 | |
---|
64 | 62 | #define RCFW_CMD_WAIT_TIME_MS 20000 /* 20 Seconds timeout */ |
---|
65 | | - |
---|
66 | | -/* CMDQ elements */ |
---|
67 | | -#define BNXT_QPLIB_CMDQE_MAX_CNT 256 |
---|
68 | | -#define BNXT_QPLIB_CMDQE_UNITS sizeof(struct bnxt_qplib_cmdqe) |
---|
69 | | -#define BNXT_QPLIB_CMDQE_CNT_PER_PG (PAGE_SIZE / BNXT_QPLIB_CMDQE_UNITS) |
---|
70 | | - |
---|
71 | | -#define MAX_CMDQ_IDX (BNXT_QPLIB_CMDQE_MAX_CNT - 1) |
---|
72 | | -#define MAX_CMDQ_IDX_PER_PG (BNXT_QPLIB_CMDQE_CNT_PER_PG - 1) |
---|
73 | | - |
---|
74 | | -#define RCFW_MAX_OUTSTANDING_CMD BNXT_QPLIB_CMDQE_MAX_CNT |
---|
75 | | -#define RCFW_MAX_COOKIE_VALUE 0x7FFF |
---|
76 | | -#define RCFW_CMD_IS_BLOCKING 0x8000 |
---|
77 | | -#define RCFW_BLOCKED_CMD_WAIT_COUNT 0x4E20 |
---|
78 | 63 | |
---|
79 | 64 | /* Cmdq contains a fix number of a 16-Byte slots */ |
---|
80 | 65 | struct bnxt_qplib_cmdqe { |
---|
81 | 66 | u8 data[16]; |
---|
82 | 67 | }; |
---|
83 | 68 | |
---|
84 | | -static inline u32 get_cmdq_pg(u32 val) |
---|
| 69 | +/* CMDQ elements */ |
---|
| 70 | +#define BNXT_QPLIB_CMDQE_MAX_CNT_256 256 |
---|
| 71 | +#define BNXT_QPLIB_CMDQE_MAX_CNT_8192 8192 |
---|
| 72 | +#define BNXT_QPLIB_CMDQE_UNITS sizeof(struct bnxt_qplib_cmdqe) |
---|
| 73 | +#define BNXT_QPLIB_CMDQE_BYTES(depth) ((depth) * BNXT_QPLIB_CMDQE_UNITS) |
---|
| 74 | + |
---|
| 75 | +static inline u32 bnxt_qplib_cmdqe_npages(u32 depth) |
---|
85 | 76 | { |
---|
86 | | - return (val & ~MAX_CMDQ_IDX_PER_PG) / BNXT_QPLIB_CMDQE_CNT_PER_PG; |
---|
| 77 | + u32 npages; |
---|
| 78 | + |
---|
| 79 | + npages = BNXT_QPLIB_CMDQE_BYTES(depth) / PAGE_SIZE; |
---|
| 80 | + if (BNXT_QPLIB_CMDQE_BYTES(depth) % PAGE_SIZE) |
---|
| 81 | + npages++; |
---|
| 82 | + return npages; |
---|
87 | 83 | } |
---|
88 | 84 | |
---|
89 | | -static inline u32 get_cmdq_idx(u32 val) |
---|
| 85 | +static inline u32 bnxt_qplib_cmdqe_page_size(u32 depth) |
---|
90 | 86 | { |
---|
91 | | - return val & MAX_CMDQ_IDX_PER_PG; |
---|
| 87 | + return (bnxt_qplib_cmdqe_npages(depth) * PAGE_SIZE); |
---|
92 | 88 | } |
---|
| 89 | + |
---|
| 90 | +/* Set the cmd_size to a factor of CMDQE unit */ |
---|
| 91 | +static inline void bnxt_qplib_set_cmd_slots(struct cmdq_base *req) |
---|
| 92 | +{ |
---|
| 93 | + req->cmd_size = (req->cmd_size + BNXT_QPLIB_CMDQE_UNITS - 1) / |
---|
| 94 | + BNXT_QPLIB_CMDQE_UNITS; |
---|
| 95 | +} |
---|
| 96 | + |
---|
| 97 | +#define RCFW_MAX_COOKIE_VALUE 0x7FFF |
---|
| 98 | +#define RCFW_CMD_IS_BLOCKING 0x8000 |
---|
| 99 | +#define RCFW_BLOCKED_CMD_WAIT_COUNT 0x4E20 |
---|
| 100 | + |
---|
| 101 | +#define HWRM_VERSION_RCFW_CMDQ_DEPTH_CHECK 0x1000900020011ULL |
---|
93 | 102 | |
---|
94 | 103 | /* Crsq buf is 1024-Byte */ |
---|
95 | 104 | struct bnxt_qplib_crsbe { |
---|
.. | .. |
---|
100 | 109 | /* Allocate 1 per QP for async error notification for now */ |
---|
101 | 110 | #define BNXT_QPLIB_CREQE_MAX_CNT (64 * 1024) |
---|
102 | 111 | #define BNXT_QPLIB_CREQE_UNITS 16 /* 16-Bytes per prod unit */ |
---|
103 | | -#define BNXT_QPLIB_CREQE_CNT_PER_PG (PAGE_SIZE / BNXT_QPLIB_CREQE_UNITS) |
---|
104 | | - |
---|
105 | | -#define MAX_CREQ_IDX (BNXT_QPLIB_CREQE_MAX_CNT - 1) |
---|
106 | | -#define MAX_CREQ_IDX_PER_PG (BNXT_QPLIB_CREQE_CNT_PER_PG - 1) |
---|
107 | | - |
---|
108 | | -static inline u32 get_creq_pg(u32 val) |
---|
109 | | -{ |
---|
110 | | - return (val & ~MAX_CREQ_IDX_PER_PG) / BNXT_QPLIB_CREQE_CNT_PER_PG; |
---|
111 | | -} |
---|
112 | | - |
---|
113 | | -static inline u32 get_creq_idx(u32 val) |
---|
114 | | -{ |
---|
115 | | - return val & MAX_CREQ_IDX_PER_PG; |
---|
116 | | -} |
---|
117 | | - |
---|
118 | | -#define BNXT_QPLIB_CREQE_PER_PG (PAGE_SIZE / sizeof(struct creq_base)) |
---|
119 | | - |
---|
120 | 112 | #define CREQ_CMP_VALID(hdr, raw_cons, cp_bit) \ |
---|
121 | 113 | (!!((hdr)->v & CREQ_BASE_V) == \ |
---|
122 | 114 | !((raw_cons) & (cp_bit))) |
---|
123 | | - |
---|
124 | | -#define CREQ_DB_KEY_CP (0x2 << CMPL_DOORBELL_KEY_SFT) |
---|
125 | | -#define CREQ_DB_IDX_VALID CMPL_DOORBELL_IDX_VALID |
---|
126 | | -#define CREQ_DB_IRQ_DIS CMPL_DOORBELL_MASK |
---|
127 | | -#define CREQ_DB_CP_FLAGS_REARM (CREQ_DB_KEY_CP | \ |
---|
128 | | - CREQ_DB_IDX_VALID) |
---|
129 | | -#define CREQ_DB_CP_FLAGS (CREQ_DB_KEY_CP | \ |
---|
130 | | - CREQ_DB_IDX_VALID | \ |
---|
131 | | - CREQ_DB_IRQ_DIS) |
---|
132 | | -#define CREQ_DB_REARM(db, raw_cons, cp_bit) \ |
---|
133 | | - writel(CREQ_DB_CP_FLAGS_REARM | ((raw_cons) & ((cp_bit) - 1)), db) |
---|
134 | | -#define CREQ_DB(db, raw_cons, cp_bit) \ |
---|
135 | | - writel(CREQ_DB_CP_FLAGS | ((raw_cons) & ((cp_bit) - 1)), db) |
---|
136 | | - |
---|
137 | 115 | #define CREQ_ENTRY_POLL_BUDGET 0x100 |
---|
138 | 116 | |
---|
139 | 117 | /* HWQ */ |
---|
| 118 | +typedef int (*aeq_handler_t)(struct bnxt_qplib_rcfw *, void *, void *); |
---|
140 | 119 | |
---|
141 | | -struct bnxt_qplib_crsq { |
---|
| 120 | +struct bnxt_qplib_crsqe { |
---|
142 | 121 | struct creq_qp_event *resp; |
---|
143 | 122 | u32 req_size; |
---|
144 | 123 | }; |
---|
.. | .. |
---|
154 | 133 | void *qp_handle; /* ptr to qplib_qp */ |
---|
155 | 134 | }; |
---|
156 | 135 | |
---|
| 136 | +#define BNXT_QPLIB_OOS_COUNT_MASK 0xFFFFFFFF |
---|
| 137 | + |
---|
| 138 | +#define FIRMWARE_INITIALIZED_FLAG (0) |
---|
| 139 | +#define FIRMWARE_FIRST_FLAG (31) |
---|
| 140 | +#define FIRMWARE_TIMED_OUT (3) |
---|
| 141 | +struct bnxt_qplib_cmdq_mbox { |
---|
| 142 | + struct bnxt_qplib_reg_desc reg; |
---|
| 143 | + void __iomem *prod; |
---|
| 144 | + void __iomem *db; |
---|
| 145 | +}; |
---|
| 146 | + |
---|
| 147 | +struct bnxt_qplib_cmdq_ctx { |
---|
| 148 | + struct bnxt_qplib_hwq hwq; |
---|
| 149 | + struct bnxt_qplib_cmdq_mbox cmdq_mbox; |
---|
| 150 | + wait_queue_head_t waitq; |
---|
| 151 | + unsigned long flags; |
---|
| 152 | + unsigned long *cmdq_bitmap; |
---|
| 153 | + u32 seq_num; |
---|
| 154 | +}; |
---|
| 155 | + |
---|
| 156 | +struct bnxt_qplib_creq_db { |
---|
| 157 | + struct bnxt_qplib_reg_desc reg; |
---|
| 158 | + struct bnxt_qplib_db_info dbinfo; |
---|
| 159 | +}; |
---|
| 160 | + |
---|
| 161 | +struct bnxt_qplib_creq_stat { |
---|
| 162 | + u64 creq_qp_event_processed; |
---|
| 163 | + u64 creq_func_event_processed; |
---|
| 164 | +}; |
---|
| 165 | + |
---|
| 166 | +struct bnxt_qplib_creq_ctx { |
---|
| 167 | + struct bnxt_qplib_hwq hwq; |
---|
| 168 | + struct bnxt_qplib_creq_db creq_db; |
---|
| 169 | + struct bnxt_qplib_creq_stat stats; |
---|
| 170 | + struct tasklet_struct creq_tasklet; |
---|
| 171 | + aeq_handler_t aeq_handler; |
---|
| 172 | + u16 ring_id; |
---|
| 173 | + int msix_vec; |
---|
| 174 | + bool requested; /*irq handler installed */ |
---|
| 175 | + char *irq_name; |
---|
| 176 | +}; |
---|
| 177 | + |
---|
157 | 178 | /* RCFW Communication Channels */ |
---|
158 | 179 | struct bnxt_qplib_rcfw { |
---|
159 | 180 | struct pci_dev *pdev; |
---|
160 | | - int vector; |
---|
161 | | - struct tasklet_struct worker; |
---|
162 | | - bool requested; |
---|
163 | | - unsigned long *cmdq_bitmap; |
---|
164 | | - u32 bmap_size; |
---|
165 | | - unsigned long flags; |
---|
166 | | -#define FIRMWARE_INITIALIZED_FLAG 0 |
---|
167 | | -#define FIRMWARE_FIRST_FLAG 31 |
---|
168 | | -#define FIRMWARE_TIMED_OUT 3 |
---|
169 | | - wait_queue_head_t waitq; |
---|
170 | | - int (*aeq_handler)(struct bnxt_qplib_rcfw *, |
---|
171 | | - void *, void *); |
---|
172 | | - u32 seq_num; |
---|
173 | | - |
---|
174 | | - /* Bar region info */ |
---|
175 | | - void __iomem *cmdq_bar_reg_iomem; |
---|
176 | | - u16 cmdq_bar_reg; |
---|
177 | | - u16 cmdq_bar_reg_prod_off; |
---|
178 | | - u16 cmdq_bar_reg_trig_off; |
---|
179 | | - u16 creq_ring_id; |
---|
180 | | - u16 creq_bar_reg; |
---|
181 | | - void __iomem *creq_bar_reg_iomem; |
---|
182 | | - |
---|
183 | | - /* Cmd-Resp and Async Event notification queue */ |
---|
184 | | - struct bnxt_qplib_hwq creq; |
---|
185 | | - u64 creq_qp_event_processed; |
---|
186 | | - u64 creq_func_event_processed; |
---|
187 | | - |
---|
188 | | - /* Actual Cmd and Resp Queues */ |
---|
189 | | - struct bnxt_qplib_hwq cmdq; |
---|
190 | | - struct bnxt_qplib_crsq *crsqe_tbl; |
---|
| 181 | + struct bnxt_qplib_res *res; |
---|
| 182 | + struct bnxt_qplib_cmdq_ctx cmdq; |
---|
| 183 | + struct bnxt_qplib_creq_ctx creq; |
---|
| 184 | + struct bnxt_qplib_crsqe *crsqe_tbl; |
---|
191 | 185 | int qp_tbl_size; |
---|
192 | 186 | struct bnxt_qplib_qp_node *qp_tbl; |
---|
| 187 | + u64 oos_prev; |
---|
| 188 | + u32 init_oos_stats; |
---|
| 189 | + u32 cmdq_depth; |
---|
193 | 190 | }; |
---|
194 | 191 | |
---|
195 | 192 | void bnxt_qplib_free_rcfw_channel(struct bnxt_qplib_rcfw *rcfw); |
---|
196 | | -int bnxt_qplib_alloc_rcfw_channel(struct pci_dev *pdev, |
---|
197 | | - struct bnxt_qplib_rcfw *rcfw, int qp_tbl_sz); |
---|
| 193 | +int bnxt_qplib_alloc_rcfw_channel(struct bnxt_qplib_res *res, |
---|
| 194 | + struct bnxt_qplib_rcfw *rcfw, |
---|
| 195 | + struct bnxt_qplib_ctx *ctx, |
---|
| 196 | + int qp_tbl_sz); |
---|
198 | 197 | void bnxt_qplib_rcfw_stop_irq(struct bnxt_qplib_rcfw *rcfw, bool kill); |
---|
199 | 198 | void bnxt_qplib_disable_rcfw_channel(struct bnxt_qplib_rcfw *rcfw); |
---|
200 | 199 | int bnxt_qplib_rcfw_start_irq(struct bnxt_qplib_rcfw *rcfw, int msix_vector, |
---|
201 | 200 | bool need_init); |
---|
202 | | -int bnxt_qplib_enable_rcfw_channel(struct pci_dev *pdev, |
---|
203 | | - struct bnxt_qplib_rcfw *rcfw, |
---|
| 201 | +int bnxt_qplib_enable_rcfw_channel(struct bnxt_qplib_rcfw *rcfw, |
---|
204 | 202 | int msix_vector, |
---|
205 | 203 | int cp_bar_reg_off, int virt_fn, |
---|
206 | | - int (*aeq_handler)(struct bnxt_qplib_rcfw *, |
---|
207 | | - void *aeqe, void *obj)); |
---|
| 204 | + aeq_handler_t aeq_handler); |
---|
208 | 205 | |
---|
209 | 206 | struct bnxt_qplib_rcfw_sbuf *bnxt_qplib_rcfw_alloc_sbuf( |
---|
210 | 207 | struct bnxt_qplib_rcfw *rcfw, |
---|
.. | .. |
---|
219 | 216 | int bnxt_qplib_init_rcfw(struct bnxt_qplib_rcfw *rcfw, |
---|
220 | 217 | struct bnxt_qplib_ctx *ctx, int is_virtfn); |
---|
221 | 218 | void bnxt_qplib_mark_qp_error(void *qp_handle); |
---|
| 219 | +static inline u32 map_qp_id_to_tbl_indx(u32 qid, struct bnxt_qplib_rcfw *rcfw) |
---|
| 220 | +{ |
---|
| 221 | + /* Last index of the qp_tbl is for QP1 ie. qp_tbl_size - 1*/ |
---|
| 222 | + return (qid == 1) ? rcfw->qp_tbl_size - 1 : qid % rcfw->qp_tbl_size - 2; |
---|
| 223 | +} |
---|
222 | 224 | #endif /* __BNXT_QPLIB_RCFW_H__ */ |
---|