Patchwork [net-next,v2,1/3] net: add ndo to get id of physical port of the device

login
register
mail settings
Submitter Jiri Pirko
Date July 20, 2013, 5:53 p.m.
Message ID <1374342834-10814-2-git-send-email-jiri@resnulli.us>
Download mbox | patch
Permalink /patch/260464/
State Changes Requested
Delegated to: David Miller
Headers show

Comments

Jiri Pirko - July 20, 2013, 5:53 p.m.
This patch adds a ndo for getting physical port of the device. Driver
which is aware of being virtual function of some physical port should
implement this ndo.

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
---
 include/linux/netdevice.h | 20 ++++++++++++++++++++
 net/core/dev.c            | 18 ++++++++++++++++++
 2 files changed, 38 insertions(+)
Or Gerlitz - July 21, 2013, 11:10 a.m.
On Sat, Jul 20, 2013 at 8:53 PM, Jiri Pirko <jiri@resnulli.us> wrote:
>
> This patch adds a ndo for getting physical port of the device. Driver
> which is aware of being virtual function of some physical port should
> implement this ndo.
>
> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
> ---
>  include/linux/netdevice.h | 20 ++++++++++++++++++++
>  net/core/dev.c            | 18 ++++++++++++++++++
>  2 files changed, 38 insertions(+)
>
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 0741a1e..726dec2 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -728,6 +728,16 @@ struct netdev_fcoe_hbainfo {
>  };
>  #endif
>
> +#define MAX_PHYS_PORT_ID_LEN 32
> +
> +/* This structure holds a unique identifier to identify the
> + * physical port used by a netdevice.
> + */
> +struct netdev_phys_port_id {
> +       unsigned char id[MAX_PHYS_PORT_ID_LEN];
> +       unsigned char id_len;
> +};


So an integer (four bytes?) is OK here? does it need to be in certain
byte order?
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ben Hutchings - July 21, 2013, 3 p.m.
On Sun, 2013-07-21 at 14:10 +0300, Or Gerlitz wrote:
> On Sat, Jul 20, 2013 at 8:53 PM, Jiri Pirko <jiri@resnulli.us> wrote:
> >
> > This patch adds a ndo for getting physical port of the device. Driver
> > which is aware of being virtual function of some physical port should
> > implement this ndo.
> >
> > Signed-off-by: Jiri Pirko <jiri@resnulli.us>
> > ---
> >  include/linux/netdevice.h | 20 ++++++++++++++++++++
> >  net/core/dev.c            | 18 ++++++++++++++++++
> >  2 files changed, 38 insertions(+)
> >
> > diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> > index 0741a1e..726dec2 100644
> > --- a/include/linux/netdevice.h
> > +++ b/include/linux/netdevice.h
> > @@ -728,6 +728,16 @@ struct netdev_fcoe_hbainfo {
> >  };
> >  #endif
> >
> > +#define MAX_PHYS_PORT_ID_LEN 32
> > +
> > +/* This structure holds a unique identifier to identify the
> > + * physical port used by a netdevice.
> > + */
> > +struct netdev_phys_port_id {
> > +       unsigned char id[MAX_PHYS_PORT_ID_LEN];
> > +       unsigned char id_len;
> > +};
> 
> 
> So an integer (four bytes?) is OK here? does it need to be in certain
> byte order?

It's an arbitrary value but is supposed to be universally unique.  So
you could use, for example, the first non-volatile MAC address assigned
to the port (if there is one).

Ben.
Ben Hutchings - July 21, 2013, 3:01 p.m.
On Sat, 2013-07-20 at 19:53 +0200, Jiri Pirko wrote:
> This patch adds a ndo for getting physical port of the device. Driver
> which is aware of being virtual function of some physical port should
> implement this ndo.
> 
> Signed-off-by: Jiri Pirko <jiri@resnulli.us>

Acked-by: Ben Hutchings <bhutchings@solarflare.com>

Ben.
Or Gerlitz - July 21, 2013, 8:26 p.m.
On Sat, Jul 20, 2013 at 8:53 PM, Jiri Pirko <jiri@resnulli.us> wrote:
>
> This patch adds a ndo for getting physical port of the device. Driver
> which is aware of being virtual function of some physical port should
> implement this ndo.


