2 * QLogic Fibre Channel HBA Driver
3 * Copyright (c) 2003-2012 QLogic Corporation
5 * See LICENSE.qla2xxx for copyright and licensing details.
9 #include <linux/kthread.h>
10 #include <linux/vmalloc.h>
11 #include <linux/delay.h>
13 /* BSG support for ELS/CT pass through */
15 qla2x00_bsg_job_done(void *data
, void *ptr
, int res
)
17 srb_t
*sp
= (srb_t
*)ptr
;
18 struct scsi_qla_host
*vha
= (scsi_qla_host_t
*)data
;
19 struct fc_bsg_job
*bsg_job
= sp
->u
.bsg_job
;
21 bsg_job
->reply
->result
= res
;
22 bsg_job
->job_done(bsg_job
);
27 qla2x00_bsg_sp_free(void *data
, void *ptr
)
29 srb_t
*sp
= (srb_t
*)ptr
;
30 struct scsi_qla_host
*vha
= sp
->fcport
->vha
;
31 struct fc_bsg_job
*bsg_job
= sp
->u
.bsg_job
;
32 struct qla_hw_data
*ha
= vha
->hw
;
34 dma_unmap_sg(&ha
->pdev
->dev
, bsg_job
->request_payload
.sg_list
,
35 bsg_job
->request_payload
.sg_cnt
, DMA_TO_DEVICE
);
37 dma_unmap_sg(&ha
->pdev
->dev
, bsg_job
->reply_payload
.sg_list
,
38 bsg_job
->reply_payload
.sg_cnt
, DMA_FROM_DEVICE
);
40 if (sp
->type
== SRB_CT_CMD
||
41 sp
->type
== SRB_ELS_CMD_HST
)
43 qla2x00_rel_sp(vha
, sp
);
47 qla24xx_fcp_prio_cfg_valid(scsi_qla_host_t
*vha
,
48 struct qla_fcp_prio_cfg
*pri_cfg
, uint8_t flag
)
50 int i
, ret
, num_valid
;
52 struct qla_fcp_prio_entry
*pri_entry
;
53 uint32_t *bcode_val_ptr
, bcode_val
;
57 bcode
= (uint8_t *)pri_cfg
;
58 bcode_val_ptr
= (uint32_t *)pri_cfg
;
59 bcode_val
= (uint32_t)(*bcode_val_ptr
);
61 if (bcode_val
== 0xFFFFFFFF) {
62 /* No FCP Priority config data in flash */
63 ql_dbg(ql_dbg_user
, vha
, 0x7051,
64 "No FCP Priority config data.\n");
68 if (bcode
[0] != 'H' || bcode
[1] != 'Q' || bcode
[2] != 'O' ||
70 /* Invalid FCP priority data header*/
71 ql_dbg(ql_dbg_user
, vha
, 0x7052,
72 "Invalid FCP Priority data header. bcode=0x%x.\n",
79 pri_entry
= &pri_cfg
->entry
[0];
80 for (i
= 0; i
< pri_cfg
->num_entries
; i
++) {
81 if (pri_entry
->flags
& FCP_PRIO_ENTRY_TAG_VALID
)
87 /* No valid FCP priority data entries */
88 ql_dbg(ql_dbg_user
, vha
, 0x7053,
89 "No valid FCP Priority data entries.\n");
92 /* FCP priority data is valid */
93 ql_dbg(ql_dbg_user
, vha
, 0x7054,
94 "Valid FCP priority data. num entries = %d.\n",
102 qla24xx_proc_fcp_prio_cfg_cmd(struct fc_bsg_job
*bsg_job
)
104 struct Scsi_Host
*host
= bsg_job
->shost
;
105 scsi_qla_host_t
*vha
= shost_priv(host
);
106 struct qla_hw_data
*ha
= vha
->hw
;
111 if (!(IS_QLA24XX_TYPE(ha
) || IS_QLA25XX(ha
) || IS_QLA82XX(ha
))) {
113 goto exit_fcp_prio_cfg
;
116 /* Get the sub command */
117 oper
= bsg_job
->request
->rqst_data
.h_vendor
.vendor_cmd
[1];
119 /* Only set config is allowed if config memory is not allocated */
120 if (!ha
->fcp_prio_cfg
&& (oper
!= QLFC_FCP_PRIO_SET_CONFIG
)) {
122 goto exit_fcp_prio_cfg
;
125 case QLFC_FCP_PRIO_DISABLE
:
126 if (ha
->flags
.fcp_prio_enabled
) {
127 ha
->flags
.fcp_prio_enabled
= 0;
128 ha
->fcp_prio_cfg
->attributes
&=
129 ~FCP_PRIO_ATTR_ENABLE
;
130 qla24xx_update_all_fcp_prio(vha
);
131 bsg_job
->reply
->result
= DID_OK
;
134 bsg_job
->reply
->result
= (DID_ERROR
<< 16);
135 goto exit_fcp_prio_cfg
;
139 case QLFC_FCP_PRIO_ENABLE
:
140 if (!ha
->flags
.fcp_prio_enabled
) {
141 if (ha
->fcp_prio_cfg
) {
142 ha
->flags
.fcp_prio_enabled
= 1;
143 ha
->fcp_prio_cfg
->attributes
|=
144 FCP_PRIO_ATTR_ENABLE
;
145 qla24xx_update_all_fcp_prio(vha
);
146 bsg_job
->reply
->result
= DID_OK
;
149 bsg_job
->reply
->result
= (DID_ERROR
<< 16);
150 goto exit_fcp_prio_cfg
;
155 case QLFC_FCP_PRIO_GET_CONFIG
:
156 len
= bsg_job
->reply_payload
.payload_len
;
157 if (!len
|| len
> FCP_PRIO_CFG_SIZE
) {
159 bsg_job
->reply
->result
= (DID_ERROR
<< 16);
160 goto exit_fcp_prio_cfg
;
163 bsg_job
->reply
->result
= DID_OK
;
164 bsg_job
->reply
->reply_payload_rcv_len
=
166 bsg_job
->reply_payload
.sg_list
,
167 bsg_job
->reply_payload
.sg_cnt
, ha
->fcp_prio_cfg
,
172 case QLFC_FCP_PRIO_SET_CONFIG
:
173 len
= bsg_job
->request_payload
.payload_len
;
174 if (!len
|| len
> FCP_PRIO_CFG_SIZE
) {
175 bsg_job
->reply
->result
= (DID_ERROR
<< 16);
177 goto exit_fcp_prio_cfg
;
180 if (!ha
->fcp_prio_cfg
) {
181 ha
->fcp_prio_cfg
= vmalloc(FCP_PRIO_CFG_SIZE
);
182 if (!ha
->fcp_prio_cfg
) {
183 ql_log(ql_log_warn
, vha
, 0x7050,
184 "Unable to allocate memory for fcp prio "
185 "config data (%x).\n", FCP_PRIO_CFG_SIZE
);
186 bsg_job
->reply
->result
= (DID_ERROR
<< 16);
188 goto exit_fcp_prio_cfg
;
192 memset(ha
->fcp_prio_cfg
, 0, FCP_PRIO_CFG_SIZE
);
193 sg_copy_to_buffer(bsg_job
->request_payload
.sg_list
,
194 bsg_job
->request_payload
.sg_cnt
, ha
->fcp_prio_cfg
,
197 /* validate fcp priority data */
199 if (!qla24xx_fcp_prio_cfg_valid(vha
,
200 (struct qla_fcp_prio_cfg
*) ha
->fcp_prio_cfg
, 1)) {
201 bsg_job
->reply
->result
= (DID_ERROR
<< 16);
203 /* If buffer was invalidatic int
204 * fcp_prio_cfg is of no use
206 vfree(ha
->fcp_prio_cfg
);
207 ha
->fcp_prio_cfg
= NULL
;
208 goto exit_fcp_prio_cfg
;
211 ha
->flags
.fcp_prio_enabled
= 0;
212 if (ha
->fcp_prio_cfg
->attributes
& FCP_PRIO_ATTR_ENABLE
)
213 ha
->flags
.fcp_prio_enabled
= 1;
214 qla24xx_update_all_fcp_prio(vha
);
215 bsg_job
->reply
->result
= DID_OK
;
223 bsg_job
->job_done(bsg_job
);
228 qla2x00_process_els(struct fc_bsg_job
*bsg_job
)
230 struct fc_rport
*rport
;
231 fc_port_t
*fcport
= NULL
;
232 struct Scsi_Host
*host
;
233 scsi_qla_host_t
*vha
;
234 struct qla_hw_data
*ha
;
237 int req_sg_cnt
, rsp_sg_cnt
;
238 int rval
= (DRIVER_ERROR
<< 16);
239 uint16_t nextlid
= 0;
241 if (bsg_job
->request
->msgcode
== FC_BSG_RPT_ELS
) {
242 rport
= bsg_job
->rport
;
243 fcport
= *(fc_port_t
**) rport
->dd_data
;
244 host
= rport_to_shost(rport
);
245 vha
= shost_priv(host
);
247 type
= "FC_BSG_RPT_ELS";
249 host
= bsg_job
->shost
;
250 vha
= shost_priv(host
);
252 type
= "FC_BSG_HST_ELS_NOLOGIN";
255 /* pass through is supported only for ISP 4Gb or higher */
256 if (!IS_FWI2_CAPABLE(ha
)) {
257 ql_dbg(ql_dbg_user
, vha
, 0x7001,
258 "ELS passthru not supported for ISP23xx based adapters.\n");
263 /* Multiple SG's are not supported for ELS requests */
264 if (bsg_job
->request_payload
.sg_cnt
> 1 ||
265 bsg_job
->reply_payload
.sg_cnt
> 1) {
266 ql_dbg(ql_dbg_user
, vha
, 0x7002,
267 "Multiple SG's are not suppored for ELS requests, "
268 "request_sg_cnt=%x reply_sg_cnt=%x.\n",
269 bsg_job
->request_payload
.sg_cnt
,
270 bsg_job
->reply_payload
.sg_cnt
);
275 /* ELS request for rport */
276 if (bsg_job
->request
->msgcode
== FC_BSG_RPT_ELS
) {
277 /* make sure the rport is logged in,
278 * if not perform fabric login
280 if (qla2x00_fabric_login(vha
, fcport
, &nextlid
)) {
281 ql_dbg(ql_dbg_user
, vha
, 0x7003,
282 "Failed to login port %06X for ELS passthru.\n",
288 /* Allocate a dummy fcport structure, since functions
289 * preparing the IOCB and mailbox command retrieves port
290 * specific information from fcport structure. For Host based
291 * ELS commands there will be no fcport structure allocated
293 fcport
= qla2x00_alloc_fcport(vha
, GFP_KERNEL
);
299 /* Initialize all required fields of fcport */
301 fcport
->d_id
.b
.al_pa
=
302 bsg_job
->request
->rqst_data
.h_els
.port_id
[0];
303 fcport
->d_id
.b
.area
=
304 bsg_job
->request
->rqst_data
.h_els
.port_id
[1];
305 fcport
->d_id
.b
.domain
=
306 bsg_job
->request
->rqst_data
.h_els
.port_id
[2];
308 (fcport
->d_id
.b
.al_pa
== 0xFD) ?
309 NPH_FABRIC_CONTROLLER
: NPH_F_PORT
;
312 if (!vha
->flags
.online
) {
313 ql_log(ql_log_warn
, vha
, 0x7005, "Host not online.\n");
319 dma_map_sg(&ha
->pdev
->dev
, bsg_job
->request_payload
.sg_list
,
320 bsg_job
->request_payload
.sg_cnt
, DMA_TO_DEVICE
);
323 goto done_free_fcport
;
326 rsp_sg_cnt
= dma_map_sg(&ha
->pdev
->dev
, bsg_job
->reply_payload
.sg_list
,
327 bsg_job
->reply_payload
.sg_cnt
, DMA_FROM_DEVICE
);
330 goto done_free_fcport
;
333 if ((req_sg_cnt
!= bsg_job
->request_payload
.sg_cnt
) ||
334 (rsp_sg_cnt
!= bsg_job
->reply_payload
.sg_cnt
)) {
335 ql_log(ql_log_warn
, vha
, 0x7008,
336 "dma mapping resulted in different sg counts, "
337 "request_sg_cnt: %x dma_request_sg_cnt:%x reply_sg_cnt:%x "
338 "dma_reply_sg_cnt:%x.\n", bsg_job
->request_payload
.sg_cnt
,
339 req_sg_cnt
, bsg_job
->reply_payload
.sg_cnt
, rsp_sg_cnt
);
344 /* Alloc SRB structure */
345 sp
= qla2x00_get_sp(vha
, fcport
, GFP_KERNEL
);
352 (bsg_job
->request
->msgcode
== FC_BSG_RPT_ELS
?
353 SRB_ELS_CMD_RPT
: SRB_ELS_CMD_HST
);
355 (bsg_job
->request
->msgcode
== FC_BSG_RPT_ELS
?
356 "bsg_els_rpt" : "bsg_els_hst");
357 sp
->u
.bsg_job
= bsg_job
;
358 sp
->free
= qla2x00_bsg_sp_free
;
359 sp
->done
= qla2x00_bsg_job_done
;
361 ql_dbg(ql_dbg_user
, vha
, 0x700a,
362 "bsg rqst type: %s els type: %x - loop-id=%x "
363 "portid=%-2x%02x%02x.\n", type
,
364 bsg_job
->request
->rqst_data
.h_els
.command_code
, fcport
->loop_id
,
365 fcport
->d_id
.b
.domain
, fcport
->d_id
.b
.area
, fcport
->d_id
.b
.al_pa
);
367 rval
= qla2x00_start_sp(sp
);
368 if (rval
!= QLA_SUCCESS
) {
369 ql_log(ql_log_warn
, vha
, 0x700e,
370 "qla2x00_start_sp failed = %d\n", rval
);
371 qla2x00_rel_sp(vha
, sp
);
378 dma_unmap_sg(&ha
->pdev
->dev
, bsg_job
->request_payload
.sg_list
,
379 bsg_job
->request_payload
.sg_cnt
, DMA_TO_DEVICE
);
380 dma_unmap_sg(&ha
->pdev
->dev
, bsg_job
->reply_payload
.sg_list
,
381 bsg_job
->reply_payload
.sg_cnt
, DMA_FROM_DEVICE
);
382 goto done_free_fcport
;
385 if (bsg_job
->request
->msgcode
== FC_BSG_HST_ELS_NOLOGIN
)
392 qla24xx_calc_ct_iocbs(uint16_t dsds
)
398 iocbs
+= (dsds
- 2) / 5;
406 qla2x00_process_ct(struct fc_bsg_job
*bsg_job
)
409 struct Scsi_Host
*host
= bsg_job
->shost
;
410 scsi_qla_host_t
*vha
= shost_priv(host
);
411 struct qla_hw_data
*ha
= vha
->hw
;
412 int rval
= (DRIVER_ERROR
<< 16);
413 int req_sg_cnt
, rsp_sg_cnt
;
415 struct fc_port
*fcport
;
416 char *type
= "FC_BSG_HST_CT";
419 dma_map_sg(&ha
->pdev
->dev
, bsg_job
->request_payload
.sg_list
,
420 bsg_job
->request_payload
.sg_cnt
, DMA_TO_DEVICE
);
422 ql_log(ql_log_warn
, vha
, 0x700f,
423 "dma_map_sg return %d for request\n", req_sg_cnt
);
428 rsp_sg_cnt
= dma_map_sg(&ha
->pdev
->dev
, bsg_job
->reply_payload
.sg_list
,
429 bsg_job
->reply_payload
.sg_cnt
, DMA_FROM_DEVICE
);
431 ql_log(ql_log_warn
, vha
, 0x7010,
432 "dma_map_sg return %d for reply\n", rsp_sg_cnt
);
437 if ((req_sg_cnt
!= bsg_job
->request_payload
.sg_cnt
) ||
438 (rsp_sg_cnt
!= bsg_job
->reply_payload
.sg_cnt
)) {
439 ql_log(ql_log_warn
, vha
, 0x7011,
440 "request_sg_cnt: %x dma_request_sg_cnt: %x reply_sg_cnt:%x "
441 "dma_reply_sg_cnt: %x\n", bsg_job
->request_payload
.sg_cnt
,
442 req_sg_cnt
, bsg_job
->reply_payload
.sg_cnt
, rsp_sg_cnt
);
447 if (!vha
->flags
.online
) {
448 ql_log(ql_log_warn
, vha
, 0x7012,
449 "Host is not online.\n");
455 (bsg_job
->request
->rqst_data
.h_ct
.preamble_word1
& 0xFF000000)
459 loop_id
= cpu_to_le16(NPH_SNS
);
462 loop_id
= vha
->mgmt_svr_loop_id
;
465 ql_dbg(ql_dbg_user
, vha
, 0x7013,
466 "Unknown loop id: %x.\n", loop_id
);
471 /* Allocate a dummy fcport structure, since functions preparing the
472 * IOCB and mailbox command retrieves port specific information
473 * from fcport structure. For Host based ELS commands there will be
474 * no fcport structure allocated
476 fcport
= qla2x00_alloc_fcport(vha
, GFP_KERNEL
);
478 ql_log(ql_log_warn
, vha
, 0x7014,
479 "Failed to allocate fcport.\n");
484 /* Initialize all required fields of fcport */
486 fcport
->d_id
.b
.al_pa
= bsg_job
->request
->rqst_data
.h_ct
.port_id
[0];
487 fcport
->d_id
.b
.area
= bsg_job
->request
->rqst_data
.h_ct
.port_id
[1];
488 fcport
->d_id
.b
.domain
= bsg_job
->request
->rqst_data
.h_ct
.port_id
[2];
489 fcport
->loop_id
= loop_id
;
491 /* Alloc SRB structure */
492 sp
= qla2x00_get_sp(vha
, fcport
, GFP_KERNEL
);
494 ql_log(ql_log_warn
, vha
, 0x7015,
495 "qla2x00_get_sp failed.\n");
497 goto done_free_fcport
;
500 sp
->type
= SRB_CT_CMD
;
502 sp
->iocbs
= qla24xx_calc_ct_iocbs(req_sg_cnt
+ rsp_sg_cnt
);
503 sp
->u
.bsg_job
= bsg_job
;
504 sp
->free
= qla2x00_bsg_sp_free
;
505 sp
->done
= qla2x00_bsg_job_done
;
507 ql_dbg(ql_dbg_user
, vha
, 0x7016,
508 "bsg rqst type: %s else type: %x - "
509 "loop-id=%x portid=%02x%02x%02x.\n", type
,
510 (bsg_job
->request
->rqst_data
.h_ct
.preamble_word2
>> 16),
511 fcport
->loop_id
, fcport
->d_id
.b
.domain
, fcport
->d_id
.b
.area
,
512 fcport
->d_id
.b
.al_pa
);
514 rval
= qla2x00_start_sp(sp
);
515 if (rval
!= QLA_SUCCESS
) {
516 ql_log(ql_log_warn
, vha
, 0x7017,
517 "qla2x00_start_sp failed=%d.\n", rval
);
518 qla2x00_rel_sp(vha
, sp
);
520 goto done_free_fcport
;
527 dma_unmap_sg(&ha
->pdev
->dev
, bsg_job
->request_payload
.sg_list
,
528 bsg_job
->request_payload
.sg_cnt
, DMA_TO_DEVICE
);
529 dma_unmap_sg(&ha
->pdev
->dev
, bsg_job
->reply_payload
.sg_list
,
530 bsg_job
->reply_payload
.sg_cnt
, DMA_FROM_DEVICE
);
535 * Set the port configuration to enable the internal or external loopback
536 * depending on the loopback mode.
539 qla81xx_set_loopback_mode(scsi_qla_host_t
*vha
, uint16_t *config
,
540 uint16_t *new_config
, uint16_t mode
)
544 struct qla_hw_data
*ha
= vha
->hw
;
546 if (!IS_QLA81XX(ha
) && !IS_QLA8031(ha
))
547 goto done_set_internal
;
549 if (mode
== INTERNAL_LOOPBACK
)
550 new_config
[0] = config
[0] | (ENABLE_INTERNAL_LOOPBACK
<< 1);
551 else if (mode
== EXTERNAL_LOOPBACK
)
552 new_config
[0] = config
[0] | (ENABLE_EXTERNAL_LOOPBACK
<< 1);
553 ql_dbg(ql_dbg_user
, vha
, 0x70be,
554 "new_config[0]=%02x\n", (new_config
[0] & INTERNAL_LOOPBACK_MASK
));
556 memcpy(&new_config
[1], &config
[1], sizeof(uint16_t) * 3);
558 ha
->notify_dcbx_comp
= 1;
559 ret
= qla81xx_set_port_config(vha
, new_config
);
560 if (ret
!= QLA_SUCCESS
) {
561 ql_log(ql_log_warn
, vha
, 0x7021,
562 "set port config failed.\n");
563 ha
->notify_dcbx_comp
= 0;
565 goto done_set_internal
;
568 /* Wait for DCBX complete event */
569 if (!wait_for_completion_timeout(&ha
->dcbx_comp
, (20 * HZ
))) {
570 ql_dbg(ql_dbg_user
, vha
, 0x7022,
571 "State change notification not received.\n");
574 if (ha
->flags
.idc_compl_status
) {
575 ql_dbg(ql_dbg_user
, vha
, 0x70c3,
576 "Bad status in IDC Completion AEN\n");
578 ha
->flags
.idc_compl_status
= 0;
580 ql_dbg(ql_dbg_user
, vha
, 0x7023,
581 "State change received.\n");
584 ha
->notify_dcbx_comp
= 0;
590 /* Disable loopback mode */
592 qla81xx_reset_loopback_mode(scsi_qla_host_t
*vha
, uint16_t *config
,
597 uint16_t new_config
[4];
598 struct qla_hw_data
*ha
= vha
->hw
;
600 if (!IS_QLA81XX(ha
) && !IS_QLA8031(ha
))
601 goto done_reset_internal
;
603 memset(new_config
, 0 , sizeof(new_config
));
604 if ((config
[0] & INTERNAL_LOOPBACK_MASK
) >> 1 ==
605 ENABLE_INTERNAL_LOOPBACK
||
606 (config
[0] & INTERNAL_LOOPBACK_MASK
) >> 1 ==
607 ENABLE_EXTERNAL_LOOPBACK
) {
608 new_config
[0] = config
[0] & ~INTERNAL_LOOPBACK_MASK
;
609 ql_dbg(ql_dbg_user
, vha
, 0x70bf, "new_config[0]=%02x\n",
610 (new_config
[0] & INTERNAL_LOOPBACK_MASK
));
611 memcpy(&new_config
[1], &config
[1], sizeof(uint16_t) * 3) ;
613 ha
->notify_dcbx_comp
= wait
;
614 ret
= qla81xx_set_port_config(vha
, new_config
);
615 if (ret
!= QLA_SUCCESS
) {
616 ql_log(ql_log_warn
, vha
, 0x7025,
617 "Set port config failed.\n");
618 ha
->notify_dcbx_comp
= 0;
620 goto done_reset_internal
;
623 /* Wait for DCBX complete event */
624 if (wait
&& !wait_for_completion_timeout(&ha
->dcbx_comp
,
626 ql_dbg(ql_dbg_user
, vha
, 0x7026,
627 "State change notification not received.\n");
628 ha
->notify_dcbx_comp
= 0;
630 goto done_reset_internal
;
632 ql_dbg(ql_dbg_user
, vha
, 0x7027,
633 "State change received.\n");
635 ha
->notify_dcbx_comp
= 0;
642 qla2x00_process_loopback(struct fc_bsg_job
*bsg_job
)
644 struct Scsi_Host
*host
= bsg_job
->shost
;
645 scsi_qla_host_t
*vha
= shost_priv(host
);
646 struct qla_hw_data
*ha
= vha
->hw
;
648 uint8_t command_sent
;
650 struct msg_echo_lb elreq
;
651 uint16_t response
[MAILBOX_REGISTER_COUNT
];
652 uint16_t config
[4], new_config
[4];
654 uint8_t *req_data
= NULL
;
655 dma_addr_t req_data_dma
;
656 uint32_t req_data_len
;
657 uint8_t *rsp_data
= NULL
;
658 dma_addr_t rsp_data_dma
;
659 uint32_t rsp_data_len
;
661 if (!vha
->flags
.online
) {
662 ql_log(ql_log_warn
, vha
, 0x7019, "Host is not online.\n");
666 elreq
.req_sg_cnt
= dma_map_sg(&ha
->pdev
->dev
,
667 bsg_job
->request_payload
.sg_list
, bsg_job
->request_payload
.sg_cnt
,
670 if (!elreq
.req_sg_cnt
) {
671 ql_log(ql_log_warn
, vha
, 0x701a,
672 "dma_map_sg returned %d for request.\n", elreq
.req_sg_cnt
);
676 elreq
.rsp_sg_cnt
= dma_map_sg(&ha
->pdev
->dev
,
677 bsg_job
->reply_payload
.sg_list
, bsg_job
->reply_payload
.sg_cnt
,
680 if (!elreq
.rsp_sg_cnt
) {
681 ql_log(ql_log_warn
, vha
, 0x701b,
682 "dma_map_sg returned %d for reply.\n", elreq
.rsp_sg_cnt
);
684 goto done_unmap_req_sg
;
687 if ((elreq
.req_sg_cnt
!= bsg_job
->request_payload
.sg_cnt
) ||
688 (elreq
.rsp_sg_cnt
!= bsg_job
->reply_payload
.sg_cnt
)) {
689 ql_log(ql_log_warn
, vha
, 0x701c,
690 "dma mapping resulted in different sg counts, "
691 "request_sg_cnt: %x dma_request_sg_cnt: %x "
692 "reply_sg_cnt: %x dma_reply_sg_cnt: %x.\n",
693 bsg_job
->request_payload
.sg_cnt
, elreq
.req_sg_cnt
,
694 bsg_job
->reply_payload
.sg_cnt
, elreq
.rsp_sg_cnt
);
698 req_data_len
= rsp_data_len
= bsg_job
->request_payload
.payload_len
;
699 req_data
= dma_alloc_coherent(&ha
->pdev
->dev
, req_data_len
,
700 &req_data_dma
, GFP_KERNEL
);
702 ql_log(ql_log_warn
, vha
, 0x701d,
703 "dma alloc failed for req_data.\n");
708 rsp_data
= dma_alloc_coherent(&ha
->pdev
->dev
, rsp_data_len
,
709 &rsp_data_dma
, GFP_KERNEL
);
711 ql_log(ql_log_warn
, vha
, 0x7004,
712 "dma alloc failed for rsp_data.\n");
714 goto done_free_dma_req
;
717 /* Copy the request buffer in req_data now */
718 sg_copy_to_buffer(bsg_job
->request_payload
.sg_list
,
719 bsg_job
->request_payload
.sg_cnt
, req_data
, req_data_len
);
721 elreq
.send_dma
= req_data_dma
;
722 elreq
.rcv_dma
= rsp_data_dma
;
723 elreq
.transfer_size
= req_data_len
;
725 elreq
.options
= bsg_job
->request
->rqst_data
.h_vendor
.vendor_cmd
[1];
727 if (atomic_read(&vha
->loop_state
) == LOOP_READY
&&
728 (ha
->current_topology
== ISP_CFG_F
||
729 ((IS_QLA81XX(ha
) || IS_QLA8031(ha
)) &&
730 le32_to_cpu(*(uint32_t *)req_data
) == ELS_OPCODE_BYTE
731 && req_data_len
== MAX_ELS_FRAME_PAYLOAD
)) &&
732 elreq
.options
== EXTERNAL_LOOPBACK
) {
733 type
= "FC_BSG_HST_VENDOR_ECHO_DIAG";
734 ql_dbg(ql_dbg_user
, vha
, 0x701e,
735 "BSG request type: %s.\n", type
);
736 command_sent
= INT_DEF_LB_ECHO_CMD
;
737 rval
= qla2x00_echo_test(vha
, &elreq
, response
);
739 if (IS_QLA81XX(ha
) || IS_QLA8031(ha
)) {
740 memset(config
, 0, sizeof(config
));
741 memset(new_config
, 0, sizeof(new_config
));
742 if (qla81xx_get_port_config(vha
, config
)) {
743 ql_log(ql_log_warn
, vha
, 0x701f,
744 "Get port config failed.\n");
746 goto done_free_dma_rsp
;
749 if ((config
[0] & INTERNAL_LOOPBACK_MASK
) != 0) {
750 ql_dbg(ql_dbg_user
, vha
, 0x70c4,
751 "Loopback operation already in "
754 goto done_free_dma_rsp
;
757 ql_dbg(ql_dbg_user
, vha
, 0x70c0,
758 "elreq.options=%04x\n", elreq
.options
);
760 if (elreq
.options
== EXTERNAL_LOOPBACK
)
762 rval
= qla81xx_set_loopback_mode(vha
,
763 config
, new_config
, elreq
.options
);
765 rval
= qla81xx_reset_loopback_mode(vha
,
768 rval
= qla81xx_set_loopback_mode(vha
, config
,
769 new_config
, elreq
.options
);
773 goto done_free_dma_rsp
;
776 type
= "FC_BSG_HST_VENDOR_LOOPBACK";
777 ql_dbg(ql_dbg_user
, vha
, 0x7028,
778 "BSG request type: %s.\n", type
);
780 command_sent
= INT_DEF_LB_LOOPBACK_CMD
;
781 rval
= qla2x00_loopback_test(vha
, &elreq
, response
);
784 /* Revert back to original port config
785 * Also clear internal loopback
787 qla81xx_reset_loopback_mode(vha
,
791 if (response
[0] == MBS_COMMAND_ERROR
&&
792 response
[1] == MBS_LB_RESET
) {
793 ql_log(ql_log_warn
, vha
, 0x7029,
794 "MBX command error, Aborting ISP.\n");
795 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
796 qla2xxx_wake_dpc(vha
);
797 qla2x00_wait_for_chip_reset(vha
);
798 /* Also reset the MPI */
799 if (IS_QLA81XX(ha
)) {
800 if (qla81xx_restart_mpi_firmware(vha
) !=
802 ql_log(ql_log_warn
, vha
, 0x702a,
803 "MPI reset failed.\n");
808 goto done_free_dma_rsp
;
811 type
= "FC_BSG_HST_VENDOR_LOOPBACK";
812 ql_dbg(ql_dbg_user
, vha
, 0x702b,
813 "BSG request type: %s.\n", type
);
814 command_sent
= INT_DEF_LB_LOOPBACK_CMD
;
815 rval
= qla2x00_loopback_test(vha
, &elreq
, response
);
820 ql_log(ql_log_warn
, vha
, 0x702c,
821 "Vendor request %s failed.\n", type
);
824 bsg_job
->reply
->result
= (DID_ERROR
<< 16);
825 bsg_job
->reply
->reply_payload_rcv_len
= 0;
827 ql_dbg(ql_dbg_user
, vha
, 0x702d,
828 "Vendor request %s completed.\n", type
);
829 bsg_job
->reply
->result
= (DID_OK
<< 16);
830 sg_copy_from_buffer(bsg_job
->reply_payload
.sg_list
,
831 bsg_job
->reply_payload
.sg_cnt
, rsp_data
,
835 bsg_job
->reply_len
= sizeof(struct fc_bsg_reply
) +
836 sizeof(response
) + sizeof(uint8_t);
837 fw_sts_ptr
= ((uint8_t *)bsg_job
->req
->sense
) +
838 sizeof(struct fc_bsg_reply
);
839 memcpy(fw_sts_ptr
, response
, sizeof(response
));
840 fw_sts_ptr
+= sizeof(response
);
841 *fw_sts_ptr
= command_sent
;
844 dma_free_coherent(&ha
->pdev
->dev
, rsp_data_len
,
845 rsp_data
, rsp_data_dma
);
847 dma_free_coherent(&ha
->pdev
->dev
, req_data_len
,
848 req_data
, req_data_dma
);
850 dma_unmap_sg(&ha
->pdev
->dev
,
851 bsg_job
->reply_payload
.sg_list
,
852 bsg_job
->reply_payload
.sg_cnt
, DMA_FROM_DEVICE
);
854 dma_unmap_sg(&ha
->pdev
->dev
,
855 bsg_job
->request_payload
.sg_list
,
856 bsg_job
->request_payload
.sg_cnt
, DMA_TO_DEVICE
);
858 bsg_job
->job_done(bsg_job
);
863 qla84xx_reset(struct fc_bsg_job
*bsg_job
)
865 struct Scsi_Host
*host
= bsg_job
->shost
;
866 scsi_qla_host_t
*vha
= shost_priv(host
);
867 struct qla_hw_data
*ha
= vha
->hw
;
871 if (!IS_QLA84XX(ha
)) {
872 ql_dbg(ql_dbg_user
, vha
, 0x702f, "Not 84xx, exiting.\n");
876 flag
= bsg_job
->request
->rqst_data
.h_vendor
.vendor_cmd
[1];
878 rval
= qla84xx_reset_chip(vha
, flag
== A84_ISSUE_RESET_DIAG_FW
);
881 ql_log(ql_log_warn
, vha
, 0x7030,
882 "Vendor request 84xx reset failed.\n");
883 rval
= (DID_ERROR
<< 16);
886 ql_dbg(ql_dbg_user
, vha
, 0x7031,
887 "Vendor request 84xx reset completed.\n");
888 bsg_job
->reply
->result
= DID_OK
;
889 bsg_job
->job_done(bsg_job
);
896 qla84xx_updatefw(struct fc_bsg_job
*bsg_job
)
898 struct Scsi_Host
*host
= bsg_job
->shost
;
899 scsi_qla_host_t
*vha
= shost_priv(host
);
900 struct qla_hw_data
*ha
= vha
->hw
;
901 struct verify_chip_entry_84xx
*mn
= NULL
;
902 dma_addr_t mn_dma
, fw_dma
;
911 if (!IS_QLA84XX(ha
)) {
912 ql_dbg(ql_dbg_user
, vha
, 0x7032,
913 "Not 84xx, exiting.\n");
917 sg_cnt
= dma_map_sg(&ha
->pdev
->dev
, bsg_job
->request_payload
.sg_list
,
918 bsg_job
->request_payload
.sg_cnt
, DMA_TO_DEVICE
);
920 ql_log(ql_log_warn
, vha
, 0x7033,
921 "dma_map_sg returned %d for request.\n", sg_cnt
);
925 if (sg_cnt
!= bsg_job
->request_payload
.sg_cnt
) {
926 ql_log(ql_log_warn
, vha
, 0x7034,
927 "DMA mapping resulted in different sg counts, "
928 "request_sg_cnt: %x dma_request_sg_cnt: %x.\n",
929 bsg_job
->request_payload
.sg_cnt
, sg_cnt
);
934 data_len
= bsg_job
->request_payload
.payload_len
;
935 fw_buf
= dma_alloc_coherent(&ha
->pdev
->dev
, data_len
,
936 &fw_dma
, GFP_KERNEL
);
938 ql_log(ql_log_warn
, vha
, 0x7035,
939 "DMA alloc failed for fw_buf.\n");
944 sg_copy_to_buffer(bsg_job
->request_payload
.sg_list
,
945 bsg_job
->request_payload
.sg_cnt
, fw_buf
, data_len
);
947 mn
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &mn_dma
);
949 ql_log(ql_log_warn
, vha
, 0x7036,
950 "DMA alloc failed for fw buffer.\n");
952 goto done_free_fw_buf
;
955 flag
= bsg_job
->request
->rqst_data
.h_vendor
.vendor_cmd
[1];
956 fw_ver
= le32_to_cpu(*((uint32_t *)((uint32_t *)fw_buf
+ 2)));
958 memset(mn
, 0, sizeof(struct access_chip_84xx
));
959 mn
->entry_type
= VERIFY_CHIP_IOCB_TYPE
;
962 options
= VCO_FORCE_UPDATE
| VCO_END_OF_DATA
;
963 if (flag
== A84_ISSUE_UPDATE_DIAGFW_CMD
)
964 options
|= VCO_DIAG_FW
;
966 mn
->options
= cpu_to_le16(options
);
967 mn
->fw_ver
= cpu_to_le32(fw_ver
);
968 mn
->fw_size
= cpu_to_le32(data_len
);
969 mn
->fw_seq_size
= cpu_to_le32(data_len
);
970 mn
->dseg_address
[0] = cpu_to_le32(LSD(fw_dma
));
971 mn
->dseg_address
[1] = cpu_to_le32(MSD(fw_dma
));
972 mn
->dseg_length
= cpu_to_le32(data_len
);
973 mn
->data_seg_cnt
= cpu_to_le16(1);
975 rval
= qla2x00_issue_iocb_timeout(vha
, mn
, mn_dma
, 0, 120);
978 ql_log(ql_log_warn
, vha
, 0x7037,
979 "Vendor request 84xx updatefw failed.\n");
981 rval
= (DID_ERROR
<< 16);
983 ql_dbg(ql_dbg_user
, vha
, 0x7038,
984 "Vendor request 84xx updatefw completed.\n");
986 bsg_job
->reply_len
= sizeof(struct fc_bsg_reply
);
987 bsg_job
->reply
->result
= DID_OK
;
990 dma_pool_free(ha
->s_dma_pool
, mn
, mn_dma
);
993 dma_free_coherent(&ha
->pdev
->dev
, data_len
, fw_buf
, fw_dma
);
996 dma_unmap_sg(&ha
->pdev
->dev
, bsg_job
->request_payload
.sg_list
,
997 bsg_job
->request_payload
.sg_cnt
, DMA_TO_DEVICE
);
1000 bsg_job
->job_done(bsg_job
);
1005 qla84xx_mgmt_cmd(struct fc_bsg_job
*bsg_job
)
1007 struct Scsi_Host
*host
= bsg_job
->shost
;
1008 scsi_qla_host_t
*vha
= shost_priv(host
);
1009 struct qla_hw_data
*ha
= vha
->hw
;
1010 struct access_chip_84xx
*mn
= NULL
;
1011 dma_addr_t mn_dma
, mgmt_dma
;
1012 void *mgmt_b
= NULL
;
1014 struct qla_bsg_a84_mgmt
*ql84_mgmt
;
1016 uint32_t data_len
= 0;
1017 uint32_t dma_direction
= DMA_NONE
;
1019 if (!IS_QLA84XX(ha
)) {
1020 ql_log(ql_log_warn
, vha
, 0x703a,
1021 "Not 84xx, exiting.\n");
1025 ql84_mgmt
= (struct qla_bsg_a84_mgmt
*)((char *)bsg_job
->request
+
1026 sizeof(struct fc_bsg_request
));
1028 ql_log(ql_log_warn
, vha
, 0x703b,
1029 "MGMT header not provided, exiting.\n");
1033 mn
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &mn_dma
);
1035 ql_log(ql_log_warn
, vha
, 0x703c,
1036 "DMA alloc failed for fw buffer.\n");
1040 memset(mn
, 0, sizeof(struct access_chip_84xx
));
1041 mn
->entry_type
= ACCESS_CHIP_IOCB_TYPE
;
1042 mn
->entry_count
= 1;
1044 switch (ql84_mgmt
->mgmt
.cmd
) {
1045 case QLA84_MGMT_READ_MEM
:
1046 case QLA84_MGMT_GET_INFO
:
1047 sg_cnt
= dma_map_sg(&ha
->pdev
->dev
,
1048 bsg_job
->reply_payload
.sg_list
,
1049 bsg_job
->reply_payload
.sg_cnt
, DMA_FROM_DEVICE
);
1051 ql_log(ql_log_warn
, vha
, 0x703d,
1052 "dma_map_sg returned %d for reply.\n", sg_cnt
);
1057 dma_direction
= DMA_FROM_DEVICE
;
1059 if (sg_cnt
!= bsg_job
->reply_payload
.sg_cnt
) {
1060 ql_log(ql_log_warn
, vha
, 0x703e,
1061 "DMA mapping resulted in different sg counts, "
1062 "reply_sg_cnt: %x dma_reply_sg_cnt: %x.\n",
1063 bsg_job
->reply_payload
.sg_cnt
, sg_cnt
);
1068 data_len
= bsg_job
->reply_payload
.payload_len
;
1070 mgmt_b
= dma_alloc_coherent(&ha
->pdev
->dev
, data_len
,
1071 &mgmt_dma
, GFP_KERNEL
);
1073 ql_log(ql_log_warn
, vha
, 0x703f,
1074 "DMA alloc failed for mgmt_b.\n");
1079 if (ql84_mgmt
->mgmt
.cmd
== QLA84_MGMT_READ_MEM
) {
1080 mn
->options
= cpu_to_le16(ACO_DUMP_MEMORY
);
1083 ql84_mgmt
->mgmt
.mgmtp
.u
.mem
.start_addr
);
1085 } else if (ql84_mgmt
->mgmt
.cmd
== QLA84_MGMT_GET_INFO
) {
1086 mn
->options
= cpu_to_le16(ACO_REQUEST_INFO
);
1088 cpu_to_le32(ql84_mgmt
->mgmt
.mgmtp
.u
.info
.type
);
1092 ql84_mgmt
->mgmt
.mgmtp
.u
.info
.context
);
1096 case QLA84_MGMT_WRITE_MEM
:
1097 sg_cnt
= dma_map_sg(&ha
->pdev
->dev
,
1098 bsg_job
->request_payload
.sg_list
,
1099 bsg_job
->request_payload
.sg_cnt
, DMA_TO_DEVICE
);
1102 ql_log(ql_log_warn
, vha
, 0x7040,
1103 "dma_map_sg returned %d.\n", sg_cnt
);
1108 dma_direction
= DMA_TO_DEVICE
;
1110 if (sg_cnt
!= bsg_job
->request_payload
.sg_cnt
) {
1111 ql_log(ql_log_warn
, vha
, 0x7041,
1112 "DMA mapping resulted in different sg counts, "
1113 "request_sg_cnt: %x dma_request_sg_cnt: %x.\n",
1114 bsg_job
->request_payload
.sg_cnt
, sg_cnt
);
1119 data_len
= bsg_job
->request_payload
.payload_len
;
1120 mgmt_b
= dma_alloc_coherent(&ha
->pdev
->dev
, data_len
,
1121 &mgmt_dma
, GFP_KERNEL
);
1123 ql_log(ql_log_warn
, vha
, 0x7042,
1124 "DMA alloc failed for mgmt_b.\n");
1129 sg_copy_to_buffer(bsg_job
->request_payload
.sg_list
,
1130 bsg_job
->request_payload
.sg_cnt
, mgmt_b
, data_len
);
1132 mn
->options
= cpu_to_le16(ACO_LOAD_MEMORY
);
1134 cpu_to_le32(ql84_mgmt
->mgmt
.mgmtp
.u
.mem
.start_addr
);
1137 case QLA84_MGMT_CHNG_CONFIG
:
1138 mn
->options
= cpu_to_le16(ACO_CHANGE_CONFIG_PARAM
);
1140 cpu_to_le32(ql84_mgmt
->mgmt
.mgmtp
.u
.config
.id
);
1143 cpu_to_le32(ql84_mgmt
->mgmt
.mgmtp
.u
.config
.param0
);
1146 cpu_to_le32(ql84_mgmt
->mgmt
.mgmtp
.u
.config
.param1
);
1154 if (ql84_mgmt
->mgmt
.cmd
!= QLA84_MGMT_CHNG_CONFIG
) {
1155 mn
->total_byte_cnt
= cpu_to_le32(ql84_mgmt
->mgmt
.len
);
1156 mn
->dseg_count
= cpu_to_le16(1);
1157 mn
->dseg_address
[0] = cpu_to_le32(LSD(mgmt_dma
));
1158 mn
->dseg_address
[1] = cpu_to_le32(MSD(mgmt_dma
));
1159 mn
->dseg_length
= cpu_to_le32(ql84_mgmt
->mgmt
.len
);
1162 rval
= qla2x00_issue_iocb(vha
, mn
, mn_dma
, 0);
1165 ql_log(ql_log_warn
, vha
, 0x7043,
1166 "Vendor request 84xx mgmt failed.\n");
1168 rval
= (DID_ERROR
<< 16);
1171 ql_dbg(ql_dbg_user
, vha
, 0x7044,
1172 "Vendor request 84xx mgmt completed.\n");
1174 bsg_job
->reply_len
= sizeof(struct fc_bsg_reply
);
1175 bsg_job
->reply
->result
= DID_OK
;
1177 if ((ql84_mgmt
->mgmt
.cmd
== QLA84_MGMT_READ_MEM
) ||
1178 (ql84_mgmt
->mgmt
.cmd
== QLA84_MGMT_GET_INFO
)) {
1179 bsg_job
->reply
->reply_payload_rcv_len
=
1180 bsg_job
->reply_payload
.payload_len
;
1182 sg_copy_from_buffer(bsg_job
->reply_payload
.sg_list
,
1183 bsg_job
->reply_payload
.sg_cnt
, mgmt_b
,
1190 dma_free_coherent(&ha
->pdev
->dev
, data_len
, mgmt_b
, mgmt_dma
);
1192 if (dma_direction
== DMA_TO_DEVICE
)
1193 dma_unmap_sg(&ha
->pdev
->dev
, bsg_job
->request_payload
.sg_list
,
1194 bsg_job
->request_payload
.sg_cnt
, DMA_TO_DEVICE
);
1195 else if (dma_direction
== DMA_FROM_DEVICE
)
1196 dma_unmap_sg(&ha
->pdev
->dev
, bsg_job
->reply_payload
.sg_list
,
1197 bsg_job
->reply_payload
.sg_cnt
, DMA_FROM_DEVICE
);
1200 dma_pool_free(ha
->s_dma_pool
, mn
, mn_dma
);
1203 bsg_job
->job_done(bsg_job
);
1208 qla24xx_iidma(struct fc_bsg_job
*bsg_job
)
1210 struct Scsi_Host
*host
= bsg_job
->shost
;
1211 scsi_qla_host_t
*vha
= shost_priv(host
);
1213 struct qla_port_param
*port_param
= NULL
;
1214 fc_port_t
*fcport
= NULL
;
1215 uint16_t mb
[MAILBOX_REGISTER_COUNT
];
1216 uint8_t *rsp_ptr
= NULL
;
1218 if (!IS_IIDMA_CAPABLE(vha
->hw
)) {
1219 ql_log(ql_log_info
, vha
, 0x7046, "iiDMA not supported.\n");
1223 port_param
= (struct qla_port_param
*)((char *)bsg_job
->request
+
1224 sizeof(struct fc_bsg_request
));
1226 ql_log(ql_log_warn
, vha
, 0x7047,
1227 "port_param header not provided.\n");
1231 if (port_param
->fc_scsi_addr
.dest_type
!= EXT_DEF_TYPE_WWPN
) {
1232 ql_log(ql_log_warn
, vha
, 0x7048,
1233 "Invalid destination type.\n");
1237 list_for_each_entry(fcport
, &vha
->vp_fcports
, list
) {
1238 if (fcport
->port_type
!= FCT_TARGET
)
1241 if (memcmp(port_param
->fc_scsi_addr
.dest_addr
.wwpn
,
1242 fcport
->port_name
, sizeof(fcport
->port_name
)))
1248 ql_log(ql_log_warn
, vha
, 0x7049,
1249 "Failed to find port.\n");
1253 if (atomic_read(&fcport
->state
) != FCS_ONLINE
) {
1254 ql_log(ql_log_warn
, vha
, 0x704a,
1255 "Port is not online.\n");
1259 if (fcport
->flags
& FCF_LOGIN_NEEDED
) {
1260 ql_log(ql_log_warn
, vha
, 0x704b,
1261 "Remote port not logged in flags = 0x%x.\n", fcport
->flags
);
1265 if (port_param
->mode
)
1266 rval
= qla2x00_set_idma_speed(vha
, fcport
->loop_id
,
1267 port_param
->speed
, mb
);
1269 rval
= qla2x00_get_idma_speed(vha
, fcport
->loop_id
,
1270 &port_param
->speed
, mb
);
1273 ql_log(ql_log_warn
, vha
, 0x704c,
1274 "iIDMA cmd failed for %02x%02x%02x%02x%02x%02x%02x%02x -- "
1275 "%04x %x %04x %04x.\n", fcport
->port_name
[0],
1276 fcport
->port_name
[1], fcport
->port_name
[2],
1277 fcport
->port_name
[3], fcport
->port_name
[4],
1278 fcport
->port_name
[5], fcport
->port_name
[6],
1279 fcport
->port_name
[7], rval
, fcport
->fp_speed
, mb
[0], mb
[1]);
1280 rval
= (DID_ERROR
<< 16);
1282 if (!port_param
->mode
) {
1283 bsg_job
->reply_len
= sizeof(struct fc_bsg_reply
) +
1284 sizeof(struct qla_port_param
);
1286 rsp_ptr
= ((uint8_t *)bsg_job
->reply
) +
1287 sizeof(struct fc_bsg_reply
);
1289 memcpy(rsp_ptr
, port_param
,
1290 sizeof(struct qla_port_param
));
1293 bsg_job
->reply
->result
= DID_OK
;
1294 bsg_job
->job_done(bsg_job
);
1301 qla2x00_optrom_setup(struct fc_bsg_job
*bsg_job
, scsi_qla_host_t
*vha
,
1306 struct qla_hw_data
*ha
= vha
->hw
;
1308 if (unlikely(pci_channel_offline(ha
->pdev
)))
1311 start
= bsg_job
->request
->rqst_data
.h_vendor
.vendor_cmd
[1];
1312 if (start
> ha
->optrom_size
) {
1313 ql_log(ql_log_warn
, vha
, 0x7055,
1314 "start %d > optrom_size %d.\n", start
, ha
->optrom_size
);
1318 if (ha
->optrom_state
!= QLA_SWAITING
) {
1319 ql_log(ql_log_info
, vha
, 0x7056,
1320 "optrom_state %d.\n", ha
->optrom_state
);
1324 ha
->optrom_region_start
= start
;
1325 ql_dbg(ql_dbg_user
, vha
, 0x7057, "is_update=%d.\n", is_update
);
1327 if (ha
->optrom_size
== OPTROM_SIZE_2300
&& start
== 0)
1329 else if (start
== (ha
->flt_region_boot
* 4) ||
1330 start
== (ha
->flt_region_fw
* 4))
1332 else if (IS_QLA24XX_TYPE(ha
) || IS_QLA25XX(ha
) ||
1333 IS_CNA_CAPABLE(ha
) || IS_QLA2031(ha
))
1336 ql_log(ql_log_warn
, vha
, 0x7058,
1337 "Invalid start region 0x%x/0x%x.\n", start
,
1338 bsg_job
->request_payload
.payload_len
);
1342 ha
->optrom_region_size
= start
+
1343 bsg_job
->request_payload
.payload_len
> ha
->optrom_size
?
1344 ha
->optrom_size
- start
:
1345 bsg_job
->request_payload
.payload_len
;
1346 ha
->optrom_state
= QLA_SWRITING
;
1348 ha
->optrom_region_size
= start
+
1349 bsg_job
->reply_payload
.payload_len
> ha
->optrom_size
?
1350 ha
->optrom_size
- start
:
1351 bsg_job
->reply_payload
.payload_len
;
1352 ha
->optrom_state
= QLA_SREADING
;
1355 ha
->optrom_buffer
= vmalloc(ha
->optrom_region_size
);
1356 if (!ha
->optrom_buffer
) {
1357 ql_log(ql_log_warn
, vha
, 0x7059,
1358 "Read: Unable to allocate memory for optrom retrieval "
1359 "(%x)\n", ha
->optrom_region_size
);
1361 ha
->optrom_state
= QLA_SWAITING
;
1365 memset(ha
->optrom_buffer
, 0, ha
->optrom_region_size
);
1370 qla2x00_read_optrom(struct fc_bsg_job
*bsg_job
)
1372 struct Scsi_Host
*host
= bsg_job
->shost
;
1373 scsi_qla_host_t
*vha
= shost_priv(host
);
1374 struct qla_hw_data
*ha
= vha
->hw
;
1377 if (ha
->flags
.nic_core_reset_hdlr_active
)
1380 rval
= qla2x00_optrom_setup(bsg_job
, vha
, 0);
1384 ha
->isp_ops
->read_optrom(vha
, ha
->optrom_buffer
,
1385 ha
->optrom_region_start
, ha
->optrom_region_size
);
1387 sg_copy_from_buffer(bsg_job
->reply_payload
.sg_list
,
1388 bsg_job
->reply_payload
.sg_cnt
, ha
->optrom_buffer
,
1389 ha
->optrom_region_size
);
1391 bsg_job
->reply
->reply_payload_rcv_len
= ha
->optrom_region_size
;
1392 bsg_job
->reply
->result
= DID_OK
;
1393 vfree(ha
->optrom_buffer
);
1394 ha
->optrom_buffer
= NULL
;
1395 ha
->optrom_state
= QLA_SWAITING
;
1396 bsg_job
->job_done(bsg_job
);
1401 qla2x00_update_optrom(struct fc_bsg_job
*bsg_job
)
1403 struct Scsi_Host
*host
= bsg_job
->shost
;
1404 scsi_qla_host_t
*vha
= shost_priv(host
);
1405 struct qla_hw_data
*ha
= vha
->hw
;
1408 rval
= qla2x00_optrom_setup(bsg_job
, vha
, 1);
1412 /* Set the isp82xx_no_md_cap not to capture minidump */
1413 ha
->flags
.isp82xx_no_md_cap
= 1;
1415 sg_copy_to_buffer(bsg_job
->request_payload
.sg_list
,
1416 bsg_job
->request_payload
.sg_cnt
, ha
->optrom_buffer
,
1417 ha
->optrom_region_size
);
1419 ha
->isp_ops
->write_optrom(vha
, ha
->optrom_buffer
,
1420 ha
->optrom_region_start
, ha
->optrom_region_size
);
1422 bsg_job
->reply
->result
= DID_OK
;
1423 vfree(ha
->optrom_buffer
);
1424 ha
->optrom_buffer
= NULL
;
1425 ha
->optrom_state
= QLA_SWAITING
;
1426 bsg_job
->job_done(bsg_job
);
1431 qla2x00_update_fru_versions(struct fc_bsg_job
*bsg_job
)
1433 struct Scsi_Host
*host
= bsg_job
->shost
;
1434 scsi_qla_host_t
*vha
= shost_priv(host
);
1435 struct qla_hw_data
*ha
= vha
->hw
;
1437 uint8_t bsg
[DMA_POOL_SIZE
];
1438 struct qla_image_version_list
*list
= (void *)bsg
;
1439 struct qla_image_version
*image
;
1442 void *sfp
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &sfp_dma
);
1444 bsg_job
->reply
->reply_data
.vendor_reply
.vendor_rsp
[0] =
1445 EXT_STATUS_NO_MEMORY
;
1449 sg_copy_to_buffer(bsg_job
->request_payload
.sg_list
,
1450 bsg_job
->request_payload
.sg_cnt
, list
, sizeof(bsg
));
1452 image
= list
->version
;
1453 count
= list
->count
;
1455 memcpy(sfp
, &image
->field_info
, sizeof(image
->field_info
));
1456 rval
= qla2x00_write_sfp(vha
, sfp_dma
, sfp
,
1457 image
->field_address
.device
, image
->field_address
.offset
,
1458 sizeof(image
->field_info
), image
->field_address
.option
);
1460 bsg_job
->reply
->reply_data
.vendor_reply
.vendor_rsp
[0] =
1467 bsg_job
->reply
->reply_data
.vendor_reply
.vendor_rsp
[0] = 0;
1470 dma_pool_free(ha
->s_dma_pool
, sfp
, sfp_dma
);
1473 bsg_job
->reply_len
= sizeof(struct fc_bsg_reply
);
1474 bsg_job
->reply
->result
= DID_OK
<< 16;
1475 bsg_job
->job_done(bsg_job
);
1481 qla2x00_read_fru_status(struct fc_bsg_job
*bsg_job
)
1483 struct Scsi_Host
*host
= bsg_job
->shost
;
1484 scsi_qla_host_t
*vha
= shost_priv(host
);
1485 struct qla_hw_data
*ha
= vha
->hw
;
1487 uint8_t bsg
[DMA_POOL_SIZE
];
1488 struct qla_status_reg
*sr
= (void *)bsg
;
1490 uint8_t *sfp
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &sfp_dma
);
1492 bsg_job
->reply
->reply_data
.vendor_reply
.vendor_rsp
[0] =
1493 EXT_STATUS_NO_MEMORY
;
1497 sg_copy_to_buffer(bsg_job
->request_payload
.sg_list
,
1498 bsg_job
->request_payload
.sg_cnt
, sr
, sizeof(*sr
));
1500 rval
= qla2x00_read_sfp(vha
, sfp_dma
, sfp
,
1501 sr
->field_address
.device
, sr
->field_address
.offset
,
1502 sizeof(sr
->status_reg
), sr
->field_address
.option
);
1503 sr
->status_reg
= *sfp
;
1506 bsg_job
->reply
->reply_data
.vendor_reply
.vendor_rsp
[0] =
1511 sg_copy_from_buffer(bsg_job
->reply_payload
.sg_list
,
1512 bsg_job
->reply_payload
.sg_cnt
, sr
, sizeof(*sr
));
1514 bsg_job
->reply
->reply_data
.vendor_reply
.vendor_rsp
[0] = 0;
1517 dma_pool_free(ha
->s_dma_pool
, sfp
, sfp_dma
);
1520 bsg_job
->reply_len
= sizeof(struct fc_bsg_reply
);
1521 bsg_job
->reply
->reply_payload_rcv_len
= sizeof(*sr
);
1522 bsg_job
->reply
->result
= DID_OK
<< 16;
1523 bsg_job
->job_done(bsg_job
);
1529 qla2x00_write_fru_status(struct fc_bsg_job
*bsg_job
)
1531 struct Scsi_Host
*host
= bsg_job
->shost
;
1532 scsi_qla_host_t
*vha
= shost_priv(host
);
1533 struct qla_hw_data
*ha
= vha
->hw
;
1535 uint8_t bsg
[DMA_POOL_SIZE
];
1536 struct qla_status_reg
*sr
= (void *)bsg
;
1538 uint8_t *sfp
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &sfp_dma
);
1540 bsg_job
->reply
->reply_data
.vendor_reply
.vendor_rsp
[0] =
1541 EXT_STATUS_NO_MEMORY
;
1545 sg_copy_to_buffer(bsg_job
->request_payload
.sg_list
,
1546 bsg_job
->request_payload
.sg_cnt
, sr
, sizeof(*sr
));
1548 *sfp
= sr
->status_reg
;
1549 rval
= qla2x00_write_sfp(vha
, sfp_dma
, sfp
,
1550 sr
->field_address
.device
, sr
->field_address
.offset
,
1551 sizeof(sr
->status_reg
), sr
->field_address
.option
);
1554 bsg_job
->reply
->reply_data
.vendor_reply
.vendor_rsp
[0] =
1559 bsg_job
->reply
->reply_data
.vendor_reply
.vendor_rsp
[0] = 0;
1562 dma_pool_free(ha
->s_dma_pool
, sfp
, sfp_dma
);
1565 bsg_job
->reply_len
= sizeof(struct fc_bsg_reply
);
1566 bsg_job
->reply
->result
= DID_OK
<< 16;
1567 bsg_job
->job_done(bsg_job
);
1573 qla2x00_write_i2c(struct fc_bsg_job
*bsg_job
)
1575 struct Scsi_Host
*host
= bsg_job
->shost
;
1576 scsi_qla_host_t
*vha
= shost_priv(host
);
1577 struct qla_hw_data
*ha
= vha
->hw
;
1579 uint8_t bsg
[DMA_POOL_SIZE
];
1580 struct qla_i2c_access
*i2c
= (void *)bsg
;
1582 uint8_t *sfp
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &sfp_dma
);
1584 bsg_job
->reply
->reply_data
.vendor_reply
.vendor_rsp
[0] =
1585 EXT_STATUS_NO_MEMORY
;
1589 sg_copy_to_buffer(bsg_job
->request_payload
.sg_list
,
1590 bsg_job
->request_payload
.sg_cnt
, i2c
, sizeof(*i2c
));
1592 memcpy(sfp
, i2c
->buffer
, i2c
->length
);
1593 rval
= qla2x00_write_sfp(vha
, sfp_dma
, sfp
,
1594 i2c
->device
, i2c
->offset
, i2c
->length
, i2c
->option
);
1597 bsg_job
->reply
->reply_data
.vendor_reply
.vendor_rsp
[0] =
1602 bsg_job
->reply
->reply_data
.vendor_reply
.vendor_rsp
[0] = 0;
1605 dma_pool_free(ha
->s_dma_pool
, sfp
, sfp_dma
);
1608 bsg_job
->reply_len
= sizeof(struct fc_bsg_reply
);
1609 bsg_job
->reply
->result
= DID_OK
<< 16;
1610 bsg_job
->job_done(bsg_job
);
1616 qla2x00_read_i2c(struct fc_bsg_job
*bsg_job
)
1618 struct Scsi_Host
*host
= bsg_job
->shost
;
1619 scsi_qla_host_t
*vha
= shost_priv(host
);
1620 struct qla_hw_data
*ha
= vha
->hw
;
1622 uint8_t bsg
[DMA_POOL_SIZE
];
1623 struct qla_i2c_access
*i2c
= (void *)bsg
;
1625 uint8_t *sfp
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &sfp_dma
);
1627 bsg_job
->reply
->reply_data
.vendor_reply
.vendor_rsp
[0] =
1628 EXT_STATUS_NO_MEMORY
;
1632 sg_copy_to_buffer(bsg_job
->request_payload
.sg_list
,
1633 bsg_job
->request_payload
.sg_cnt
, i2c
, sizeof(*i2c
));
1635 rval
= qla2x00_read_sfp(vha
, sfp_dma
, sfp
,
1636 i2c
->device
, i2c
->offset
, i2c
->length
, i2c
->option
);
1639 bsg_job
->reply
->reply_data
.vendor_reply
.vendor_rsp
[0] =
1644 memcpy(i2c
->buffer
, sfp
, i2c
->length
);
1645 sg_copy_from_buffer(bsg_job
->reply_payload
.sg_list
,
1646 bsg_job
->reply_payload
.sg_cnt
, i2c
, sizeof(*i2c
));
1648 bsg_job
->reply
->reply_data
.vendor_reply
.vendor_rsp
[0] = 0;
1651 dma_pool_free(ha
->s_dma_pool
, sfp
, sfp_dma
);
1654 bsg_job
->reply_len
= sizeof(struct fc_bsg_reply
);
1655 bsg_job
->reply
->reply_payload_rcv_len
= sizeof(*i2c
);
1656 bsg_job
->reply
->result
= DID_OK
<< 16;
1657 bsg_job
->job_done(bsg_job
);
1663 qla24xx_process_bidir_cmd(struct fc_bsg_job
*bsg_job
)
1665 struct Scsi_Host
*host
= bsg_job
->shost
;
1666 scsi_qla_host_t
*vha
= shost_priv(host
);
1667 struct qla_hw_data
*ha
= vha
->hw
;
1669 uint32_t rval
= EXT_STATUS_OK
;
1670 uint16_t req_sg_cnt
= 0;
1671 uint16_t rsp_sg_cnt
= 0;
1672 uint16_t nextlid
= 0;
1675 uint32_t req_data_len
= 0;
1676 uint32_t rsp_data_len
= 0;
1678 /* Check the type of the adapter */
1679 if (!IS_BIDI_CAPABLE(ha
)) {
1680 ql_log(ql_log_warn
, vha
, 0x70a0,
1681 "This adapter is not supported\n");
1682 rval
= EXT_STATUS_NOT_SUPPORTED
;
1686 if (test_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
) ||
1687 test_bit(ABORT_ISP_ACTIVE
, &vha
->dpc_flags
) ||
1688 test_bit(ISP_ABORT_RETRY
, &vha
->dpc_flags
)) {
1689 rval
= EXT_STATUS_BUSY
;
1693 /* Check if host is online */
1694 if (!vha
->flags
.online
) {
1695 ql_log(ql_log_warn
, vha
, 0x70a1,
1696 "Host is not online\n");
1697 rval
= EXT_STATUS_DEVICE_OFFLINE
;
1701 /* Check if cable is plugged in or not */
1702 if (vha
->device_flags
& DFLG_NO_CABLE
) {
1703 ql_log(ql_log_warn
, vha
, 0x70a2,
1704 "Cable is unplugged...\n");
1705 rval
= EXT_STATUS_INVALID_CFG
;
1709 /* Check if the switch is connected or not */
1710 if (ha
->current_topology
!= ISP_CFG_F
) {
1711 ql_log(ql_log_warn
, vha
, 0x70a3,
1712 "Host is not connected to the switch\n");
1713 rval
= EXT_STATUS_INVALID_CFG
;
1717 /* Check if operating mode is P2P */
1718 if (ha
->operating_mode
!= P2P
) {
1719 ql_log(ql_log_warn
, vha
, 0x70a4,
1720 "Host is operating mode is not P2p\n");
1721 rval
= EXT_STATUS_INVALID_CFG
;
1725 thread_id
= bsg_job
->request
->rqst_data
.h_vendor
.vendor_cmd
[1];
1727 mutex_lock(&ha
->selflogin_lock
);
1728 if (vha
->self_login_loop_id
== 0) {
1729 /* Initialize all required fields of fcport */
1730 vha
->bidir_fcport
.vha
= vha
;
1731 vha
->bidir_fcport
.d_id
.b
.al_pa
= vha
->d_id
.b
.al_pa
;
1732 vha
->bidir_fcport
.d_id
.b
.area
= vha
->d_id
.b
.area
;
1733 vha
->bidir_fcport
.d_id
.b
.domain
= vha
->d_id
.b
.domain
;
1734 vha
->bidir_fcport
.loop_id
= vha
->loop_id
;
1736 if (qla2x00_fabric_login(vha
, &(vha
->bidir_fcport
), &nextlid
)) {
1737 ql_log(ql_log_warn
, vha
, 0x70a7,
1738 "Failed to login port %06X for bidirectional IOCB\n",
1739 vha
->bidir_fcport
.d_id
.b24
);
1740 mutex_unlock(&ha
->selflogin_lock
);
1741 rval
= EXT_STATUS_MAILBOX
;
1744 vha
->self_login_loop_id
= nextlid
- 1;
1747 /* Assign the self login loop id to fcport */
1748 mutex_unlock(&ha
->selflogin_lock
);
1750 vha
->bidir_fcport
.loop_id
= vha
->self_login_loop_id
;
1752 req_sg_cnt
= dma_map_sg(&ha
->pdev
->dev
,
1753 bsg_job
->request_payload
.sg_list
,
1754 bsg_job
->request_payload
.sg_cnt
,
1758 rval
= EXT_STATUS_NO_MEMORY
;
1762 rsp_sg_cnt
= dma_map_sg(&ha
->pdev
->dev
,
1763 bsg_job
->reply_payload
.sg_list
, bsg_job
->reply_payload
.sg_cnt
,
1767 rval
= EXT_STATUS_NO_MEMORY
;
1768 goto done_unmap_req_sg
;
1771 if ((req_sg_cnt
!= bsg_job
->request_payload
.sg_cnt
) ||
1772 (rsp_sg_cnt
!= bsg_job
->reply_payload
.sg_cnt
)) {
1773 ql_dbg(ql_dbg_user
, vha
, 0x70a9,
1774 "Dma mapping resulted in different sg counts "
1775 "[request_sg_cnt: %x dma_request_sg_cnt: %x reply_sg_cnt: "
1776 "%x dma_reply_sg_cnt: %x]\n",
1777 bsg_job
->request_payload
.sg_cnt
, req_sg_cnt
,
1778 bsg_job
->reply_payload
.sg_cnt
, rsp_sg_cnt
);
1779 rval
= EXT_STATUS_NO_MEMORY
;
1783 if (req_data_len
!= rsp_data_len
) {
1784 rval
= EXT_STATUS_BUSY
;
1785 ql_log(ql_log_warn
, vha
, 0x70aa,
1786 "req_data_len != rsp_data_len\n");
1790 req_data_len
= bsg_job
->request_payload
.payload_len
;
1791 rsp_data_len
= bsg_job
->reply_payload
.payload_len
;
1794 /* Alloc SRB structure */
1795 sp
= qla2x00_get_sp(vha
, &(vha
->bidir_fcport
), GFP_KERNEL
);
1797 ql_dbg(ql_dbg_user
, vha
, 0x70ac,
1798 "Alloc SRB structure failed\n");
1799 rval
= EXT_STATUS_NO_MEMORY
;
1803 /*Populate srb->ctx with bidir ctx*/
1804 sp
->u
.bsg_job
= bsg_job
;
1805 sp
->free
= qla2x00_bsg_sp_free
;
1806 sp
->type
= SRB_BIDI_CMD
;
1807 sp
->done
= qla2x00_bsg_job_done
;
1809 /* Add the read and write sg count */
1810 tot_dsds
= rsp_sg_cnt
+ req_sg_cnt
;
1812 rval
= qla2x00_start_bidir(sp
, vha
, tot_dsds
);
1813 if (rval
!= EXT_STATUS_OK
)
1815 /* the bsg request will be completed in the interrupt handler */
1819 mempool_free(sp
, ha
->srb_mempool
);
1821 dma_unmap_sg(&ha
->pdev
->dev
,
1822 bsg_job
->reply_payload
.sg_list
,
1823 bsg_job
->reply_payload
.sg_cnt
, DMA_FROM_DEVICE
);
1825 dma_unmap_sg(&ha
->pdev
->dev
,
1826 bsg_job
->request_payload
.sg_list
,
1827 bsg_job
->request_payload
.sg_cnt
, DMA_TO_DEVICE
);
1830 /* Return an error vendor specific response
1831 * and complete the bsg request
1833 bsg_job
->reply
->reply_data
.vendor_reply
.vendor_rsp
[0] = rval
;
1834 bsg_job
->reply_len
= sizeof(struct fc_bsg_reply
);
1835 bsg_job
->reply
->reply_payload_rcv_len
= 0;
1836 bsg_job
->reply
->result
= (DID_OK
) << 16;
1837 bsg_job
->job_done(bsg_job
);
1838 /* Always retrun success, vendor rsp carries correct status */
1843 qla2x00_process_vendor_specific(struct fc_bsg_job
*bsg_job
)
1845 switch (bsg_job
->request
->rqst_data
.h_vendor
.vendor_cmd
[0]) {
1846 case QL_VND_LOOPBACK
:
1847 return qla2x00_process_loopback(bsg_job
);
1849 case QL_VND_A84_RESET
:
1850 return qla84xx_reset(bsg_job
);
1852 case QL_VND_A84_UPDATE_FW
:
1853 return qla84xx_updatefw(bsg_job
);
1855 case QL_VND_A84_MGMT_CMD
:
1856 return qla84xx_mgmt_cmd(bsg_job
);
1859 return qla24xx_iidma(bsg_job
);
1861 case QL_VND_FCP_PRIO_CFG_CMD
:
1862 return qla24xx_proc_fcp_prio_cfg_cmd(bsg_job
);
1864 case QL_VND_READ_FLASH
:
1865 return qla2x00_read_optrom(bsg_job
);
1867 case QL_VND_UPDATE_FLASH
:
1868 return qla2x00_update_optrom(bsg_job
);
1870 case QL_VND_SET_FRU_VERSION
:
1871 return qla2x00_update_fru_versions(bsg_job
);
1873 case QL_VND_READ_FRU_STATUS
:
1874 return qla2x00_read_fru_status(bsg_job
);
1876 case QL_VND_WRITE_FRU_STATUS
:
1877 return qla2x00_write_fru_status(bsg_job
);
1879 case QL_VND_WRITE_I2C
:
1880 return qla2x00_write_i2c(bsg_job
);
1882 case QL_VND_READ_I2C
:
1883 return qla2x00_read_i2c(bsg_job
);
1885 case QL_VND_DIAG_IO_CMD
:
1886 return qla24xx_process_bidir_cmd(bsg_job
);
1894 qla24xx_bsg_request(struct fc_bsg_job
*bsg_job
)
1897 struct fc_rport
*rport
;
1898 fc_port_t
*fcport
= NULL
;
1899 struct Scsi_Host
*host
;
1900 scsi_qla_host_t
*vha
;
1902 /* In case no data transferred. */
1903 bsg_job
->reply
->reply_payload_rcv_len
= 0;
1905 if (bsg_job
->request
->msgcode
== FC_BSG_RPT_ELS
) {
1906 rport
= bsg_job
->rport
;
1907 fcport
= *(fc_port_t
**) rport
->dd_data
;
1908 host
= rport_to_shost(rport
);
1909 vha
= shost_priv(host
);
1911 host
= bsg_job
->shost
;
1912 vha
= shost_priv(host
);
1915 if (qla2x00_reset_active(vha
)) {
1916 ql_dbg(ql_dbg_user
, vha
, 0x709f,
1917 "BSG: ISP abort active/needed -- cmd=%d.\n",
1918 bsg_job
->request
->msgcode
);
1922 ql_dbg(ql_dbg_user
, vha
, 0x7000,
1923 "Entered %s msgcode=0x%x.\n", __func__
, bsg_job
->request
->msgcode
);
1925 switch (bsg_job
->request
->msgcode
) {
1926 case FC_BSG_RPT_ELS
:
1927 case FC_BSG_HST_ELS_NOLOGIN
:
1928 ret
= qla2x00_process_els(bsg_job
);
1931 ret
= qla2x00_process_ct(bsg_job
);
1933 case FC_BSG_HST_VENDOR
:
1934 ret
= qla2x00_process_vendor_specific(bsg_job
);
1936 case FC_BSG_HST_ADD_RPORT
:
1937 case FC_BSG_HST_DEL_RPORT
:
1940 ql_log(ql_log_warn
, vha
, 0x705a, "Unsupported BSG request.\n");
1947 qla24xx_bsg_timeout(struct fc_bsg_job
*bsg_job
)
1949 scsi_qla_host_t
*vha
= shost_priv(bsg_job
->shost
);
1950 struct qla_hw_data
*ha
= vha
->hw
;
1953 unsigned long flags
;
1954 struct req_que
*req
;
1956 /* find the bsg job from the active list of commands */
1957 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
1958 for (que
= 0; que
< ha
->max_req_queues
; que
++) {
1959 req
= ha
->req_q_map
[que
];
1963 for (cnt
= 1; cnt
< req
->num_outstanding_cmds
; cnt
++) {
1964 sp
= req
->outstanding_cmds
[cnt
];
1966 if (((sp
->type
== SRB_CT_CMD
) ||
1967 (sp
->type
== SRB_ELS_CMD_HST
))
1968 && (sp
->u
.bsg_job
== bsg_job
)) {
1969 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
1970 if (ha
->isp_ops
->abort_command(sp
)) {
1971 ql_log(ql_log_warn
, vha
, 0x7089,
1972 "mbx abort_command "
1974 bsg_job
->req
->errors
=
1975 bsg_job
->reply
->result
= -EIO
;
1977 ql_dbg(ql_dbg_user
, vha
, 0x708a,
1978 "mbx abort_command "
1980 bsg_job
->req
->errors
=
1981 bsg_job
->reply
->result
= 0;
1983 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
1989 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
1990 ql_log(ql_log_info
, vha
, 0x708b, "SRB not found to abort.\n");
1991 bsg_job
->req
->errors
= bsg_job
->reply
->result
= -ENXIO
;
1995 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
1996 if (bsg_job
->request
->msgcode
== FC_BSG_HST_CT
)
1998 qla2x00_rel_sp(vha
, sp
);