xref: /freebsd/sys/dev/irdma/irdma_protos.h (revision 38a52bd3)
1 /*-
2  * SPDX-License-Identifier: GPL-2.0 or Linux-OpenIB
3  *
4  * Copyright (c) 2016 - 2021 Intel Corporation
5  *
6  * This software is available to you under a choice of one of two
7  * licenses.  You may choose to be licensed under the terms of the GNU
8  * General Public License (GPL) Version 2, available from the file
9  * COPYING in the main directory of this source tree, or the
10  * OpenFabrics.org BSD license below:
11  *
12  *   Redistribution and use in source and binary forms, with or
13  *   without modification, are permitted provided that the following
14  *   conditions are met:
15  *
16  *    - Redistributions of source code must retain the above
17  *	copyright notice, this list of conditions and the following
18  *	disclaimer.
19  *
20  *    - Redistributions in binary form must reproduce the above
21  *	copyright notice, this list of conditions and the following
22  *	disclaimer in the documentation and/or other materials
23  *	provided with the distribution.
24  *
25  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32  * SOFTWARE.
33  */
34 /*$FreeBSD$*/
35 
36 #ifndef IRDMA_PROTOS_H
37 #define IRDMA_PROTOS_H
38 
39 #define PAUSE_TIMER_VAL		0xffff
40 #define REFRESH_THRESHOLD	0x7fff
41 #define HIGH_THRESHOLD		0x800
42 #define LOW_THRESHOLD		0x200
43 #define ALL_TC2PFC		0xff
44 #define CQP_COMPL_WAIT_TIME_MS	10
45 #define CQP_TIMEOUT_THRESHOLD	500
46 
47 /* init operations */
48 int irdma_sc_dev_init(enum irdma_vers ver, struct irdma_sc_dev *dev,
49 		      struct irdma_device_init_info *info);
50 void irdma_sc_cqp_post_sq(struct irdma_sc_cqp *cqp);
51 __le64 *irdma_sc_cqp_get_next_send_wqe(struct irdma_sc_cqp *cqp, u64 scratch);
52 int irdma_sc_mr_fast_register(struct irdma_sc_qp *qp,
53 			      struct irdma_fast_reg_stag_info *info,
54 			      bool post_sq);
55 void irdma_init_config_check(struct irdma_config_check *cc,
56 			     u8 traffic_class,
57 			     u16 qs_handle);
58 /* HMC/FPM functions */
59 int irdma_sc_init_iw_hmc(struct irdma_sc_dev *dev, u8 hmc_fn_id);
60 /* stats misc */
61 int irdma_cqp_gather_stats_cmd(struct irdma_sc_dev *dev,
62 			       struct irdma_vsi_pestat *pestat, bool wait);
63 int irdma_cqp_ws_node_cmd(struct irdma_sc_dev *dev, u8 cmd,
64 			  struct irdma_ws_node_info *node_info);
65 int irdma_cqp_up_map_cmd(struct irdma_sc_dev *dev, u8 cmd,
66 			 struct irdma_up_info *map_info);
67 int irdma_cqp_ceq_cmd(struct irdma_sc_dev *dev, struct irdma_sc_ceq *sc_ceq,
68 		      u8 op);
69 int irdma_cqp_aeq_cmd(struct irdma_sc_dev *dev, struct irdma_sc_aeq *sc_aeq,
70 		      u8 op);
71 int irdma_cqp_stats_inst_cmd(struct irdma_sc_vsi *vsi, u8 cmd,
72 			     struct irdma_stats_inst_info *stats_info);
73 u16 irdma_alloc_ws_node_id(struct irdma_sc_dev *dev);
74 void irdma_free_ws_node_id(struct irdma_sc_dev *dev, u16 node_id);
75 void irdma_update_stats(struct irdma_dev_hw_stats *hw_stats,
76 			struct irdma_gather_stats *gather_stats,
77 			struct irdma_gather_stats *last_gather_stats,
78 			const struct irdma_hw_stat_map *map,
79 			u16 max_stat_idx);
80 /* vsi functions */
81 int irdma_vsi_stats_init(struct irdma_sc_vsi *vsi,
82 			 struct irdma_vsi_stats_info *info);
83 void irdma_vsi_stats_free(struct irdma_sc_vsi *vsi);
84 void irdma_sc_vsi_init(struct irdma_sc_vsi *vsi,
85 		       struct irdma_vsi_init_info *info);
86 int irdma_sc_add_cq_ctx(struct irdma_sc_ceq *ceq, struct irdma_sc_cq *cq);
87 void irdma_sc_remove_cq_ctx(struct irdma_sc_ceq *ceq, struct irdma_sc_cq *cq);
88 /* misc L2 param change functions */
89 void irdma_change_l2params(struct irdma_sc_vsi *vsi,
90 			   struct irdma_l2params *l2params);
91 void irdma_sc_suspend_resume_qps(struct irdma_sc_vsi *vsi, u8 suspend);
92 int irdma_cqp_qp_suspend_resume(struct irdma_sc_qp *qp, u8 cmd);
93 void irdma_qp_add_qos(struct irdma_sc_qp *qp);
94 void irdma_qp_rem_qos(struct irdma_sc_qp *qp);
95 struct irdma_sc_qp *irdma_get_qp_from_list(struct list_head *head,
96 					   struct irdma_sc_qp *qp);
97 void irdma_reinitialize_ieq(struct irdma_sc_vsi *vsi);
98 u16 irdma_alloc_ws_node_id(struct irdma_sc_dev *dev);
99 void irdma_free_ws_node_id(struct irdma_sc_dev *dev, u16 node_id);
100 /* terminate functions*/
101 void irdma_terminate_send_fin(struct irdma_sc_qp *qp);
102 
103 void irdma_terminate_connection(struct irdma_sc_qp *qp,
104 				struct irdma_aeqe_info *info);
105 
106 void irdma_terminate_received(struct irdma_sc_qp *qp,
107 			      struct irdma_aeqe_info *info);
108 /* dynamic memory allocation */
109 void *irdma_allocate_dma_mem(struct irdma_hw *hw, struct irdma_dma_mem *mem,
110 			     u64 size, u32 alignment);
111 void *irdma_allocate_virt_mem(struct irdma_hw *hw, struct irdma_virt_mem *mem, 			      u32 size);
112 int irdma_free_dma_mem(struct irdma_hw *hw, struct irdma_dma_mem *mem);
113 /* misc */
114 u8 irdma_get_encoded_wqe_size(u32 wqsize, enum irdma_queue_type queue_type);
115 void irdma_modify_qp_to_err(struct irdma_sc_qp *sc_qp);
116 int irdma_sc_static_hmc_pages_allocated(struct irdma_sc_cqp *cqp, u64 scratch,
117 					u8 hmc_fn_id, bool post_sq,
118 					bool poll_registers);
119 int irdma_cfg_fpm_val(struct irdma_sc_dev *dev, u32 qp_count);
120 int irdma_get_rdma_features(struct irdma_sc_dev *dev);
121 void free_sd_mem(struct irdma_sc_dev *dev);
122 int irdma_process_cqp_cmd(struct irdma_sc_dev *dev,
123 			  struct cqp_cmds_info *pcmdinfo);
124 int irdma_process_bh(struct irdma_sc_dev *dev);
125 extern void dump_ctx(struct irdma_sc_dev *dev, u32 pf_num, u32 qp_num);
126 void dumpCSR(struct irdma_sc_dev *dev);
127 void dumpCSRx(struct irdma_sc_dev *dev);
128 void dumpcls(struct irdma_sc_dev *dev);
129 int irdma_cqp_sds_cmd(struct irdma_sc_dev *dev,
130 		      struct irdma_update_sds_info *info);
131 int irdma_cqp_query_fpm_val_cmd(struct irdma_sc_dev *dev,
132 				struct irdma_dma_mem *val_mem, u8 hmc_fn_id);
133 int irdma_cqp_commit_fpm_val_cmd(struct irdma_sc_dev *dev,
134 				 struct irdma_dma_mem *val_mem, u8 hmc_fn_id);
135 int irdma_alloc_query_fpm_buf(struct irdma_sc_dev *dev,
136 			      struct irdma_dma_mem *mem);
137 int irdma_cqp_manage_hmc_fcn_cmd(struct irdma_sc_dev *dev,
138 				 struct irdma_hmc_fcn_info *hmcfcninfo,
139 				 u16 *pmf_idx);
140 void *irdma_remove_cqp_head(struct irdma_sc_dev *dev);
141 #endif /* IRDMA_PROTOS_H */
142