From patchwork Fri Jun 15 08:23:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniele Palmas X-Patchwork-Id: 929825 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ox5cemTO"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 416YRJ4R7Dz9s29 for ; Fri, 15 Jun 2018 18:23:40 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755965AbeFOIXi (ORCPT ); Fri, 15 Jun 2018 04:23:38 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:34678 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755847AbeFOIXh (ORCPT ); Fri, 15 Jun 2018 04:23:37 -0400 Received: by mail-wm0-f67.google.com with SMTP id l15-v6so5877107wmc.1 for ; Fri, 15 Jun 2018 01:23:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=4NOkK+0nfpTtJ77eddzny2wtCCczvdphvHKKqSMqRlI=; b=ox5cemTOxDl0PL3DLy7ru7EZI0eUaQnNUer4IWV5f0OHQnLajA4E9imWpeNU66GUE/ gTU39gYgJIp9Hh6RT50YmRHZ+E0ohBtQfXdI5Vs0QnwjZ8YbQL0NusxYYFsq3RSb1UdB G4HBN+qLLBrHXSyhEX/lzEbFThoXD+WCTORmKq7b9zwli9sMl/k0EI7mlnMhckZpFU9I q33INIPpYWSUbrR7yt40qteCveJ1Fs2Q06Z2FLzTBpDvR+QC1kDyCJXGhGFLlagRs99U f5w6LwUPrrcpDT0UL/m+Hp0A+4AGxHkzTVVowPPpjCQfECfG22D30j0j7dcMN2z0R+83 Lu5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=4NOkK+0nfpTtJ77eddzny2wtCCczvdphvHKKqSMqRlI=; b=rDHyBffYtWxhWxxJE86dmOHkUnA8AsAyrwqqULAjMJhTlbXEQUPq8Msc6IjFiDlPCB XIe45czHTSVS9i5+GV8KoiWUiidtPshvWfP8F6W7lB/GRIMsqkzP8CoWkcGbIYFZg+16 JN8cEh+T6NWnETPAnUy0nWnFZ7wwm1fPCetzAZXbwyBftGCJ5WhbCKqurZWEauz61+80 TWmlGrjUbeII4jEBPv5bCbGP5PPFXWyelfHocXG6kIWLnJxUCyXoq8KQSlFRAFp16U/l PiDUrcHXOnbStsHal8tqmiOBSse2aG0E6lV/SVHhuDT1ySbh1jjyj7GaFs9L9+2VT3y2 riaw== X-Gm-Message-State: APt69E3u6cYV2hJ2k3iOB7u8I/q040Q3v8FWMB5agxg1kIk8thooumxF oLS+ajzoA1AInzBYEDQLi5AWYw== X-Google-Smtp-Source: ADUXVKJyE5a5oZ0kAC6JxyISgjSVZwG24JHcFKCNAI1wCPaqmhfA4wOpcfyQBi8O2vo/FvGt8Mw/pg== X-Received: by 2002:a1c:5e95:: with SMTP id s143-v6mr435970wmb.19.1529051015513; Fri, 15 Jun 2018 01:23:35 -0700 (PDT) Received: from L2122.tmt.telital.com (static-82-85-31-68.clienti.tiscali.it. [82.85.31.68]) by smtp.gmail.com with ESMTPSA id g4-v6sm5704537wrq.32.2018.06.15.01.23.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 15 Jun 2018 01:23:34 -0700 (PDT) From: Daniele Palmas To: netdev@vger.kernel.org, Stephen Hemminger Cc: Subash Abhinov Kasiviswanathan , Daniele Palmas Subject: [PATCH v2] ip: add rmnet initial support Date: Fri, 15 Jun 2018 10:23:05 +0200 Message-Id: <1529050985-17518-1-git-send-email-dnlplm@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch adds basic support for Qualcomm rmnet devices. Signed-off-by: Daniele Palmas --- v2: rebased on iproute2-next removed GPL boilerplate added print_opt function man page updated fixed MUXID values --- ip/Makefile | 2 +- ip/iplink.c | 2 +- ip/iplink_rmnet.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++ man/man8/ip-link.8.in | 21 ++++++++++++- 4 files changed, 103 insertions(+), 3 deletions(-) create mode 100644 ip/iplink_rmnet.c diff --git a/ip/Makefile b/ip/Makefile index 77fadee..a88f936 100644 --- a/ip/Makefile +++ b/ip/Makefile @@ -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 diff --git a/ip/iplink.c b/ip/iplink.c index e4d4da9..0ba5f1a 100644 --- a/ip/iplink.c +++ b/ip/iplink.c @@ -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 index 0000000..1d16440 --- /dev/null +++ b/ip/iplink_rmnet.c @@ -0,0 +1,81 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * iplink_rmnet.c RMNET device support + * + * Authors: Daniele Palmas + */ + +#include +#include +#include + +#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, +}; diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in index 83ef3ca..fd2c107 100644 --- a/man/man8/ip-link.8.in +++ b/man/man8/ip-link.8.in @@ -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