All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fcoe: provide translation table between Ethernet and FC port speeds
@ 2016-08-15 15:24 Johannes Thumshirn
  2016-08-19  8:37 ` Hannes Reinecke
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Thumshirn @ 2016-08-15 15:24 UTC (permalink / raw)
  To: Martin K . Petersen, James Bottomley
  Cc: Linux SCSI Mailinglist, Linux Kernel Mailinglist, 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>
---
 drivers/scsi/fcoe/fcoe_transport.c | 48 ++++++++++++++++++++++++--------------
 1 file changed, 31 insertions(+), 17 deletions(-)

diff --git a/drivers/scsi/fcoe/fcoe_transport.c b/drivers/scsi/fcoe/fcoe_transport.c
index 7028dd3..3e7f0e7 100644
--- a/drivers/scsi/fcoe/fcoe_transport.c
+++ b/drivers/scsi/fcoe/fcoe_transport.c
@@ -83,6 +83,36 @@ static struct notifier_block libfcoe_notifier = {
 	.notifier_call = libfcoe_device_notification,
 };
 
+static const struct {
+	u32 fc_port_speed;
+	u32 eth_port_speed;
+} fcoe_port_speed_mapping[] = {
+	{ FC_PORTSPEED_1GBIT, SPEED_1000 },
+	{ FC_PORTSPEED_2GBIT, 2000 },
+	{ FC_PORTSPEED_4GBIT, 4000 },
+	{ FC_PORTSPEED_8GBIT, 8000 },
+	{ FC_PORTSPEED_10GBIT, SPEED_10000 },
+	{ FC_PORTSPEED_16GBIT, 16000 },
+	{ FC_PORTSPEED_20GBIT, SPEED_20000  },
+	{ FC_PORTSPEED_25GBIT, SPEED_25000  },
+	{ FC_PORTSPEED_32GBIT, 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 +156,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] 3+ messages in thread

* Re: [PATCH] fcoe: provide translation table between Ethernet and FC port speeds
  2016-08-15 15:24 [PATCH] fcoe: provide translation table between Ethernet and FC port speeds Johannes Thumshirn
@ 2016-08-19  8:37 ` Hannes Reinecke
  2016-08-19 11:30   ` Johannes Thumshirn
  0 siblings, 1 reply; 3+ messages in thread
From: Hannes Reinecke @ 2016-08-19  8:37 UTC (permalink / raw)
  To: Johannes Thumshirn, Martin K . Petersen, James Bottomley
  Cc: Linux SCSI Mailinglist, Linux Kernel Mailinglist

On 08/15/2016 05:24 PM, 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>
> ---
>  drivers/scsi/fcoe/fcoe_transport.c | 48 ++++++++++++++++++++++++--------------
>  1 file changed, 31 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/scsi/fcoe/fcoe_transport.c b/drivers/scsi/fcoe/fcoe_transport.c
> index 7028dd3..3e7f0e7 100644
> --- a/drivers/scsi/fcoe/fcoe_transport.c
> +++ b/drivers/scsi/fcoe/fcoe_transport.c
> @@ -83,6 +83,36 @@ static struct notifier_block libfcoe_notifier = {
>  	.notifier_call = libfcoe_device_notification,
>  };
>  
> +static const struct {
> +	u32 fc_port_speed;
> +	u32 eth_port_speed;
> +} fcoe_port_speed_mapping[] = {
> +	{ FC_PORTSPEED_1GBIT, SPEED_1000 },
> +	{ FC_PORTSPEED_2GBIT, 2000 },
> +	{ FC_PORTSPEED_4GBIT, 4000 },
> +	{ FC_PORTSPEED_8GBIT, 8000 },
> +	{ FC_PORTSPEED_10GBIT, SPEED_10000 },
> +	{ FC_PORTSPEED_16GBIT, 16000 },
> +	{ FC_PORTSPEED_20GBIT, SPEED_20000  },
> +	{ FC_PORTSPEED_25GBIT, SPEED_25000  },
> +	{ FC_PORTSPEED_32GBIT, 32000 },
> +	{ FC_PORTSPEED_40GBIT, SPEED_40000  },
> +	{ FC_PORTSPEED_50GBIT, SPEED_50000  },
> +	{ FC_PORTSPEED_100GBIT, SPEED_100000 },
> +};
> +
Hmm. Why not 'SPEED_2000' etc?

This looks a bit weird, mixing values with defines ...

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

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

* Re: [PATCH] fcoe: provide translation table between Ethernet and FC port speeds
  2016-08-19  8:37 ` Hannes Reinecke
@ 2016-08-19 11:30   ` Johannes Thumshirn
  0 siblings, 0 replies; 3+ messages in thread
From: Johannes Thumshirn @ 2016-08-19 11:30 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Martin K . Petersen, James Bottomley, Linux SCSI Mailinglist,
	Linux Kernel Mailinglist

On Fri, Aug 19, 2016 at 10:37:04AM +0200, Hannes Reinecke wrote:
> On 08/15/2016 05:24 PM, Johannes Thumshirn wrote:

[...]

> >  
> > +static const struct {
> > +	u32 fc_port_speed;
> > +	u32 eth_port_speed;
> > +} fcoe_port_speed_mapping[] = {
> > +	{ FC_PORTSPEED_1GBIT, SPEED_1000 },
> > +	{ FC_PORTSPEED_2GBIT, 2000 },
> > +	{ FC_PORTSPEED_4GBIT, 4000 },
> > +	{ FC_PORTSPEED_8GBIT, 8000 },
> > +	{ FC_PORTSPEED_10GBIT, SPEED_10000 },
> > +	{ FC_PORTSPEED_16GBIT, 16000 },
> > +	{ FC_PORTSPEED_20GBIT, SPEED_20000  },
> > +	{ FC_PORTSPEED_25GBIT, SPEED_25000  },
> > +	{ FC_PORTSPEED_32GBIT, 32000 },
> > +	{ FC_PORTSPEED_40GBIT, SPEED_40000  },
> > +	{ FC_PORTSPEED_50GBIT, SPEED_50000  },
> > +	{ FC_PORTSPEED_100GBIT, SPEED_100000 },
> > +};
> > +
> Hmm. Why not 'SPEED_2000' etc?
> 
> This looks a bit weird, mixing values with defines ...

I'll add defines for the non Ethernet native speeds privately to this file.

-- 
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] 3+ messages in thread

end of thread, other threads:[~2016-08-19 11:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-15 15:24 [PATCH] fcoe: provide translation table between Ethernet and FC port speeds Johannes Thumshirn
2016-08-19  8:37 ` Hannes Reinecke
2016-08-19 11:30   ` Johannes Thumshirn

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.