From patchwork Tue Jun 12 07:34:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 10459525 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 63E4C601A0 for ; Tue, 12 Jun 2018 07:34:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 519EC28680 for ; Tue, 12 Jun 2018 07:34:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4167C28682; Tue, 12 Jun 2018 07:34:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B02128676 for ; Tue, 12 Jun 2018 07:34:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933248AbeFLHe3 (ORCPT ); Tue, 12 Jun 2018 03:34:29 -0400 Received: from mx2.suse.de ([195.135.220.15]:36542 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933242AbeFLHe2 (ORCPT ); Tue, 12 Jun 2018 03:34:28 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 906B9AE75; Tue, 12 Jun 2018 07:34:27 +0000 (UTC) From: Hannes Reinecke To: Moni Shoua Cc: Doug Ledford , Jason Gunthorpe , linux-rdma@vger.kernel.org, Johannes Thumshirn , Hannes Reinecke , Hannes Reinecke Subject: [PATCH 2/2] rxe: allow several interfaces to be specified for 'add' Date: Tue, 12 Jun 2018 09:34:20 +0200 Message-Id: <20180612073420.45736-3-hare@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180612073420.45736-1-hare@suse.de> References: <20180612073420.45736-1-hare@suse.de> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Allowing several interface (separated by whitespaces) to be specified when writing to the /sys/module/rdma_rxe/parameters/add sysfs attribute. Signed-off-by: Hannes Reinecke --- drivers/infiniband/sw/rxe/rxe_sysfs.c | 67 +++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 30 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_sysfs.c b/drivers/infiniband/sw/rxe/rxe_sysfs.c index bb54992e3ff2..eaf76f7c7472 100644 --- a/drivers/infiniband/sw/rxe/rxe_sysfs.c +++ b/drivers/infiniband/sw/rxe/rxe_sysfs.c @@ -71,9 +71,9 @@ static void rxe_set_port_state(struct net_device *ndev) static int rxe_param_set_add(const char *val, const struct kernel_param *kp) { - int len; int err = 0; - char intf[32]; + char **intf_argv = NULL; + int intf_argc, i; struct net_device *ndev = NULL; struct rxe_dev *rxe; @@ -82,38 +82,45 @@ static int rxe_param_set_add(const char *val, const struct kernel_param *kp) err = -EINVAL; goto err; } - len = sanitize_arg(val, intf, sizeof(intf)); - if (!len) { - pr_err("add: invalid interface name\n"); - err = -EINVAL; - goto err; - } - - ndev = dev_get_by_name(&init_net, intf); - if (!ndev) { - pr_err("interface %s not found\n", intf); - err = -EINVAL; - goto err; + intf_argv = argv_split(GFP_KERNEL, val, &intf_argc); + for (i = 0; i < intf_argc; i++) { + ndev = dev_get_by_name(&init_net, intf_argv[i]); + if (!ndev) { + pr_err("interface %s not found\n", intf_argv[i]); + err = -EINVAL; + goto err; + } + + if (net_to_rxe(ndev)) { + pr_err("already configured on %s\n", intf_argv[i]); + err = -EINVAL; + goto err; + } + + rxe = rxe_net_add(ndev); + if (!rxe) { + pr_err("failed to add %s\n", intf_argv[i]); + err = -EINVAL; + goto err; + } + + rxe_set_port_state(ndev); + pr_info("added %s to %s\n", rxe->ib_dev.name, intf_argv[i]); } - - if (net_to_rxe(ndev)) { - pr_err("already configured on %s\n", intf); - err = -EINVAL; - goto err; - } - - rxe = rxe_net_add(ndev); - if (!rxe) { - pr_err("failed to add %s\n", intf); - err = -EINVAL; - goto err; - } - - rxe_set_port_state(ndev); - pr_info("added %s to %s\n", rxe->ib_dev.name, intf); err: if (ndev) dev_put(ndev); + + if (intf_argv) { + for (i = 0; i < intf_argc; i++) { + rxe = get_rxe_by_name(intf_argv[i]); + if (rxe) { + list_del(&rxe->list); + rxe_remove(rxe); + } + } + argv_free(intf_argv); + } return err; }