All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] fcoe: provide translation table between Ethernet and FC port speeds
@ 2016-08-19 13:33 Johannes Thumshirn
  2016-08-20  0:36 ` Lee Duncan
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Johannes Thumshirn @ 2016-08-19 13:33 UTC (permalink / raw)
  To: Martin K . Petersen, Linux SCSI Mailinglist; +Cc: Johannes Thumshirn

Provide a translation table between Ethernet and FC port speeds so odd
speeds (from a Ethernet POV) like 8 Gbit are correctly mapped to sysfs
and open-fcoe's fcoeadm.

Before:
    Description:      BCM57840 NetXtreme II 10/20-Gigabit Ethernet
    Revision:         11
    Manufacturer:     Broadcom Corporation
    Serial Number:    6CC2173EA1D0

    Driver:           bnx2x 1.712.30-0
    Number of Ports:  1

        Symbolic Name:     bnx2fc (QLogic BCM57840) v2.10.3 over eth2
        OS Device Name:    host1
        Node Name:         0x20006cc2173ea1d1
        Port Name:         0x10006cc2173ea1d1
        FabricName:        0x100000c0dd0ce717
        Speed:             unknown
        Supported Speed:   1 Gbit, 10 Gbit
        MaxFrameSize:      2048 bytes
        FC-ID (Port ID):   0x660702
        State:             Online

After:
    Description:      BCM57840 NetXtreme II 10/20-Gigabit Ethernet
    Revision:         11
    Manufacturer:     Broadcom Corporation
    Serial Number:    6CC2173EA1D0

    Driver:           bnx2x 1.712.30-0
    Number of Ports:  1

        Symbolic Name:     bnx2fc (QLogic BCM57840) v2.10.3 over eth2
        OS Device Name:    host1
        Node Name:         0x20006cc2173ea1d1
        Port Name:         0x10006cc2173ea1d1
        FabricName:        0x100000c0dd0ce717
        Speed:             8 Gbit
        Supported Speed:   1 Gbit, 10 Gbit
        MaxFrameSize:      2048 bytes
        FC-ID (Port ID):   0x660701
        State:             Online

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
---

Changes to v1:
* Add definitions for non-native Ethernet speeds

 drivers/scsi/fcoe/fcoe_transport.c | 53 ++++++++++++++++++++++++++------------
 1 file changed, 36 insertions(+), 17 deletions(-)

diff --git a/drivers/scsi/fcoe/fcoe_transport.c b/drivers/scsi/fcoe/fcoe_transport.c
index 7028dd3..c164eec 100644
--- a/drivers/scsi/fcoe/fcoe_transport.c
+++ b/drivers/scsi/fcoe/fcoe_transport.c
@@ -83,6 +83,41 @@ static struct notifier_block libfcoe_notifier = {
 	.notifier_call = libfcoe_device_notification,
 };
 
+static const struct {
+	u32 fc_port_speed;
+#define SPEED_2000	2000
+#define SPEED_4000	4000
+#define SPEED_8000	8000
+#define SPEED_16000	16000
+#define SPEED_32000	32000
+	u32 eth_port_speed;
+} fcoe_port_speed_mapping[] = {
+	{ FC_PORTSPEED_1GBIT,   SPEED_1000   },
+	{ FC_PORTSPEED_2GBIT,   SPEED_2000   },
+	{ FC_PORTSPEED_4GBIT,   SPEED_4000   },
+	{ FC_PORTSPEED_8GBIT,   SPEED_8000   },
+	{ FC_PORTSPEED_10GBIT,  SPEED_10000  },
+	{ FC_PORTSPEED_16GBIT,  SPEED_16000  },
+	{ FC_PORTSPEED_20GBIT,  SPEED_20000  },
+	{ FC_PORTSPEED_25GBIT,  SPEED_25000  },
+	{ FC_PORTSPEED_32GBIT,  SPEED_32000  },
+	{ FC_PORTSPEED_40GBIT,  SPEED_40000  },
+	{ FC_PORTSPEED_50GBIT,  SPEED_50000  },
+	{ FC_PORTSPEED_100GBIT, SPEED_100000 },
+};
+
+static inline u32 eth2fc_speed(u32 eth_port_speed)
+{
+	int i;
+
+	for (i = 0; i <= ARRAY_SIZE(fcoe_port_speed_mapping); i++) {
+		if (fcoe_port_speed_mapping[i].eth_port_speed == eth_port_speed)
+			return fcoe_port_speed_mapping[i].fc_port_speed;
+	}
+
+	return FC_PORTSPEED_UNKNOWN;
+}
+
 /**
  * fcoe_link_speed_update() - Update the supported and actual link speeds
  * @lport: The local port to update speeds for
@@ -126,23 +161,7 @@ int fcoe_link_speed_update(struct fc_lport *lport)
 			    SUPPORTED_40000baseLR4_Full))
 			lport->link_supported_speeds |= FC_PORTSPEED_40GBIT;
 
-		switch (ecmd.base.speed) {
-		case SPEED_1000:
-			lport->link_speed = FC_PORTSPEED_1GBIT;
-			break;
-		case SPEED_10000:
-			lport->link_speed = FC_PORTSPEED_10GBIT;
-			break;
-		case SPEED_20000:
-			lport->link_speed = FC_PORTSPEED_20GBIT;
-			break;
-		case SPEED_40000:
-			lport->link_speed = FC_PORTSPEED_40GBIT;
-			break;
-		default:
-			lport->link_speed = FC_PORTSPEED_UNKNOWN;
-			break;
-		}
+		lport->link_speed = eth2fc_speed(ecmd.base.speed);
 		return 0;
 	}
 	return -1;
-- 
1.8.5.6


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] fcoe: provide translation table between Ethernet and FC port speeds
  2016-08-19 13:33 [PATCH v2] fcoe: provide translation table between Ethernet and FC port speeds Johannes Thumshirn
@ 2016-08-20  0:36 ` Lee Duncan
  2016-08-24  2:28 ` Martin K. Petersen
  2016-09-21 20:54 ` [PATCH next] scsi: fcoe: fix off by one in eth2fc_speed() Vincent Stehlé
  2 siblings, 0 replies; 6+ messages in thread
