[SCSI] bfa: Check supported speed based on port mode
authorKrishna Gudipati <kgudipat@brocade.com>
Thu, 21 Jul 2011 00:01:07 +0000 (17:01 -0700)
committerJames Bottomley <JBottomley@Parallels.com>
Wed, 27 Jul 2011 10:45:44 +0000 (14:45 +0400)
Added logic to check the loopback test input speed based on port mode.

Signed-off-by: Krishna Gudipati <kgudipat@brocade.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
drivers/scsi/bfa/bfa_svc.c

index 136f5f922cd3ecc7e2bb1fd808a46473e78e728a..6e1ed9a9aa2a618f0f1bca8627ffa88ae65a9917 100644 (file)
@@ -5553,11 +5553,29 @@ bfa_fcdiag_loopback(struct bfa_s *bfa, enum bfa_port_opmode opmode,
                return BFA_STATUS_PORT_NOT_DISABLED;
        }
 
-       /* Check if the speed is supported */
-       bfa_fcport_get_attr(bfa, &attr);
-       bfa_trc(fcdiag, attr.speed_supported);
-       if (speed > attr.speed_supported)
-               return BFA_STATUS_UNSUPP_SPEED;
+       /*
+        * Check if input speed is supported by the port mode
+        */
+       if (bfa_ioc_get_type(&bfa->ioc) == BFA_IOC_TYPE_FC) {
+               if (!(speed == BFA_PORT_SPEED_1GBPS ||
+                     speed == BFA_PORT_SPEED_2GBPS ||
+                     speed == BFA_PORT_SPEED_4GBPS ||
+                     speed == BFA_PORT_SPEED_8GBPS ||
+                     speed == BFA_PORT_SPEED_16GBPS ||
+                     speed == BFA_PORT_SPEED_AUTO)) {
+                       bfa_trc(fcdiag, speed);
+                       return BFA_STATUS_UNSUPP_SPEED;
+               }
+               bfa_fcport_get_attr(bfa, &attr);
+               bfa_trc(fcdiag, attr.speed_supported);
+               if (speed > attr.speed_supported)
+                       return BFA_STATUS_UNSUPP_SPEED;
+       } else {
+               if (speed != BFA_PORT_SPEED_10GBPS) {
+                       bfa_trc(fcdiag, speed);
+                       return BFA_STATUS_UNSUPP_SPEED;
+               }
+       }
 
        /* For Mezz card, port speed entered needs to be checked */
        if (bfa_mfg_is_mezz(bfa->ioc.attr->card_type)) {