Do you mean virtual function literally?  that is in the PCI IOV aspect?


>
> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
> ---
>  include/linux/netdevice.h | 20 ++++++++++++++++++++
>  net/core/dev.c            | 18 ++++++++++++++++++
>  2 files changed, 38 insertions(+)
>
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 0741a1e..726dec2 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -728,6 +728,16 @@ struct netdev_fcoe_hbainfo {
>  };
>  #endif
>
> +#define MAX_PHYS_PORT_ID_LEN 32
> +
> +/* This structure holds a unique identifier to identify the
> + * physical port used by a netdevice.
> + */
> +struct netdev_phys_port_id {
> +       unsigned char id[MAX_PHYS_PORT_ID_LEN];
> +       unsigned char id_len;
> +};
> +
>  /*
>   * This structure defines the management hooks for network devices.
>   * The following hooks can be defined; unless noted otherwise, they are
> @@ -932,6 +942,12 @@ struct netdev_fcoe_hbainfo {
>   *     that determine carrier state from physical hardware properties (eg
>   *     network cables) or protocol-dependent mechanisms (eg
>   *     USB_CDC_NOTIFY_NETWORK_CONNECTION) should NOT implement this function.
> + *
> + * int (*ndo_get_phys_port_id)(struct net_device *dev,
> + *                            struct netdev_phys_port_id *ppid);
> + *     Called to get ID of physical port of this device. If driver does
> + *     not implement this, it is assumed that the hw is not able to have
> + *     multiple net devices on single physical port.
>   */

I am not sure to understand what is assumed here and why it it mandated.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jiri Pirko - July 21, 2013, 9:02 p.m.
Sun, Jul 21, 2013 at 10:26:32PM CEST, or.gerlitz@gmail.com wrote:
>On Sat, Jul 20, 2013 at 8:53 PM, Jiri Pirko <jiri@resnulli.us> wrote:
>>
>> This patch adds a ndo for getting physical port of the device. Driver
>> which is aware of being virtual function of some physical port should
>> implement this ndo.
>
>
>Do you mean virtual function literally?  that is in the PCI IOV aspect?

This is applicable not only for IOV, nbut for other solutions (NPAR,
multichannel) as well. Basically if there is possible to have multiple
netdevs on the single hw port.

>
>
>>
>> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
>> ---
>>  include/linux/netdevice.h | 20 ++++++++++++++++++++
>>  net/core/dev.c            | 18 ++++++++++++++++++
>>  2 files changed, 38 insertions(+)
>>
>> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
>> index 0741a1e..726dec2 100644
>> --- a/include/linux/netdevice.h
>> +++ b/include/linux/netdevice.h
>> @@ -728,6 +728,16 @@ struct netdev_fcoe_hbainfo {
>>  };
>>  #endif
>>
>> +#define MAX_PHYS_PORT_ID_LEN 32
>> +
>> +/* This structure holds a unique identifier to identify the
>> + * physical port used by a netdevice.
>> + */
>> +struct netdev_phys_port_id {
>> +       unsigned char id[MAX_PHYS_PORT_ID_LEN];
>> +       unsigned char id_len;
>> +};
>> +
>>  /*
>>   * This structure defines the management hooks for network devices.
>>   * The following hooks can be defined; unless noted otherwise, they are
>> @@ -932,6 +942,12 @@ struct netdev_fcoe_hbainfo {
>>   *     that determine carrier state from physical hardware properties (eg
>>   *     network cables) or protocol-dependent mechanisms (eg
>>   *     USB_CDC_NOTIFY_NETWORK_CONNECTION) should NOT implement this function.
>> + *
>> + * int (*ndo_get_phys_port_id)(struct net_device *dev,
>> + *                            struct netdev_phys_port_id *ppid);
>> + *     Called to get ID of physical port of this device. If driver does
>> + *     not implement this, it is assumed that the hw is not able to have
>> + *     multiple net devices on single physical port.
>>   */
>
>I am not sure to understand what is assumed here and why it it mandated.

It is not mandated. The key is to provide clear info to user that couple of
netdevs share the same port. The goal is to have this implemented for
all drivers which are able to have more netdevs on single hw port.

