0001
0002
0003
0004
0005
0006
0007 #ifndef _QED_SP_H
0008 #define _QED_SP_H
0009
0010 #include <linux/types.h>
0011 #include <linux/kernel.h>
0012 #include <linux/list.h>
0013 #include <linux/slab.h>
0014 #include <linux/spinlock.h>
0015 #include <linux/qed/qed_chain.h>
0016 #include "qed.h"
0017 #include "qed_hsi.h"
0018
0019 enum spq_mode {
0020 QED_SPQ_MODE_BLOCK,
0021 QED_SPQ_MODE_CB,
0022 QED_SPQ_MODE_EBLOCK,
0023 };
0024
0025 struct qed_spq_comp_cb {
0026 void (*function)(struct qed_hwfn *p_hwfn,
0027 void *cookie,
0028 union event_ring_data *data,
0029 u8 fw_return_code);
0030 void *cookie;
0031 };
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042 int qed_eth_cqe_completion(struct qed_hwfn *p_hwfn,
0043 struct eth_slow_path_rx_cqe *cqe);
0044
0045
0046 union ramrod_data {
0047 struct pf_start_ramrod_data pf_start;
0048 struct pf_update_ramrod_data pf_update;
0049 struct rx_queue_start_ramrod_data rx_queue_start;
0050 struct rx_queue_update_ramrod_data rx_queue_update;
0051 struct rx_queue_stop_ramrod_data rx_queue_stop;
0052 struct tx_queue_start_ramrod_data tx_queue_start;
0053 struct tx_queue_stop_ramrod_data tx_queue_stop;
0054 struct vport_start_ramrod_data vport_start;
0055 struct vport_stop_ramrod_data vport_stop;
0056 struct rx_update_gft_filter_ramrod_data rx_update_gft;
0057 struct vport_update_ramrod_data vport_update;
0058 struct core_rx_start_ramrod_data core_rx_queue_start;
0059 struct core_rx_stop_ramrod_data core_rx_queue_stop;
0060 struct core_tx_start_ramrod_data core_tx_queue_start;
0061 struct core_tx_stop_ramrod_data core_tx_queue_stop;
0062 struct vport_filter_update_ramrod_data vport_filter_update;
0063
0064 struct rdma_init_func_ramrod_data rdma_init_func;
0065 struct rdma_close_func_ramrod_data rdma_close_func;
0066 struct rdma_register_tid_ramrod_data rdma_register_tid;
0067 struct rdma_deregister_tid_ramrod_data rdma_deregister_tid;
0068 struct roce_create_qp_resp_ramrod_data roce_create_qp_resp;
0069 struct roce_create_qp_req_ramrod_data roce_create_qp_req;
0070 struct roce_modify_qp_resp_ramrod_data roce_modify_qp_resp;
0071 struct roce_modify_qp_req_ramrod_data roce_modify_qp_req;
0072 struct roce_query_qp_resp_ramrod_data roce_query_qp_resp;
0073 struct roce_query_qp_req_ramrod_data roce_query_qp_req;
0074 struct roce_destroy_qp_resp_ramrod_data roce_destroy_qp_resp;
0075 struct roce_destroy_qp_req_ramrod_data roce_destroy_qp_req;
0076 struct roce_init_func_ramrod_data roce_init_func;
0077 struct rdma_create_cq_ramrod_data rdma_create_cq;
0078 struct rdma_destroy_cq_ramrod_data rdma_destroy_cq;
0079 struct rdma_srq_create_ramrod_data rdma_create_srq;
0080 struct rdma_srq_destroy_ramrod_data rdma_destroy_srq;
0081 struct rdma_srq_modify_ramrod_data rdma_modify_srq;
0082 struct iwarp_create_qp_ramrod_data iwarp_create_qp;
0083 struct iwarp_tcp_offload_ramrod_data iwarp_tcp_offload;
0084 struct iwarp_mpa_offload_ramrod_data iwarp_mpa_offload;
0085 struct iwarp_modify_qp_ramrod_data iwarp_modify_qp;
0086 struct iwarp_init_func_ramrod_data iwarp_init_func;
0087 struct fcoe_init_ramrod_params fcoe_init;
0088 struct fcoe_conn_offload_ramrod_params fcoe_conn_ofld;
0089 struct fcoe_conn_terminate_ramrod_params fcoe_conn_terminate;
0090 struct fcoe_stat_ramrod_params fcoe_stat;
0091
0092 struct iscsi_init_ramrod_params iscsi_init;
0093 struct iscsi_spe_conn_offload iscsi_conn_offload;
0094 struct iscsi_conn_update_ramrod_params iscsi_conn_update;
0095 struct iscsi_spe_conn_mac_update iscsi_conn_mac_update;
0096 struct iscsi_spe_conn_termination iscsi_conn_terminate;
0097
0098 struct nvmetcp_init_ramrod_params nvmetcp_init;
0099 struct nvmetcp_spe_conn_offload nvmetcp_conn_offload;
0100 struct nvmetcp_conn_update_ramrod_params nvmetcp_conn_update;
0101 struct nvmetcp_spe_conn_termination nvmetcp_conn_terminate;
0102
0103 struct vf_start_ramrod_data vf_start;
0104 struct vf_stop_ramrod_data vf_stop;
0105 };
0106
0107 #define EQ_MAX_CREDIT 0xffffffff
0108
0109 enum spq_priority {
0110 QED_SPQ_PRIORITY_NORMAL,
0111 QED_SPQ_PRIORITY_HIGH,
0112 };
0113
0114 union qed_spq_req_comp {
0115 struct qed_spq_comp_cb cb;
0116 u64 *done_addr;
0117 };
0118
0119 struct qed_spq_comp_done {
0120 unsigned int done;
0121 u8 fw_return_code;
0122 };
0123
0124 struct qed_spq_entry {
0125 struct list_head list;
0126
0127 u8 flags;
0128
0129
0130 struct slow_path_element elem;
0131
0132 union ramrod_data ramrod;
0133
0134 enum spq_priority priority;
0135
0136
0137 struct list_head *queue;
0138
0139 enum spq_mode comp_mode;
0140 struct qed_spq_comp_cb comp_cb;
0141 struct qed_spq_comp_done comp_done;
0142
0143
0144 struct qed_spq_entry *post_ent;
0145 };
0146
0147 struct qed_eq {
0148 struct qed_chain chain;
0149 u8 eq_sb_index;
0150 __le16 *p_fw_cons;
0151 };
0152
0153 struct qed_consq {
0154 struct qed_chain chain;
0155 };
0156
0157 typedef int (*qed_spq_async_comp_cb)(struct qed_hwfn *p_hwfn, u8 opcode,
0158 __le16 echo, union event_ring_data *data,
0159 u8 fw_return_code);
0160
0161 int
0162 qed_spq_register_async_cb(struct qed_hwfn *p_hwfn,
0163 enum protocol_type protocol_id,
0164 qed_spq_async_comp_cb cb);
0165
0166 void
0167 qed_spq_unregister_async_cb(struct qed_hwfn *p_hwfn,
0168 enum protocol_type protocol_id);
0169
0170 struct qed_spq {
0171 spinlock_t lock;
0172
0173 struct list_head unlimited_pending;
0174 struct list_head pending;
0175 struct list_head completion_pending;
0176 struct list_head free_pool;
0177
0178 struct qed_chain chain;
0179
0180
0181 dma_addr_t p_phys;
0182 struct qed_spq_entry *p_virt;
0183
0184 #define SPQ_RING_SIZE \
0185 (CORE_SPQE_PAGE_SIZE_BYTES / sizeof(struct slow_path_element))
0186
0187
0188 DECLARE_BITMAP(p_comp_bitmap, SPQ_RING_SIZE);
0189 u8 comp_bitmap_idx;
0190
0191
0192 u32 unlimited_pending_count;
0193 u32 normal_count;
0194 u32 high_count;
0195 u32 comp_sent_count;
0196 u32 comp_count;
0197
0198 u32 cid;
0199 u32 db_addr_offset;
0200 struct core_db_data db_data;
0201 qed_spq_async_comp_cb async_comp_cb[MAX_PROTOCOL_TYPE];
0202 };
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214 int qed_spq_post(struct qed_hwfn *p_hwfn,
0215 struct qed_spq_entry *p_ent,
0216 u8 *fw_return_code);
0217
0218
0219
0220
0221
0222
0223
0224
0225 int qed_spq_alloc(struct qed_hwfn *p_hwfn);
0226
0227
0228
0229
0230
0231
0232
0233
0234 void qed_spq_setup(struct qed_hwfn *p_hwfn);
0235
0236
0237
0238
0239
0240
0241
0242
0243 void qed_spq_free(struct qed_hwfn *p_hwfn);
0244
0245
0246
0247
0248
0249
0250
0251
0252
0253
0254 int
0255 qed_spq_get_entry(struct qed_hwfn *p_hwfn,
0256 struct qed_spq_entry **pp_ent);
0257
0258
0259
0260
0261
0262
0263
0264
0265
0266 void qed_spq_return_entry(struct qed_hwfn *p_hwfn,
0267 struct qed_spq_entry *p_ent);
0268
0269
0270
0271
0272
0273
0274
0275
0276 int qed_eq_alloc(struct qed_hwfn *p_hwfn, u16 num_elem);
0277
0278
0279
0280
0281
0282
0283
0284
0285 void qed_eq_setup(struct qed_hwfn *p_hwfn);
0286
0287
0288
0289
0290
0291
0292
0293
0294 void qed_eq_free(struct qed_hwfn *p_hwfn);
0295
0296
0297
0298
0299
0300
0301
0302
0303
0304 void qed_eq_prod_update(struct qed_hwfn *p_hwfn,
0305 u16 prod);
0306
0307
0308
0309
0310
0311
0312
0313
0314
0315 int qed_eq_completion(struct qed_hwfn *p_hwfn,
0316 void *cookie);
0317
0318
0319
0320
0321
0322
0323
0324
0325
0326
0327
0328 int qed_spq_completion(struct qed_hwfn *p_hwfn,
0329 __le16 echo,
0330 u8 fw_return_code,
0331 union event_ring_data *p_data);
0332
0333
0334
0335
0336
0337
0338
0339
0340 u32 qed_spq_get_cid(struct qed_hwfn *p_hwfn);
0341
0342
0343
0344
0345
0346
0347
0348
0349 int qed_consq_alloc(struct qed_hwfn *p_hwfn);
0350
0351
0352
0353
0354
0355
0356
0357
0358 void qed_consq_setup(struct qed_hwfn *p_hwfn);
0359
0360
0361
0362
0363
0364
0365
0366
0367 void qed_consq_free(struct qed_hwfn *p_hwfn);
0368 int qed_spq_pend_post(struct qed_hwfn *p_hwfn);
0369
0370
0371
0372 #define QED_SP_EQ_COMPLETION 0x01
0373 #define QED_SP_CQE_COMPLETION 0x02
0374
0375 struct qed_sp_init_data {
0376 u32 cid;
0377 u16 opaque_fid;
0378
0379
0380 enum spq_mode comp_mode;
0381 struct qed_spq_comp_cb *p_comp_data;
0382 };
0383
0384
0385
0386
0387
0388
0389
0390
0391
0392
0393
0394
0395 void qed_sp_destroy_request(struct qed_hwfn *p_hwfn,
0396 struct qed_spq_entry *p_ent);
0397
0398 int qed_sp_init_request(struct qed_hwfn *p_hwfn,
0399 struct qed_spq_entry **pp_ent,
0400 u8 cmd,
0401 u8 protocol,
0402 struct qed_sp_init_data *p_data);
0403
0404
0405
0406
0407
0408
0409
0410
0411
0412
0413
0414
0415
0416
0417
0418
0419
0420
0421
0422
0423
0424 int qed_sp_pf_start(struct qed_hwfn *p_hwfn,
0425 struct qed_ptt *p_ptt,
0426 struct qed_tunnel_info *p_tunn,
0427 bool allow_npar_tx_switch);
0428
0429
0430
0431
0432
0433
0434
0435
0436
0437
0438
0439
0440 int qed_sp_pf_update(struct qed_hwfn *p_hwfn);
0441
0442
0443
0444
0445
0446
0447
0448
0449 int qed_sp_pf_update_stag(struct qed_hwfn *p_hwfn);
0450
0451
0452
0453
0454
0455
0456
0457
0458 int qed_sp_pf_update_ufp(struct qed_hwfn *p_hwfn);
0459
0460 int qed_sp_pf_stop(struct qed_hwfn *p_hwfn);
0461
0462 int qed_sp_pf_update_tunn_cfg(struct qed_hwfn *p_hwfn,
0463 struct qed_ptt *p_ptt,
0464 struct qed_tunnel_info *p_tunn,
0465 enum spq_mode comp_mode,
0466 struct qed_spq_comp_cb *p_comp_data);
0467
0468
0469
0470
0471
0472
0473
0474
0475 int qed_sp_heartbeat_ramrod(struct qed_hwfn *p_hwfn);
0476
0477 #endif