.. | .. |
---|
41 | 41 | |
---|
42 | 42 | extern const struct bnxt_qplib_gid bnxt_qplib_gid_zero; |
---|
43 | 43 | |
---|
| 44 | +#define CHIP_NUM_57508 0x1750 |
---|
| 45 | +#define CHIP_NUM_57504 0x1751 |
---|
| 46 | +#define CHIP_NUM_57502 0x1752 |
---|
| 47 | + |
---|
| 48 | +enum bnxt_qplib_wqe_mode { |
---|
| 49 | + BNXT_QPLIB_WQE_MODE_STATIC = 0x00, |
---|
| 50 | + BNXT_QPLIB_WQE_MODE_VARIABLE = 0x01, |
---|
| 51 | + BNXT_QPLIB_WQE_MODE_INVALID = 0x02 |
---|
| 52 | +}; |
---|
| 53 | + |
---|
| 54 | +struct bnxt_qplib_drv_modes { |
---|
| 55 | + u8 wqe_mode; |
---|
| 56 | + /* Other modes to follow here */ |
---|
| 57 | +}; |
---|
| 58 | + |
---|
| 59 | +struct bnxt_qplib_chip_ctx { |
---|
| 60 | + u16 chip_num; |
---|
| 61 | + u8 chip_rev; |
---|
| 62 | + u8 chip_metal; |
---|
| 63 | + u16 hw_stats_size; |
---|
| 64 | + struct bnxt_qplib_drv_modes modes; |
---|
| 65 | +}; |
---|
| 66 | + |
---|
44 | 67 | #define PTR_CNT_PER_PG (PAGE_SIZE / sizeof(void *)) |
---|
45 | 68 | #define PTR_MAX_IDX_PER_PG (PTR_CNT_PER_PG - 1) |
---|
46 | 69 | #define PTR_PG(x) (((x) & ~PTR_MAX_IDX_PER_PG) / PTR_CNT_PER_PG) |
---|
.. | .. |
---|
55 | 78 | enum bnxt_qplib_hwq_type { |
---|
56 | 79 | HWQ_TYPE_CTX, |
---|
57 | 80 | HWQ_TYPE_QUEUE, |
---|
58 | | - HWQ_TYPE_L2_CMPL |
---|
| 81 | + HWQ_TYPE_L2_CMPL, |
---|
| 82 | + HWQ_TYPE_MR |
---|
59 | 83 | }; |
---|
60 | 84 | |
---|
61 | 85 | #define MAX_PBL_LVL_0_PGS 1 |
---|
.. | .. |
---|
63 | 87 | #define MAX_PBL_LVL_1_PGS_SHIFT 9 |
---|
64 | 88 | #define MAX_PBL_LVL_1_PGS_FOR_LVL_2 256 |
---|
65 | 89 | #define MAX_PBL_LVL_2_PGS (256 * 512) |
---|
| 90 | +#define MAX_PDL_LVL_SHIFT 9 |
---|
66 | 91 | |
---|
67 | 92 | enum bnxt_qplib_pbl_lvl { |
---|
68 | 93 | PBL_LVL_0, |
---|
.. | .. |
---|
78 | 103 | #define ROCE_PG_SIZE_8M (8 * 1024 * 1024) |
---|
79 | 104 | #define ROCE_PG_SIZE_1G (1024 * 1024 * 1024) |
---|
80 | 105 | |
---|
| 106 | +enum bnxt_qplib_hwrm_pg_size { |
---|
| 107 | + BNXT_QPLIB_HWRM_PG_SIZE_4K = 0, |
---|
| 108 | + BNXT_QPLIB_HWRM_PG_SIZE_8K = 1, |
---|
| 109 | + BNXT_QPLIB_HWRM_PG_SIZE_64K = 2, |
---|
| 110 | + BNXT_QPLIB_HWRM_PG_SIZE_2M = 3, |
---|
| 111 | + BNXT_QPLIB_HWRM_PG_SIZE_8M = 4, |
---|
| 112 | + BNXT_QPLIB_HWRM_PG_SIZE_1G = 5, |
---|
| 113 | +}; |
---|
| 114 | + |
---|
| 115 | +struct bnxt_qplib_reg_desc { |
---|
| 116 | + u8 bar_id; |
---|
| 117 | + resource_size_t bar_base; |
---|
| 118 | + void __iomem *bar_reg; |
---|
| 119 | + size_t len; |
---|
| 120 | +}; |
---|
| 121 | + |
---|
81 | 122 | struct bnxt_qplib_pbl { |
---|
82 | 123 | u32 pg_count; |
---|
83 | 124 | u32 pg_size; |
---|
.. | .. |
---|
85 | 126 | dma_addr_t *pg_map_arr; |
---|
86 | 127 | }; |
---|
87 | 128 | |
---|
| 129 | +struct bnxt_qplib_sg_info { |
---|
| 130 | + struct ib_umem *umem; |
---|
| 131 | + u32 npages; |
---|
| 132 | + u32 pgshft; |
---|
| 133 | + u32 pgsize; |
---|
| 134 | + bool nopte; |
---|
| 135 | +}; |
---|
| 136 | + |
---|
| 137 | +struct bnxt_qplib_hwq_attr { |
---|
| 138 | + struct bnxt_qplib_res *res; |
---|
| 139 | + struct bnxt_qplib_sg_info *sginfo; |
---|
| 140 | + enum bnxt_qplib_hwq_type type; |
---|
| 141 | + u32 depth; |
---|
| 142 | + u32 stride; |
---|
| 143 | + u32 aux_stride; |
---|
| 144 | + u32 aux_depth; |
---|
| 145 | +}; |
---|
| 146 | + |
---|
88 | 147 | struct bnxt_qplib_hwq { |
---|
89 | 148 | struct pci_dev *pdev; |
---|
90 | 149 | /* lock to protect qplib_hwq */ |
---|
91 | 150 | spinlock_t lock; |
---|
92 | | - struct bnxt_qplib_pbl pbl[PBL_LVL_MAX]; |
---|
| 151 | + struct bnxt_qplib_pbl pbl[PBL_LVL_MAX + 1]; |
---|
93 | 152 | enum bnxt_qplib_pbl_lvl level; /* 0, 1, or 2 */ |
---|
94 | 153 | /* ptr for easy access to the PBL entries */ |
---|
95 | 154 | void **pbl_ptr; |
---|
96 | 155 | /* ptr for easy access to the dma_addr */ |
---|
97 | 156 | dma_addr_t *pbl_dma_ptr; |
---|
98 | 157 | u32 max_elements; |
---|
| 158 | + u32 depth; |
---|
99 | 159 | u16 element_size; /* Size of each entry */ |
---|
| 160 | + u16 qe_ppg; /* queue entry per page */ |
---|
100 | 161 | |
---|
101 | 162 | u32 prod; /* raw */ |
---|
102 | 163 | u32 cons; /* raw */ |
---|
103 | 164 | u8 cp_bit; |
---|
104 | 165 | u8 is_user; |
---|
| 166 | + u64 *pad_pg; |
---|
| 167 | + u32 pad_stride; |
---|
| 168 | + u32 pad_pgofft; |
---|
| 169 | +}; |
---|
| 170 | + |
---|
| 171 | +struct bnxt_qplib_db_info { |
---|
| 172 | + void __iomem *db; |
---|
| 173 | + void __iomem *priv_db; |
---|
| 174 | + struct bnxt_qplib_hwq *hwq; |
---|
| 175 | + u32 xid; |
---|
| 176 | + u32 max_slot; |
---|
105 | 177 | }; |
---|
106 | 178 | |
---|
107 | 179 | /* Tables */ |
---|
.. | .. |
---|
111 | 183 | }; |
---|
112 | 184 | |
---|
113 | 185 | struct bnxt_qplib_sgid_tbl { |
---|
114 | | - struct bnxt_qplib_gid *tbl; |
---|
| 186 | + struct bnxt_qplib_gid_info *tbl; |
---|
115 | 187 | u16 *hw_id; |
---|
116 | 188 | u16 max; |
---|
117 | 189 | u16 active; |
---|
.. | .. |
---|
159 | 231 | #define BNXT_QPLIB_MAX_CQ_CTX_ENTRY_SIZE 64 |
---|
160 | 232 | #define BNXT_QPLIB_MAX_MRW_CTX_ENTRY_SIZE 128 |
---|
161 | 233 | |
---|
| 234 | +#define MAX_TQM_ALLOC_REQ 48 |
---|
| 235 | +#define MAX_TQM_ALLOC_BLK_SIZE 8 |
---|
| 236 | +struct bnxt_qplib_tqm_ctx { |
---|
| 237 | + struct bnxt_qplib_hwq pde; |
---|
| 238 | + u8 pde_level; /* Original level */ |
---|
| 239 | + struct bnxt_qplib_hwq qtbl[MAX_TQM_ALLOC_REQ]; |
---|
| 240 | + u8 qcount[MAX_TQM_ALLOC_REQ]; |
---|
| 241 | +}; |
---|
| 242 | + |
---|
162 | 243 | struct bnxt_qplib_ctx { |
---|
163 | 244 | u32 qpc_count; |
---|
164 | 245 | struct bnxt_qplib_hwq qpc_tbl; |
---|
.. | .. |
---|
169 | 250 | u32 cq_count; |
---|
170 | 251 | struct bnxt_qplib_hwq cq_tbl; |
---|
171 | 252 | struct bnxt_qplib_hwq tim_tbl; |
---|
172 | | -#define MAX_TQM_ALLOC_REQ 48 |
---|
173 | | -#define MAX_TQM_ALLOC_BLK_SIZE 8 |
---|
174 | | - u8 tqm_count[MAX_TQM_ALLOC_REQ]; |
---|
175 | | - struct bnxt_qplib_hwq tqm_pde; |
---|
176 | | - u32 tqm_pde_level; |
---|
177 | | - struct bnxt_qplib_hwq tqm_tbl[MAX_TQM_ALLOC_REQ]; |
---|
| 253 | + struct bnxt_qplib_tqm_ctx tqm_ctx; |
---|
178 | 254 | struct bnxt_qplib_stats stats; |
---|
179 | 255 | struct bnxt_qplib_vf_res vf_res; |
---|
| 256 | + u64 hwrm_intf_ver; |
---|
180 | 257 | }; |
---|
181 | 258 | |
---|
182 | 259 | struct bnxt_qplib_res { |
---|
183 | 260 | struct pci_dev *pdev; |
---|
| 261 | + struct bnxt_qplib_chip_ctx *cctx; |
---|
184 | 262 | struct net_device *netdev; |
---|
185 | 263 | |
---|
186 | 264 | struct bnxt_qplib_rcfw *rcfw; |
---|
187 | | - |
---|
188 | 265 | struct bnxt_qplib_pd_tbl pd_tbl; |
---|
189 | 266 | struct bnxt_qplib_sgid_tbl sgid_tbl; |
---|
190 | 267 | struct bnxt_qplib_pkey_tbl pkey_tbl; |
---|
.. | .. |
---|
192 | 269 | bool prio; |
---|
193 | 270 | }; |
---|
194 | 271 | |
---|
| 272 | +static inline bool bnxt_qplib_is_chip_gen_p5(struct bnxt_qplib_chip_ctx *cctx) |
---|
| 273 | +{ |
---|
| 274 | + return (cctx->chip_num == CHIP_NUM_57508 || |
---|
| 275 | + cctx->chip_num == CHIP_NUM_57504 || |
---|
| 276 | + cctx->chip_num == CHIP_NUM_57502); |
---|
| 277 | +} |
---|
| 278 | + |
---|
| 279 | +static inline u8 bnxt_qplib_get_hwq_type(struct bnxt_qplib_res *res) |
---|
| 280 | +{ |
---|
| 281 | + return bnxt_qplib_is_chip_gen_p5(res->cctx) ? |
---|
| 282 | + HWQ_TYPE_QUEUE : HWQ_TYPE_L2_CMPL; |
---|
| 283 | +} |
---|
| 284 | + |
---|
| 285 | +static inline u8 bnxt_qplib_get_ring_type(struct bnxt_qplib_chip_ctx *cctx) |
---|
| 286 | +{ |
---|
| 287 | + return bnxt_qplib_is_chip_gen_p5(cctx) ? |
---|
| 288 | + RING_ALLOC_REQ_RING_TYPE_NQ : |
---|
| 289 | + RING_ALLOC_REQ_RING_TYPE_ROCE_CMPL; |
---|
| 290 | +} |
---|
| 291 | + |
---|
| 292 | +static inline u8 bnxt_qplib_base_pg_size(struct bnxt_qplib_hwq *hwq) |
---|
| 293 | +{ |
---|
| 294 | + u8 pg_size = BNXT_QPLIB_HWRM_PG_SIZE_4K; |
---|
| 295 | + struct bnxt_qplib_pbl *pbl; |
---|
| 296 | + |
---|
| 297 | + pbl = &hwq->pbl[PBL_LVL_0]; |
---|
| 298 | + switch (pbl->pg_size) { |
---|
| 299 | + case ROCE_PG_SIZE_4K: |
---|
| 300 | + pg_size = BNXT_QPLIB_HWRM_PG_SIZE_4K; |
---|
| 301 | + break; |
---|
| 302 | + case ROCE_PG_SIZE_8K: |
---|
| 303 | + pg_size = BNXT_QPLIB_HWRM_PG_SIZE_8K; |
---|
| 304 | + break; |
---|
| 305 | + case ROCE_PG_SIZE_64K: |
---|
| 306 | + pg_size = BNXT_QPLIB_HWRM_PG_SIZE_64K; |
---|
| 307 | + break; |
---|
| 308 | + case ROCE_PG_SIZE_2M: |
---|
| 309 | + pg_size = BNXT_QPLIB_HWRM_PG_SIZE_2M; |
---|
| 310 | + break; |
---|
| 311 | + case ROCE_PG_SIZE_8M: |
---|
| 312 | + pg_size = BNXT_QPLIB_HWRM_PG_SIZE_8M; |
---|
| 313 | + break; |
---|
| 314 | + case ROCE_PG_SIZE_1G: |
---|
| 315 | + pg_size = BNXT_QPLIB_HWRM_PG_SIZE_1G; |
---|
| 316 | + break; |
---|
| 317 | + default: |
---|
| 318 | + break; |
---|
| 319 | + } |
---|
| 320 | + |
---|
| 321 | + return pg_size; |
---|
| 322 | +} |
---|
| 323 | + |
---|
| 324 | +static inline void *bnxt_qplib_get_qe(struct bnxt_qplib_hwq *hwq, |
---|
| 325 | + u32 indx, u64 *pg) |
---|
| 326 | +{ |
---|
| 327 | + u32 pg_num, pg_idx; |
---|
| 328 | + |
---|
| 329 | + pg_num = (indx / hwq->qe_ppg); |
---|
| 330 | + pg_idx = (indx % hwq->qe_ppg); |
---|
| 331 | + if (pg) |
---|
| 332 | + *pg = (u64)&hwq->pbl_ptr[pg_num]; |
---|
| 333 | + return (void *)(hwq->pbl_ptr[pg_num] + hwq->element_size * pg_idx); |
---|
| 334 | +} |
---|
| 335 | + |
---|
| 336 | +static inline void *bnxt_qplib_get_prod_qe(struct bnxt_qplib_hwq *hwq, u32 idx) |
---|
| 337 | +{ |
---|
| 338 | + idx += hwq->prod; |
---|
| 339 | + if (idx >= hwq->depth) |
---|
| 340 | + idx -= hwq->depth; |
---|
| 341 | + return bnxt_qplib_get_qe(hwq, idx, NULL); |
---|
| 342 | +} |
---|
| 343 | + |
---|
195 | 344 | #define to_bnxt_qplib(ptr, type, member) \ |
---|
196 | 345 | container_of(ptr, type, member) |
---|
197 | 346 | |
---|
198 | 347 | struct bnxt_qplib_pd; |
---|
199 | 348 | struct bnxt_qplib_dev_attr; |
---|
200 | 349 | |
---|
201 | | -void bnxt_qplib_free_hwq(struct pci_dev *pdev, struct bnxt_qplib_hwq *hwq); |
---|
202 | | -int bnxt_qplib_alloc_init_hwq(struct pci_dev *pdev, struct bnxt_qplib_hwq *hwq, |
---|
203 | | - struct scatterlist *sl, int nmap, u32 *elements, |
---|
204 | | - u32 elements_per_page, u32 aux, u32 pg_size, |
---|
205 | | - enum bnxt_qplib_hwq_type hwq_type); |
---|
| 350 | +void bnxt_qplib_free_hwq(struct bnxt_qplib_res *res, |
---|
| 351 | + struct bnxt_qplib_hwq *hwq); |
---|
| 352 | +int bnxt_qplib_alloc_init_hwq(struct bnxt_qplib_hwq *hwq, |
---|
| 353 | + struct bnxt_qplib_hwq_attr *hwq_attr); |
---|
206 | 354 | void bnxt_qplib_get_guid(u8 *dev_addr, u8 *guid); |
---|
207 | 355 | int bnxt_qplib_alloc_pd(struct bnxt_qplib_pd_tbl *pd_tbl, |
---|
208 | 356 | struct bnxt_qplib_pd *pd); |
---|
.. | .. |
---|
221 | 369 | int bnxt_qplib_alloc_res(struct bnxt_qplib_res *res, struct pci_dev *pdev, |
---|
222 | 370 | struct net_device *netdev, |
---|
223 | 371 | struct bnxt_qplib_dev_attr *dev_attr); |
---|
224 | | -void bnxt_qplib_free_ctx(struct pci_dev *pdev, |
---|
| 372 | +void bnxt_qplib_free_ctx(struct bnxt_qplib_res *res, |
---|
225 | 373 | struct bnxt_qplib_ctx *ctx); |
---|
226 | | -int bnxt_qplib_alloc_ctx(struct pci_dev *pdev, |
---|
| 374 | +int bnxt_qplib_alloc_ctx(struct bnxt_qplib_res *res, |
---|
227 | 375 | struct bnxt_qplib_ctx *ctx, |
---|
228 | | - bool virt_fn); |
---|
| 376 | + bool virt_fn, bool is_p5); |
---|
| 377 | + |
---|
| 378 | +static inline void bnxt_qplib_hwq_incr_prod(struct bnxt_qplib_hwq *hwq, u32 cnt) |
---|
| 379 | +{ |
---|
| 380 | + hwq->prod = (hwq->prod + cnt) % hwq->depth; |
---|
| 381 | +} |
---|
| 382 | + |
---|
| 383 | +static inline void bnxt_qplib_hwq_incr_cons(struct bnxt_qplib_hwq *hwq, |
---|
| 384 | + u32 cnt) |
---|
| 385 | +{ |
---|
| 386 | + hwq->cons = (hwq->cons + cnt) % hwq->depth; |
---|
| 387 | +} |
---|
| 388 | + |
---|
| 389 | +static inline void bnxt_qplib_ring_db32(struct bnxt_qplib_db_info *info, |
---|
| 390 | + bool arm) |
---|
| 391 | +{ |
---|
| 392 | + u32 key; |
---|
| 393 | + |
---|
| 394 | + key = info->hwq->cons & (info->hwq->max_elements - 1); |
---|
| 395 | + key |= (CMPL_DOORBELL_IDX_VALID | |
---|
| 396 | + (CMPL_DOORBELL_KEY_CMPL & CMPL_DOORBELL_KEY_MASK)); |
---|
| 397 | + if (!arm) |
---|
| 398 | + key |= CMPL_DOORBELL_MASK; |
---|
| 399 | + writel(key, info->db); |
---|
| 400 | +} |
---|
| 401 | + |
---|
| 402 | +static inline void bnxt_qplib_ring_db(struct bnxt_qplib_db_info *info, |
---|
| 403 | + u32 type) |
---|
| 404 | +{ |
---|
| 405 | + u64 key = 0; |
---|
| 406 | + |
---|
| 407 | + key = (info->xid & DBC_DBC_XID_MASK) | DBC_DBC_PATH_ROCE | type; |
---|
| 408 | + key <<= 32; |
---|
| 409 | + key |= (info->hwq->cons & (info->hwq->max_elements - 1)) & |
---|
| 410 | + DBC_DBC_INDEX_MASK; |
---|
| 411 | + writeq(key, info->db); |
---|
| 412 | +} |
---|
| 413 | + |
---|
| 414 | +static inline void bnxt_qplib_ring_prod_db(struct bnxt_qplib_db_info *info, |
---|
| 415 | + u32 type) |
---|
| 416 | +{ |
---|
| 417 | + u64 key = 0; |
---|
| 418 | + |
---|
| 419 | + key = (info->xid & DBC_DBC_XID_MASK) | DBC_DBC_PATH_ROCE | type; |
---|
| 420 | + key <<= 32; |
---|
| 421 | + key |= ((info->hwq->prod / info->max_slot)) & DBC_DBC_INDEX_MASK; |
---|
| 422 | + writeq(key, info->db); |
---|
| 423 | +} |
---|
| 424 | + |
---|
| 425 | +static inline void bnxt_qplib_armen_db(struct bnxt_qplib_db_info *info, |
---|
| 426 | + u32 type) |
---|
| 427 | +{ |
---|
| 428 | + u64 key = 0; |
---|
| 429 | + |
---|
| 430 | + key = (info->xid & DBC_DBC_XID_MASK) | DBC_DBC_PATH_ROCE | type; |
---|
| 431 | + key <<= 32; |
---|
| 432 | + writeq(key, info->priv_db); |
---|
| 433 | +} |
---|
| 434 | + |
---|
| 435 | +static inline void bnxt_qplib_srq_arm_db(struct bnxt_qplib_db_info *info, |
---|
| 436 | + u32 th) |
---|
| 437 | +{ |
---|
| 438 | + u64 key = 0; |
---|
| 439 | + |
---|
| 440 | + key = (info->xid & DBC_DBC_XID_MASK) | DBC_DBC_PATH_ROCE | th; |
---|
| 441 | + key <<= 32; |
---|
| 442 | + key |= th & DBC_DBC_INDEX_MASK; |
---|
| 443 | + writeq(key, info->priv_db); |
---|
| 444 | +} |
---|
| 445 | + |
---|
| 446 | +static inline void bnxt_qplib_ring_nq_db(struct bnxt_qplib_db_info *info, |
---|
| 447 | + struct bnxt_qplib_chip_ctx *cctx, |
---|
| 448 | + bool arm) |
---|
| 449 | +{ |
---|
| 450 | + u32 type; |
---|
| 451 | + |
---|
| 452 | + type = arm ? DBC_DBC_TYPE_NQ_ARM : DBC_DBC_TYPE_NQ; |
---|
| 453 | + if (bnxt_qplib_is_chip_gen_p5(cctx)) |
---|
| 454 | + bnxt_qplib_ring_db(info, type); |
---|
| 455 | + else |
---|
| 456 | + bnxt_qplib_ring_db32(info, arm); |
---|
| 457 | +} |
---|
229 | 458 | #endif /* __BNXT_QPLIB_RES_H__ */ |
---|