2 * Copyright (C) 2005 - 2012 Emulex
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@emulex.com)
12 * Contact Information:
13 * linux-drivers@emulex.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 /* UE Status Low CSR */
28 static const char * const desc_ue_status_low[] = {
63 /* UE Status High CSR */
64 static const char * const desc_ue_status_hi[] = {
100 * beiscsi_ue_detec()- Detect Unrecoverable Error on adapter
101 * @phba: Driver priv structure
103 * Read registers linked to UE and check for the UE status
105 void beiscsi_ue_detect(struct beiscsi_hba *phba)
107 uint32_t ue_hi = 0, ue_lo = 0;
108 uint32_t ue_mask_hi = 0, ue_mask_lo = 0;
111 if (phba->ue_detected)
114 pci_read_config_dword(phba->pcidev,
115 PCICFG_UE_STATUS_LOW, &ue_lo);
116 pci_read_config_dword(phba->pcidev,
117 PCICFG_UE_STATUS_MASK_LOW,
119 pci_read_config_dword(phba->pcidev,
120 PCICFG_UE_STATUS_HIGH,
122 pci_read_config_dword(phba->pcidev,
123 PCICFG_UE_STATUS_MASK_HI,
126 ue_lo = (ue_lo & ~ue_mask_lo);
127 ue_hi = (ue_hi & ~ue_mask_hi);
130 if (ue_lo || ue_hi) {
131 phba->ue_detected = true;
132 beiscsi_log(phba, KERN_ERR,
133 BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX,
134 "BG_%d : Error detected on the adapter\n");
138 for (i = 0; ue_lo; ue_lo >>= 1, i++) {
140 beiscsi_log(phba, KERN_ERR,
142 "BG_%d : UE_LOW %s bit set\n",
143 desc_ue_status_low[i]);
148 for (i = 0; ue_hi; ue_hi >>= 1, i++) {
150 beiscsi_log(phba, KERN_ERR,
152 "BG_%d : UE_HIGH %s bit set\n",
153 desc_ue_status_hi[i]);
159 * mgmt_reopen_session()- Reopen a session based on reopen_type
160 * @phba: Device priv structure instance
161 * @reopen_type: Type of reopen_session FW should do.
162 * @sess_handle: Session Handle of the session to be re-opened
165 * the TAG used for MBOX Command
168 unsigned int mgmt_reopen_session(struct beiscsi_hba *phba,
169 unsigned int reopen_type,
170 unsigned int sess_handle)
172 struct be_ctrl_info *ctrl = &phba->ctrl;
173 struct be_mcc_wrb *wrb;
174 struct be_cmd_reopen_session_req *req;
175 unsigned int tag = 0;
177 beiscsi_log(phba, KERN_INFO,
178 BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX,
179 "BG_%d : In bescsi_get_boot_target\n");
181 spin_lock(&ctrl->mbox_lock);
182 tag = alloc_mcc_tag(phba);
184 spin_unlock(&ctrl->mbox_lock);
188 wrb = wrb_from_mccq(phba);
189 req = embedded_payload(wrb);
191 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
192 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI,
193 OPCODE_ISCSI_INI_DRIVER_REOPEN_ALL_SESSIONS,
194 sizeof(struct be_cmd_reopen_session_resp));
196 /* set the reopen_type,sess_handle */
197 req->reopen_type = reopen_type;
198 req->session_handle = sess_handle;
201 spin_unlock(&ctrl->mbox_lock);
205 unsigned int mgmt_get_boot_target(struct beiscsi_hba *phba)
207 struct be_ctrl_info *ctrl = &phba->ctrl;
208 struct be_mcc_wrb *wrb;
209 struct be_cmd_get_boot_target_req *req;
210 unsigned int tag = 0;
212 beiscsi_log(phba, KERN_INFO,
213 BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX,
214 "BG_%d : In bescsi_get_boot_target\n");
216 spin_lock(&ctrl->mbox_lock);
217 tag = alloc_mcc_tag(phba);
219 spin_unlock(&ctrl->mbox_lock);
223 wrb = wrb_from_mccq(phba);
224 req = embedded_payload(wrb);
226 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
227 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI,
228 OPCODE_ISCSI_INI_BOOT_GET_BOOT_TARGET,
229 sizeof(struct be_cmd_get_boot_target_resp));
232 spin_unlock(&ctrl->mbox_lock);
236 unsigned int mgmt_get_session_info(struct beiscsi_hba *phba,
237 u32 boot_session_handle,
238 struct be_dma_mem *nonemb_cmd)
240 struct be_ctrl_info *ctrl = &phba->ctrl;
241 struct be_mcc_wrb *wrb;
242 unsigned int tag = 0;
243 struct be_cmd_get_session_req *req;
244 struct be_cmd_get_session_resp *resp;
247 beiscsi_log(phba, KERN_INFO,
248 BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX,
249 "BG_%d : In beiscsi_get_session_info\n");
251 spin_lock(&ctrl->mbox_lock);
252 tag = alloc_mcc_tag(phba);
254 spin_unlock(&ctrl->mbox_lock);
258 nonemb_cmd->size = sizeof(*resp);
259 req = nonemb_cmd->va;
260 memset(req, 0, sizeof(*req));
261 wrb = wrb_from_mccq(phba);
262 sge = nonembedded_sgl(wrb);
267 be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1);
268 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI,
269 OPCODE_ISCSI_INI_SESSION_GET_A_SESSION,
271 req->session_handle = boot_session_handle;
272 sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma));
273 sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF);
274 sge->len = cpu_to_le32(nonemb_cmd->size);
277 spin_unlock(&ctrl->mbox_lock);
281 int mgmt_get_fw_config(struct be_ctrl_info *ctrl,
282 struct beiscsi_hba *phba)
284 struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem);
285 struct be_fw_cfg *req = embedded_payload(wrb);
288 spin_lock(&ctrl->mbox_lock);
289 memset(wrb, 0, sizeof(*wrb));
291 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
293 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
294 OPCODE_COMMON_QUERY_FIRMWARE_CONFIG, sizeof(*req));
295 status = be_mbox_notify(ctrl);
297 struct be_fw_cfg *pfw_cfg;
299 phba->fw_config.phys_port = pfw_cfg->phys_port;
300 phba->fw_config.iscsi_icd_start =
301 pfw_cfg->ulp[0].icd_base;
302 phba->fw_config.iscsi_icd_count =
303 pfw_cfg->ulp[0].icd_count;
304 phba->fw_config.iscsi_cid_start =
305 pfw_cfg->ulp[0].sq_base;
306 phba->fw_config.iscsi_cid_count =
307 pfw_cfg->ulp[0].sq_count;
308 if (phba->fw_config.iscsi_cid_count > (BE2_MAX_SESSIONS / 2)) {
309 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
310 "BG_%d : FW reported MAX CXNS as %d\t"
311 "Max Supported = %d.\n",
312 phba->fw_config.iscsi_cid_count,
314 phba->fw_config.iscsi_cid_count = BE2_MAX_SESSIONS / 2;
317 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT,
318 "BG_%d : Failed in mgmt_get_fw_config\n");
321 spin_unlock(&ctrl->mbox_lock);
325 int mgmt_check_supported_fw(struct be_ctrl_info *ctrl,
326 struct beiscsi_hba *phba)
328 struct be_dma_mem nonemb_cmd;
329 struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem);
330 struct be_mgmt_controller_attributes *req;
331 struct be_sge *sge = nonembedded_sgl(wrb);
334 nonemb_cmd.va = pci_alloc_consistent(ctrl->pdev,
335 sizeof(struct be_mgmt_controller_attributes),
337 if (nonemb_cmd.va == NULL) {
338 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
339 "BG_%d : Failed to allocate memory for "
340 "mgmt_check_supported_fw\n");
343 nonemb_cmd.size = sizeof(struct be_mgmt_controller_attributes);
345 memset(req, 0, sizeof(*req));
346 spin_lock(&ctrl->mbox_lock);
347 memset(wrb, 0, sizeof(*wrb));
348 be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1);
349 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
350 OPCODE_COMMON_GET_CNTL_ATTRIBUTES, sizeof(*req));
351 sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd.dma));
352 sge->pa_lo = cpu_to_le32(nonemb_cmd.dma & 0xFFFFFFFF);
353 sge->len = cpu_to_le32(nonemb_cmd.size);
354 status = be_mbox_notify(ctrl);
356 struct be_mgmt_controller_attributes_resp *resp = nonemb_cmd.va;
357 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
358 "BG_%d : Firmware Version of CMD : %s\n"
359 "Firmware Version is : %s\n"
360 "Developer Build, not performing version check...\n",
361 resp->params.hba_attribs
362 .flashrom_version_string,
363 resp->params.hba_attribs.
364 firmware_version_string);
366 phba->fw_config.iscsi_features =
367 resp->params.hba_attribs.iscsi_features;
368 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
369 "BM_%d : phba->fw_config.iscsi_features = %d\n",
370 phba->fw_config.iscsi_features);
372 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
373 "BG_%d : Failed in mgmt_check_supported_fw\n");
374 spin_unlock(&ctrl->mbox_lock);
376 pci_free_consistent(ctrl->pdev, nonemb_cmd.size,
377 nonemb_cmd.va, nonemb_cmd.dma);
382 unsigned int mgmt_vendor_specific_fw_cmd(struct be_ctrl_info *ctrl,
383 struct beiscsi_hba *phba,
385 struct be_dma_mem *nonemb_cmd)
387 struct be_cmd_resp_hdr *resp;
388 struct be_mcc_wrb *wrb = wrb_from_mccq(phba);
389 struct be_sge *mcc_sge = nonembedded_sgl(wrb);
390 unsigned int tag = 0;
391 struct iscsi_bsg_request *bsg_req = job->request;
392 struct be_bsg_vendor_cmd *req = nonemb_cmd->va;
393 unsigned short region, sector_size, sector, offset;
395 nonemb_cmd->size = job->request_payload.payload_len;
396 memset(nonemb_cmd->va, 0, nonemb_cmd->size);
397 resp = nonemb_cmd->va;
398 region = bsg_req->rqst_data.h_vendor.vendor_cmd[1];
399 sector_size = bsg_req->rqst_data.h_vendor.vendor_cmd[2];
400 sector = bsg_req->rqst_data.h_vendor.vendor_cmd[3];
401 offset = bsg_req->rqst_data.h_vendor.vendor_cmd[4];
402 req->region = region;
403 req->sector = sector;
404 req->offset = offset;
405 spin_lock(&ctrl->mbox_lock);
406 memset(wrb, 0, sizeof(*wrb));
408 switch (bsg_req->rqst_data.h_vendor.vendor_cmd[0]) {
409 case BEISCSI_WRITE_FLASH:
410 offset = sector * sector_size + offset;
411 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI,
412 OPCODE_COMMON_WRITE_FLASH, sizeof(*req));
413 sg_copy_to_buffer(job->request_payload.sg_list,
414 job->request_payload.sg_cnt,
415 nonemb_cmd->va + offset, job->request_len);
417 case BEISCSI_READ_FLASH:
418 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI,
419 OPCODE_COMMON_READ_FLASH, sizeof(*req));
422 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
423 "BG_%d : Unsupported cmd = 0x%x\n\n",
424 bsg_req->rqst_data.h_vendor.vendor_cmd[0]);
426 spin_unlock(&ctrl->mbox_lock);
430 tag = alloc_mcc_tag(phba);
432 spin_unlock(&ctrl->mbox_lock);
436 be_wrb_hdr_prepare(wrb, nonemb_cmd->size, false,
437 job->request_payload.sg_cnt);
438 mcc_sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma));
439 mcc_sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF);
440 mcc_sge->len = cpu_to_le32(nonemb_cmd->size);
445 spin_unlock(&ctrl->mbox_lock);
449 int mgmt_epfw_cleanup(struct beiscsi_hba *phba, unsigned short chute)
451 struct be_ctrl_info *ctrl = &phba->ctrl;
452 struct be_mcc_wrb *wrb = wrb_from_mccq(phba);
453 struct iscsi_cleanup_req *req = embedded_payload(wrb);
456 spin_lock(&ctrl->mbox_lock);
457 memset(wrb, 0, sizeof(*wrb));
459 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
460 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI,
461 OPCODE_COMMON_ISCSI_CLEANUP, sizeof(*req));
464 req->hdr_ring_id = cpu_to_le16(HWI_GET_DEF_HDRQ_ID(phba));
465 req->data_ring_id = cpu_to_le16(HWI_GET_DEF_BUFQ_ID(phba));
467 status = be_mcc_notify_wait(phba);
469 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT,
470 "BG_%d : mgmt_epfw_cleanup , FAILED\n");
471 spin_unlock(&ctrl->mbox_lock);
475 unsigned int mgmt_invalidate_icds(struct beiscsi_hba *phba,
476 struct invalidate_command_table *inv_tbl,
477 unsigned int num_invalidate, unsigned int cid,
478 struct be_dma_mem *nonemb_cmd)
481 struct be_ctrl_info *ctrl = &phba->ctrl;
482 struct be_mcc_wrb *wrb;
484 struct invalidate_commands_params_in *req;
485 unsigned int i, tag = 0;
487 spin_lock(&ctrl->mbox_lock);
488 tag = alloc_mcc_tag(phba);
490 spin_unlock(&ctrl->mbox_lock);
494 req = nonemb_cmd->va;
495 memset(req, 0, sizeof(*req));
496 wrb = wrb_from_mccq(phba);
497 sge = nonembedded_sgl(wrb);
500 be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1);
501 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI,
502 OPCODE_COMMON_ISCSI_ERROR_RECOVERY_INVALIDATE_COMMANDS,
505 req->cleanup_type = CMD_ISCSI_COMMAND_INVALIDATE;
506 for (i = 0; i < num_invalidate; i++) {
507 req->table[i].icd = inv_tbl->icd;
508 req->table[i].cid = inv_tbl->cid;
512 sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma));
513 sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF);
514 sge->len = cpu_to_le32(nonemb_cmd->size);
517 spin_unlock(&ctrl->mbox_lock);
521 unsigned int mgmt_invalidate_connection(struct beiscsi_hba *phba,
522 struct beiscsi_endpoint *beiscsi_ep,
524 unsigned short issue_reset,
525 unsigned short savecfg_flag)
527 struct be_ctrl_info *ctrl = &phba->ctrl;
528 struct be_mcc_wrb *wrb;
529 struct iscsi_invalidate_connection_params_in *req;
530 unsigned int tag = 0;
532 spin_lock(&ctrl->mbox_lock);
533 tag = alloc_mcc_tag(phba);
535 spin_unlock(&ctrl->mbox_lock);
538 wrb = wrb_from_mccq(phba);
540 req = embedded_payload(wrb);
542 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
543 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI,
544 OPCODE_ISCSI_INI_DRIVER_INVALIDATE_CONNECTION,
546 req->session_handle = beiscsi_ep->fw_handle;
549 req->cleanup_type = CMD_ISCSI_CONNECTION_ISSUE_TCP_RST;
551 req->cleanup_type = CMD_ISCSI_CONNECTION_INVALIDATE;
552 req->save_cfg = savecfg_flag;
554 spin_unlock(&ctrl->mbox_lock);
558 unsigned int mgmt_upload_connection(struct beiscsi_hba *phba,
559 unsigned short cid, unsigned int upload_flag)
561 struct be_ctrl_info *ctrl = &phba->ctrl;
562 struct be_mcc_wrb *wrb;
563 struct tcp_upload_params_in *req;
564 unsigned int tag = 0;
566 spin_lock(&ctrl->mbox_lock);
567 tag = alloc_mcc_tag(phba);
569 spin_unlock(&ctrl->mbox_lock);
572 wrb = wrb_from_mccq(phba);
573 req = embedded_payload(wrb);
576 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
577 be_cmd_hdr_prepare(&req->hdr, CMD_COMMON_TCP_UPLOAD,
578 OPCODE_COMMON_TCP_UPLOAD, sizeof(*req));
579 req->id = (unsigned short)cid;
580 req->upload_type = (unsigned char)upload_flag;
582 spin_unlock(&ctrl->mbox_lock);
586 int mgmt_open_connection(struct beiscsi_hba *phba,
587 struct sockaddr *dst_addr,
588 struct beiscsi_endpoint *beiscsi_ep,
589 struct be_dma_mem *nonemb_cmd)
591 struct hwi_controller *phwi_ctrlr;
592 struct hwi_context_memory *phwi_context;
593 struct sockaddr_in *daddr_in = (struct sockaddr_in *)dst_addr;
594 struct sockaddr_in6 *daddr_in6 = (struct sockaddr_in6 *)dst_addr;
595 struct be_ctrl_info *ctrl = &phba->ctrl;
596 struct be_mcc_wrb *wrb;
597 struct tcp_connect_and_offload_in *req;
598 unsigned short def_hdr_id;
599 unsigned short def_data_id;
600 struct phys_addr template_address = { 0, 0 };
601 struct phys_addr *ptemplate_address;
602 unsigned int tag = 0;
604 unsigned short cid = beiscsi_ep->ep_cid;
607 phwi_ctrlr = phba->phwi_ctrlr;
608 phwi_context = phwi_ctrlr->phwi_ctxt;
609 def_hdr_id = (unsigned short)HWI_GET_DEF_HDRQ_ID(phba);
610 def_data_id = (unsigned short)HWI_GET_DEF_BUFQ_ID(phba);
612 ptemplate_address = &template_address;
613 ISCSI_GET_PDU_TEMPLATE_ADDRESS(phba, ptemplate_address);
614 spin_lock(&ctrl->mbox_lock);
615 tag = alloc_mcc_tag(phba);
617 spin_unlock(&ctrl->mbox_lock);
620 wrb = wrb_from_mccq(phba);
621 memset(wrb, 0, sizeof(*wrb));
622 sge = nonembedded_sgl(wrb);
624 req = nonemb_cmd->va;
625 memset(req, 0, sizeof(*req));
628 be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1);
629 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI,
630 OPCODE_COMMON_ISCSI_TCP_CONNECT_AND_OFFLOAD,
632 if (dst_addr->sa_family == PF_INET) {
633 __be32 s_addr = daddr_in->sin_addr.s_addr;
634 req->ip_address.ip_type = BE2_IPV4;
635 req->ip_address.addr[0] = s_addr & 0x000000ff;
636 req->ip_address.addr[1] = (s_addr & 0x0000ff00) >> 8;
637 req->ip_address.addr[2] = (s_addr & 0x00ff0000) >> 16;
638 req->ip_address.addr[3] = (s_addr & 0xff000000) >> 24;
639 req->tcp_port = ntohs(daddr_in->sin_port);
640 beiscsi_ep->dst_addr = daddr_in->sin_addr.s_addr;
641 beiscsi_ep->dst_tcpport = ntohs(daddr_in->sin_port);
642 beiscsi_ep->ip_type = BE2_IPV4;
643 } else if (dst_addr->sa_family == PF_INET6) {
644 req->ip_address.ip_type = BE2_IPV6;
645 memcpy(&req->ip_address.addr,
646 &daddr_in6->sin6_addr.in6_u.u6_addr8, 16);
647 req->tcp_port = ntohs(daddr_in6->sin6_port);
648 beiscsi_ep->dst_tcpport = ntohs(daddr_in6->sin6_port);
649 memcpy(&beiscsi_ep->dst6_addr,
650 &daddr_in6->sin6_addr.in6_u.u6_addr8, 16);
651 beiscsi_ep->ip_type = BE2_IPV6;
653 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
654 "BG_%d : unknown addr family %d\n",
655 dst_addr->sa_family);
656 spin_unlock(&ctrl->mbox_lock);
657 free_mcc_tag(&phba->ctrl, tag);
662 i = phba->nxt_cqid++;
663 if (phba->nxt_cqid == phba->num_cpus)
665 req->cq_id = phwi_context->be_cq[i].id;
666 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
667 "BG_%d : i=%d cq_id=%d\n", i, req->cq_id);
668 req->defq_id = def_hdr_id;
669 req->hdr_ring_id = def_hdr_id;
670 req->data_ring_id = def_data_id;
672 req->dataout_template_pa.lo = ptemplate_address->lo;
673 req->dataout_template_pa.hi = ptemplate_address->hi;
674 sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma));
675 sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF);
676 sge->len = cpu_to_le32(nonemb_cmd->size);
678 spin_unlock(&ctrl->mbox_lock);
682 unsigned int mgmt_get_all_if_id(struct beiscsi_hba *phba)
684 struct be_ctrl_info *ctrl = &phba->ctrl;
685 struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem);
686 struct be_cmd_get_all_if_id_req *req = embedded_payload(wrb);
687 struct be_cmd_get_all_if_id_req *pbe_allid = req;
690 memset(wrb, 0, sizeof(*wrb));
692 spin_lock(&ctrl->mbox_lock);
694 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
695 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI,
696 OPCODE_COMMON_ISCSI_NTWK_GET_ALL_IF_ID,
698 status = be_mbox_notify(ctrl);
700 phba->interface_handle = pbe_allid->if_hndl_list[0];
702 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
703 "BG_%d : Failed in mgmt_get_all_if_id\n");
705 spin_unlock(&ctrl->mbox_lock);
711 * mgmt_exec_nonemb_cmd()- Execute Non Embedded MBX Cmd
712 * @phba: Driver priv structure
713 * @nonemb_cmd: Address of the MBX command issued
714 * @resp_buf: Buffer to copy the MBX cmd response
715 * @resp_buf_len: respone lenght to be copied
718 static int mgmt_exec_nonemb_cmd(struct beiscsi_hba *phba,
719 struct be_dma_mem *nonemb_cmd, void *resp_buf,
722 struct be_ctrl_info *ctrl = &phba->ctrl;
723 struct be_mcc_wrb *wrb = wrb_from_mccq(phba);
728 spin_lock(&ctrl->mbox_lock);
729 tag = alloc_mcc_tag(phba);
731 spin_unlock(&ctrl->mbox_lock);
735 memset(wrb, 0, sizeof(*wrb));
737 sge = nonembedded_sgl(wrb);
739 be_wrb_hdr_prepare(wrb, nonemb_cmd->size, false, 1);
740 sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma));
741 sge->pa_lo = cpu_to_le32(lower_32_bits(nonemb_cmd->dma));
742 sge->len = cpu_to_le32(nonemb_cmd->size);
745 spin_unlock(&ctrl->mbox_lock);
747 rc = beiscsi_mccq_compl(phba, tag, NULL, nonemb_cmd->va);
749 beiscsi_log(phba, KERN_ERR,
750 BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX,
751 "BG_%d : mgmt_exec_nonemb_cmd Failed status\n");
758 memcpy(resp_buf, nonemb_cmd->va, resp_buf_len);
761 pci_free_consistent(ctrl->pdev, nonemb_cmd->size,
762 nonemb_cmd->va, nonemb_cmd->dma);
766 static int mgmt_alloc_cmd_data(struct beiscsi_hba *phba, struct be_dma_mem *cmd,
767 int iscsi_cmd, int size)
769 cmd->va = pci_alloc_consistent(phba->ctrl.pdev, size, &cmd->dma);
771 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
772 "BG_%d : Failed to allocate memory for if info\n");
775 memset(cmd->va, 0, size);
777 be_cmd_hdr_prepare(cmd->va, CMD_SUBSYSTEM_ISCSI, iscsi_cmd, size);
782 mgmt_static_ip_modify(struct beiscsi_hba *phba,
783 struct be_cmd_get_if_info_resp *if_info,
784 struct iscsi_iface_param_info *ip_param,
785 struct iscsi_iface_param_info *subnet_param,
788 struct be_cmd_set_ip_addr_req *req;
789 struct be_dma_mem nonemb_cmd;
793 rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd,
794 OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR,
799 ip_type = (ip_param->param == ISCSI_NET_PARAM_IPV6_ADDR) ?
800 BE2_IPV6 : BE2_IPV4 ;
803 req->ip_params.record_entry_count = 1;
804 req->ip_params.ip_record.action = ip_action;
805 req->ip_params.ip_record.interface_hndl =
806 phba->interface_handle;
807 req->ip_params.ip_record.ip_addr.size_of_structure =
808 sizeof(struct be_ip_addr_subnet_format);
809 req->ip_params.ip_record.ip_addr.ip_type = ip_type;
811 if (ip_action == IP_ACTION_ADD) {
812 memcpy(req->ip_params.ip_record.ip_addr.addr, ip_param->value,
816 memcpy(req->ip_params.ip_record.ip_addr.subnet_mask,
817 subnet_param->value, subnet_param->len);
819 memcpy(req->ip_params.ip_record.ip_addr.addr,
820 if_info->ip_addr.addr, ip_param->len);
822 memcpy(req->ip_params.ip_record.ip_addr.subnet_mask,
823 if_info->ip_addr.subnet_mask, ip_param->len);
826 rc = mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0);
828 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
829 "BG_%d : Failed to Modify existing IP Address\n");
833 static int mgmt_modify_gateway(struct beiscsi_hba *phba, uint8_t *gt_addr,
834 uint32_t gtway_action, uint32_t param_len)
836 struct be_cmd_set_def_gateway_req *req;
837 struct be_dma_mem nonemb_cmd;
841 rt_val = mgmt_alloc_cmd_data(phba, &nonemb_cmd,
842 OPCODE_COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY,
848 req->action = gtway_action;
849 req->ip_addr.ip_type = BE2_IPV4;
851 memcpy(req->ip_addr.addr, gt_addr, param_len);
853 return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0);
856 int mgmt_set_ip(struct beiscsi_hba *phba,
857 struct iscsi_iface_param_info *ip_param,
858 struct iscsi_iface_param_info *subnet_param,
861 struct be_cmd_get_def_gateway_resp gtway_addr_set;
862 struct be_cmd_get_if_info_resp if_info;
863 struct be_cmd_set_dhcp_req *dhcpreq;
864 struct be_cmd_rel_dhcp_req *reldhcp;
865 struct be_dma_mem nonemb_cmd;
870 if (mgmt_get_all_if_id(phba))
873 memset(&if_info, 0, sizeof(if_info));
874 ip_type = (ip_param->param == ISCSI_NET_PARAM_IPV6_ADDR) ?
875 BE2_IPV6 : BE2_IPV4 ;
877 rc = mgmt_get_if_info(phba, ip_type, &if_info);
881 if (boot_proto == ISCSI_BOOTPROTO_DHCP) {
882 if (if_info.dhcp_state) {
883 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
884 "BG_%d : DHCP Already Enabled\n");
887 /* The ip_param->len is 1 in DHCP case. Setting
888 proper IP len as this it is used while
889 freeing the Static IP.
891 ip_param->len = (ip_param->param == ISCSI_NET_PARAM_IPV6_ADDR) ?
892 IP_V6_LEN : IP_V4_LEN;
895 if (if_info.dhcp_state) {
897 memset(&if_info, 0, sizeof(if_info));
898 rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd,
899 OPCODE_COMMON_ISCSI_NTWK_REL_STATELESS_IP_ADDR,
905 reldhcp = nonemb_cmd.va;
906 reldhcp->interface_hndl = phba->interface_handle;
907 reldhcp->ip_type = ip_type;
909 rc = mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0);
911 beiscsi_log(phba, KERN_WARNING,
913 "BG_%d : Failed to Delete existing dhcp\n");
919 /* Delete the Static IP Set */
920 if (if_info.ip_addr.addr[0]) {
921 rc = mgmt_static_ip_modify(phba, &if_info, ip_param, NULL,
927 /* Delete the Gateway settings if mode change is to DHCP */
928 if (boot_proto == ISCSI_BOOTPROTO_DHCP) {
929 memset(>way_addr_set, 0, sizeof(gtway_addr_set));
930 rc = mgmt_get_gateway(phba, BE2_IPV4, >way_addr_set);
932 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
933 "BG_%d : Failed to Get Gateway Addr\n");
937 if (gtway_addr_set.ip_addr.addr[0]) {
938 gtway_addr = (uint8_t *)>way_addr_set.ip_addr.addr;
939 rc = mgmt_modify_gateway(phba, gtway_addr,
940 IP_ACTION_DEL, IP_V4_LEN);
943 beiscsi_log(phba, KERN_WARNING,
945 "BG_%d : Failed to clear Gateway Addr Set\n");
951 /* Set Adapter to DHCP/Static Mode */
952 if (boot_proto == ISCSI_BOOTPROTO_DHCP) {
953 rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd,
954 OPCODE_COMMON_ISCSI_NTWK_CONFIG_STATELESS_IP_ADDR,
959 dhcpreq = nonemb_cmd.va;
960 dhcpreq->flags = BLOCKING;
961 dhcpreq->retry_count = 1;
962 dhcpreq->interface_hndl = phba->interface_handle;
963 dhcpreq->ip_type = BE2_DHCP_V4;
965 return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0);
967 return mgmt_static_ip_modify(phba, &if_info, ip_param,
968 subnet_param, IP_ACTION_ADD);
974 int mgmt_set_gateway(struct beiscsi_hba *phba,
975 struct iscsi_iface_param_info *gateway_param)
977 struct be_cmd_get_def_gateway_resp gtway_addr_set;
981 memset(>way_addr_set, 0, sizeof(gtway_addr_set));
982 rt_val = mgmt_get_gateway(phba, BE2_IPV4, >way_addr_set);
984 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
985 "BG_%d : Failed to Get Gateway Addr\n");
989 if (gtway_addr_set.ip_addr.addr[0]) {
990 gtway_addr = (uint8_t *)>way_addr_set.ip_addr.addr;
991 rt_val = mgmt_modify_gateway(phba, gtway_addr, IP_ACTION_DEL,
994 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
995 "BG_%d : Failed to clear Gateway Addr Set\n");
1000 gtway_addr = (uint8_t *)&gateway_param->value;
1001 rt_val = mgmt_modify_gateway(phba, gtway_addr, IP_ACTION_ADD,
1002 gateway_param->len);
1005 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
1006 "BG_%d : Failed to Set Gateway Addr\n");
1011 int mgmt_get_gateway(struct beiscsi_hba *phba, int ip_type,
1012 struct be_cmd_get_def_gateway_resp *gateway)
1014 struct be_cmd_get_def_gateway_req *req;
1015 struct be_dma_mem nonemb_cmd;
1018 rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd,
1019 OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY,
1024 req = nonemb_cmd.va;
1025 req->ip_type = ip_type;
1027 return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, gateway,
1031 int mgmt_get_if_info(struct beiscsi_hba *phba, int ip_type,
1032 struct be_cmd_get_if_info_resp *if_info)
1034 struct be_cmd_get_if_info_req *req;
1035 struct be_dma_mem nonemb_cmd;
1038 if (mgmt_get_all_if_id(phba))
1041 rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd,
1042 OPCODE_COMMON_ISCSI_NTWK_GET_IF_INFO,
1047 req = nonemb_cmd.va;
1048 req->interface_hndl = phba->interface_handle;
1049 req->ip_type = ip_type;
1051 return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, if_info,
1055 int mgmt_get_nic_conf(struct beiscsi_hba *phba,
1056 struct be_cmd_get_nic_conf_resp *nic)
1058 struct be_dma_mem nonemb_cmd;
1061 rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd,
1062 OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG,
1067 return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, nic, sizeof(*nic));
1072 unsigned int be_cmd_get_initname(struct beiscsi_hba *phba)
1074 unsigned int tag = 0;
1075 struct be_mcc_wrb *wrb;
1076 struct be_cmd_hba_name *req;
1077 struct be_ctrl_info *ctrl = &phba->ctrl;
1079 spin_lock(&ctrl->mbox_lock);
1080 tag = alloc_mcc_tag(phba);
1082 spin_unlock(&ctrl->mbox_lock);
1086 wrb = wrb_from_mccq(phba);
1087 req = embedded_payload(wrb);
1089 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
1090 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI,
1091 OPCODE_ISCSI_INI_CFG_GET_HBA_NAME,
1094 be_mcc_notify(phba);
1095 spin_unlock(&ctrl->mbox_lock);
1099 unsigned int be_cmd_get_port_speed(struct beiscsi_hba *phba)
1101 unsigned int tag = 0;
1102 struct be_mcc_wrb *wrb;
1103 struct be_cmd_ntwk_link_status_req *req;
1104 struct be_ctrl_info *ctrl = &phba->ctrl;
1106 spin_lock(&ctrl->mbox_lock);
1107 tag = alloc_mcc_tag(phba);
1109 spin_unlock(&ctrl->mbox_lock);
1113 wrb = wrb_from_mccq(phba);
1114 req = embedded_payload(wrb);
1116 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
1117 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
1118 OPCODE_COMMON_NTWK_LINK_STATUS_QUERY,
1121 be_mcc_notify(phba);
1122 spin_unlock(&ctrl->mbox_lock);
1127 * be_mgmt_get_boot_shandle()- Get the session handle
1128 * @phba: device priv structure instance
1129 * @s_handle: session handle returned for boot session.
1131 * Get the boot target session handle. In case of
1132 * crashdump mode driver has to issue and MBX Cmd
1133 * for FW to login to boot target
1137 * Failure: Non-Zero value
1140 int be_mgmt_get_boot_shandle(struct beiscsi_hba *phba,
1141 unsigned int *s_handle)
1143 struct be_cmd_get_boot_target_resp *boot_resp;
1144 struct be_mcc_wrb *wrb;
1146 uint8_t boot_retry = 3;
1150 /* Get the Boot Target Session Handle and Count*/
1151 tag = mgmt_get_boot_target(phba);
1153 beiscsi_log(phba, KERN_ERR,
1154 BEISCSI_LOG_CONFIG | BEISCSI_LOG_INIT,
1155 "BG_%d : Getting Boot Target Info Failed\n");
1159 rc = beiscsi_mccq_compl(phba, tag, &wrb, NULL);
1161 beiscsi_log(phba, KERN_ERR,
1162 BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG,
1163 "BG_%d : MBX CMD get_boot_target Failed\n");
1167 boot_resp = embedded_payload(wrb);
1169 /* Check if the there are any Boot targets configured */
1170 if (!boot_resp->boot_session_count) {
1171 beiscsi_log(phba, KERN_INFO,
1172 BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG,
1173 "BG_%d ;No boot targets configured\n");
1177 /* FW returns the session handle of the boot session */
1178 if (boot_resp->boot_session_handle != INVALID_SESS_HANDLE) {
1179 *s_handle = boot_resp->boot_session_handle;
1183 /* Issue MBX Cmd to FW to login to the boot target */
1184 tag = mgmt_reopen_session(phba, BE_REOPEN_BOOT_SESSIONS,
1185 INVALID_SESS_HANDLE);
1187 beiscsi_log(phba, KERN_ERR,
1188 BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG,
1189 "BG_%d : mgmt_reopen_session Failed\n");
1193 rc = beiscsi_mccq_compl(phba, tag, NULL, NULL);
1195 beiscsi_log(phba, KERN_ERR,
1196 BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG,
1197 "BG_%d : mgmt_reopen_session Failed");
1200 } while (--boot_retry);
1202 /* Couldn't log into the boot target */
1203 beiscsi_log(phba, KERN_ERR,
1204 BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG,
1205 "BG_%d : Login to Boot Target Failed\n");
1210 * mgmt_set_vlan()- Issue and wait for CMD completion
1211 * @phba: device private structure instance
1212 * @vlan_tag: VLAN tag
1214 * Issue the MBX Cmd and wait for the completion of the
1219 * Failure: Non-Xero Value
1221 int mgmt_set_vlan(struct beiscsi_hba *phba,
1226 struct be_mcc_wrb *wrb = NULL;
1228 tag = be_cmd_set_vlan(phba, vlan_tag);
1230 beiscsi_log(phba, KERN_ERR,
1231 (BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX),
1232 "BG_%d : VLAN Setting Failed\n");
1236 rc = beiscsi_mccq_compl(phba, tag, &wrb, NULL);
1238 beiscsi_log(phba, KERN_ERR,
1239 (BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX),
1240 "BS_%d : VLAN MBX Cmd Failed\n");
1247 * beiscsi_drvr_ver_disp()- Display the driver Name and Version
1248 * @dev: ptr to device not used.
1249 * @attr: device attribute, not used.
1250 * @buf: contains formatted text driver name and version
1253 * size of the formatted string
1256 beiscsi_drvr_ver_disp(struct device *dev, struct device_attribute *attr,
1259 return snprintf(buf, PAGE_SIZE, BE_NAME "\n");
1263 * beiscsi_adap_family_disp()- Display adapter family.
1264 * @dev: ptr to device to get priv structure
1265 * @attr: device attribute, not used.
1266 * @buf: contains formatted text driver name and version
1269 * size of the formatted string
1272 beiscsi_adap_family_disp(struct device *dev, struct device_attribute *attr,
1275 uint16_t dev_id = 0;
1276 struct Scsi_Host *shost = class_to_shost(dev);
1277 struct beiscsi_hba *phba = iscsi_host_priv(shost);
1279 dev_id = phba->pcidev->device;
1284 return snprintf(buf, PAGE_SIZE, "BE2 Adapter Family\n");
1288 return snprintf(buf, PAGE_SIZE, "BE3-R Adapter Family\n");
1291 return snprintf(buf, PAGE_SIZE, "Skyhawk-R Adapter Family\n");
1294 return snprintf(buf, PAGE_SIZE,
1295 "Unkown Adapter Family: 0x%x\n", dev_id);
1301 void beiscsi_offload_cxn_v0(struct beiscsi_offload_params *params,
1302 struct wrb_handle *pwrb_handle,
1303 struct be_mem_descriptor *mem_descr)
1305 struct iscsi_wrb *pwrb = pwrb_handle->pwrb;
1307 memset(pwrb, 0, sizeof(*pwrb));
1308 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb,
1309 max_send_data_segment_length, pwrb,
1310 params->dw[offsetof(struct amap_beiscsi_offload_params,
1311 max_send_data_segment_length) / 32]);
1312 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, type, pwrb,
1313 BE_TGT_CTX_UPDT_CMD);
1314 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb,
1317 params->dw[offsetof(struct amap_beiscsi_offload_params,
1318 first_burst_length) / 32]);
1319 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, erl, pwrb,
1320 (params->dw[offsetof(struct amap_beiscsi_offload_params,
1321 erl) / 32] & OFFLD_PARAMS_ERL));
1322 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, dde, pwrb,
1323 (params->dw[offsetof(struct amap_beiscsi_offload_params,
1324 dde) / 32] & OFFLD_PARAMS_DDE) >> 2);
1325 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, hde, pwrb,
1326 (params->dw[offsetof(struct amap_beiscsi_offload_params,
1327 hde) / 32] & OFFLD_PARAMS_HDE) >> 3);
1328 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, ir2t, pwrb,
1329 (params->dw[offsetof(struct amap_beiscsi_offload_params,
1330 ir2t) / 32] & OFFLD_PARAMS_IR2T) >> 4);
1331 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, imd, pwrb,
1332 (params->dw[offsetof(struct amap_beiscsi_offload_params,
1333 imd) / 32] & OFFLD_PARAMS_IMD) >> 5);
1334 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, stat_sn,
1336 (params->dw[offsetof(struct amap_beiscsi_offload_params,
1337 exp_statsn) / 32] + 1));
1338 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, wrb_idx,
1339 pwrb, pwrb_handle->wrb_index);
1341 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb,
1342 max_burst_length, pwrb, params->dw[offsetof
1343 (struct amap_beiscsi_offload_params,
1344 max_burst_length) / 32]);
1346 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, ptr2nextwrb,
1347 pwrb, pwrb_handle->nxt_wrb_index);
1348 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb,
1349 session_state, pwrb, 0);
1350 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, compltonack,
1352 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, notpredblq,
1354 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, mode, pwrb,
1357 mem_descr += ISCSI_MEM_GLOBAL_HEADER;
1358 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb,
1359 pad_buffer_addr_hi, pwrb,
1360 mem_descr->mem_array[0].bus_address.u.a32.address_hi);
1361 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb,
1362 pad_buffer_addr_lo, pwrb,
1363 mem_descr->mem_array[0].bus_address.u.a32.address_lo);
1366 void beiscsi_offload_cxn_v2(struct beiscsi_offload_params *params,
1367 struct wrb_handle *pwrb_handle)
1369 struct iscsi_wrb *pwrb = pwrb_handle->pwrb;
1371 memset(pwrb, 0, sizeof(*pwrb));
1373 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb,
1374 max_burst_length, pwrb, params->dw[offsetof
1375 (struct amap_beiscsi_offload_params,
1376 max_burst_length) / 32]);
1377 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
1378 max_burst_length, pwrb, params->dw[offsetof
1379 (struct amap_beiscsi_offload_params,
1380 max_burst_length) / 32]);
1381 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
1383 BE_TGT_CTX_UPDT_CMD);
1384 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
1386 pwrb, pwrb_handle->nxt_wrb_index);
1387 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, wrb_idx,
1388 pwrb, pwrb_handle->wrb_index);
1389 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
1390 max_send_data_segment_length, pwrb,
1391 params->dw[offsetof(struct amap_beiscsi_offload_params,
1392 max_send_data_segment_length) / 32]);
1393 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
1394 first_burst_length, pwrb,
1395 params->dw[offsetof(struct amap_beiscsi_offload_params,
1396 first_burst_length) / 32]);
1397 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
1398 max_recv_dataseg_len, pwrb, BEISCSI_MAX_RECV_DATASEG_LEN);
1399 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
1400 max_cxns, pwrb, BEISCSI_MAX_CXNS);
1401 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, erl, pwrb,
1402 (params->dw[offsetof(struct amap_beiscsi_offload_params,
1403 erl) / 32] & OFFLD_PARAMS_ERL));
1404 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, dde, pwrb,
1405 (params->dw[offsetof(struct amap_beiscsi_offload_params,
1406 dde) / 32] & OFFLD_PARAMS_DDE) >> 2);
1407 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, hde, pwrb,
1408 (params->dw[offsetof(struct amap_beiscsi_offload_params,
1409 hde) / 32] & OFFLD_PARAMS_HDE) >> 3);
1410 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
1412 (params->dw[offsetof(struct amap_beiscsi_offload_params,
1413 ir2t) / 32] & OFFLD_PARAMS_IR2T) >> 4);
1414 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, imd, pwrb,
1415 (params->dw[offsetof(struct amap_beiscsi_offload_params,
1416 imd) / 32] & OFFLD_PARAMS_IMD) >> 5);
1417 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
1420 (params->dw[offsetof(struct amap_beiscsi_offload_params,
1421 data_seq_inorder) / 32] &
1422 OFFLD_PARAMS_DATA_SEQ_INORDER) >> 6);
1423 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
1426 (params->dw[offsetof(struct amap_beiscsi_offload_params,
1427 pdu_seq_inorder) / 32] &
1428 OFFLD_PARAMS_PDU_SEQ_INORDER) >> 7);
1429 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, max_r2t,
1431 (params->dw[offsetof(struct amap_beiscsi_offload_params,
1433 OFFLD_PARAMS_MAX_R2T) >> 8);
1434 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, stat_sn,
1436 (params->dw[offsetof(struct amap_beiscsi_offload_params,
1437 exp_statsn) / 32] + 1));