scsi: qla2xxx: Reduce duplicate code in reporting speed
authorQuinn Tran <qutran@marvell.com>
Fri, 4 Sep 2020 04:51:20 +0000 (21:51 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 22 Sep 2020 22:42:41 +0000 (18:42 -0400)
Indicate correct speed for 16G Mezz card.

Link: https://lore.kernel.org/r/20200904045128.23631-6-njavali@marvell.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Quinn Tran <qutran@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/qla2xxx/qla_attr.c
drivers/scsi/qla2xxx/qla_gbl.h
drivers/scsi/qla2xxx/qla_gs.c
drivers/scsi/qla2xxx/qla_os.c

index 5d93ccc73153514157272ee31d580eb89a7a9d9c..d006ae1936775fc47f9cdd61cefef58fdf9b9c8c 100644 (file)
@@ -3214,46 +3214,7 @@ qla2x00_init_host_attr(scsi_qla_host_t *vha)
        fc_host_max_npiv_vports(vha->host) = ha->max_npiv_vports;
        fc_host_npiv_vports_inuse(vha->host) = ha->cur_vport_count;
 
-       if (IS_CNA_CAPABLE(ha))
-               speeds = FC_PORTSPEED_10GBIT;
-       else if (IS_QLA28XX(ha) || IS_QLA27XX(ha)) {
-               if (ha->max_supported_speed == 2) {
-                       if (ha->min_supported_speed <= 6)
-                               speeds |= FC_PORTSPEED_64GBIT;
-               }
-               if (ha->max_supported_speed == 2 ||
-                   ha->max_supported_speed == 1) {
-                       if (ha->min_supported_speed <= 5)
-                               speeds |= FC_PORTSPEED_32GBIT;
-               }
-               if (ha->max_supported_speed == 2 ||
-                   ha->max_supported_speed == 1 ||
-                   ha->max_supported_speed == 0) {
-                       if (ha->min_supported_speed <= 4)
-                               speeds |= FC_PORTSPEED_16GBIT;
-               }
-               if (ha->max_supported_speed == 1 ||
-                   ha->max_supported_speed == 0) {
-                       if (ha->min_supported_speed <= 3)
-                               speeds |= FC_PORTSPEED_8GBIT;
-               }
-               if (ha->max_supported_speed == 0) {
-                       if (ha->min_supported_speed <= 2)
-                               speeds |= FC_PORTSPEED_4GBIT;
-               }
-       } else if (IS_QLA2031(ha))
-               speeds = FC_PORTSPEED_16GBIT|FC_PORTSPEED_8GBIT|
-                       FC_PORTSPEED_4GBIT;
-       else if (IS_QLA25XX(ha) || IS_QLAFX00(ha))
-               speeds = FC_PORTSPEED_8GBIT|FC_PORTSPEED_4GBIT|
-                       FC_PORTSPEED_2GBIT|FC_PORTSPEED_1GBIT;
-       else if (IS_QLA24XX_TYPE(ha))
-               speeds = FC_PORTSPEED_4GBIT|FC_PORTSPEED_2GBIT|
-                       FC_PORTSPEED_1GBIT;
-       else if (IS_QLA23XX(ha))
-               speeds = FC_PORTSPEED_2GBIT|FC_PORTSPEED_1GBIT;
-       else
-               speeds = FC_PORTSPEED_1GBIT;
+       speeds = qla25xx_fdmi_port_speed_capability(ha);
 
        fc_host_supported_speeds(vha->host) = speeds;
 }
index 36c210c24f72c3482557b81d9b8fe3f2316254bd..3360857c440546cb6cbb14f82d0b8c277ce0c7af 100644 (file)
@@ -704,6 +704,8 @@ int qla24xx_async_gfpnid(scsi_qla_host_t *, fc_port_t *);
 void qla24xx_handle_gfpnid_event(scsi_qla_host_t *, struct event_arg *);
 void qla24xx_sp_unmap(scsi_qla_host_t *, srb_t *);
 void qla_scan_work_fn(struct work_struct *);