Jiri
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Narendra K - July 22, 2013, 11:29 a.m.
On Mon, Jul 22, 2013 at 02:32:30AM +0530, Jiri Pirko wrote:
> 
> Sun, Jul 21, 2013 at 10:26:32PM CEST, or.gerlitz@gmail.com wrote:
> >On Sat, Jul 20, 2013 at 8:53 PM, Jiri Pirko <jiri@resnulli.us> wrote:
> >>
> >> This patch adds a ndo for getting physical port of the device. Driver
> >> which is aware of being virtual function of some physical port should
> >> implement this ndo.
> >
> >
> >Do you mean virtual function literally?  that is in the PCI IOV aspect?
> 
> This is applicable not only for IOV, nbut for other solutions (NPAR,
> multichannel) as well. Basically if there is possible to have multiple
> netdevs on the single hw port.

I think it would be useful to include this information in the commit
message.
Jiri Pirko - July 22, 2013, 11:53 a.m.
Mon, Jul 22, 2013 at 01:29:50PM CEST, Narendra_K@Dell.com wrote:
>On Mon, Jul 22, 2013 at 02:32:30AM +0530, Jiri Pirko wrote:
>> 
>> Sun, Jul 21, 2013 at 10:26:32PM CEST, or.gerlitz@gmail.com wrote:
>> >On Sat, Jul 20, 2013 at 8:53 PM, Jiri Pirko <jiri@resnulli.us> wrote:
>> >>
>> >> This patch adds a ndo for getting physical port of the device. Driver
>> >> which is aware of being virtual function of some physical port should
>> >> implement this ndo.
>> >
>> >
>> >Do you mean virtual function literally?  that is in the PCI IOV aspect?
>> 
>> This is applicable not only for IOV, nbut for other solutions (NPAR,
>> multichannel) as well. Basically if there is possible to have multiple
>> netdevs on the single hw port.
>
>I think it would be useful to include this information in the commit
>message.

ok. I will resend the patchset soon.

>
>-- 
>With regards,
>Narendra K
>Linux Engineering
>Dell Inc.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Or Gerlitz - July 22, 2013, 3:52 p.m.
On Mon, Jul 22, 2013 at 12:02 AM, Jiri Pirko <jiri@resnulli.us> wrote:
> Sun, Jul 21, 2013 at 10:26:32PM CEST, or.gerlitz@gmail.com wrote:
>>On Sat, Jul 20, 2013 at 8:53 PM, Jiri Pirko <jiri@resnulli.us> wrote:
>>>
>>> This patch adds a ndo for getting physical port of the device. Driver
>>> which is aware of being virtual function of some physical port should
>>> implement this ndo.
>>
>>
>>Do you mean virtual function literally?  that is in the PCI IOV aspect?
>
> This is applicable not only for IOV, nbut for other solutions (NPAR,
> multichannel) as well. Basically if there is possible to have multiple
> netdevs on the single hw port.
>
>>
>>
>>>
>>> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
>>> ---
>>>  include/linux/netdevice.h | 20 ++++++++++++++++++++
>>>  net/core/dev.c            | 18 ++++++++++++++++++
>>>  2 files changed, 38 insertions(+)
>>>
>>> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
>>> index 0741a1e..726dec2 100644
>>> --- a/include/linux/netdevice.h
>>> +++ b/include/linux/netdevice.h
>>> @@ -728,6 +728,16 @@ struct netdev_fcoe_hbainfo {
>>>  };
>>>  #endif
>>>
>>> +#define MAX_PHYS_PORT_ID_LEN 32
>>> +
>>> +/* This structure holds a unique identifier to identify the
>>> + * physical port used by a netdevice.
>>> + */
>>> +struct netdev_phys_port_id {
>>> +       unsigned char id[MAX_PHYS_PORT_ID_LEN];
>>> +       unsigned char id_len;
>>> +};
>>> +
>>>  /*
>>>   * This structure defines the management hooks for network devices.
>>>   * The following hooks can be defined; unless noted otherwise, they are
>>> @@ -932,6 +942,12 @@ struct netdev_fcoe_hbainfo {
>>>   *     that determine carrier state from physical hardware properties (eg
>>>   *     network cables) or protocol-dependent mechanisms (eg
>>>   *     USB_CDC_NOTIFY_NETWORK_CONNECTION) should NOT implement this function.
>>> + *
>>> + * int (*ndo_get_phys_port_id)(struct net_device *dev,
>>> + *                            struct netdev_phys_port_id *ppid);
>>> + *     Called to get ID of physical port of this device. If driver does
>>> + *     not implement this, it is assumed that the hw is not able to have
>>> + *     multiple net devices on single physical port.
>>>   */
>>
>>I am not sure to understand what is assumed here and why it it mandated.
>
> It is not mandated. The key is to provide clear info to user that couple of
> netdevs share the same port. The goal is to have this implemented for
> all drivers which are able to have more netdevs on single hw port.