From: Lee Duncan @ 2016-08-20  0:36 UTC (permalink / raw)
  To: Johannes Thumshirn, Martin K . Petersen, Linux SCSI Mailinglist

On 08/19/2016 06:33 AM, Johannes Thumshirn wrote:
> Provide a translation table between Ethernet and FC port speeds so odd
> speeds (from a Ethernet POV) like 8 Gbit are correctly mapped to sysfs
> and open-fcoe's fcoeadm.
> 
> Before:
>     Description:      BCM57840 NetXtreme II 10/20-Gigabit Ethernet
>     Revision:         11
>     Manufacturer:     Broadcom Corporation
>     Serial Number:    6CC2173EA1D0
> 
>     Driver:           bnx2x 1.712.30-0
>     Number of Ports:  1
> 
>         Symbolic Name:     bnx2fc (QLogic BCM57840) v2.10.3 over eth2
>         OS Device Name:    host1
>         Node Name:         0x20006cc2173ea1d1
>         Port Name:         0x10006cc2173ea1d1
>         FabricName:        0x100000c0dd0ce717
>         Speed:             unknown
>         Supported Speed:   1 Gbit, 10 Gbit
>         MaxFrameSize:      2048 bytes
>         FC-ID (Port ID):   0x660702
>         State:             Online
> 
> After:
>     Description:      BCM57840 NetXtreme II 10/20-Gigabit Ethernet
>     Revision:         11
>     Manufacturer:     Broadcom Corporation
>     Serial Number:    6CC2173EA1D0
> 
>     Driver:           bnx2x 1.712.30-0
>     Number of Ports:  1
> 
>         Symbolic Name:     bnx2fc (QLogic BCM57840) v2.10.3 over eth2
>         OS Device Name:    host1
>         Node Name:         0x20006cc2173ea1d1
>         Port Name:         0x10006cc2173ea1d1
>         FabricName:        0x100000c0dd0ce717
>         Speed:             8 Gbit
>         Supported Speed:   1 Gbit, 10 Gbit
>         MaxFrameSize:      2048 bytes
>         FC-ID (Port ID):   0x660701
>         State:             Online
> 
> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
> ---
> 
> Changes to v1:
> * Add definitions for non-native Ethernet speeds
> 
>  drivers/scsi/fcoe/fcoe_transport.c | 53 ++++++++++++++++++++++++++------------
>  1 file changed, 36 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/scsi/fcoe/fcoe_transport.c b/drivers/scsi/fcoe/fcoe_transport.c
> index 7028dd3..c164eec 100644
> --- a/drivers/scsi/fcoe/fcoe_transport.c
> +++ b/drivers/scsi/fcoe/fcoe_transport.c
> @@ -83,6 +83,41 @@ static struct notifier_block libfcoe_notifier = {
>  	.notifier_call = libfcoe_device_notification,
>  };
>  
> +static const struct {
> +	u32 fc_port_speed;
> +#define SPEED_2000	2000
> +#define SPEED_4000	4000
> +#define SPEED_8000	8000
> +#define SPEED_16000	16000
> +#define SPEED_32000	32000
> +	u32 eth_port_speed;
> +} fcoe_port_speed_mapping[] = {
> +	{ FC_PORTSPEED_1GBIT,   SPEED_1000   },
> +	{ FC_PORTSPEED_2GBIT,   SPEED_2000   },
> +	{ FC_PORTSPEED_4GBIT,   SPEED_4000   },
> +	{ FC_PORTSPEED_8GBIT,   SPEED_8000   },
> +	{ FC_PORTSPEED_10GBIT,  SPEED_10000  },
> +	{ FC_PORTSPEED_16GBIT,  SPEED_16000  },
> +	{ FC_PORTSPEED_20GBIT,  SPEED_20000  },
> +	{ FC_PORTSPEED_25GBIT,  SPEED_25000  },
> +	{ FC_PORTSPEED_32GBIT,  SPEED_32000  },
> +	{ FC_PORTSPEED_40GBIT,  SPEED_40000  },
> +	{ FC_PORTSPEED_50GBIT,  SPEED_50000  },
> +	{ FC_PORTSPEED_100GBIT, SPEED_100000 },
> +};
> +
> +static inline u32 eth2fc_speed(u32 eth_port_speed)
> +{
> +	int i;
> +
> +	for (i = 0; i <= ARRAY_SIZE(fcoe_port_speed_mapping); i++) {
> +		if (fcoe_port_speed_mapping[i].eth_port_speed == eth_port_speed)
> +			return fcoe_port_speed_mapping[i].fc_port_speed;
> +	}
> +
> +	return FC_PORTSPEED_UNKNOWN;
> +}
> +
>  /**
>   * fcoe_link_speed_update() - Update the supported and actual link speeds
>   * @lport: The local port to update speeds for
> @@ -126,23 +161,7 @@ int fcoe_link_speed_update(struct fc_lport *lport)
>  			    SUPPORTED_40000baseLR4_Full))
>  			lport->link_supported_speeds |= FC_PORTSPEED_40GBIT;
>  
> -		switch (ecmd.base.speed) {
> -		case SPEED_1000:
> -			lport->link_speed = FC_PORTSPEED_1GBIT;
> -			break;
> -		case SPEED_10000:
> -			lport->link_speed = FC_PORTSPEED_10GBIT;
> -			break;
> -		case SPEED_20000:
> -			lport->link_speed = FC_PORTSPEED_20GBIT;
> -			break;
> -		case SPEED_40000:
> -			lport->link_speed = FC_PORTSPEED_40GBIT;
> -			break;
> -		default:
> -			lport->link_speed = FC_PORTSPEED_UNKNOWN;
> -			break;
> -		}Reviewed-by: Lee Duncan <lduncan@suse.com>
> +		lport->link_speed = eth2fc_speed(ecmd.base.speed);
>  		return 0;
>  	}
>  	return -1;
> 

Reviewed-by: Lee Duncan <lduncan@suse.com>

-- 
Lee Duncan


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] fcoe: provide translation table between Ethernet and FC port speeds
  2016-08-19 13:33 [PATCH v2] fcoe: provide translation table between Ethernet and FC port speeds Johannes Thumshirn
  2016-08-20  0:36 ` Lee Duncan
@ 2016-08-24  2:28 ` Martin K. Petersen
  2016-09-21 20:54 ` [PATCH next] scsi: fcoe: fix off by one in eth2fc_speed() Vincent Stehlé
  2 siblings, 0 replies; 6+ messages in thread
From: Martin K. Petersen @ 2016-08-24  2:28 UTC (permalink / raw)
  To: Johannes Thumshirn; +Cc: Martin K . Petersen, Linux SCSI Mailinglist

>>>>> "Johannes" == Johannes Thumshirn <jthumshirn@suse.de> writes:

Johannes> Provide a translation table between Ethernet and FC port
Johannes> speeds so odd speeds (from a Ethernet POV) like 8 Gbit are
Johannes> correctly mapped to sysfs and open-fcoe's fcoeadm.

Applied to 4.9/scsi-queue.

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH next] scsi: fcoe: fix off by one in eth2fc_speed()
  2016-08-19 13:33 [PATCH v2] fcoe: provide translation table between Ethernet and FC port speeds Johannes Thumshirn
  2016-08-20  0:36 ` Lee Duncan
  2016-08-24  2:28 ` Martin K. Petersen
@ 2016-09-21 20:54 ` Vincent Stehlé
  2016-09-22 10:48   ` Johannes Thumshirn
  2016-09-27  0:55   ` Martin K. Petersen
  2 siblings, 2 replies; 6+ messages in thread
From: Vincent Stehlé @ 2016-09-21 20:54 UTC (permalink / raw)
  To: linux-scsi; +Cc: Vincent Stehlé, Johannes Thumshirn, Martin K. Petersen

This should be "< ARRAY_SIZE()" instead of "<= ARRAY_SIZE()".

Fixes: 0b924e5505a568e7 ("scsi: fcoe: provide translation table between Ethernet and FC port speeds")
Signed-off-by: Vincent Stehlé <vincent.stehle@laposte.net>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
---

Hi,

I saw that in Linux next-20160921.

Best regards,

Vincent.

 drivers/scsi/fcoe/fcoe_transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/fcoe/fcoe_transport.c b/drivers/scsi/fcoe/fcoe_transport.c
index c164eec..375c536 100644
--- a/drivers/scsi/fcoe/fcoe_transport.c
+++ b/drivers/scsi/fcoe/fcoe_transport.c
@@ -110,7 +110,7 @@ static inline u32 eth2fc_speed(u32 eth_port_speed)
 {
 	int i;
 
-	for (i = 0; i <= ARRAY_SIZE(fcoe_port_speed_mapping); i++) {
+	for (i = 0; i < ARRAY_SIZE(fcoe_port_speed_mapping); i++) {
 		if (fcoe_port_speed_mapping[i].eth_port_speed == eth_port_speed)
 			return fcoe_port_speed_mapping[i].fc_port_speed;
 	}
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH next] scsi: fcoe: fix off by one in eth2fc_speed()
  2016-09-21 20:54 ` [PATCH next] scsi: fcoe: fix off by one in eth2fc_speed() Vincent Stehlé
@ 2016-09-22 10:48   ` Johannes Thumshirn
  2016-09-27  0:55   ` Martin K. Petersen
  1 sibling, 0 replies; 6+ messages in thread
From: Johannes Thumshirn @ 2016-09-22 10:48 UTC (permalink / raw)
  To: Vincent Stehlé; +Cc: linux-scsi, Martin K. Petersen

On Wed, Sep 21, 2016 at 10:54:07PM +0200, Vincent Stehlé wrote:
> This should be "< ARRAY_SIZE()" instead of "<= ARRAY_SIZE()".
> 
> Fixes: 0b924e5505a568e7 ("scsi: fcoe: provide translation table between Ethernet and FC port speeds")
> Signed-off-by: Vincent Stehlé <vincent.stehle@laposte.net>
> Cc: Johannes Thumshirn <jthumshirn@suse.de>
> Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
> ---
> 
> Hi,
> 
> I saw that in Linux next-20160921.
> 
> Best regards,
> 
> Vincent.
> 
>  drivers/scsi/fcoe/fcoe_transport.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/fcoe/fcoe_transport.c b/drivers/scsi/fcoe/fcoe_transport.c
> index c164eec..375c536 100644
> --- a/drivers/scsi/fcoe/fcoe_transport.c
> +++ b/drivers/scsi/fcoe/fcoe_transport.c
> @@ -110,7 +110,7 @@ static inline u32 eth2fc_speed(u32 eth_port_speed)
>  {
>  	int i;
>  
> -	for (i = 0; i <= ARRAY_SIZE(fcoe_port_speed_mapping); i++) {
> +	for (i = 0; i < ARRAY_SIZE(fcoe_port_speed_mapping); i++) {
>  		if (fcoe_port_speed_mapping[i].eth_port_speed == eth_port_speed)
>  			return fcoe_port_speed_mapping[i].fc_port_speed;
>  	}
> -- 
> 2.9.3
> 

Good catch,
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>

-- 
Johannes Thumshirn                                          Storage
jthumshirn@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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH next] scsi: fcoe: fix off by one in eth2fc_speed()
  2016-09-21 20:54 ` [PATCH next] scsi: fcoe: fix off by one in eth2fc_speed() Vincent Stehlé
  2016-09-22 10:48   ` Johannes Thumshirn
@ 2016-09-27  0:55   ` Martin K. Petersen
  1 sibling, 0 replies; 6+ messages in thread
From: Martin K. Petersen @ 2016-09-27  0:55 UTC (permalink / raw)
  To: Vincent Stehlé; +Cc: linux-scsi, Johannes Thumshirn, Martin K. Petersen

>>>>> "Vincent" == Vincent Stehlé <vincent.stehle@laposte.net> writes:

Vincent> This should be "< ARRAY_SIZE()" instead of "<= ARRAY_SIZE()".

Applied to 4.9/scsi-queue.

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-09-27  0:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-19 13:33 [PATCH v2] fcoe: provide translation table between Ethernet and FC port speeds Johannes Thumshirn
2016-08-20  0:36 ` Lee Duncan
2016-08-24  2:28 ` Martin K. Petersen
2016-09-21 20:54 ` [PATCH next] scsi: fcoe: fix off by one in eth2fc_speed() Vincent Stehlé
2016-09-22 10:48   ` Johannes Thumshirn
2016-09-27  0:55   ` Martin K. Petersen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.