2 * Copyright (C) 2005 - 2016 Broadcom
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.
10 * Written by: Jayamohan Kallickal (jayamohan.kallickal@broadcom.com)
12 * Contact Information:
13 * linux-drivers@broadcom.com
17 * Costa Mesa, CA 92626
20 #include <linux/bsg-lib.h>
21 #include <scsi/scsi_transport_iscsi.h>
22 #include <scsi/scsi_bsg_iscsi.h>
27 int beiscsi_modify_eq_delay(struct beiscsi_hba *phba,
28 struct be_set_eqd *set_eqd,
31 struct be_ctrl_info *ctrl = &phba->ctrl;
32 struct be_mcc_wrb *wrb;
33 struct be_cmd_req_modify_eq_delay *req;
37 mutex_lock(&ctrl->mbox_lock);
38 wrb = alloc_mcc_wrb(phba, &tag);
40 mutex_unlock(&ctrl->mbox_lock);
44 req = embedded_payload(wrb);
45 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
46 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
47 OPCODE_COMMON_MODIFY_EQ_DELAY, sizeof(*req));
49 req->num_eq = cpu_to_le32(num);
50 for (i = 0; i < num; i++) {
51 req->delay[i].eq_id = cpu_to_le32(set_eqd[i].eq_id);
52 req->delay[i].phase = 0;
53 req->delay[i].delay_multiplier =
54 cpu_to_le32(set_eqd[i].delay_multiplier);
57 /* ignore the completion of this mbox command */
58 set_bit(MCC_TAG_STATE_IGNORE, &ctrl->ptag_state[tag].tag_state);
59 be_mcc_notify(phba, tag);
60 mutex_unlock(&ctrl->mbox_lock);
64 unsigned int mgmt_vendor_specific_fw_cmd(struct be_ctrl_info *ctrl,
65 struct beiscsi_hba *phba,
67 struct be_dma_mem *nonemb_cmd)
69 struct be_cmd_resp_hdr *resp;
70 struct be_mcc_wrb *wrb;
71 struct be_sge *mcc_sge;
73 struct iscsi_bsg_request *bsg_req = job->request;
74 struct be_bsg_vendor_cmd *req = nonemb_cmd->va;
75 unsigned short region, sector_size, sector, offset;
77 nonemb_cmd->size = job->request_payload.payload_len;
78 memset(nonemb_cmd->va, 0, nonemb_cmd->size);
79 resp = nonemb_cmd->va;
80 region = bsg_req->rqst_data.h_vendor.vendor_cmd[1];
81 sector_size = bsg_req->rqst_data.h_vendor.vendor_cmd[2];
82 sector = bsg_req->rqst_data.h_vendor.vendor_cmd[3];
83 offset = bsg_req->rqst_data.h_vendor.vendor_cmd[4];
88 if (mutex_lock_interruptible(&ctrl->mbox_lock))
90 switch (bsg_req->rqst_data.h_vendor.vendor_cmd[0]) {
91 case BEISCSI_WRITE_FLASH:
92 offset = sector * sector_size + offset;
93 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI,
94 OPCODE_COMMON_WRITE_FLASH, sizeof(*req));
95 sg_copy_to_buffer(job->request_payload.sg_list,
96 job->request_payload.sg_cnt,
97 nonemb_cmd->va + offset, job->request_len);
99 case BEISCSI_READ_FLASH:
100 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI,
101 OPCODE_COMMON_READ_FLASH, sizeof(*req));
104 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
105 "BG_%d : Unsupported cmd = 0x%x\n\n",
106 bsg_req->rqst_data.h_vendor.vendor_cmd[0]);
108 mutex_unlock(&ctrl->mbox_lock);
112 wrb = alloc_mcc_wrb(phba, &tag);
114 mutex_unlock(&ctrl->mbox_lock);
118 mcc_sge = nonembedded_sgl(wrb);
119 be_wrb_hdr_prepare(wrb, nonemb_cmd->size, false,
120 job->request_payload.sg_cnt);
121 mcc_sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma));
122 mcc_sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF);
123 mcc_sge->len = cpu_to_le32(nonemb_cmd->size);
125 be_mcc_notify(phba, tag);
127 mutex_unlock(&ctrl->mbox_lock);
131 unsigned int mgmt_invalidate_icds(struct beiscsi_hba *phba,
132 struct invalidate_command_table *inv_tbl,
133 unsigned int num_invalidate, unsigned int cid,
134 struct be_dma_mem *nonemb_cmd)
137 struct be_ctrl_info *ctrl = &phba->ctrl;
138 struct be_mcc_wrb *wrb;
140 struct invalidate_commands_params_in *req;
143 mutex_lock(&ctrl->mbox_lock);
144 wrb = alloc_mcc_wrb(phba, &tag);
146 mutex_unlock(&ctrl->mbox_lock);
150 req = nonemb_cmd->va;
151 memset(req, 0, sizeof(*req));
152 sge = nonembedded_sgl(wrb);
154 be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1);
155 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI,
156 OPCODE_COMMON_ISCSI_ERROR_RECOVERY_INVALIDATE_COMMANDS,
159 req->cleanup_type = CMD_ISCSI_COMMAND_INVALIDATE;
160 for (i = 0; i < num_invalidate; i++) {
161 req->table[i].icd = inv_tbl->icd;
162 req->table[i].cid = inv_tbl->cid;
166 sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma));
167 sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF);
168 sge->len = cpu_to_le32(nonemb_cmd->size);
170 be_mcc_notify(phba, tag);
171 mutex_unlock(&ctrl->mbox_lock);
175 unsigned int mgmt_invalidate_connection(struct beiscsi_hba *phba,
176 struct beiscsi_endpoint *beiscsi_ep,
178 unsigned short issue_reset,
179 unsigned short savecfg_flag)
181 struct be_ctrl_info *ctrl = &phba->ctrl;
182 struct be_mcc_wrb *wrb;
183 struct iscsi_invalidate_connection_params_in *req;
184 unsigned int tag = 0;
186 mutex_lock(&ctrl->mbox_lock);
187 wrb = alloc_mcc_wrb(phba, &tag);
189 mutex_unlock(&ctrl->mbox_lock);
193 req = embedded_payload(wrb);
194 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
195 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI,
196 OPCODE_ISCSI_INI_DRIVER_INVALIDATE_CONNECTION,
198 req->session_handle = beiscsi_ep->fw_handle;
201 req->cleanup_type = CMD_ISCSI_CONNECTION_ISSUE_TCP_RST;
203 req->cleanup_type = CMD_ISCSI_CONNECTION_INVALIDATE;
204 req->save_cfg = savecfg_flag;
205 be_mcc_notify(phba, tag);
206 mutex_unlock(&ctrl->mbox_lock);
210 unsigned int mgmt_upload_connection(struct beiscsi_hba *phba,
211 unsigned short cid, unsigned int upload_flag)
213 struct be_ctrl_info *ctrl = &phba->ctrl;
214 struct be_mcc_wrb *wrb;
215 struct tcp_upload_params_in *req;
218 mutex_lock(&ctrl->mbox_lock);
219 wrb = alloc_mcc_wrb(phba, &tag);
221 mutex_unlock(&ctrl->mbox_lock);
225 req = embedded_payload(wrb);
226 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
227 be_cmd_hdr_prepare(&req->hdr, CMD_COMMON_TCP_UPLOAD,
228 OPCODE_COMMON_TCP_UPLOAD, sizeof(*req));
229 req->id = (unsigned short)cid;
230 req->upload_type = (unsigned char)upload_flag;
231 be_mcc_notify(phba, tag);
232 mutex_unlock(&ctrl->mbox_lock);
237 * mgmt_open_connection()- Establish a TCP CXN
238 * @dst_addr: Destination Address
239 * @beiscsi_ep: ptr to device endpoint struct
240 * @nonemb_cmd: ptr to memory allocated for command
243 * Success: Tag number of the MBX Command issued
244 * Failure: Error code
246 int mgmt_open_connection(struct beiscsi_hba *phba,
247 struct sockaddr *dst_addr,
248 struct beiscsi_endpoint *beiscsi_ep,
249 struct be_dma_mem *nonemb_cmd)
251 struct hwi_controller *phwi_ctrlr;
252 struct hwi_context_memory *phwi_context;
253 struct sockaddr_in *daddr_in = (struct sockaddr_in *)dst_addr;
254 struct sockaddr_in6 *daddr_in6 = (struct sockaddr_in6 *)dst_addr;
255 struct be_ctrl_info *ctrl = &phba->ctrl;
256 struct be_mcc_wrb *wrb;
257 struct tcp_connect_and_offload_in_v1 *req;
258 unsigned short def_hdr_id;
259 unsigned short def_data_id;
260 struct phys_addr template_address = { 0, 0 };
261 struct phys_addr *ptemplate_address;
262 unsigned int tag = 0;
263 unsigned int i, ulp_num;
264 unsigned short cid = beiscsi_ep->ep_cid;
267 if (dst_addr->sa_family != PF_INET && dst_addr->sa_family != PF_INET6) {
268 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
269 "BG_%d : unknown addr family %d\n",
270 dst_addr->sa_family);
274 phwi_ctrlr = phba->phwi_ctrlr;
275 phwi_context = phwi_ctrlr->phwi_ctxt;
277 ulp_num = phwi_ctrlr->wrb_context[BE_GET_CRI_FROM_CID(cid)].ulp_num;
279 def_hdr_id = (unsigned short)HWI_GET_DEF_HDRQ_ID(phba, ulp_num);
280 def_data_id = (unsigned short)HWI_GET_DEF_BUFQ_ID(phba, ulp_num);
282 ptemplate_address = &template_address;
283 ISCSI_GET_PDU_TEMPLATE_ADDRESS(phba, ptemplate_address);
284 if (mutex_lock_interruptible(&ctrl->mbox_lock))
286 wrb = alloc_mcc_wrb(phba, &tag);
288 mutex_unlock(&ctrl->mbox_lock);
292 sge = nonembedded_sgl(wrb);
293 req = nonemb_cmd->va;
294 memset(req, 0, sizeof(*req));
296 be_wrb_hdr_prepare(wrb, nonemb_cmd->size, false, 1);
297 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI,
298 OPCODE_COMMON_ISCSI_TCP_CONNECT_AND_OFFLOAD,
300 if (dst_addr->sa_family == PF_INET) {
301 __be32 s_addr = daddr_in->sin_addr.s_addr;
302 req->ip_address.ip_type = BEISCSI_IP_TYPE_V4;
303 req->ip_address.addr[0] = s_addr & 0x000000ff;
304 req->ip_address.addr[1] = (s_addr & 0x0000ff00) >> 8;
305 req->ip_address.addr[2] = (s_addr & 0x00ff0000) >> 16;
306 req->ip_address.addr[3] = (s_addr & 0xff000000) >> 24;
307 req->tcp_port = ntohs(daddr_in->sin_port);
308 beiscsi_ep->dst_addr = daddr_in->sin_addr.s_addr;
309 beiscsi_ep->dst_tcpport = ntohs(daddr_in->sin_port);
310 beiscsi_ep->ip_type = BEISCSI_IP_TYPE_V4;
312 /* else its PF_INET6 family */
313 req->ip_address.ip_type = BEISCSI_IP_TYPE_V6;
314 memcpy(&req->ip_address.addr,
315 &daddr_in6->sin6_addr.in6_u.u6_addr8, 16);
316 req->tcp_port = ntohs(daddr_in6->sin6_port);
317 beiscsi_ep->dst_tcpport = ntohs(daddr_in6->sin6_port);
318 memcpy(&beiscsi_ep->dst6_addr,
319 &daddr_in6->sin6_addr.in6_u.u6_addr8, 16);
320 beiscsi_ep->ip_type = BEISCSI_IP_TYPE_V6;
323 i = phba->nxt_cqid++;
324 if (phba->nxt_cqid == phba->num_cpus)
326 req->cq_id = phwi_context->be_cq[i].id;
327 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
328 "BG_%d : i=%d cq_id=%d\n", i, req->cq_id);
329 req->defq_id = def_hdr_id;
330 req->hdr_ring_id = def_hdr_id;
331 req->data_ring_id = def_data_id;
333 req->dataout_template_pa.lo = ptemplate_address->lo;
334 req->dataout_template_pa.hi = ptemplate_address->hi;
335 sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma));
336 sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF);
337 sge->len = cpu_to_le32(nonemb_cmd->size);
339 if (!is_chip_be2_be3r(phba)) {
340 req->hdr.version = MBX_CMD_VER1;
341 req->tcp_window_size = 0x8000;
342 req->tcp_window_scale_count = 2;
345 be_mcc_notify(phba, tag);
346 mutex_unlock(&ctrl->mbox_lock);
351 * mgmt_exec_nonemb_cmd()- Execute Non Embedded MBX Cmd
352 * @phba: Driver priv structure
353 * @nonemb_cmd: Address of the MBX command issued
354 * @resp_buf: Buffer to copy the MBX cmd response
355 * @resp_buf_len: respone lenght to be copied
358 static int mgmt_exec_nonemb_cmd(struct beiscsi_hba *phba,
359 struct be_dma_mem *nonemb_cmd, void *resp_buf,
362 struct be_ctrl_info *ctrl = &phba->ctrl;
363 struct be_mcc_wrb *wrb;
368 mutex_lock(&ctrl->mbox_lock);
369 wrb = alloc_mcc_wrb(phba, &tag);
371 mutex_unlock(&ctrl->mbox_lock);
376 sge = nonembedded_sgl(wrb);
377 be_wrb_hdr_prepare(wrb, nonemb_cmd->size, false, 1);
378 sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma));
379 sge->pa_lo = cpu_to_le32(lower_32_bits(nonemb_cmd->dma));
380 sge->len = cpu_to_le32(nonemb_cmd->size);
382 be_mcc_notify(phba, tag);
383 mutex_unlock(&ctrl->mbox_lock);
385 rc = beiscsi_mccq_compl_wait(phba, tag, NULL, nonemb_cmd);
388 memcpy(resp_buf, nonemb_cmd->va, resp_buf_len);
391 /* Check if the MBX Cmd needs to be re-issued */
395 beiscsi_log(phba, KERN_WARNING,
396 BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX,
397 "BG_%d : mgmt_exec_nonemb_cmd Failed status\n");
405 pci_free_consistent(ctrl->pdev, nonemb_cmd->size,
406 nonemb_cmd->va, nonemb_cmd->dma);
410 static int mgmt_alloc_cmd_data(struct beiscsi_hba *phba, struct be_dma_mem *cmd,
411 int iscsi_cmd, int size)
413 cmd->va = pci_zalloc_consistent(phba->ctrl.pdev, size, &cmd->dma);
415 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
416 "BG_%d : Failed to allocate memory for if info\n");
420 be_cmd_hdr_prepare(cmd->va, CMD_SUBSYSTEM_ISCSI, iscsi_cmd, size);
421 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
422 "BG_%d : subsystem iSCSI cmd %d size %d\n",
427 unsigned int beiscsi_if_get_handle(struct beiscsi_hba *phba)
429 struct be_ctrl_info *ctrl = &phba->ctrl;
430 struct be_mcc_wrb *wrb;
431 struct be_cmd_get_all_if_id_req *req;
432 struct be_cmd_get_all_if_id_req *pbe_allid;
436 if (mutex_lock_interruptible(&ctrl->mbox_lock))
438 wrb = alloc_mcc_wrb(phba, &tag);
440 mutex_unlock(&ctrl->mbox_lock);
444 req = embedded_payload(wrb);
445 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
446 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI,
447 OPCODE_COMMON_ISCSI_NTWK_GET_ALL_IF_ID,
449 be_mcc_notify(phba, tag);
450 mutex_unlock(&ctrl->mbox_lock);
452 status = beiscsi_mccq_compl_wait(phba, tag, &wrb, NULL);
454 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
455 "BG_%d : %s failed: %d\n", __func__, status);
459 pbe_allid = embedded_payload(wrb);
460 /* we now support only one interface per function */
461 phba->interface_handle = pbe_allid->if_hndl_list[0];
466 static inline bool beiscsi_if_zero_ip(u8 *ip, u32 ip_type)
470 len = (ip_type < BEISCSI_IP_TYPE_V6) ? IP_V4_LEN : IP_V6_LEN;
471 while (len && !ip[len - 1])
476 static int beiscsi_if_mod_gw(struct beiscsi_hba *phba,
477 u32 action, u32 ip_type, u8 *gw)
479 struct be_cmd_set_def_gateway_req *req;
480 struct be_dma_mem nonemb_cmd;
483 rt_val = mgmt_alloc_cmd_data(phba, &nonemb_cmd,
484 OPCODE_COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY,
490 req->action = action;
491 req->ip_addr.ip_type = ip_type;
492 memcpy(req->ip_addr.addr, gw,
493 (ip_type < BEISCSI_IP_TYPE_V6) ? IP_V4_LEN : IP_V6_LEN);
494 return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0);
497 int beiscsi_if_set_gw(struct beiscsi_hba *phba, u32 ip_type, u8 *gw)
499 struct be_cmd_get_def_gateway_resp gw_resp;
502 memset(&gw_resp, 0, sizeof(gw_resp));
503 rt_val = beiscsi_if_get_gw(phba, ip_type, &gw_resp);
505 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
506 "BG_%d : Failed to Get Gateway Addr\n");
510 if (!beiscsi_if_zero_ip(gw_resp.ip_addr.addr, ip_type)) {
511 rt_val = beiscsi_if_mod_gw(phba, IP_ACTION_DEL, ip_type,
512 gw_resp.ip_addr.addr);
514 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
515 "BG_%d : Failed to clear Gateway Addr Set\n");
520 rt_val = beiscsi_if_mod_gw(phba, IP_ACTION_ADD, ip_type, gw);
522 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
523 "BG_%d : Failed to Set Gateway Addr\n");
528 int beiscsi_if_get_gw(struct beiscsi_hba *phba, u32 ip_type,
529 struct be_cmd_get_def_gateway_resp *resp)
531 struct be_cmd_get_def_gateway_req *req;
532 struct be_dma_mem nonemb_cmd;
535 rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd,
536 OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY,
542 req->ip_type = ip_type;
544 return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, resp,
549 beiscsi_if_clr_ip(struct beiscsi_hba *phba,
550 struct be_cmd_get_if_info_resp *if_info)
552 struct be_cmd_set_ip_addr_req *req;
553 struct be_dma_mem nonemb_cmd;
556 rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd,
557 OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR,
563 req->ip_params.record_entry_count = 1;
564 req->ip_params.ip_record.action = IP_ACTION_DEL;
565 req->ip_params.ip_record.interface_hndl =
566 phba->interface_handle;
567 req->ip_params.ip_record.ip_addr.size_of_structure =
568 sizeof(struct be_ip_addr_subnet_format);
569 req->ip_params.ip_record.ip_addr.ip_type = if_info->ip_addr.ip_type;
570 memcpy(req->ip_params.ip_record.ip_addr.addr,
571 if_info->ip_addr.addr,
572 sizeof(if_info->ip_addr.addr));
573 memcpy(req->ip_params.ip_record.ip_addr.subnet_mask,
574 if_info->ip_addr.subnet_mask,
575 sizeof(if_info->ip_addr.subnet_mask));
576 rc = mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0);
577 if (rc < 0 || req->ip_params.ip_record.status) {
578 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
579 "BG_%d : failed to clear IP: rc %d status %d\n",
580 rc, req->ip_params.ip_record.status);
586 beiscsi_if_set_ip(struct beiscsi_hba *phba, u8 *ip,
587 u8 *subnet, u32 ip_type)
589 struct be_cmd_set_ip_addr_req *req;
590 struct be_dma_mem nonemb_cmd;
594 rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd,
595 OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR,
601 req->ip_params.record_entry_count = 1;
602 req->ip_params.ip_record.action = IP_ACTION_ADD;
603 req->ip_params.ip_record.interface_hndl =
604 phba->interface_handle;
605 req->ip_params.ip_record.ip_addr.size_of_structure =
606 sizeof(struct be_ip_addr_subnet_format);
607 req->ip_params.ip_record.ip_addr.ip_type = ip_type;
608 ip_len = (ip_type < BEISCSI_IP_TYPE_V6) ? IP_V4_LEN : IP_V6_LEN;
609 memcpy(req->ip_params.ip_record.ip_addr.addr, ip, ip_len);
611 memcpy(req->ip_params.ip_record.ip_addr.subnet_mask,
614 rc = mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0);
616 * In some cases, host needs to look into individual record status
617 * even though FW reported success for that IOCTL.
619 if (rc < 0 || req->ip_params.ip_record.status) {
620 __beiscsi_log(phba, KERN_ERR,
621 "BG_%d : failed to set IP: rc %d status %d\n",
622 rc, req->ip_params.ip_record.status);
623 if (req->ip_params.ip_record.status)
629 int beiscsi_if_en_static(struct beiscsi_hba *phba, u32 ip_type,
632 struct be_cmd_get_if_info_resp *if_info;
633 struct be_cmd_rel_dhcp_req *reldhcp;
634 struct be_dma_mem nonemb_cmd;
637 rc = beiscsi_if_get_info(phba, ip_type, &if_info);
641 if (if_info->dhcp_state) {
642 rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd,
643 OPCODE_COMMON_ISCSI_NTWK_REL_STATELESS_IP_ADDR,
648 reldhcp = nonemb_cmd.va;
649 reldhcp->interface_hndl = phba->interface_handle;
650 reldhcp->ip_type = ip_type;
651 rc = mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0);
653 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
654 "BG_%d : failed to release existing DHCP: %d\n",
660 /* first delete any IP set */
661 if (!beiscsi_if_zero_ip(if_info->ip_addr.addr, ip_type)) {
662 rc = beiscsi_if_clr_ip(phba, if_info);
667 /* if ip == NULL then this is called just to release DHCP IP */
669 rc = beiscsi_if_set_ip(phba, ip, subnet, ip_type);
675 int beiscsi_if_en_dhcp(struct beiscsi_hba *phba, u32 ip_type)
677 struct be_cmd_get_def_gateway_resp gw_resp;
678 struct be_cmd_get_if_info_resp *if_info;
679 struct be_cmd_set_dhcp_req *dhcpreq;
680 struct be_dma_mem nonemb_cmd;
684 rc = beiscsi_if_get_info(phba, ip_type, &if_info);
688 if (if_info->dhcp_state) {
689 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
690 "BG_%d : DHCP Already Enabled\n");
694 /* first delete any IP set */
695 if (!beiscsi_if_zero_ip(if_info->ip_addr.addr, ip_type)) {
696 rc = beiscsi_if_clr_ip(phba, if_info);
701 /* delete gateway settings if mode change is to DHCP */
702 memset(&gw_resp, 0, sizeof(gw_resp));
703 /* use ip_type provided in if_info */
704 rc = beiscsi_if_get_gw(phba, if_info->ip_addr.ip_type, &gw_resp);
706 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
707 "BG_%d : Failed to Get Gateway Addr\n");
710 gw = (u8 *)&gw_resp.ip_addr.addr;
711 if (!beiscsi_if_zero_ip(gw, if_info->ip_addr.ip_type)) {
712 rc = beiscsi_if_mod_gw(phba, IP_ACTION_DEL,
713 if_info->ip_addr.ip_type, gw);
715 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
716 "BG_%d : Failed to clear Gateway Addr Set\n");
721 rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd,
722 OPCODE_COMMON_ISCSI_NTWK_CONFIG_STATELESS_IP_ADDR,
727 dhcpreq = nonemb_cmd.va;
728 dhcpreq->flags = 1; /* 1 - blocking; 0 - non-blocking */
729 dhcpreq->retry_count = 1;
730 dhcpreq->interface_hndl = phba->interface_handle;
731 dhcpreq->ip_type = ip_type;
732 rc = mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0);
740 * beiscsi_if_set_vlan()- Issue and wait for CMD completion
741 * @phba: device private structure instance
742 * @vlan_tag: VLAN tag
744 * Issue the MBX Cmd and wait for the completion of the
749 * Failure: Non-Xero Value
751 int beiscsi_if_set_vlan(struct beiscsi_hba *phba, uint16_t vlan_tag)
756 tag = be_cmd_set_vlan(phba, vlan_tag);
758 beiscsi_log(phba, KERN_ERR,
759 (BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX),
760 "BG_%d : VLAN Setting Failed\n");
764 rc = beiscsi_mccq_compl_wait(phba, tag, NULL, NULL);
766 beiscsi_log(phba, KERN_ERR,
767 (BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX),
768 "BS_%d : VLAN MBX Cmd Failed\n");
775 int beiscsi_if_get_info(struct beiscsi_hba *phba, int ip_type,
776 struct be_cmd_get_if_info_resp **if_info)
778 struct be_cmd_get_if_info_req *req;
779 struct be_dma_mem nonemb_cmd;
780 uint32_t ioctl_size = sizeof(struct be_cmd_get_if_info_resp);
783 rc = beiscsi_if_get_handle(phba);
788 rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd,
789 OPCODE_COMMON_ISCSI_NTWK_GET_IF_INFO,
795 req->interface_hndl = phba->interface_handle;
796 req->ip_type = ip_type;
798 /* Allocate memory for if_info */
799 *if_info = kzalloc(ioctl_size, GFP_KERNEL);
801 beiscsi_log(phba, KERN_ERR,
802 BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG,
803 "BG_%d : Memory Allocation Failure\n");
805 /* Free the DMA memory for the IOCTL issuing */
806 pci_free_consistent(phba->ctrl.pdev,
813 rc = mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, *if_info,
816 /* Check if the error is because of Insufficent_Buffer */
819 /* Get the new memory size */
820 ioctl_size = ((struct be_cmd_resp_hdr *)
821 nonemb_cmd.va)->actual_resp_len;
822 ioctl_size += sizeof(struct be_cmd_req_hdr);
824 /* Free the previous allocated DMA memory */
825 pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
829 /* Free the virtual memory */
837 int mgmt_get_nic_conf(struct beiscsi_hba *phba,
838 struct be_cmd_get_nic_conf_resp *nic)
840 struct be_dma_mem nonemb_cmd;
843 rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd,
844 OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG,
849 return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, nic, sizeof(*nic));
854 unsigned int be_cmd_get_initname(struct beiscsi_hba *phba)
857 struct be_mcc_wrb *wrb;
858 struct be_cmd_hba_name *req;
859 struct be_ctrl_info *ctrl = &phba->ctrl;
861 if (mutex_lock_interruptible(&ctrl->mbox_lock))
863 wrb = alloc_mcc_wrb(phba, &tag);
865 mutex_unlock(&ctrl->mbox_lock);
869 req = embedded_payload(wrb);
870 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
871 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI,
872 OPCODE_ISCSI_INI_CFG_GET_HBA_NAME,
875 be_mcc_notify(phba, tag);
876 mutex_unlock(&ctrl->mbox_lock);
880 static void beiscsi_boot_process_compl(struct beiscsi_hba *phba,
883 struct be_cmd_get_boot_target_resp *boot_resp;
884 struct be_cmd_resp_logout_fw_sess *logo_resp;
885 struct be_cmd_get_session_resp *sess_resp;
886 struct be_mcc_wrb *wrb;
887 struct boot_struct *bs;
888 int boot_work, status;
890 if (!test_bit(BEISCSI_HBA_BOOT_WORK, &phba->state)) {
891 __beiscsi_log(phba, KERN_ERR,
892 "BG_%d : %s no boot work %lx\n",
893 __func__, phba->state);
897 if (phba->boot_struct.tag != tag) {
898 __beiscsi_log(phba, KERN_ERR,
899 "BG_%d : %s tag mismatch %d:%d\n",
900 __func__, tag, phba->boot_struct.tag);
903 bs = &phba->boot_struct;
906 switch (bs->action) {
907 case BEISCSI_BOOT_REOPEN_SESS:
908 status = __beiscsi_mcc_compl_status(phba, tag, NULL, NULL);
910 bs->action = BEISCSI_BOOT_GET_SHANDLE;
914 case BEISCSI_BOOT_GET_SHANDLE:
915 status = __beiscsi_mcc_compl_status(phba, tag, &wrb, NULL);
917 boot_resp = embedded_payload(wrb);
918 bs->s_handle = boot_resp->boot_session_handle;
920 if (bs->s_handle == BE_BOOT_INVALID_SHANDLE) {
921 bs->action = BEISCSI_BOOT_REOPEN_SESS;
924 bs->action = BEISCSI_BOOT_GET_SINFO;
927 case BEISCSI_BOOT_GET_SINFO:
928 status = __beiscsi_mcc_compl_status(phba, tag, NULL,
931 sess_resp = bs->nonemb_cmd.va;
932 memcpy(&bs->boot_sess, &sess_resp->session_info,
933 sizeof(struct mgmt_session_info));
934 bs->action = BEISCSI_BOOT_LOGOUT_SESS;
936 __beiscsi_log(phba, KERN_ERR,
937 "BG_%d : get boot session info error : 0x%x\n",
941 pci_free_consistent(phba->ctrl.pdev, bs->nonemb_cmd.size,
942 bs->nonemb_cmd.va, bs->nonemb_cmd.dma);
943 bs->nonemb_cmd.va = NULL;
945 case BEISCSI_BOOT_LOGOUT_SESS:
946 status = __beiscsi_mcc_compl_status(phba, tag, &wrb, NULL);
948 logo_resp = embedded_payload(wrb);
949 if (logo_resp->session_status != BE_SESS_STATUS_CLOSE) {
950 __beiscsi_log(phba, KERN_ERR,
951 "BG_%d : FW boot session logout error : 0x%x\n",
952 logo_resp->session_status);
955 /* continue to create boot_kset even if logout failed? */
956 bs->action = BEISCSI_BOOT_CREATE_KSET;
962 /* clear the tag so no other completion matches this tag */
966 __beiscsi_log(phba, KERN_ERR,
967 "BG_%d : failed to setup boot target: status %d action %d\n",
971 /* wait for next event to start boot_work */
972 clear_bit(BEISCSI_HBA_BOOT_WORK, &phba->state);
975 schedule_work(&phba->boot_work);
979 * beiscsi_boot_logout_sess()- Logout from boot FW session
980 * @phba: Device priv structure instance
983 * the TAG used for MBOX Command
986 unsigned int beiscsi_boot_logout_sess(struct beiscsi_hba *phba)
988 struct be_ctrl_info *ctrl = &phba->ctrl;
989 struct be_mcc_wrb *wrb;
990 struct be_cmd_req_logout_fw_sess *req;
993 mutex_lock(&ctrl->mbox_lock);
994 wrb = alloc_mcc_wrb(phba, &tag);
996 mutex_unlock(&ctrl->mbox_lock);
1000 req = embedded_payload(wrb);
1001 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
1002 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI,
1003 OPCODE_ISCSI_INI_SESSION_LOGOUT_TARGET,
1004 sizeof(struct be_cmd_req_logout_fw_sess));
1005 /* Use the session handle copied into boot_sess */
1006 req->session_handle = phba->boot_struct.boot_sess.session_handle;
1008 phba->boot_struct.tag = tag;
1009 set_bit(MCC_TAG_STATE_ASYNC, &ctrl->ptag_state[tag].tag_state);
1010 ctrl->ptag_state[tag].cbfn = beiscsi_boot_process_compl;
1012 be_mcc_notify(phba, tag);
1013 mutex_unlock(&ctrl->mbox_lock);
1018 * beiscsi_boot_reopen_sess()- Reopen boot session
1019 * @phba: Device priv structure instance
1022 * the TAG used for MBOX Command
1025 unsigned int beiscsi_boot_reopen_sess(struct beiscsi_hba *phba)
1027 struct be_ctrl_info *ctrl = &phba->ctrl;
1028 struct be_mcc_wrb *wrb;
1029 struct be_cmd_reopen_session_req *req;
1032 mutex_lock(&ctrl->mbox_lock);
1033 wrb = alloc_mcc_wrb(phba, &tag);
1035 mutex_unlock(&ctrl->mbox_lock);
1039 req = embedded_payload(wrb);
1040 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
1041 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI,
1042 OPCODE_ISCSI_INI_DRIVER_REOPEN_ALL_SESSIONS,
1043 sizeof(struct be_cmd_reopen_session_resp));
1044 req->reopen_type = BE_REOPEN_BOOT_SESSIONS;
1045 req->session_handle = BE_BOOT_INVALID_SHANDLE;
1047 phba->boot_struct.tag = tag;
1048 set_bit(MCC_TAG_STATE_ASYNC, &ctrl->ptag_state[tag].tag_state);
1049 ctrl->ptag_state[tag].cbfn = beiscsi_boot_process_compl;
1051 be_mcc_notify(phba, tag);
1052 mutex_unlock(&ctrl->mbox_lock);
1058 * beiscsi_boot_get_sinfo()- Get boot session info
1059 * @phba: device priv structure instance
1061 * Fetches the boot_struct.s_handle info from FW.
1063 * the TAG used for MBOX Command
1066 unsigned int beiscsi_boot_get_sinfo(struct beiscsi_hba *phba)
1068 struct be_ctrl_info *ctrl = &phba->ctrl;
1069 struct be_cmd_get_session_resp *resp;
1070 struct be_cmd_get_session_req *req;
1071 struct be_dma_mem *nonemb_cmd;
1072 struct be_mcc_wrb *wrb;
1076 mutex_lock(&ctrl->mbox_lock);
1077 wrb = alloc_mcc_wrb(phba, &tag);
1079 mutex_unlock(&ctrl->mbox_lock);
1083 nonemb_cmd = &phba->boot_struct.nonemb_cmd;
1084 nonemb_cmd->size = sizeof(*resp);
1085 nonemb_cmd->va = pci_alloc_consistent(phba->ctrl.pdev,
1088 if (!nonemb_cmd->va) {
1089 mutex_unlock(&ctrl->mbox_lock);
1093 req = nonemb_cmd->va;
1094 memset(req, 0, sizeof(*req));
1095 sge = nonembedded_sgl(wrb);
1096 be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1);
1097 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI,
1098 OPCODE_ISCSI_INI_SESSION_GET_A_SESSION,
1100 req->session_handle = phba->boot_struct.s_handle;
1101 sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma));
1102 sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF);
1103 sge->len = cpu_to_le32(nonemb_cmd->size);
1105 phba->boot_struct.tag = tag;
1106 set_bit(MCC_TAG_STATE_ASYNC, &ctrl->ptag_state[tag].tag_state);
1107 ctrl->ptag_state[tag].cbfn = beiscsi_boot_process_compl;
1109 be_mcc_notify(phba, tag);
1110 mutex_unlock(&ctrl->mbox_lock);
1114 unsigned int __beiscsi_boot_get_shandle(struct beiscsi_hba *phba, int async)
1116 struct be_ctrl_info *ctrl = &phba->ctrl;
1117 struct be_mcc_wrb *wrb;
1118 struct be_cmd_get_boot_target_req *req;
1121 mutex_lock(&ctrl->mbox_lock);
1122 wrb = alloc_mcc_wrb(phba, &tag);
1124 mutex_unlock(&ctrl->mbox_lock);
1128 req = embedded_payload(wrb);
1129 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
1130 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI,
1131 OPCODE_ISCSI_INI_BOOT_GET_BOOT_TARGET,
1132 sizeof(struct be_cmd_get_boot_target_resp));
1135 phba->boot_struct.tag = tag;
1136 set_bit(MCC_TAG_STATE_ASYNC, &ctrl->ptag_state[tag].tag_state);
1137 ctrl->ptag_state[tag].cbfn = beiscsi_boot_process_compl;
1140 be_mcc_notify(phba, tag);
1141 mutex_unlock(&ctrl->mbox_lock);
1146 * beiscsi_boot_get_shandle()- Get boot session handle
1147 * @phba: device priv structure instance
1148 * @s_handle: session handle returned for boot session.
1155 int beiscsi_boot_get_shandle(struct beiscsi_hba *phba, unsigned int *s_handle)
1157 struct be_cmd_get_boot_target_resp *boot_resp;
1158 struct be_mcc_wrb *wrb;
1162 *s_handle = BE_BOOT_INVALID_SHANDLE;
1163 /* get configured boot session count and handle */
1164 tag = __beiscsi_boot_get_shandle(phba, 0);
1166 beiscsi_log(phba, KERN_ERR,
1167 BEISCSI_LOG_CONFIG | BEISCSI_LOG_INIT,
1168 "BG_%d : Getting Boot Target Info Failed\n");
1172 rc = beiscsi_mccq_compl_wait(phba, tag, &wrb, NULL);
1174 beiscsi_log(phba, KERN_ERR,
1175 BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG,
1176 "BG_%d : MBX CMD get_boot_target Failed\n");
1180 boot_resp = embedded_payload(wrb);
1181 /* check if there are any boot targets configured */
1182 if (!boot_resp->boot_session_count) {
1183 __beiscsi_log(phba, KERN_INFO,
1184 "BG_%d : No boot targets configured\n");
1188 /* only if FW has logged in to the boot target, s_handle is valid */
1189 *s_handle = boot_resp->boot_session_handle;
1194 * beiscsi_drvr_ver_disp()- Display the driver Name and Version
1195 * @dev: ptr to device not used.
1196 * @attr: device attribute, not used.
1197 * @buf: contains formatted text driver name and version
1200 * size of the formatted string
1203 beiscsi_drvr_ver_disp(struct device *dev, struct device_attribute *attr,
1206 return snprintf(buf, PAGE_SIZE, BE_NAME "\n");
1210 * beiscsi_fw_ver_disp()- Display Firmware Version
1211 * @dev: ptr to device not used.
1212 * @attr: device attribute, not used.
1213 * @buf: contains formatted text Firmware version
1216 * size of the formatted string
1219 beiscsi_fw_ver_disp(struct device *dev, struct device_attribute *attr,
1222 struct Scsi_Host *shost = class_to_shost(dev);
1223 struct beiscsi_hba *phba = iscsi_host_priv(shost);
1225 return snprintf(buf, PAGE_SIZE, "%s\n", phba->fw_ver_str);
1229 * beiscsi_active_session_disp()- Display Sessions Active
1230 * @dev: ptr to device not used.
1231 * @attr: device attribute, not used.
1232 * @buf: contains formatted text Session Count
1235 * size of the formatted string
1238 beiscsi_active_session_disp(struct device *dev, struct device_attribute *attr,
1241 struct Scsi_Host *shost = class_to_shost(dev);
1242 struct beiscsi_hba *phba = iscsi_host_priv(shost);
1243 uint16_t avlbl_cids = 0, ulp_num, len = 0, total_cids = 0;
1245 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) {
1246 if (test_bit(ulp_num, (void *)&phba->fw_config.ulp_supported)) {
1247 avlbl_cids = BEISCSI_ULP_AVLBL_CID(phba, ulp_num);
1248 total_cids = BEISCSI_GET_CID_COUNT(phba, ulp_num);
1249 len += snprintf(buf+len, PAGE_SIZE - len,
1250 "ULP%d : %d\n", ulp_num,
1251 (total_cids - avlbl_cids));
1253 len += snprintf(buf+len, PAGE_SIZE - len,
1254 "ULP%d : %d\n", ulp_num, 0);
1261 * beiscsi_free_session_disp()- Display Avaliable Session
1262 * @dev: ptr to device not used.
1263 * @attr: device attribute, not used.
1264 * @buf: contains formatted text Session Count
1267 * size of the formatted string
1270 beiscsi_free_session_disp(struct device *dev, struct device_attribute *attr,
1273 struct Scsi_Host *shost = class_to_shost(dev);
1274 struct beiscsi_hba *phba = iscsi_host_priv(shost);
1275 uint16_t ulp_num, len = 0;
1277 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) {
1278 if (test_bit(ulp_num, (void *)&phba->fw_config.ulp_supported))
1279 len += snprintf(buf+len, PAGE_SIZE - len,
1280 "ULP%d : %d\n", ulp_num,
1281 BEISCSI_ULP_AVLBL_CID(phba, ulp_num));
1283 len += snprintf(buf+len, PAGE_SIZE - len,
1284 "ULP%d : %d\n", ulp_num, 0);
1291 * beiscsi_adap_family_disp()- Display adapter family.
1292 * @dev: ptr to device to get priv structure
1293 * @attr: device attribute, not used.
1294 * @buf: contains formatted text driver name and version
1297 * size of the formatted string
1300 beiscsi_adap_family_disp(struct device *dev, struct device_attribute *attr,
1303 uint16_t dev_id = 0;
1304 struct Scsi_Host *shost = class_to_shost(dev);
1305 struct beiscsi_hba *phba = iscsi_host_priv(shost);
1307 dev_id = phba->pcidev->device;
1312 return snprintf(buf, PAGE_SIZE, "BE2 Adapter Family\n");
1316 return snprintf(buf, PAGE_SIZE, "BE3-R Adapter Family\n");
1319 return snprintf(buf, PAGE_SIZE, "Skyhawk-R Adapter Family\n");
1322 return snprintf(buf, PAGE_SIZE,
1323 "Unknown Adapter Family: 0x%x\n", dev_id);
1329 * beiscsi_phys_port()- Display Physical Port Identifier
1330 * @dev: ptr to device not used.
1331 * @attr: device attribute, not used.
1332 * @buf: contains formatted text port identifier
1335 * size of the formatted string
1338 beiscsi_phys_port_disp(struct device *dev, struct device_attribute *attr,
1341 struct Scsi_Host *shost = class_to_shost(dev);
1342 struct beiscsi_hba *phba = iscsi_host_priv(shost);
1344 return snprintf(buf, PAGE_SIZE, "Port Identifier : %d\n",
1345 phba->fw_config.phys_port);
1348 void beiscsi_offload_cxn_v0(struct beiscsi_offload_params *params,
1349 struct wrb_handle *pwrb_handle,
1350 struct be_mem_descriptor *mem_descr,
1351 struct hwi_wrb_context *pwrb_context)
1353 struct iscsi_wrb *pwrb = pwrb_handle->pwrb;
1355 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb,
1356 max_send_data_segment_length, pwrb,
1357 params->dw[offsetof(struct amap_beiscsi_offload_params,
1358 max_send_data_segment_length) / 32]);
1359 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, type, pwrb,
1360 BE_TGT_CTX_UPDT_CMD);
1361 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb,
1364 params->dw[offsetof(struct amap_beiscsi_offload_params,
1365 first_burst_length) / 32]);
1366 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, erl, pwrb,
1367 (params->dw[offsetof(struct amap_beiscsi_offload_params,
1368 erl) / 32] & OFFLD_PARAMS_ERL));
1369 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, dde, pwrb,
1370 (params->dw[offsetof(struct amap_beiscsi_offload_params,
1371 dde) / 32] & OFFLD_PARAMS_DDE) >> 2);
1372 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, hde, pwrb,
1373 (params->dw[offsetof(struct amap_beiscsi_offload_params,
1374 hde) / 32] & OFFLD_PARAMS_HDE) >> 3);
1375 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, ir2t, pwrb,
1376 (params->dw[offsetof(struct amap_beiscsi_offload_params,
1377 ir2t) / 32] & OFFLD_PARAMS_IR2T) >> 4);
1378 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, imd, pwrb,
1379 (params->dw[offsetof(struct amap_beiscsi_offload_params,
1380 imd) / 32] & OFFLD_PARAMS_IMD) >> 5);
1381 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, stat_sn,
1383 (params->dw[offsetof(struct amap_beiscsi_offload_params,
1384 exp_statsn) / 32] + 1));
1385 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, wrb_idx,
1386 pwrb, pwrb_handle->wrb_index);
1388 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb,
1389 max_burst_length, pwrb, params->dw[offsetof
1390 (struct amap_beiscsi_offload_params,
1391 max_burst_length) / 32]);
1393 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, ptr2nextwrb,
1394 pwrb, pwrb_handle->wrb_index);
1395 if (pwrb_context->plast_wrb)
1396 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb,
1398 pwrb_context->plast_wrb,
1399 pwrb_handle->wrb_index);
1400 pwrb_context->plast_wrb = pwrb;
1402 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb,
1403 session_state, pwrb, 0);
1404 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, compltonack,
1406 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, notpredblq,
1408 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, mode, pwrb,
1411 mem_descr += ISCSI_MEM_GLOBAL_HEADER;
1412 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb,
1413 pad_buffer_addr_hi, pwrb,
1414 mem_descr->mem_array[0].bus_address.u.a32.address_hi);
1415 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb,
1416 pad_buffer_addr_lo, pwrb,
1417 mem_descr->mem_array[0].bus_address.u.a32.address_lo);
1420 void beiscsi_offload_cxn_v2(struct beiscsi_offload_params *params,
1421 struct wrb_handle *pwrb_handle,
1422 struct hwi_wrb_context *pwrb_context)
1424 struct iscsi_wrb *pwrb = pwrb_handle->pwrb;
1426 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
1427 max_burst_length, pwrb, params->dw[offsetof
1428 (struct amap_beiscsi_offload_params,
1429 max_burst_length) / 32]);
1430 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
1432 BE_TGT_CTX_UPDT_CMD);
1433 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
1435 pwrb, pwrb_handle->wrb_index);
1436 if (pwrb_context->plast_wrb)
1437 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
1439 pwrb_context->plast_wrb,
1440 pwrb_handle->wrb_index);
1441 pwrb_context->plast_wrb = pwrb;
1443 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, wrb_idx,
1444 pwrb, pwrb_handle->wrb_index);
1445 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
1446 max_send_data_segment_length, pwrb,
1447 params->dw[offsetof(struct amap_beiscsi_offload_params,
1448 max_send_data_segment_length) / 32]);
1449 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
1450 first_burst_length, pwrb,
1451 params->dw[offsetof(struct amap_beiscsi_offload_params,
1452 first_burst_length) / 32]);
1453 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
1454 max_recv_dataseg_len, pwrb,
1455 params->dw[offsetof(struct amap_beiscsi_offload_params,
1456 max_recv_data_segment_length) / 32]);
1457 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
1458 max_cxns, pwrb, BEISCSI_MAX_CXNS);
1459 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, erl, pwrb,
1460 (params->dw[offsetof(struct amap_beiscsi_offload_params,
1461 erl) / 32] & OFFLD_PARAMS_ERL));
1462 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, dde, pwrb,
1463 (params->dw[offsetof(struct amap_beiscsi_offload_params,
1464 dde) / 32] & OFFLD_PARAMS_DDE) >> 2);
1465 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, hde, pwrb,
1466 (params->dw[offsetof(struct amap_beiscsi_offload_params,
1467 hde) / 32] & OFFLD_PARAMS_HDE) >> 3);
1468 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
1470 (params->dw[offsetof(struct amap_beiscsi_offload_params,
1471 ir2t) / 32] & OFFLD_PARAMS_IR2T) >> 4);
1472 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, imd, pwrb,
1473 (params->dw[offsetof(struct amap_beiscsi_offload_params,
1474 imd) / 32] & OFFLD_PARAMS_IMD) >> 5);
1475 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
1478 (params->dw[offsetof(struct amap_beiscsi_offload_params,
1479 data_seq_inorder) / 32] &
1480 OFFLD_PARAMS_DATA_SEQ_INORDER) >> 6);
1481 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
1484 (params->dw[offsetof(struct amap_beiscsi_offload_params,
1485 pdu_seq_inorder) / 32] &
1486 OFFLD_PARAMS_PDU_SEQ_INORDER) >> 7);
1487 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, max_r2t,
1489 (params->dw[offsetof(struct amap_beiscsi_offload_params,
1491 OFFLD_PARAMS_MAX_R2T) >> 8);
1492 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, stat_sn,
1494 (params->dw[offsetof(struct amap_beiscsi_offload_params,
1495 exp_statsn) / 32] + 1));