But why say that if a certain driver did not implement this NDO, their
HW can't have multiple netdevs on the same port? e.g think on a driver
that supports SRIOV such that multiple VFs can be assigned to the same
guest but their VF driver doesn't support this NDO, what's the problem
with that?  why the documentation does this <-- link

Or.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 0741a1e..726dec2 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -728,6 +728,16 @@  struct netdev_fcoe_hbainfo {
 };
 #endif
 
+#define MAX_PHYS_PORT_ID_LEN 32
+
+/* This structure holds a unique identifier to identify the
+ * physical port used by a netdevice.
+ */
+struct netdev_phys_port_id {
+	unsigned char id[MAX_PHYS_PORT_ID_LEN];
+	unsigned char id_len;
+};
+
 /*
  * This structure defines the management hooks for network devices.
  * The following hooks can be defined; unless noted otherwise, they are
@@ -932,6 +942,12 @@  struct netdev_fcoe_hbainfo {
  *	that determine carrier state from physical hardware properties (eg
  *	network cables) or protocol-dependent mechanisms (eg
  *	USB_CDC_NOTIFY_NETWORK_CONNECTION) should NOT implement this function.
+ *
+ * int (*ndo_get_phys_port_id)(struct net_device *dev,
+ *			       struct netdev_phys_port_id *ppid);
+ *	Called to get ID of physical port of this device. If driver does
+ *	not implement this, it is assumed that the hw is not able to have
+ *	multiple net devices on single physical port.
  */
 struct net_device_ops {
 	int			(*ndo_init)(struct net_device *dev);
@@ -1060,6 +1076,8 @@  struct net_device_ops {
 						      struct nlmsghdr *nlh);
 	int			(*ndo_change_carrier)(struct net_device *dev,
 						      bool new_carrier);
+	int			(*ndo_get_phys_port_id)(struct net_device *dev,
+							struct netdev_phys_port_id *ppid);
 };
 
 /*
@@ -2317,6 +2335,8 @@  extern int		dev_set_mac_address(struct net_device *,
 					    struct sockaddr *);
 extern int		dev_change_carrier(struct net_device *,
 					   bool new_carrier);
+extern int		dev_get_phys_port_id(struct net_device *dev,
+					     struct netdev_phys_port_id *ppid);
 extern int		dev_hard_start_xmit(struct sk_buff *skb,
 					    struct net_device *dev,
 					    struct netdev_queue *txq);
diff --git a/net/core/dev.c b/net/core/dev.c
index 26755dd..90172eb 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4989,6 +4989,24 @@  int dev_change_carrier(struct net_device *dev, bool new_carrier)
 EXPORT_SYMBOL(dev_change_carrier);
 
 /**
+ *	dev_get_phys_port_id - Get device physical port ID
+ *	@dev: device
+ *	@ppid: port ID
+ *
+ *	Get device physical port ID
+ */
+int dev_get_phys_port_id(struct net_device *dev,
+			 struct netdev_phys_port_id *ppid)
+{
+	const struct net_device_ops *ops = dev->netdev_ops;
+
+	if (!ops->ndo_get_phys_port_id)
+		return -EOPNOTSUPP;
+	return ops->ndo_get_phys_port_id(dev, ppid);
+}
+EXPORT_SYMBOL(dev_get_phys_port_id);
+
+/**
  *	dev_new_index	-	allocate an ifindex
  *	@net: the applicable net namespace
  *