* [PATCH iproute2-next v2 0/2] ip: wwan links management support
@ 2021-06-22 23:52 Sergey Ryazanov
  2021-06-22 23:52 ` [PATCH iproute2-next v2 1/2] iplink: add support for parent device Sergey Ryazanov
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sergey Ryazanov @ 2021-06-22 23:52 UTC (permalink / raw)
  To: David Ahern, Stephen Hemminger; +Cc: netdev, Loic Poulain
This short series introduces support for WWAN links  support.
First patch adds support for new common attributes: parent device name
and parent device bus name. The former attribute required to create a
new WWAN link. Finally, the second patch introduces support for a new
'wwan' link type.
Changelong:
  v1 -> v2
    * shorten the 'parentdevbus' parameter to 'parentbus', as Parav
      suggested and Loic recalled
  RFC -> v1
    * drop the kernel headers update patch
    * add a parent device bus attribute support
    * shorten the 'parentdev-name' parameter to just 'parentdev'
Sergey Ryazanov (2):
  iplink: add support for parent device
  iplink: support for WWAN devices
 ip/Makefile      |  2 +-
 ip/ipaddress.c   | 14 ++++++++++
 ip/iplink.c      |  9 ++++--
 ip/iplink_wwan.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 94 insertions(+), 3 deletions(-)
 create mode 100644 ip/iplink_wwan.c
-- 
2.26.3
^ permalink raw reply	[flat|nested] 4+ messages in thread
* [PATCH iproute2-next v2 1/2] iplink: add support for parent device
  2021-06-22 23:52 [PATCH iproute2-next v2 0/2] ip: wwan links management support Sergey Ryazanov
@ 2021-06-22 23:52 ` Sergey Ryazanov
  2021-06-22 23:52 ` [PATCH iproute2-next v2 2/2] iplink: support for WWAN devices Sergey Ryazanov
  2021-06-26  4:41 ` [PATCH iproute2-next v2 0/2] ip: wwan links management support David Ahern
  2 siblings, 0 replies; 4+ messages in thread
From: Sergey Ryazanov @ 2021-06-22 23:52 UTC (permalink / raw)
  To: David Ahern, Stephen Hemminger; +Cc: netdev, Loic Poulain
Add support for specifying a parent device (struct device) by its name
during the link creation and printing parent name in the links list.
This option will be used to create WWAN links and possibly by other
device classes that do not have a "natural parent netdev".
Add the parent device bus name printing for links list info
completeness. But do not add a corresponding command line argument, as
we do not have a use case for this attribute.
Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
---
Changes since v1:
* shorten the 'parentdevbus' parameter to 'parentbus', as Parav
  suggested and Loic recalled
Changes since RFC:
* add a parent device bus attribute support
* shorten the 'parentdev-name' parameter to just 'parentdev'
 ip/ipaddress.c | 14 ++++++++++++++
 ip/iplink.c    |  6 +++++-
 2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 06ca7273..85534aaf 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -1242,6 +1242,20 @@ int print_linkinfo(struct nlmsghdr *n, void *arg)
 						   RTA_PAYLOAD(tb[IFLA_PHYS_SWITCH_ID]),
 						   b1, sizeof(b1)));
 		}
