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
,
815 sizeof(req
->ip_params
.ip_record
.ip_addr
.addr
));
818 memcpy(req
->ip_params
.ip_record
.ip_addr
.subnet_mask
,
820 sizeof(req
->ip_params
.ip_record
.ip_addr
.subnet_mask
));
822 memcpy(req
->ip_params
.ip_record
.ip_addr
.addr
,
823 if_info
->ip_addr
.addr
,
824 sizeof(req
->ip_params
.ip_record
.ip_addr
.addr
));
826 memcpy(req
->ip_params
.ip_record
.ip_addr
.subnet_mask
,
827 if_info
->ip_addr
.subnet_mask
,
828 sizeof(req
->ip_params
.ip_record
.ip_addr
.subnet_mask
));
831 rc
= mgmt_exec_nonemb_cmd(phba
, &nonemb_cmd
, NULL
, 0);
833 beiscsi_log(phba
, KERN_WARNING
, BEISCSI_LOG_CONFIG
,
834 "BG_%d : Failed to Modify existing IP Address\n");
838 static int mgmt_modify_gateway(struct beiscsi_hba
*phba
, uint8_t *gt_addr
,
839 uint32_t gtway_action
, uint32_t param_len
)
841 struct be_cmd_set_def_gateway_req
*req
;
842 struct be_dma_mem nonemb_cmd
;
846 rt_val
= mgmt_alloc_cmd_data(phba
, &nonemb_cmd
,
847 OPCODE_COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY
,
853 req
->action
= gtway_action
;
854 req
->ip_addr
.ip_type
= BE2_IPV4
;
856 memcpy(req
->ip_addr
.addr
, gt_addr
, sizeof(req
->ip_addr
.addr
));
858 return mgmt_exec_nonemb_cmd(phba
, &nonemb_cmd
, NULL
, 0);
861 int mgmt_set_ip(struct beiscsi_hba
*phba
,
862 struct iscsi_iface_param_info
*ip_param
,
863 struct iscsi_iface_param_info
*subnet_param
,
866 struct be_cmd_get_def_gateway_resp gtway_addr_set
;
867 struct be_cmd_get_if_info_resp if_info
;
868 struct be_cmd_set_dhcp_req
*dhcpreq
;
869 struct be_cmd_rel_dhcp_req
*reldhcp
;
870 struct be_dma_mem nonemb_cmd
;
875 if (mgmt_get_all_if_id(phba
))
878 memset(&if_info
, 0, sizeof(if_info
));
879 ip_type
= (ip_param
->param
== ISCSI_NET_PARAM_IPV6_ADDR
) ?
880 BE2_IPV6
: BE2_IPV4
;
882 rc
= mgmt_get_if_info(phba
, ip_type
, &if_info
);
886 if (boot_proto
== ISCSI_BOOTPROTO_DHCP
) {
887 if (if_info
.dhcp_state
) {
888 beiscsi_log(phba
, KERN_WARNING
, BEISCSI_LOG_CONFIG
,
889 "BG_%d : DHCP Already Enabled\n");
892 /* The ip_param->len is 1 in DHCP case. Setting
893 proper IP len as this it is used while
894 freeing the Static IP.
896 ip_param
->len
= (ip_param
->param
== ISCSI_NET_PARAM_IPV6_ADDR
) ?
897 IP_V6_LEN
: IP_V4_LEN
;
900 if (if_info
.dhcp_state
) {
902 memset(&if_info
, 0, sizeof(if_info
));
903 rc
= mgmt_alloc_cmd_data(phba
, &nonemb_cmd
,
904 OPCODE_COMMON_ISCSI_NTWK_REL_STATELESS_IP_ADDR
,
910 reldhcp
= nonemb_cmd
.va
;
911 reldhcp
->interface_hndl
= phba
->interface_handle
;
912 reldhcp
->ip_type
= ip_type
;
914 rc
= mgmt_exec_nonemb_cmd(phba
, &nonemb_cmd
, NULL
, 0);
916 beiscsi_log(phba
, KERN_WARNING
,
918 "BG_%d : Failed to Delete existing dhcp\n");
924 /* Delete the Static IP Set */
925 if (if_info
.ip_addr
.addr
[0]) {
926 rc
= mgmt_static_ip_modify(phba
, &if_info
, ip_param
, NULL
,
932 /* Delete the Gateway settings if mode change is to DHCP */
933 if (boot_proto
== ISCSI_BOOTPROTO_DHCP
) {
934 memset(>way_addr_set
, 0, sizeof(gtway_addr_set
));
935 rc
= mgmt_get_gateway(phba
, BE2_IPV4
, >way_addr_set
);
937 beiscsi_log(phba
, KERN_WARNING
, BEISCSI_LOG_CONFIG
,
938 "BG_%d : Failed to Get Gateway Addr\n");
942 if (gtway_addr_set
.ip_addr
.addr
[0]) {
943 gtway_addr
= (uint8_t *)>way_addr_set
.ip_addr
.addr
;
944 rc
= mgmt_modify_gateway(phba
, gtway_addr
,
945 IP_ACTION_DEL
, IP_V4_LEN
);
948 beiscsi_log(phba
, KERN_WARNING
,
950 "BG_%d : Failed to clear Gateway Addr Set\n");
956 /* Set Adapter to DHCP/Static Mode */
957 if (boot_proto
== ISCSI_BOOTPROTO_DHCP
) {
958 rc
= mgmt_alloc_cmd_data(phba
, &nonemb_cmd
,
959 OPCODE_COMMON_ISCSI_NTWK_CONFIG_STATELESS_IP_ADDR
,
964 dhcpreq
= nonemb_cmd
.va
;
965 dhcpreq
->flags
= BLOCKING
;
966 dhcpreq
->retry_count
= 1;
967 dhcpreq
->interface_hndl
= phba
->interface_handle
;
968 dhcpreq
->ip_type
= BE2_DHCP_V4
;
970 return mgmt_exec_nonemb_cmd(phba
, &nonemb_cmd
, NULL
, 0);
972 return mgmt_static_ip_modify(phba
, &if_info
, ip_param
,
973 subnet_param
, IP_ACTION_ADD
);
979 int mgmt_set_gateway(struct beiscsi_hba
*phba
,
980 struct iscsi_iface_param_info
*gateway_param
)
982 struct be_cmd_get_def_gateway_resp gtway_addr_set
;
986 memset(>way_addr_set
, 0, sizeof(gtway_addr_set
));
987 rt_val
= mgmt_get_gateway(phba
, BE2_IPV4
, >way_addr_set
);
989 beiscsi_log(phba
, KERN_WARNING
, BEISCSI_LOG_CONFIG
,
990 "BG_%d : Failed to Get Gateway Addr\n");
994 if (gtway_addr_set
.ip_addr
.addr
[0]) {
995 gtway_addr
= (uint8_t *)>way_addr_set
.ip_addr
.addr
;
996 rt_val
= mgmt_modify_gateway(phba
, gtway_addr
, IP_ACTION_DEL
,
999 beiscsi_log(phba
, KERN_WARNING
, BEISCSI_LOG_CONFIG
,
1000 "BG_%d : Failed to clear Gateway Addr Set\n");
1005 gtway_addr
= (uint8_t *)&gateway_param
->value
;
1006 rt_val
= mgmt_modify_gateway(phba
, gtway_addr
, IP_ACTION_ADD
,
1007 gateway_param
->len
);
1010 beiscsi_log(phba
, KERN_WARNING
, BEISCSI_LOG_CONFIG
,
1011 "BG_%d : Failed to Set Gateway Addr\n");
1016 int mgmt_get_gateway(struct beiscsi_hba
*phba
, int ip_type
,
1017 struct be_cmd_get_def_gateway_resp
*gateway
)
1019 struct be_cmd_get_def_gateway_req
*req
;
1020 struct be_dma_mem nonemb_cmd
;
1023 rc
= mgmt_alloc_cmd_data(phba
, &nonemb_cmd
,
1024 OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY
,
1029 req
= nonemb_cmd
.va
;
1030 req
->ip_type
= ip_type
;
1032 return mgmt_exec_nonemb_cmd(phba
, &nonemb_cmd
, gateway
,
1036 int mgmt_get_if_info(struct beiscsi_hba
*phba
, int ip_type
,
1037 struct be_cmd_get_if_info_resp
*if_info
)
1039 struct be_cmd_get_if_info_req
*req
;
1040 struct be_dma_mem nonemb_cmd
;
1043 if (mgmt_get_all_if_id(phba
))
1046 rc
= mgmt_alloc_cmd_data(phba
, &nonemb_cmd
,
1047 OPCODE_COMMON_ISCSI_NTWK_GET_IF_INFO
,
1052 req
= nonemb_cmd
.va
;
1053 req
->interface_hndl
= phba
->interface_handle
;
1054 req
->ip_type
= ip_type
;
1056 return mgmt_exec_nonemb_cmd(phba
, &nonemb_cmd
, if_info
,
1060 int mgmt_get_nic_conf(struct beiscsi_hba
*phba
,
1061 struct be_cmd_get_nic_conf_resp
*nic
)
1063 struct be_dma_mem nonemb_cmd
;
1066 rc
= mgmt_alloc_cmd_data(phba
, &nonemb_cmd
,
1067 OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG
,
1072 return mgmt_exec_nonemb_cmd(phba
, &nonemb_cmd
, nic
, sizeof(*nic
));
1077 unsigned int be_cmd_get_initname(struct beiscsi_hba
*phba
)
1079 unsigned int tag
= 0;
1080 struct be_mcc_wrb
*wrb
;
1081 struct be_cmd_hba_name
*req
;
1082 struct be_ctrl_info
*ctrl
= &phba
->ctrl
;
1084 spin_lock(&ctrl
->mbox_lock
);
1085 tag
= alloc_mcc_tag(phba
);
1087 spin_unlock(&ctrl
->mbox_lock
);
1091 wrb
= wrb_from_mccq(phba
);
1092 req
= embedded_payload(wrb
);
1094 be_wrb_hdr_prepare(wrb
, sizeof(*req
), true, 0);
1095 be_cmd_hdr_prepare(&req
->hdr
, CMD_SUBSYSTEM_ISCSI_INI
,
1096 OPCODE_ISCSI_INI_CFG_GET_HBA_NAME
,
1099 be_mcc_notify(phba
);
1100 spin_unlock(&ctrl
->mbox_lock
);
1104 unsigned int be_cmd_get_port_speed(struct beiscsi_hba
*phba
)
1106 unsigned int tag
= 0;
1107 struct be_mcc_wrb
*wrb
;
1108 struct be_cmd_ntwk_link_status_req
*req
;
1109 struct be_ctrl_info
*ctrl
= &phba
->ctrl
;
1111 spin_lock(&ctrl
->mbox_lock
);
1112 tag
= alloc_mcc_tag(phba
);
1114 spin_unlock(&ctrl
->mbox_lock
);
1118 wrb
= wrb_from_mccq(phba
);
1119 req
= embedded_payload(wrb
);
1121 be_wrb_hdr_prepare(wrb
, sizeof(*req
), true, 0);
1122 be_cmd_hdr_prepare(&req
->hdr
, CMD_SUBSYSTEM_COMMON
,
1123 OPCODE_COMMON_NTWK_LINK_STATUS_QUERY
,
1126 be_mcc_notify(phba
);
1127 spin_unlock(&ctrl
->mbox_lock
);
1132 * be_mgmt_get_boot_shandle()- Get the session handle
1133 * @phba: device priv structure instance
1134 * @s_handle: session handle returned for boot session.
1136 * Get the boot target session handle. In case of
1137 * crashdump mode driver has to issue and MBX Cmd
1138 * for FW to login to boot target
1142 * Failure: Non-Zero value
1145 int be_mgmt_get_boot_shandle(struct beiscsi_hba
*phba
,
1146 unsigned int *s_handle
)
1148 struct be_cmd_get_boot_target_resp
*boot_resp
;
1149 struct be_mcc_wrb
*wrb
;
1151 uint8_t boot_retry
= 3;
1155 /* Get the Boot Target Session Handle and Count*/
1156 tag
= mgmt_get_boot_target(phba
);
1158 beiscsi_log(phba
, KERN_ERR
,
1159 BEISCSI_LOG_CONFIG
| BEISCSI_LOG_INIT
,
1160 "BG_%d : Getting Boot Target Info Failed\n");
1164 rc
= beiscsi_mccq_compl(phba
, tag
, &wrb
, NULL
);
1166 beiscsi_log(phba
, KERN_ERR
,
1167 BEISCSI_LOG_INIT
| BEISCSI_LOG_CONFIG
,
1168 "BG_%d : MBX CMD get_boot_target Failed\n");
1172 boot_resp
= embedded_payload(wrb
);
1174 /* Check if the there are any Boot targets configured */
1175 if (!boot_resp
->boot_session_count
) {
1176 beiscsi_log(phba
, KERN_INFO
,
1177 BEISCSI_LOG_INIT
| BEISCSI_LOG_CONFIG
,
1178 "BG_%d ;No boot targets configured\n");
1182 /* FW returns the session handle of the boot session */
1183 if (boot_resp
->boot_session_handle
!= INVALID_SESS_HANDLE
) {
1184 *s_handle
= boot_resp
->boot_session_handle
;
1188 /* Issue MBX Cmd to FW to login to the boot target */
1189 tag
= mgmt_reopen_session(phba
, BE_REOPEN_BOOT_SESSIONS
,
1190 INVALID_SESS_HANDLE
);
1192 beiscsi_log(phba
, KERN_ERR
,
1193 BEISCSI_LOG_INIT
| BEISCSI_LOG_CONFIG
,
1194 "BG_%d : mgmt_reopen_session Failed\n");
1198 rc
= beiscsi_mccq_compl(phba
, tag
, NULL
, NULL
);
1200 beiscsi_log(phba
, KERN_ERR
,
1201 BEISCSI_LOG_INIT
| BEISCSI_LOG_CONFIG
,
1202 "BG_%d : mgmt_reopen_session Failed");
1205 } while (--boot_retry
);
1207 /* Couldn't log into the boot target */
1208 beiscsi_log(phba
, KERN_ERR
,
1209 BEISCSI_LOG_INIT
| BEISCSI_LOG_CONFIG
,
1210 "BG_%d : Login to Boot Target Failed\n");
1215 * mgmt_set_vlan()- Issue and wait for CMD completion
1216 * @phba: device private structure instance
1217 * @vlan_tag: VLAN tag
1219 * Issue the MBX Cmd and wait for the completion of the
1224 * Failure: Non-Xero Value
1226 int mgmt_set_vlan(struct beiscsi_hba
*phba
,
1231 struct be_mcc_wrb
*wrb
= NULL
;
1233 tag
= be_cmd_set_vlan(phba
, vlan_tag
);
1235 beiscsi_log(phba
, KERN_ERR
,
1236 (BEISCSI_LOG_CONFIG
| BEISCSI_LOG_MBOX
),
1237 "BG_%d : VLAN Setting Failed\n");
1241 rc
= beiscsi_mccq_compl(phba
, tag
, &wrb
, NULL
);
1243 beiscsi_log(phba
, KERN_ERR
,
1244 (BEISCSI_LOG_CONFIG
| BEISCSI_LOG_MBOX
),
1245 "BS_%d : VLAN MBX Cmd Failed\n");
1252 * beiscsi_drvr_ver_disp()- Display the driver Name and Version
1253 * @dev: ptr to device not used.
1254 * @attr: device attribute, not used.
1255 * @buf: contains formatted text driver name and version
1258 * size of the formatted string
1261 beiscsi_drvr_ver_disp(struct device
*dev
, struct device_attribute
*attr
,
1264 return snprintf(buf
, PAGE_SIZE
, BE_NAME
"\n");
1268 * beiscsi_fw_ver_disp()- Display Firmware Version
1269 * @dev: ptr to device not used.
1270 * @attr: device attribute, not used.
1271 * @buf: contains formatted text Firmware version
1274 * size of the formatted string
1277 beiscsi_fw_ver_disp(struct device
*dev
, struct device_attribute
*attr
,
1280 struct Scsi_Host
*shost
= class_to_shost(dev
);
1281 struct beiscsi_hba
*phba
= iscsi_host_priv(shost
);
1283 return snprintf(buf
, PAGE_SIZE
, "%s\n", phba
->fw_ver_str
);
1287 * beiscsi_active_cid_disp()- Display Sessions Active
1288 * @dev: ptr to device not used.
1289 * @attr: device attribute, not used.
1290 * @buf: contains formatted text Session Count
1293 * size of the formatted string
1296 beiscsi_active_cid_disp(struct device
*dev
, struct device_attribute
*attr
,
1299 struct Scsi_Host
*shost
= class_to_shost(dev
);
1300 struct beiscsi_hba
*phba
= iscsi_host_priv(shost
);
1302 return snprintf(buf
, PAGE_SIZE
, "%d\n",
1303 (phba
->params
.cxns_per_ctrl
- phba
->avlbl_cids
));
1307 * beiscsi_adap_family_disp()- Display adapter family.
1308 * @dev: ptr to device to get priv structure
1309 * @attr: device attribute, not used.
1310 * @buf: contains formatted text driver name and version
1313 * size of the formatted string
1316 beiscsi_adap_family_disp(struct device
*dev
, struct device_attribute
*attr
,
1319 uint16_t dev_id
= 0;
1320 struct Scsi_Host
*shost
= class_to_shost(dev
);
1321 struct beiscsi_hba
*phba
= iscsi_host_priv(shost
);
1323 dev_id
= phba
->pcidev
->device
;
1328 return snprintf(buf
, PAGE_SIZE
, "BE2 Adapter Family\n");
1332 return snprintf(buf
, PAGE_SIZE
, "BE3-R Adapter Family\n");
1335 return snprintf(buf
, PAGE_SIZE
, "Skyhawk-R Adapter Family\n");
1338 return snprintf(buf
, PAGE_SIZE
,
1339 "Unknown Adapter Family: 0x%x\n", dev_id
);
1345 void beiscsi_offload_cxn_v0(struct beiscsi_offload_params
*params
,
1346 struct wrb_handle
*pwrb_handle
,
1347 struct be_mem_descriptor
*mem_descr
)
1349 struct iscsi_wrb
*pwrb
= pwrb_handle
->pwrb
;
1351 memset(pwrb
, 0, sizeof(*pwrb
));
1352 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
,
1353 max_send_data_segment_length
, pwrb
,
1354 params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1355 max_send_data_segment_length
) / 32]);
1356 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
, type
, pwrb
,
1357 BE_TGT_CTX_UPDT_CMD
);
1358 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
,
1361 params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1362 first_burst_length
) / 32]);
1363 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
, erl
, pwrb
,
1364 (params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1365 erl
) / 32] & OFFLD_PARAMS_ERL
));
1366 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
, dde
, pwrb
,
1367 (params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1368 dde
) / 32] & OFFLD_PARAMS_DDE
) >> 2);
1369 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
, hde
, pwrb
,
1370 (params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1371 hde
) / 32] & OFFLD_PARAMS_HDE
) >> 3);
1372 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
, ir2t
, pwrb
,
1373 (params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1374 ir2t
) / 32] & OFFLD_PARAMS_IR2T
) >> 4);
1375 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
, imd
, pwrb
,
1376 (params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1377 imd
) / 32] & OFFLD_PARAMS_IMD
) >> 5);
1378 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
, stat_sn
,
1380 (params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1381 exp_statsn
) / 32] + 1));
1382 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
, wrb_idx
,
1383 pwrb
, pwrb_handle
->wrb_index
);
1385 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
,
1386 max_burst_length
, pwrb
, params
->dw
[offsetof
1387 (struct amap_beiscsi_offload_params
,
1388 max_burst_length
) / 32]);
1390 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
, ptr2nextwrb
,
1391 pwrb
, pwrb_handle
->nxt_wrb_index
);
1392 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
,
1393 session_state
, pwrb
, 0);
1394 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
, compltonack
,
1396 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
, notpredblq
,
1398 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
, mode
, pwrb
,
1401 mem_descr
+= ISCSI_MEM_GLOBAL_HEADER
;
1402 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
,
1403 pad_buffer_addr_hi
, pwrb
,
1404 mem_descr
->mem_array
[0].bus_address
.u
.a32
.address_hi
);
1405 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
,
1406 pad_buffer_addr_lo
, pwrb
,
1407 mem_descr
->mem_array
[0].bus_address
.u
.a32
.address_lo
);
1410 void beiscsi_offload_cxn_v2(struct beiscsi_offload_params
*params
,
1411 struct wrb_handle
*pwrb_handle
)
1413 struct iscsi_wrb
*pwrb
= pwrb_handle
->pwrb
;
1415 memset(pwrb
, 0, sizeof(*pwrb
));
1417 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb
,
1418 max_burst_length
, pwrb
, params
->dw
[offsetof
1419 (struct amap_beiscsi_offload_params
,
1420 max_burst_length
) / 32]);
1421 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
,
1422 max_burst_length
, pwrb
, params
->dw
[offsetof
1423 (struct amap_beiscsi_offload_params
,
1424 max_burst_length
) / 32]);
1425 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
,
1427 BE_TGT_CTX_UPDT_CMD
);
1428 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
,
1430 pwrb
, pwrb_handle
->nxt_wrb_index
);
1431 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
, wrb_idx
,
1432 pwrb
, pwrb_handle
->wrb_index
);
1433 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
,
1434 max_send_data_segment_length
, pwrb
,
1435 params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1436 max_send_data_segment_length
) / 32]);
1437 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
,
1438 first_burst_length
, pwrb
,
1439 params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1440 first_burst_length
) / 32]);
1441 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
,
1442 max_recv_dataseg_len
, pwrb
, BEISCSI_MAX_RECV_DATASEG_LEN
);
1443 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
,
1444 max_cxns
, pwrb
, BEISCSI_MAX_CXNS
);
1445 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
, erl
, pwrb
,
1446 (params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1447 erl
) / 32] & OFFLD_PARAMS_ERL
));
1448 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
, dde
, pwrb
,
1449 (params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1450 dde
) / 32] & OFFLD_PARAMS_DDE
) >> 2);
1451 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
, hde
, pwrb
,
1452 (params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1453 hde
) / 32] & OFFLD_PARAMS_HDE
) >> 3);
1454 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
,
1456 (params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1457 ir2t
) / 32] & OFFLD_PARAMS_IR2T
) >> 4);
1458 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
, imd
, pwrb
,
1459 (params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1460 imd
) / 32] & OFFLD_PARAMS_IMD
) >> 5);
1461 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
,
1464 (params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1465 data_seq_inorder
) / 32] &
1466 OFFLD_PARAMS_DATA_SEQ_INORDER
) >> 6);
1467 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
,
1470 (params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1471 pdu_seq_inorder
) / 32] &
1472 OFFLD_PARAMS_PDU_SEQ_INORDER
) >> 7);
1473 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
, max_r2t
,
1475 (params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1477 OFFLD_PARAMS_MAX_R2T
) >> 8);
1478 AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2
, stat_sn
,
1480 (params
->dw
[offsetof(struct amap_beiscsi_offload_params
,
1481 exp_statsn
) / 32] + 1));