aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/qla2xxx/qla_bsg.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/qla2xxx/qla_bsg.c')
-rw-r--r--drivers/scsi/qla2xxx/qla_bsg.c441
1 files changed, 238 insertions, 203 deletions
diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c
index 8c10e2c4928e..07d1767cd26b 100644
--- a/drivers/scsi/qla2xxx/qla_bsg.c
+++ b/drivers/scsi/qla2xxx/qla_bsg.c
@@ -36,7 +36,8 @@ done:
36} 36}
37 37
38int 38int
39qla24xx_fcp_prio_cfg_valid(struct qla_fcp_prio_cfg *pri_cfg, uint8_t flag) 39qla24xx_fcp_prio_cfg_valid(scsi_qla_host_t *vha,
40 struct qla_fcp_prio_cfg *pri_cfg, uint8_t flag)
40{ 41{
41 int i, ret, num_valid; 42 int i, ret, num_valid;
42 uint8_t *bcode; 43 uint8_t *bcode;
@@ -51,18 +52,17 @@ qla24xx_fcp_prio_cfg_valid(struct qla_fcp_prio_cfg *pri_cfg, uint8_t flag)
51 52
52 if (bcode_val == 0xFFFFFFFF) { 53 if (bcode_val == 0xFFFFFFFF) {
53 /* No FCP Priority config data in flash */ 54 /* No FCP Priority config data in flash */
54 DEBUG2(printk(KERN_INFO 55 ql_dbg(ql_dbg_user, vha, 0x7051,
55 "%s: No FCP priority config data.\n", 56 "No FCP Priority config data.\n");
56 __func__));
57 return 0; 57 return 0;
58 } 58 }
59 59
60 if (bcode[0] != 'H' || bcode[1] != 'Q' || bcode[2] != 'O' || 60 if (bcode[0] != 'H' || bcode[1] != 'Q' || bcode[2] != 'O' ||
61 bcode[3] != 'S') { 61 bcode[3] != 'S') {
62 /* Invalid FCP priority data header*/ 62 /* Invalid FCP priority data header*/
63 DEBUG2(printk(KERN_ERR 63 ql_dbg(ql_dbg_user, vha, 0x7052,
64 "%s: Invalid FCP Priority data header. bcode=0x%x\n", 64 "Invalid FCP Priority data header. bcode=0x%x.\n",
65 __func__, bcode_val)); 65 bcode_val);
66 return 0; 66 return 0;
67 } 67 }
68 if (flag != 1) 68 if (flag != 1)
@@ -77,15 +77,14 @@ qla24xx_fcp_prio_cfg_valid(struct qla_fcp_prio_cfg *pri_cfg, uint8_t flag)
77 77
78 if (num_valid == 0) { 78 if (num_valid == 0) {
79 /* No valid FCP priority data entries */ 79 /* No valid FCP priority data entries */
80 DEBUG2(printk(KERN_ERR 80 ql_dbg(ql_dbg_user, vha, 0x7053,
81 "%s: No valid FCP Priority data entries.\n", 81 "No valid FCP Priority data entries.\n");
82 __func__));
83 ret = 0; 82 ret = 0;
84 } else { 83 } else {
85 /* FCP priority data is valid */ 84 /* FCP priority data is valid */
86 DEBUG2(printk(KERN_INFO 85 ql_dbg(ql_dbg_user, vha, 0x7054,
87 "%s: Valid FCP priority data. num entries = %d\n", 86 "Valid FCP priority data. num entries = %d.\n",
88 __func__, num_valid)); 87 num_valid);
89 } 88 }
90 89
91 return ret; 90 return ret;
@@ -182,10 +181,9 @@ qla24xx_proc_fcp_prio_cfg_cmd(struct fc_bsg_job *bsg_job)
182 if (!ha->fcp_prio_cfg) { 181 if (!ha->fcp_prio_cfg) {
183 ha->fcp_prio_cfg = vmalloc(FCP_PRIO_CFG_SIZE); 182 ha->fcp_prio_cfg = vmalloc(FCP_PRIO_CFG_SIZE);
184 if (!ha->fcp_prio_cfg) { 183 if (!ha->fcp_prio_cfg) {
185 qla_printk(KERN_WARNING, ha, 184 ql_log(ql_log_warn, vha, 0x7050,
186 "Unable to allocate memory " 185 "Unable to allocate memory for fcp prio "
187 "for fcp prio config data (%x).\n", 186 "config data (%x).\n", FCP_PRIO_CFG_SIZE);
188 FCP_PRIO_CFG_SIZE);
189 bsg_job->reply->result = (DID_ERROR << 16); 187 bsg_job->reply->result = (DID_ERROR << 16);
190 ret = -ENOMEM; 188 ret = -ENOMEM;
191 goto exit_fcp_prio_cfg; 189 goto exit_fcp_prio_cfg;
@@ -198,9 +196,9 @@ qla24xx_proc_fcp_prio_cfg_cmd(struct fc_bsg_job *bsg_job)
198 FCP_PRIO_CFG_SIZE); 196 FCP_PRIO_CFG_SIZE);
199 197
200 /* validate fcp priority data */ 198 /* validate fcp priority data */
201 if (!qla24xx_fcp_prio_cfg_valid( 199
202 (struct qla_fcp_prio_cfg *) 200 if (!qla24xx_fcp_prio_cfg_valid(vha,
203 ha->fcp_prio_cfg, 1)) { 201 (struct qla_fcp_prio_cfg *) ha->fcp_prio_cfg, 1)) {
204 bsg_job->reply->result = (DID_ERROR << 16); 202 bsg_job->reply->result = (DID_ERROR << 16);
205 ret = -EINVAL; 203 ret = -EINVAL;
206 /* If buffer was invalidatic int 204 /* If buffer was invalidatic int
@@ -256,9 +254,8 @@ qla2x00_process_els(struct fc_bsg_job *bsg_job)
256 254
257 /* pass through is supported only for ISP 4Gb or higher */ 255 /* pass through is supported only for ISP 4Gb or higher */
258 if (!IS_FWI2_CAPABLE(ha)) { 256 if (!IS_FWI2_CAPABLE(ha)) {
259 DEBUG2(qla_printk(KERN_INFO, ha, 257 ql_dbg(ql_dbg_user, vha, 0x7001,
260 "scsi(%ld):ELS passthru not supported for ISP23xx based " 258 "ELS passthru not supported for ISP23xx based adapters.\n");
261 "adapters\n", vha->host_no));
262 rval = -EPERM; 259 rval = -EPERM;
263 goto done; 260 goto done;
264 } 261 }
@@ -266,11 +263,11 @@ qla2x00_process_els(struct fc_bsg_job *bsg_job)
266 /* Multiple SG's are not supported for ELS requests */ 263 /* Multiple SG's are not supported for ELS requests */
267 if (bsg_job->request_payload.sg_cnt > 1 || 264 if (bsg_job->request_payload.sg_cnt > 1 ||
268 bsg_job->reply_payload.sg_cnt > 1) { 265 bsg_job->reply_payload.sg_cnt > 1) {
269 DEBUG2(printk(KERN_INFO 266 ql_dbg(ql_dbg_user, vha, 0x7002,
270 "multiple SG's are not supported for ELS requests" 267 "Multiple SG's are not suppored for ELS requests, "
271 " [request_sg_cnt: %x reply_sg_cnt: %x]\n", 268 "request_sg_cnt=%x reply_sg_cnt=%x.\n",
272 bsg_job->request_payload.sg_cnt, 269 bsg_job->request_payload.sg_cnt,
273 bsg_job->reply_payload.sg_cnt)); 270 bsg_job->reply_payload.sg_cnt);
274 rval = -EPERM; 271 rval = -EPERM;
275 goto done; 272 goto done;
276 } 273 }
@@ -281,9 +278,9 @@ qla2x00_process_els(struct fc_bsg_job *bsg_job)
281 * if not perform fabric login 278 * if not perform fabric login
282 */ 279 */
283 if (qla2x00_fabric_login(vha, fcport, &nextlid)) { 280 if (qla2x00_fabric_login(vha, fcport, &nextlid)) {
284 DEBUG2(qla_printk(KERN_WARNING, ha, 281 ql_dbg(ql_dbg_user, vha, 0x7003,
285 "failed to login port %06X for ELS passthru\n", 282 "Failed to login port %06X for ELS passthru.\n",
286 fcport->d_id.b24)); 283 fcport->d_id.b24);
287 rval = -EIO; 284 rval = -EIO;
288 goto done; 285 goto done;
289 } 286 }
@@ -314,8 +311,7 @@ qla2x00_process_els(struct fc_bsg_job *bsg_job)
314 } 311 }
315 312
316 if (!vha->flags.online) { 313 if (!vha->flags.online) {
317 DEBUG2(qla_printk(KERN_WARNING, ha, 314 ql_log(ql_log_warn, vha, 0x7005, "Host not online.\n");
318 "host not online\n"));
319 rval = -EIO; 315 rval = -EIO;
320 goto done; 316 goto done;
321 } 317 }
@@ -337,12 +333,11 @@ qla2x00_process_els(struct fc_bsg_job *bsg_job)
337 333
338 if ((req_sg_cnt != bsg_job->request_payload.sg_cnt) || 334 if ((req_sg_cnt != bsg_job->request_payload.sg_cnt) ||
339 (rsp_sg_cnt != bsg_job->reply_payload.sg_cnt)) { 335 (rsp_sg_cnt != bsg_job->reply_payload.sg_cnt)) {
340 DEBUG2(printk(KERN_INFO 336 ql_log(ql_log_warn, vha, 0x7008,
341 "dma mapping resulted in different sg counts \ 337 "dma mapping resulted in different sg counts, "
342 [request_sg_cnt: %x dma_request_sg_cnt: %x\ 338 "request_sg_cnt: %x dma_request_sg_cnt:%x reply_sg_cnt:%x "
343 reply_sg_cnt: %x dma_reply_sg_cnt: %x]\n", 339 "dma_reply_sg_cnt:%x.\n", bsg_job->request_payload.sg_cnt,
344 bsg_job->request_payload.sg_cnt, req_sg_cnt, 340 req_sg_cnt, bsg_job->reply_payload.sg_cnt, rsp_sg_cnt);
345 bsg_job->reply_payload.sg_cnt, rsp_sg_cnt));
346 rval = -EAGAIN; 341 rval = -EAGAIN;
347 goto done_unmap_sg; 342 goto done_unmap_sg;
348 } 343 }
@@ -363,15 +358,16 @@ qla2x00_process_els(struct fc_bsg_job *bsg_job)
363 "bsg_els_rpt" : "bsg_els_hst"); 358 "bsg_els_rpt" : "bsg_els_hst");
364 els->u.bsg_job = bsg_job; 359 els->u.bsg_job = bsg_job;
365 360
366 DEBUG2(qla_printk(KERN_INFO, ha, 361 ql_dbg(ql_dbg_user, vha, 0x700a,
367 "scsi(%ld:%x): bsg rqst type: %s els type: %x - loop-id=%x " 362 "bsg rqst type: %s els type: %x - loop-id=%x "
368 "portid=%02x%02x%02x.\n", vha->host_no, sp->handle, type, 363 "portid=%-2x%02x%02x.\n", type,
369 bsg_job->request->rqst_data.h_els.command_code, 364 bsg_job->request->rqst_data.h_els.command_code, fcport->loop_id,
370 fcport->loop_id, fcport->d_id.b.domain, fcport->d_id.b.area, 365 fcport->d_id.b.domain, fcport->d_id.b.area, fcport->d_id.b.al_pa);
371 fcport->d_id.b.al_pa));
372 366
373 rval = qla2x00_start_sp(sp); 367 rval = qla2x00_start_sp(sp);
374 if (rval != QLA_SUCCESS) { 368 if (rval != QLA_SUCCESS) {
369 ql_log(ql_log_warn, vha, 0x700e,
370 "qla2x00_start_sp failed = %d\n", rval);
375 kfree(sp->ctx); 371 kfree(sp->ctx);
376 mempool_free(sp, ha->srb_mempool); 372 mempool_free(sp, ha->srb_mempool);
377 rval = -EIO; 373 rval = -EIO;
@@ -411,6 +407,8 @@ qla2x00_process_ct(struct fc_bsg_job *bsg_job)
411 dma_map_sg(&ha->pdev->dev, bsg_job->request_payload.sg_list, 407 dma_map_sg(&ha->pdev->dev, bsg_job->request_payload.sg_list,
412 bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE); 408 bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE);
413 if (!req_sg_cnt) { 409 if (!req_sg_cnt) {
410 ql_log(ql_log_warn, vha, 0x700f,
411 "dma_map_sg return %d for request\n", req_sg_cnt);
414 rval = -ENOMEM; 412 rval = -ENOMEM;
415 goto done; 413 goto done;
416 } 414 }
@@ -418,24 +416,25 @@ qla2x00_process_ct(struct fc_bsg_job *bsg_job)
418 rsp_sg_cnt = dma_map_sg(&ha->pdev->dev, bsg_job->reply_payload.sg_list, 416 rsp_sg_cnt = dma_map_sg(&ha->pdev->dev, bsg_job->reply_payload.sg_list,
419 bsg_job->reply_payload.sg_cnt, DMA_FROM_DEVICE); 417 bsg_job->reply_payload.sg_cnt, DMA_FROM_DEVICE);
420 if (!rsp_sg_cnt) { 418 if (!rsp_sg_cnt) {
419 ql_log(ql_log_warn, vha, 0x7010,
420 "dma_map_sg return %d for reply\n", rsp_sg_cnt);
421 rval = -ENOMEM; 421 rval = -ENOMEM;
422 goto done; 422 goto done;
423 } 423 }
424 424
425 if ((req_sg_cnt != bsg_job->request_payload.sg_cnt) || 425 if ((req_sg_cnt != bsg_job->request_payload.sg_cnt) ||
426 (rsp_sg_cnt != bsg_job->reply_payload.sg_cnt)) { 426 (rsp_sg_cnt != bsg_job->reply_payload.sg_cnt)) {
427 DEBUG2(qla_printk(KERN_WARNING, ha, 427 ql_log(ql_log_warn, vha, 0x7011,
428 "[request_sg_cnt: %x dma_request_sg_cnt: %x\ 428 "request_sg_cnt: %x dma_request_sg_cnt: %x reply_sg_cnt:%x "
429 reply_sg_cnt: %x dma_reply_sg_cnt: %x]\n", 429 "dma_reply_sg_cnt: %x\n", bsg_job->request_payload.sg_cnt,
430 bsg_job->request_payload.sg_cnt, req_sg_cnt, 430 req_sg_cnt, bsg_job->reply_payload.sg_cnt, rsp_sg_cnt);
431 bsg_job->reply_payload.sg_cnt, rsp_sg_cnt));
432 rval = -EAGAIN; 431 rval = -EAGAIN;
433 goto done_unmap_sg; 432 goto done_unmap_sg;
434 } 433 }
435 434
436 if (!vha->flags.online) { 435 if (!vha->flags.online) {
437 DEBUG2(qla_printk(KERN_WARNING, ha, 436 ql_log(ql_log_warn, vha, 0x7012,
438 "host not online\n")); 437 "Host is not online.\n");
439 rval = -EIO; 438 rval = -EIO;
440 goto done_unmap_sg; 439 goto done_unmap_sg;
441 } 440 }
@@ -451,8 +450,8 @@ qla2x00_process_ct(struct fc_bsg_job *bsg_job)
451 loop_id = vha->mgmt_svr_loop_id; 450 loop_id = vha->mgmt_svr_loop_id;
452 break; 451 break;
453 default: 452 default:
454 DEBUG2(qla_printk(KERN_INFO, ha, 453 ql_dbg(ql_dbg_user, vha, 0x7013,
455 "Unknown loop id: %x\n", loop_id)); 454 "Unknown loop id: %x.\n", loop_id);
456 rval = -EINVAL; 455 rval = -EINVAL;
457 goto done_unmap_sg; 456 goto done_unmap_sg;
458 } 457 }
@@ -464,6 +463,8 @@ qla2x00_process_ct(struct fc_bsg_job *bsg_job)
464 */ 463 */
465 fcport = qla2x00_alloc_fcport(vha, GFP_KERNEL); 464 fcport = qla2x00_alloc_fcport(vha, GFP_KERNEL);
466 if (!fcport) { 465 if (!fcport) {
466 ql_log(ql_log_warn, vha, 0x7014,
467 "Failed to allocate fcport.\n");
467 rval = -ENOMEM; 468 rval = -ENOMEM;
468 goto done_unmap_sg; 469 goto done_unmap_sg;
469 } 470 }
@@ -479,6 +480,8 @@ qla2x00_process_ct(struct fc_bsg_job *bsg_job)
479 /* Alloc SRB structure */ 480 /* Alloc SRB structure */
480 sp = qla2x00_get_ctx_bsg_sp(vha, fcport, sizeof(struct srb_ctx)); 481 sp = qla2x00_get_ctx_bsg_sp(vha, fcport, sizeof(struct srb_ctx));
481 if (!sp) { 482 if (!sp) {
483 ql_log(ql_log_warn, vha, 0x7015,
484 "qla2x00_get_ctx_bsg_sp failed.\n");
482 rval = -ENOMEM; 485 rval = -ENOMEM;
483 goto done_free_fcport; 486 goto done_free_fcport;
484 } 487 }
@@ -488,15 +491,17 @@ qla2x00_process_ct(struct fc_bsg_job *bsg_job)
488 ct->name = "bsg_ct"; 491 ct->name = "bsg_ct";
489 ct->u.bsg_job = bsg_job; 492 ct->u.bsg_job = bsg_job;
490 493
491 DEBUG2(qla_printk(KERN_INFO, ha, 494 ql_dbg(ql_dbg_user, vha, 0x7016,
492 "scsi(%ld:%x): bsg rqst type: %s els type: %x - loop-id=%x " 495 "bsg rqst type: %s else type: %x - "
493 "portid=%02x%02x%02x.\n", vha->host_no, sp->handle, type, 496 "loop-id=%x portid=%02x%02x%02x.\n", type,
494 (bsg_job->request->rqst_data.h_ct.preamble_word2 >> 16), 497 (bsg_job->request->rqst_data.h_ct.preamble_word2 >> 16),
495 fcport->loop_id, fcport->d_id.b.domain, fcport->d_id.b.area, 498 fcport->loop_id, fcport->d_id.b.domain, fcport->d_id.b.area,
496 fcport->d_id.b.al_pa)); 499 fcport->d_id.b.al_pa);
497 500
498 rval = qla2x00_start_sp(sp); 501 rval = qla2x00_start_sp(sp);
499 if (rval != QLA_SUCCESS) { 502 if (rval != QLA_SUCCESS) {
503 ql_log(ql_log_warn, vha, 0x7017,
504 "qla2x00_start_sp failed=%d.\n", rval);
500 kfree(sp->ctx); 505 kfree(sp->ctx);
501 mempool_free(sp, ha->srb_mempool); 506 mempool_free(sp, ha->srb_mempool);
502 rval = -EIO; 507 rval = -EIO;
@@ -535,9 +540,8 @@ qla81xx_set_internal_loopback(scsi_qla_host_t *vha, uint16_t *config,
535 ha->notify_dcbx_comp = 1; 540 ha->notify_dcbx_comp = 1;
536 ret = qla81xx_set_port_config(vha, new_config); 541 ret = qla81xx_set_port_config(vha, new_config);
537 if (ret != QLA_SUCCESS) { 542 if (ret != QLA_SUCCESS) {
538 DEBUG2(printk(KERN_ERR 543 ql_log(ql_log_warn, vha, 0x7021,
539 "%s(%lu): Set port config failed\n", 544 "set port config failed.\n");
540 __func__, vha->host_no));
541 ha->notify_dcbx_comp = 0; 545 ha->notify_dcbx_comp = 0;
542 rval = -EINVAL; 546 rval = -EINVAL;
543 goto done_set_internal; 547 goto done_set_internal;
@@ -545,11 +549,11 @@ qla81xx_set_internal_loopback(scsi_qla_host_t *vha, uint16_t *config,
545 549
546 /* Wait for DCBX complete event */ 550 /* Wait for DCBX complete event */
547 if (!wait_for_completion_timeout(&ha->dcbx_comp, (20 * HZ))) { 551 if (!wait_for_completion_timeout(&ha->dcbx_comp, (20 * HZ))) {
548 DEBUG2(qla_printk(KERN_WARNING, ha, 552 ql_dbg(ql_dbg_user, vha, 0x7022,
549 "State change notificaition not received.\n")); 553 "State change notification not received.\n");
550 } else 554 } else
551 DEBUG2(qla_printk(KERN_INFO, ha, 555 ql_dbg(ql_dbg_user, vha, 0x7023,
552 "State change RECEIVED\n")); 556 "State change received.\n");
553 557
554 ha->notify_dcbx_comp = 0; 558 ha->notify_dcbx_comp = 0;
555 559
@@ -581,9 +585,8 @@ qla81xx_reset_internal_loopback(scsi_qla_host_t *vha, uint16_t *config,
581 ha->notify_dcbx_comp = wait; 585 ha->notify_dcbx_comp = wait;
582 ret = qla81xx_set_port_config(vha, new_config); 586 ret = qla81xx_set_port_config(vha, new_config);
583 if (ret != QLA_SUCCESS) { 587 if (ret != QLA_SUCCESS) {
584 DEBUG2(printk(KERN_ERR 588 ql_log(ql_log_warn, vha, 0x7025,
585 "%s(%lu): Set port config failed\n", 589 "Set port config failed.\n");
586 __func__, vha->host_no));
587 ha->notify_dcbx_comp = 0; 590 ha->notify_dcbx_comp = 0;
588 rval = -EINVAL; 591 rval = -EINVAL;
589 goto done_reset_internal; 592 goto done_reset_internal;
@@ -592,14 +595,14 @@ qla81xx_reset_internal_loopback(scsi_qla_host_t *vha, uint16_t *config,
592 /* Wait for DCBX complete event */ 595 /* Wait for DCBX complete event */
593 if (wait && !wait_for_completion_timeout(&ha->dcbx_comp, 596 if (wait && !wait_for_completion_timeout(&ha->dcbx_comp,
594 (20 * HZ))) { 597 (20 * HZ))) {
595 DEBUG2(qla_printk(KERN_WARNING, ha, 598 ql_dbg(ql_dbg_user, vha, 0x7026,
596 "State change notificaition not received.\n")); 599 "State change notification not received.\n");
597 ha->notify_dcbx_comp = 0; 600 ha->notify_dcbx_comp = 0;
598 rval = -EINVAL; 601 rval = -EINVAL;
599 goto done_reset_internal; 602 goto done_reset_internal;
600 } else 603 } else
601 DEBUG2(qla_printk(KERN_INFO, ha, 604 ql_dbg(ql_dbg_user, vha, 0x7027,
602 "State change RECEIVED\n")); 605 "State change received.\n");
603 606
604 ha->notify_dcbx_comp = 0; 607 ha->notify_dcbx_comp = 0;
605 } 608 }
@@ -629,11 +632,13 @@ qla2x00_process_loopback(struct fc_bsg_job *bsg_job)
629 632
630 if (test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) || 633 if (test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) ||
631 test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) || 634 test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) ||
632 test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) 635 test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) {
636 ql_log(ql_log_warn, vha, 0x7018, "Abort active or needed.\n");
633 return -EBUSY; 637 return -EBUSY;
638 }
634 639
635 if (!vha->flags.online) { 640 if (!vha->flags.online) {
636 DEBUG2(qla_printk(KERN_WARNING, ha, "host not online\n")); 641 ql_log(ql_log_warn, vha, 0x7019, "Host is not online.\n");
637 return -EIO; 642 return -EIO;
638 } 643 }
639 644
@@ -641,26 +646,31 @@ qla2x00_process_loopback(struct fc_bsg_job *bsg_job)
641 bsg_job->request_payload.sg_list, bsg_job->request_payload.sg_cnt, 646 bsg_job->request_payload.sg_list, bsg_job->request_payload.sg_cnt,
642 DMA_TO_DEVICE); 647 DMA_TO_DEVICE);
643 648
644 if (!elreq.req_sg_cnt) 649 if (!elreq.req_sg_cnt) {
650 ql_log(ql_log_warn, vha, 0x701a,
651 "dma_map_sg returned %d for request.\n", elreq.req_sg_cnt);
645 return -ENOMEM; 652 return -ENOMEM;
653 }
646 654
647 elreq.rsp_sg_cnt = dma_map_sg(&ha->pdev->dev, 655 elreq.rsp_sg_cnt = dma_map_sg(&ha->pdev->dev,
648 bsg_job->reply_payload.sg_list, bsg_job->reply_payload.sg_cnt, 656 bsg_job->reply_payload.sg_list, bsg_job->reply_payload.sg_cnt,
649 DMA_FROM_DEVICE); 657 DMA_FROM_DEVICE);
650 658
651 if (!elreq.rsp_sg_cnt) { 659 if (!elreq.rsp_sg_cnt) {
660 ql_log(ql_log_warn, vha, 0x701b,
661 "dma_map_sg returned %d for reply.\n", elreq.rsp_sg_cnt);
652 rval = -ENOMEM; 662 rval = -ENOMEM;
653 goto done_unmap_req_sg; 663 goto done_unmap_req_sg;
654 } 664 }
655 665
656 if ((elreq.req_sg_cnt != bsg_job->request_payload.sg_cnt) || 666 if ((elreq.req_sg_cnt != bsg_job->request_payload.sg_cnt) ||
657 (elreq.rsp_sg_cnt != bsg_job->reply_payload.sg_cnt)) { 667 (elreq.rsp_sg_cnt != bsg_job->reply_payload.sg_cnt)) {
658 DEBUG2(printk(KERN_INFO 668 ql_log(ql_log_warn, vha, 0x701c,
659 "dma mapping resulted in different sg counts " 669 "dma mapping resulted in different sg counts, "
660 "[request_sg_cnt: %x dma_request_sg_cnt: %x " 670 "request_sg_cnt: %x dma_request_sg_cnt: %x "
661 "reply_sg_cnt: %x dma_reply_sg_cnt: %x]\n", 671 "reply_sg_cnt: %x dma_reply_sg_cnt: %x.\n",
662 bsg_job->request_payload.sg_cnt, elreq.req_sg_cnt, 672 bsg_job->request_payload.sg_cnt, elreq.req_sg_cnt,
663 bsg_job->reply_payload.sg_cnt, elreq.rsp_sg_cnt)); 673 bsg_job->reply_payload.sg_cnt, elreq.rsp_sg_cnt);
664 rval = -EAGAIN; 674 rval = -EAGAIN;
665 goto done_unmap_sg; 675 goto done_unmap_sg;
666 } 676 }
@@ -668,8 +678,8 @@ qla2x00_process_loopback(struct fc_bsg_job *bsg_job)
668 req_data = dma_alloc_coherent(&ha->pdev->dev, req_data_len, 678 req_data = dma_alloc_coherent(&ha->pdev->dev, req_data_len,
669 &req_data_dma, GFP_KERNEL); 679 &req_data_dma, GFP_KERNEL);
670 if (!req_data) { 680 if (!req_data) {
671 DEBUG2(printk(KERN_ERR "%s: dma alloc for req_data " 681 ql_log(ql_log_warn, vha, 0x701d,
672 "failed for host=%lu\n", __func__, vha->host_no)); 682 "dma alloc failed for req_data.\n");
673 rval = -ENOMEM; 683 rval = -ENOMEM;
674 goto done_unmap_sg; 684 goto done_unmap_sg;
675 } 685 }
@@ -677,8 +687,8 @@ qla2x00_process_loopback(struct fc_bsg_job *bsg_job)
677 rsp_data = dma_alloc_coherent(&ha->pdev->dev, rsp_data_len, 687 rsp_data = dma_alloc_coherent(&ha->pdev->dev, rsp_data_len,
678 &rsp_data_dma, GFP_KERNEL); 688 &rsp_data_dma, GFP_KERNEL);
679 if (!rsp_data) { 689 if (!rsp_data) {
680 DEBUG2(printk(KERN_ERR "%s: dma alloc for rsp_data " 690 ql_log(ql_log_warn, vha, 0x7004,
681 "failed for host=%lu\n", __func__, vha->host_no)); 691 "dma alloc failed for rsp_data.\n");
682 rval = -ENOMEM; 692 rval = -ENOMEM;
683 goto done_free_dma_req; 693 goto done_free_dma_req;
684 } 694 }
@@ -699,8 +709,8 @@ qla2x00_process_loopback(struct fc_bsg_job *bsg_job)
699 && req_data_len == MAX_ELS_FRAME_PAYLOAD)) && 709 && req_data_len == MAX_ELS_FRAME_PAYLOAD)) &&
700 elreq.options == EXTERNAL_LOOPBACK) { 710 elreq.options == EXTERNAL_LOOPBACK) {
701 type = "FC_BSG_HST_VENDOR_ECHO_DIAG"; 711 type = "FC_BSG_HST_VENDOR_ECHO_DIAG";
702 DEBUG2(qla_printk(KERN_INFO, ha, 712 ql_dbg(ql_dbg_user, vha, 0x701e,
703 "scsi(%ld) bsg rqst type: %s\n", vha->host_no, type)); 713 "BSG request type: %s.\n", type);
704 command_sent = INT_DEF_LB_ECHO_CMD; 714 command_sent = INT_DEF_LB_ECHO_CMD;
705 rval = qla2x00_echo_test(vha, &elreq, response); 715 rval = qla2x00_echo_test(vha, &elreq, response);
706 } else { 716 } else {
@@ -708,9 +718,8 @@ qla2x00_process_loopback(struct fc_bsg_job *bsg_job)
708 memset(config, 0, sizeof(config)); 718 memset(config, 0, sizeof(config));
709 memset(new_config, 0, sizeof(new_config)); 719 memset(new_config, 0, sizeof(new_config));
710 if (qla81xx_get_port_config(vha, config)) { 720 if (qla81xx_get_port_config(vha, config)) {
711 DEBUG2(printk(KERN_ERR 721 ql_log(ql_log_warn, vha, 0x701f,
712 "%s(%lu): Get port config failed\n", 722 "Get port config failed.\n");
713 __func__, vha->host_no));
714 bsg_job->reply->reply_payload_rcv_len = 0; 723 bsg_job->reply->reply_payload_rcv_len = 0;
715 bsg_job->reply->result = (DID_ERROR << 16); 724 bsg_job->reply->result = (DID_ERROR << 16);
716 rval = -EPERM; 725 rval = -EPERM;
@@ -718,11 +727,13 @@ qla2x00_process_loopback(struct fc_bsg_job *bsg_job)
718 } 727 }
719 728
720 if (elreq.options != EXTERNAL_LOOPBACK) { 729 if (elreq.options != EXTERNAL_LOOPBACK) {
721 DEBUG2(qla_printk(KERN_INFO, ha, 730 ql_dbg(ql_dbg_user, vha, 0x7020,
722 "Internal: current port config = %x\n", 731 "Internal: curent port config = %x\n",
723 config[0])); 732 config[0]);
724 if (qla81xx_set_internal_loopback(vha, config, 733 if (qla81xx_set_internal_loopback(vha, config,
725 new_config)) { 734 new_config)) {
735 ql_log(ql_log_warn, vha, 0x7024,
736 "Internal loopback failed.\n");
726 bsg_job->reply->reply_payload_rcv_len = 737 bsg_job->reply->reply_payload_rcv_len =
727 0; 738 0;
728 bsg_job->reply->result = 739 bsg_job->reply->result =
@@ -746,9 +757,8 @@ qla2x00_process_loopback(struct fc_bsg_job *bsg_job)
746 } 757 }
747 758
748 type = "FC_BSG_HST_VENDOR_LOOPBACK"; 759 type = "FC_BSG_HST_VENDOR_LOOPBACK";
749 DEBUG2(qla_printk(KERN_INFO, ha, 760 ql_dbg(ql_dbg_user, vha, 0x7028,
750 "scsi(%ld) bsg rqst type: %s\n", 761 "BSG request type: %s.\n", type);
751 vha->host_no, type));
752 762
753 command_sent = INT_DEF_LB_LOOPBACK_CMD; 763 command_sent = INT_DEF_LB_LOOPBACK_CMD;
754 rval = qla2x00_loopback_test(vha, &elreq, response); 764 rval = qla2x00_loopback_test(vha, &elreq, response);
@@ -763,17 +773,16 @@ qla2x00_process_loopback(struct fc_bsg_job *bsg_job)
763 773
764 if (response[0] == MBS_COMMAND_ERROR && 774 if (response[0] == MBS_COMMAND_ERROR &&
765 response[1] == MBS_LB_RESET) { 775 response[1] == MBS_LB_RESET) {
766 DEBUG2(printk(KERN_ERR "%s(%ld): ABORTing " 776 ql_log(ql_log_warn, vha, 0x7029,
767 "ISP\n", __func__, vha->host_no)); 777 "MBX command error, Aborting ISP.\n");
768 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); 778 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
769 qla2xxx_wake_dpc(vha); 779 qla2xxx_wake_dpc(vha);
770 qla2x00_wait_for_chip_reset(vha); 780 qla2x00_wait_for_chip_reset(vha);
771 /* Also reset the MPI */ 781 /* Also reset the MPI */
772 if (qla81xx_restart_mpi_firmware(vha) != 782 if (qla81xx_restart_mpi_firmware(vha) !=
773 QLA_SUCCESS) { 783 QLA_SUCCESS) {
774 qla_printk(KERN_INFO, ha, 784 ql_log(ql_log_warn, vha, 0x702a,
775 "MPI reset failed for host%ld.\n", 785 "MPI reset failed.\n");
776 vha->host_no);
777 } 786 }
778 787
779 bsg_job->reply->reply_payload_rcv_len = 0; 788 bsg_job->reply->reply_payload_rcv_len = 0;
@@ -783,17 +792,16 @@ qla2x00_process_loopback(struct fc_bsg_job *bsg_job)
783 } 792 }
784 } else { 793 } else {
785 type = "FC_BSG_HST_VENDOR_LOOPBACK"; 794 type = "FC_BSG_HST_VENDOR_LOOPBACK";
786 DEBUG2(qla_printk(KERN_INFO, ha, 795 ql_dbg(ql_dbg_user, vha, 0x702b,
787 "scsi(%ld) bsg rqst type: %s\n", 796 "BSG request type: %s.\n", type);
788 vha->host_no, type));
789 command_sent = INT_DEF_LB_LOOPBACK_CMD; 797 command_sent = INT_DEF_LB_LOOPBACK_CMD;
790 rval = qla2x00_loopback_test(vha, &elreq, response); 798 rval = qla2x00_loopback_test(vha, &elreq, response);
791 } 799 }
792 } 800 }
793 801
794 if (rval) { 802 if (rval) {
795 DEBUG2(qla_printk(KERN_WARNING, ha, "scsi(%ld) Vendor " 803 ql_log(ql_log_warn, vha, 0x702c,
796 "request %s failed\n", vha->host_no, type)); 804 "Vendor request %s failed.\n", type);
797 805
798 fw_sts_ptr = ((uint8_t *)bsg_job->req->sense) + 806 fw_sts_ptr = ((uint8_t *)bsg_job->req->sense) +
799 sizeof(struct fc_bsg_reply); 807 sizeof(struct fc_bsg_reply);
@@ -805,8 +813,8 @@ qla2x00_process_loopback(struct fc_bsg_job *bsg_job)
805 bsg_job->reply->reply_payload_rcv_len = 0; 813 bsg_job->reply->reply_payload_rcv_len = 0;
806 bsg_job->reply->result = (DID_ERROR << 16); 814 bsg_job->reply->result = (DID_ERROR << 16);
807 } else { 815 } else {
808 DEBUG2(qla_printk(KERN_WARNING, ha, "scsi(%ld) Vendor " 816 ql_dbg(ql_dbg_user, vha, 0x702d,
809 "request %s completed\n", vha->host_no, type)); 817 "Vendor request %s completed.\n", type);
810 818
811 bsg_job->reply_len = sizeof(struct fc_bsg_reply) + 819 bsg_job->reply_len = sizeof(struct fc_bsg_reply) +
812 sizeof(response) + sizeof(uint8_t); 820 sizeof(response) + sizeof(uint8_t);
@@ -851,12 +859,13 @@ qla84xx_reset(struct fc_bsg_job *bsg_job)
851 859
852 if (test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) || 860 if (test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) ||
853 test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) || 861 test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) ||
854 test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) 862 test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) {
863 ql_log(ql_log_warn, vha, 0x702e, "Abort active or needed.\n");
855 return -EBUSY; 864 return -EBUSY;
865 }
856 866
857 if (!IS_QLA84XX(ha)) { 867 if (!IS_QLA84XX(ha)) {
858 DEBUG2(qla_printk(KERN_WARNING, ha, "scsi(%ld): Not 84xx, " 868 ql_dbg(ql_dbg_user, vha, 0x702f, "Not 84xx, exiting.\n");
859 "exiting.\n", vha->host_no));
860 return -EINVAL; 869 return -EINVAL;
861 } 870 }
862 871
@@ -865,14 +874,14 @@ qla84xx_reset(struct fc_bsg_job *bsg_job)
865 rval = qla84xx_reset_chip(vha, flag == A84_ISSUE_RESET_DIAG_FW); 874 rval = qla84xx_reset_chip(vha, flag == A84_ISSUE_RESET_DIAG_FW);
866 875
867 if (rval) { 876 if (rval) {
868 DEBUG2(qla_printk(KERN_WARNING, ha, "scsi(%ld) Vendor " 877 ql_log(ql_log_warn, vha, 0x7030,
869 "request 84xx reset failed\n", vha->host_no)); 878 "Vendor request 84xx reset failed.\n");
870 rval = bsg_job->reply->reply_payload_rcv_len = 0; 879 rval = bsg_job->reply->reply_payload_rcv_len = 0;
871 bsg_job->reply->result = (DID_ERROR << 16); 880 bsg_job->reply->result = (DID_ERROR << 16);
872 881
873 } else { 882 } else {
874 DEBUG2(qla_printk(KERN_WARNING, ha, "scsi(%ld) Vendor " 883 ql_dbg(ql_dbg_user, vha, 0x7031,
875 "request 84xx reset completed\n", vha->host_no)); 884 "Vendor request 84xx reset completed.\n");
876 bsg_job->reply->result = DID_OK; 885 bsg_job->reply->result = DID_OK;
877 } 886 }
878 887
@@ -902,21 +911,24 @@ qla84xx_updatefw(struct fc_bsg_job *bsg_job)
902 return -EBUSY; 911 return -EBUSY;
903 912
904 if (!IS_QLA84XX(ha)) { 913 if (!IS_QLA84XX(ha)) {
905 DEBUG2(qla_printk(KERN_WARNING, ha, "scsi(%ld): Not 84xx, " 914 ql_dbg(ql_dbg_user, vha, 0x7032,
906 "exiting.\n", vha->host_no)); 915 "Not 84xx, exiting.\n");
907 return -EINVAL; 916 return -EINVAL;
908 } 917 }
909 918
910 sg_cnt = dma_map_sg(&ha->pdev->dev, bsg_job->request_payload.sg_list, 919 sg_cnt = dma_map_sg(&ha->pdev->dev, bsg_job->request_payload.sg_list,
911 bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE); 920 bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE);
912 if (!sg_cnt) 921 if (!sg_cnt) {
922 ql_log(ql_log_warn, vha, 0x7033,
923 "dma_map_sg returned %d for request.\n", sg_cnt);
913 return -ENOMEM; 924 return -ENOMEM;
925 }
914 926
915 if (sg_cnt != bsg_job->request_payload.sg_cnt) { 927 if (sg_cnt != bsg_job->request_payload.sg_cnt) {
916 DEBUG2(printk(KERN_INFO 928 ql_log(ql_log_warn, vha, 0x7034,
917 "dma mapping resulted in different sg counts " 929 "DMA mapping resulted in different sg counts, "
918 "request_sg_cnt: %x dma_request_sg_cnt: %x ", 930 "request_sg_cnt: %x dma_request_sg_cnt: %x.\n",
919 bsg_job->request_payload.sg_cnt, sg_cnt)); 931 bsg_job->request_payload.sg_cnt, sg_cnt);
920 rval = -EAGAIN; 932 rval = -EAGAIN;
921 goto done_unmap_sg; 933 goto done_unmap_sg;
922 } 934 }
@@ -925,8 +937,8 @@ qla84xx_updatefw(struct fc_bsg_job *bsg_job)
925 fw_buf = dma_alloc_coherent(&ha->pdev->dev, data_len, 937 fw_buf = dma_alloc_coherent(&ha->pdev->dev, data_len,
926 &fw_dma, GFP_KERNEL); 938 &fw_dma, GFP_KERNEL);
927 if (!fw_buf) { 939 if (!fw_buf) {
928 DEBUG2(printk(KERN_ERR "%s: dma alloc for fw_buf " 940 ql_log(ql_log_warn, vha, 0x7035,
929 "failed for host=%lu\n", __func__, vha->host_no)); 941 "DMA alloc failed for fw_buf.\n");
930 rval = -ENOMEM; 942 rval = -ENOMEM;
931 goto done_unmap_sg; 943 goto done_unmap_sg;
932 } 944 }
@@ -936,8 +948,8 @@ qla84xx_updatefw(struct fc_bsg_job *bsg_job)
936 948
937 mn = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma); 949 mn = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma);
938 if (!mn) { 950 if (!mn) {
939 DEBUG2(printk(KERN_ERR "%s: dma alloc for fw buffer " 951 ql_log(ql_log_warn, vha, 0x7036,
940 "failed for host=%lu\n", __func__, vha->host_no)); 952 "DMA alloc failed for fw buffer.\n");
941 rval = -ENOMEM; 953 rval = -ENOMEM;
942 goto done_free_fw_buf; 954 goto done_free_fw_buf;
943 } 955 }
@@ -965,15 +977,15 @@ qla84xx_updatefw(struct fc_bsg_job *bsg_job)
965 rval = qla2x00_issue_iocb_timeout(vha, mn, mn_dma, 0, 120); 977 rval = qla2x00_issue_iocb_timeout(vha, mn, mn_dma, 0, 120);
966 978
967 if (rval) { 979 if (rval) {
968 DEBUG2(qla_printk(KERN_WARNING, ha, "scsi(%ld) Vendor " 980 ql_log(ql_log_warn, vha, 0x7037,
969 "request 84xx updatefw failed\n", vha->host_no)); 981 "Vendor request 84xx updatefw failed.\n");
970 982
971 rval = bsg_job->reply->reply_payload_rcv_len = 0; 983 rval = bsg_job->reply->reply_payload_rcv_len = 0;
972 bsg_job->reply->result = (DID_ERROR << 16); 984 bsg_job->reply->result = (DID_ERROR << 16);
973 985
974 } else { 986 } else {
975 DEBUG2(qla_printk(KERN_WARNING, ha, "scsi(%ld) Vendor " 987 ql_dbg(ql_dbg_user, vha, 0x7038,
976 "request 84xx updatefw completed\n", vha->host_no)); 988 "Vendor request 84xx updatefw completed.\n");
977 989
978 bsg_job->reply_len = sizeof(struct fc_bsg_reply); 990 bsg_job->reply_len = sizeof(struct fc_bsg_reply);
979 bsg_job->reply->result = DID_OK; 991 bsg_job->reply->result = DID_OK;
@@ -1009,27 +1021,30 @@ qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_job)
1009 1021
1010 if (test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) || 1022 if (test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) ||
1011 test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) || 1023 test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) ||
1012 test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) 1024 test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) {
1025 ql_log(ql_log_warn, vha, 0x7039,
1026 "Abort active or needed.\n");
1013 return -EBUSY; 1027 return -EBUSY;
1028 }
1014 1029
1015 if (!IS_QLA84XX(ha)) { 1030 if (!IS_QLA84XX(ha)) {
1016 DEBUG2(qla_printk(KERN_WARNING, ha, "scsi(%ld): Not 84xx, " 1031 ql_log(ql_log_warn, vha, 0x703a,
1017 "exiting.\n", vha->host_no)); 1032 "Not 84xx, exiting.\n");
1018 return -EINVAL; 1033 return -EINVAL;
1019 } 1034 }
1020 1035
1021 ql84_mgmt = (struct qla_bsg_a84_mgmt *)((char *)bsg_job->request + 1036 ql84_mgmt = (struct qla_bsg_a84_mgmt *)((char *)bsg_job->request +
1022 sizeof(struct fc_bsg_request)); 1037 sizeof(struct fc_bsg_request));
1023 if (!ql84_mgmt) { 1038 if (!ql84_mgmt) {
1024 DEBUG2(printk("%s(%ld): mgmt header not provided, exiting.\n", 1039 ql_log(ql_log_warn, vha, 0x703b,
1025 __func__, vha->host_no)); 1040 "MGMT header not provided, exiting.\n");
1026 return -EINVAL; 1041 return -EINVAL;
1027 } 1042 }
1028 1043
1029 mn = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma); 1044 mn = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma);
1030 if (!mn) { 1045 if (!mn) {
1031 DEBUG2(printk(KERN_ERR "%s: dma alloc for fw buffer " 1046 ql_log(ql_log_warn, vha, 0x703c,
1032 "failed for host=%lu\n", __func__, vha->host_no)); 1047 "DMA alloc failed for fw buffer.\n");
1033 return -ENOMEM; 1048 return -ENOMEM;
1034 } 1049 }
1035 1050
@@ -1044,6 +1059,8 @@ qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_job)
1044 bsg_job->reply_payload.sg_list, 1059 bsg_job->reply_payload.sg_list,
1045 bsg_job->reply_payload.sg_cnt, DMA_FROM_DEVICE); 1060 bsg_job->reply_payload.sg_cnt, DMA_FROM_DEVICE);
1046 if (!sg_cnt) { 1061 if (!sg_cnt) {
1062 ql_log(ql_log_warn, vha, 0x703d,
1063 "dma_map_sg returned %d for reply.\n", sg_cnt);
1047 rval = -ENOMEM; 1064 rval = -ENOMEM;
1048 goto exit_mgmt; 1065 goto exit_mgmt;
1049 } 1066 }
@@ -1051,10 +1068,10 @@ qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_job)
1051 dma_direction = DMA_FROM_DEVICE; 1068 dma_direction = DMA_FROM_DEVICE;
1052 1069
1053 if (sg_cnt != bsg_job->reply_payload.sg_cnt) { 1070 if (sg_cnt != bsg_job->reply_payload.sg_cnt) {
1054 DEBUG2(printk(KERN_INFO 1071 ql_log(ql_log_warn, vha, 0x703e,
1055 "dma mapping resulted in different sg counts " 1072 "DMA mapping resulted in different sg counts, "
1056 "reply_sg_cnt: %x dma_reply_sg_cnt: %x\n", 1073 "reply_sg_cnt: %x dma_reply_sg_cnt: %x.\n",
1057 bsg_job->reply_payload.sg_cnt, sg_cnt)); 1074 bsg_job->reply_payload.sg_cnt, sg_cnt);
1058 rval = -EAGAIN; 1075 rval = -EAGAIN;
1059 goto done_unmap_sg; 1076 goto done_unmap_sg;
1060 } 1077 }
@@ -1064,9 +1081,8 @@ qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_job)
1064 mgmt_b = dma_alloc_coherent(&ha->pdev->dev, data_len, 1081 mgmt_b = dma_alloc_coherent(&ha->pdev->dev, data_len,
1065 &mgmt_dma, GFP_KERNEL); 1082 &mgmt_dma, GFP_KERNEL);
1066 if (!mgmt_b) { 1083 if (!mgmt_b) {
1067 DEBUG2(printk(KERN_ERR "%s: dma alloc for mgmt_b " 1084 ql_log(ql_log_warn, vha, 0x703f,
1068 "failed for host=%lu\n", 1085 "DMA alloc failed for mgmt_b.\n");
1069 __func__, vha->host_no));
1070 rval = -ENOMEM; 1086 rval = -ENOMEM;
1071 goto done_unmap_sg; 1087 goto done_unmap_sg;
1072 } 1088 }
@@ -1094,6 +1110,8 @@ qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_job)
1094 bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE); 1110 bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE);
1095 1111
1096 if (!sg_cnt) { 1112 if (!sg_cnt) {
1113 ql_log(ql_log_warn, vha, 0x7040,
1114 "dma_map_sg returned %d.\n", sg_cnt);
1097 rval = -ENOMEM; 1115 rval = -ENOMEM;
1098 goto exit_mgmt; 1116 goto exit_mgmt;
1099 } 1117 }
@@ -1101,10 +1119,10 @@ qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_job)
1101 dma_direction = DMA_TO_DEVICE; 1119 dma_direction = DMA_TO_DEVICE;
1102 1120
1103 if (sg_cnt != bsg_job->request_payload.sg_cnt) { 1121 if (sg_cnt != bsg_job->request_payload.sg_cnt) {
1104 DEBUG2(printk(KERN_INFO 1122 ql_log(ql_log_warn, vha, 0x7041,
1105 "dma mapping resulted in different sg counts " 1123 "DMA mapping resulted in different sg counts, "
1106 "request_sg_cnt: %x dma_request_sg_cnt: %x ", 1124 "request_sg_cnt: %x dma_request_sg_cnt: %x.\n",
1107 bsg_job->request_payload.sg_cnt, sg_cnt)); 1125 bsg_job->request_payload.sg_cnt, sg_cnt);
1108 rval = -EAGAIN; 1126 rval = -EAGAIN;
1109 goto done_unmap_sg; 1127 goto done_unmap_sg;
1110 } 1128 }
@@ -1113,9 +1131,8 @@ qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_job)
1113 mgmt_b = dma_alloc_coherent(&ha->pdev->dev, data_len, 1131 mgmt_b = dma_alloc_coherent(&ha->pdev->dev, data_len,
1114 &mgmt_dma, GFP_KERNEL); 1132 &mgmt_dma, GFP_KERNEL);
1115 if (!mgmt_b) { 1133 if (!mgmt_b) {
1116 DEBUG2(printk(KERN_ERR "%s: dma alloc for mgmt_b " 1134 ql_log(ql_log_warn, vha, 0x7042,
1117 "failed for host=%lu\n", 1135 "DMA alloc failed for mgmt_b.\n");
1118 __func__, vha->host_no));
1119 rval = -ENOMEM; 1136 rval = -ENOMEM;
1120 goto done_unmap_sg; 1137 goto done_unmap_sg;
1121 } 1138 }
@@ -1156,15 +1173,15 @@ qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_job)
1156 rval = qla2x00_issue_iocb(vha, mn, mn_dma, 0); 1173 rval = qla2x00_issue_iocb(vha, mn, mn_dma, 0);
1157 1174
1158 if (rval) { 1175 if (rval) {
1159 DEBUG2(qla_printk(KERN_WARNING, ha, "scsi(%ld) Vendor " 1176 ql_log(ql_log_warn, vha, 0x7043,
1160 "request 84xx mgmt failed\n", vha->host_no)); 1177 "Vendor request 84xx mgmt failed.\n");
1161 1178
1162 rval = bsg_job->reply->reply_payload_rcv_len = 0; 1179 rval = bsg_job->reply->reply_payload_rcv_len = 0;
1163 bsg_job->reply->result = (DID_ERROR << 16); 1180 bsg_job->reply->result = (DID_ERROR << 16);
1164 1181
1165 } else { 1182 } else {
1166 DEBUG2(qla_printk(KERN_WARNING, ha, "scsi(%ld) Vendor " 1183 ql_dbg(ql_dbg_user, vha, 0x7044,
1167 "request 84xx mgmt completed\n", vha->host_no)); 1184 "Vendor request 84xx mgmt completed.\n");
1168 1185
1169 bsg_job->reply_len = sizeof(struct fc_bsg_reply); 1186 bsg_job->reply_len = sizeof(struct fc_bsg_reply);
1170 bsg_job->reply->result = DID_OK; 1187 bsg_job->reply->result = DID_OK;
@@ -1204,7 +1221,6 @@ qla24xx_iidma(struct fc_bsg_job *bsg_job)
1204{ 1221{
1205 struct Scsi_Host *host = bsg_job->shost; 1222 struct Scsi_Host *host = bsg_job->shost;
1206 scsi_qla_host_t *vha = shost_priv(host); 1223 scsi_qla_host_t *vha = shost_priv(host);
1207 struct qla_hw_data *ha = vha->hw;
1208 int rval = 0; 1224 int rval = 0;
1209 struct qla_port_param *port_param = NULL; 1225 struct qla_port_param *port_param = NULL;
1210 fc_port_t *fcport = NULL; 1226 fc_port_t *fcport = NULL;
@@ -1215,26 +1231,27 @@ qla24xx_iidma(struct fc_bsg_job *bsg_job)
1215 1231
1216 if (test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) || 1232 if (test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) ||
1217 test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) || 1233 test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) ||
1218 test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) 1234 test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) {
1235 ql_log(ql_log_warn, vha, 0x7045, "abort active or needed.\n");
1219 return -EBUSY; 1236 return -EBUSY;
1237 }
1220 1238
1221 if (!IS_IIDMA_CAPABLE(vha->hw)) { 1239 if (!IS_IIDMA_CAPABLE(vha->hw)) {
1222 DEBUG2(qla_printk(KERN_WARNING, ha, "%s(%lu): iiDMA not " 1240 ql_log(ql_log_info, vha, 0x7046, "iiDMA not supported.\n");
1223 "supported\n", __func__, vha->host_no));
1224 return -EINVAL; 1241 return -EINVAL;
1225 } 1242 }
1226 1243
1227 port_param = (struct qla_port_param *)((char *)bsg_job->request + 1244 port_param = (struct qla_port_param *)((char *)bsg_job->request +
1228 sizeof(struct fc_bsg_request)); 1245 sizeof(struct fc_bsg_request));
1229 if (!port_param) { 1246 if (!port_param) {
1230 DEBUG2(printk("%s(%ld): port_param header not provided, " 1247 ql_log(ql_log_warn, vha, 0x7047,
1231 "exiting.\n", __func__, vha->host_no)); 1248 "port_param header not provided.\n");
1232 return -EINVAL; 1249 return -EINVAL;
1233 } 1250 }
1234 1251
1235 if (port_param->fc_scsi_addr.dest_type != EXT_DEF_TYPE_WWPN) { 1252 if (port_param->fc_scsi_addr.dest_type != EXT_DEF_TYPE_WWPN) {
1236 DEBUG2(printk(KERN_ERR "%s(%ld): Invalid destination type\n", 1253 ql_log(ql_log_warn, vha, 0x7048,
1237 __func__, vha->host_no)); 1254 "Invalid destination type.\n");
1238 return -EINVAL; 1255 return -EINVAL;
1239 } 1256 }
1240 1257
@@ -1249,21 +1266,20 @@ qla24xx_iidma(struct fc_bsg_job *bsg_job)
1249 } 1266 }
1250 1267
1251 if (!fcport) { 1268 if (!fcport) {
1252 DEBUG2(printk(KERN_ERR "%s(%ld): Failed to find port\n", 1269 ql_log(ql_log_warn, vha, 0x7049,
1253 __func__, vha->host_no)); 1270 "Failed to find port.\n");
1254 return -EINVAL; 1271 return -EINVAL;
1255 } 1272 }
1256 1273
1257 if (atomic_read(&fcport->state) != FCS_ONLINE) { 1274 if (atomic_read(&fcport->state) != FCS_ONLINE) {
1258 DEBUG2(printk(KERN_ERR "%s(%ld): Port not online\n", 1275 ql_log(ql_log_warn, vha, 0x704a,
1259 __func__, vha->host_no)); 1276 "Port is not online.\n");
1260 return -EINVAL; 1277 return -EINVAL;
1261 } 1278 }
1262 1279
1263 if (fcport->flags & FCF_LOGIN_NEEDED) { 1280 if (fcport->flags & FCF_LOGIN_NEEDED) {
1264 DEBUG2(printk(KERN_ERR "%s(%ld): Remote port not logged in, " 1281 ql_log(ql_log_warn, vha, 0x704b,
1265 "flags = 0x%x\n", 1282 "Remote port not logged in flags = 0x%x.\n", fcport->flags);
1266 __func__, vha->host_no, fcport->flags));
1267 return -EINVAL; 1283 return -EINVAL;
1268 } 1284 }
1269 1285
@@ -1275,15 +1291,13 @@ qla24xx_iidma(struct fc_bsg_job *bsg_job)
1275 &port_param->speed, mb); 1291 &port_param->speed, mb);
1276 1292
1277 if (rval) { 1293 if (rval) {
1278 DEBUG16(printk(KERN_ERR "scsi(%ld): iIDMA cmd failed for " 1294 ql_log(ql_log_warn, vha, 0x704c,
1279 "%02x%02x%02x%02x%02x%02x%02x%02x -- " 1295 "iIDMA cmd failed for %02x%02x%02x%02x%02x%02x%02x%02x -- "
1280 "%04x %x %04x %04x.\n", 1296 "%04x %x %04x %04x.\n", fcport->port_name[0],
1281 vha->host_no, fcport->port_name[0], 1297 fcport->port_name[1], fcport->port_name[2],
1282 fcport->port_name[1], 1298 fcport->port_name[3], fcport->port_name[4],
1283 fcport->port_name[2], fcport->port_name[3], 1299 fcport->port_name[5], fcport->port_name[6],
1284 fcport->port_name[4], fcport->port_name[5], 1300 fcport->port_name[7], rval, fcport->fp_speed, mb[0], mb[1]);
1285 fcport->port_name[6], fcport->port_name[7], rval,
1286 fcport->fp_speed, mb[0], mb[1]));
1287 rval = 0; 1301 rval = 0;
1288 bsg_job->reply->result = (DID_ERROR << 16); 1302 bsg_job->reply->result = (DID_ERROR << 16);
1289 1303
@@ -1307,11 +1321,12 @@ qla24xx_iidma(struct fc_bsg_job *bsg_job)
1307} 1321}
1308 1322
1309static int 1323static int
1310qla2x00_optrom_setup(struct fc_bsg_job *bsg_job, struct qla_hw_data *ha, 1324qla2x00_optrom_setup(struct fc_bsg_job *bsg_job, scsi_qla_host_t *vha,
1311 uint8_t is_update) 1325 uint8_t is_update)
1312{ 1326{
1313 uint32_t start = 0; 1327 uint32_t start = 0;
1314 int valid = 0; 1328 int valid = 0;
1329 struct qla_hw_data *ha = vha->hw;
1315 1330
1316 bsg_job->reply->reply_payload_rcv_len = 0; 1331 bsg_job->reply->reply_payload_rcv_len = 0;
1317 1332
@@ -1319,14 +1334,20 @@ qla2x00_optrom_setup(struct fc_bsg_job *bsg_job, struct qla_hw_data *ha,
1319 return -EINVAL; 1334 return -EINVAL;
1320 1335
1321 start = bsg_job->request->rqst_data.h_vendor.vendor_cmd[1]; 1336 start = bsg_job->request->rqst_data.h_vendor.vendor_cmd[1];
1322 if (start > ha->optrom_size) 1337 if (start > ha->optrom_size) {
1338 ql_log(ql_log_warn, vha, 0x7055,
1339 "start %d > optrom_size %d.\n", start, ha->optrom_size);
1323 return -EINVAL; 1340 return -EINVAL;
1341 }
1324 1342
1325 if (ha->optrom_state != QLA_SWAITING) 1343 if (ha->optrom_state != QLA_SWAITING) {
1344 ql_log(ql_log_info, vha, 0x7056,
1345 "optrom_state %d.\n", ha->optrom_state);
1326 return -EBUSY; 1346 return -EBUSY;
1347 }
1327 1348
1328 ha->optrom_region_start = start; 1349 ha->optrom_region_start = start;
1329 1350 ql_dbg(ql_dbg_user, vha, 0x7057, "is_update=%d.\n", is_update);
1330 if (is_update) { 1351 if (is_update) {
1331 if (ha->optrom_size == OPTROM_SIZE_2300 && start == 0) 1352 if (ha->optrom_size == OPTROM_SIZE_2300 && start == 0)
1332 valid = 1; 1353 valid = 1;
@@ -1337,9 +1358,9 @@ qla2x00_optrom_setup(struct fc_bsg_job *bsg_job, struct qla_hw_data *ha,
1337 IS_QLA8XXX_TYPE(ha)) 1358 IS_QLA8XXX_TYPE(ha))
1338 valid = 1; 1359 valid = 1;
1339 if (!valid) { 1360 if (!valid) {
1340 qla_printk(KERN_WARNING, ha, 1361 ql_log(ql_log_warn, vha, 0x7058,
1341 "Invalid start region 0x%x/0x%x.\n", 1362 "Invalid start region 0x%x/0x%x.\n", start,
1342 start, bsg_job->request_payload.payload_len); 1363 bsg_job->request_payload.payload_len);
1343 return -EINVAL; 1364 return -EINVAL;
1344 } 1365 }
1345 1366
@@ -1358,9 +1379,9 @@ qla2x00_optrom_setup(struct fc_bsg_job *bsg_job, struct qla_hw_data *ha,
1358 1379
1359 ha->optrom_buffer = vmalloc(ha->optrom_region_size); 1380 ha->optrom_buffer = vmalloc(ha->optrom_region_size);
1360 if (!ha->optrom_buffer) { 1381 if (!ha->optrom_buffer) {
1361 qla_printk(KERN_WARNING, ha, 1382 ql_log(ql_log_warn, vha, 0x7059,
1362 "Read: Unable to allocate memory for optrom retrieval " 1383 "Read: Unable to allocate memory for optrom retrieval "
1363 "(%x).\n", ha->optrom_region_size); 1384 "(%x)\n", ha->optrom_region_size);
1364 1385
1365 ha->optrom_state = QLA_SWAITING; 1386 ha->optrom_state = QLA_SWAITING;
1366 return -ENOMEM; 1387 return -ENOMEM;
@@ -1378,7 +1399,7 @@ qla2x00_read_optrom(struct fc_bsg_job *bsg_job)
1378 struct qla_hw_data *ha = vha->hw; 1399 struct qla_hw_data *ha = vha->hw;
1379 int rval = 0; 1400 int rval = 0;
1380 1401
1381 rval = qla2x00_optrom_setup(bsg_job, ha, 0); 1402 rval = qla2x00_optrom_setup(bsg_job, vha, 0);
1382 if (rval) 1403 if (rval)
1383 return rval; 1404 return rval;
1384 1405
@@ -1406,7 +1427,7 @@ qla2x00_update_optrom(struct fc_bsg_job *bsg_job)
1406 struct qla_hw_data *ha = vha->hw; 1427 struct qla_hw_data *ha = vha->hw;
1407 int rval = 0; 1428 int rval = 0;
1408 1429
1409 rval = qla2x00_optrom_setup(bsg_job, ha, 1); 1430 rval = qla2x00_optrom_setup(bsg_job, vha, 1);
1410 if (rval) 1431 if (rval)
1411 return rval; 1432 return rval;
1412 1433
@@ -1464,6 +1485,23 @@ int
1464qla24xx_bsg_request(struct fc_bsg_job *bsg_job) 1485qla24xx_bsg_request(struct fc_bsg_job *bsg_job)
1465{ 1486{
1466 int ret = -EINVAL; 1487 int ret = -EINVAL;
1488 struct fc_rport *rport;
1489 fc_port_t *fcport = NULL;
1490 struct Scsi_Host *host;
1491 scsi_qla_host_t *vha;
1492
1493 if (bsg_job->request->msgcode == FC_BSG_RPT_ELS) {
1494 rport = bsg_job->rport;
1495 fcport = *(fc_port_t **) rport->dd_data;
1496 host = rport_to_shost(rport);
1497 vha = shost_priv(host);
1498 } else {
1499 host = bsg_job->shost;
1500 vha = shost_priv(host);
1501 }
1502
1503 ql_dbg(ql_dbg_user, vha, 0x7000,
1504 "Entered %s msgcode=%d.\n", __func__, bsg_job->request->msgcode);
1467 1505
1468 switch (bsg_job->request->msgcode) { 1506 switch (bsg_job->request->msgcode) {
1469 case FC_BSG_RPT_ELS: 1507 case FC_BSG_RPT_ELS:
@@ -1480,7 +1518,7 @@ qla24xx_bsg_request(struct fc_bsg_job *bsg_job)
1480 case FC_BSG_HST_DEL_RPORT: 1518 case FC_BSG_HST_DEL_RPORT:
1481 case FC_BSG_RPT_CT: 1519 case FC_BSG_RPT_CT:
1482 default: 1520 default:
1483 DEBUG2(printk("qla2xxx: unsupported BSG request\n")); 1521 ql_log(ql_log_warn, vha, 0x705a, "Unsupported BSG request.\n");
1484 break; 1522 break;
1485 } 1523 }
1486 return ret; 1524 return ret;
@@ -1514,17 +1552,15 @@ qla24xx_bsg_timeout(struct fc_bsg_job *bsg_job)
1514 && (sp_bsg->u.bsg_job == bsg_job)) { 1552 && (sp_bsg->u.bsg_job == bsg_job)) {
1515 spin_unlock_irqrestore(&ha->hardware_lock, flags); 1553 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1516 if (ha->isp_ops->abort_command(sp)) { 1554 if (ha->isp_ops->abort_command(sp)) {
1517 DEBUG2(qla_printk(KERN_INFO, ha, 1555 ql_log(ql_log_warn, vha, 0x7089,
1518 "scsi(%ld): mbx " 1556 "mbx abort_command "
1519 "abort_command failed\n", 1557 "failed.\n");
1520 vha->host_no));
1521 bsg_job->req->errors = 1558 bsg_job->req->errors =
1522 bsg_job->reply->result = -EIO; 1559 bsg_job->reply->result = -EIO;
1523 } else { 1560 } else {
1524 DEBUG2(qla_printk(KERN_INFO, ha, 1561 ql_dbg(ql_dbg_user, vha, 0x708a,
1525 "scsi(%ld): mbx " 1562 "mbx abort_command "
1526 "abort_command success\n", 1563 "success.\n");
1527 vha->host_no));
1528 bsg_job->req->errors = 1564 bsg_job->req->errors =
1529 bsg_job->reply->result = 0; 1565 bsg_job->reply->result = 0;
1530 } 1566 }
@@ -1535,8 +1571,7 @@ qla24xx_bsg_timeout(struct fc_bsg_job *bsg_job)
1535 } 1571 }
1536 } 1572 }
1537 spin_unlock_irqrestore(&ha->hardware_lock, flags); 1573 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1538 DEBUG2(qla_printk(KERN_INFO, ha, 1574 ql_log(ql_log_info, vha, 0x708b, "SRB not found to abort.\n");
1539 "scsi(%ld) SRB not found to abort\n", vha->host_no));
1540 bsg_job->req->errors = bsg_job->reply->result = -ENXIO; 1575 bsg_job->req->errors = bsg_job->reply->result = -ENXIO;
1541 return 0; 1576 return 0;
1542 1577