Skip to content

Commit

Permalink
Merge branch 'net-usb-qmi_wwan-new-mux_id-sysfs-file'
Browse files Browse the repository at this point in the history
Daniele Palmas says:

====================
net: usb: qmi_wwan: new mux_id sysfs file

this patch series add a sysfs file to let userspace know which mux
id has been used to create a qmimux network interface.

I'm aware that adding new sysfs files is not usually the right path,
but my understanding is that this piece of information can't be
retrieved in any other way and its absence restricts how
userspace application (e.g. like libqmi) can take advantage of the
qmimux implementation in qmi_wwan.
====================

Link: https://lore.kernel.org/r/20210127153433.12237-1-dnlplm@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Jakub Kicinski committed Jan 29, 2021
2 parents d7a177e + b4b91e2 commit bbe25b7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Documentation/ABI/testing/sysfs-class-net-qmi
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,13 @@ Description:

Write a number ranging from 1 to 254 to delete a previously
created qmap mux based network device.

What: /sys/class/net/<qmimux iface>/qmap/mux_id
Date: January 2021
KernelVersion: 5.12
Contact: Daniele Palmas <dnlplm@gmail.com>
Description:
Unsigned integer

Indicates the mux id associated to the qmimux network interface
during its creation.
24 changes: 24 additions & 0 deletions drivers/net/usb/qmi_wwan.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,28 @@ static int qmimux_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
return 1;
}

static ssize_t mux_id_show(struct device *d, struct device_attribute *attr, char *buf)
{
struct net_device *dev = to_net_dev(d);
struct qmimux_priv *priv;

priv = netdev_priv(dev);

return sysfs_emit(buf, "0x%02x\n", priv->mux_id);
}

static DEVICE_ATTR_RO(mux_id);

static struct attribute *qmi_wwan_sysfs_qmimux_attrs[] = {
&dev_attr_mux_id.attr,
NULL,
};

static struct attribute_group qmi_wwan_sysfs_qmimux_attr_group = {
.name = "qmap",
.attrs = qmi_wwan_sysfs_qmimux_attrs,
};

static int qmimux_register_device(struct net_device *real_dev, u8 mux_id)
{
struct net_device *new_dev;
Expand All @@ -240,6 +262,8 @@ static int qmimux_register_device(struct net_device *real_dev, u8 mux_id)
goto out_free_newdev;
}

new_dev->sysfs_groups[0] = &qmi_wwan_sysfs_qmimux_attr_group;

err = register_netdevice(new_dev);
if (err < 0)
goto out_free_newdev;
Expand Down

0 comments on commit bbe25b7

Please sign in to comment.