netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <Narendra_K@Dell.com>
To: <jiri@resnulli.us>, <netdev@vger.kernel.org>
Cc: <bhutchings@solarflare.com>, <john.r.fastabend@intel.com>
Subject: RE: [patch net-next RFC 3/3] net: export physical port id via sysfs
Date: Tue, 16 Jul 2013 13:03:04 -0700	[thread overview]
Message-ID: <E31FB011129F30488D5861F383904915210EF3F51F@BLRX7MCDC201.AMER.DELL.COM> (raw)
In-Reply-To: <1373908027-25800-4-git-send-email-jiri@resnulli.us>

> -----Original Message-----
> From: Jiri Pirko [mailto:jiri@resnulli.us]
> Sent: Monday, July 15, 2013 10:37 PM
> To: netdev@vger.kernel.org
> Cc: K, Narendra; bhutchings@solarflare.com; john.r.fastabend@intel.com
> Subject: [patch net-next RFC 3/3] net: export physical port id via sysfs
> 
> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
> ---
>  net/core/net-sysfs.c | 41
> +++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 41 insertions(+)
> 
> diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index
> 981fed3..fb19ede 100644
> --- a/net/core/net-sysfs.c
> +++ b/net/core/net-sysfs.c
> @@ -334,6 +334,46 @@ static ssize_t store_group(struct device *dev, struct
> device_attribute *attr,
>  	return netdev_store(dev, attr, buf, len, change_group);  }
> 
> +static size_t _format_port_id(char *buf, int buflen,
> +			      const unsigned char *id, int len) {
> +	int i;
> +	char *cp = buf;
> +
> +	for (i = 0; i < len; i++)
> +		cp += scnprintf(cp, buflen - (cp - buf), "%02x", id[i]);
> +	return cp - buf;
> +}
> +
> +ssize_t sysfs_format_port_id(char *buf, const unsigned char *id, int
> +len) {
> +	size_t l;
> +
> +	l = _format_port_id(buf, PAGE_SIZE, id, len);
> +	l += scnprintf(buf + l, PAGE_SIZE - l, "\n");
> +	return (ssize_t)l;
> +}
> +static ssize_t show_phys_port_id(struct device *dev,
> +				 struct device_attribute *attr, char *buf) {
> +	struct net_device *netdev = to_net_dev(dev);
> +	ssize_t ret = 0;
> +
> +	if (!rtnl_trylock())
> +		return restart_syscall();
> +
> +	if (dev_isalive(netdev) && netdev->netdev_ops-
> >ndo_get_phys_port_id) {
> +		struct netdev_phys_port_id ppid;
> +
> +		ret = netdev->netdev_ops->ndo_get_phys_port_id(netdev,
> &ppid);
[>] 

Hello,
I am thinking if "ndo_get_phys_port_id()" is required.  With it, the driver needs to generate port_id  every time "ndo_get_phys_port_id()" is called, but the "netdev->phys_port.port_id" might not have changed.  If 'phys_port'  structure is part of 'struct net_device',  then 'netdev->phys_port.port_id' and port_id_len are set by driver before calling 'register_netdev' and are available to the core.  Driver not implementing it would indicate it by a "port_id_len" of zero.     If the "netdev->phys_port.port_id" changes for some reason then the notification sent by the driver would ensure that the interested kernel components and user space are notified of the change.

With regards,
Narendra K
Linux Engineering
Dell Inc.

  reply	other threads:[~2013-07-16 20:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-15 17:07 [patch net-next RFC 0/3] export device physical port id to userspace Jiri Pirko
2013-07-15 17:07 ` [patch net-next RFC 1/3] net: add ndo to get id of physical port of the device Jiri Pirko
2013-07-15 22:01   ` Ben Hutchings
2013-07-16  6:41     ` Jiri Pirko
2013-07-15 17:07 ` [patch net-next RFC 2/3] rtnl: export physical port id via RT netlink Jiri Pirko
2013-07-15 17:07 ` [patch net-next RFC 3/3] net: export physical port id via sysfs Jiri Pirko
2013-07-16 20:03   ` Narendra_K [this message]
2013-07-17  8:29     ` Jiri Pirko
2013-07-17 19:39       ` Narendra_K
2013-07-17 22:27         ` Ben Hutchings

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E31FB011129F30488D5861F383904915210EF3F51F@BLRX7MCDC201.AMER.DELL.COM \
    --to=narendra_k@dell.com \
    --cc=bhutchings@solarflare.com \
    --cc=jiri@resnulli.us \
    --cc=john.r.fastabend@intel.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).