+uint qla25xx_fdmi_port_speed_capability(struct qla_hw_data *);
+uint qla25xx_fdmi_port_speed_currently(struct qla_hw_data *);
 
 /*
  * Global Function Prototypes in qla_attr.c source file.
index de9fd7f688d014dca79eba9fde812ae63e14c91e..700d4247a79126d3bb1ead992b831d33840e1a4c 100644 (file)
@@ -1502,7 +1502,7 @@ qla2x00_prep_ct_fdmi_req(struct ct_sns_pkt *p, uint16_t cmd,
        return &p->p.req;
 }
 
-static uint
+uint
 qla25xx_fdmi_port_speed_capability(struct qla_hw_data *ha)
 {
        uint speeds = 0;
@@ -1546,7 +1546,7 @@ qla25xx_fdmi_port_speed_capability(struct qla_hw_data *ha)
                }
                return speeds;
        }
-       if (IS_QLA25XX(ha))
+       if (IS_QLA25XX(ha) || IS_QLAFX00(ha))
                return FDMI_PORT_SPEED_8GB|FDMI_PORT_SPEED_4GB|
                        FDMI_PORT_SPEED_2GB|FDMI_PORT_SPEED_1GB;
        if (IS_QLA24XX_TYPE(ha))
@@ -1556,7 +1556,8 @@ qla25xx_fdmi_port_speed_capability(struct qla_hw_data *ha)
                return FDMI_PORT_SPEED_2GB|FDMI_PORT_SPEED_1GB;
        return FDMI_PORT_SPEED_1GB;
 }
-static uint
+
+uint
 qla25xx_fdmi_port_speed_currently(struct qla_hw_data *ha)
 {
        switch (ha->link_data_rate) {
index f9e40a6d718979a94ddde53f886568b00cffe32c..74e6a04850c0e0c48477763b5115778979ac6a1a 100644 (file)
@@ -5810,98 +5810,6 @@ qla25xx_rdp_rsp_reduce_size(struct scsi_qla_host *vha,
        return true;
 }
 
-static uint
-qla25xx_rdp_port_speed_capability(struct qla_hw_data *ha)
-{
-       if (IS_CNA_CAPABLE(ha))
-               return RDP_PORT_SPEED_10GB;
-
-       if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
-               unsigned int speeds = 0;
-
-               if (ha->max_supported_speed == 2) {
-                       if (ha->min_supported_speed <= 6)
-                               speeds |= RDP_PORT_SPEED_64GB;
-               }
-
-               if (ha->max_supported_speed == 2 ||
-                   ha->max_supported_speed == 1) {
-                       if (ha->min_supported_speed <= 5)
-                               speeds |= RDP_PORT_SPEED_32GB;
-               }
-
-               if (ha->max_supported_speed == 2 ||
-                   ha->max_supported_speed == 1 ||
-                   ha->max_supported_speed == 0) {
-                       if (ha->min_supported_speed <= 4)
-                               speeds |= RDP_PORT_SPEED_16GB;
-               }
-
-               if (ha->max_supported_speed == 1 ||
-                   ha->max_supported_speed == 0) {
-                       if (ha->min_supported_speed <= 3)
-                               speeds |= RDP_PORT_SPEED_8GB;
-               }
-
-               if (ha->max_supported_speed == 0) {
-                       if (ha->min_supported_speed <= 2)
-                               speeds |= RDP_PORT_SPEED_4GB;
-               }
-
-               return speeds;
-       }
-
-       if (IS_QLA2031(ha))
-               return RDP_PORT_SPEED_16GB|RDP_PORT_SPEED_8GB|
-                      RDP_PORT_SPEED_4GB;
-
-       if (IS_QLA25XX(ha))
-               return RDP_PORT_SPEED_8GB|RDP_PORT_SPEED_4GB|
-                      RDP_PORT_SPEED_2GB|RDP_PORT_SPEED_1GB;
-
-       if (IS_QLA24XX_TYPE(ha))
-               return RDP_PORT_SPEED_4GB|RDP_PORT_SPEED_2GB|
-                      RDP_PORT_SPEED_1GB;
-
-       if (IS_QLA23XX(ha))
-               return RDP_PORT_SPEED_2GB|RDP_PORT_SPEED_1GB;
-
-       return RDP_PORT_SPEED_1GB;
-}
-
-static uint
-qla25xx_rdp_port_speed_currently(struct qla_hw_data *ha)
-{
-       switch (ha->link_data_rate) {
-       case PORT_SPEED_1GB:
-               return RDP_PORT_SPEED_1GB;
-
-       case PORT_SPEED_2GB:
-               return RDP_PORT_SPEED_2GB;
-
-       case PORT_SPEED_4GB:
-               return RDP_PORT_SPEED_4GB;
-
-       case PORT_SPEED_8GB:
-               return RDP_PORT_SPEED_8GB;
-
-       case PORT_SPEED_10GB:
-               return RDP_PORT_SPEED_10GB;
-
-       case PORT_SPEED_16GB:
-               return RDP_PORT_SPEED_16GB;
-
-       case PORT_SPEED_32GB:
-               return RDP_PORT_SPEED_32GB;
-
-       case PORT_SPEED_64GB:
-               return RDP_PORT_SPEED_64GB;
-
-       default:
-               return RDP_PORT_SPEED_UNKNOWN;
-       }
-}
-
 /*
  * Function Name: qla24xx_process_purex_iocb
  *
@@ -6068,9 +5976,9 @@ void qla24xx_process_purex_rdp(struct scsi_qla_host *vha,
        rsp_payload->port_speed_desc.desc_len =
            cpu_to_be32(RDP_DESC_LEN(rsp_payload->port_speed_desc));
        rsp_payload->port_speed_desc.speed_capab = cpu_to_be16(
-           qla25xx_rdp_port_speed_capability(ha));
+           qla25xx_fdmi_port_speed_capability(ha));
        rsp_payload->port_speed_desc.operating_speed = cpu_to_be16(
-           qla25xx_rdp_port_speed_currently(ha));
+           qla25xx_fdmi_port_speed_currently(ha));
 
        /* Link Error Status Descriptor */
        rsp_payload->ls_err_desc.desc_tag = cpu_to_be32(0x10002);