netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Bjørn Mork" <bjorn@mork.no>
To: netdev@vger.kernel.org
Cc: linux-usb@vger.kernel.org,
	"Alexey Orishko" <alexey.orishko@gmail.com>,
	"Oliver Neukum" <oliver@neukum.org>,
	"Enrico Mioso" <mrkiko.rs@gmail.com>,
	"David Laight" <David.Laight@ACULAB.COM>,
	"Lars Melin" <larsm17@gmail.com>, "Peter Stuge" <peter@stuge.se>,
	"Greg Suarez" <gsuarez@smithmicro.com>,
	"Bjørn Mork" <bjorn@mork.no>
Subject: [PATCH v2 net-next 6/8] net: cdc_ncm: export NCM Transfer Block (NTB) parameters
Date: Fri, 30 May 2014 09:31:08 +0200	[thread overview]
Message-ID: <1401435070-26721-7-git-send-email-bjorn@mork.no> (raw)
In-Reply-To: <1401435070-26721-1-git-send-email-bjorn@mork.no>

The mandatory GetNtbParameters control request is an important part of
the host <-> device protocol negotiation in CDC NCM (and CDC MBIM). It
gives device limits which the host must obey when configuring the
protocol aggregation variables. The driver will enforce this by
rejecting attempts to set any of the tunable variables to a value
which is not supported by the device.  Exporting the parameter block
helps userspace decide which values are allowed without resorting
to trial and error.

Signed-off-by: Bjørn Mork <bjorn@mork.no>
---
 drivers/net/usb/cdc_ncm.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index aaa440d892b8..98c3adb5aea3 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -260,10 +260,40 @@ static DEVICE_ATTR(rx_max, S_IRUGO | S_IWUSR, cdc_ncm_show_rx_max, cdc_ncm_store
 static DEVICE_ATTR(tx_max, S_IRUGO | S_IWUSR, cdc_ncm_show_tx_max, cdc_ncm_store_tx_max);
 static DEVICE_ATTR(tx_timer_usecs, S_IRUGO | S_IWUSR, cdc_ncm_show_tx_timer_usecs, cdc_ncm_store_tx_timer_usecs);
 
+#define NCM_PARM_ATTR(name, format, tocpu)				\
+static ssize_t cdc_ncm_show_##name(struct device *d, struct device_attribute *attr, char *buf) \
+{ \
+	struct usbnet *dev = netdev_priv(to_net_dev(d)); \
+	struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0]; \
+	return sprintf(buf, format "\n", tocpu(ctx->ncm_parm.name));	\
+} \
+static DEVICE_ATTR(name, S_IRUGO, cdc_ncm_show_##name, NULL)
+
+NCM_PARM_ATTR(bmNtbFormatsSupported, "0x%04x", le16_to_cpu);
+NCM_PARM_ATTR(dwNtbInMaxSize, "%u", le32_to_cpu);
+NCM_PARM_ATTR(wNdpInDivisor, "%u", le16_to_cpu);
+NCM_PARM_ATTR(wNdpInPayloadRemainder, "%u", le16_to_cpu);
+NCM_PARM_ATTR(wNdpInAlignment, "%u", le16_to_cpu);
+NCM_PARM_ATTR(dwNtbOutMaxSize, "%u", le32_to_cpu);
+NCM_PARM_ATTR(wNdpOutDivisor, "%u", le16_to_cpu);
+NCM_PARM_ATTR(wNdpOutPayloadRemainder, "%u", le16_to_cpu);
+NCM_PARM_ATTR(wNdpOutAlignment, "%u", le16_to_cpu);
+NCM_PARM_ATTR(wNtbOutMaxDatagrams, "%u", le16_to_cpu);
+
 static struct attribute *cdc_ncm_sysfs_attrs[] = {
 	&dev_attr_rx_max.attr,
 	&dev_attr_tx_max.attr,
 	&dev_attr_tx_timer_usecs.attr,
+	&dev_attr_bmNtbFormatsSupported.attr,
+	&dev_attr_dwNtbInMaxSize.attr,
+	&dev_attr_wNdpInDivisor.attr,
+	&dev_attr_wNdpInPayloadRemainder.attr,
+	&dev_attr_wNdpInAlignment.attr,
+	&dev_attr_dwNtbOutMaxSize.attr,
+	&dev_attr_wNdpOutDivisor.attr,
+	&dev_attr_wNdpOutPayloadRemainder.attr,
+	&dev_attr_wNdpOutAlignment.attr,
+	&dev_attr_wNtbOutMaxDatagrams.attr,
 	NULL,
 };
 
-- 
2.0.0.rc4

  parent reply	other threads:[~2014-05-30  7:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-30  7:31 [PATCH v2 net-next 0/8] cdc_ncm: fixes and conversion to sysfs API Bjørn Mork
2014-05-30  7:31 ` [PATCH v2 net-next 1/8] net: cdc_ncm: reduce skb truesize in rx path Bjørn Mork
     [not found] ` <1401435070-26721-1-git-send-email-bjorn-yOkvZcmFvRU@public.gmane.org>
2014-05-30  7:31   ` [PATCH v2 net-next 2/8] net: cdc_ncm: always reallocate tx_curr_skb when tx_max increases Bjørn Mork
2014-05-30  7:31   ` [PATCH v2 net-next 4/8] net: cdc_ncm: use sysfs for rx/tx aggregation tuning Bjørn Mork
2014-05-30  7:31 ` [PATCH v2 net-next 3/8] net: cdc_ncm: inform usbnet when rx buffers are reduced Bjørn Mork
     [not found]   ` <1401435070-26721-4-git-send-email-bjorn-yOkvZcmFvRU@public.gmane.org>
2014-05-30  9:18     ` David Laight
2014-05-30 11:39       ` Bjørn Mork
2014-05-30 12:39         ` David Laight
2014-05-30 13:35           ` Bjørn Mork
     [not found]         ` <87d2eva41t.fsf-lbf33ChDnrE/G1V5fR+Y7Q@public.gmane.org>
2014-05-30 12:42           ` David Laight
2014-05-30 13:39             ` Bjørn Mork
2014-05-30  7:31 ` [PATCH v2 net-next 5/8] net: cdc_ncm: drop ethtool coalesce support Bjørn Mork
2014-05-30  7:31 ` Bjørn Mork [this message]
2014-05-30  7:31 ` [PATCH v2 net-next 7/8] net: cdc_ncm: allow tuning min_tx_pkt Bjørn Mork
2014-05-30  7:31 ` [PATCH v2 net-next 8/8] net: cdc_ncm: document the sysfs API Bjørn Mork
2014-06-02 23:02 ` [PATCH v2 net-next 0/8] cdc_ncm: fixes and conversion to " David Miller

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=1401435070-26721-7-git-send-email-bjorn@mork.no \
    --to=bjorn@mork.no \
    --cc=David.Laight@ACULAB.COM \
    --cc=alexey.orishko@gmail.com \
    --cc=gsuarez@smithmicro.com \
    --cc=larsm17@gmail.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=mrkiko.rs@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=oliver@neukum.org \
    --cc=peter@stuge.se \
    /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).