Re: [PATCH v3 06/13] lpfc: Add 64G link speed support

2018-02-14 Thread Johannes Thumshirn
Looks good,
Reviewed-by: Johannes Thumshirn 
-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850


[PATCH v3 06/13] lpfc: Add 64G link speed support

2018-02-13 Thread James Smart
The G7 adapter supports 64G link speeds. Add support to the driver.

In addition, a small cleanup to replace the odd bitmap logic with
a switch case.

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 

---
v2:
  address review comment of typo in define name. Define wasn't used
  anywhere yet.
v3:
  reformat printf_log 0469
---
 drivers/scsi/lpfc/lpfc.h | 14 +++--
 drivers/scsi/lpfc/lpfc_attr.c| 62 
 drivers/scsi/lpfc/lpfc_ct.c  |  5 
 drivers/scsi/lpfc/lpfc_els.c |  5 
 drivers/scsi/lpfc/lpfc_hbadisc.c |  1 +
 drivers/scsi/lpfc/lpfc_hw.h  | 12 
 drivers/scsi/lpfc/lpfc_hw4.h |  3 ++
 drivers/scsi/lpfc/lpfc_init.c| 17 +--
 drivers/scsi/lpfc/lpfc_mbox.c|  4 +++
 9 files changed, 93 insertions(+), 30 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index 86ffb9756e65..7aad4a717f13 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -544,16 +544,10 @@ struct unsol_rcv_ct_ctx {
 #define LPFC_USER_LINK_SPEED_10G   10  /* 10 Gigabaud */
 #define LPFC_USER_LINK_SPEED_16G   16  /* 16 Gigabaud */
 #define LPFC_USER_LINK_SPEED_32G   32  /* 32 Gigabaud */
-#define LPFC_USER_LINK_SPEED_MAX   LPFC_USER_LINK_SPEED_32G
-#define LPFC_USER_LINK_SPEED_BITMAP  ((1ULL << LPFC_USER_LINK_SPEED_32G) | \
-(1 << LPFC_USER_LINK_SPEED_16G) | \
-(1 << LPFC_USER_LINK_SPEED_10G) | \
-(1 << LPFC_USER_LINK_SPEED_8G) | \
-(1 << LPFC_USER_LINK_SPEED_4G) | \
-(1 << LPFC_USER_LINK_SPEED_2G) | \
-(1 << LPFC_USER_LINK_SPEED_1G) | \
-(1 << LPFC_USER_LINK_SPEED_AUTO))
-#define LPFC_LINK_SPEED_STRING "0, 1, 2, 4, 8, 10, 16, 32"
+#define LPFC_USER_LINK_SPEED_64G   64  /* 64 Gigabaud */
+#define LPFC_USER_LINK_SPEED_MAX   LPFC_USER_LINK_SPEED_64G
+
+#define LPFC_LINK_SPEED_STRING "0, 1, 2, 4, 8, 10, 16, 32, 64"
 
 enum nemb_type {
nemb_mse = 1,
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index e90d5066f66b..bbed20a39b25 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -4115,23 +4115,32 @@ lpfc_link_speed_store(struct device *dev, struct 
device_attribute *attr,
((val == LPFC_USER_LINK_SPEED_8G) && !(phba->lmt & LMT_8Gb)) ||
((val == LPFC_USER_LINK_SPEED_10G) && !(phba->lmt & LMT_10Gb)) ||
((val == LPFC_USER_LINK_SPEED_16G) && !(phba->lmt & LMT_16Gb)) ||
-   ((val == LPFC_USER_LINK_SPEED_32G) && !(phba->lmt & LMT_32Gb))) {
+   ((val == LPFC_USER_LINK_SPEED_32G) && !(phba->lmt & LMT_32Gb)) ||
+   ((val == LPFC_USER_LINK_SPEED_64G) && !(phba->lmt & LMT_64Gb))) {
lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
"2879 lpfc_link_speed attribute cannot be set "
"to %d. Speed is not supported by this port.\n",
val);
return -EINVAL;
}
-   if (val == LPFC_USER_LINK_SPEED_16G &&
-phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
+   if (val >= LPFC_USER_LINK_SPEED_16G &&
+   phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
"3112 lpfc_link_speed attribute cannot be set "
"to %d. Speed is not supported in loop mode.\n",
val);
return -EINVAL;
}
-   if ((val >= 0) && (val <= LPFC_USER_LINK_SPEED_MAX) &&
-   (LPFC_USER_LINK_SPEED_BITMAP & (1 << val))) {
+
+   switch (val) {
+   case LPFC_USER_LINK_SPEED_AUTO:
+   case LPFC_USER_LINK_SPEED_1G:
+   case LPFC_USER_LINK_SPEED_2G:
+   case LPFC_USER_LINK_SPEED_4G:
+   case LPFC_USER_LINK_SPEED_8G:
+   case LPFC_USER_LINK_SPEED_16G:
+   case LPFC_USER_LINK_SPEED_32G:
+   case LPFC_USER_LINK_SPEED_64G:
prev_val = phba->cfg_link_speed;
phba->cfg_link_speed = val;
if (nolip)
@@ -4141,13 +4150,18 @@ lpfc_link_speed_store(struct device *dev, struct 
device_attribute *attr,
if (err) {
phba->cfg_link_speed = prev_val;
return -EINVAL;
-   } else
-   return strlen(buf);
+   }
+   return strlen(buf);
+   default:
+   break;
}
+
lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
-   "0469 lpfc_link_speed attribute cannot be set to %d, "
-   "allowed values are ["LPFC_LINK_SPEED_STRING"]\n", val);
+   "0469 lpfc_link_speed attribute cannot be set to %d, "
+