aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/usb
diff options
context:
space:
mode:
authorBjørn Mork <bjorn@mork.no>2014-05-30 03:31:08 -0400
committerDavid S. Miller <davem@davemloft.net>2014-06-02 19:01:31 -0400
commit871578c90a9de5b785a815596dc7f8f0c147be19 (patch)
treea0daf5e392145a2a974b6eefc7c945a5039489c6 /drivers/net/usb
parente368d27ff007f7405cf668679f48ab3174a53922 (diff)
net: cdc_ncm: export NCM Transfer Block (NTB) parameters
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> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/usb')
-rw-r--r--drivers/net/usb/cdc_ncm.c30
1 files changed, 30 insertions, 0 deletions
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
260static DEVICE_ATTR(tx_max, S_IRUGO | S_IWUSR, cdc_ncm_show_tx_max, cdc_ncm_store_tx_max); 260static DEVICE_ATTR(tx_max, S_IRUGO | S_IWUSR, cdc_ncm_show_tx_max, cdc_ncm_store_tx_max);
261static DEVICE_ATTR(tx_timer_usecs, S_IRUGO | S_IWUSR, cdc_ncm_show_tx_timer_usecs, cdc_ncm_store_tx_timer_usecs); 261static DEVICE_ATTR(tx_timer_usecs, S_IRUGO | S_IWUSR, cdc_ncm_show_tx_timer_usecs, cdc_ncm_store_tx_timer_usecs);
262 262
263#define NCM_PARM_ATTR(name, format, tocpu) \
264static ssize_t cdc_ncm_show_##name(struct device *d, struct device_attribute *attr, char *buf) \
265{ \
266 struct usbnet *dev = netdev_priv(to_net_dev(d)); \
267 struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0]; \
268 return sprintf(buf, format "\n", tocpu(ctx->ncm_parm.name)); \
269} \
270static DEVICE_ATTR(name, S_IRUGO, cdc_ncm_show_##name, NULL)
271
272NCM_PARM_ATTR(bmNtbFormatsSupported, "0x%04x", le16_to_cpu);
273NCM_PARM_ATTR(dwNtbInMaxSize, "%u", le32_to_cpu);
274NCM_PARM_ATTR(wNdpInDivisor, "%u", le16_to_cpu);
275NCM_PARM_ATTR(wNdpInPayloadRemainder, "%u", le16_to_cpu);
276NCM_PARM_ATTR(wNdpInAlignment, "%u", le16_to_cpu);
277NCM_PARM_ATTR(dwNtbOutMaxSize, "%u", le32_to_cpu);
278NCM_PARM_ATTR(wNdpOutDivisor, "%u", le16_to_cpu);
279NCM_PARM_ATTR(wNdpOutPayloadRemainder, "%u", le16_to_cpu);
280NCM_PARM_ATTR(wNdpOutAlignment, "%u", le16_to_cpu);
281NCM_PARM_ATTR(wNtbOutMaxDatagrams, "%u", le16_to_cpu);
282
263static struct attribute *cdc_ncm_sysfs_attrs[] = { 283static struct attribute *cdc_ncm_sysfs_attrs[] = {
264 &dev_attr_rx_max.attr, 284 &dev_attr_rx_max.attr,
265 &dev_attr_tx_max.attr, 285 &dev_attr_tx_max.attr,
266 &dev_attr_tx_timer_usecs.attr, 286 &dev_attr_tx_timer_usecs.attr,
287 &dev_attr_bmNtbFormatsSupported.attr,
288 &dev_attr_dwNtbInMaxSize.attr,
289 &dev_attr_wNdpInDivisor.attr,
290 &dev_attr_wNdpInPayloadRemainder.attr,
291 &dev_attr_wNdpInAlignment.attr,
292 &dev_attr_dwNtbOutMaxSize.attr,
293 &dev_attr_wNdpOutDivisor.attr,
294 &dev_attr_wNdpOutPayloadRemainder.attr,
295 &dev_attr_wNdpOutAlignment.attr,
296 &dev_attr_wNtbOutMaxDatagrams.attr,
267 NULL, 297 NULL,
268}; 298};
269 299