aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorJoe Carnuccio <joe.carnuccio@qlogic.com>2011-05-10 14:30:15 -0400
committerJames Bottomley <jbottomley@parallels.com>2011-05-17 03:36:23 -0400
commit6766df9e8ae2ab29459381ade1ca91b28688ab13 (patch)
tree2065424e4518d33bf08feed3aa0876dbae2cf91d /drivers/scsi
parent773120e4df1d2bf543345ad850cc92dc1f1bad8a (diff)
[SCSI] qla2xxx: Unify the read/write sfp mailbox command routines.
Make the read/write sfp mailbox command routines uniform, and remove redundancy. Also protect against attempting to do a single byte dma in these routines. Signed-off-by: Joe Carnuccio <joe.carnuccio@qlogic.com> Signed-off-by: Madhuranath Iyengar <Madhu.Iyengar@qlogic.com> Signed-off-by: James Bottomley <jbottomley@parallels.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c12
-rw-r--r--drivers/scsi/qla2xxx/qla_gbl.h11
-rw-r--r--drivers/scsi/qla2xxx/qla_mbx.c72
3 files changed, 33 insertions, 62 deletions
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 4e51124899fd..532313e0725e 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -496,8 +496,8 @@ do_read:
496 offset = 0; 496 offset = 0;
497 } 497 }
498 498
499 rval = qla2x00_read_sfp(vha, ha->sfp_data_dma, addr, offset, 499 rval = qla2x00_read_sfp(vha, ha->sfp_data_dma, ha->sfp_data,
500 SFP_BLOCK_SIZE); 500 addr, offset, SFP_BLOCK_SIZE, 0);
501 if (rval != QLA_SUCCESS) { 501 if (rval != QLA_SUCCESS) {
502 qla_printk(KERN_WARNING, ha, 502 qla_printk(KERN_WARNING, ha,
503 "Unable to read SFP data (%x/%x/%x).\n", rval, 503 "Unable to read SFP data (%x/%x/%x).\n", rval,
@@ -628,8 +628,8 @@ qla2x00_sysfs_write_edc(struct file *filp, struct kobject *kobj,
628 628
629 memcpy(ha->edc_data, &buf[8], len); 629 memcpy(ha->edc_data, &buf[8], len);
630 630
631 rval = qla2x00_write_edc(vha, dev, adr, ha->edc_data_dma, 631 rval = qla2x00_write_sfp(vha, ha->edc_data_dma, ha->edc_data,
632 ha->edc_data, len, opt); 632 dev, adr, len, opt);
633 if (rval != QLA_SUCCESS) { 633 if (rval != QLA_SUCCESS) {
634 DEBUG2(qla_printk(KERN_INFO, ha, 634 DEBUG2(qla_printk(KERN_INFO, ha,
635 "Unable to write EDC (%x) %02x:%02x:%04x:%02x:%02x.\n", 635 "Unable to write EDC (%x) %02x:%02x:%04x:%02x:%02x.\n",
@@ -685,8 +685,8 @@ qla2x00_sysfs_write_edc_status(struct file *filp, struct kobject *kobj,
685 return -EINVAL; 685 return -EINVAL;
686 686
687 memset(ha->edc_data, 0, len); 687 memset(ha->edc_data, 0, len);
688 rval = qla2x00_read_edc(vha, dev, adr, ha->edc_data_dma, 688 rval = qla2x00_read_sfp(vha, ha->edc_data_dma, ha->edc_data,
689 ha->edc_data, len, opt); 689 dev, adr, len, opt);
690 if (rval != QLA_SUCCESS) { 690 if (rval != QLA_SUCCESS) {
691 DEBUG2(qla_printk(KERN_INFO, ha, 691 DEBUG2(qla_printk(KERN_INFO, ha,
692 "Unable to write EDC status (%x) %02x:%02x:%04x:%02x.\n", 692 "Unable to write EDC status (%x) %02x:%02x:%04x:%02x.\n",
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index 79a12aa978a4..0b381224ae4b 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -323,15 +323,12 @@ extern int
323qla2x00_disable_fce_trace(scsi_qla_host_t *, uint64_t *, uint64_t *); 323qla2x00_disable_fce_trace(scsi_qla_host_t *, uint64_t *, uint64_t *);
324 324
325extern int 325extern int
326qla2x00_read_sfp(scsi_qla_host_t *, dma_addr_t, uint16_t, uint16_t, uint16_t); 326qla2x00_read_sfp(scsi_qla_host_t *, dma_addr_t, uint8_t *,
327 uint16_t, uint16_t, uint16_t, uint16_t);
327 328
328extern int 329extern int
329qla2x00_read_edc(scsi_qla_host_t *, uint16_t, uint16_t, dma_addr_t, 330qla2x00_write_sfp(scsi_qla_host_t *, dma_addr_t, uint8_t *,
330 uint8_t *, uint16_t, uint16_t); 331 uint16_t, uint16_t, uint16_t, uint16_t);
331
332extern int
333qla2x00_write_edc(scsi_qla_host_t *, uint16_t, uint16_t, dma_addr_t,
334 uint8_t *, uint16_t, uint16_t);
335 332
336extern int 333extern int
337qla2x00_set_idma_speed(scsi_qla_host_t *, uint16_t, uint16_t, uint16_t *); 334qla2x00_set_idma_speed(scsi_qla_host_t *, uint16_t, uint16_t, uint16_t *);
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index aab628bf8d36..7184b870c0d9 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -2787,44 +2787,6 @@ qla2x00_disable_fce_trace(scsi_qla_host_t *vha, uint64_t *wr, uint64_t *rd)
2787} 2787}
2788 2788
2789int 2789int
2790qla2x00_read_sfp(scsi_qla_host_t *vha, dma_addr_t sfp_dma, uint16_t addr,
2791 uint16_t off, uint16_t count)
2792{
2793 int rval;
2794 mbx_cmd_t mc;
2795 mbx_cmd_t *mcp = &mc;
2796
2797 if (!IS_FWI2_CAPABLE(vha->hw))
2798 return QLA_FUNCTION_FAILED;
2799
2800 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2801
2802 mcp->mb[0] = MBC_READ_SFP;
2803 mcp->mb[1] = addr;
2804 mcp->mb[2] = MSW(sfp_dma);
2805 mcp->mb[3] = LSW(sfp_dma);
2806 mcp->mb[6] = MSW(MSD(sfp_dma));
2807 mcp->mb[7] = LSW(MSD(sfp_dma));
2808 mcp->mb[8] = count;
2809 mcp->mb[9] = off;
2810 mcp->mb[10] = 0;
2811 mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
2812 mcp->in_mb = MBX_0;
2813 mcp->tov = MBX_TOV_SECONDS;
2814 mcp->flags = 0;
2815 rval = qla2x00_mailbox_command(vha, mcp);
2816
2817 if (rval != QLA_SUCCESS) {
2818 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__,
2819 vha->host_no, rval, mcp->mb[0]));
2820 } else {
2821 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2822 }
2823
2824 return rval;
2825}
2826
2827int
2828qla2x00_get_idma_speed(scsi_qla_host_t *vha, uint16_t loop_id, 2790qla2x00_get_idma_speed(scsi_qla_host_t *vha, uint16_t loop_id,
2829 uint16_t *port_speed, uint16_t *mb) 2791 uint16_t *port_speed, uint16_t *mb)
2830{ 2792{
@@ -3589,15 +3551,22 @@ qla81xx_restart_mpi_firmware(scsi_qla_host_t *vha)
3589} 3551}
3590 3552
3591int 3553int
3592qla2x00_read_edc(scsi_qla_host_t *vha, uint16_t dev, uint16_t adr, 3554qla2x00_read_sfp(scsi_qla_host_t *vha, dma_addr_t sfp_dma, uint8_t *sfp,
3593 dma_addr_t sfp_dma, uint8_t *sfp, uint16_t len, uint16_t opt) 3555 uint16_t dev, uint16_t off, uint16_t len, uint16_t opt)
3594{ 3556{
3595 int rval; 3557 int rval;
3596 mbx_cmd_t mc; 3558 mbx_cmd_t mc;
3597 mbx_cmd_t *mcp = &mc; 3559 mbx_cmd_t *mcp = &mc;
3560 struct qla_hw_data *ha = vha->hw;
3561
3562 if (!IS_FWI2_CAPABLE(ha))
3563 return QLA_FUNCTION_FAILED;
3598 3564
3599 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 3565 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
3600 3566
3567 if (len == 1)
3568 opt |= BIT_0;
3569
3601 mcp->mb[0] = MBC_READ_SFP; 3570 mcp->mb[0] = MBC_READ_SFP;
3602 mcp->mb[1] = dev; 3571 mcp->mb[1] = dev;
3603 mcp->mb[2] = MSW(sfp_dma); 3572 mcp->mb[2] = MSW(sfp_dma);
@@ -3605,7 +3574,7 @@ qla2x00_read_edc(scsi_qla_host_t *vha, uint16_t dev, uint16_t adr,
3605 mcp->mb[6] = MSW(MSD(sfp_dma)); 3574 mcp->mb[6] = MSW(MSD(sfp_dma));
3606 mcp->mb[7] = LSW(MSD(sfp_dma)); 3575 mcp->mb[7] = LSW(MSD(sfp_dma));
3607 mcp->mb[8] = len; 3576 mcp->mb[8] = len;
3608 mcp->mb[9] = adr; 3577 mcp->mb[9] = off;
3609 mcp->mb[10] = opt; 3578 mcp->mb[10] = opt;
3610 mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; 3579 mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
3611 mcp->in_mb = MBX_1|MBX_0; 3580 mcp->in_mb = MBX_1|MBX_0;
@@ -3614,8 +3583,7 @@ qla2x00_read_edc(scsi_qla_host_t *vha, uint16_t dev, uint16_t adr,
3614 rval = qla2x00_mailbox_command(vha, mcp); 3583 rval = qla2x00_mailbox_command(vha, mcp);
3615 3584
3616 if (opt & BIT_0) 3585 if (opt & BIT_0)
3617 if (sfp) 3586 *sfp = mcp->mb[1];
3618 *sfp = mcp->mb[1];
3619 3587
3620 if (rval != QLA_SUCCESS) { 3588 if (rval != QLA_SUCCESS) {
3621 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__, 3589 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__,
@@ -3628,18 +3596,24 @@ qla2x00_read_edc(scsi_qla_host_t *vha, uint16_t dev, uint16_t adr,
3628} 3596}
3629 3597
3630int 3598int
3631qla2x00_write_edc(scsi_qla_host_t *vha, uint16_t dev, uint16_t adr, 3599qla2x00_write_sfp(scsi_qla_host_t *vha, dma_addr_t sfp_dma, uint8_t *sfp,
3632 dma_addr_t sfp_dma, uint8_t *sfp, uint16_t len, uint16_t opt) 3600 uint16_t dev, uint16_t off, uint16_t len, uint16_t opt)
3633{ 3601{
3634 int rval; 3602 int rval;
3635 mbx_cmd_t mc; 3603 mbx_cmd_t mc;
3636 mbx_cmd_t *mcp = &mc; 3604 mbx_cmd_t *mcp = &mc;
3605 struct qla_hw_data *ha = vha->hw;
3606
3607 if (!IS_FWI2_CAPABLE(ha))
3608 return QLA_FUNCTION_FAILED;
3637 3609
3638 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 3610 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
3639 3611
3612 if (len == 1)
3613 opt |= BIT_0;
3614
3640 if (opt & BIT_0) 3615 if (opt & BIT_0)
3641 if (sfp) 3616 len = *sfp;
3642 len = *sfp;
3643 3617
3644 mcp->mb[0] = MBC_WRITE_SFP; 3618 mcp->mb[0] = MBC_WRITE_SFP;
3645 mcp->mb[1] = dev; 3619 mcp->mb[1] = dev;
@@ -3648,10 +3622,10 @@ qla2x00_write_edc(scsi_qla_host_t *vha, uint16_t dev, uint16_t adr,
3648 mcp->mb[6] = MSW(MSD(sfp_dma)); 3622 mcp->mb[6] = MSW(MSD(sfp_dma));
3649 mcp->mb[7] = LSW(MSD(sfp_dma)); 3623 mcp->mb[7] = LSW(MSD(sfp_dma));
3650 mcp->mb[8] = len; 3624 mcp->mb[8] = len;
3651 mcp->mb[9] = adr; 3625 mcp->mb[9] = off;
3652 mcp->mb[10] = opt; 3626 mcp->mb[10] = opt;
3653 mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; 3627 mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
3654 mcp->in_mb = MBX_0; 3628 mcp->in_mb = MBX_1|MBX_0;
3655 mcp->tov = MBX_TOV_SECONDS; 3629 mcp->tov = MBX_TOV_SECONDS;
3656 mcp->flags = 0; 3630 mcp->flags = 0;
3657 rval = qla2x00_mailbox_command(vha, mcp); 3631 rval = qla2x00_mailbox_command(vha, mcp);