aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/qla2xxx/qla_mbx.c
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/qla2xxx/qla_mbx.c
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/qla2xxx/qla_mbx.c')
-rw-r--r--drivers/scsi/qla2xxx/qla_mbx.c72
1 files changed, 23 insertions, 49 deletions
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);