blob: 26350e470bccf71ea47b8dd99f387a31aff21670 [file] [log] [blame]
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301/**
Jayamohan Kallickald2eeb1a2010-01-23 05:35:15 +05302 * Copyright (C) 2005 - 2010 ServerEngines
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05303 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Written by: Jayamohan Kallickal (jayamohank@serverengines.com)
11 *
12 * Contact Information:
13 * linux-drivers@serverengines.com
14 *
15 * ServerEngines
16 * 209 N. Fair Oaks Ave
17 * Sunnyvale, CA 94085
18 *
19 */
20
21#include "be_mgmt.h"
22#include "be_iscsi.h"
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +053023#include <scsi/scsi_transport_iscsi.h>
24
25unsigned int beiscsi_get_boot_target(struct beiscsi_hba *phba)
26{
27 struct be_ctrl_info *ctrl = &phba->ctrl;
28 struct be_mcc_wrb *wrb;
29 struct be_cmd_req_get_mac_addr *req;
30 unsigned int tag = 0;
31
32 SE_DEBUG(DBG_LVL_8, "In bescsi_get_boot_target\n");
33 spin_lock(&ctrl->mbox_lock);
34 tag = alloc_mcc_tag(phba);
35 if (!tag) {
36 spin_unlock(&ctrl->mbox_lock);
37 return tag;
38 }
39
40 wrb = wrb_from_mccq(phba);
41 req = embedded_payload(wrb);
42 wrb->tag0 |= tag;
43 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
44 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI,
45 OPCODE_ISCSI_INI_BOOT_GET_BOOT_TARGET,
46 sizeof(*req));
47
48 be_mcc_notify(phba);
49 spin_unlock(&ctrl->mbox_lock);
50 return tag;
51}
52
53unsigned int beiscsi_get_session_info(struct beiscsi_hba *phba,
54 u32 boot_session_handle,
55 struct be_dma_mem *nonemb_cmd)
56{
57 struct be_ctrl_info *ctrl = &phba->ctrl;
58 struct be_mcc_wrb *wrb;
59 unsigned int tag = 0;
60 struct be_cmd_req_get_session *req;
61 struct be_cmd_resp_get_session *resp;
62 struct be_sge *sge;
63
64 SE_DEBUG(DBG_LVL_8, "In beiscsi_get_session_info\n");
65 spin_lock(&ctrl->mbox_lock);
66 tag = alloc_mcc_tag(phba);
67 if (!tag) {
68 spin_unlock(&ctrl->mbox_lock);
69 return tag;
70 }
71
72 nonemb_cmd->size = sizeof(*resp);
73 req = nonemb_cmd->va;
74 memset(req, 0, sizeof(*req));
75 wrb = wrb_from_mccq(phba);
76 sge = nonembedded_sgl(wrb);
77 wrb->tag0 |= tag;
78
79
80 wrb->tag0 |= tag;
81 be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1);
82 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI,
83 OPCODE_ISCSI_INI_SESSION_GET_A_SESSION,
84 sizeof(*resp));
85 req->session_handle = boot_session_handle;
86 sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma));
87 sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF);
88 sge->len = cpu_to_le32(nonemb_cmd->size);
89
90 be_mcc_notify(phba);
91 spin_unlock(&ctrl->mbox_lock);
92 return tag;
93}
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053094
Jayamohan Kallickal03a12312010-07-22 04:17:16 +053095int mgmt_get_fw_config(struct be_ctrl_info *ctrl,
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053096 struct beiscsi_hba *phba)
97{
98 struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem);
99 struct be_fw_cfg *req = embedded_payload(wrb);
100 int status = 0;
101
102 spin_lock(&ctrl->mbox_lock);
103 memset(wrb, 0, sizeof(*wrb));
104
105 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
106
107 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
108 OPCODE_COMMON_QUERY_FIRMWARE_CONFIG, sizeof(*req));
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530109 status = be_mbox_notify(ctrl);
110 if (!status) {
111 struct be_fw_cfg *pfw_cfg;
112 pfw_cfg = req;
113 phba->fw_config.phys_port = pfw_cfg->phys_port;
114 phba->fw_config.iscsi_icd_start =
115 pfw_cfg->ulp[0].icd_base;
116 phba->fw_config.iscsi_icd_count =
117 pfw_cfg->ulp[0].icd_count;
118 phba->fw_config.iscsi_cid_start =
119 pfw_cfg->ulp[0].sq_base;
120 phba->fw_config.iscsi_cid_count =
121 pfw_cfg->ulp[0].sq_count;
Jayamohan Kallickal7da50872010-01-05 05:04:12 +0530122 if (phba->fw_config.iscsi_cid_count > (BE2_MAX_SESSIONS / 2)) {
Jayamohan Kallickala3babda2010-01-07 01:51:44 +0530123 SE_DEBUG(DBG_LVL_8,
Jayamohan Kallickal3cbb7a72010-07-22 04:27:47 +0530124 "FW reported MAX CXNS as %d\t"
Jayamohan Kallickala3babda2010-01-07 01:51:44 +0530125 "Max Supported = %d.\n",
126 phba->fw_config.iscsi_cid_count,
127 BE2_MAX_SESSIONS);
128 phba->fw_config.iscsi_cid_count = BE2_MAX_SESSIONS / 2;
Jayamohan Kallickal7da50872010-01-05 05:04:12 +0530129 }
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530130 } else {
131 shost_printk(KERN_WARNING, phba->shost,
Jayamohan Kallickal457ff3b2010-07-22 04:16:00 +0530132 "Failed in mgmt_get_fw_config\n");
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530133 }
134
135 spin_unlock(&ctrl->mbox_lock);
136 return status;
137}
138
Jayamohan Kallickal03a12312010-07-22 04:17:16 +0530139int mgmt_check_supported_fw(struct be_ctrl_info *ctrl,
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530140 struct beiscsi_hba *phba)
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530141{
142 struct be_dma_mem nonemb_cmd;
143 struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem);
144 struct be_mgmt_controller_attributes *req;
145 struct be_sge *sge = nonembedded_sgl(wrb);
146 int status = 0;
147
148 nonemb_cmd.va = pci_alloc_consistent(ctrl->pdev,
149 sizeof(struct be_mgmt_controller_attributes),
150 &nonemb_cmd.dma);
151 if (nonemb_cmd.va == NULL) {
152 SE_DEBUG(DBG_LVL_1,
153 "Failed to allocate memory for mgmt_check_supported_fw"
154 "\n");
Jayamohan Kallickald3ad2bb2010-07-22 04:16:38 +0530155 return -ENOMEM;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530156 }
157 nonemb_cmd.size = sizeof(struct be_mgmt_controller_attributes);
158 req = nonemb_cmd.va;
Jayamohan Kallickalf98c96b2010-02-11 05:11:15 +0530159 memset(req, 0, sizeof(*req));
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530160 spin_lock(&ctrl->mbox_lock);
161 memset(wrb, 0, sizeof(*wrb));
162 be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1);
163 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
164 OPCODE_COMMON_GET_CNTL_ATTRIBUTES, sizeof(*req));
165 sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd.dma));
166 sge->pa_lo = cpu_to_le32(nonemb_cmd.dma & 0xFFFFFFFF);
167 sge->len = cpu_to_le32(nonemb_cmd.size);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530168 status = be_mbox_notify(ctrl);
169 if (!status) {
170 struct be_mgmt_controller_attributes_resp *resp = nonemb_cmd.va;
171 SE_DEBUG(DBG_LVL_8, "Firmware version of CMD: %s\n",
172 resp->params.hba_attribs.flashrom_version_string);
173 SE_DEBUG(DBG_LVL_8, "Firmware version is : %s\n",
174 resp->params.hba_attribs.firmware_version_string);
175 SE_DEBUG(DBG_LVL_8,
176 "Developer Build, not performing version check...\n");
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530177 phba->fw_config.iscsi_features =
178 resp->params.hba_attribs.iscsi_features;
179 SE_DEBUG(DBG_LVL_8, " phba->fw_config.iscsi_features = %d\n",
180 phba->fw_config.iscsi_features);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530181 } else
182 SE_DEBUG(DBG_LVL_1, " Failed in mgmt_check_supported_fw\n");
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530183 spin_unlock(&ctrl->mbox_lock);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530184 if (nonemb_cmd.va)
185 pci_free_consistent(ctrl->pdev, nonemb_cmd.size,
186 nonemb_cmd.va, nonemb_cmd.dma);
187
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530188 return status;
189}
190
Jayamohan Kallickal03a12312010-07-22 04:17:16 +0530191int mgmt_epfw_cleanup(struct beiscsi_hba *phba, unsigned short chute)
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530192{
193 struct be_ctrl_info *ctrl = &phba->ctrl;
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530194 struct be_mcc_wrb *wrb = wrb_from_mccq(phba);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530195 struct iscsi_cleanup_req *req = embedded_payload(wrb);
196 int status = 0;
197
198 spin_lock(&ctrl->mbox_lock);
199 memset(wrb, 0, sizeof(*wrb));
200
201 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
202 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI,
203 OPCODE_COMMON_ISCSI_CLEANUP, sizeof(*req));
204
205 req->chute = chute;
206 req->hdr_ring_id = 0;
207 req->data_ring_id = 0;
208
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530209 status = be_mcc_notify_wait(phba);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530210 if (status)
211 shost_printk(KERN_WARNING, phba->shost,
212 " mgmt_epfw_cleanup , FAILED\n");
213 spin_unlock(&ctrl->mbox_lock);
214 return status;
215}
216
Jayamohan Kallickal03a12312010-07-22 04:17:16 +0530217unsigned int mgmt_invalidate_icds(struct beiscsi_hba *phba,
Jayamohan Kallickal41831222010-02-20 08:02:39 +0530218 struct invalidate_command_table *inv_tbl,
Jayamohan Kallickal3cbb7a72010-07-22 04:27:47 +0530219 unsigned int num_invalidate, unsigned int cid,
220 struct be_dma_mem *nonemb_cmd)
221
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530222{
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530223 struct be_ctrl_info *ctrl = &phba->ctrl;
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530224 struct be_mcc_wrb *wrb;
225 struct be_sge *sge;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530226 struct invalidate_commands_params_in *req;
Jayamohan Kallickal41831222010-02-20 08:02:39 +0530227 unsigned int i, tag = 0;
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530228
229 spin_lock(&ctrl->mbox_lock);
230 tag = alloc_mcc_tag(phba);
231 if (!tag) {
232 spin_unlock(&ctrl->mbox_lock);
233 return tag;
234 }
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530235
Jayamohan Kallickal3cbb7a72010-07-22 04:27:47 +0530236 req = nonemb_cmd->va;
Jayamohan Kallickalf98c96b2010-02-11 05:11:15 +0530237 memset(req, 0, sizeof(*req));
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530238 wrb = wrb_from_mccq(phba);
239 sge = nonembedded_sgl(wrb);
240 wrb->tag0 |= tag;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530241
242 be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1);
243 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI,
244 OPCODE_COMMON_ISCSI_ERROR_RECOVERY_INVALIDATE_COMMANDS,
245 sizeof(*req));
246 req->ref_handle = 0;
247 req->cleanup_type = CMD_ISCSI_COMMAND_INVALIDATE;
Jayamohan Kallickal41831222010-02-20 08:02:39 +0530248 for (i = 0; i < num_invalidate; i++) {
249 req->table[i].icd = inv_tbl->icd;
250 req->table[i].cid = inv_tbl->cid;
251 req->icd_count++;
252 inv_tbl++;
253 }
Jayamohan Kallickal3cbb7a72010-07-22 04:27:47 +0530254 sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma));
255 sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF);
256 sge->len = cpu_to_le32(nonemb_cmd->size);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530257
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530258 be_mcc_notify(phba);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530259 spin_unlock(&ctrl->mbox_lock);
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530260 return tag;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530261}
262
Jayamohan Kallickal03a12312010-07-22 04:17:16 +0530263unsigned int mgmt_invalidate_connection(struct beiscsi_hba *phba,
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530264 struct beiscsi_endpoint *beiscsi_ep,
265 unsigned short cid,
266 unsigned short issue_reset,
267 unsigned short savecfg_flag)
268{
269 struct be_ctrl_info *ctrl = &phba->ctrl;
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530270 struct be_mcc_wrb *wrb;
271 struct iscsi_invalidate_connection_params_in *req;
272 unsigned int tag = 0;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530273
274 spin_lock(&ctrl->mbox_lock);
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530275 tag = alloc_mcc_tag(phba);
276 if (!tag) {
277 spin_unlock(&ctrl->mbox_lock);
278 return tag;
279 }
280 wrb = wrb_from_mccq(phba);
281 wrb->tag0 |= tag;
282 req = embedded_payload(wrb);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530283
284 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
285 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI,
286 OPCODE_ISCSI_INI_DRIVER_INVALIDATE_CONNECTION,
287 sizeof(*req));
288 req->session_handle = beiscsi_ep->fw_handle;
289 req->cid = cid;
290 if (issue_reset)
291 req->cleanup_type = CMD_ISCSI_CONNECTION_ISSUE_TCP_RST;
292 else
293 req->cleanup_type = CMD_ISCSI_CONNECTION_INVALIDATE;
294 req->save_cfg = savecfg_flag;
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530295 be_mcc_notify(phba);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530296 spin_unlock(&ctrl->mbox_lock);
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530297 return tag;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530298}
299
Jayamohan Kallickal03a12312010-07-22 04:17:16 +0530300unsigned int mgmt_upload_connection(struct beiscsi_hba *phba,
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530301 unsigned short cid, unsigned int upload_flag)
302{
303 struct be_ctrl_info *ctrl = &phba->ctrl;
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530304 struct be_mcc_wrb *wrb;
305 struct tcp_upload_params_in *req;
306 unsigned int tag = 0;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530307
308 spin_lock(&ctrl->mbox_lock);
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530309 tag = alloc_mcc_tag(phba);
310 if (!tag) {
311 spin_unlock(&ctrl->mbox_lock);
312 return tag;
313 }
314 wrb = wrb_from_mccq(phba);
315 req = embedded_payload(wrb);
316 wrb->tag0 |= tag;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530317
318 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
319 be_cmd_hdr_prepare(&req->hdr, CMD_COMMON_TCP_UPLOAD,
320 OPCODE_COMMON_TCP_UPLOAD, sizeof(*req));
321 req->id = (unsigned short)cid;
322 req->upload_type = (unsigned char)upload_flag;
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530323 be_mcc_notify(phba);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530324 spin_unlock(&ctrl->mbox_lock);
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530325 return tag;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530326}
327
328int mgmt_open_connection(struct beiscsi_hba *phba,
329 struct sockaddr *dst_addr,
Jayamohan Kallickal3cbb7a72010-07-22 04:27:47 +0530330 struct beiscsi_endpoint *beiscsi_ep,
331 struct be_dma_mem *nonemb_cmd)
332
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530333{
334 struct hwi_controller *phwi_ctrlr;
335 struct hwi_context_memory *phwi_context;
336 struct sockaddr_in *daddr_in = (struct sockaddr_in *)dst_addr;
337 struct sockaddr_in6 *daddr_in6 = (struct sockaddr_in6 *)dst_addr;
338 struct be_ctrl_info *ctrl = &phba->ctrl;
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530339 struct be_mcc_wrb *wrb;
340 struct tcp_connect_and_offload_in *req;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530341 unsigned short def_hdr_id;
342 unsigned short def_data_id;
343 struct phys_addr template_address = { 0, 0 };
344 struct phys_addr *ptemplate_address;
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530345 unsigned int tag = 0;
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530346 unsigned int i;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530347 unsigned short cid = beiscsi_ep->ep_cid;
Jayamohan Kallickal3cbb7a72010-07-22 04:27:47 +0530348 struct be_sge *sge;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530349
350 phwi_ctrlr = phba->phwi_ctrlr;
351 phwi_context = phwi_ctrlr->phwi_ctxt;
352 def_hdr_id = (unsigned short)HWI_GET_DEF_HDRQ_ID(phba);
353 def_data_id = (unsigned short)HWI_GET_DEF_BUFQ_ID(phba);
354
355 ptemplate_address = &template_address;
356 ISCSI_GET_PDU_TEMPLATE_ADDRESS(phba, ptemplate_address);
357 spin_lock(&ctrl->mbox_lock);
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530358 tag = alloc_mcc_tag(phba);
359 if (!tag) {
360 spin_unlock(&ctrl->mbox_lock);
361 return tag;
362 }
363 wrb = wrb_from_mccq(phba);
Jayamohan Kallickal3cbb7a72010-07-22 04:27:47 +0530364 memset(wrb, 0, sizeof(*wrb));
365 sge = nonembedded_sgl(wrb);
366
367 req = nonemb_cmd->va;
368 memset(req, 0, sizeof(*req));
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530369 wrb->tag0 |= tag;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530370
Jayamohan Kallickal3cbb7a72010-07-22 04:27:47 +0530371 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 1);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530372 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI,
373 OPCODE_COMMON_ISCSI_TCP_CONNECT_AND_OFFLOAD,
374 sizeof(*req));
375 if (dst_addr->sa_family == PF_INET) {
376 __be32 s_addr = daddr_in->sin_addr.s_addr;
377 req->ip_address.ip_type = BE2_IPV4;
378 req->ip_address.ip_address[0] = s_addr & 0x000000ff;
379 req->ip_address.ip_address[1] = (s_addr & 0x0000ff00) >> 8;
380 req->ip_address.ip_address[2] = (s_addr & 0x00ff0000) >> 16;
381 req->ip_address.ip_address[3] = (s_addr & 0xff000000) >> 24;
382 req->tcp_port = ntohs(daddr_in->sin_port);
383 beiscsi_ep->dst_addr = daddr_in->sin_addr.s_addr;
384 beiscsi_ep->dst_tcpport = ntohs(daddr_in->sin_port);
385 beiscsi_ep->ip_type = BE2_IPV4;
386 } else if (dst_addr->sa_family == PF_INET6) {
387 req->ip_address.ip_type = BE2_IPV6;
388 memcpy(&req->ip_address.ip_address,
389 &daddr_in6->sin6_addr.in6_u.u6_addr8, 16);
390 req->tcp_port = ntohs(daddr_in6->sin6_port);
391 beiscsi_ep->dst_tcpport = ntohs(daddr_in6->sin6_port);
392 memcpy(&beiscsi_ep->dst6_addr,
393 &daddr_in6->sin6_addr.in6_u.u6_addr8, 16);
394 beiscsi_ep->ip_type = BE2_IPV6;
395 } else{
396 shost_printk(KERN_ERR, phba->shost, "unknown addr family %d\n",
397 dst_addr->sa_family);
398 spin_unlock(&ctrl->mbox_lock);
Jayamohan Kallickal5db3f332010-07-22 04:24:22 +0530399 free_mcc_tag(&phba->ctrl, tag);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530400 return -EINVAL;
401
402 }
403 req->cid = cid;
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530404 i = phba->nxt_cqid++;
405 if (phba->nxt_cqid == phba->num_cpus)
406 phba->nxt_cqid = 0;
407 req->cq_id = phwi_context->be_cq[i].id;
Jayamohan Kallickal457ff3b2010-07-22 04:16:00 +0530408 SE_DEBUG(DBG_LVL_8, "i=%d cq_id=%d\n", i, req->cq_id);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530409 req->defq_id = def_hdr_id;
410 req->hdr_ring_id = def_hdr_id;
411 req->data_ring_id = def_data_id;
412 req->do_offload = 1;
413 req->dataout_template_pa.lo = ptemplate_address->lo;
414 req->dataout_template_pa.hi = ptemplate_address->hi;
Jayamohan Kallickal3cbb7a72010-07-22 04:27:47 +0530415 sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma));
416 sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF);
417 sge->len = cpu_to_le32(nonemb_cmd->size);
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530418 be_mcc_notify(phba);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530419 spin_unlock(&ctrl->mbox_lock);
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530420 return tag;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530421}
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530422
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530423unsigned int be_cmd_get_mac_addr(struct beiscsi_hba *phba)
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530424{
425 struct be_ctrl_info *ctrl = &phba->ctrl;
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530426 struct be_mcc_wrb *wrb;
427 struct be_cmd_req_get_mac_addr *req;
428 unsigned int tag = 0;
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530429
430 SE_DEBUG(DBG_LVL_8, "In be_cmd_get_mac_addr\n");
431 spin_lock(&ctrl->mbox_lock);
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530432 tag = alloc_mcc_tag(phba);
433 if (!tag) {
434 spin_unlock(&ctrl->mbox_lock);
435 return tag;
436 }
437
438 wrb = wrb_from_mccq(phba);
439 req = embedded_payload(wrb);
440 wrb->tag0 |= tag;
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530441 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
442 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI,
443 OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG,
444 sizeof(*req));
445
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530446 be_mcc_notify(phba);
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530447 spin_unlock(&ctrl->mbox_lock);
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530448 return tag;
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530449}
450