2 * Copyright (C) 2005 - 2013 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
);
371 memcpy(phba
->fw_ver_str
, resp
->params
.hba_attribs
.
372 firmware_version_string
, BEISCSI_VER_STRLEN
);
374 beiscsi_log(phba
, KERN_ERR
, BEISCSI_LOG_INIT
,
375 "BG_%d : Failed in mgmt_check_supported_fw\n");
376 spin_unlock(&ctrl
->mbox_lock
);
378 pci_free_consistent(ctrl
->pdev
, nonemb_cmd
.size
,
379 nonemb_cmd
.va
, nonemb_cmd
.dma
);
384 unsigned int mgmt_vendor_specific_fw_cmd(struct be_ctrl_info
*ctrl
,
385 struct beiscsi_hba
*phba
,
387 struct be_dma_mem
*nonemb_cmd
)
389 struct be_cmd_resp_hdr
*resp
;
390 struct be_mcc_wrb
*wrb
= wrb_from_mccq(phba
);
391 struct be_sge
*mcc_sge
= nonembedded_sgl(wrb
);
392 unsigned int tag
= 0;
393 struct iscsi_bsg_request
*bsg_req
= job
->request
;
394 struct be_bsg_vendor_cmd
*req
= nonemb_cmd
->va
;
395 unsigned short region
, sector_size
, sector
, offset
;
397 nonemb_cmd
->size
= job
->request_payload
.payload_len
;
398 memset(nonemb_cmd
->va
, 0, nonemb_cmd
->size
);
399 resp
= nonemb_cmd
->va
;
400 region
= bsg_req
->rqst_data
.h_vendor
.vendor_cmd
[1];
401 sector_size
= bsg_req
->rqst_data
.h_vendor
.vendor_cmd
[2];
402 sector
= bsg_req
->rqst_data
.h_vendor
.vendor_cmd
[3];
403 offset
= bsg_req
->rqst_data
.h_vendor
.vendor_cmd
[4];
404 req
->region
= region
;
405 req
->sector
= sector
;
406 req
->offset
= offset
;
407 spin_lock(&ctrl
->mbox_lock
);
408 memset(wrb
, 0, sizeof(*wrb
));
410 switch (bsg_req
->rqst_data
.h_vendor
.vendor_cmd
[0]) {
411 case BEISCSI_WRITE_FLASH
:
412 offset
= sector
* sector_size
+ offset
;
413 be_cmd_hdr_prepare(&req
->hdr
, CMD_SUBSYSTEM_ISCSI
,
414 OPCODE_COMMON_WRITE_FLASH
, sizeof(*req
));
415 sg_copy_to_buffer(job
->request_payload
.sg_list
,
416 job
->request_payload
.sg_cnt
,
417 nonemb_cmd
->va
+ offset
, job
->request_len
);
419 case BEISCSI_READ_FLASH
:
420 be_cmd_hdr_prepare(&req
->hdr
, CMD_SUBSYSTEM_ISCSI
,
421 OPCODE_COMMON_READ_FLASH
, sizeof(*req
));
424 beiscsi_log(phba
, KERN_WARNING
, BEISCSI_LOG_CONFIG
,
425 "BG_%d : Unsupported cmd = 0x%x\n\n",
426 bsg_req
->rqst_data
.h_vendor
.vendor_cmd
[0]);
428 spin_unlock(&ctrl
->mbox_lock
);
432 tag
= alloc_mcc_tag(phba
);
434 spin_unlock(&ctrl
->mbox_lock
);
438 be_wrb_hdr_prepare(wrb
, nonemb_cmd
->size
, false,
439 job
->request_payload
.sg_cnt
);
440 mcc_sge
->pa_hi
= cpu_to_le32(upper_32_bits(nonemb_cmd
->dma
));
441 mcc_sge
->pa_lo
= cpu_to_le32(nonemb_cmd
->dma
& 0xFFFFFFFF);
442 mcc_sge
->len
= cpu_to_le32(nonemb_cmd
->size
);
447 spin_unlock(&ctrl
->mbox_lock
);
451 int mgmt_epfw_cleanup(struct beiscsi_hba
*phba
, unsigned short chute
)
453 struct be_ctrl_info
*ctrl
= &phba
->ctrl
;
454 struct be_mcc_wrb
*wrb
= wrb_from_mccq(phba
);
455 struct iscsi_cleanup_req
*req
= embedded_payload(wrb
);
458 spin_lock(&ctrl
->mbox_lock
);
459 memset(wrb
, 0, sizeof(*wrb
));
461 be_wrb_hdr_prepare(wrb
, sizeof(*req
), true, 0);
462 be_cmd_hdr_prepare(&req
->hdr
, CMD_SUBSYSTEM_ISCSI
,
463 OPCODE_COMMON_ISCSI_CLEANUP
, sizeof(*req
));
466 req
->hdr_ring_id
= cpu_to_le16(HWI_GET_DEF_HDRQ_ID(phba
));
467 req
->data_ring_id
= cpu_to_le16(HWI_GET_DEF_BUFQ_ID(phba
));
469 status
= be_mcc_notify_wait(phba
);
471 beiscsi_log(phba
, KERN_WARNING
, BEISCSI_LOG_INIT
,
472 "BG_%d : mgmt_epfw_cleanup , FAILED\n");
473 spin_unlock(&ctrl
->mbox_lock
);
477 unsigned int mgmt_invalidate_icds(struct beiscsi_hba
*phba
,
478 struct invalidate_command_table
*inv_tbl
,
479 unsigned int num_invalidate
, unsigned int cid
,
480 struct be_dma_mem
*nonemb_cmd
)
483 struct be_ctrl_info
*ctrl
= &phba
->ctrl
;
484 struct be_mcc_wrb
*wrb
;
486 struct invalidate_commands_params_in
*req
;
487 unsigned int i
, tag
= 0;
489 spin_lock(&ctrl
->mbox_lock
);
490 tag
= alloc_mcc_tag(phba
);
492 spin_unlock(&ctrl
->mbox_lock
);
496 req
= nonemb_cmd
->va
;
497 memset(req
, 0, sizeof(*req
));
498 wrb
= wrb_from_mccq(phba
);
499 sge
= nonembedded_sgl(wrb
);
502 be_wrb_hdr_prepare(wrb
, sizeof(*req
), false, 1);
503 be_cmd_hdr_prepare(&req
->hdr
, CMD_SUBSYSTEM_ISCSI
,
504 OPCODE_COMMON_ISCSI_ERROR_RECOVERY_INVALIDATE_COMMANDS
,
507 req
->cleanup_type
= CMD_ISCSI_COMMAND_INVALIDATE
;
508 for (i
= 0; i
< num_invalidate
; i
++) {
509 req
->table
[i
].icd
= inv_tbl
->icd
;
510 req
->table
[i
].cid
= inv_tbl
->cid
;
514 sge
->pa_hi
= cpu_to_le32(upper_32_bits(nonemb_cmd
->dma
));
515 sge
->pa_lo
= cpu_to_le32(nonemb_cmd
->dma
& 0xFFFFFFFF);
516 sge
->len
= cpu_to_le32(nonemb_cmd
->size
);
519 spin_unlock(&ctrl
->mbox_lock
);
523 unsigned int mgmt_invalidate_connection(struct beiscsi_hba
*phba
,
524 struct beiscsi_endpoint
*beiscsi_ep
,
526 unsigned short issue_reset
,
527 unsigned short savecfg_flag
)
529 struct be_ctrl_info
*ctrl
= &phba
->ctrl
;
530 struct be_mcc_wrb
*wrb
;
531 struct iscsi_invalidate_connection_params_in
*req
;
532 unsigned int tag
= 0;
534 spin_lock(&ctrl
->mbox_lock
);
535 tag
= alloc_mcc_tag(phba
);
537 spin_unlock(&ctrl
->mbox_lock
);
540 wrb
= wrb_from_mccq(phba
);
542 req
= embedded_payload(wrb
);
544 be_wrb_hdr_prepare(wrb
, sizeof(*req
), true, 0);
545 be_cmd_hdr_prepare(&req
->hdr
, CMD_SUBSYSTEM_ISCSI_INI
,
546 OPCODE_ISCSI_INI_DRIVER_INVALIDATE_CONNECTION
,
548 req
->session_handle
= beiscsi_ep
->fw_handle
;
551 req
->cleanup_type
= CMD_ISCSI_CONNECTION_ISSUE_TCP_RST
;
553 req
->cleanup_type
= CMD_ISCSI_CONNECTION_INVALIDATE
;
554 req
->save_cfg
= savecfg_flag
;
556 spin_unlock(&ctrl
->mbox_lock
);
560 unsigned int mgmt_upload_connection(struct beiscsi_hba
*phba
,
561 unsigned short cid
, unsigned int upload_flag
)
563 struct be_ctrl_info
*ctrl
= &phba
->ctrl
;
564 struct be_mcc_wrb
*wrb
;
565 struct tcp_upload_params_in
*req
;
566 unsigned int tag
= 0;
568 spin_lock(&ctrl
->mbox_lock
);
569 tag
= alloc_mcc_tag(phba
);
571 spin_unlock(&ctrl
->mbox_lock
);
574 wrb
= wrb_from_mccq(phba
);
575 req
= embedded_payload(wrb
);
578 be_wrb_hdr_prepare(wrb
, sizeof(*req
), true, 0);
579 be_cmd_hdr_prepare(&req
->hdr
, CMD_COMMON_TCP_UPLOAD
,
580 OPCODE_COMMON_TCP_UPLOAD
, sizeof(*req
));
581 req
->id
= (unsigned short)cid
;
582 req
->upload_type
= (unsigned char)upload_flag
;
584 spin_unlock(&ctrl
->mbox_lock
);
588 int mgmt_open_connection(struct beiscsi_hba
*phba
,
589 struct sockaddr
*dst_addr
,
590 struct beiscsi_endpoint
*beiscsi_ep
,
591 struct be_dma_mem
*nonemb_cmd
)
593 struct hwi_controller
*phwi_ctrlr
;
594 struct hwi_context_memory
*phwi_context
;
595 struct sockaddr_in
*daddr_in
= (struct sockaddr_in
*)dst_addr
;
596 struct sockaddr_in6
*daddr_in6
= (struct sockaddr_in6
*)dst_addr
;
597 struct be_ctrl_info
*ctrl
= &phba
->ctrl
;
598 struct be_mcc_wrb
*wrb
;
599 struct tcp_connect_and_offload_in
*req
;
600 unsigned short def_hdr_id
;
601 unsigned short def_data_id
;
602 struct phys_addr template_address
= { 0, 0 };
603 struct phys_addr
*ptemplate_address
;
604 unsigned int tag
= 0;
606 unsigned short cid
= beiscsi_ep
->ep_cid
;
609 phwi_ctrlr
= phba
->phwi_ctrlr
;
610 phwi_context
= phwi_ctrlr
->phwi_ctxt
;
611 def_hdr_id
= (unsigned short)HWI_GET_DEF_HDRQ_ID(phba
);
612 def_data_id
= (unsigned short)HWI_GET_DEF_BUFQ_ID(phba
);
614 ptemplate_address
= &template_address
;
615 ISCSI_GET_PDU_TEMPLATE_ADDRESS(phba
, ptemplate_address
);
616 spin_lock(&ctrl
->mbox_lock
);
617 tag
= alloc_mcc_tag(phba
);
619 spin_unlock(&ctrl
->mbox_lock
);
622 wrb
= wrb_from_mccq(phba
);
623 memset(wrb
, 0, sizeof(*wrb
));
624 sge
= nonembedded_sgl(wrb
);
626 req
= nonemb_cmd
->va
;
627 memset(req
, 0, sizeof(*req
));
630 be_wrb_hdr_prepare(wrb
, sizeof(*req
), false, 1);
631 be_cmd_hdr_prepare(&req
->hdr
, CMD_SUBSYSTEM_ISCSI
,
632 OPCODE_COMMON_ISCSI_TCP_CONNECT_AND_OFFLOAD
,
634 if (dst_addr
->sa_family
== PF_INET
) {
635 __be32 s_addr
= daddr_in
->sin_addr
.s_addr
;
636 req
->ip_address
.ip_type
= BE2_IPV4
;
637 req
->ip_address
.addr
[0] = s_addr
& 0x000000ff;
638 req
->ip_address
.addr
[1] = (s_addr
& 0x0000ff00) >> 8;
639 req
->ip_address
.addr
[2] = (s_addr
& 0x00ff0000) >> 16;
640 req
->ip_address
.addr
[3] = (s_addr
& 0xff000000) >> 24;
641 req
->tcp_port
= ntohs(daddr_in
->sin_port
);
642 beiscsi_ep
->dst_addr
= daddr_in
->sin_addr
.s_addr
;
643 beiscsi_ep
->dst_tcpport
= ntohs(daddr_in
->sin_port
);
644 beiscsi_ep
->ip_type
= BE2_IPV4
;
645 } else if (dst_addr
->sa_family
== PF_INET6
) {
646 req
->ip_address
.ip_type
= BE2_IPV6
;
647 memcpy(&req
->ip_address
.addr
,
648 &daddr_in6
->sin6_addr
.in6_u
.u6_addr8
, 16);
649 req
->tcp_port
= ntohs(daddr_in6
->sin6_port
);
650 beiscsi_ep
->dst_tcpport
= ntohs(daddr_in6
->sin6_port
);
651 memcpy(&beiscsi_ep
->dst6_addr
,
652 &daddr_in6
->sin6_addr
.in6_u
.u6_addr8
, 16);
653 beiscsi_ep
->ip_type
= BE2_IPV6
;
655 beiscsi_log(phba
, KERN_ERR
, BEISCSI_LOG_CONFIG
,
656 "BG_%d : unknown addr family %d\n",
657 dst_addr
->sa_family
);
658 spin_unlock(&ctrl
->mbox_lock
);
659 free_mcc_tag(&phba
->ctrl
, tag
);
664 i
= phba
->nxt_cqid
++;
665 if (phba
->nxt_cqid
== phba
->num_cpus
)
667 req
->cq_id
= phwi_context
->be_cq
[i
].id
;
668 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
669 "BG_%d : i=%d cq_id=%d\n", i
, req
->cq_id
);
670 req
->defq_id
= def_hdr_id
;
671 req
->hdr_ring_id
= def_hdr_id
;
672 req
->data_ring_id
= def_data_id
;
674 req
->dataout_template_pa
.lo
= ptemplate_address
->lo
;
675 req
->dataout_template_pa
.hi
= ptemplate_address
->hi
;
676 sge
->pa_hi
= cpu_to_le32(upper_32_bits(nonemb_cmd
->dma
));
677 sge
->pa_lo
= cpu_to_le32(nonemb_cmd
->dma
& 0xFFFFFFFF);
678 sge
->len
= cpu_to_le32(nonemb_cmd
->size
);
680 spin_unlock(&ctrl
->mbox_lock
);
684 unsigned int mgmt_get_all_if_id(struct beiscsi_hba
*phba
)
686 struct be_ctrl_info
*ctrl
= &phba
->ctrl
;
687 struct be_mcc_wrb
*wrb
= wrb_from_mbox(&ctrl
->mbox_mem
);
688 struct be_cmd_get_all_if_id_req
*req
= embedded_payload(wrb
);
689 struct be_cmd_get_all_if_id_req
*pbe_allid
= req
;
692 memset(wrb
, 0, sizeof(*wrb
));
694 spin_lock(&ctrl
->mbox_lock
);
696 be_wrb_hdr_prepare(wrb
, sizeof(*req
), true, 0);
697 be_cmd_hdr_prepare(&req
->hdr
, CMD_SUBSYSTEM_ISCSI
,
698 OPCODE_COMMON_ISCSI_NTWK_GET_ALL_IF_ID
,
700 status
= be_mbox_notify(ctrl
);
702 phba
->interface_handle
= pbe_allid
->if_hndl_list
[0];
704 beiscsi_log(phba
, KERN_WARNING
, BEISCSI_LOG_CONFIG
,
705 "BG_%d : Failed in mgmt_get_all_if_id\n");
707 spin_unlock(&ctrl
->mbox_lock
);
713 * mgmt_exec_nonemb_cmd()- Execute Non Embedded MBX Cmd
714 * @phba: Driver priv structure
715 * @nonemb_cmd: Address of the MBX command issued
716 * @resp_buf: Buffer to copy the MBX cmd response
717 * @resp_buf_len: respone lenght to be copied
720 static int mgmt_exec_nonemb_cmd(struct beiscsi_hba
*phba
,
721 struct be_dma_mem
*nonemb_cmd
, void *resp_buf
,
724 struct be_ctrl_info
*ctrl
= &phba
->ctrl
;
725 struct be_mcc_wrb
*wrb
= wrb_from_mccq(phba
);
730 spin_lock(&ctrl
->mbox_lock
);
731 tag
= alloc_mcc_tag(phba
);
733 spin_unlock(&ctrl
->mbox_lock
);
737 memset(wrb
, 0, sizeof(*wrb
));
739 sge
= nonembedded_sgl(wrb
);
741 be_wrb_hdr_prepare(wrb
, nonemb_cmd
->size
, false, 1);
742 sge
->pa_hi
= cpu_to_le32(upper_32_bits(nonemb_cmd
->dma
));
743 sge
->pa_lo
= cpu_to_le32(lower_32_bits(nonemb_cmd
->dma
));
744 sge
->len
= cpu_to_le32(nonemb_cmd
->size
);
747 spin_unlock(&ctrl
->mbox_lock
);
749 rc
= beiscsi_mccq_compl(phba
, tag
, NULL
, nonemb_cmd
->va
);
751 beiscsi_log(phba
, KERN_ERR
,
752 BEISCSI_LOG_CONFIG
| BEISCSI_LOG_MBOX
,
753 "BG_%d : mgmt_exec_nonemb_cmd Failed status\n");
760 memcpy(resp_buf
, nonemb_cmd
->va
, resp_buf_len
);
763 pci_free_consistent(ctrl
->pdev
, nonemb_cmd
->size
,
764 nonemb_cmd
->va
, nonemb_cmd
->dma
);
768 static int mgmt_alloc_cmd_data(struct beiscsi_hba
*phba
, struct be_dma_mem
*cmd
,
769 int iscsi_cmd
, int size
)
771 cmd
->va
= pci_alloc_consistent(phba
->ctrl
.pdev
, size
, &cmd
->dma
);
773 beiscsi_log(phba
, KERN_ERR
, BEISCSI_LOG_CONFIG
,
774 "BG_%d : Failed to allocate memory for if info\n");
777 memset(cmd
->va
, 0, size
);
779 be_cmd_hdr_prepare(cmd
->va
, CMD_SUBSYSTEM_ISCSI
, iscsi_cmd
, size
);
784 mgmt_static_ip_modify(struct beiscsi_hba
*phba
,
785 struct be_cmd_get_if_info_resp
*if_info
,
786 struct iscsi_iface_param_info
*ip_param
,
787 struct iscsi_iface_param_info
*subnet_param
,
790 struct be_cmd_set_ip_addr_req
*req
;
791 struct be_dma_mem nonemb_cmd
;
795 rc
= mgmt_alloc_cmd_data(phba
, &nonemb_cmd
,
796 OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR
,
801 ip_type
= (ip_param
->param
== ISCSI_NET_PARAM_IPV6_ADDR
) ?
802 BE2_IPV6
: BE2_IPV4
;
805 req
->ip_params
.record_entry_count
= 1;
806 req
->ip_params
.ip_record
.action
= ip_action
;
807 req
->ip_params
.ip_record
.interface_hndl
=
808 phba
->interface_handle
;
809 req
->ip_params
.ip_record
.ip_addr
.size_of_structure
=
810 sizeof(struct be_ip_addr_subnet_format
);
811 req
->ip_params
.ip_record
.ip_addr
.ip_type
= ip_type
;
813 if (ip_action
== IP_ACTION_ADD
) {
814 memcpy(req
->ip_params
.ip_record
.ip_addr
.addr
, ip_param
->value
,
818 memcpy(req
->ip_params
.ip_record
.ip_addr
.subnet_mask
,
819 subnet_param
->value
, subnet_param
->len
);
821 memcpy(req
->ip_params
.ip_record
.ip_addr
.addr
,
822 if_info
->ip_addr
.addr
, ip_param
->len
);
824 memcpy(req
->ip_params
.ip_record
.ip_addr
.subnet_mask
,
825 if_info
->ip_addr
.subnet_mask
, ip_param
->len
);
828 rc
= mgmt_exec_nonemb_cmd(phba
, &nonemb_cmd
, NULL
, 0);
830 beiscsi_log(phba
, KERN_WARNING
, BEISCSI_LOG_CONFIG
,
831 "BG_%d : Failed to Modify existing IP Address\n");
835 static int mgmt_modify_gateway(struct beiscsi_hba
*phba
, uint8_t *gt_addr
,
836 uint32_t gtway_action
, uint32_t param_len
)
838 struct be_cmd_set_def_gateway_req
*req
;
839 struct be_dma_mem nonemb_cmd
;
843 rt_val
= mgmt_alloc_cmd_data(phba
, &nonemb_cmd
,
844 OPCODE_COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY
,
850 req
->action
= gtway_action
;
851 req
->ip_addr
.ip_type
= BE2_IPV4
;
853 memcpy(req
->ip_addr
.addr
, gt_addr
, param_len
);
855 return mgmt_exec_nonemb_cmd(phba
, &nonemb_cmd
, NULL
, 0);
858 int mgmt_set_ip(struct beiscsi_hba
*phba
,
859 struct iscsi_iface_param_info
*ip_param
,
860 struct iscsi_iface_param_info
*subnet_param
,
863 struct be_cmd_get_def_gateway_resp gtway_addr_set
;
864 struct be_cmd_get_if_info_resp if_info
;
865 struct be_cmd_set_dhcp_req
*dhcpreq
;
866 struct be_cmd_rel_dhcp_req
*reldhcp
;
867 struct be_dma_mem nonemb_cmd
;
872 if (mgmt_get_all_if_id(phba
))
875 memset(&if_info
, 0, sizeof(if_info
));
876 ip_type
= (ip_param
->param
== ISCSI_NET_PARAM_IPV6_ADDR
) ?
877 BE2_IPV6
: BE2_IPV4
;
879 rc
= mgmt_get_if_info(phba
, ip_type
, &if_info
);
883 if (boot_proto
== ISCSI_BOOTPROTO_DHCP
) {
884 if (if_info
.dhcp_state
) {
885 beiscsi_log(phba
, KERN_WARNING
, BEISCSI_LOG_CONFIG
,
886 "BG_%d : DHCP Already Enabled\n");
889 /* The ip_param->len is 1 in DHCP case. Setting
890 proper IP len as this it is used while
891 freeing the Static IP.
893 ip_param
->len
= (ip_param
->param
== ISCSI_NET_PARAM_IPV6_ADDR
) ?
894 IP_V6_LEN
: IP_V4_LEN
;
897 if (if_info
.dhcp_state
) {
899 memset(&if_info
, 0, sizeof(if_info
));
900 rc
= mgmt_alloc_cmd_data(phba
, &nonemb_cmd
,
901 OPCODE_COMMON_ISCSI_NTWK_REL_STATELESS_IP_ADDR
,
907 reldhcp
= nonemb_cmd
.va
;
908 reldhcp
->interface_hndl
= phba
->interface_handle
;
909 reldhcp
->ip_type
= ip_type
;
911 rc
= mgmt_exec_nonemb_cmd(phba
, &nonemb_cmd
, NULL
, 0);
913 beiscsi_log(phba
, KERN_WARNING
,
915 "BG_%d : Failed to Delete existing dhcp\n");
921 /* Delete the Static IP Set */
922 if (if_info
.ip_addr
.addr
[0]) {
923 rc
= mgmt_static_ip_modify(phba
, &if_info
, ip_param
, NULL
,
929 /* Delete the Gateway settings if mode change is to DHCP */
930 if (boot_proto
== ISCSI_BOOTPROTO_DHCP
) {
931 memset(>way_addr_set
, 0, sizeof(gtway_addr_set
));
932 rc
= mgmt_get_gateway(phba
, BE2_IPV4
, >way_addr_set
);
934 beiscsi_log(phba
, KERN_WARNING
, BEISCSI_LOG_CONFIG
,
935 "BG_%d : Failed to Get Gateway Addr\n");
939 if (gtway_addr_set
.ip_addr
.addr
[0]) {
940 gtway_addr
= (uint8_t *)>way_addr_set
.ip_addr
.addr
;
941 rc
= mgmt_modify_gateway(phba
, gtway_addr
,
942 IP_ACTION_DEL
, IP_V4_LEN
);
945 beiscsi_log(phba
, KERN_WARNING
,
947 "BG_%d : Failed to clear Gateway Addr Set\n");
953 /* Set Adapter to DHCP/Static Mode */
954 if (boot_proto
== ISCSI_BOOTPROTO_DHCP
) {
955 rc
= mgmt_alloc_cmd_data(phba
, &nonemb_cmd
,
956 OPCODE_COMMON_ISCSI_NTWK_CONFIG_STATELESS_IP_ADDR
,
961 dhcpreq
= nonemb_cmd
.va
;
962 dhcpreq
->flags
= BLOCKING
;
963 dhcpreq
->retry_count
= 1;
964 dhcpreq
->interface_hndl
= phba
->interface_handle
;
965 dhcpreq
->ip_type
= BE2_DHCP_V4
;
967 return mgmt_exec_nonemb_cmd(phba
, &nonemb_cmd
, NULL
, 0);
969 return mgmt_static_ip_modify(phba
, &if_info
, ip_param
,
970 subnet_param
, IP_ACTION_ADD
);
976 int mgmt_set_gateway(struct beiscsi_hba
*phba
,
977 struct iscsi_iface_param_info
*gateway_param
)
979 struct be_cmd_get_def_gateway_resp gtway_addr_set
;
983 memset(>way_addr_set
, 0, sizeof(gtway_addr_set
));
984 rt_val
= mgmt_get_gateway(phba
, BE2_IPV4
, >way_addr_set
);
986 beiscsi_log(phba
, KERN_WARNING
, BEISCSI_LOG_CONFIG
,
987 "BG_%d : Failed to Get Gateway Addr\n");
991 if (gtway_addr_set
.ip_addr
.addr
[0]) {
992 gtway_addr
= (uint8_t *)>way_addr_set
.ip_addr
.addr
;
993 rt_val
= mgmt_modify_gateway(phba
, gtway_addr
, IP_ACTION_DEL
,
996 beiscsi_log(phba
, KERN_WARNING
, BEISCSI_LOG_CONFIG
,
997 "BG_%d : Failed to clear Gateway Addr Set\n");
1002 gtway_addr
= (uint8_t *)&gateway_param
->value
;
1003 rt_val
= mgmt_modify_gateway(phba
, gtway_addr
, IP_ACTION_ADD
,
1004 gateway_param
->len
);
1007 beiscsi_log(phba
, KERN_WARNING
, BEISCSI_LOG_CONFIG
,
1008 "BG_%d : Failed to Set Gateway Addr\n");
1013 int mgmt_get_gateway(struct beiscsi_hba
*phba
, int ip_type
,
1014 struct be_cmd_get_def_gateway_resp
*gateway
)
1016 struct be_cmd_get_def_gateway_req
*req
;
1017 struct be_dma_mem nonemb_cmd
;
1020 rc
= mgmt_alloc_cmd_data(phba
, &nonemb_cmd
,
1021 OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY
,
1026 req
= nonemb_cmd
.va
;
1027 req
->ip_type
= ip_type
;
1029 return mgmt_exec_nonemb_cmd(phba
, &nonemb_cmd
, gateway
,
1033 int mgmt_get_if_info(struct beiscsi_hba
*phba
, int ip_type
,
1034 struct be_cmd_get_if_info_resp
*if_info
)
1036 struct be_cmd_get_if_info_req
*req
;
1037 struct be_dma_mem nonemb_cmd
;
1040 if (mgmt_get_all_if_id(phba
))
1043 rc
= mgmt_alloc_cmd_data(phba
, &nonemb_cmd
,
1044 OPCODE_COMMON_ISCSI_NTWK_GET_IF_INFO
,
1049 req
= nonemb_cmd
.va
;
1050 req
->interface_hndl
= phba
->interface_handle
;
1051 req
->ip_type
= ip_type
;
1053 return mgmt_exec_nonemb_cmd(phba
, &nonemb_cmd
, if_info
,
1057 int mgmt_get_nic_conf(struct beiscsi_hba
*phba
,
1058 struct be_cmd_get_nic_conf_resp
*nic
)
1060 struct be_dma_mem nonemb_cmd
;
1063 rc
= mgmt_alloc_cmd_data(phba
, &nonemb_cmd
,
1064 OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG
,
1069 return mgmt_exec_nonemb_cmd(phba
, &nonemb_cmd
, nic
, sizeof(*nic
));
1074 unsigned int be_cmd_get_initname(struct beiscsi_hba
*phba
)
1076 unsigned int tag
= 0;
1077 struct be_mcc_wrb
*wrb
;
1078 struct be_cmd_hba_name
*req
;
1079 struct be_ctrl_info
*ctrl
= &phba
->ctrl
;
1081 spin_lock(&ctrl
->mbox_lock
);
1082 tag
= alloc_mcc_tag(phba
);
1084 spin_unlock(&ctrl
->mbox_lock
);
1088 wrb
= wrb_from_mccq(phba
);
1089 req
= embedded_payload(wrb
);
1091 be_wrb_hdr_prepare(wrb
, sizeof(*req
), true, 0);
1092 be_cmd_hdr_prepare(&req
->hdr
, CMD_SUBSYSTEM_ISCSI_INI
,
1093 OPCODE_ISCSI_INI_CFG_GET_HBA_NAME
,
1096 be_mcc_notify(phba
);
1097 spin_unlock(&ctrl
->mbox_lock
);
1101 unsigned int be_cmd_get_port_speed(struct beiscsi_hba
*phba
)
1103 unsigned int tag
= 0;
1104 struct be_mcc_wrb
*wrb
;
1105 struct be_cmd_ntwk_link_status_req
*req
;
1106 struct be_ctrl_info
*ctrl
= &phba
->ctrl
;
1108 spin_lock(&ctrl
->mbox_lock
);
1109 tag
= alloc_mcc_tag(phba
);
1111 spin_unlock(&ctrl
->mbox_lock
);
1115 wrb
= wrb_from_mccq(phba
);
1116 req
= embedded_payload(wrb
);
1118 be_wrb_hdr_prepare(wrb
, sizeof(*req
), true, 0);
1119 be_cmd_hdr_prepare(&req
->hdr
, CMD_SUBSYSTEM_COMMON
,
1120 OPCODE_COMMON_NTWK_LINK_STATUS_QUERY
,
1123 be_mcc_notify(phba
);
1124 spin_unlock(&ctrl
->mbox_lock
);
1129 * be_mgmt_get_boot_shandle()- Get the session handle
1130 * @phba: device priv structure instance
1131 * @s_handle: session handle returned for boot session.
1133 * Get the boot target session handle. In case of
1134 * crashdump mode driver has to issue and MBX Cmd
1135 * for FW to login to boot target
1139 * Failure: Non-Zero value
1142 int be_mgmt_get_boot_shandle(struct beiscsi_hba
*phba
,
1143 unsigned int *s_handle
)
1145 struct be_cmd_get_boot_target_resp
*boot_resp
;
1146 struct be_mcc_wrb
*wrb
;
1148 uint8_t boot_retry
= 3;
1152 /* Get the Boot Target Session Handle and Count*/
1153 tag
= mgmt_get_boot_target(phba
);
1155 beiscsi_log(phba
, KERN_ERR
,
1156 BEISCSI_LOG_CONFIG
| BEISCSI_LOG_INIT
,
1157 "BG_%d : Getting Boot Target Info Failed\n");
1161 rc
= beiscsi_mccq_compl(phba
, tag
, &wrb
, NULL
);
1163 beiscsi_log(phba
, KERN_ERR
,
1164 BEISCSI_LOG_INIT
| BEISCSI_LOG_CONFIG
,
1165 "BG_%d : MBX CMD get_boot_target Failed\n");
1169 boot_resp
= embedded_payload(wrb
);
1171 /* Check if the there are any Boot targets configured */
1172 if (!boot_resp
->boot_session_count
) {
1173 beiscsi_log(phba
, KERN_INFO
,
1174 BEISCSI_LOG_INIT
| BEISCSI_LOG_CONFIG
,
1175 "BG_%d ;No boot targets configured\n");
1179 /* FW returns the session handle of the boot session */
1180 if (boot_resp
->boot_session_handle
!= INVALID_SESS_HANDLE
) {
1181 *s_handle
= boot_resp
->boot_session_handle
;
1185 /* Issue MBX Cmd to FW to login to the boot target */
1186 tag
= mgmt_reopen_session(phba
, BE_REOPEN_BOOT_SESSIONS
,
1187 INVALID_SESS_HANDLE
);
1189 beiscsi_log(phba
, KERN_ERR
,
1190 BEISCSI_LOG_INIT
| BEISCSI_LOG_CONFIG
,
1191 "BG_%d : mgmt_reopen_session Failed\n");
1195 rc
= beiscsi_mccq_compl(phba
, tag
, NULL
, NULL
);
1197 beiscsi_log(phba
, KERN_ERR
,
1198 BEISCSI_LOG_INIT
| BEISCSI_LOG_CONFIG
,
1199 "BG_%d : mgmt_reopen_session Failed");
1202 } while (--boot_retry
);
1204 /* Couldn't log into the boot target */
1205 beiscsi_log(phba
, KERN_ERR
,
1206 BEISCSI_LOG_INIT
| BEISCSI_LOG_CONFIG
,
1207 "BG_%d : Login to Boot Target Failed\n");
1212 * mgmt_set_vlan()- Issue and wait for CMD completion
1213 * @phba: device private structure instance
1214 * @vlan_tag: VLAN tag
1216 * Issue the MBX Cmd and wait for the completion of the
1221 * Failure: Non-Xero Value
1223 int mgmt_set_vlan(struct beiscsi_hba
*phba
,
1228 struct be_mcc_wrb
*wrb
= NULL
;
1230 tag
= be_cmd_set_vlan(phba
, vlan_tag
);
1232 beiscsi_log(phba
, KERN_ERR
,
1233 (BEISCSI_LOG_CONFIG
| BEISCSI_LOG_MBOX
),
1234 "BG_%d : VLAN Setting Failed\n");
1238 rc
= beiscsi_mccq_compl(phba
, tag
, &wrb
, NULL
);
1240 beiscsi_log(phba
, KERN_ERR
,
1241 (BEISCSI_LOG_CONFIG
| BEISCSI_LOG_MBOX
),
1242 "BS_%d : VLAN MBX Cmd Failed\n");
1249 * beiscsi_drvr_ver_disp()- Display the driver Name and Version
1250 * @dev: ptr to device not used.
1251 * @attr: device attribute, not used.
1252 * @buf: contains formatted text driver name and version
1255 * size of the formatted string
1258 beiscsi_drvr_ver_disp(struct device
*dev
, struct device_attribute
*attr
,
1261 return snprintf(buf
, PAGE_SIZE
, BE_NAME
"\n");
1265 * beiscsi_fw_ver_disp()- Display Firmware Version
1266 * @dev: ptr to device not used.
1267 * @attr: device attribute, not used.
1268 * @buf: contains formatted text Firmware version
1271 * size of the formatted string
1274 beiscsi_fw_ver_disp(struct device
*dev
, struct device_attribute
*attr
,
1277 struct Scsi_Host
*shost
= class_to_shost(dev
);
1278 struct beiscsi_hba
*phba
= iscsi_host_priv(shost
);
1280 return snprintf(buf
, PAGE_SIZE
, "%s\n", phba
->fw_ver_str
);
1284 * beiscsi_active_cid_disp()- Display Sessions Active
1285 * @dev: ptr to device not used.
1286 * @attr: device attribute, not used.
1287 * @buf: contains formatted text Session Count
1290 * size of the formatted string
1293 beiscsi_active_cid_disp(struct device
*dev
, struct device_attribute
*attr
,
1296 struct Scsi_Host
*shost
= class_to_shost(dev
);
1297 struct beiscsi_hba
*phba
= iscsi_host_priv(shost
);
1299 return snprintf(buf
, PAGE_SIZE
, "%d\n",
1300 (phba
->params
.cxns_per_ctrl
- phba
->avlbl_cids
));
1304 * beiscsi_adap_family_disp()- Display adapter family.
1305 * @dev: ptr to device to get priv structure
1306 * @attr: device attribute, not used.
1307 * @buf: contains formatted text driver name and version
1310 * size of the formatted string
1313 beiscsi_adap_family_disp(struct device
*dev
, struct device_attribute
*attr
,
1316 uint16_t dev_id
= 0;
1317 struct Scsi_Host
*shost
= class_to_shost(dev
);
1318 struct beiscsi_hba
*phba
= iscsi_host_priv(shost
);
1320 dev_id
= phba
->pcidev
->device
;
1325 return snprintf(buf
, PAGE_SIZE
, "BE2 Adapter Family\n");
1329 return snprintf(buf
, PAGE_SIZE
, "BE3-R Adapter Family\n");
1332 return snprintf(buf
, PAGE_SIZE
, "Skyhawk-R Adapter Family\n");
1335 return snprintf(buf
, PAGE_SIZE
,
1336 "Unknown Adapter Family: 0x%x\n", dev_id
);
1342 void beiscsi_offload_cxn_v0(struct beiscsi_offload_params
*params
,
1343 struct wrb_handle
*pwrb_handle
,
1344 struct be_mem_descriptor
*mem_descr
)
1346 struct iscsi_wrb
*pwrb
= pwrb_handle
->pwrb
;
1348 memset(pwrb
, 0, sizeof(*pwrb
));
1349 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
,
1350 max_send_data_segment_length
, pwrb
,
1351 params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1352 max_send_data_segment_length
) / 32]);
1353 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
, type
, pwrb
,
1354 BE_TGT_CTX_UPDT_CMD
);
1355 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
,
1358 params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1359 first_burst_length
) / 32]);
1360 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
, erl
, pwrb
,
1361 (params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1362 erl
) / 32] & OFFLD_PARAMS_ERL
));
1363 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
, dde
, pwrb
,
1364 (params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1365 dde
) / 32] & OFFLD_PARAMS_DDE
) >> 2);
1366 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
, hde
, pwrb
,
1367 (params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1368 hde
) / 32] & OFFLD_PARAMS_HDE
) >> 3);
1369 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
, ir2t
, pwrb
,
1370 (params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1371 ir2t
) / 32] & OFFLD_PARAMS_IR2T
) >> 4);
1372 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
, imd
, pwrb
,
1373 (params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1374 imd
) / 32] & OFFLD_PARAMS_IMD
) >> 5);
1375 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
, stat_sn
,
1377 (params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1378 exp_statsn
) / 32] + 1));
1379 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
, wrb_idx
,
1380 pwrb
, pwrb_handle
->wrb_index
);
1382 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
,
1383 max_burst_length
, pwrb
, params
->dw
[offsetof
1384 (struct amap_beiscsi_offload_params
,
1385 max_burst_length
) / 32]);
1387 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
, ptr2nextwrb
,
1388 pwrb
, pwrb_handle
->nxt_wrb_index
);
1389 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
,
1390 session_state
, pwrb
, 0);
1391 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
, compltonack
,
1393 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
, notpredblq
,
1395 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
, mode
, pwrb
,
1398 mem_descr
+= ISCSI_MEM_GLOBAL_HEADER
;
1399 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
,
1400 pad_buffer_addr_hi
, pwrb
,
1401 mem_descr
->mem_array
[0].bus_address
.u
.a32
.address_hi
);
1402 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
,
1403 pad_buffer_addr_lo
, pwrb
,
1404 mem_descr
->mem_array
[0].bus_address
.u
.a32
.address_lo
);
1407 void beiscsi_offload_cxn_v2(struct beiscsi_offload_params
*params
,
1408 struct wrb_handle
*pwrb_handle
)
1410 struct iscsi_wrb
*pwrb
= pwrb_handle
->pwrb
;
1412 memset(pwrb
, 0, sizeof(*pwrb
));
1414 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
,
1415 max_burst_length
, pwrb
, params
->dw
[offsetof
1416 (struct amap_beiscsi_offload_params
,
1417 max_burst_length
) / 32]);
1418 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
,
1419 max_burst_length
, pwrb
, params
->dw
[offsetof
1420 (struct amap_beiscsi_offload_params
,
1421 max_burst_length
) / 32]);
1422 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
,
1424 BE_TGT_CTX_UPDT_CMD
);
1425 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
,
1427 pwrb
, pwrb_handle
->nxt_wrb_index
);
1428 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
, wrb_idx
,
1429 pwrb
, pwrb_handle
->wrb_index
);
1430 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
,
1431 max_send_data_segment_length
, pwrb
,
1432 params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1433 max_send_data_segment_length
) / 32]);
1434 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
,
1435 first_burst_length
, pwrb
,
1436 params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1437 first_burst_length
) / 32]);
1438 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
,
1439 max_recv_dataseg_len
, pwrb
, BEISCSI_MAX_RECV_DATASEG_LEN
);
1440 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
,
1441 max_cxns
, pwrb
, BEISCSI_MAX_CXNS
);
1442 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
, erl
, pwrb
,
1443 (params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1444 erl
) / 32] & OFFLD_PARAMS_ERL
));
1445 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
, dde
, pwrb
,
1446 (params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1447 dde
) / 32] & OFFLD_PARAMS_DDE
) >> 2);
1448 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
, hde
, pwrb
,
1449 (params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1450 hde
) / 32] & OFFLD_PARAMS_HDE
) >> 3);
1451 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
,
1453 (params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1454 ir2t
) / 32] & OFFLD_PARAMS_IR2T
) >> 4);
1455 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
, imd
, pwrb
,
1456 (params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1457 imd
) / 32] & OFFLD_PARAMS_IMD
) >> 5);
1458 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
,
1461 (params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1462 data_seq_inorder
) / 32] &
1463 OFFLD_PARAMS_DATA_SEQ_INORDER
) >> 6);
1464 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
,
1467 (params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1468 pdu_seq_inorder
) / 32] &
1469 OFFLD_PARAMS_PDU_SEQ_INORDER
) >> 7);
1470 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
, max_r2t
,
1472 (params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1474 OFFLD_PARAMS_MAX_R2T
) >> 8);
1475 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
, stat_sn
,
1477 (params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1478 exp_statsn
) / 32] + 1));