2 * QLogic Fibre Channel HBA Driver
3 * Copyright (c) 2003-2014 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
;
20 struct fc_bsg_reply
*bsg_reply
= bsg_job
->reply
;
22 bsg_reply
->result
= res
;
23 bsg_job
->job_done(bsg_job
);
28 qla2x00_bsg_sp_free(void *data
, void *ptr
)
30 srb_t
*sp
= (srb_t
*)ptr
;
31 struct scsi_qla_host
*vha
= sp
->fcport
->vha
;
32 struct fc_bsg_job
*bsg_job
= sp
->u
.bsg_job
;
33 struct fc_bsg_request
*bsg_request
= bsg_job
->request
;
35 struct qla_hw_data
*ha
= vha
->hw
;
36 struct qla_mt_iocb_rqst_fx00
*piocb_rqst
;
38 if (sp
->type
== SRB_FXIOCB_BCMD
) {
39 piocb_rqst
= (struct qla_mt_iocb_rqst_fx00
*)
40 &bsg_request
->rqst_data
.h_vendor
.vendor_cmd
[1];
42 if (piocb_rqst
->flags
& SRB_FXDISC_REQ_DMA_VALID
)
43 dma_unmap_sg(&ha
->pdev
->dev
,
44 bsg_job
->request_payload
.sg_list
,
45 bsg_job
->request_payload
.sg_cnt
, DMA_TO_DEVICE
);
47 if (piocb_rqst
->flags
& SRB_FXDISC_RESP_DMA_VALID
)
48 dma_unmap_sg(&ha
->pdev
->dev
,
49 bsg_job
->reply_payload
.sg_list
,
50 bsg_job
->reply_payload
.sg_cnt
, DMA_FROM_DEVICE
);
52 dma_unmap_sg(&ha
->pdev
->dev
, bsg_job
->request_payload
.sg_list
,
53 bsg_job
->request_payload
.sg_cnt
, DMA_TO_DEVICE
);
55 dma_unmap_sg(&ha
->pdev
->dev
, bsg_job
->reply_payload
.sg_list
,
56 bsg_job
->reply_payload
.sg_cnt
, DMA_FROM_DEVICE
);
59 if (sp
->type
== SRB_CT_CMD
||
60 sp
->type
== SRB_FXIOCB_BCMD
||
61 sp
->type
== SRB_ELS_CMD_HST
)
63 qla2x00_rel_sp(vha
, sp
);
67 qla24xx_fcp_prio_cfg_valid(scsi_qla_host_t
*vha
,
68 struct qla_fcp_prio_cfg
*pri_cfg
, uint8_t flag
)
70 int i
, ret
, num_valid
;
72 struct qla_fcp_prio_entry
*pri_entry
;
73 uint32_t *bcode_val_ptr
, bcode_val
;
77 bcode
= (uint8_t *)pri_cfg
;
78 bcode_val_ptr
= (uint32_t *)pri_cfg
;
79 bcode_val
= (uint32_t)(*bcode_val_ptr
);
81 if (bcode_val
== 0xFFFFFFFF) {
82 /* No FCP Priority config data in flash */
83 ql_dbg(ql_dbg_user
, vha
, 0x7051,
84 "No FCP Priority config data.\n");
88 if (bcode
[0] != 'H' || bcode
[1] != 'Q' || bcode
[2] != 'O' ||
90 /* Invalid FCP priority data header*/
91 ql_dbg(ql_dbg_user
, vha
, 0x7052,
92 "Invalid FCP Priority data header. bcode=0x%x.\n",
99 pri_entry
= &pri_cfg
->entry
[0];
100 for (i
= 0; i
< pri_cfg
->num_entries
; i
++) {
101 if (pri_entry
->flags
& FCP_PRIO_ENTRY_TAG_VALID
)
106 if (num_valid
== 0) {
107 /* No valid FCP priority data entries */
108 ql_dbg(ql_dbg_user
, vha
, 0x7053,
109 "No valid FCP Priority data entries.\n");
112 /* FCP priority data is valid */
113 ql_dbg(ql_dbg_user
, vha
, 0x7054,
114 "Valid FCP priority data. num entries = %d.\n",
122 qla24xx_proc_fcp_prio_cfg_cmd(struct fc_bsg_job
*bsg_job
)
124 struct Scsi_Host
*host
= bsg_job
->shost
;
125 struct fc_bsg_request
*bsg_request
= bsg_job
->request
;
126 struct fc_bsg_reply
*bsg_reply
= bsg_job
->reply
;
127 scsi_qla_host_t
*vha
= shost_priv(host
);
128 struct qla_hw_data
*ha
= vha
->hw
;
133 if (!(IS_QLA24XX_TYPE(ha
) || IS_QLA25XX(ha
) || IS_P3P_TYPE(ha
))) {
135 goto exit_fcp_prio_cfg
;
138 /* Get the sub command */
139 oper
= bsg_request
->rqst_data
.h_vendor
.vendor_cmd
[1];
141 /* Only set config is allowed if config memory is not allocated */
142 if (!ha
->fcp_prio_cfg
&& (oper
!= QLFC_FCP_PRIO_SET_CONFIG
)) {
144 goto exit_fcp_prio_cfg
;
147 case QLFC_FCP_PRIO_DISABLE
:
148 if (ha
->flags
.fcp_prio_enabled
) {
149 ha
->flags
.fcp_prio_enabled
= 0;
150 ha
->fcp_prio_cfg
->attributes
&=
151 ~FCP_PRIO_ATTR_ENABLE
;
152 qla24xx_update_all_fcp_prio(vha
);
153 bsg_reply
->result
= DID_OK
;
156 bsg_reply
->result
= (DID_ERROR
<< 16);
157 goto exit_fcp_prio_cfg
;
161 case QLFC_FCP_PRIO_ENABLE
:
162 if (!ha
->flags
.fcp_prio_enabled
) {
163 if (ha
->fcp_prio_cfg
) {
164 ha
->flags
.fcp_prio_enabled
= 1;
165 ha
->fcp_prio_cfg
->attributes
|=
166 FCP_PRIO_ATTR_ENABLE
;
167 qla24xx_update_all_fcp_prio(vha
);
168 bsg_reply
->result
= DID_OK
;
171 bsg_reply
->result
= (DID_ERROR
<< 16);
172 goto exit_fcp_prio_cfg
;
177 case QLFC_FCP_PRIO_GET_CONFIG
:
178 len
= bsg_job
->reply_payload
.payload_len
;
179 if (!len
|| len
> FCP_PRIO_CFG_SIZE
) {
181 bsg_reply
->result
= (DID_ERROR
<< 16);
182 goto exit_fcp_prio_cfg
;
185 bsg_reply
->result
= DID_OK
;
186 bsg_reply
->reply_payload_rcv_len
=
188 bsg_job
->reply_payload
.sg_list
,
189 bsg_job
->reply_payload
.sg_cnt
, ha
->fcp_prio_cfg
,
194 case QLFC_FCP_PRIO_SET_CONFIG
:
195 len
= bsg_job
->request_payload
.payload_len
;
196 if (!len
|| len
> FCP_PRIO_CFG_SIZE
) {
197 bsg_reply
->result
= (DID_ERROR
<< 16);
199 goto exit_fcp_prio_cfg
;
202 if (!ha
->fcp_prio_cfg
) {
203 ha
->fcp_prio_cfg
= vmalloc(FCP_PRIO_CFG_SIZE
);
204 if (!ha
->fcp_prio_cfg
) {
205 ql_log(ql_log_warn
, vha
, 0x7050,
206 "Unable to allocate memory for fcp prio "
207 "config data (%x).\n", FCP_PRIO_CFG_SIZE
);
208 bsg_reply
->result
= (DID_ERROR
<< 16);
210 goto exit_fcp_prio_cfg
;
214 memset(ha
->fcp_prio_cfg
, 0, FCP_PRIO_CFG_SIZE
);
215 sg_copy_to_buffer(bsg_job
->request_payload
.sg_list
,
216 bsg_job
->request_payload
.sg_cnt
, ha
->fcp_prio_cfg
,
219 /* validate fcp priority data */
221 if (!qla24xx_fcp_prio_cfg_valid(vha
,
222 (struct qla_fcp_prio_cfg
*) ha
->fcp_prio_cfg
, 1)) {
223 bsg_reply
->result
= (DID_ERROR
<< 16);
225 /* If buffer was invalidatic int
226 * fcp_prio_cfg is of no use
228 vfree(ha
->fcp_prio_cfg
);
229 ha
->fcp_prio_cfg
= NULL
;
230 goto exit_fcp_prio_cfg
;
233 ha
->flags
.fcp_prio_enabled
= 0;
234 if (ha
->fcp_prio_cfg
->attributes
& FCP_PRIO_ATTR_ENABLE
)
235 ha
->flags
.fcp_prio_enabled
= 1;
236 qla24xx_update_all_fcp_prio(vha
);
237 bsg_reply
->result
= DID_OK
;
245 bsg_job
->job_done(bsg_job
);
250 qla2x00_process_els(struct fc_bsg_job
*bsg_job
)
252 struct fc_bsg_request
*bsg_request
= bsg_job
->request
;
253 struct fc_rport
*rport
;
254 fc_port_t
*fcport
= NULL
;
255 struct Scsi_Host
*host
;
256 scsi_qla_host_t
*vha
;
257 struct qla_hw_data
*ha
;
260 int req_sg_cnt
, rsp_sg_cnt
;
261 int rval
= (DRIVER_ERROR
<< 16);
262 uint16_t nextlid
= 0;
264 if (bsg_request
->msgcode
== FC_BSG_RPT_ELS
) {
265 rport
= bsg_job
->rport
;
266 fcport
= *(fc_port_t
**) rport
->dd_data
;
267 host
= rport_to_shost(rport
);
268 vha
= shost_priv(host
);
270 type
= "FC_BSG_RPT_ELS";
272 host
= bsg_job
->shost
;
273 vha
= shost_priv(host
);
275 type
= "FC_BSG_HST_ELS_NOLOGIN";
278 if (!vha
->flags
.online
) {
279 ql_log(ql_log_warn
, vha
, 0x7005, "Host not online.\n");
284 /* pass through is supported only for ISP 4Gb or higher */
285 if (!IS_FWI2_CAPABLE(ha
)) {
286 ql_dbg(ql_dbg_user
, vha
, 0x7001,
287 "ELS passthru not supported for ISP23xx based adapters.\n");
292 /* Multiple SG's are not supported for ELS requests */
293 if (bsg_job
->request_payload
.sg_cnt
> 1 ||
294 bsg_job
->reply_payload
.sg_cnt
> 1) {
295 ql_dbg(ql_dbg_user
, vha
, 0x7002,
296 "Multiple SG's are not suppored for ELS requests, "
297 "request_sg_cnt=%x reply_sg_cnt=%x.\n",
298 bsg_job
->request_payload
.sg_cnt
,
299 bsg_job
->reply_payload
.sg_cnt
);
304 /* ELS request for rport */
305 if (bsg_request
->msgcode
== FC_BSG_RPT_ELS
) {
306 /* make sure the rport is logged in,
307 * if not perform fabric login
309 if (qla2x00_fabric_login(vha
, fcport
, &nextlid
)) {
310 ql_dbg(ql_dbg_user
, vha
, 0x7003,
311 "Failed to login port %06X for ELS passthru.\n",
317 /* Allocate a dummy fcport structure, since functions
318 * preparing the IOCB and mailbox command retrieves port
319 * specific information from fcport structure. For Host based
320 * ELS commands there will be no fcport structure allocated
322 fcport
= qla2x00_alloc_fcport(vha
, GFP_KERNEL
);
328 /* Initialize all required fields of fcport */
330 fcport
->d_id
.b
.al_pa
=
331 bsg_request
->rqst_data
.h_els
.port_id
[0];
332 fcport
->d_id
.b
.area
=
333 bsg_request
->rqst_data
.h_els
.port_id
[1];
334 fcport
->d_id
.b
.domain
=
335 bsg_request
->rqst_data
.h_els
.port_id
[2];
337 (fcport
->d_id
.b
.al_pa
== 0xFD) ?
338 NPH_FABRIC_CONTROLLER
: NPH_F_PORT
;
342 dma_map_sg(&ha
->pdev
->dev
, bsg_job
->request_payload
.sg_list
,
343 bsg_job
->request_payload
.sg_cnt
, DMA_TO_DEVICE
);
346 goto done_free_fcport
;
349 rsp_sg_cnt
= dma_map_sg(&ha
->pdev
->dev
, bsg_job
->reply_payload
.sg_list
,
350 bsg_job
->reply_payload
.sg_cnt
, DMA_FROM_DEVICE
);
353 goto done_free_fcport
;
356 if ((req_sg_cnt
!= bsg_job
->request_payload
.sg_cnt
) ||
357 (rsp_sg_cnt
!= bsg_job
->reply_payload
.sg_cnt
)) {
358 ql_log(ql_log_warn
, vha
, 0x7008,
359 "dma mapping resulted in different sg counts, "
360 "request_sg_cnt: %x dma_request_sg_cnt:%x reply_sg_cnt:%x "
361 "dma_reply_sg_cnt:%x.\n", bsg_job
->request_payload
.sg_cnt
,
362 req_sg_cnt
, bsg_job
->reply_payload
.sg_cnt
, rsp_sg_cnt
);
367 /* Alloc SRB structure */
368 sp
= qla2x00_get_sp(vha
, fcport
, GFP_KERNEL
);
375 (bsg_request
->msgcode
== FC_BSG_RPT_ELS
?
376 SRB_ELS_CMD_RPT
: SRB_ELS_CMD_HST
);
378 (bsg_request
->msgcode
== FC_BSG_RPT_ELS
?
379 "bsg_els_rpt" : "bsg_els_hst");
380 sp
->u
.bsg_job
= bsg_job
;
381 sp
->free
= qla2x00_bsg_sp_free
;
382 sp
->done
= qla2x00_bsg_job_done
;
384 ql_dbg(ql_dbg_user
, vha
, 0x700a,
385 "bsg rqst type: %s els type: %x - loop-id=%x "
386 "portid=%-2x%02x%02x.\n", type
,
387 bsg_request
->rqst_data
.h_els
.command_code
, fcport
->loop_id
,
388 fcport
->d_id
.b
.domain
, fcport
->d_id
.b
.area
, fcport
->d_id
.b
.al_pa
);
390 rval
= qla2x00_start_sp(sp
);
391 if (rval
!= QLA_SUCCESS
) {
392 ql_log(ql_log_warn
, vha
, 0x700e,
393 "qla2x00_start_sp failed = %d\n", rval
);
394 qla2x00_rel_sp(vha
, sp
);
401 dma_unmap_sg(&ha
->pdev
->dev
, bsg_job
->request_payload
.sg_list
,
402 bsg_job
->request_payload
.sg_cnt
, DMA_TO_DEVICE
);
403 dma_unmap_sg(&ha
->pdev
->dev
, bsg_job
->reply_payload
.sg_list
,
404 bsg_job
->reply_payload
.sg_cnt
, DMA_FROM_DEVICE
);
405 goto done_free_fcport
;
408 if (bsg_request
->msgcode
== FC_BSG_RPT_ELS
)
414 static inline uint16_t
415 qla24xx_calc_ct_iocbs(uint16_t dsds
)
421 iocbs
+= (dsds
- 2) / 5;
429 qla2x00_process_ct(struct fc_bsg_job
*bsg_job
)
432 struct fc_bsg_request
*bsg_request
= bsg_job
->request
;
433 struct Scsi_Host
*host
= bsg_job
->shost
;
434 scsi_qla_host_t
*vha
= shost_priv(host
);
435 struct qla_hw_data
*ha
= vha
->hw
;
436 int rval
= (DRIVER_ERROR
<< 16);
437 int req_sg_cnt
, rsp_sg_cnt
;
439 struct fc_port
*fcport
;
440 char *type
= "FC_BSG_HST_CT";
443 dma_map_sg(&ha
->pdev
->dev
, bsg_job
->request_payload
.sg_list
,
444 bsg_job
->request_payload
.sg_cnt
, DMA_TO_DEVICE
);
446 ql_log(ql_log_warn
, vha
, 0x700f,
447 "dma_map_sg return %d for request\n", req_sg_cnt
);
452 rsp_sg_cnt
= dma_map_sg(&ha
->pdev
->dev
, bsg_job
->reply_payload
.sg_list
,
453 bsg_job
->reply_payload
.sg_cnt
, DMA_FROM_DEVICE
);
455 ql_log(ql_log_warn
, vha
, 0x7010,
456 "dma_map_sg return %d for reply\n", rsp_sg_cnt
);
461 if ((req_sg_cnt
!= bsg_job
->request_payload
.sg_cnt
) ||
462 (rsp_sg_cnt
!= bsg_job
->reply_payload
.sg_cnt
)) {
463 ql_log(ql_log_warn
, vha
, 0x7011,
464 "request_sg_cnt: %x dma_request_sg_cnt: %x reply_sg_cnt:%x "
465 "dma_reply_sg_cnt: %x\n", bsg_job
->request_payload
.sg_cnt
,
466 req_sg_cnt
, bsg_job
->reply_payload
.sg_cnt
, rsp_sg_cnt
);
471 if (!vha
->flags
.online
) {
472 ql_log(ql_log_warn
, vha
, 0x7012,
473 "Host is not online.\n");
479 (bsg_request
->rqst_data
.h_ct
.preamble_word1
& 0xFF000000)
483 loop_id
= cpu_to_le16(NPH_SNS
);
486 loop_id
= vha
->mgmt_svr_loop_id
;
489 ql_dbg(ql_dbg_user
, vha
, 0x7013,
490 "Unknown loop id: %x.\n", loop_id
);
495 /* Allocate a dummy fcport structure, since functions preparing the
496 * IOCB and mailbox command retrieves port specific information
497 * from fcport structure. For Host based ELS commands there will be
498 * no fcport structure allocated
500 fcport
= qla2x00_alloc_fcport(vha
, GFP_KERNEL
);
502 ql_log(ql_log_warn
, vha
, 0x7014,
503 "Failed to allocate fcport.\n");
508 /* Initialize all required fields of fcport */
510 fcport
->d_id
.b
.al_pa
= bsg_request
->rqst_data
.h_ct
.port_id
[0];
511 fcport
->d_id
.b
.area
= bsg_request
->rqst_data
.h_ct
.port_id
[1];
512 fcport
->d_id
.b
.domain
= bsg_request
->rqst_data
.h_ct
.port_id
[2];
513 fcport
->loop_id
= loop_id
;
515 /* Alloc SRB structure */
516 sp
= qla2x00_get_sp(vha
, fcport
, GFP_KERNEL
);
518 ql_log(ql_log_warn
, vha
, 0x7015,
519 "qla2x00_get_sp failed.\n");
521 goto done_free_fcport
;
524 sp
->type
= SRB_CT_CMD
;
526 sp
->iocbs
= qla24xx_calc_ct_iocbs(req_sg_cnt
+ rsp_sg_cnt
);
527 sp
->u
.bsg_job
= bsg_job
;
528 sp
->free
= qla2x00_bsg_sp_free
;
529 sp
->done
= qla2x00_bsg_job_done
;
531 ql_dbg(ql_dbg_user
, vha
, 0x7016,
532 "bsg rqst type: %s else type: %x - "
533 "loop-id=%x portid=%02x%02x%02x.\n", type
,
534 (bsg_request
->rqst_data
.h_ct
.preamble_word2
>> 16),
535 fcport
->loop_id
, fcport
->d_id
.b
.domain
, fcport
->d_id
.b
.area
,
536 fcport
->d_id
.b
.al_pa
);
538 rval
= qla2x00_start_sp(sp
);
539 if (rval
!= QLA_SUCCESS
) {
540 ql_log(ql_log_warn
, vha
, 0x7017,
541 "qla2x00_start_sp failed=%d.\n", rval
);
542 qla2x00_rel_sp(vha
, sp
);
544 goto done_free_fcport
;
551 dma_unmap_sg(&ha
->pdev
->dev
, bsg_job
->request_payload
.sg_list
,
552 bsg_job
->request_payload
.sg_cnt
, DMA_TO_DEVICE
);
553 dma_unmap_sg(&ha
->pdev
->dev
, bsg_job
->reply_payload
.sg_list
,
554 bsg_job
->reply_payload
.sg_cnt
, DMA_FROM_DEVICE
);
559 /* Disable loopback mode */
561 qla81xx_reset_loopback_mode(scsi_qla_host_t
*vha
, uint16_t *config
,
566 uint16_t new_config
[4];
567 struct qla_hw_data
*ha
= vha
->hw
;
569 if (!IS_QLA81XX(ha
) && !IS_QLA8031(ha
) && !IS_QLA8044(ha
))
570 goto done_reset_internal
;
572 memset(new_config
, 0 , sizeof(new_config
));
573 if ((config
[0] & INTERNAL_LOOPBACK_MASK
) >> 1 ==
574 ENABLE_INTERNAL_LOOPBACK
||
575 (config
[0] & INTERNAL_LOOPBACK_MASK
) >> 1 ==
576 ENABLE_EXTERNAL_LOOPBACK
) {
577 new_config
[0] = config
[0] & ~INTERNAL_LOOPBACK_MASK
;
578 ql_dbg(ql_dbg_user
, vha
, 0x70bf, "new_config[0]=%02x\n",
579 (new_config
[0] & INTERNAL_LOOPBACK_MASK
));
580 memcpy(&new_config
[1], &config
[1], sizeof(uint16_t) * 3) ;
582 ha
->notify_dcbx_comp
= wait
;
583 ha
->notify_lb_portup_comp
= wait2
;
585 ret
= qla81xx_set_port_config(vha
, new_config
);
586 if (ret
!= QLA_SUCCESS
) {
587 ql_log(ql_log_warn
, vha
, 0x7025,
588 "Set port config failed.\n");
589 ha
->notify_dcbx_comp
= 0;
590 ha
->notify_lb_portup_comp
= 0;
592 goto done_reset_internal
;
595 /* Wait for DCBX complete event */
596 if (wait
&& !wait_for_completion_timeout(&ha
->dcbx_comp
,
597 (DCBX_COMP_TIMEOUT
* HZ
))) {
598 ql_dbg(ql_dbg_user
, vha
, 0x7026,
599 "DCBX completion not received.\n");
600 ha
->notify_dcbx_comp
= 0;
601 ha
->notify_lb_portup_comp
= 0;
603 goto done_reset_internal
;
605 ql_dbg(ql_dbg_user
, vha
, 0x7027,
606 "DCBX completion received.\n");
609 !wait_for_completion_timeout(&ha
->lb_portup_comp
,
610 (LB_PORTUP_COMP_TIMEOUT
* HZ
))) {
611 ql_dbg(ql_dbg_user
, vha
, 0x70c5,
612 "Port up completion not received.\n");
613 ha
->notify_lb_portup_comp
= 0;
615 goto done_reset_internal
;
617 ql_dbg(ql_dbg_user
, vha
, 0x70c6,
618 "Port up completion received.\n");
620 ha
->notify_dcbx_comp
= 0;
621 ha
->notify_lb_portup_comp
= 0;
628 * Set the port configuration to enable the internal or external loopback
629 * depending on the loopback mode.
632 qla81xx_set_loopback_mode(scsi_qla_host_t
*vha
, uint16_t *config
,
633 uint16_t *new_config
, uint16_t mode
)
637 unsigned long rem_tmo
= 0, current_tmo
= 0;
638 struct qla_hw_data
*ha
= vha
->hw
;
640 if (!IS_QLA81XX(ha
) && !IS_QLA8031(ha
) && !IS_QLA8044(ha
))
641 goto done_set_internal
;
643 if (mode
== INTERNAL_LOOPBACK
)
644 new_config
[0] = config
[0] | (ENABLE_INTERNAL_LOOPBACK
<< 1);
645 else if (mode
== EXTERNAL_LOOPBACK
)
646 new_config
[0] = config
[0] | (ENABLE_EXTERNAL_LOOPBACK
<< 1);
647 ql_dbg(ql_dbg_user
, vha
, 0x70be,
648 "new_config[0]=%02x\n", (new_config
[0] & INTERNAL_LOOPBACK_MASK
));
650 memcpy(&new_config
[1], &config
[1], sizeof(uint16_t) * 3);
652 ha
->notify_dcbx_comp
= 1;
653 ret
= qla81xx_set_port_config(vha
, new_config
);
654 if (ret
!= QLA_SUCCESS
) {
655 ql_log(ql_log_warn
, vha
, 0x7021,
656 "set port config failed.\n");
657 ha
->notify_dcbx_comp
= 0;
659 goto done_set_internal
;
662 /* Wait for DCBX complete event */
663 current_tmo
= DCBX_COMP_TIMEOUT
* HZ
;
665 rem_tmo
= wait_for_completion_timeout(&ha
->dcbx_comp
,
667 if (!ha
->idc_extend_tmo
|| rem_tmo
) {
668 ha
->idc_extend_tmo
= 0;
671 current_tmo
= ha
->idc_extend_tmo
* HZ
;
672 ha
->idc_extend_tmo
= 0;
676 ql_dbg(ql_dbg_user
, vha
, 0x7022,
677 "DCBX completion not received.\n");
678 ret
= qla81xx_reset_loopback_mode(vha
, new_config
, 0, 0);
680 * If the reset of the loopback mode doesn't work take a FCoE
681 * dump and reset the chip.
684 ha
->isp_ops
->fw_dump(vha
, 0);
685 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
689 if (ha
->flags
.idc_compl_status
) {
690 ql_dbg(ql_dbg_user
, vha
, 0x70c3,
691 "Bad status in IDC Completion AEN\n");
693 ha
->flags
.idc_compl_status
= 0;
695 ql_dbg(ql_dbg_user
, vha
, 0x7023,
696 "DCBX completion received.\n");
699 ha
->notify_dcbx_comp
= 0;
700 ha
->idc_extend_tmo
= 0;
707 qla2x00_process_loopback(struct fc_bsg_job
*bsg_job
)
709 struct fc_bsg_request
*bsg_request
= bsg_job
->request
;
710 struct fc_bsg_reply
*bsg_reply
= bsg_job
->reply
;
711 struct Scsi_Host
*host
= bsg_job
->shost
;
712 scsi_qla_host_t
*vha
= shost_priv(host
);
713 struct qla_hw_data
*ha
= vha
->hw
;
715 uint8_t command_sent
;
717 struct msg_echo_lb elreq
;
718 uint16_t response
[MAILBOX_REGISTER_COUNT
];
719 uint16_t config
[4], new_config
[4];
721 uint8_t *req_data
= NULL
;
722 dma_addr_t req_data_dma
;
723 uint32_t req_data_len
;
724 uint8_t *rsp_data
= NULL
;
725 dma_addr_t rsp_data_dma
;
726 uint32_t rsp_data_len
;
728 if (!vha
->flags
.online
) {
729 ql_log(ql_log_warn
, vha
, 0x7019, "Host is not online.\n");
733 elreq
.req_sg_cnt
= dma_map_sg(&ha
->pdev
->dev
,
734 bsg_job
->request_payload
.sg_list
, bsg_job
->request_payload
.sg_cnt
,
737 if (!elreq
.req_sg_cnt
) {
738 ql_log(ql_log_warn
, vha
, 0x701a,
739 "dma_map_sg returned %d for request.\n", elreq
.req_sg_cnt
);
743 elreq
.rsp_sg_cnt
= dma_map_sg(&ha
->pdev
->dev
,
744 bsg_job
->reply_payload
.sg_list
, bsg_job
->reply_payload
.sg_cnt
,
747 if (!elreq
.rsp_sg_cnt
) {
748 ql_log(ql_log_warn
, vha
, 0x701b,
749 "dma_map_sg returned %d for reply.\n", elreq
.rsp_sg_cnt
);
751 goto done_unmap_req_sg
;
754 if ((elreq
.req_sg_cnt
!= bsg_job
->request_payload
.sg_cnt
) ||
755 (elreq
.rsp_sg_cnt
!= bsg_job
->reply_payload
.sg_cnt
)) {
756 ql_log(ql_log_warn
, vha
, 0x701c,
757 "dma mapping resulted in different sg counts, "
758 "request_sg_cnt: %x dma_request_sg_cnt: %x "
759 "reply_sg_cnt: %x dma_reply_sg_cnt: %x.\n",
760 bsg_job
->request_payload
.sg_cnt
, elreq
.req_sg_cnt
,
761 bsg_job
->reply_payload
.sg_cnt
, elreq
.rsp_sg_cnt
);
765 req_data_len
= rsp_data_len
= bsg_job
->request_payload
.payload_len
;
766 req_data
= dma_alloc_coherent(&ha
->pdev
->dev
, req_data_len
,
767 &req_data_dma
, GFP_KERNEL
);
769 ql_log(ql_log_warn
, vha
, 0x701d,
770 "dma alloc failed for req_data.\n");
775 rsp_data
= dma_alloc_coherent(&ha
->pdev
->dev
, rsp_data_len
,
776 &rsp_data_dma
, GFP_KERNEL
);
778 ql_log(ql_log_warn
, vha
, 0x7004,
779 "dma alloc failed for rsp_data.\n");
781 goto done_free_dma_req
;
784 /* Copy the request buffer in req_data now */
785 sg_copy_to_buffer(bsg_job
->request_payload
.sg_list
,
786 bsg_job
->request_payload
.sg_cnt
, req_data
, req_data_len
);
788 elreq
.send_dma
= req_data_dma
;
789 elreq
.rcv_dma
= rsp_data_dma
;
790 elreq
.transfer_size
= req_data_len
;
792 elreq
.options
= bsg_request
->rqst_data
.h_vendor
.vendor_cmd
[1];
793 elreq
.iteration_count
=
794 bsg_request
->rqst_data
.h_vendor
.vendor_cmd
[2];
796 if (atomic_read(&vha
->loop_state
) == LOOP_READY
&&
797 (ha
->current_topology
== ISP_CFG_F
||
798 ((IS_QLA81XX(ha
) || IS_QLA8031(ha
) || IS_QLA8044(ha
)) &&
799 le32_to_cpu(*(uint32_t *)req_data
) == ELS_OPCODE_BYTE
800 && req_data_len
== MAX_ELS_FRAME_PAYLOAD
)) &&
801 elreq
.options
== EXTERNAL_LOOPBACK
) {
802 type
= "FC_BSG_HST_VENDOR_ECHO_DIAG";
803 ql_dbg(ql_dbg_user
, vha
, 0x701e,
804 "BSG request type: %s.\n", type
);
805 command_sent
= INT_DEF_LB_ECHO_CMD
;
806 rval
= qla2x00_echo_test(vha
, &elreq
, response
);
808 if (IS_QLA81XX(ha
) || IS_QLA8031(ha
) || IS_QLA8044(ha
)) {
809 memset(config
, 0, sizeof(config
));
810 memset(new_config
, 0, sizeof(new_config
));
812 if (qla81xx_get_port_config(vha
, config
)) {
813 ql_log(ql_log_warn
, vha
, 0x701f,
814 "Get port config failed.\n");
816 goto done_free_dma_rsp
;
819 if ((config
[0] & INTERNAL_LOOPBACK_MASK
) != 0) {
820 ql_dbg(ql_dbg_user
, vha
, 0x70c4,
821 "Loopback operation already in "
824 goto done_free_dma_rsp
;
827 ql_dbg(ql_dbg_user
, vha
, 0x70c0,
828 "elreq.options=%04x\n", elreq
.options
);
830 if (elreq
.options
== EXTERNAL_LOOPBACK
)
831 if (IS_QLA8031(ha
) || IS_QLA8044(ha
))
832 rval
= qla81xx_set_loopback_mode(vha
,
833 config
, new_config
, elreq
.options
);
835 rval
= qla81xx_reset_loopback_mode(vha
,
838 rval
= qla81xx_set_loopback_mode(vha
, config
,
839 new_config
, elreq
.options
);
843 goto done_free_dma_rsp
;
846 type
= "FC_BSG_HST_VENDOR_LOOPBACK";
847 ql_dbg(ql_dbg_user
, vha
, 0x7028,
848 "BSG request type: %s.\n", type
);
850 command_sent
= INT_DEF_LB_LOOPBACK_CMD
;
851 rval
= qla2x00_loopback_test(vha
, &elreq
, response
);
853 if (response
[0] == MBS_COMMAND_ERROR
&&
854 response
[1] == MBS_LB_RESET
) {
855 ql_log(ql_log_warn
, vha
, 0x7029,
856 "MBX command error, Aborting ISP.\n");
857 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
858 qla2xxx_wake_dpc(vha
);
859 qla2x00_wait_for_chip_reset(vha
);
860 /* Also reset the MPI */
861 if (IS_QLA81XX(ha
)) {
862 if (qla81xx_restart_mpi_firmware(vha
) !=
864 ql_log(ql_log_warn
, vha
, 0x702a,
865 "MPI reset failed.\n");
870 goto done_free_dma_rsp
;
876 /* Revert back to original port config
877 * Also clear internal loopback
879 ret
= qla81xx_reset_loopback_mode(vha
,
883 * If the reset of the loopback mode
884 * doesn't work take FCoE dump and then
887 ha
->isp_ops
->fw_dump(vha
, 0);
888 set_bit(ISP_ABORT_NEEDED
,
895 type
= "FC_BSG_HST_VENDOR_LOOPBACK";
896 ql_dbg(ql_dbg_user
, vha
, 0x702b,
897 "BSG request type: %s.\n", type
);
898 command_sent
= INT_DEF_LB_LOOPBACK_CMD
;
899 rval
= qla2x00_loopback_test(vha
, &elreq
, response
);
904 ql_log(ql_log_warn
, vha
, 0x702c,
905 "Vendor request %s failed.\n", type
);
908 bsg_reply
->result
= (DID_ERROR
<< 16);
909 bsg_reply
->reply_payload_rcv_len
= 0;
911 ql_dbg(ql_dbg_user
, vha
, 0x702d,
912 "Vendor request %s completed.\n", type
);
913 bsg_reply
->result
= (DID_OK
<< 16);
914 sg_copy_from_buffer(bsg_job
->reply_payload
.sg_list
,
915 bsg_job
->reply_payload
.sg_cnt
, rsp_data
,
919 bsg_job
->reply_len
= sizeof(struct fc_bsg_reply
) +
920 sizeof(response
) + sizeof(uint8_t);
921 fw_sts_ptr
= ((uint8_t *)bsg_job
->req
->sense
) +
922 sizeof(struct fc_bsg_reply
);
923 memcpy(fw_sts_ptr
, response
, sizeof(response
));
924 fw_sts_ptr
+= sizeof(response
);
925 *fw_sts_ptr
= command_sent
;
928 dma_free_coherent(&ha
->pdev
->dev
, rsp_data_len
,
929 rsp_data
, rsp_data_dma
);
931 dma_free_coherent(&ha
->pdev
->dev
, req_data_len
,
932 req_data
, req_data_dma
);
934 dma_unmap_sg(&ha
->pdev
->dev
,
935 bsg_job
->reply_payload
.sg_list
,
936 bsg_job
->reply_payload
.sg_cnt
, DMA_FROM_DEVICE
);
938 dma_unmap_sg(&ha
->pdev
->dev
,
939 bsg_job
->request_payload
.sg_list
,
940 bsg_job
->request_payload
.sg_cnt
, DMA_TO_DEVICE
);
942 bsg_job
->job_done(bsg_job
);
947 qla84xx_reset(struct fc_bsg_job
*bsg_job
)
949 struct fc_bsg_request
*bsg_request
= bsg_job
->request
;
950 struct Scsi_Host
*host
= bsg_job
->shost
;
951 struct fc_bsg_reply
*bsg_reply
= bsg_job
->reply
;
952 scsi_qla_host_t
*vha
= shost_priv(host
);
953 struct qla_hw_data
*ha
= vha
->hw
;
957 if (!IS_QLA84XX(ha
)) {
958 ql_dbg(ql_dbg_user
, vha
, 0x702f, "Not 84xx, exiting.\n");
962 flag
= bsg_request
->rqst_data
.h_vendor
.vendor_cmd
[1];
964 rval
= qla84xx_reset_chip(vha
, flag
== A84_ISSUE_RESET_DIAG_FW
);
967 ql_log(ql_log_warn
, vha
, 0x7030,
968 "Vendor request 84xx reset failed.\n");
969 rval
= (DID_ERROR
<< 16);
972 ql_dbg(ql_dbg_user
, vha
, 0x7031,
973 "Vendor request 84xx reset completed.\n");
974 bsg_reply
->result
= DID_OK
;
975 bsg_job
->job_done(bsg_job
);
982 qla84xx_updatefw(struct fc_bsg_job
*bsg_job
)
984 struct fc_bsg_request
*bsg_request
= bsg_job
->request
;
985 struct fc_bsg_reply
*bsg_reply
= bsg_job
->reply
;
986 struct Scsi_Host
*host
= bsg_job
->shost
;
987 scsi_qla_host_t
*vha
= shost_priv(host
);
988 struct qla_hw_data
*ha
= vha
->hw
;
989 struct verify_chip_entry_84xx
*mn
= NULL
;
990 dma_addr_t mn_dma
, fw_dma
;
999 if (!IS_QLA84XX(ha
)) {
1000 ql_dbg(ql_dbg_user
, vha
, 0x7032,
1001 "Not 84xx, exiting.\n");
1005 sg_cnt
= dma_map_sg(&ha
->pdev
->dev
, bsg_job
->request_payload
.sg_list
,
1006 bsg_job
->request_payload
.sg_cnt
, DMA_TO_DEVICE
);
1008 ql_log(ql_log_warn
, vha
, 0x7033,
1009 "dma_map_sg returned %d for request.\n", sg_cnt
);
1013 if (sg_cnt
!= bsg_job
->request_payload
.sg_cnt
) {
1014 ql_log(ql_log_warn
, vha
, 0x7034,
1015 "DMA mapping resulted in different sg counts, "
1016 "request_sg_cnt: %x dma_request_sg_cnt: %x.\n",
1017 bsg_job
->request_payload
.sg_cnt
, sg_cnt
);
1022 data_len
= bsg_job
->request_payload
.payload_len
;
1023 fw_buf
= dma_alloc_coherent(&ha
->pdev
->dev
, data_len
,
1024 &fw_dma
, GFP_KERNEL
);
1026 ql_log(ql_log_warn
, vha
, 0x7035,
1027 "DMA alloc failed for fw_buf.\n");
1032 sg_copy_to_buffer(bsg_job
->request_payload
.sg_list
,
1033 bsg_job
->request_payload
.sg_cnt
, fw_buf
, data_len
);
1035 mn
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &mn_dma
);
1037 ql_log(ql_log_warn
, vha
, 0x7036,
1038 "DMA alloc failed for fw buffer.\n");
1040 goto done_free_fw_buf
;
1043 flag
= bsg_request
->rqst_data
.h_vendor
.vendor_cmd
[1];
1044 fw_ver
= le32_to_cpu(*((uint32_t *)((uint32_t *)fw_buf
+ 2)));
1046 memset(mn
, 0, sizeof(struct access_chip_84xx
));
1047 mn
->entry_type
= VERIFY_CHIP_IOCB_TYPE
;
1048 mn
->entry_count
= 1;
1050 options
= VCO_FORCE_UPDATE
| VCO_END_OF_DATA
;
1051 if (flag
== A84_ISSUE_UPDATE_DIAGFW_CMD
)
1052 options
|= VCO_DIAG_FW
;
1054 mn
->options
= cpu_to_le16(options
);
1055 mn
->fw_ver
= cpu_to_le32(fw_ver
);
1056 mn
->fw_size
= cpu_to_le32(data_len
);
1057 mn
->fw_seq_size
= cpu_to_le32(data_len
);
1058 mn
->dseg_address
[0] = cpu_to_le32(LSD(fw_dma
));
1059 mn
->dseg_address
[1] = cpu_to_le32(MSD(fw_dma
));
1060 mn
->dseg_length
= cpu_to_le32(data_len
);
1061 mn
->data_seg_cnt
= cpu_to_le16(1);
1063 rval
= qla2x00_issue_iocb_timeout(vha
, mn
, mn_dma
, 0, 120);
1066 ql_log(ql_log_warn
, vha
, 0x7037,
1067 "Vendor request 84xx updatefw failed.\n");
1069 rval
= (DID_ERROR
<< 16);
1071 ql_dbg(ql_dbg_user
, vha
, 0x7038,
1072 "Vendor request 84xx updatefw completed.\n");
1074 bsg_job
->reply_len
= sizeof(struct fc_bsg_reply
);
1075 bsg_reply
->result
= DID_OK
;
1078 dma_pool_free(ha
->s_dma_pool
, mn
, mn_dma
);
1081 dma_free_coherent(&ha
->pdev
->dev
, data_len
, fw_buf
, fw_dma
);
1084 dma_unmap_sg(&ha
->pdev
->dev
, bsg_job
->request_payload
.sg_list
,
1085 bsg_job
->request_payload
.sg_cnt
, DMA_TO_DEVICE
);
1088 bsg_job
->job_done(bsg_job
);
1093 qla84xx_mgmt_cmd(struct fc_bsg_job
*bsg_job
)
1095 struct fc_bsg_request
*bsg_request
= bsg_job
->request
;
1096 struct fc_bsg_reply
*bsg_reply
= bsg_job
->reply
;
1097 struct Scsi_Host
*host
= bsg_job
->shost
;
1098 scsi_qla_host_t
*vha
= shost_priv(host
);
1099 struct qla_hw_data
*ha
= vha
->hw
;
1100 struct access_chip_84xx
*mn
= NULL
;
1101 dma_addr_t mn_dma
, mgmt_dma
;
1102 void *mgmt_b
= NULL
;
1104 struct qla_bsg_a84_mgmt
*ql84_mgmt
;
1106 uint32_t data_len
= 0;
1107 uint32_t dma_direction
= DMA_NONE
;
1109 if (!IS_QLA84XX(ha
)) {
1110 ql_log(ql_log_warn
, vha
, 0x703a,
1111 "Not 84xx, exiting.\n");
1115 mn
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &mn_dma
);
1117 ql_log(ql_log_warn
, vha
, 0x703c,
1118 "DMA alloc failed for fw buffer.\n");
1122 memset(mn
, 0, sizeof(struct access_chip_84xx
));
1123 mn
->entry_type
= ACCESS_CHIP_IOCB_TYPE
;
1124 mn
->entry_count
= 1;
1125 ql84_mgmt
= (void *)bsg_request
+ sizeof(struct fc_bsg_request
);
1126 switch (ql84_mgmt
->mgmt
.cmd
) {
1127 case QLA84_MGMT_READ_MEM
:
1128 case QLA84_MGMT_GET_INFO
:
1129 sg_cnt
= dma_map_sg(&ha
->pdev
->dev
,
1130 bsg_job
->reply_payload
.sg_list
,
1131 bsg_job
->reply_payload
.sg_cnt
, DMA_FROM_DEVICE
);
1133 ql_log(ql_log_warn
, vha
, 0x703d,
1134 "dma_map_sg returned %d for reply.\n", sg_cnt
);
1139 dma_direction
= DMA_FROM_DEVICE
;
1141 if (sg_cnt
!= bsg_job
->reply_payload
.sg_cnt
) {
1142 ql_log(ql_log_warn
, vha
, 0x703e,
1143 "DMA mapping resulted in different sg counts, "
1144 "reply_sg_cnt: %x dma_reply_sg_cnt: %x.\n",
1145 bsg_job
->reply_payload
.sg_cnt
, sg_cnt
);
1150 data_len
= bsg_job
->reply_payload
.payload_len
;
1152 mgmt_b
= dma_alloc_coherent(&ha
->pdev
->dev
, data_len
,
1153 &mgmt_dma
, GFP_KERNEL
);
1155 ql_log(ql_log_warn
, vha
, 0x703f,
1156 "DMA alloc failed for mgmt_b.\n");
1161 if (ql84_mgmt
->mgmt
.cmd
== QLA84_MGMT_READ_MEM
) {
1162 mn
->options
= cpu_to_le16(ACO_DUMP_MEMORY
);
1165 ql84_mgmt
->mgmt
.mgmtp
.u
.mem
.start_addr
);
1167 } else if (ql84_mgmt
->mgmt
.cmd
== QLA84_MGMT_GET_INFO
) {
1168 mn
->options
= cpu_to_le16(ACO_REQUEST_INFO
);
1170 cpu_to_le32(ql84_mgmt
->mgmt
.mgmtp
.u
.info
.type
);
1174 ql84_mgmt
->mgmt
.mgmtp
.u
.info
.context
);
1178 case QLA84_MGMT_WRITE_MEM
:
1179 sg_cnt
= dma_map_sg(&ha
->pdev
->dev
,
1180 bsg_job
->request_payload
.sg_list
,
1181 bsg_job
->request_payload
.sg_cnt
, DMA_TO_DEVICE
);
1184 ql_log(ql_log_warn
, vha
, 0x7040,
1185 "dma_map_sg returned %d.\n", sg_cnt
);
1190 dma_direction
= DMA_TO_DEVICE
;
1192 if (sg_cnt
!= bsg_job
->request_payload
.sg_cnt
) {
1193 ql_log(ql_log_warn
, vha
, 0x7041,
1194 "DMA mapping resulted in different sg counts, "
1195 "request_sg_cnt: %x dma_request_sg_cnt: %x.\n",
1196 bsg_job
->request_payload
.sg_cnt
, sg_cnt
);
1201 data_len
= bsg_job
->request_payload
.payload_len
;
1202 mgmt_b
= dma_alloc_coherent(&ha
->pdev
->dev
, data_len
,
1203 &mgmt_dma
, GFP_KERNEL
);
1205 ql_log(ql_log_warn
, vha
, 0x7042,
1206 "DMA alloc failed for mgmt_b.\n");
1211 sg_copy_to_buffer(bsg_job
->request_payload
.sg_list
,
1212 bsg_job
->request_payload
.sg_cnt
, mgmt_b
, data_len
);
1214 mn
->options
= cpu_to_le16(ACO_LOAD_MEMORY
);
1216 cpu_to_le32(ql84_mgmt
->mgmt
.mgmtp
.u
.mem
.start_addr
);
1219 case QLA84_MGMT_CHNG_CONFIG
:
1220 mn
->options
= cpu_to_le16(ACO_CHANGE_CONFIG_PARAM
);
1222 cpu_to_le32(ql84_mgmt
->mgmt
.mgmtp
.u
.config
.id
);
1225 cpu_to_le32(ql84_mgmt
->mgmt
.mgmtp
.u
.config
.param0
);
1228 cpu_to_le32(ql84_mgmt
->mgmt
.mgmtp
.u
.config
.param1
);
1236 if (ql84_mgmt
->mgmt
.cmd
!= QLA84_MGMT_CHNG_CONFIG
) {
1237 mn
->total_byte_cnt
= cpu_to_le32(ql84_mgmt
->mgmt
.len
);
1238 mn
->dseg_count
= cpu_to_le16(1);
1239 mn
->dseg_address
[0] = cpu_to_le32(LSD(mgmt_dma
));
1240 mn
->dseg_address
[1] = cpu_to_le32(MSD(mgmt_dma
));
1241 mn
->dseg_length
= cpu_to_le32(ql84_mgmt
->mgmt
.len
);
1244 rval
= qla2x00_issue_iocb(vha
, mn
, mn_dma
, 0);
1247 ql_log(ql_log_warn
, vha
, 0x7043,
1248 "Vendor request 84xx mgmt failed.\n");
1250 rval
= (DID_ERROR
<< 16);
1253 ql_dbg(ql_dbg_user
, vha
, 0x7044,
1254 "Vendor request 84xx mgmt completed.\n");
1256 bsg_job
->reply_len
= sizeof(struct fc_bsg_reply
);
1257 bsg_reply
->result
= DID_OK
;
1259 if ((ql84_mgmt
->mgmt
.cmd
== QLA84_MGMT_READ_MEM
) ||
1260 (ql84_mgmt
->mgmt
.cmd
== QLA84_MGMT_GET_INFO
)) {
1261 bsg_reply
->reply_payload_rcv_len
=
1262 bsg_job
->reply_payload
.payload_len
;
1264 sg_copy_from_buffer(bsg_job
->reply_payload
.sg_list
,
1265 bsg_job
->reply_payload
.sg_cnt
, mgmt_b
,
1272 dma_free_coherent(&ha
->pdev
->dev
, data_len
, mgmt_b
, mgmt_dma
);
1274 if (dma_direction
== DMA_TO_DEVICE
)
1275 dma_unmap_sg(&ha
->pdev
->dev
, bsg_job
->request_payload
.sg_list
,
1276 bsg_job
->request_payload
.sg_cnt
, DMA_TO_DEVICE
);
1277 else if (dma_direction
== DMA_FROM_DEVICE
)
1278 dma_unmap_sg(&ha
->pdev
->dev
, bsg_job
->reply_payload
.sg_list
,
1279 bsg_job
->reply_payload
.sg_cnt
, DMA_FROM_DEVICE
);
1282 dma_pool_free(ha
->s_dma_pool
, mn
, mn_dma
);
1285 bsg_job
->job_done(bsg_job
);
1290 qla24xx_iidma(struct fc_bsg_job
*bsg_job
)
1292 struct fc_bsg_request
*bsg_request
= bsg_job
->request
;
1293 struct fc_bsg_reply
*bsg_reply
= bsg_job
->reply
;
1294 struct Scsi_Host
*host
= bsg_job
->shost
;
1295 scsi_qla_host_t
*vha
= shost_priv(host
);
1297 struct qla_port_param
*port_param
= NULL
;
1298 fc_port_t
*fcport
= NULL
;
1300 uint16_t mb
[MAILBOX_REGISTER_COUNT
];
1301 uint8_t *rsp_ptr
= NULL
;
1303 if (!IS_IIDMA_CAPABLE(vha
->hw
)) {
1304 ql_log(ql_log_info
, vha
, 0x7046, "iiDMA not supported.\n");
1308 port_param
= (void *)bsg_request
+ sizeof(struct fc_bsg_request
);
1309 if (port_param
->fc_scsi_addr
.dest_type
!= EXT_DEF_TYPE_WWPN
) {
1310 ql_log(ql_log_warn
, vha
, 0x7048,
1311 "Invalid destination type.\n");
1315 list_for_each_entry(fcport
, &vha
->vp_fcports
, list
) {
1316 if (fcport
->port_type
!= FCT_TARGET
)
1319 if (memcmp(port_param
->fc_scsi_addr
.dest_addr
.wwpn
,
1320 fcport
->port_name
, sizeof(fcport
->port_name
)))
1328 ql_log(ql_log_warn
, vha
, 0x7049,
1329 "Failed to find port.\n");
1333 if (atomic_read(&fcport
->state
) != FCS_ONLINE
) {
1334 ql_log(ql_log_warn
, vha
, 0x704a,
1335 "Port is not online.\n");
1339 if (fcport
->flags
& FCF_LOGIN_NEEDED
) {
1340 ql_log(ql_log_warn
, vha
, 0x704b,
1341 "Remote port not logged in flags = 0x%x.\n", fcport
->flags
);
1345 if (port_param
->mode
)
1346 rval
= qla2x00_set_idma_speed(vha
, fcport
->loop_id
,
1347 port_param
->speed
, mb
);
1349 rval
= qla2x00_get_idma_speed(vha
, fcport
->loop_id
,
1350 &port_param
->speed
, mb
);
1353 ql_log(ql_log_warn
, vha
, 0x704c,
1354 "iIDMA cmd failed for %8phN -- "
1355 "%04x %x %04x %04x.\n", fcport
->port_name
,
1356 rval
, fcport
->fp_speed
, mb
[0], mb
[1]);
1357 rval
= (DID_ERROR
<< 16);
1359 if (!port_param
->mode
) {
1360 bsg_job
->reply_len
= sizeof(struct fc_bsg_reply
) +
1361 sizeof(struct qla_port_param
);
1363 rsp_ptr
= ((uint8_t *)bsg_reply
) +
1364 sizeof(struct fc_bsg_reply
);
1366 memcpy(rsp_ptr
, port_param
,
1367 sizeof(struct qla_port_param
));
1370 bsg_reply
->result
= DID_OK
;
1371 bsg_job
->job_done(bsg_job
);
1378 qla2x00_optrom_setup(struct fc_bsg_job
*bsg_job
, scsi_qla_host_t
*vha
,
1381 struct fc_bsg_request
*bsg_request
= bsg_job
->request
;
1384 struct qla_hw_data
*ha
= vha
->hw
;
1386 if (unlikely(pci_channel_offline(ha
->pdev
)))
1389 start
= bsg_request
->rqst_data
.h_vendor
.vendor_cmd
[1];
1390 if (start
> ha
->optrom_size
) {
1391 ql_log(ql_log_warn
, vha
, 0x7055,
1392 "start %d > optrom_size %d.\n", start
, ha
->optrom_size
);
1396 if (ha
->optrom_state
!= QLA_SWAITING
) {
1397 ql_log(ql_log_info
, vha
, 0x7056,
1398 "optrom_state %d.\n", ha
->optrom_state
);
1402 ha
->optrom_region_start
= start
;
1403 ql_dbg(ql_dbg_user
, vha
, 0x7057, "is_update=%d.\n", is_update
);
1405 if (ha
->optrom_size
== OPTROM_SIZE_2300
&& start
== 0)
1407 else if (start
== (ha
->flt_region_boot
* 4) ||
1408 start
== (ha
->flt_region_fw
* 4))
1410 else if (IS_QLA24XX_TYPE(ha
) || IS_QLA25XX(ha
) ||
1411 IS_CNA_CAPABLE(ha
) || IS_QLA2031(ha
) || IS_QLA27XX(ha
))
1414 ql_log(ql_log_warn
, vha
, 0x7058,
1415 "Invalid start region 0x%x/0x%x.\n", start
,
1416 bsg_job
->request_payload
.payload_len
);
1420 ha
->optrom_region_size
= start
+
1421 bsg_job
->request_payload
.payload_len
> ha
->optrom_size
?
1422 ha
->optrom_size
- start
:
1423 bsg_job
->request_payload
.payload_len
;
1424 ha
->optrom_state
= QLA_SWRITING
;
1426 ha
->optrom_region_size
= start
+
1427 bsg_job
->reply_payload
.payload_len
> ha
->optrom_size
?
1428 ha
->optrom_size
- start
:
1429 bsg_job
->reply_payload
.payload_len
;
1430 ha
->optrom_state
= QLA_SREADING
;
1433 ha
->optrom_buffer
= vmalloc(ha
->optrom_region_size
);
1434 if (!ha
->optrom_buffer
) {
1435 ql_log(ql_log_warn
, vha
, 0x7059,
1436 "Read: Unable to allocate memory for optrom retrieval "
1437 "(%x)\n", ha
->optrom_region_size
);
1439 ha
->optrom_state
= QLA_SWAITING
;
1443 memset(ha
->optrom_buffer
, 0, ha
->optrom_region_size
);
1448 qla2x00_read_optrom(struct fc_bsg_job
*bsg_job
)
1450 struct fc_bsg_reply
*bsg_reply
= bsg_job
->reply
;
1451 struct Scsi_Host
*host
= bsg_job
->shost
;
1452 scsi_qla_host_t
*vha
= shost_priv(host
);
1453 struct qla_hw_data
*ha
= vha
->hw
;
1456 if (ha
->flags
.nic_core_reset_hdlr_active
)
1459 mutex_lock(&ha
->optrom_mutex
);
1460 rval
= qla2x00_optrom_setup(bsg_job
, vha
, 0);
1462 mutex_unlock(&ha
->optrom_mutex
);
1466 ha
->isp_ops
->read_optrom(vha
, ha
->optrom_buffer
,
1467 ha
->optrom_region_start
, ha
->optrom_region_size
);
1469 sg_copy_from_buffer(bsg_job
->reply_payload
.sg_list
,
1470 bsg_job
->reply_payload
.sg_cnt
, ha
->optrom_buffer
,
1471 ha
->optrom_region_size
);
1473 bsg_reply
->reply_payload_rcv_len
= ha
->optrom_region_size
;
1474 bsg_reply
->result
= DID_OK
;
1475 vfree(ha
->optrom_buffer
);
1476 ha
->optrom_buffer
= NULL
;
1477 ha
->optrom_state
= QLA_SWAITING
;
1478 mutex_unlock(&ha
->optrom_mutex
);
1479 bsg_job
->job_done(bsg_job
);
1484 qla2x00_update_optrom(struct fc_bsg_job
*bsg_job
)
1486 struct fc_bsg_reply
*bsg_reply
= bsg_job
->reply
;
1487 struct Scsi_Host
*host
= bsg_job
->shost
;
1488 scsi_qla_host_t
*vha
= shost_priv(host
);
1489 struct qla_hw_data
*ha
= vha
->hw
;
1492 mutex_lock(&ha
->optrom_mutex
);
1493 rval
= qla2x00_optrom_setup(bsg_job
, vha
, 1);
1495 mutex_unlock(&ha
->optrom_mutex
);
1499 /* Set the isp82xx_no_md_cap not to capture minidump */
1500 ha
->flags
.isp82xx_no_md_cap
= 1;
1502 sg_copy_to_buffer(bsg_job
->request_payload
.sg_list
,
1503 bsg_job
->request_payload
.sg_cnt
, ha
->optrom_buffer
,
1504 ha
->optrom_region_size
);
1506 ha
->isp_ops
->write_optrom(vha
, ha
->optrom_buffer
,
1507 ha
->optrom_region_start
, ha
->optrom_region_size
);
1509 bsg_reply
->result
= DID_OK
;
1510 vfree(ha
->optrom_buffer
);
1511 ha
->optrom_buffer
= NULL
;
1512 ha
->optrom_state
= QLA_SWAITING
;
1513 mutex_unlock(&ha
->optrom_mutex
);
1514 bsg_job
->job_done(bsg_job
);
1519 qla2x00_update_fru_versions(struct fc_bsg_job
*bsg_job
)
1521 struct fc_bsg_reply
*bsg_reply
= bsg_job
->reply
;
1522 struct Scsi_Host
*host
= bsg_job
->shost
;
1523 scsi_qla_host_t
*vha
= shost_priv(host
);
1524 struct qla_hw_data
*ha
= vha
->hw
;
1526 uint8_t bsg
[DMA_POOL_SIZE
];
1527 struct qla_image_version_list
*list
= (void *)bsg
;
1528 struct qla_image_version
*image
;
1531 void *sfp
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &sfp_dma
);
1533 bsg_reply
->reply_data
.vendor_reply
.vendor_rsp
[0] =
1534 EXT_STATUS_NO_MEMORY
;
1538 sg_copy_to_buffer(bsg_job
->request_payload
.sg_list
,
1539 bsg_job
->request_payload
.sg_cnt
, list
, sizeof(bsg
));
1541 image
= list
->version
;
1542 count
= list
->count
;
1544 memcpy(sfp
, &image
->field_info
, sizeof(image
->field_info
));
1545 rval
= qla2x00_write_sfp(vha
, sfp_dma
, sfp
,
1546 image
->field_address
.device
, image
->field_address
.offset
,
1547 sizeof(image
->field_info
), image
->field_address
.option
);
1549 bsg_reply
->reply_data
.vendor_reply
.vendor_rsp
[0] =
1556 bsg_reply
->reply_data
.vendor_reply
.vendor_rsp
[0] = 0;
1559 dma_pool_free(ha
->s_dma_pool
, sfp
, sfp_dma
);
1562 bsg_job
->reply_len
= sizeof(struct fc_bsg_reply
);
1563 bsg_reply
->result
= DID_OK
<< 16;
1564 bsg_job
->job_done(bsg_job
);
1570 qla2x00_read_fru_status(struct fc_bsg_job
*bsg_job
)
1572 struct fc_bsg_reply
*bsg_reply
= bsg_job
->reply
;
1573 struct Scsi_Host
*host
= bsg_job
->shost
;
1574 scsi_qla_host_t
*vha
= shost_priv(host
);
1575 struct qla_hw_data
*ha
= vha
->hw
;
1577 uint8_t bsg
[DMA_POOL_SIZE
];
1578 struct qla_status_reg
*sr
= (void *)bsg
;
1580 uint8_t *sfp
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &sfp_dma
);
1582 bsg_reply
->reply_data
.vendor_reply
.vendor_rsp
[0] =
1583 EXT_STATUS_NO_MEMORY
;
1587 sg_copy_to_buffer(bsg_job
->request_payload
.sg_list
,
1588 bsg_job
->request_payload
.sg_cnt
, sr
, sizeof(*sr
));
1590 rval
= qla2x00_read_sfp(vha
, sfp_dma
, sfp
,
1591 sr
->field_address
.device
, sr
->field_address
.offset
,
1592 sizeof(sr
->status_reg
), sr
->field_address
.option
);
1593 sr
->status_reg
= *sfp
;
1596 bsg_reply
->reply_data
.vendor_reply
.vendor_rsp
[0] =
1601 sg_copy_from_buffer(bsg_job
->reply_payload
.sg_list
,
1602 bsg_job
->reply_payload
.sg_cnt
, sr
, sizeof(*sr
));
1604 bsg_reply
->reply_data
.vendor_reply
.vendor_rsp
[0] = 0;
1607 dma_pool_free(ha
->s_dma_pool
, sfp
, sfp_dma
);
1610 bsg_job
->reply_len
= sizeof(struct fc_bsg_reply
);
1611 bsg_reply
->reply_payload_rcv_len
= sizeof(*sr
);
1612 bsg_reply
->result
= DID_OK
<< 16;
1613 bsg_job
->job_done(bsg_job
);
1619 qla2x00_write_fru_status(struct fc_bsg_job
*bsg_job
)
1621 struct fc_bsg_reply
*bsg_reply
= bsg_job
->reply
;
1622 struct Scsi_Host
*host
= bsg_job
->shost
;
1623 scsi_qla_host_t
*vha
= shost_priv(host
);
1624 struct qla_hw_data
*ha
= vha
->hw
;
1626 uint8_t bsg
[DMA_POOL_SIZE
];
1627 struct qla_status_reg
*sr
= (void *)bsg
;
1629 uint8_t *sfp
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &sfp_dma
);
1631 bsg_reply
->reply_data
.vendor_reply
.vendor_rsp
[0] =
1632 EXT_STATUS_NO_MEMORY
;
1636 sg_copy_to_buffer(bsg_job
->request_payload
.sg_list
,
1637 bsg_job
->request_payload
.sg_cnt
, sr
, sizeof(*sr
));
1639 *sfp
= sr
->status_reg
;
1640 rval
= qla2x00_write_sfp(vha
, sfp_dma
, sfp
,
1641 sr
->field_address
.device
, sr
->field_address
.offset
,
1642 sizeof(sr
->status_reg
), sr
->field_address
.option
);
1645 bsg_reply
->reply_data
.vendor_reply
.vendor_rsp
[0] =
1650 bsg_reply
->reply_data
.vendor_reply
.vendor_rsp
[0] = 0;
1653 dma_pool_free(ha
->s_dma_pool
, sfp
, sfp_dma
);
1656 bsg_job
->reply_len
= sizeof(struct fc_bsg_reply
);
1657 bsg_reply
->result
= DID_OK
<< 16;
1658 bsg_job
->job_done(bsg_job
);
1664 qla2x00_write_i2c(struct fc_bsg_job
*bsg_job
)
1666 struct fc_bsg_reply
*bsg_reply
= bsg_job
->reply
;
1667 struct Scsi_Host
*host
= bsg_job
->shost
;
1668 scsi_qla_host_t
*vha
= shost_priv(host
);
1669 struct qla_hw_data
*ha
= vha
->hw
;
1671 uint8_t bsg
[DMA_POOL_SIZE
];
1672 struct qla_i2c_access
*i2c
= (void *)bsg
;
1674 uint8_t *sfp
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &sfp_dma
);
1676 bsg_reply
->reply_data
.vendor_reply
.vendor_rsp
[0] =
1677 EXT_STATUS_NO_MEMORY
;
1681 sg_copy_to_buffer(bsg_job
->request_payload
.sg_list
,
1682 bsg_job
->request_payload
.sg_cnt
, i2c
, sizeof(*i2c
));
1684 memcpy(sfp
, i2c
->buffer
, i2c
->length
);
1685 rval
= qla2x00_write_sfp(vha
, sfp_dma
, sfp
,
1686 i2c
->device
, i2c
->offset
, i2c
->length
, i2c
->option
);
1689 bsg_reply
->reply_data
.vendor_reply
.vendor_rsp
[0] =
1694 bsg_reply
->reply_data
.vendor_reply
.vendor_rsp
[0] = 0;
1697 dma_pool_free(ha
->s_dma_pool
, sfp
, sfp_dma
);
1700 bsg_job
->reply_len
= sizeof(struct fc_bsg_reply
);
1701 bsg_reply
->result
= DID_OK
<< 16;
1702 bsg_job
->job_done(bsg_job
);
1708 qla2x00_read_i2c(struct fc_bsg_job
*bsg_job
)
1710 struct fc_bsg_reply
*bsg_reply
= bsg_job
->reply
;
1711 struct Scsi_Host
*host
= bsg_job
->shost
;
1712 scsi_qla_host_t
*vha
= shost_priv(host
);
1713 struct qla_hw_data
*ha
= vha
->hw
;
1715 uint8_t bsg
[DMA_POOL_SIZE
];
1716 struct qla_i2c_access
*i2c
= (void *)bsg
;
1718 uint8_t *sfp
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &sfp_dma
);
1720 bsg_reply
->reply_data
.vendor_reply
.vendor_rsp
[0] =
1721 EXT_STATUS_NO_MEMORY
;
1725 sg_copy_to_buffer(bsg_job
->request_payload
.sg_list
,
1726 bsg_job
->request_payload
.sg_cnt
, i2c
, sizeof(*i2c
));
1728 rval
= qla2x00_read_sfp(vha
, sfp_dma
, sfp
,
1729 i2c
->device
, i2c
->offset
, i2c
->length
, i2c
->option
);
1732 bsg_reply
->reply_data
.vendor_reply
.vendor_rsp
[0] =
1737 memcpy(i2c
->buffer
, sfp
, i2c
->length
);
1738 sg_copy_from_buffer(bsg_job
->reply_payload
.sg_list
,
1739 bsg_job
->reply_payload
.sg_cnt
, i2c
, sizeof(*i2c
));
1741 bsg_reply
->reply_data
.vendor_reply
.vendor_rsp
[0] = 0;
1744 dma_pool_free(ha
->s_dma_pool
, sfp
, sfp_dma
);
1747 bsg_job
->reply_len
= sizeof(struct fc_bsg_reply
);
1748 bsg_reply
->reply_payload_rcv_len
= sizeof(*i2c
);
1749 bsg_reply
->result
= DID_OK
<< 16;
1750 bsg_job
->job_done(bsg_job
);
1756 qla24xx_process_bidir_cmd(struct fc_bsg_job
*bsg_job
)
1758 struct fc_bsg_reply
*bsg_reply
= bsg_job
->reply
;
1759 struct Scsi_Host
*host
= bsg_job
->shost
;
1760 scsi_qla_host_t
*vha
= shost_priv(host
);
1761 struct qla_hw_data
*ha
= vha
->hw
;
1762 uint32_t rval
= EXT_STATUS_OK
;
1763 uint16_t req_sg_cnt
= 0;
1764 uint16_t rsp_sg_cnt
= 0;
1765 uint16_t nextlid
= 0;
1768 uint32_t req_data_len
= 0;
1769 uint32_t rsp_data_len
= 0;
1771 /* Check the type of the adapter */
1772 if (!IS_BIDI_CAPABLE(ha
)) {
1773 ql_log(ql_log_warn
, vha
, 0x70a0,
1774 "This adapter is not supported\n");
1775 rval
= EXT_STATUS_NOT_SUPPORTED
;
1779 if (test_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
) ||
1780 test_bit(ABORT_ISP_ACTIVE
, &vha
->dpc_flags
) ||
1781 test_bit(ISP_ABORT_RETRY
, &vha
->dpc_flags
)) {
1782 rval
= EXT_STATUS_BUSY
;
1786 /* Check if host is online */
1787 if (!vha
->flags
.online
) {
1788 ql_log(ql_log_warn
, vha
, 0x70a1,
1789 "Host is not online\n");
1790 rval
= EXT_STATUS_DEVICE_OFFLINE
;
1794 /* Check if cable is plugged in or not */
1795 if (vha
->device_flags
& DFLG_NO_CABLE
) {
1796 ql_log(ql_log_warn
, vha
, 0x70a2,
1797 "Cable is unplugged...\n");
1798 rval
= EXT_STATUS_INVALID_CFG
;
1802 /* Check if the switch is connected or not */
1803 if (ha
->current_topology
!= ISP_CFG_F
) {
1804 ql_log(ql_log_warn
, vha
, 0x70a3,
1805 "Host is not connected to the switch\n");
1806 rval
= EXT_STATUS_INVALID_CFG
;
1810 /* Check if operating mode is P2P */
1811 if (ha
->operating_mode
!= P2P
) {
1812 ql_log(ql_log_warn
, vha
, 0x70a4,
1813 "Host is operating mode is not P2p\n");
1814 rval
= EXT_STATUS_INVALID_CFG
;
1818 mutex_lock(&ha
->selflogin_lock
);
1819 if (vha
->self_login_loop_id
== 0) {
1820 /* Initialize all required fields of fcport */
1821 vha
->bidir_fcport
.vha
= vha
;
1822 vha
->bidir_fcport
.d_id
.b
.al_pa
= vha
->d_id
.b
.al_pa
;
1823 vha
->bidir_fcport
.d_id
.b
.area
= vha
->d_id
.b
.area
;
1824 vha
->bidir_fcport
.d_id
.b
.domain
= vha
->d_id
.b
.domain
;
1825 vha
->bidir_fcport
.loop_id
= vha
->loop_id
;
1827 if (qla2x00_fabric_login(vha
, &(vha
->bidir_fcport
), &nextlid
)) {
1828 ql_log(ql_log_warn
, vha
, 0x70a7,
1829 "Failed to login port %06X for bidirectional IOCB\n",
1830 vha
->bidir_fcport
.d_id
.b24
);
1831 mutex_unlock(&ha
->selflogin_lock
);
1832 rval
= EXT_STATUS_MAILBOX
;
1835 vha
->self_login_loop_id
= nextlid
- 1;
1838 /* Assign the self login loop id to fcport */
1839 mutex_unlock(&ha
->selflogin_lock
);
1841 vha
->bidir_fcport
.loop_id
= vha
->self_login_loop_id
;
1843 req_sg_cnt
= dma_map_sg(&ha
->pdev
->dev
,
1844 bsg_job
->request_payload
.sg_list
,
1845 bsg_job
->request_payload
.sg_cnt
,
1849 rval
= EXT_STATUS_NO_MEMORY
;
1853 rsp_sg_cnt
= dma_map_sg(&ha
->pdev
->dev
,
1854 bsg_job
->reply_payload
.sg_list
, bsg_job
->reply_payload
.sg_cnt
,
1858 rval
= EXT_STATUS_NO_MEMORY
;
1859 goto done_unmap_req_sg
;
1862 if ((req_sg_cnt
!= bsg_job
->request_payload
.sg_cnt
) ||
1863 (rsp_sg_cnt
!= bsg_job
->reply_payload
.sg_cnt
)) {
1864 ql_dbg(ql_dbg_user
, vha
, 0x70a9,
1865 "Dma mapping resulted in different sg counts "
1866 "[request_sg_cnt: %x dma_request_sg_cnt: %x reply_sg_cnt: "
1867 "%x dma_reply_sg_cnt: %x]\n",
1868 bsg_job
->request_payload
.sg_cnt
, req_sg_cnt
,
1869 bsg_job
->reply_payload
.sg_cnt
, rsp_sg_cnt
);
1870 rval
= EXT_STATUS_NO_MEMORY
;
1874 if (req_data_len
!= rsp_data_len
) {
1875 rval
= EXT_STATUS_BUSY
;
1876 ql_log(ql_log_warn
, vha
, 0x70aa,
1877 "req_data_len != rsp_data_len\n");
1881 req_data_len
= bsg_job
->request_payload
.payload_len
;
1882 rsp_data_len
= bsg_job
->reply_payload
.payload_len
;
1885 /* Alloc SRB structure */
1886 sp
= qla2x00_get_sp(vha
, &(vha
->bidir_fcport
), GFP_KERNEL
);
1888 ql_dbg(ql_dbg_user
, vha
, 0x70ac,
1889 "Alloc SRB structure failed\n");
1890 rval
= EXT_STATUS_NO_MEMORY
;
1894 /*Populate srb->ctx with bidir ctx*/
1895 sp
->u
.bsg_job
= bsg_job
;
1896 sp
->free
= qla2x00_bsg_sp_free
;
1897 sp
->type
= SRB_BIDI_CMD
;
1898 sp
->done
= qla2x00_bsg_job_done
;
1900 /* Add the read and write sg count */
1901 tot_dsds
= rsp_sg_cnt
+ req_sg_cnt
;
1903 rval
= qla2x00_start_bidir(sp
, vha
, tot_dsds
);
1904 if (rval
!= EXT_STATUS_OK
)
1906 /* the bsg request will be completed in the interrupt handler */
1910 mempool_free(sp
, ha
->srb_mempool
);
1912 dma_unmap_sg(&ha
->pdev
->dev
,
1913 bsg_job
->reply_payload
.sg_list
,
1914 bsg_job
->reply_payload
.sg_cnt
, DMA_FROM_DEVICE
);
1916 dma_unmap_sg(&ha
->pdev
->dev
,
1917 bsg_job
->request_payload
.sg_list
,
1918 bsg_job
->request_payload
.sg_cnt
, DMA_TO_DEVICE
);
1921 /* Return an error vendor specific response
1922 * and complete the bsg request
1924 bsg_reply
->reply_data
.vendor_reply
.vendor_rsp
[0] = rval
;
1925 bsg_job
->reply_len
= sizeof(struct fc_bsg_reply
);
1926 bsg_reply
->reply_payload_rcv_len
= 0;
1927 bsg_reply
->result
= (DID_OK
) << 16;
1928 bsg_job
->job_done(bsg_job
);
1929 /* Always return success, vendor rsp carries correct status */
1934 qlafx00_mgmt_cmd(struct fc_bsg_job
*bsg_job
)
1936 struct fc_bsg_request
*bsg_request
= bsg_job
->request
;
1937 struct Scsi_Host
*host
= bsg_job
->shost
;
1938 scsi_qla_host_t
*vha
= shost_priv(host
);
1939 struct qla_hw_data
*ha
= vha
->hw
;
1940 int rval
= (DRIVER_ERROR
<< 16);
1941 struct qla_mt_iocb_rqst_fx00
*piocb_rqst
;
1943 int req_sg_cnt
= 0, rsp_sg_cnt
= 0;
1944 struct fc_port
*fcport
;
1945 char *type
= "FC_BSG_HST_FX_MGMT";
1947 /* Copy the IOCB specific information */
1948 piocb_rqst
= (struct qla_mt_iocb_rqst_fx00
*)
1949 &bsg_request
->rqst_data
.h_vendor
.vendor_cmd
[1];
1951 /* Dump the vendor information */
1952 ql_dump_buffer(ql_dbg_user
+ ql_dbg_verbose
, vha
, 0x70cf,
1953 (uint8_t *)piocb_rqst
, sizeof(struct qla_mt_iocb_rqst_fx00
));
1955 if (!vha
->flags
.online
) {
1956 ql_log(ql_log_warn
, vha
, 0x70d0,
1957 "Host is not online.\n");
1962 if (piocb_rqst
->flags
& SRB_FXDISC_REQ_DMA_VALID
) {
1963 req_sg_cnt
= dma_map_sg(&ha
->pdev
->dev
,
1964 bsg_job
->request_payload
.sg_list
,
1965 bsg_job
->request_payload
.sg_cnt
, DMA_TO_DEVICE
);
1967 ql_log(ql_log_warn
, vha
, 0x70c7,
1968 "dma_map_sg return %d for request\n", req_sg_cnt
);
1974 if (piocb_rqst
->flags
& SRB_FXDISC_RESP_DMA_VALID
) {
1975 rsp_sg_cnt
= dma_map_sg(&ha
->pdev
->dev
,
1976 bsg_job
->reply_payload
.sg_list
,
1977 bsg_job
->reply_payload
.sg_cnt
, DMA_FROM_DEVICE
);
1979 ql_log(ql_log_warn
, vha
, 0x70c8,
1980 "dma_map_sg return %d for reply\n", rsp_sg_cnt
);
1982 goto done_unmap_req_sg
;
1986 ql_dbg(ql_dbg_user
, vha
, 0x70c9,
1987 "request_sg_cnt: %x dma_request_sg_cnt: %x reply_sg_cnt:%x "
1988 "dma_reply_sg_cnt: %x\n", bsg_job
->request_payload
.sg_cnt
,
1989 req_sg_cnt
, bsg_job
->reply_payload
.sg_cnt
, rsp_sg_cnt
);
1991 /* Allocate a dummy fcport structure, since functions preparing the
1992 * IOCB and mailbox command retrieves port specific information
1993 * from fcport structure. For Host based ELS commands there will be
1994 * no fcport structure allocated
1996 fcport
= qla2x00_alloc_fcport(vha
, GFP_KERNEL
);
1998 ql_log(ql_log_warn
, vha
, 0x70ca,
1999 "Failed to allocate fcport.\n");
2001 goto done_unmap_rsp_sg
;
2004 /* Alloc SRB structure */
2005 sp
= qla2x00_get_sp(vha
, fcport
, GFP_KERNEL
);
2007 ql_log(ql_log_warn
, vha
, 0x70cb,
2008 "qla2x00_get_sp failed.\n");
2010 goto done_free_fcport
;
2013 /* Initialize all required fields of fcport */
2015 fcport
->loop_id
= piocb_rqst
->dataword
;
2017 sp
->type
= SRB_FXIOCB_BCMD
;
2018 sp
->name
= "bsg_fx_mgmt";
2019 sp
->iocbs
= qla24xx_calc_ct_iocbs(req_sg_cnt
+ rsp_sg_cnt
);
2020 sp
->u
.bsg_job
= bsg_job
;
2021 sp
->free
= qla2x00_bsg_sp_free
;
2022 sp
->done
= qla2x00_bsg_job_done
;
2024 ql_dbg(ql_dbg_user
, vha
, 0x70cc,
2025 "bsg rqst type: %s fx_mgmt_type: %x id=%x\n",
2026 type
, piocb_rqst
->func_type
, fcport
->loop_id
);
2028 rval
= qla2x00_start_sp(sp
);
2029 if (rval
!= QLA_SUCCESS
) {
2030 ql_log(ql_log_warn
, vha
, 0x70cd,
2031 "qla2x00_start_sp failed=%d.\n", rval
);
2032 mempool_free(sp
, ha
->srb_mempool
);
2034 goto done_free_fcport
;
2042 if (piocb_rqst
->flags
& SRB_FXDISC_RESP_DMA_VALID
)
2043 dma_unmap_sg(&ha
->pdev
->dev
,
2044 bsg_job
->reply_payload
.sg_list
,
2045 bsg_job
->reply_payload
.sg_cnt
, DMA_FROM_DEVICE
);
2047 if (piocb_rqst
->flags
& SRB_FXDISC_REQ_DMA_VALID
)
2048 dma_unmap_sg(&ha
->pdev
->dev
,
2049 bsg_job
->request_payload
.sg_list
,
2050 bsg_job
->request_payload
.sg_cnt
, DMA_TO_DEVICE
);
2057 qla26xx_serdes_op(struct fc_bsg_job
*bsg_job
)
2059 struct fc_bsg_reply
*bsg_reply
= bsg_job
->reply
;
2060 struct Scsi_Host
*host
= bsg_job
->shost
;
2061 scsi_qla_host_t
*vha
= shost_priv(host
);
2063 struct qla_serdes_reg sr
;
2065 memset(&sr
, 0, sizeof(sr
));
2067 sg_copy_to_buffer(bsg_job
->request_payload
.sg_list
,
2068 bsg_job
->request_payload
.sg_cnt
, &sr
, sizeof(sr
));
2071 case INT_SC_SERDES_WRITE_REG
:
2072 rval
= qla2x00_write_serdes_word(vha
, sr
.addr
, sr
.val
);
2073 bsg_reply
->reply_payload_rcv_len
= 0;
2075 case INT_SC_SERDES_READ_REG
:
2076 rval
= qla2x00_read_serdes_word(vha
, sr
.addr
, &sr
.val
);
2077 sg_copy_from_buffer(bsg_job
->reply_payload
.sg_list
,
2078 bsg_job
->reply_payload
.sg_cnt
, &sr
, sizeof(sr
));
2079 bsg_reply
->reply_payload_rcv_len
= sizeof(sr
);
2082 ql_dbg(ql_dbg_user
, vha
, 0x708c,
2083 "Unknown serdes cmd %x.\n", sr
.cmd
);
2088 bsg_reply
->reply_data
.vendor_reply
.vendor_rsp
[0] =
2089 rval
? EXT_STATUS_MAILBOX
: 0;
2091 bsg_job
->reply_len
= sizeof(struct fc_bsg_reply
);
2092 bsg_reply
->result
= DID_OK
<< 16;
2093 bsg_job
->job_done(bsg_job
);
2098 qla8044_serdes_op(struct fc_bsg_job
*bsg_job
)
2100 struct fc_bsg_reply
*bsg_reply
= bsg_job
->reply
;
2101 struct Scsi_Host
*host
= bsg_job
->shost
;
2102 scsi_qla_host_t
*vha
= shost_priv(host
);
2104 struct qla_serdes_reg_ex sr
;
2106 memset(&sr
, 0, sizeof(sr
));
2108 sg_copy_to_buffer(bsg_job
->request_payload
.sg_list
,
2109 bsg_job
->request_payload
.sg_cnt
, &sr
, sizeof(sr
));
2112 case INT_SC_SERDES_WRITE_REG
:
2113 rval
= qla8044_write_serdes_word(vha
, sr
.addr
, sr
.val
);
2114 bsg_reply
->reply_payload_rcv_len
= 0;
2116 case INT_SC_SERDES_READ_REG
:
2117 rval
= qla8044_read_serdes_word(vha
, sr
.addr
, &sr
.val
);
2118 sg_copy_from_buffer(bsg_job
->reply_payload
.sg_list
,
2119 bsg_job
->reply_payload
.sg_cnt
, &sr
, sizeof(sr
));
2120 bsg_reply
->reply_payload_rcv_len
= sizeof(sr
);
2123 ql_dbg(ql_dbg_user
, vha
, 0x70cf,
2124 "Unknown serdes cmd %x.\n", sr
.cmd
);
2129 bsg_reply
->reply_data
.vendor_reply
.vendor_rsp
[0] =
2130 rval
? EXT_STATUS_MAILBOX
: 0;
2132 bsg_job
->reply_len
= sizeof(struct fc_bsg_reply
);
2133 bsg_reply
->result
= DID_OK
<< 16;
2134 bsg_job
->job_done(bsg_job
);
2139 qla27xx_get_flash_upd_cap(struct fc_bsg_job
*bsg_job
)
2141 struct fc_bsg_reply
*bsg_reply
= bsg_job
->reply
;
2142 struct Scsi_Host
*host
= bsg_job
->shost
;
2143 scsi_qla_host_t
*vha
= shost_priv(host
);
2144 struct qla_hw_data
*ha
= vha
->hw
;
2145 struct qla_flash_update_caps cap
;
2147 if (!(IS_QLA27XX(ha
)))
2150 memset(&cap
, 0, sizeof(cap
));
2151 cap
.capabilities
= (uint64_t)ha
->fw_attributes_ext
[1] << 48 |
2152 (uint64_t)ha
->fw_attributes_ext
[0] << 32 |
2153 (uint64_t)ha
->fw_attributes_h
<< 16 |
2154 (uint64_t)ha
->fw_attributes
;
2156 sg_copy_from_buffer(bsg_job
->reply_payload
.sg_list
,
2157 bsg_job
->reply_payload
.sg_cnt
, &cap
, sizeof(cap
));
2158 bsg_reply
->reply_payload_rcv_len
= sizeof(cap
);
2160 bsg_reply
->reply_data
.vendor_reply
.vendor_rsp
[0] =
2163 bsg_job
->reply_len
= sizeof(struct fc_bsg_reply
);
2164 bsg_reply
->result
= DID_OK
<< 16;
2165 bsg_job
->job_done(bsg_job
);
2170 qla27xx_set_flash_upd_cap(struct fc_bsg_job
*bsg_job
)
2172 struct fc_bsg_reply
*bsg_reply
= bsg_job
->reply
;
2173 struct Scsi_Host
*host
= bsg_job
->shost
;
2174 scsi_qla_host_t
*vha
= shost_priv(host
);
2175 struct qla_hw_data
*ha
= vha
->hw
;
2176 uint64_t online_fw_attr
= 0;
2177 struct qla_flash_update_caps cap
;
2179 if (!(IS_QLA27XX(ha
)))
2182 memset(&cap
, 0, sizeof(cap
));
2183 sg_copy_to_buffer(bsg_job
->request_payload
.sg_list
,
2184 bsg_job
->request_payload
.sg_cnt
, &cap
, sizeof(cap
));
2186 online_fw_attr
= (uint64_t)ha
->fw_attributes_ext
[1] << 48 |
2187 (uint64_t)ha
->fw_attributes_ext
[0] << 32 |
2188 (uint64_t)ha
->fw_attributes_h
<< 16 |
2189 (uint64_t)ha
->fw_attributes
;
2191 if (online_fw_attr
!= cap
.capabilities
) {
2192 bsg_reply
->reply_data
.vendor_reply
.vendor_rsp
[0] =
2193 EXT_STATUS_INVALID_PARAM
;
2197 if (cap
.outage_duration
< MAX_LOOP_TIMEOUT
) {
2198 bsg_reply
->reply_data
.vendor_reply
.vendor_rsp
[0] =
2199 EXT_STATUS_INVALID_PARAM
;
2203 bsg_reply
->reply_payload_rcv_len
= 0;
2205 bsg_reply
->reply_data
.vendor_reply
.vendor_rsp
[0] =
2208 bsg_job
->reply_len
= sizeof(struct fc_bsg_reply
);
2209 bsg_reply
->result
= DID_OK
<< 16;
2210 bsg_job
->job_done(bsg_job
);
2215 qla27xx_get_bbcr_data(struct fc_bsg_job
*bsg_job
)
2217 struct fc_bsg_reply
*bsg_reply
= bsg_job
->reply
;
2218 struct Scsi_Host
*host
= bsg_job
->shost
;
2219 scsi_qla_host_t
*vha
= shost_priv(host
);
2220 struct qla_hw_data
*ha
= vha
->hw
;
2221 struct qla_bbcr_data bbcr
;
2222 uint16_t loop_id
, topo
, sw_cap
;
2223 uint8_t domain
, area
, al_pa
, state
;
2226 if (!(IS_QLA27XX(ha
)))
2229 memset(&bbcr
, 0, sizeof(bbcr
));
2231 if (vha
->flags
.bbcr_enable
)
2232 bbcr
.status
= QLA_BBCR_STATUS_ENABLED
;
2234 bbcr
.status
= QLA_BBCR_STATUS_DISABLED
;
2236 if (bbcr
.status
== QLA_BBCR_STATUS_ENABLED
) {
2237 rval
= qla2x00_get_adapter_id(vha
, &loop_id
, &al_pa
,
2238 &area
, &domain
, &topo
, &sw_cap
);
2239 if (rval
!= QLA_SUCCESS
) {
2240 bbcr
.status
= QLA_BBCR_STATUS_UNKNOWN
;
2241 bbcr
.state
= QLA_BBCR_STATE_OFFLINE
;
2242 bbcr
.mbx1
= loop_id
;
2246 state
= (vha
->bbcr
>> 12) & 0x1;
2249 bbcr
.state
= QLA_BBCR_STATE_OFFLINE
;
2250 bbcr
.offline_reason_code
= QLA_BBCR_REASON_LOGIN_REJECT
;
2252 bbcr
.state
= QLA_BBCR_STATE_ONLINE
;
2253 bbcr
.negotiated_bbscn
= (vha
->bbcr
>> 8) & 0xf;
2256 bbcr
.configured_bbscn
= vha
->bbcr
& 0xf;
2260 sg_copy_from_buffer(bsg_job
->reply_payload
.sg_list
,
2261 bsg_job
->reply_payload
.sg_cnt
, &bbcr
, sizeof(bbcr
));
2262 bsg_reply
->reply_payload_rcv_len
= sizeof(bbcr
);
2264 bsg_reply
->reply_data
.vendor_reply
.vendor_rsp
[0] = EXT_STATUS_OK
;
2266 bsg_job
->reply_len
= sizeof(struct fc_bsg_reply
);
2267 bsg_reply
->result
= DID_OK
<< 16;
2268 bsg_job
->job_done(bsg_job
);
2273 qla2x00_get_priv_stats(struct fc_bsg_job
*bsg_job
)
2275 struct fc_bsg_request
*bsg_request
= bsg_job
->request
;
2276 struct fc_bsg_reply
*bsg_reply
= bsg_job
->reply
;
2277 struct Scsi_Host
*host
= bsg_job
->shost
;
2278 scsi_qla_host_t
*vha
= shost_priv(host
);
2279 struct qla_hw_data
*ha
= vha
->hw
;
2280 struct scsi_qla_host
*base_vha
= pci_get_drvdata(ha
->pdev
);
2281 struct link_statistics
*stats
= NULL
;
2282 dma_addr_t stats_dma
;
2284 uint32_t *cmd
= bsg_request
->rqst_data
.h_vendor
.vendor_cmd
;
2285 uint options
= cmd
[0] == QL_VND_GET_PRIV_STATS_EX
? cmd
[1] : 0;
2287 if (test_bit(UNLOADING
, &vha
->dpc_flags
))
2290 if (unlikely(pci_channel_offline(ha
->pdev
)))
2293 if (qla2x00_reset_active(vha
))
2296 if (!IS_FWI2_CAPABLE(ha
))
2299 stats
= dma_alloc_coherent(&ha
->pdev
->dev
,
2300 sizeof(*stats
), &stats_dma
, GFP_KERNEL
);
2302 ql_log(ql_log_warn
, vha
, 0x70e2,
2303 "Failed to allocate memory for stats.\n");
2307 memset(stats
, 0, sizeof(*stats
));
2309 rval
= qla24xx_get_isp_stats(base_vha
, stats
, stats_dma
, options
);
2311 if (rval
== QLA_SUCCESS
) {
2312 ql_dump_buffer(ql_dbg_user
+ ql_dbg_verbose
, vha
, 0x70e3,
2313 (uint8_t *)stats
, sizeof(*stats
));
2314 sg_copy_from_buffer(bsg_job
->reply_payload
.sg_list
,
2315 bsg_job
->reply_payload
.sg_cnt
, stats
, sizeof(*stats
));
2318 bsg_reply
->reply_payload_rcv_len
= sizeof(*stats
);
2319 bsg_reply
->reply_data
.vendor_reply
.vendor_rsp
[0] =
2320 rval
? EXT_STATUS_MAILBOX
: EXT_STATUS_OK
;
2322 bsg_job
->reply_len
= sizeof(*bsg_reply
);
2323 bsg_reply
->result
= DID_OK
<< 16;
2324 bsg_job
->job_done(bsg_job
);
2326 dma_free_coherent(&ha
->pdev
->dev
, sizeof(*stats
),
2333 qla2x00_do_dport_diagnostics(struct fc_bsg_job
*bsg_job
)
2335 struct fc_bsg_reply
*bsg_reply
= bsg_job
->reply
;
2336 struct Scsi_Host
*host
= bsg_job
->shost
;
2337 scsi_qla_host_t
*vha
= shost_priv(host
);
2339 struct qla_dport_diag
*dd
;
2341 if (!IS_QLA83XX(vha
->hw
) && !IS_QLA27XX(vha
->hw
))
2344 dd
= kmalloc(sizeof(*dd
), GFP_KERNEL
);
2346 ql_log(ql_log_warn
, vha
, 0x70db,
2347 "Failed to allocate memory for dport.\n");
2351 sg_copy_to_buffer(bsg_job
->request_payload
.sg_list
,
2352 bsg_job
->request_payload
.sg_cnt
, dd
, sizeof(*dd
));
2354 rval
= qla26xx_dport_diagnostics(
2355 vha
, dd
->buf
, sizeof(dd
->buf
), dd
->options
);
2356 if (rval
== QLA_SUCCESS
) {
2357 sg_copy_from_buffer(bsg_job
->reply_payload
.sg_list
,
2358 bsg_job
->reply_payload
.sg_cnt
, dd
, sizeof(*dd
));
2361 bsg_reply
->reply_payload_rcv_len
= sizeof(*dd
);
2362 bsg_reply
->reply_data
.vendor_reply
.vendor_rsp
[0] =
2363 rval
? EXT_STATUS_MAILBOX
: EXT_STATUS_OK
;
2365 bsg_job
->reply_len
= sizeof(*bsg_reply
);
2366 bsg_reply
->result
= DID_OK
<< 16;
2367 bsg_job
->job_done(bsg_job
);
2375 qla2x00_process_vendor_specific(struct fc_bsg_job
*bsg_job
)
2377 struct fc_bsg_request
*bsg_request
= bsg_job
->request
;
2379 switch (bsg_request
->rqst_data
.h_vendor
.vendor_cmd
[0]) {
2380 case QL_VND_LOOPBACK
:
2381 return qla2x00_process_loopback(bsg_job
);
2383 case QL_VND_A84_RESET
:
2384 return qla84xx_reset(bsg_job
);
2386 case QL_VND_A84_UPDATE_FW
:
2387 return qla84xx_updatefw(bsg_job
);
2389 case QL_VND_A84_MGMT_CMD
:
2390 return qla84xx_mgmt_cmd(bsg_job
);
2393 return qla24xx_iidma(bsg_job
);
2395 case QL_VND_FCP_PRIO_CFG_CMD
:
2396 return qla24xx_proc_fcp_prio_cfg_cmd(bsg_job
);
2398 case QL_VND_READ_FLASH
:
2399 return qla2x00_read_optrom(bsg_job
);
2401 case QL_VND_UPDATE_FLASH
:
2402 return qla2x00_update_optrom(bsg_job
);
2404 case QL_VND_SET_FRU_VERSION
:
2405 return qla2x00_update_fru_versions(bsg_job
);
2407 case QL_VND_READ_FRU_STATUS
:
2408 return qla2x00_read_fru_status(bsg_job
);
2410 case QL_VND_WRITE_FRU_STATUS
:
2411 return qla2x00_write_fru_status(bsg_job
);
2413 case QL_VND_WRITE_I2C
:
2414 return qla2x00_write_i2c(bsg_job
);
2416 case QL_VND_READ_I2C
:
2417 return qla2x00_read_i2c(bsg_job
);
2419 case QL_VND_DIAG_IO_CMD
:
2420 return qla24xx_process_bidir_cmd(bsg_job
);
2422 case QL_VND_FX00_MGMT_CMD
:
2423 return qlafx00_mgmt_cmd(bsg_job
);
2425 case QL_VND_SERDES_OP
:
2426 return qla26xx_serdes_op(bsg_job
);
2428 case QL_VND_SERDES_OP_EX
:
2429 return qla8044_serdes_op(bsg_job
);
2431 case QL_VND_GET_FLASH_UPDATE_CAPS
:
2432 return qla27xx_get_flash_upd_cap(bsg_job
);
2434 case QL_VND_SET_FLASH_UPDATE_CAPS
:
2435 return qla27xx_set_flash_upd_cap(bsg_job
);
2437 case QL_VND_GET_BBCR_DATA
:
2438 return qla27xx_get_bbcr_data(bsg_job
);
2440 case QL_VND_GET_PRIV_STATS
:
2441 case QL_VND_GET_PRIV_STATS_EX
:
2442 return qla2x00_get_priv_stats(bsg_job
);
2444 case QL_VND_DPORT_DIAGNOSTICS
:
2445 return qla2x00_do_dport_diagnostics(bsg_job
);
2453 qla24xx_bsg_request(struct fc_bsg_job
*bsg_job
)
2455 struct fc_bsg_request
*bsg_request
= bsg_job
->request
;
2456 struct fc_bsg_reply
*bsg_reply
= bsg_job
->reply
;
2458 struct fc_rport
*rport
;
2459 struct Scsi_Host
*host
;
2460 scsi_qla_host_t
*vha
;
2462 /* In case no data transferred. */
2463 bsg_reply
->reply_payload_rcv_len
= 0;
2465 if (bsg_request
->msgcode
== FC_BSG_RPT_ELS
) {
2466 rport
= bsg_job
->rport
;
2467 host
= rport_to_shost(rport
);
2468 vha
= shost_priv(host
);
2470 host
= bsg_job
->shost
;
2471 vha
= shost_priv(host
);
2474 if (qla2x00_reset_active(vha
)) {
2475 ql_dbg(ql_dbg_user
, vha
, 0x709f,
2476 "BSG: ISP abort active/needed -- cmd=%d.\n",
2477 bsg_request
->msgcode
);
2481 ql_dbg(ql_dbg_user
, vha
, 0x7000,
2482 "Entered %s msgcode=0x%x.\n", __func__
, bsg_request
->msgcode
);
2484 switch (bsg_request
->msgcode
) {
2485 case FC_BSG_RPT_ELS
:
2486 case FC_BSG_HST_ELS_NOLOGIN
:
2487 ret
= qla2x00_process_els(bsg_job
);
2490 ret
= qla2x00_process_ct(bsg_job
);
2492 case FC_BSG_HST_VENDOR
:
2493 ret
= qla2x00_process_vendor_specific(bsg_job
);
2495 case FC_BSG_HST_ADD_RPORT
:
2496 case FC_BSG_HST_DEL_RPORT
:
2499 ql_log(ql_log_warn
, vha
, 0x705a, "Unsupported BSG request.\n");
2506 qla24xx_bsg_timeout(struct fc_bsg_job
*bsg_job
)
2508 struct fc_bsg_reply
*bsg_reply
= bsg_job
->reply
;
2509 scsi_qla_host_t
*vha
= shost_priv(bsg_job
->shost
);
2510 struct qla_hw_data
*ha
= vha
->hw
;
2513 unsigned long flags
;
2514 struct req_que
*req
;
2516 /* find the bsg job from the active list of commands */
2517 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
2518 for (que
= 0; que
< ha
->max_req_queues
; que
++) {
2519 req
= ha
->req_q_map
[que
];
2523 for (cnt
= 1; cnt
< req
->num_outstanding_cmds
; cnt
++) {
2524 sp
= req
->outstanding_cmds
[cnt
];
2526 if (((sp
->type
== SRB_CT_CMD
) ||
2527 (sp
->type
== SRB_ELS_CMD_HST
) ||
2528 (sp
->type
== SRB_FXIOCB_BCMD
))
2529 && (sp
->u
.bsg_job
== bsg_job
)) {
2530 req
->outstanding_cmds
[cnt
] = NULL
;
2531 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
2532 if (ha
->isp_ops
->abort_command(sp
)) {
2533 ql_log(ql_log_warn
, vha
, 0x7089,
2534 "mbx abort_command "
2536 bsg_job
->req
->errors
=
2537 bsg_reply
->result
= -EIO
;
2539 ql_dbg(ql_dbg_user
, vha
, 0x708a,
2540 "mbx abort_command "
2542 bsg_job
->req
->errors
=
2543 bsg_reply
->result
= 0;
2545 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
2551 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
2552 ql_log(ql_log_info
, vha
, 0x708b, "SRB not found to abort.\n");
2553 bsg_job
->req
->errors
= bsg_reply
->result
= -ENXIO
;
2557 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);