]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
ip: add rmnet initial support
authorDaniele Palmas <dnlplm@gmail.com>
Fri, 15 Jun 2018 08:23:05 +0000 (10:23 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Fri, 15 Jun 2018 18:15:14 +0000 (11:15 -0700)
This patch adds basic support for Qualcomm rmnet devices.

Signed-off-by: Daniele Palmas <dnlplm@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
ip/Makefile
ip/iplink.c
ip/iplink_rmnet.c [new file with mode: 0644]
man/man8/ip-link.8.in

index 77fadeed2e62bda3d0cadf345ddb8bca56efc3e5..a88f93665ee6d5ef81199fc285a871eb0a24c6a1 100644 (file)
@@ -10,7 +10,7 @@ IPOBJ=ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o \
     link_iptnl.o link_gre6.o iplink_bond.o iplink_bond_slave.o iplink_hsr.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
+    ipvrf.o iplink_xstats.o ipseg6.o iplink_netdevsim.o iplink_rmnet.o
 
 RTMONOBJ=rtmon.o
 
index e4d4da96aedb0282d2dbe7fcda7b8412f2410190..0ba5f1af766974bccb80526910f15c27bb3f840b 100644 (file)
@@ -121,7 +121,7 @@ void iplink_usage(void)
                        "          bridge | bond | team | ipoib | ip6tnl | ipip | sit | vxlan |\n"
                        "          gre | gretap | erspan | ip6gre | ip6gretap | ip6erspan |\n"
                        "          vti | nlmon | team_slave | bond_slave | ipvlan | geneve |\n"
-                       "          bridge_slave | vrf | macsec | netdevsim }\n");
+                       "          bridge_slave | vrf | macsec | netdevsim | rmnet }\n");
        }
        exit(-1);
 }
diff --git a/ip/iplink_rmnet.c b/ip/iplink_rmnet.c
new file mode 100644 (file)
index 0000000..1d16440
--- /dev/null
@@ -0,0 +1,81 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * iplink_rmnet.c      RMNET device support
+ *
+ * Authors:     Daniele Palmas <dnlplm@gmail.com>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "utils.h"
+#include "ip_common.h"
+
+static void print_explain(FILE *f)
+{
+       fprintf(f,
+               "Usage: ... rmnet mux_id MUXID\n"
+               "\n"
+               "MUXID := 1-254\n"
+       );
+}
+
+static void explain(void)
+{
+       print_explain(stderr);
+}
+
+static int rmnet_parse_opt(struct link_util *lu, int argc, char **argv,
+                          struct nlmsghdr *n)
+{
+       __u16 mux_id;
+
+       while (argc > 0) {
+               if (matches(*argv, "mux_id") == 0) {
+                       NEXT_ARG();
+                       if (get_u16(&mux_id, *argv, 0))
+                               invarg("mux_id is invalid", *argv);
+                       addattr16(n, 1024, IFLA_RMNET_MUX_ID, mux_id);
+               } else if (matches(*argv, "help") == 0) {
+                       explain();
+                       return -1;
+               } else {
+                       fprintf(stderr, "rmnet: unknown command \"%s\"?\n", *argv);
+                       explain();
+                       return -1;
+               }
+               argc--, argv++;
+       }
+
+       return 0;
+}
+
+static void rmnet_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
+{
+       if (!tb)
+               return;
+
+       if (!tb[IFLA_RMNET_MUX_ID] ||
+           RTA_PAYLOAD(tb[IFLA_RMNET_MUX_ID]) < sizeof(__u16))
+               return;
+
+       print_uint(PRINT_ANY,
+                  "mux_id",
+                  "mux_id %u ",
+                  rta_getattr_u16(tb[IFLA_RMNET_MUX_ID]));
+}
+
+static void rmnet_print_help(struct link_util *lu, int argc, char **argv,
+                            FILE *f)
+{
+       print_explain(f);
+}
+
+struct link_util rmnet_link_util = {
+       .id             = "rmnet",
+       .maxattr        = IFLA_RMNET_MAX,
+       .parse_opt      = rmnet_parse_opt,
+       .print_opt      = rmnet_print_opt,
+       .print_help     = rmnet_print_help,
+};
index 83ef3cae54b97b4ee5446f09d582fb3b1af3cdda..fd2c1071c3314acebddb9a116fac38e0ce160d85 100644 (file)
@@ -219,7 +219,8 @@ ip-link \- network device configuration
 .BR geneve " |"
 .BR vrf " |"
 .BR macsec " |"
-.BR netdevsim " ]"
+.BR netdevsim " |"
+.BR rmnet " ]"
 
 .ti -8
 .IR ETYPE " := [ " TYPE " |"
@@ -342,6 +343,9 @@ Link types:
 .sp
 .BR netdevsim
 - Interface for netdev API tests
+.sp
+.BR rmnet
+- Qualcomm rmnet device
 .in -8
 
 .TP
@@ -1651,6 +1655,21 @@ the following additional arguments are supported:
 
 .in -8
 
+.TP
+RMNET Type Support
+For a link of type
+.I RMNET
+the following additional arguments are supported:
+
+.BI "ip link add link " DEVICE " name " NAME " type rmnet mux_id " MUXID
+
+.in +8
+.sp
+.BI mux_id " MUXID "
+- specifies the mux identifier for the rmnet device, possible values 1-254.
+
+.in -8
+
 .SS ip link delete - delete virtual link
 
 .TP