0001
0002
0003
0004
0005
0006
0007 #ifndef _QED_CXT_H
0008 #define _QED_CXT_H
0009
0010 #include <linux/types.h>
0011 #include <linux/slab.h>
0012 #include <linux/qed/qed_if.h>
0013 #include "qed_hsi.h"
0014 #include "qed.h"
0015
0016 struct qed_cxt_info {
0017 void *p_cxt;
0018 u32 iid;
0019 enum protocol_type type;
0020 };
0021
0022 #define MAX_TID_BLOCKS 512
0023 struct qed_tid_mem {
0024 u32 tid_size;
0025 u32 num_tids_per_block;
0026 u32 waste;
0027 u8 *blocks[MAX_TID_BLOCKS];
0028 };
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 int qed_cxt_get_cid_info(struct qed_hwfn *p_hwfn,
0039 struct qed_cxt_info *p_info);
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049 int qed_cxt_get_tid_mem_info(struct qed_hwfn *p_hwfn,
0050 struct qed_tid_mem *p_info);
0051
0052 #define QED_CXT_TCP_ULP_TID_SEG PROTOCOLID_TCP_ULP
0053 #define QED_CXT_ROCE_TID_SEG PROTOCOLID_ROCE
0054 #define QED_CXT_FCOE_TID_SEG PROTOCOLID_FCOE
0055 enum qed_cxt_elem_type {
0056 QED_ELEM_CXT,
0057 QED_ELEM_SRQ,
0058 QED_ELEM_TASK,
0059 QED_ELEM_XRC_SRQ,
0060 };
0061
0062 u32 qed_cxt_get_proto_cid_count(struct qed_hwfn *p_hwfn,
0063 enum protocol_type type, u32 *vf_cid);
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073 int qed_cxt_set_pf_params(struct qed_hwfn *p_hwfn, u32 rdma_tasks);
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083 int qed_cxt_cfg_ilt_compute(struct qed_hwfn *p_hwfn, u32 *last_line);
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093 u32 qed_cxt_cfg_ilt_compute_excess(struct qed_hwfn *p_hwfn, u32 used_lines);
0094
0095
0096
0097
0098
0099
0100
0101
0102 int qed_cxt_mngr_alloc(struct qed_hwfn *p_hwfn);
0103
0104
0105
0106
0107
0108
0109
0110
0111 void qed_cxt_mngr_free(struct qed_hwfn *p_hwfn);
0112
0113
0114
0115
0116
0117
0118
0119
0120 int qed_cxt_tables_alloc(struct qed_hwfn *p_hwfn);
0121
0122
0123
0124
0125
0126
0127 void qed_cxt_mngr_setup(struct qed_hwfn *p_hwfn);
0128
0129
0130
0131
0132
0133
0134
0135
0136 void qed_cxt_hw_init_common(struct qed_hwfn *p_hwfn);
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146 void qed_cxt_hw_init_pf(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157 void qed_qm_init_pf(struct qed_hwfn *p_hwfn,
0158 struct qed_ptt *p_ptt, bool is_pf_loading);
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168 int qed_qm_reconf(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
0169
0170 #define QED_CXT_PF_CID (0xff)
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180 void qed_cxt_release_cid(struct qed_hwfn *p_hwfn, u32 cid);
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191 void _qed_cxt_release_cid(struct qed_hwfn *p_hwfn, u32 cid, u8 vfid);
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202 int qed_cxt_acquire_cid(struct qed_hwfn *p_hwfn,
0203 enum protocol_type type, u32 *p_cid);
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216 int _qed_cxt_acquire_cid(struct qed_hwfn *p_hwfn,
0217 enum protocol_type type, u32 *p_cid, u8 vfid);
0218
0219 int qed_cxt_dynamic_ilt_alloc(struct qed_hwfn *p_hwfn,
0220 enum qed_cxt_elem_type elem_type, u32 iid);
0221 u32 qed_cxt_get_proto_tid_count(struct qed_hwfn *p_hwfn,
0222 enum protocol_type type);
0223 u32 qed_cxt_get_proto_cid_start(struct qed_hwfn *p_hwfn,
0224 enum protocol_type type);
0225 int qed_cxt_free_proto_ilt(struct qed_hwfn *p_hwfn, enum protocol_type proto);
0226
0227 #define QED_CTX_WORKING_MEM 0
0228 #define QED_CTX_FL_MEM 1
0229 int qed_cxt_get_task_ctx(struct qed_hwfn *p_hwfn,
0230 u32 tid, u8 ctx_type, void **task_ctx);
0231
0232
0233 #define MAX_CONN_TYPES PROTOCOLID_COMMON
0234 #define NUM_TASK_TYPES 2
0235 #define NUM_TASK_PF_SEGMENTS 4
0236 #define NUM_TASK_VF_SEGMENTS 1
0237
0238
0239 #define TASK_SEGMENTS (NUM_TASK_PF_SEGMENTS + NUM_TASK_VF_SEGMENTS)
0240 #define TASK_SEGMENT_VF (NUM_TASK_PF_SEGMENTS)
0241
0242 struct qed_tid_seg {
0243 u32 count;
0244 u8 type;
0245 bool has_fl_mem;
0246 };
0247
0248 struct qed_conn_type_cfg {
0249 u32 cid_count;
0250 u32 cids_per_vf;
0251 struct qed_tid_seg tid_seg[TASK_SEGMENTS];
0252 };
0253
0254
0255
0256
0257
0258
0259 #define ILT_CLI_PF_BLOCKS (1 + NUM_TASK_PF_SEGMENTS * 2)
0260 #define ILT_CLI_VF_BLOCKS (1 + NUM_TASK_VF_SEGMENTS * 2)
0261 #define CDUC_BLK (0)
0262 #define SRQ_BLK (0)
0263 #define CDUT_SEG_BLK(n) (1 + (u8)(n))
0264 #define CDUT_FL_SEG_BLK(n, X) (1 + (n) + NUM_TASK_ ## X ## _SEGMENTS)
0265
0266 struct ilt_cfg_pair {
0267 u32 reg;
0268 u32 val;
0269 };
0270
0271 struct qed_ilt_cli_blk {
0272 u32 total_size;
0273 u32 real_size_in_page;
0274 u32 start_line;
0275 u32 dynamic_line_offset;
0276 u32 dynamic_line_cnt;
0277 };
0278
0279 struct qed_ilt_client_cfg {
0280 bool active;
0281
0282
0283 struct ilt_cfg_pair first;
0284 struct ilt_cfg_pair last;
0285 struct ilt_cfg_pair p_size;
0286
0287
0288 struct qed_ilt_cli_blk pf_blks[ILT_CLI_PF_BLOCKS];
0289 u32 pf_total_lines;
0290
0291
0292 struct qed_ilt_cli_blk vf_blks[ILT_CLI_VF_BLOCKS];
0293 u32 vf_total_lines;
0294 };
0295
0296 struct qed_cid_acquired_map {
0297 u32 start_cid;
0298 u32 max_count;
0299 unsigned long *cid_map;
0300 };
0301
0302 struct qed_src_t2 {
0303 struct phys_mem_desc *dma_mem;
0304 u32 num_pages;
0305 u64 first_free;
0306 u64 last_free;
0307 };
0308
0309 struct qed_cxt_mngr {
0310
0311 struct qed_conn_type_cfg conn_cfg[MAX_CONN_TYPES];
0312
0313
0314 struct qed_ilt_client_cfg clients[MAX_ILT_CLIENTS];
0315
0316
0317 u32 task_type_size[NUM_TASK_TYPES];
0318
0319
0320
0321
0322 u32 vf_count;
0323 u32 first_vf_in_pf;
0324
0325
0326 struct qed_cid_acquired_map acquired[MAX_CONN_TYPES];
0327
0328 struct qed_cid_acquired_map
0329 acquired_vf[MAX_CONN_TYPES][MAX_NUM_VFS];
0330
0331
0332 struct phys_mem_desc *ilt_shadow;
0333 u32 ilt_shadow_size;
0334 u32 pf_start_line;
0335
0336
0337 struct mutex mutex;
0338
0339
0340 struct qed_src_t2 src_t2;
0341
0342
0343 u32 srq_count;
0344 u32 xrc_srq_count;
0345
0346
0347 u32 arfs_count;
0348
0349 u16 iscsi_task_pages;
0350 u16 fcoe_task_pages;
0351 u16 roce_task_pages;
0352 u16 eth_task_pages;
0353 u16 task_ctx_size;
0354 u16 conn_ctx_size;
0355 };
0356
0357 u16 qed_get_cdut_num_pf_init_pages(struct qed_hwfn *p_hwfn);
0358 u16 qed_get_cdut_num_vf_init_pages(struct qed_hwfn *p_hwfn);
0359 u16 qed_get_cdut_num_pf_work_pages(struct qed_hwfn *p_hwfn);
0360 u16 qed_get_cdut_num_vf_work_pages(struct qed_hwfn *p_hwfn);
0361
0362 u32 qed_cxt_get_ilt_page_size(struct qed_hwfn *p_hwfn,
0363 enum ilt_clients ilt_client);
0364
0365 u32 qed_cxt_get_total_srq_count(struct qed_hwfn *p_hwfn);
0366
0367 #endif