netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Xu Yilun <yilun.xu@intel.com>
Cc: andrew@lunn.ch, arnd@arndb.de, lee.jones@linaro.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	trix@redhat.com, lgoncalv@redhat.com, hao.wu@intel.com,
	matthew.gerlach@intel.com, russell.h.weight@intel.com
Subject: Re: [RESEND PATCH 2/2] misc: add support for retimers interfaces on Intel MAX 10 BMC
Date: Thu, 7 Jan 2021 10:26:12 +0100	[thread overview]
Message-ID: <X/bTtBUevX5IBPUl@kroah.com> (raw)
In-Reply-To: <1609999628-12748-3-git-send-email-yilun.xu@intel.com>

On Thu, Jan 07, 2021 at 02:07:08PM +0800, Xu Yilun wrote:
> This driver supports the ethernet retimers (C827) for the Intel PAC
> (Programmable Acceleration Card) N3000, which is a FPGA based Smart NIC.
> 
> C827 is an Intel(R) Ethernet serdes transceiver chip that supports
> up to 100G transfer. On Intel PAC N3000 there are 2 C827 chips
> managed by the Intel MAX 10 BMC firmware. They are configured in 4 ports
> 10G/25G retimer mode. Host could query their link states and firmware
> version information via retimer interfaces (Shared registers) on Intel
> MAX 10 BMC. The driver creates sysfs interfaces for users to query these
> information.

Networking people, please look at this sysfs file:

> +What:		/sys/bus/platform/devices/n3000bmc-retimer.*.auto/link_statusX
> +Date:		Jan 2021
> +KernelVersion:	5.12
> +Contact:	Xu Yilun <yilun.xu@intel.com>
> +Description:	Read only. Returns the status of each line side link. "1" for
> +		link up, "0" for link down.
> +		Format: "%u".

as I need your approval to add it because it is not the "normal" way for
link status to be exported to userspace.

One code issue:

> +#define to_link_attr(dev_attr) \
> +	container_of(dev_attr, struct link_attr, attr)
> +
> +static ssize_t
> +link_status_show(struct device *dev, struct device_attribute *attr, char *buf)
> +{
> +	struct m10bmc_retimer *retimer = dev_get_drvdata(dev);
> +	struct link_attr *lattr = to_link_attr(attr);
> +	unsigned int val;
> +	int ret;
> +
> +	ret = m10bmc_sys_read(retimer->m10bmc, M10BMC_PKVL_LSTATUS, &val);
> +	if (ret)
> +		return ret;
> +
> +	return sysfs_emit(buf, "%u\n",
> +			  !!(val & BIT((retimer->id << 2) + lattr->index)));
> +}
> +
> +#define link_status_attr(_index)				\
> +	static struct link_attr link_attr_status##_index =	\
> +		{ .attr = __ATTR(link_status##_index, 0444,	\
> +				 link_status_show, NULL),	\
> +		  .index = (_index) }

Why is this a "raw" attribute and not a device attribute?

Please just use a normal DEVICE_ATTR_RO() macro to make it simpler and
easier to understand over time, what you are doing here.  I can't
determine what is happening with this code now...

thanks,

greg k-h

  reply	other threads:[~2021-01-07  9:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-07  6:07 [RESEND PATCH 0/2] Add retimer interfaces support for Intel MAX 10 BMC Xu Yilun
2021-01-07  6:07 ` [RESEND PATCH 1/2] mfd: intel-m10-bmc: specify the retimer sub devices Xu Yilun
2021-01-07  6:07 ` [RESEND PATCH 2/2] misc: add support for retimers interfaces on Intel MAX 10 BMC Xu Yilun
2021-01-07  9:26   ` Greg KH [this message]
2021-01-07 14:51     ` Andrew Lunn
2021-01-08  2:08       ` Xu Yilun
2021-01-08  2:05     ` Xu Yilun
2021-01-08  7:47       ` Greg KH

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=X/bTtBUevX5IBPUl@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=andrew@lunn.ch \
    --cc=arnd@arndb.de \
    --cc=hao.wu@intel.com \
    --cc=lee.jones@linaro.org \
    --cc=lgoncalv@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew.gerlach@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=russell.h.weight@intel.com \
    --cc=trix@redhat.com \
    --cc=yilun.xu@intel.com \
    /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).