diff options
Diffstat (limited to 'drivers/scsi/be2iscsi/be_mgmt.c')
-rw-r--r-- | drivers/scsi/be2iscsi/be_mgmt.c | 139 |
1 files changed, 80 insertions, 59 deletions
diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c index 79c2bd525a84..317bcd042ced 100644 --- a/drivers/scsi/be2iscsi/be_mgmt.c +++ b/drivers/scsi/be2iscsi/be_mgmt.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /** | 1 | /** |
2 | * Copyright (C) 2005 - 2009 ServerEngines | 2 | * Copyright (C) 2005 - 2010 ServerEngines |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or | 5 | * This program is free software; you can redistribute it and/or |
@@ -48,6 +48,14 @@ unsigned char mgmt_get_fw_config(struct be_ctrl_info *ctrl, | |||
48 | pfw_cfg->ulp[0].sq_base; | 48 | pfw_cfg->ulp[0].sq_base; |
49 | phba->fw_config.iscsi_cid_count = | 49 | phba->fw_config.iscsi_cid_count = |
50 | pfw_cfg->ulp[0].sq_count; | 50 | pfw_cfg->ulp[0].sq_count; |
51 | if (phba->fw_config.iscsi_cid_count > (BE2_MAX_SESSIONS / 2)) { | ||
52 | SE_DEBUG(DBG_LVL_8, | ||
53 | "FW reported MAX CXNS as %d \t" | ||
54 | "Max Supported = %d.\n", | ||
55 | phba->fw_config.iscsi_cid_count, | ||
56 | BE2_MAX_SESSIONS); | ||
57 | phba->fw_config.iscsi_cid_count = BE2_MAX_SESSIONS / 2; | ||
58 | } | ||
51 | } else { | 59 | } else { |
52 | shost_printk(KERN_WARNING, phba->shost, | 60 | shost_printk(KERN_WARNING, phba->shost, |
53 | "Failed in mgmt_get_fw_config \n"); | 61 | "Failed in mgmt_get_fw_config \n"); |
@@ -77,6 +85,7 @@ unsigned char mgmt_check_supported_fw(struct be_ctrl_info *ctrl, | |||
77 | } | 85 | } |
78 | nonemb_cmd.size = sizeof(struct be_mgmt_controller_attributes); | 86 | nonemb_cmd.size = sizeof(struct be_mgmt_controller_attributes); |
79 | req = nonemb_cmd.va; | 87 | req = nonemb_cmd.va; |
88 | memset(req, 0, sizeof(*req)); | ||
80 | spin_lock(&ctrl->mbox_lock); | 89 | spin_lock(&ctrl->mbox_lock); |
81 | memset(wrb, 0, sizeof(*wrb)); | 90 | memset(wrb, 0, sizeof(*wrb)); |
82 | be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1); | 91 | be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1); |
@@ -140,10 +149,17 @@ unsigned char mgmt_invalidate_icds(struct beiscsi_hba *phba, | |||
140 | { | 149 | { |
141 | struct be_dma_mem nonemb_cmd; | 150 | struct be_dma_mem nonemb_cmd; |
142 | struct be_ctrl_info *ctrl = &phba->ctrl; | 151 | struct be_ctrl_info *ctrl = &phba->ctrl; |
143 | struct be_mcc_wrb *wrb = wrb_from_mccq(phba); | 152 | struct be_mcc_wrb *wrb; |
144 | struct be_sge *sge = nonembedded_sgl(wrb); | 153 | struct be_sge *sge; |
145 | struct invalidate_commands_params_in *req; | 154 | struct invalidate_commands_params_in *req; |
146 | int status = 0; | 155 | unsigned int tag = 0; |
156 | |||
157 | spin_lock(&ctrl->mbox_lock); | ||
158 | tag = alloc_mcc_tag(phba); | ||
159 | if (!tag) { | ||
160 | spin_unlock(&ctrl->mbox_lock); | ||
161 | return tag; | ||
162 | } | ||
147 | 163 | ||
148 | nonemb_cmd.va = pci_alloc_consistent(ctrl->pdev, | 164 | nonemb_cmd.va = pci_alloc_consistent(ctrl->pdev, |
149 | sizeof(struct invalidate_commands_params_in), | 165 | sizeof(struct invalidate_commands_params_in), |
@@ -156,8 +172,10 @@ unsigned char mgmt_invalidate_icds(struct beiscsi_hba *phba, | |||
156 | } | 172 | } |
157 | nonemb_cmd.size = sizeof(struct invalidate_commands_params_in); | 173 | nonemb_cmd.size = sizeof(struct invalidate_commands_params_in); |
158 | req = nonemb_cmd.va; | 174 | req = nonemb_cmd.va; |
159 | spin_lock(&ctrl->mbox_lock); | 175 | memset(req, 0, sizeof(*req)); |
160 | memset(wrb, 0, sizeof(*wrb)); | 176 | wrb = wrb_from_mccq(phba); |
177 | sge = nonembedded_sgl(wrb); | ||
178 | wrb->tag0 |= tag; | ||
161 | 179 | ||
162 | be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1); | 180 | be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1); |
163 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI, | 181 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI, |
@@ -172,14 +190,12 @@ unsigned char mgmt_invalidate_icds(struct beiscsi_hba *phba, | |||
172 | sge->pa_lo = cpu_to_le32(nonemb_cmd.dma & 0xFFFFFFFF); | 190 | sge->pa_lo = cpu_to_le32(nonemb_cmd.dma & 0xFFFFFFFF); |
173 | sge->len = cpu_to_le32(nonemb_cmd.size); | 191 | sge->len = cpu_to_le32(nonemb_cmd.size); |
174 | 192 | ||
175 | status = be_mcc_notify_wait(phba); | 193 | be_mcc_notify(phba); |
176 | if (status) | ||
177 | SE_DEBUG(DBG_LVL_1, "ICDS Invalidation Failed\n"); | ||
178 | spin_unlock(&ctrl->mbox_lock); | 194 | spin_unlock(&ctrl->mbox_lock); |
179 | if (nonemb_cmd.va) | 195 | if (nonemb_cmd.va) |
180 | pci_free_consistent(ctrl->pdev, nonemb_cmd.size, | 196 | pci_free_consistent(ctrl->pdev, nonemb_cmd.size, |
181 | nonemb_cmd.va, nonemb_cmd.dma); | 197 | nonemb_cmd.va, nonemb_cmd.dma); |
182 | return status; | 198 | return tag; |
183 | } | 199 | } |
184 | 200 | ||
185 | unsigned char mgmt_invalidate_connection(struct beiscsi_hba *phba, | 201 | unsigned char mgmt_invalidate_connection(struct beiscsi_hba *phba, |
@@ -189,13 +205,19 @@ unsigned char mgmt_invalidate_connection(struct beiscsi_hba *phba, | |||
189 | unsigned short savecfg_flag) | 205 | unsigned short savecfg_flag) |
190 | { | 206 | { |
191 | struct be_ctrl_info *ctrl = &phba->ctrl; | 207 | struct be_ctrl_info *ctrl = &phba->ctrl; |
192 | struct be_mcc_wrb *wrb = wrb_from_mccq(phba); | 208 | struct be_mcc_wrb *wrb; |
193 | struct iscsi_invalidate_connection_params_in *req = | 209 | struct iscsi_invalidate_connection_params_in *req; |
194 | embedded_payload(wrb); | 210 | unsigned int tag = 0; |
195 | int status = 0; | ||
196 | 211 | ||
197 | spin_lock(&ctrl->mbox_lock); | 212 | spin_lock(&ctrl->mbox_lock); |
198 | memset(wrb, 0, sizeof(*wrb)); | 213 | tag = alloc_mcc_tag(phba); |
214 | if (!tag) { | ||
215 | spin_unlock(&ctrl->mbox_lock); | ||
216 | return tag; | ||
217 | } | ||
218 | wrb = wrb_from_mccq(phba); | ||
219 | wrb->tag0 |= tag; | ||
220 | req = embedded_payload(wrb); | ||
199 | 221 | ||
200 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 222 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
201 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI, | 223 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI, |
@@ -208,35 +230,37 @@ unsigned char mgmt_invalidate_connection(struct beiscsi_hba *phba, | |||
208 | else | 230 | else |
209 | req->cleanup_type = CMD_ISCSI_CONNECTION_INVALIDATE; | 231 | req->cleanup_type = CMD_ISCSI_CONNECTION_INVALIDATE; |
210 | req->save_cfg = savecfg_flag; | 232 | req->save_cfg = savecfg_flag; |
211 | status = be_mcc_notify_wait(phba); | 233 | be_mcc_notify(phba); |
212 | if (status) | ||
213 | SE_DEBUG(DBG_LVL_1, "Invalidation Failed\n"); | ||
214 | |||
215 | spin_unlock(&ctrl->mbox_lock); | 234 | spin_unlock(&ctrl->mbox_lock); |
216 | return status; | 235 | return tag; |
217 | } | 236 | } |
218 | 237 | ||
219 | unsigned char mgmt_upload_connection(struct beiscsi_hba *phba, | 238 | unsigned char mgmt_upload_connection(struct beiscsi_hba *phba, |
220 | unsigned short cid, unsigned int upload_flag) | 239 | unsigned short cid, unsigned int upload_flag) |
221 | { | 240 | { |
222 | struct be_ctrl_info *ctrl = &phba->ctrl; | 241 | struct be_ctrl_info *ctrl = &phba->ctrl; |
223 | struct be_mcc_wrb *wrb = wrb_from_mccq(phba); | 242 | struct be_mcc_wrb *wrb; |
224 | struct tcp_upload_params_in *req = embedded_payload(wrb); | 243 | struct tcp_upload_params_in *req; |
225 | int status = 0; | 244 | unsigned int tag = 0; |
226 | 245 | ||
227 | spin_lock(&ctrl->mbox_lock); | 246 | spin_lock(&ctrl->mbox_lock); |
228 | memset(wrb, 0, sizeof(*wrb)); | 247 | tag = alloc_mcc_tag(phba); |
248 | if (!tag) { | ||
249 | spin_unlock(&ctrl->mbox_lock); | ||
250 | return tag; | ||
251 | } | ||
252 | wrb = wrb_from_mccq(phba); | ||
253 | req = embedded_payload(wrb); | ||
254 | wrb->tag0 |= tag; | ||
229 | 255 | ||
230 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 256 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
231 | be_cmd_hdr_prepare(&req->hdr, CMD_COMMON_TCP_UPLOAD, | 257 | be_cmd_hdr_prepare(&req->hdr, CMD_COMMON_TCP_UPLOAD, |
232 | OPCODE_COMMON_TCP_UPLOAD, sizeof(*req)); | 258 | OPCODE_COMMON_TCP_UPLOAD, sizeof(*req)); |
233 | req->id = (unsigned short)cid; | 259 | req->id = (unsigned short)cid; |
234 | req->upload_type = (unsigned char)upload_flag; | 260 | req->upload_type = (unsigned char)upload_flag; |
235 | status = be_mcc_notify_wait(phba); | 261 | be_mcc_notify(phba); |
236 | if (status) | ||
237 | SE_DEBUG(DBG_LVL_1, "mgmt_upload_connection Failed\n"); | ||
238 | spin_unlock(&ctrl->mbox_lock); | 262 | spin_unlock(&ctrl->mbox_lock); |
239 | return status; | 263 | return tag; |
240 | } | 264 | } |
241 | 265 | ||
242 | int mgmt_open_connection(struct beiscsi_hba *phba, | 266 | int mgmt_open_connection(struct beiscsi_hba *phba, |
@@ -248,13 +272,13 @@ int mgmt_open_connection(struct beiscsi_hba *phba, | |||
248 | struct sockaddr_in *daddr_in = (struct sockaddr_in *)dst_addr; | 272 | struct sockaddr_in *daddr_in = (struct sockaddr_in *)dst_addr; |
249 | struct sockaddr_in6 *daddr_in6 = (struct sockaddr_in6 *)dst_addr; | 273 | struct sockaddr_in6 *daddr_in6 = (struct sockaddr_in6 *)dst_addr; |
250 | struct be_ctrl_info *ctrl = &phba->ctrl; | 274 | struct be_ctrl_info *ctrl = &phba->ctrl; |
251 | struct be_mcc_wrb *wrb = wrb_from_mccq(phba); | 275 | struct be_mcc_wrb *wrb; |
252 | struct tcp_connect_and_offload_in *req = embedded_payload(wrb); | 276 | struct tcp_connect_and_offload_in *req; |
253 | unsigned short def_hdr_id; | 277 | unsigned short def_hdr_id; |
254 | unsigned short def_data_id; | 278 | unsigned short def_data_id; |
255 | struct phys_addr template_address = { 0, 0 }; | 279 | struct phys_addr template_address = { 0, 0 }; |
256 | struct phys_addr *ptemplate_address; | 280 | struct phys_addr *ptemplate_address; |
257 | int status = 0; | 281 | unsigned int tag = 0; |
258 | unsigned int i; | 282 | unsigned int i; |
259 | unsigned short cid = beiscsi_ep->ep_cid; | 283 | unsigned short cid = beiscsi_ep->ep_cid; |
260 | 284 | ||
@@ -266,7 +290,14 @@ int mgmt_open_connection(struct beiscsi_hba *phba, | |||
266 | ptemplate_address = &template_address; | 290 | ptemplate_address = &template_address; |
267 | ISCSI_GET_PDU_TEMPLATE_ADDRESS(phba, ptemplate_address); | 291 | ISCSI_GET_PDU_TEMPLATE_ADDRESS(phba, ptemplate_address); |
268 | spin_lock(&ctrl->mbox_lock); | 292 | spin_lock(&ctrl->mbox_lock); |
269 | memset(wrb, 0, sizeof(*wrb)); | 293 | tag = alloc_mcc_tag(phba); |
294 | if (!tag) { | ||
295 | spin_unlock(&ctrl->mbox_lock); | ||
296 | return tag; | ||
297 | } | ||
298 | wrb = wrb_from_mccq(phba); | ||
299 | req = embedded_payload(wrb); | ||
300 | wrb->tag0 |= tag; | ||
270 | 301 | ||
271 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 302 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
272 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI, | 303 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI, |
@@ -311,46 +342,36 @@ int mgmt_open_connection(struct beiscsi_hba *phba, | |||
311 | req->do_offload = 1; | 342 | req->do_offload = 1; |
312 | req->dataout_template_pa.lo = ptemplate_address->lo; | 343 | req->dataout_template_pa.lo = ptemplate_address->lo; |
313 | req->dataout_template_pa.hi = ptemplate_address->hi; | 344 | req->dataout_template_pa.hi = ptemplate_address->hi; |
314 | status = be_mcc_notify_wait(phba); | 345 | be_mcc_notify(phba); |
315 | if (!status) { | ||
316 | struct iscsi_endpoint *ep; | ||
317 | struct tcp_connect_and_offload_out *ptcpcnct_out = | ||
318 | embedded_payload(wrb); | ||
319 | |||
320 | ep = phba->ep_array[ptcpcnct_out->cid]; | ||
321 | beiscsi_ep = ep->dd_data; | ||
322 | beiscsi_ep->fw_handle = ptcpcnct_out->connection_handle; | ||
323 | beiscsi_ep->cid_vld = 1; | ||
324 | SE_DEBUG(DBG_LVL_8, "mgmt_open_connection Success\n"); | ||
325 | } else | ||
326 | SE_DEBUG(DBG_LVL_1, "mgmt_open_connection Failed\n"); | ||
327 | spin_unlock(&ctrl->mbox_lock); | 346 | spin_unlock(&ctrl->mbox_lock); |
328 | return status; | 347 | return tag; |
329 | } | 348 | } |
330 | 349 | ||
331 | int be_cmd_get_mac_addr(struct beiscsi_hba *phba, u8 *mac_addr) | 350 | unsigned int be_cmd_get_mac_addr(struct beiscsi_hba *phba) |
332 | { | 351 | { |
333 | struct be_ctrl_info *ctrl = &phba->ctrl; | 352 | struct be_ctrl_info *ctrl = &phba->ctrl; |
334 | struct be_mcc_wrb *wrb = wrb_from_mccq(phba); | 353 | struct be_mcc_wrb *wrb; |
335 | struct be_cmd_req_get_mac_addr *req = embedded_payload(wrb); | 354 | struct be_cmd_req_get_mac_addr *req; |
336 | int status; | 355 | unsigned int tag = 0; |
337 | 356 | ||
338 | SE_DEBUG(DBG_LVL_8, "In be_cmd_get_mac_addr\n"); | 357 | SE_DEBUG(DBG_LVL_8, "In be_cmd_get_mac_addr\n"); |
339 | spin_lock(&ctrl->mbox_lock); | 358 | spin_lock(&ctrl->mbox_lock); |
340 | memset(wrb, 0, sizeof(*wrb)); | 359 | tag = alloc_mcc_tag(phba); |
360 | if (!tag) { | ||
361 | spin_unlock(&ctrl->mbox_lock); | ||
362 | return tag; | ||
363 | } | ||
364 | |||
365 | wrb = wrb_from_mccq(phba); | ||
366 | req = embedded_payload(wrb); | ||
367 | wrb->tag0 |= tag; | ||
341 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 368 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
342 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI, | 369 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI, |
343 | OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG, | 370 | OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG, |
344 | sizeof(*req)); | 371 | sizeof(*req)); |
345 | 372 | ||
346 | status = be_mcc_notify_wait(phba); | 373 | be_mcc_notify(phba); |
347 | if (!status) { | ||
348 | struct be_cmd_resp_get_mac_addr *resp = embedded_payload(wrb); | ||
349 | |||
350 | memcpy(mac_addr, resp->mac_address, ETH_ALEN); | ||
351 | } | ||
352 | |||
353 | spin_unlock(&ctrl->mbox_lock); | 374 | spin_unlock(&ctrl->mbox_lock); |
354 | return status; | 375 | return tag; |
355 | } | 376 | } |
356 | 377 | ||