1 /* SPDX-License-Identifier: GPL-2.0 or Linux-OpenIB */
2 /* Copyright (c) 2016 - 2021 Intel Corporation */
3 #ifndef IRDMA_PROTOS_H
4 #define IRDMA_PROTOS_H
5 
6 #define PAUSE_TIMER_VAL		0xffff
7 #define REFRESH_THRESHOLD	0x7fff
8 #define HIGH_THRESHOLD		0x800
9 #define LOW_THRESHOLD		0x200
10 #define ALL_TC2PFC		0xff
11 #define CQP_COMPL_WAIT_TIME_MS	10
12 #define CQP_TIMEOUT_THRESHOLD	500
13 
14 /* init operations */
15 enum irdma_status_code irdma_sc_dev_init(enum irdma_vers ver,
16 					 struct irdma_sc_dev *dev,
17 					 struct irdma_device_init_info *info);
18 void irdma_sc_rt_init(struct irdma_sc_dev *dev);
19 void irdma_sc_cqp_post_sq(struct irdma_sc_cqp *cqp);
20 __le64 *irdma_sc_cqp_get_next_send_wqe(struct irdma_sc_cqp *cqp, u64 scratch);
21 enum irdma_status_code
22 irdma_sc_mr_fast_register(struct irdma_sc_qp *qp,
23 			  struct irdma_fast_reg_stag_info *info, bool post_sq);
24 /* HMC/FPM functions */
25 enum irdma_status_code irdma_sc_init_iw_hmc(struct irdma_sc_dev *dev,
26 					    u8 hmc_fn_id);
27 /* stats misc */
28 enum irdma_status_code
29 irdma_cqp_gather_stats_cmd(struct irdma_sc_dev *dev,
30 			   struct irdma_vsi_pestat *pestat, bool wait);
31 void irdma_cqp_gather_stats_gen1(struct irdma_sc_dev *dev,
32 				 struct irdma_vsi_pestat *pestat);
33 void irdma_hw_stats_read_all(struct irdma_vsi_pestat *stats,
34 			     struct irdma_dev_hw_stats *stats_values,
35 			     u64 *hw_stats_regs_32, u64 *hw_stats_regs_64,
36 			     u8 hw_rev);
37 enum irdma_status_code
38 irdma_cqp_ws_node_cmd(struct irdma_sc_dev *dev, u8 cmd,
39 		      struct irdma_ws_node_info *node_info);
40 enum irdma_status_code irdma_cqp_up_map_cmd(struct irdma_sc_dev *dev, u8 cmd,
41 					    struct irdma_up_info *map_info);
42 enum irdma_status_code irdma_cqp_ceq_cmd(struct irdma_sc_dev *dev,
43 					 struct irdma_sc_ceq *sc_ceq, u8 op);
44 enum irdma_status_code irdma_cqp_aeq_cmd(struct irdma_sc_dev *dev,
45 					 struct irdma_sc_aeq *sc_aeq, u8 op);
46 enum irdma_status_code
47 irdma_cqp_stats_inst_cmd(struct irdma_sc_vsi *vsi, u8 cmd,
48 			 struct irdma_stats_inst_info *stats_info);
49 u16 irdma_alloc_ws_node_id(struct irdma_sc_dev *dev);
50 void irdma_free_ws_node_id(struct irdma_sc_dev *dev, u16 node_id);
51 void irdma_update_stats(struct irdma_dev_hw_stats *hw_stats,
52 			struct irdma_gather_stats *gather_stats,
53 			struct irdma_gather_stats *last_gather_stats);
54 /* vsi functions */
55 enum irdma_status_code irdma_vsi_stats_init(struct irdma_sc_vsi *vsi,
56 					    struct irdma_vsi_stats_info *info);
57 void irdma_vsi_stats_free(struct irdma_sc_vsi *vsi);
58 void irdma_sc_vsi_init(struct irdma_sc_vsi *vsi,
59 		       struct irdma_vsi_init_info *info);
60 enum irdma_status_code irdma_sc_add_cq_ctx(struct irdma_sc_ceq *ceq,
61 					   struct irdma_sc_cq *cq);
62 void irdma_sc_remove_cq_ctx(struct irdma_sc_ceq *ceq, struct irdma_sc_cq *cq);
63 /* misc L2 param change functions */
64 void irdma_change_l2params(struct irdma_sc_vsi *vsi,
65 			   struct irdma_l2params *l2params);
66 void irdma_sc_suspend_resume_qps(struct irdma_sc_vsi *vsi, u8 suspend);
67 enum irdma_status_code irdma_cqp_qp_suspend_resume(struct irdma_sc_qp *qp,
68 						   u8 cmd);
69 void irdma_qp_add_qos(struct irdma_sc_qp *qp);
70 void irdma_qp_rem_qos(struct irdma_sc_qp *qp);
71 struct irdma_sc_qp *irdma_get_qp_from_list(struct list_head *head,
72 					   struct irdma_sc_qp *qp);
73 void irdma_reinitialize_ieq(struct irdma_sc_vsi *vsi);
74 /* terminate functions*/
75 void irdma_terminate_send_fin(struct irdma_sc_qp *qp);
76 
77 void irdma_terminate_connection(struct irdma_sc_qp *qp,
78 				struct irdma_aeqe_info *info);
79 
80 void irdma_terminate_received(struct irdma_sc_qp *qp,
81 			      struct irdma_aeqe_info *info);
82 /* dynamic memory allocation */
83 /* misc */
84 u8 irdma_get_encoded_wqe_size(u32 wqsize, enum irdma_queue_type queue_type);
85 void irdma_modify_qp_to_err(struct irdma_sc_qp *sc_qp);
86 enum irdma_status_code
87 irdma_sc_static_hmc_pages_allocated(struct irdma_sc_cqp *cqp, u64 scratch,
88 				    u8 hmc_fn_id, bool post_sq,
89 				    bool poll_registers);
90 enum irdma_status_code irdma_cfg_fpm_val(struct irdma_sc_dev *dev,
91 					 u32 qp_count);
92 enum irdma_status_code irdma_get_rdma_features(struct irdma_sc_dev *dev);
93 void free_sd_mem(struct irdma_sc_dev *dev);
94 enum irdma_status_code irdma_process_cqp_cmd(struct irdma_sc_dev *dev,
95 					     struct cqp_cmds_info *pcmdinfo);
96 enum irdma_status_code irdma_process_bh(struct irdma_sc_dev *dev);
97 enum irdma_status_code irdma_cqp_sds_cmd(struct irdma_sc_dev *dev,
98 					 struct irdma_update_sds_info *info);
99 enum irdma_status_code
100 irdma_cqp_query_fpm_val_cmd(struct irdma_sc_dev *dev,
101 			    struct irdma_dma_mem *val_mem, u8 hmc_fn_id);
102 enum irdma_status_code
103 irdma_cqp_commit_fpm_val_cmd(struct irdma_sc_dev *dev,
104 			     struct irdma_dma_mem *val_mem, u8 hmc_fn_id);
105 enum irdma_status_code irdma_alloc_query_fpm_buf(struct irdma_sc_dev *dev,
106 						 struct irdma_dma_mem *mem);
107 enum irdma_status_code
108 irdma_cqp_manage_hmc_fcn_cmd(struct irdma_sc_dev *dev,
109 			     struct irdma_hmc_fcn_info *hmcfcninfo,
110 			     u16 *pmf_idx);
111 void irdma_add_dev_ref(struct irdma_sc_dev *dev);
112 void irdma_put_dev_ref(struct irdma_sc_dev *dev);
113 void *irdma_remove_cqp_head(struct irdma_sc_dev *dev);
114 #endif /* IRDMA_PROTOS_H */
115