+
+		if (tb[IFLA_PARENT_DEV_BUS_NAME]) {
+			print_string(PRINT_ANY,
+				     "parentbus",
+				     "parentbus %s ",
+				     rta_getattr_str(tb[IFLA_PARENT_DEV_BUS_NAME]));
+		}
+
+		if (tb[IFLA_PARENT_DEV_NAME]) {
+			print_string(PRINT_ANY,
+				     "parentdev",
+				     "parentdev %s ",
+				     rta_getattr_str(tb[IFLA_PARENT_DEV_NAME]));
+		}
 	}
 
 	if ((do_link || show_details) && tb[IFLA_IFALIAS]) {
diff --git a/ip/iplink.c b/ip/iplink.c
index faafd7e8..33b7be30 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -63,7 +63,7 @@ void iplink_usage(void)
 {
 	if (iplink_have_newlink()) {
 		fprintf(stderr,
-			"Usage: ip link add [link DEV] [ name ] NAME\n"
+			"Usage: ip link add [link DEV | parentdev NAME] [ name ] NAME\n"
 			"		    [ txqueuelen PACKETS ]\n"
 			"		    [ address LLADDR ]\n"
 			"		    [ broadcast LLADDR ]\n"
@@ -938,6 +938,10 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req, char **type)
 				       *argv);
 			addattr32(&req->n, sizeof(*req),
 				  IFLA_GSO_MAX_SEGS, max_segs);
+		} else if (strcmp(*argv, "parentdev") == 0) {
+			NEXT_ARG();
+			addattr_l(&req->n, sizeof(*req), IFLA_PARENT_DEV_NAME,
+				  *argv, strlen(*argv) + 1);
 		} else {
 			if (matches(*argv, "help") == 0)
 				usage();
-- 
2.26.3
^ permalink raw reply related	[flat|nested] 4+ messages in thread
* [PATCH iproute2-next v2 2/2] iplink: support for WWAN devices
  2021-06-22 23:52 [PATCH iproute2-next v2 0/2] ip: wwan links management support Sergey Ryazanov
  2021-06-22 23:52 ` [PATCH iproute2-next v2 1/2] iplink: add support for parent device Sergey Ryazanov
@ 2021-06-22 23:52 ` Sergey Ryazanov
  2021-06-26  4:41 ` [PATCH iproute2-next v2 0/2] ip: wwan links management support David Ahern
  2 siblings, 0 replies; 4+ messages in thread
From: Sergey Ryazanov @ 2021-06-22 23:52 UTC (permalink / raw)
  To: David Ahern, Stephen Hemminger; +Cc: netdev, Loic Poulain
The WWAN subsystem has been extended to generalize the per data channel
network interfaces management. This change implements support for WWAN
links handling. And actively uses the earlier introduced ip-link
capability to specify the parent by its device name.
The WWAN interface for a new data channel should be created with a
command like this:
ip link add dev wwan0-2 parentdev wwan0 type wwan linkid 2
Where: wwan0 is the modem HW device name (should be taken from
/sys/class/wwan) and linkid is an identifier of the opened data
channel.
Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
---
To compile this, a new uapi/linux/wwan.h header file should be copied
from the kernel sources.
Changes since v1:
* no changes
Changes since RFC:
* no changes
 ip/Makefile      |  2 +-
 ip/iplink.c      |  3 +-
 ip/iplink_wwan.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 75 insertions(+), 2 deletions(-)
 create mode 100644 ip/iplink_wwan.c
diff --git a/ip/Makefile b/ip/Makefile
index 4cad619c..b03af29b 100644
--- a/ip/Makefile
+++ b/ip/Makefile
@@ -11,7 +11,7 @@ IPOBJ=ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o \
     iplink_bridge.o iplink_bridge_slave.o ipfou.o iplink_ipvlan.o \
     iplink_geneve.o iplink_vrf.o iproute_lwtunnel.o ipmacsec.o ipila.o \
     ipvrf.o iplink_xstats.o ipseg6.o iplink_netdevsim.o iplink_rmnet.o \
-    ipnexthop.o ipmptcp.o iplink_bareudp.o
+    ipnexthop.o ipmptcp.o iplink_bareudp.o iplink_wwan.o
 
 RTMONOBJ=rtmon.o
 
diff --git a/ip/iplink.c b/ip/iplink.c
index 33b7be30..18b2ea25 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -56,7 +56,8 @@ void iplink_types_usage(void)
 		"          ipip | ipoib | ipvlan | ipvtap |\n"
 		"          macsec | macvlan | macvtap |\n"
 		"          netdevsim | nlmon | rmnet | sit | team | team_slave |\n"
-		"          vcan | veth | vlan | vrf | vti | vxcan | vxlan | xfrm }\n");
+		"          vcan | veth | vlan | vrf | vti | vxcan | vxlan | wwan |\n"
+		"          xfrm }\n");
 }
 
 void iplink_usage(void)
diff --git a/ip/iplink_wwan.c b/ip/iplink_wwan.c
new file mode 100644
index 00000000..3510477a
--- /dev/null
+++ b/ip/iplink_wwan.c
@@ -0,0 +1,72 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#include <stdio.h>
+#include <linux/netlink.h>
+#include <linux/wwan.h>
+
+#include "utils.h"
+#include "ip_common.h"
+
+static void print_explain(FILE *f)
+{
+	fprintf(f,
+		"Usage: ... wwan linkid LINKID\n"
+		"\n"
+		"Where: LINKID := 0-4294967295\n"
+	);
+}
+
+static void explain(void)
+{
+	print_explain(stderr);
+}
+
+static int wwan_parse_opt(struct link_util *lu, int argc, char **argv,
+			  struct nlmsghdr *n)
+{
+	while (argc > 0) {
+		if (matches(*argv, "linkid") == 0) {
+			__u32 linkid;
+
+			NEXT_ARG();
+			if (get_u32(&linkid, *argv, 0))
+				invarg("linkid", *argv);
+			addattr32(n, 1024, IFLA_WWAN_LINK_ID, linkid);
+		} else if (matches(*argv, "help") == 0) {
+			explain();
+			return -1;
+		} else {
+			fprintf(stderr, "wwan: unknown command \"%s\"?\n",
+				*argv);
+			explain();
+			return -1;
+		}
+		argc--, argv++;
+	}
+
+	return 0;
+}
+
+static void wwan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
+{
+	if (!tb)
+		return;
+
+	if (tb[IFLA_WWAN_LINK_ID])
+		print_uint(PRINT_ANY, "linkid", "linkid %u ",
+			   rta_getattr_u32(tb[IFLA_WWAN_LINK_ID]));
+}
+
+static void wwan_print_help(struct link_util *lu, int argc, char **argv,
+			    FILE *f)
+{
+	print_explain(f);
+}
+
+struct link_util wwan_link_util = {
+	.id		= "wwan",
+	.maxattr	= IFLA_WWAN_MAX,
+	.parse_opt	= wwan_parse_opt,
+	.print_opt	= wwan_print_opt,
+	.print_help	= wwan_print_help,
+};
-- 
2.26.3
^ permalink raw reply related	[flat|nested] 4+ messages in thread
* Re: [PATCH iproute2-next v2 0/2] ip: wwan links management support
  2021-06-22 23:52 [PATCH iproute2-next v2 0/2] ip: wwan links management support Sergey Ryazanov
  2021-06-22 23:52 ` [PATCH iproute2-next v2 1/2] iplink: add support for parent device Sergey Ryazanov
  2021-06-22 23:52 ` [PATCH iproute2-next v2 2/2] iplink: support for WWAN devices Sergey Ryazanov
@ 2021-06-26  4:41 ` David Ahern
  2 siblings, 0 replies; 4+ messages in thread
From: David Ahern @ 2021-06-26  4:41 UTC (permalink / raw)
  To: Sergey Ryazanov, Stephen Hemminger; +Cc: netdev, Loic Poulain
On 6/22/21 5:52 PM, Sergey Ryazanov wrote:
> This short series introduces support for WWAN links  support.
> 
> First patch adds support for new common attributes: parent device name
> and parent device bus name. The former attribute required to create a
> new WWAN link. Finally, the second patch introduces support for a new
> 'wwan' link type.
> 
> Changelong:
>   v1 -> v2
>     * shorten the 'parentdevbus' parameter to 'parentbus', as Parav
>       suggested and Loic recalled
>   RFC -> v1
>     * drop the kernel headers update patch
>     * add a parent device bus attribute support
>     * shorten the 'parentdev-name' parameter to just 'parentdev'
> 
> Sergey Ryazanov (2):
>   iplink: add support for parent device
>   iplink: support for WWAN devices
> 
>  ip/Makefile      |  2 +-
>  ip/ipaddress.c   | 14 ++++++++++
>  ip/iplink.c      |  9 ++++--
>  ip/iplink_wwan.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 94 insertions(+), 3 deletions(-)
>  create mode 100644 ip/iplink_wwan.c
> 
applied to iproute2-next. Thanks,
^ permalink raw reply	[flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-06-26  4:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-22 23:52 [PATCH iproute2-next v2 0/2] ip: wwan links management support Sergey Ryazanov
2021-06-22 23:52 ` [PATCH iproute2-next v2 1/2] iplink: add support for parent device Sergey Ryazanov
2021-06-22 23:52 ` [PATCH iproute2-next v2 2/2] iplink: support for WWAN devices Sergey Ryazanov
2021-06-26  4:41 ` [PATCH iproute2-next v2 0/2] ip: wwan links management support David Ahern
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).