diff options
author | Faisal Latif <faisal.latif@intel.com> | 2016-01-20 14:40:14 -0500 |
---|---|---|
committer | Doug Ledford <dledford@redhat.com> | 2016-03-16 13:50:53 -0400 |
commit | 4097351a47c588aeb50649da32213634563b1fe2 (patch) | |
tree | 3d77522b79cada15ea11167df31c50331237e8ca | |
parent | 280cfc4b74e6d584cd368498742ad0e3c04c3ac9 (diff) |
i40iw: virtual channel handling files
i40iw_vf.[ch] and i40iw_virtchnl[ch] are used for virtual
channel support for iWARP VF module.
Changes since v2:
code cleanup
Acked-by: Anjali Singhai Jain <anjali.singhai@intel.com>
Acked-by: Shannon Nelson <shannon.nelson@intel.com>
Signed-off-by: Faisal Latif <faisal.latif@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
-rw-r--r-- | drivers/infiniband/hw/i40iw/i40iw_vf.c | 85 | ||||
-rw-r--r-- | drivers/infiniband/hw/i40iw/i40iw_vf.h | 62 | ||||
-rw-r--r-- | drivers/infiniband/hw/i40iw/i40iw_virtchnl.c | 748 | ||||
-rw-r--r-- | drivers/infiniband/hw/i40iw/i40iw_virtchnl.h | 124 |
4 files changed, 1019 insertions, 0 deletions
diff --git a/drivers/infiniband/hw/i40iw/i40iw_vf.c b/drivers/infiniband/hw/i40iw/i40iw_vf.c new file mode 100644 index 000000000000..cb0f18340e14 --- /dev/null +++ b/drivers/infiniband/hw/i40iw/i40iw_vf.c | |||
@@ -0,0 +1,85 @@ | |||
1 | /******************************************************************************* | ||
2 | * | ||
3 | * Copyright (c) 2015-2016 Intel Corporation. All rights reserved. | ||
4 | * | ||
5 | * This software is available to you under a choice of one of two | ||
6 | * licenses. You may choose to be licensed under the terms of the GNU | ||
7 | * General Public License (GPL) Version 2, available from the file | ||
8 | * COPYING in the main directory of this source tree, or the | ||
9 | * OpenFabrics.org BSD license below: | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or | ||
12 | * without modification, are permitted provided that the following | ||
13 | * conditions are met: | ||
14 | * | ||
15 | * - Redistributions of source code must retain the above | ||
16 | * copyright notice, this list of conditions and the following | ||
17 | * disclaimer. | ||
18 | * | ||
19 | * - Redistributions in binary form must reproduce the above | ||
20 | * copyright notice, this list of conditions and the following | ||
21 | * disclaimer in the documentation and/or other materials | ||
22 | * provided with the distribution. | ||
23 | * | ||
24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
25 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
26 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
27 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
28 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
29 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
30 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
31 | * SOFTWARE. | ||
32 | * | ||
33 | *******************************************************************************/ | ||
34 | |||
35 | #include "i40iw_osdep.h" | ||
36 | #include "i40iw_register.h" | ||
37 | #include "i40iw_status.h" | ||
38 | #include "i40iw_hmc.h" | ||
39 | #include "i40iw_d.h" | ||
40 | #include "i40iw_type.h" | ||
41 | #include "i40iw_p.h" | ||
42 | #include "i40iw_vf.h" | ||
43 | |||
44 | /** | ||
45 | * i40iw_manage_vf_pble_bp - manage vf pble | ||
46 | * @cqp: cqp for cqp' sq wqe | ||
47 | * @info: pble info | ||
48 | * @scratch: pointer for completion | ||
49 | * @post_sq: to post and ring | ||
50 | */ | ||
51 | enum i40iw_status_code i40iw_manage_vf_pble_bp(struct i40iw_sc_cqp *cqp, | ||
52 | struct i40iw_manage_vf_pble_info *info, | ||
53 | u64 scratch, | ||
54 | bool post_sq) | ||
55 | { | ||
56 | u64 *wqe; | ||
57 | u64 temp, header, pd_pl_pba = 0; | ||
58 | |||
59 | wqe = i40iw_sc_cqp_get_next_send_wqe(cqp, scratch); | ||
60 | if (!wqe) | ||
61 | return I40IW_ERR_RING_FULL; | ||
62 | |||
63 | temp = LS_64(info->pd_entry_cnt, I40IW_CQPSQ_MVPBP_PD_ENTRY_CNT) | | ||
64 | LS_64(info->first_pd_index, I40IW_CQPSQ_MVPBP_FIRST_PD_INX) | | ||
65 | LS_64(info->sd_index, I40IW_CQPSQ_MVPBP_SD_INX); | ||
66 | set_64bit_val(wqe, 16, temp); | ||
67 | |||
68 | header = LS_64((info->inv_pd_ent ? 1 : 0), I40IW_CQPSQ_MVPBP_INV_PD_ENT) | | ||
69 | LS_64(I40IW_CQP_OP_MANAGE_VF_PBLE_BP, I40IW_CQPSQ_OPCODE) | | ||
70 | LS_64(cqp->polarity, I40IW_CQPSQ_WQEVALID); | ||
71 | set_64bit_val(wqe, 24, header); | ||
72 | |||
73 | pd_pl_pba = LS_64(info->pd_pl_pba >> 3, I40IW_CQPSQ_MVPBP_PD_PLPBA); | ||
74 | set_64bit_val(wqe, 32, pd_pl_pba); | ||
75 | |||
76 | i40iw_debug_buf(cqp->dev, I40IW_DEBUG_WQE, "MANAGE VF_PBLE_BP WQE", wqe, I40IW_CQP_WQE_SIZE * 8); | ||
77 | |||
78 | if (post_sq) | ||
79 | i40iw_sc_cqp_post_sq(cqp); | ||
80 | return 0; | ||
81 | } | ||
82 | |||
83 | struct i40iw_vf_cqp_ops iw_vf_cqp_ops = { | ||
84 | i40iw_manage_vf_pble_bp | ||
85 | }; | ||
diff --git a/drivers/infiniband/hw/i40iw/i40iw_vf.h b/drivers/infiniband/hw/i40iw/i40iw_vf.h new file mode 100644 index 000000000000..f649f3a62e13 --- /dev/null +++ b/drivers/infiniband/hw/i40iw/i40iw_vf.h | |||
@@ -0,0 +1,62 @@ | |||
1 | /******************************************************************************* | ||
2 | * | ||
3 | * Copyright (c) 2015-2016 Intel Corporation. All rights reserved. | ||
4 | * | ||
5 | * This software is available to you under a choice of one of two | ||
6 | * licenses. You may choose to be licensed under the terms of the GNU | ||
7 | * General Public License (GPL) Version 2, available from the file | ||
8 | * COPYING in the main directory of this source tree, or the | ||
9 | * OpenFabrics.org BSD license below: | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or | ||
12 | * without modification, are permitted provided that the following | ||
13 | * conditions are met: | ||
14 | * | ||
15 | * - Redistributions of source code must retain the above | ||
16 | * copyright notice, this list of conditions and the following | ||
17 | * disclaimer. | ||
18 | * | ||
19 | * - Redistributions in binary form must reproduce the above | ||
20 | * copyright notice, this list of conditions and the following | ||
21 | * disclaimer in the documentation and/or other materials | ||
22 | * provided with the distribution. | ||
23 | * | ||
24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
25 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
26 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
27 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
28 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
29 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
30 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
31 | * SOFTWARE. | ||
32 | * | ||
33 | *******************************************************************************/ | ||
34 | |||
35 | #ifndef I40IW_VF_H | ||
36 | #define I40IW_VF_H | ||
37 | |||
38 | struct i40iw_sc_cqp; | ||
39 | |||
40 | struct i40iw_manage_vf_pble_info { | ||
41 | u32 sd_index; | ||
42 | u16 first_pd_index; | ||
43 | u16 pd_entry_cnt; | ||
44 | u8 inv_pd_ent; | ||
45 | u64 pd_pl_pba; | ||
46 | }; | ||
47 | |||
48 | struct i40iw_vf_cqp_ops { | ||
49 | enum i40iw_status_code (*manage_vf_pble_bp)(struct i40iw_sc_cqp *, | ||
50 | struct i40iw_manage_vf_pble_info *, | ||
51 | u64, | ||
52 | bool); | ||
53 | }; | ||
54 | |||
55 | enum i40iw_status_code i40iw_manage_vf_pble_bp(struct i40iw_sc_cqp *cqp, | ||
56 | struct i40iw_manage_vf_pble_info *info, | ||
57 | u64 scratch, | ||
58 | bool post_sq); | ||
59 | |||
60 | extern struct i40iw_vf_cqp_ops iw_vf_cqp_ops; | ||
61 | |||
62 | #endif | ||
diff --git a/drivers/infiniband/hw/i40iw/i40iw_virtchnl.c b/drivers/infiniband/hw/i40iw/i40iw_virtchnl.c new file mode 100644 index 000000000000..6b68f7890b76 --- /dev/null +++ b/drivers/infiniband/hw/i40iw/i40iw_virtchnl.c | |||
@@ -0,0 +1,748 @@ | |||
1 | /******************************************************************************* | ||
2 | * | ||
3 | * Copyright (c) 2015-2016 Intel Corporation. All rights reserved. | ||
4 | * | ||
5 | * This software is available to you under a choice of one of two | ||
6 | * licenses. You may choose to be licensed under the terms of the GNU | ||
7 | * General Public License (GPL) Version 2, available from the file | ||
8 | * COPYING in the main directory of this source tree, or the | ||
9 | * OpenFabrics.org BSD license below: | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or | ||
12 | * without modification, are permitted provided that the following | ||
13 | * conditions are met: | ||
14 | * | ||
15 | * - Redistributions of source code must retain the above | ||
16 | * copyright notice, this list of conditions and the following | ||
17 | * disclaimer. | ||
18 | * | ||
19 | * - Redistributions in binary form must reproduce the above | ||
20 | * copyright notice, this list of conditions and the following | ||
21 | * disclaimer in the documentation and/or other materials | ||
22 | * provided with the distribution. | ||
23 | * | ||
24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
25 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
26 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
27 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
28 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
29 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
30 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
31 | * SOFTWARE. | ||
32 | * | ||
33 | *******************************************************************************/ | ||
34 | |||
35 | #include "i40iw_osdep.h" | ||
36 | #include "i40iw_register.h" | ||
37 | #include "i40iw_status.h" | ||
38 | #include "i40iw_hmc.h" | ||
39 | #include "i40iw_d.h" | ||
40 | #include "i40iw_type.h" | ||
41 | #include "i40iw_p.h" | ||
42 | #include "i40iw_virtchnl.h" | ||
43 | |||
44 | /** | ||
45 | * vchnl_vf_send_get_ver_req - Request Channel version | ||
46 | * @dev: IWARP device pointer | ||
47 | * @vchnl_req: Virtual channel message request pointer | ||
48 | */ | ||
49 | static enum i40iw_status_code vchnl_vf_send_get_ver_req(struct i40iw_sc_dev *dev, | ||
50 | struct i40iw_virtchnl_req *vchnl_req) | ||
51 | { | ||
52 | enum i40iw_status_code ret_code = I40IW_ERR_NOT_READY; | ||
53 | struct i40iw_virtchnl_op_buf *vchnl_msg = vchnl_req->vchnl_msg; | ||
54 | |||
55 | if (!dev->vchnl_up) | ||
56 | return ret_code; | ||
57 | |||
58 | memset(vchnl_msg, 0, sizeof(*vchnl_msg)); | ||
59 | vchnl_msg->iw_chnl_op_ctx = (uintptr_t)vchnl_req; | ||
60 | vchnl_msg->iw_chnl_buf_len = sizeof(*vchnl_msg); | ||
61 | vchnl_msg->iw_op_code = I40IW_VCHNL_OP_GET_VER; | ||
62 | vchnl_msg->iw_op_ver = I40IW_VCHNL_OP_GET_VER_V0; | ||
63 | ret_code = dev->vchnl_if.vchnl_send(dev, 0, (u8 *)vchnl_msg, vchnl_msg->iw_chnl_buf_len); | ||
64 | if (ret_code) | ||
65 | i40iw_debug(dev, I40IW_DEBUG_VIRT, | ||
66 | "%s: virt channel send failed 0x%x\n", __func__, ret_code); | ||
67 | return ret_code; | ||
68 | } | ||
69 | |||
70 | /** | ||
71 | * vchnl_vf_send_get_hmc_fcn_req - Request HMC Function from VF | ||
72 | * @dev: IWARP device pointer | ||
73 | * @vchnl_req: Virtual channel message request pointer | ||
74 | */ | ||
75 | static enum i40iw_status_code vchnl_vf_send_get_hmc_fcn_req(struct i40iw_sc_dev *dev, | ||
76 | struct i40iw_virtchnl_req *vchnl_req) | ||
77 | { | ||
78 | enum i40iw_status_code ret_code = I40IW_ERR_NOT_READY; | ||
79 | struct i40iw_virtchnl_op_buf *vchnl_msg = vchnl_req->vchnl_msg; | ||
80 | |||
81 | if (!dev->vchnl_up) | ||
82 | return ret_code; | ||
83 | |||
84 | memset(vchnl_msg, 0, sizeof(*vchnl_msg)); | ||
85 | vchnl_msg->iw_chnl_op_ctx = (uintptr_t)vchnl_req; | ||
86 | vchnl_msg->iw_chnl_buf_len = sizeof(*vchnl_msg); | ||
87 | vchnl_msg->iw_op_code = I40IW_VCHNL_OP_GET_HMC_FCN; | ||
88 | vchnl_msg->iw_op_ver = I40IW_VCHNL_OP_GET_HMC_FCN_V0; | ||
89 | ret_code = dev->vchnl_if.vchnl_send(dev, 0, (u8 *)vchnl_msg, vchnl_msg->iw_chnl_buf_len); | ||
90 | if (ret_code) | ||
91 | i40iw_debug(dev, I40IW_DEBUG_VIRT, | ||
92 | "%s: virt channel send failed 0x%x\n", __func__, ret_code); | ||
93 | return ret_code; | ||
94 | } | ||
95 | |||
96 | /** | ||
97 | * vchnl_vf_send_get_pe_stats_req - Request PE stats from VF | ||
98 | * @dev: IWARP device pointer | ||
99 | * @vchnl_req: Virtual channel message request pointer | ||
100 | */ | ||
101 | static enum i40iw_status_code vchnl_vf_send_get_pe_stats_req(struct i40iw_sc_dev *dev, | ||
102 | struct i40iw_virtchnl_req *vchnl_req) | ||
103 | { | ||
104 | enum i40iw_status_code ret_code = I40IW_ERR_NOT_READY; | ||
105 | struct i40iw_virtchnl_op_buf *vchnl_msg = vchnl_req->vchnl_msg; | ||
106 | |||
107 | if (!dev->vchnl_up) | ||
108 | return ret_code; | ||
109 | |||
110 | memset(vchnl_msg, 0, sizeof(*vchnl_msg)); | ||
111 | vchnl_msg->iw_chnl_op_ctx = (uintptr_t)vchnl_req; | ||
112 | vchnl_msg->iw_chnl_buf_len = sizeof(*vchnl_msg) + sizeof(struct i40iw_dev_hw_stats) - 1; | ||
113 | vchnl_msg->iw_op_code = I40IW_VCHNL_OP_GET_STATS; | ||
114 | vchnl_msg->iw_op_ver = I40IW_VCHNL_OP_GET_STATS_V0; | ||
115 | ret_code = dev->vchnl_if.vchnl_send(dev, 0, (u8 *)vchnl_msg, vchnl_msg->iw_chnl_buf_len); | ||
116 | if (ret_code) | ||
117 | i40iw_debug(dev, I40IW_DEBUG_VIRT, | ||
118 | "%s: virt channel send failed 0x%x\n", __func__, ret_code); | ||
119 | return ret_code; | ||
120 | } | ||
121 | |||
122 | /** | ||
123 | * vchnl_vf_send_add_hmc_objs_req - Add HMC objects | ||
124 | * @dev: IWARP device pointer | ||
125 | * @vchnl_req: Virtual channel message request pointer | ||
126 | */ | ||
127 | static enum i40iw_status_code vchnl_vf_send_add_hmc_objs_req(struct i40iw_sc_dev *dev, | ||
128 | struct i40iw_virtchnl_req *vchnl_req, | ||
129 | enum i40iw_hmc_rsrc_type rsrc_type, | ||
130 | u32 start_index, | ||
131 | u32 rsrc_count) | ||
132 | { | ||
133 | enum i40iw_status_code ret_code = I40IW_ERR_NOT_READY; | ||
134 | struct i40iw_virtchnl_op_buf *vchnl_msg = vchnl_req->vchnl_msg; | ||
135 | struct i40iw_virtchnl_hmc_obj_range *add_hmc_obj; | ||
136 | |||
137 | if (!dev->vchnl_up) | ||
138 | return ret_code; | ||
139 | |||
140 | add_hmc_obj = (struct i40iw_virtchnl_hmc_obj_range *)vchnl_msg->iw_chnl_buf; | ||
141 | memset(vchnl_msg, 0, sizeof(*vchnl_msg)); | ||
142 | memset(add_hmc_obj, 0, sizeof(*add_hmc_obj)); | ||
143 | vchnl_msg->iw_chnl_op_ctx = (uintptr_t)vchnl_req; | ||
144 | vchnl_msg->iw_chnl_buf_len = sizeof(*vchnl_msg) + sizeof(struct i40iw_virtchnl_hmc_obj_range) - 1; | ||
145 | vchnl_msg->iw_op_code = I40IW_VCHNL_OP_ADD_HMC_OBJ_RANGE; | ||
146 | vchnl_msg->iw_op_ver = I40IW_VCHNL_OP_ADD_HMC_OBJ_RANGE_V0; | ||
147 | add_hmc_obj->obj_type = (u16)rsrc_type; | ||
148 | add_hmc_obj->start_index = start_index; | ||
149 | add_hmc_obj->obj_count = rsrc_count; | ||
150 | ret_code = dev->vchnl_if.vchnl_send(dev, 0, (u8 *)vchnl_msg, vchnl_msg->iw_chnl_buf_len); | ||
151 | if (ret_code) | ||
152 | i40iw_debug(dev, I40IW_DEBUG_VIRT, | ||
153 | "%s: virt channel send failed 0x%x\n", __func__, ret_code); | ||
154 | return ret_code; | ||
155 | } | ||
156 | |||
157 | /** | ||
158 | * vchnl_vf_send_del_hmc_objs_req - del HMC objects | ||
159 | * @dev: IWARP device pointer | ||
160 | * @vchnl_req: Virtual channel message request pointer | ||
161 | * @ rsrc_type - resource type to delete | ||
162 | * @ start_index - starting index for resource | ||
163 | * @ rsrc_count - number of resource type to delete | ||
164 | */ | ||
165 | static enum i40iw_status_code vchnl_vf_send_del_hmc_objs_req(struct i40iw_sc_dev *dev, | ||
166 | struct i40iw_virtchnl_req *vchnl_req, | ||
167 | enum i40iw_hmc_rsrc_type rsrc_type, | ||
168 | u32 start_index, | ||
169 | u32 rsrc_count) | ||
170 | { | ||
171 | enum i40iw_status_code ret_code = I40IW_ERR_NOT_READY; | ||
172 | struct i40iw_virtchnl_op_buf *vchnl_msg = vchnl_req->vchnl_msg; | ||
173 | struct i40iw_virtchnl_hmc_obj_range *add_hmc_obj; | ||
174 | |||
175 | if (!dev->vchnl_up) | ||
176 | return ret_code; | ||
177 | |||
178 | add_hmc_obj = (struct i40iw_virtchnl_hmc_obj_range *)vchnl_msg->iw_chnl_buf; | ||
179 | memset(vchnl_msg, 0, sizeof(*vchnl_msg)); | ||
180 | memset(add_hmc_obj, 0, sizeof(*add_hmc_obj)); | ||
181 | vchnl_msg->iw_chnl_op_ctx = (uintptr_t)vchnl_req; | ||
182 | vchnl_msg->iw_chnl_buf_len = sizeof(*vchnl_msg) + sizeof(struct i40iw_virtchnl_hmc_obj_range) - 1; | ||
183 | vchnl_msg->iw_op_code = I40IW_VCHNL_OP_DEL_HMC_OBJ_RANGE; | ||
184 | vchnl_msg->iw_op_ver = I40IW_VCHNL_OP_DEL_HMC_OBJ_RANGE_V0; | ||
185 | add_hmc_obj->obj_type = (u16)rsrc_type; | ||
186 | add_hmc_obj->start_index = start_index; | ||
187 | add_hmc_obj->obj_count = rsrc_count; | ||
188 | ret_code = dev->vchnl_if.vchnl_send(dev, 0, (u8 *)vchnl_msg, vchnl_msg->iw_chnl_buf_len); | ||
189 | if (ret_code) | ||
190 | i40iw_debug(dev, I40IW_DEBUG_VIRT, | ||
191 | "%s: virt channel send failed 0x%x\n", __func__, ret_code); | ||
192 | return ret_code; | ||
193 | } | ||
194 | |||
195 | /** | ||
196 | * vchnl_pf_send_get_ver_resp - Send channel version to VF | ||
197 | * @dev: IWARP device pointer | ||
198 | * @vf_id: Virtual function ID associated with the message | ||
199 | * @vchnl_msg: Virtual channel message buffer pointer | ||
200 | */ | ||
201 | static void vchnl_pf_send_get_ver_resp(struct i40iw_sc_dev *dev, | ||
202 | u32 vf_id, | ||
203 | struct i40iw_virtchnl_op_buf *vchnl_msg) | ||
204 | { | ||
205 | enum i40iw_status_code ret_code; | ||
206 | u8 resp_buffer[sizeof(struct i40iw_virtchnl_resp_buf) + sizeof(u32) - 1]; | ||
207 | struct i40iw_virtchnl_resp_buf *vchnl_msg_resp = (struct i40iw_virtchnl_resp_buf *)resp_buffer; | ||
208 | |||
209 | memset(resp_buffer, 0, sizeof(*resp_buffer)); | ||
210 | vchnl_msg_resp->iw_chnl_op_ctx = vchnl_msg->iw_chnl_op_ctx; | ||
211 | vchnl_msg_resp->iw_chnl_buf_len = sizeof(resp_buffer); | ||
212 | vchnl_msg_resp->iw_op_ret_code = I40IW_SUCCESS; | ||
213 | *((u32 *)vchnl_msg_resp->iw_chnl_buf) = I40IW_VCHNL_CHNL_VER_V0; | ||
214 | ret_code = dev->vchnl_if.vchnl_send(dev, vf_id, resp_buffer, sizeof(resp_buffer)); | ||
215 | if (ret_code) | ||
216 | i40iw_debug(dev, I40IW_DEBUG_VIRT, | ||
217 | "%s: virt channel send failed 0x%x\n", __func__, ret_code); | ||
218 | } | ||
219 | |||
220 | /** | ||
221 | * vchnl_pf_send_get_hmc_fcn_resp - Send HMC Function to VF | ||
222 | * @dev: IWARP device pointer | ||
223 | * @vf_id: Virtual function ID associated with the message | ||
224 | * @vchnl_msg: Virtual channel message buffer pointer | ||
225 | */ | ||
226 | static void vchnl_pf_send_get_hmc_fcn_resp(struct i40iw_sc_dev *dev, | ||
227 | u32 vf_id, | ||
228 | struct i40iw_virtchnl_op_buf *vchnl_msg, | ||
229 | u16 hmc_fcn) | ||
230 | { | ||
231 | enum i40iw_status_code ret_code; | ||
232 | u8 resp_buffer[sizeof(struct i40iw_virtchnl_resp_buf) + sizeof(u16) - 1]; | ||
233 | struct i40iw_virtchnl_resp_buf *vchnl_msg_resp = (struct i40iw_virtchnl_resp_buf *)resp_buffer; | ||
234 | |||
235 | memset(resp_buffer, 0, sizeof(*resp_buffer)); | ||
236 | vchnl_msg_resp->iw_chnl_op_ctx = vchnl_msg->iw_chnl_op_ctx; | ||
237 | vchnl_msg_resp->iw_chnl_buf_len = sizeof(resp_buffer); | ||
238 | vchnl_msg_resp->iw_op_ret_code = I40IW_SUCCESS; | ||
239 | *((u16 *)vchnl_msg_resp->iw_chnl_buf) = hmc_fcn; | ||
240 | ret_code = dev->vchnl_if.vchnl_send(dev, vf_id, resp_buffer, sizeof(resp_buffer)); | ||
241 | if (ret_code) | ||
242 | i40iw_debug(dev, I40IW_DEBUG_VIRT, | ||
243 | "%s: virt channel send failed 0x%x\n", __func__, ret_code); | ||
244 | } | ||
245 | |||
246 | /** | ||
247 | * vchnl_pf_send_get_pe_stats_resp - Send PE Stats to VF | ||
248 | * @dev: IWARP device pointer | ||
249 | * @vf_id: Virtual function ID associated with the message | ||
250 | * @vchnl_msg: Virtual channel message buffer pointer | ||
251 | * @hw_stats: HW Stats struct | ||
252 | */ | ||
253 | |||
254 | static void vchnl_pf_send_get_pe_stats_resp(struct i40iw_sc_dev *dev, | ||
255 | u32 vf_id, | ||
256 | struct i40iw_virtchnl_op_buf *vchnl_msg, | ||
257 | struct i40iw_dev_hw_stats hw_stats) | ||
258 | { | ||
259 | enum i40iw_status_code ret_code; | ||
260 | u8 resp_buffer[sizeof(struct i40iw_virtchnl_resp_buf) + sizeof(struct i40iw_dev_hw_stats) - 1]; | ||
261 | struct i40iw_virtchnl_resp_buf *vchnl_msg_resp = (struct i40iw_virtchnl_resp_buf *)resp_buffer; | ||
262 | |||
263 | memset(resp_buffer, 0, sizeof(*resp_buffer)); | ||
264 | vchnl_msg_resp->iw_chnl_op_ctx = vchnl_msg->iw_chnl_op_ctx; | ||
265 | vchnl_msg_resp->iw_chnl_buf_len = sizeof(resp_buffer); | ||
266 | vchnl_msg_resp->iw_op_ret_code = I40IW_SUCCESS; | ||
267 | *((struct i40iw_dev_hw_stats *)vchnl_msg_resp->iw_chnl_buf) = hw_stats; | ||
268 | ret_code = dev->vchnl_if.vchnl_send(dev, vf_id, resp_buffer, sizeof(resp_buffer)); | ||
269 | if (ret_code) | ||
270 | i40iw_debug(dev, I40IW_DEBUG_VIRT, | ||
271 | "%s: virt channel send failed 0x%x\n", __func__, ret_code); | ||
272 | } | ||
273 | |||
274 | /** | ||
275 | * vchnl_pf_send_error_resp - Send an error response to VF | ||
276 | * @dev: IWARP device pointer | ||
277 | * @vf_id: Virtual function ID associated with the message | ||
278 | * @vchnl_msg: Virtual channel message buffer pointer | ||
279 | */ | ||
280 | static void vchnl_pf_send_error_resp(struct i40iw_sc_dev *dev, u32 vf_id, | ||
281 | struct i40iw_virtchnl_op_buf *vchnl_msg, | ||
282 | u16 op_ret_code) | ||
283 | { | ||
284 | enum i40iw_status_code ret_code; | ||
285 | u8 resp_buffer[sizeof(struct i40iw_virtchnl_resp_buf)]; | ||
286 | struct i40iw_virtchnl_resp_buf *vchnl_msg_resp = (struct i40iw_virtchnl_resp_buf *)resp_buffer; | ||
287 | |||
288 | memset(resp_buffer, 0, sizeof(resp_buffer)); | ||
289 | vchnl_msg_resp->iw_chnl_op_ctx = vchnl_msg->iw_chnl_op_ctx; | ||
290 | vchnl_msg_resp->iw_chnl_buf_len = sizeof(resp_buffer); | ||
291 | vchnl_msg_resp->iw_op_ret_code = (u16)op_ret_code; | ||
292 | ret_code = dev->vchnl_if.vchnl_send(dev, vf_id, resp_buffer, sizeof(resp_buffer)); | ||
293 | if (ret_code) | ||
294 | i40iw_debug(dev, I40IW_DEBUG_VIRT, | ||
295 | "%s: virt channel send failed 0x%x\n", __func__, ret_code); | ||
296 | } | ||
297 | |||
298 | /** | ||
299 | * pf_cqp_get_hmc_fcn_callback - Callback for Get HMC Fcn | ||
300 | * @cqp_req_param: CQP Request param value | ||
301 | * @not_used: unused CQP callback parameter | ||
302 | */ | ||
303 | static void pf_cqp_get_hmc_fcn_callback(struct i40iw_sc_dev *dev, void *callback_param, | ||
304 | struct i40iw_ccq_cqe_info *cqe_info) | ||
305 | { | ||
306 | struct i40iw_vfdev *vf_dev = callback_param; | ||
307 | struct i40iw_virt_mem vf_dev_mem; | ||
308 | |||
309 | if (cqe_info->error) { | ||
310 | i40iw_debug(dev, I40IW_DEBUG_VIRT, | ||
311 | "CQP Completion Error on Get HMC Function. Maj = 0x%04x, Minor = 0x%04x\n", | ||
312 | cqe_info->maj_err_code, cqe_info->min_err_code); | ||
313 | dev->vf_dev[vf_dev->iw_vf_idx] = NULL; | ||
314 | vchnl_pf_send_error_resp(dev, vf_dev->vf_id, &vf_dev->vf_msg_buffer.vchnl_msg, | ||
315 | (u16)I40IW_ERR_CQP_COMPL_ERROR); | ||
316 | vf_dev_mem.va = vf_dev; | ||
317 | vf_dev_mem.size = sizeof(*vf_dev); | ||
318 | i40iw_free_virt_mem(dev->hw, &vf_dev_mem); | ||
319 | } else { | ||
320 | i40iw_debug(dev, I40IW_DEBUG_VIRT, | ||
321 | "CQP Completion Operation Return information = 0x%08x\n", | ||
322 | cqe_info->op_ret_val); | ||
323 | vf_dev->pmf_index = (u16)cqe_info->op_ret_val; | ||
324 | vf_dev->msg_count--; | ||
325 | vchnl_pf_send_get_hmc_fcn_resp(dev, | ||
326 | vf_dev->vf_id, | ||
327 | &vf_dev->vf_msg_buffer.vchnl_msg, | ||
328 | vf_dev->pmf_index); | ||
329 | } | ||
330 | } | ||
331 | |||
332 | /** | ||
333 | * pf_add_hmc_obj - Callback for Add HMC Object | ||
334 | * @vf_dev: pointer to the VF Device | ||
335 | */ | ||
336 | static void pf_add_hmc_obj_callback(void *work_vf_dev) | ||
337 | { | ||
338 | struct i40iw_vfdev *vf_dev = (struct i40iw_vfdev *)work_vf_dev; | ||
339 | struct i40iw_hmc_info *hmc_info = &vf_dev->hmc_info; | ||
340 | struct i40iw_virtchnl_op_buf *vchnl_msg = &vf_dev->vf_msg_buffer.vchnl_msg; | ||
341 | struct i40iw_hmc_create_obj_info info; | ||
342 | struct i40iw_virtchnl_hmc_obj_range *add_hmc_obj; | ||
343 | enum i40iw_status_code ret_code; | ||
344 | |||
345 | if (!vf_dev->pf_hmc_initialized) { | ||
346 | ret_code = i40iw_pf_init_vfhmc(vf_dev->pf_dev, (u8)vf_dev->pmf_index, NULL); | ||
347 | if (ret_code) | ||
348 | goto add_out; | ||
349 | vf_dev->pf_hmc_initialized = true; | ||
350 | } | ||
351 | |||
352 | add_hmc_obj = (struct i40iw_virtchnl_hmc_obj_range *)vchnl_msg->iw_chnl_buf; | ||
353 | |||
354 | memset(&info, 0, sizeof(info)); | ||
355 | info.hmc_info = hmc_info; | ||
356 | info.is_pf = false; | ||
357 | info.rsrc_type = (u32)add_hmc_obj->obj_type; | ||
358 | info.entry_type = (info.rsrc_type == I40IW_HMC_IW_PBLE) ? I40IW_SD_TYPE_PAGED : I40IW_SD_TYPE_DIRECT; | ||
359 | info.start_idx = add_hmc_obj->start_index; | ||
360 | info.count = add_hmc_obj->obj_count; | ||
361 | i40iw_debug(vf_dev->pf_dev, I40IW_DEBUG_VIRT, | ||
362 | "I40IW_VCHNL_OP_ADD_HMC_OBJ_RANGE. Add %u type %u objects\n", | ||
363 | info.count, info.rsrc_type); | ||
364 | ret_code = i40iw_sc_create_hmc_obj(vf_dev->pf_dev, &info); | ||
365 | if (!ret_code) | ||
366 | vf_dev->hmc_info.hmc_obj[add_hmc_obj->obj_type].cnt = add_hmc_obj->obj_count; | ||
367 | add_out: | ||
368 | vf_dev->msg_count--; | ||
369 | vchnl_pf_send_error_resp(vf_dev->pf_dev, vf_dev->vf_id, vchnl_msg, (u16)ret_code); | ||
370 | } | ||
371 | |||
372 | /** | ||
373 | * pf_del_hmc_obj_callback - Callback for delete HMC Object | ||
374 | * @work_vf_dev: pointer to the VF Device | ||
375 | */ | ||
376 | static void pf_del_hmc_obj_callback(void *work_vf_dev) | ||
377 | { | ||
378 | struct i40iw_vfdev *vf_dev = (struct i40iw_vfdev *)work_vf_dev; | ||
379 | struct i40iw_hmc_info *hmc_info = &vf_dev->hmc_info; | ||
380 | struct i40iw_virtchnl_op_buf *vchnl_msg = &vf_dev->vf_msg_buffer.vchnl_msg; | ||
381 | struct i40iw_hmc_del_obj_info info; | ||
382 | struct i40iw_virtchnl_hmc_obj_range *del_hmc_obj; | ||
383 | enum i40iw_status_code ret_code = I40IW_SUCCESS; | ||
384 | |||
385 | if (!vf_dev->pf_hmc_initialized) | ||
386 | goto del_out; | ||
387 | |||
388 | del_hmc_obj = (struct i40iw_virtchnl_hmc_obj_range *)vchnl_msg->iw_chnl_buf; | ||
389 | |||
390 | memset(&info, 0, sizeof(info)); | ||
391 | info.hmc_info = hmc_info; | ||
392 | info.is_pf = false; | ||
393 | info.rsrc_type = (u32)del_hmc_obj->obj_type; | ||
394 | info.start_idx = del_hmc_obj->start_index; | ||
395 | info.count = del_hmc_obj->obj_count; | ||
396 | i40iw_debug(vf_dev->pf_dev, I40IW_DEBUG_VIRT, | ||
397 | "I40IW_VCHNL_OP_DEL_HMC_OBJ_RANGE. Delete %u type %u objects\n", | ||
398 | info.count, info.rsrc_type); | ||
399 | ret_code = i40iw_sc_del_hmc_obj(vf_dev->pf_dev, &info, false); | ||
400 | del_out: | ||
401 | vf_dev->msg_count--; | ||
402 | vchnl_pf_send_error_resp(vf_dev->pf_dev, vf_dev->vf_id, vchnl_msg, (u16)ret_code); | ||
403 | } | ||
404 | |||
405 | /** | ||
406 | * i40iw_vchnl_recv_pf - Receive PF virtual channel messages | ||
407 | * @dev: IWARP device pointer | ||
408 | * @vf_id: Virtual function ID associated with the message | ||
409 | * @msg: Virtual channel message buffer pointer | ||
410 | * @len: Length of the virtual channels message | ||
411 | */ | ||
412 | enum i40iw_status_code i40iw_vchnl_recv_pf(struct i40iw_sc_dev *dev, | ||
413 | u32 vf_id, | ||
414 | u8 *msg, | ||
415 | u16 len) | ||
416 | { | ||
417 | struct i40iw_virtchnl_op_buf *vchnl_msg = (struct i40iw_virtchnl_op_buf *)msg; | ||
418 | struct i40iw_vfdev *vf_dev = NULL; | ||
419 | struct i40iw_hmc_fcn_info hmc_fcn_info; | ||
420 | u16 iw_vf_idx; | ||
421 | u16 first_avail_iw_vf = I40IW_MAX_PE_ENABLED_VF_COUNT; | ||
422 | struct i40iw_virt_mem vf_dev_mem; | ||
423 | struct i40iw_virtchnl_work_info work_info; | ||
424 | struct i40iw_dev_pestat *devstat; | ||
425 | enum i40iw_status_code ret_code; | ||
426 | unsigned long flags; | ||
427 | |||
428 | if (!dev || !msg || !len) | ||
429 | return I40IW_ERR_PARAM; | ||
430 | |||
431 | if (!dev->vchnl_up) | ||
432 | return I40IW_ERR_NOT_READY; | ||
433 | if (vchnl_msg->iw_op_code == I40IW_VCHNL_OP_GET_VER) { | ||
434 | if (vchnl_msg->iw_op_ver != I40IW_VCHNL_OP_GET_VER_V0) | ||
435 | vchnl_pf_send_get_ver_resp(dev, vf_id, vchnl_msg); | ||
436 | else | ||
437 | vchnl_pf_send_get_ver_resp(dev, vf_id, vchnl_msg); | ||
438 | return I40IW_SUCCESS; | ||
439 | } | ||
440 | for (iw_vf_idx = 0; iw_vf_idx < I40IW_MAX_PE_ENABLED_VF_COUNT; | ||
441 | iw_vf_idx++) { | ||
442 | if (!dev->vf_dev[iw_vf_idx]) { | ||
443 | if (first_avail_iw_vf == | ||
444 | I40IW_MAX_PE_ENABLED_VF_COUNT) | ||
445 | first_avail_iw_vf = iw_vf_idx; | ||
446 | continue; | ||
447 | } | ||
448 | if (dev->vf_dev[iw_vf_idx]->vf_id == vf_id) { | ||
449 | vf_dev = dev->vf_dev[iw_vf_idx]; | ||
450 | break; | ||
451 | } | ||
452 | } | ||
453 | if (vf_dev) { | ||
454 | if (!vf_dev->msg_count) { | ||
455 | vf_dev->msg_count++; | ||
456 | } else { | ||
457 | i40iw_debug(dev, I40IW_DEBUG_VIRT, | ||
458 | "VF%u already has a channel message in progress.\n", | ||
459 | vf_id); | ||
460 | return I40IW_SUCCESS; | ||
461 | } | ||
462 | } | ||
463 | switch (vchnl_msg->iw_op_code) { | ||
464 | case I40IW_VCHNL_OP_GET_HMC_FCN: | ||
465 | if (!vf_dev && | ||
466 | (first_avail_iw_vf != I40IW_MAX_PE_ENABLED_VF_COUNT)) { | ||
467 | ret_code = i40iw_allocate_virt_mem(dev->hw, &vf_dev_mem, sizeof(struct i40iw_vfdev) + | ||
468 | (sizeof(struct i40iw_hmc_obj_info) * I40IW_HMC_IW_MAX)); | ||
469 | if (!ret_code) { | ||
470 | vf_dev = vf_dev_mem.va; | ||
471 | vf_dev->stats_initialized = false; | ||
472 | vf_dev->pf_dev = dev; | ||
473 | vf_dev->msg_count = 1; | ||
474 | vf_dev->vf_id = vf_id; | ||
475 | vf_dev->iw_vf_idx = first_avail_iw_vf; | ||
476 | vf_dev->pf_hmc_initialized = false; | ||
477 | vf_dev->hmc_info.hmc_obj = (struct i40iw_hmc_obj_info *)(&vf_dev[1]); | ||
478 | i40iw_debug(dev, I40IW_DEBUG_VIRT, | ||
479 | "vf_dev %p, hmc_info %p, hmc_obj %p\n", | ||
480 | vf_dev, &vf_dev->hmc_info, vf_dev->hmc_info.hmc_obj); | ||
481 | dev->vf_dev[first_avail_iw_vf] = vf_dev; | ||
482 | iw_vf_idx = first_avail_iw_vf; | ||
483 | } else { | ||
484 | i40iw_debug(dev, I40IW_DEBUG_VIRT, | ||
485 | "VF%u Unable to allocate a VF device structure.\n", | ||
486 | vf_id); | ||
487 | vchnl_pf_send_error_resp(dev, vf_id, vchnl_msg, (u16)I40IW_ERR_NO_MEMORY); | ||
488 | return I40IW_SUCCESS; | ||
489 | } | ||
490 | memcpy(&vf_dev->vf_msg_buffer.vchnl_msg, vchnl_msg, len); | ||
491 | hmc_fcn_info.callback_fcn = pf_cqp_get_hmc_fcn_callback; | ||
492 | hmc_fcn_info.vf_id = vf_id; | ||
493 | hmc_fcn_info.iw_vf_idx = vf_dev->iw_vf_idx; | ||
494 | hmc_fcn_info.cqp_callback_param = vf_dev; | ||
495 | hmc_fcn_info.free_fcn = false; | ||
496 | ret_code = i40iw_cqp_manage_hmc_fcn_cmd(dev, &hmc_fcn_info); | ||
497 | if (ret_code) | ||
498 | i40iw_debug(dev, I40IW_DEBUG_VIRT, | ||
499 | "VF%u error CQP HMC Function operation.\n", | ||
500 | vf_id); | ||
501 | ret_code = i40iw_device_init_pestat(&vf_dev->dev_pestat); | ||
502 | if (ret_code) | ||
503 | i40iw_debug(dev, I40IW_DEBUG_VIRT, | ||
504 | "VF%u - i40iw_device_init_pestat failed\n", | ||
505 | vf_id); | ||
506 | vf_dev->dev_pestat.ops.iw_hw_stat_init(&vf_dev->dev_pestat, | ||
507 | (u8)vf_dev->pmf_index, | ||
508 | dev->hw, false); | ||
509 | vf_dev->stats_initialized = true; | ||
510 | } else { | ||
511 | if (vf_dev) { | ||
512 | vf_dev->msg_count--; | ||
513 | vchnl_pf_send_get_hmc_fcn_resp(dev, vf_id, vchnl_msg, vf_dev->pmf_index); | ||
514 | } else { | ||
515 | vchnl_pf_send_error_resp(dev, vf_id, vchnl_msg, | ||
516 | (u16)I40IW_ERR_NO_MEMORY); | ||
517 | } | ||
518 | } | ||
519 | break; | ||
520 | case I40IW_VCHNL_OP_ADD_HMC_OBJ_RANGE: | ||
521 | if (!vf_dev) | ||
522 | return I40IW_ERR_BAD_PTR; | ||
523 | work_info.worker_vf_dev = vf_dev; | ||
524 | work_info.callback_fcn = pf_add_hmc_obj_callback; | ||
525 | memcpy(&vf_dev->vf_msg_buffer.vchnl_msg, vchnl_msg, len); | ||
526 | i40iw_cqp_spawn_worker(dev, &work_info, vf_dev->iw_vf_idx); | ||
527 | break; | ||
528 | case I40IW_VCHNL_OP_DEL_HMC_OBJ_RANGE: | ||
529 | if (!vf_dev) | ||
530 | return I40IW_ERR_BAD_PTR; | ||
531 | work_info.worker_vf_dev = vf_dev; | ||
532 | work_info.callback_fcn = pf_del_hmc_obj_callback; | ||
533 | memcpy(&vf_dev->vf_msg_buffer.vchnl_msg, vchnl_msg, len); | ||
534 | i40iw_cqp_spawn_worker(dev, &work_info, vf_dev->iw_vf_idx); | ||
535 | break; | ||
536 | case I40IW_VCHNL_OP_GET_STATS: | ||
537 | if (!vf_dev) | ||
538 | return I40IW_ERR_BAD_PTR; | ||
539 | devstat = &vf_dev->dev_pestat; | ||
540 | spin_lock_irqsave(&dev->dev_pestat.stats_lock, flags); | ||
541 | devstat->ops.iw_hw_stat_read_all(devstat, &devstat->hw_stats); | ||
542 | spin_unlock_irqrestore(&dev->dev_pestat.stats_lock, flags); | ||
543 | vf_dev->msg_count--; | ||
544 | vchnl_pf_send_get_pe_stats_resp(dev, vf_id, vchnl_msg, devstat->hw_stats); | ||
545 | break; | ||
546 | default: | ||
547 | i40iw_debug(dev, I40IW_DEBUG_VIRT, | ||
548 | "40iw_vchnl_recv_pf: Invalid OpCode 0x%x\n", | ||
549 | vchnl_msg->iw_op_code); | ||
550 | vchnl_pf_send_error_resp(dev, vf_id, | ||
551 | vchnl_msg, (u16)I40IW_ERR_NOT_IMPLEMENTED); | ||
552 | } | ||
553 | return I40IW_SUCCESS; | ||
554 | } | ||
555 | |||
556 | /** | ||
557 | * i40iw_vchnl_recv_vf - Receive VF virtual channel messages | ||
558 | * @dev: IWARP device pointer | ||
559 | * @vf_id: Virtual function ID associated with the message | ||
560 | * @msg: Virtual channel message buffer pointer | ||
561 | * @len: Length of the virtual channels message | ||
562 | */ | ||
563 | enum i40iw_status_code i40iw_vchnl_recv_vf(struct i40iw_sc_dev *dev, | ||
564 | u32 vf_id, | ||
565 | u8 *msg, | ||
566 | u16 len) | ||
567 | { | ||
568 | struct i40iw_virtchnl_resp_buf *vchnl_msg_resp = (struct i40iw_virtchnl_resp_buf *)msg; | ||
569 | struct i40iw_virtchnl_req *vchnl_req; | ||
570 | |||
571 | vchnl_req = (struct i40iw_virtchnl_req *)(uintptr_t)vchnl_msg_resp->iw_chnl_op_ctx; | ||
572 | vchnl_req->ret_code = (enum i40iw_status_code)vchnl_msg_resp->iw_op_ret_code; | ||
573 | if (len == (sizeof(*vchnl_msg_resp) + vchnl_req->parm_len - 1)) { | ||
574 | if (vchnl_req->parm_len && vchnl_req->parm) | ||
575 | memcpy(vchnl_req->parm, vchnl_msg_resp->iw_chnl_buf, vchnl_req->parm_len); | ||
576 | i40iw_debug(dev, I40IW_DEBUG_VIRT, | ||
577 | "%s: Got response, data size %u\n", __func__, | ||
578 | vchnl_req->parm_len); | ||
579 | } else { | ||
580 | i40iw_debug(dev, I40IW_DEBUG_VIRT, | ||
581 | "%s: error length on response, Got %u, expected %u\n", __func__, | ||
582 | len, (u32)(sizeof(*vchnl_msg_resp) + vchnl_req->parm_len - 1)); | ||
583 | } | ||
584 | |||
585 | return I40IW_SUCCESS; | ||
586 | } | ||
587 | |||
588 | /** | ||
589 | * i40iw_vchnl_vf_get_ver - Request Channel version | ||
590 | * @dev: IWARP device pointer | ||
591 | * @vchnl_ver: Virtual channel message version pointer | ||
592 | */ | ||
593 | enum i40iw_status_code i40iw_vchnl_vf_get_ver(struct i40iw_sc_dev *dev, | ||
594 | u32 *vchnl_ver) | ||
595 | { | ||
596 | struct i40iw_virtchnl_req vchnl_req; | ||
597 | enum i40iw_status_code ret_code; | ||
598 | |||
599 | memset(&vchnl_req, 0, sizeof(vchnl_req)); | ||
600 | vchnl_req.dev = dev; | ||
601 | vchnl_req.parm = vchnl_ver; | ||
602 | vchnl_req.parm_len = sizeof(*vchnl_ver); | ||
603 | vchnl_req.vchnl_msg = &dev->vchnl_vf_msg_buf.vchnl_msg; | ||
604 | ret_code = vchnl_vf_send_get_ver_req(dev, &vchnl_req); | ||
605 | if (!ret_code) { | ||
606 | ret_code = i40iw_vf_wait_vchnl_resp(dev); | ||
607 | if (!ret_code) | ||
608 | ret_code = vchnl_req.ret_code; | ||
609 | else | ||
610 | dev->vchnl_up = false; | ||
611 | } else { | ||
612 | i40iw_debug(dev, I40IW_DEBUG_VIRT, | ||
613 | "%s Send message failed 0x%0x\n", __func__, ret_code); | ||
614 | } | ||
615 | return ret_code; | ||
616 | } | ||
617 | |||
618 | /** | ||
619 | * i40iw_vchnl_vf_get_hmc_fcn - Request HMC Function | ||
620 | * @dev: IWARP device pointer | ||
621 | * @hmc_fcn: HMC function index pointer | ||
622 | */ | ||
623 | enum i40iw_status_code i40iw_vchnl_vf_get_hmc_fcn(struct i40iw_sc_dev *dev, | ||
624 | u16 *hmc_fcn) | ||
625 | { | ||
626 | struct i40iw_virtchnl_req vchnl_req; | ||
627 | enum i40iw_status_code ret_code; | ||
628 | |||
629 | memset(&vchnl_req, 0, sizeof(vchnl_req)); | ||
630 | vchnl_req.dev = dev; | ||
631 | vchnl_req.parm = hmc_fcn; | ||
632 | vchnl_req.parm_len = sizeof(*hmc_fcn); | ||
633 | vchnl_req.vchnl_msg = &dev->vchnl_vf_msg_buf.vchnl_msg; | ||
634 | ret_code = vchnl_vf_send_get_hmc_fcn_req(dev, &vchnl_req); | ||
635 | if (!ret_code) { | ||
636 | ret_code = i40iw_vf_wait_vchnl_resp(dev); | ||
637 | if (!ret_code) | ||
638 | ret_code = vchnl_req.ret_code; | ||
639 | else | ||
640 | dev->vchnl_up = false; | ||
641 | } else { | ||
642 | i40iw_debug(dev, I40IW_DEBUG_VIRT, | ||
643 | "%s Send message failed 0x%0x\n", __func__, ret_code); | ||
644 | } | ||
645 | return ret_code; | ||
646 | } | ||
647 | |||
648 | /** | ||
649 | * i40iw_vchnl_vf_add_hmc_objs - Add HMC Object | ||
650 | * @dev: IWARP device pointer | ||
651 | * @rsrc_type: HMC Resource type | ||
652 | * @start_index: Starting index of the objects to be added | ||
653 | * @rsrc_count: Number of resources to be added | ||
654 | */ | ||
655 | enum i40iw_status_code i40iw_vchnl_vf_add_hmc_objs(struct i40iw_sc_dev *dev, | ||
656 | enum i40iw_hmc_rsrc_type rsrc_type, | ||
657 | u32 start_index, | ||
658 | u32 rsrc_count) | ||
659 | { | ||
660 | struct i40iw_virtchnl_req vchnl_req; | ||
661 | enum i40iw_status_code ret_code; | ||
662 | |||
663 | memset(&vchnl_req, 0, sizeof(vchnl_req)); | ||
664 | vchnl_req.dev = dev; | ||
665 | vchnl_req.vchnl_msg = &dev->vchnl_vf_msg_buf.vchnl_msg; | ||
666 | ret_code = vchnl_vf_send_add_hmc_objs_req(dev, | ||
667 | &vchnl_req, | ||
668 | rsrc_type, | ||
669 | start_index, | ||
670 | rsrc_count); | ||
671 | if (!ret_code) { | ||
672 | ret_code = i40iw_vf_wait_vchnl_resp(dev); | ||
673 | if (!ret_code) | ||
674 | ret_code = vchnl_req.ret_code; | ||
675 | else | ||
676 | dev->vchnl_up = false; | ||
677 | } else { | ||
678 | i40iw_debug(dev, I40IW_DEBUG_VIRT, | ||
679 | "%s Send message failed 0x%0x\n", __func__, ret_code); | ||
680 | } | ||
681 | return ret_code; | ||
682 | } | ||
683 | |||
684 | /** | ||
685 | * i40iw_vchnl_vf_del_hmc_obj - del HMC obj | ||
686 | * @dev: IWARP device pointer | ||
687 | * @rsrc_type: HMC Resource type | ||
688 | * @start_index: Starting index of the object to delete | ||
689 | * @rsrc_count: Number of resources to be delete | ||
690 | */ | ||
691 | enum i40iw_status_code i40iw_vchnl_vf_del_hmc_obj(struct i40iw_sc_dev *dev, | ||
692 | enum i40iw_hmc_rsrc_type rsrc_type, | ||
693 | u32 start_index, | ||
694 | u32 rsrc_count) | ||
695 | { | ||
696 | struct i40iw_virtchnl_req vchnl_req; | ||
697 | enum i40iw_status_code ret_code; | ||
698 | |||
699 | memset(&vchnl_req, 0, sizeof(vchnl_req)); | ||
700 | vchnl_req.dev = dev; | ||
701 | vchnl_req.vchnl_msg = &dev->vchnl_vf_msg_buf.vchnl_msg; | ||
702 | ret_code = vchnl_vf_send_del_hmc_objs_req(dev, | ||
703 | &vchnl_req, | ||
704 | rsrc_type, | ||
705 | start_index, | ||
706 | rsrc_count); | ||
707 | if (!ret_code) { | ||
708 | ret_code = i40iw_vf_wait_vchnl_resp(dev); | ||
709 | if (!ret_code) | ||
710 | ret_code = vchnl_req.ret_code; | ||
711 | else | ||
712 | dev->vchnl_up = false; | ||
713 | } else { | ||
714 | i40iw_debug(dev, I40IW_DEBUG_VIRT, | ||
715 | "%s Send message failed 0x%0x\n", __func__, ret_code); | ||
716 | } | ||
717 | return ret_code; | ||
718 | } | ||
719 | |||
720 | /** | ||
721 | * i40iw_vchnl_vf_get_pe_stats - Get PE stats | ||
722 | * @dev: IWARP device pointer | ||
723 | * @hw_stats: HW stats struct | ||
724 | */ | ||
725 | enum i40iw_status_code i40iw_vchnl_vf_get_pe_stats(struct i40iw_sc_dev *dev, | ||
726 | struct i40iw_dev_hw_stats *hw_stats) | ||
727 | { | ||
728 | struct i40iw_virtchnl_req vchnl_req; | ||
729 | enum i40iw_status_code ret_code; | ||
730 | |||
731 | memset(&vchnl_req, 0, sizeof(vchnl_req)); | ||
732 | vchnl_req.dev = dev; | ||
733 | vchnl_req.parm = hw_stats; | ||
734 | vchnl_req.parm_len = sizeof(*hw_stats); | ||
735 | vchnl_req.vchnl_msg = &dev->vchnl_vf_msg_buf.vchnl_msg; | ||
736 | ret_code = vchnl_vf_send_get_pe_stats_req(dev, &vchnl_req); | ||
737 | if (!ret_code) { | ||
738 | ret_code = i40iw_vf_wait_vchnl_resp(dev); | ||
739 | if (!ret_code) | ||
740 | ret_code = vchnl_req.ret_code; | ||
741 | else | ||
742 | dev->vchnl_up = false; | ||
743 | } else { | ||
744 | i40iw_debug(dev, I40IW_DEBUG_VIRT, | ||
745 | "%s Send message failed 0x%0x\n", __func__, ret_code); | ||
746 | } | ||
747 | return ret_code; | ||
748 | } | ||
diff --git a/drivers/infiniband/hw/i40iw/i40iw_virtchnl.h b/drivers/infiniband/hw/i40iw/i40iw_virtchnl.h new file mode 100644 index 000000000000..24886ef08293 --- /dev/null +++ b/drivers/infiniband/hw/i40iw/i40iw_virtchnl.h | |||
@@ -0,0 +1,124 @@ | |||
1 | /******************************************************************************* | ||
2 | * | ||
3 | * Copyright (c) 2015-2016 Intel Corporation. All rights reserved. | ||
4 | * | ||
5 | * This software is available to you under a choice of one of two | ||
6 | * licenses. You may choose to be licensed under the terms of the GNU | ||
7 | * General Public License (GPL) Version 2, available from the file | ||
8 | * COPYING in the main directory of this source tree, or the | ||
9 | * OpenFabrics.org BSD license below: | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or | ||
12 | * without modification, are permitted provided that the following | ||
13 | * conditions are met: | ||
14 | * | ||
15 | * - Redistributions of source code must retain the above | ||
16 | * copyright notice, this list of conditions and the following | ||
17 | * disclaimer. | ||
18 | * | ||
19 | * - Redistributions in binary form must reproduce the above | ||
20 | * copyright notice, this list of conditions and the following | ||
21 | * disclaimer in the documentation and/or other materials | ||
22 | * provided with the distribution. | ||
23 | * | ||
24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
25 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
26 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
27 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
28 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
29 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
30 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
31 | * SOFTWARE. | ||
32 | * | ||
33 | *******************************************************************************/ | ||
34 | |||
35 | #ifndef I40IW_VIRTCHNL_H | ||
36 | #define I40IW_VIRTCHNL_H | ||
37 | |||
38 | #include "i40iw_hmc.h" | ||
39 | |||
40 | #pragma pack(push, 1) | ||
41 | |||
42 | struct i40iw_virtchnl_op_buf { | ||
43 | u16 iw_op_code; | ||
44 | u16 iw_op_ver; | ||
45 | u16 iw_chnl_buf_len; | ||
46 | u16 rsvd; | ||
47 | u64 iw_chnl_op_ctx; | ||
48 | /* Member alignment MUST be maintained above this location */ | ||
49 | u8 iw_chnl_buf[1]; | ||
50 | }; | ||
51 | |||
52 | struct i40iw_virtchnl_resp_buf { | ||
53 | u64 iw_chnl_op_ctx; | ||
54 | u16 iw_chnl_buf_len; | ||
55 | s16 iw_op_ret_code; | ||
56 | /* Member alignment MUST be maintained above this location */ | ||
57 | u16 rsvd[2]; | ||
58 | u8 iw_chnl_buf[1]; | ||
59 | }; | ||
60 | |||
61 | enum i40iw_virtchnl_ops { | ||
62 | I40IW_VCHNL_OP_GET_VER = 0, | ||
63 | I40IW_VCHNL_OP_GET_HMC_FCN, | ||
64 | I40IW_VCHNL_OP_ADD_HMC_OBJ_RANGE, | ||
65 | I40IW_VCHNL_OP_DEL_HMC_OBJ_RANGE, | ||
66 | I40IW_VCHNL_OP_GET_STATS | ||
67 | }; | ||
68 | |||
69 | #define I40IW_VCHNL_OP_GET_VER_V0 0 | ||
70 | #define I40IW_VCHNL_OP_GET_HMC_FCN_V0 0 | ||
71 | #define I40IW_VCHNL_OP_ADD_HMC_OBJ_RANGE_V0 0 | ||
72 | #define I40IW_VCHNL_OP_DEL_HMC_OBJ_RANGE_V0 0 | ||
73 | #define I40IW_VCHNL_OP_GET_STATS_V0 0 | ||
74 | #define I40IW_VCHNL_CHNL_VER_V0 0 | ||
75 | |||
76 | struct i40iw_dev_hw_stats; | ||
77 | |||
78 | struct i40iw_virtchnl_hmc_obj_range { | ||
79 | u16 obj_type; | ||
80 | u16 rsvd; | ||
81 | u32 start_index; | ||
82 | u32 obj_count; | ||
83 | }; | ||
84 | |||
85 | enum i40iw_status_code i40iw_vchnl_recv_pf(struct i40iw_sc_dev *dev, | ||
86 | u32 vf_id, | ||
87 | u8 *msg, | ||
88 | u16 len); | ||
89 | |||
90 | enum i40iw_status_code i40iw_vchnl_recv_vf(struct i40iw_sc_dev *dev, | ||
91 | u32 vf_id, | ||
92 | u8 *msg, | ||
93 | u16 len); | ||
94 | |||
95 | struct i40iw_virtchnl_req { | ||
96 | struct i40iw_sc_dev *dev; | ||
97 | struct i40iw_virtchnl_op_buf *vchnl_msg; | ||
98 | void *parm; | ||
99 | u32 vf_id; | ||
100 | u16 parm_len; | ||
101 | s16 ret_code; | ||
102 | }; | ||
103 | |||
104 | #pragma pack(pop) | ||
105 | |||
106 | enum i40iw_status_code i40iw_vchnl_vf_get_ver(struct i40iw_sc_dev *dev, | ||
107 | u32 *vchnl_ver); | ||
108 | |||
109 | enum i40iw_status_code i40iw_vchnl_vf_get_hmc_fcn(struct i40iw_sc_dev *dev, | ||
110 | u16 *hmc_fcn); | ||
111 | |||
112 | enum i40iw_status_code i40iw_vchnl_vf_add_hmc_objs(struct i40iw_sc_dev *dev, | ||
113 | enum i40iw_hmc_rsrc_type rsrc_type, | ||
114 | u32 start_index, | ||
115 | u32 rsrc_count); | ||
116 | |||
117 | enum i40iw_status_code i40iw_vchnl_vf_del_hmc_obj(struct i40iw_sc_dev *dev, | ||
118 | enum i40iw_hmc_rsrc_type rsrc_type, | ||
119 | u32 start_index, | ||
120 | u32 rsrc_count); | ||
121 | |||
122 | enum i40iw_status_code i40iw_vchnl_vf_get_pe_stats(struct i40iw_sc_dev *dev, | ||
123 | struct i40iw_dev_hw_stats *hw_stats); | ||
124 | #endif | ||