From patchwork Tue Dec 5 20:53:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Branden X-Patchwork-Id: 844935 X-Patchwork-Delegate: linville@tuxdriver.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@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; dkim=pass (1024-bit key; unprotected) header.d=broadcom.com header.i=@broadcom.com header.b="bobo7kOD"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yrv9Z1yWhz9sPm for ; Wed, 6 Dec 2017 07:53:54 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752212AbdLEUxw (ORCPT ); Tue, 5 Dec 2017 15:53:52 -0500 Received: from mail-qt0-f195.google.com ([209.85.216.195]:36506 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751416AbdLEUxp (ORCPT ); Tue, 5 Dec 2017 15:53:45 -0500 Received: by mail-qt0-f195.google.com with SMTP id a16so4100821qtj.3 for ; Tue, 05 Dec 2017 12:53:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yzLB7eHOp8mVwq90oYIr/4ZNYuQuV33Dh4dqJydMiy4=; b=bobo7kODIiE2V1KGJg5EFmoGPvI7gpevn641HumN+O1erXqAJ9cGKuOB+w/ym9ALJQ q1+/eN7FJ9WO0Ok5NYeF11av2VqP+PKYvWpRhs6ynG8ElIkZd4qaJ2U/iW0pVGMHRqRh O87N4XlG/d1rSQJJYCygr1AMbH9YK6eX+jNO8= 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:in-reply-to :references; bh=yzLB7eHOp8mVwq90oYIr/4ZNYuQuV33Dh4dqJydMiy4=; b=jZCxh3WH4LBMwNI1wqCoLoH4gFEZ43P+9nOzD8SYIlDIA328EKMsdqm+gOLZ5wTaQ/ h6UwjiofXUq4n9Ky42tw+tq5I0ADDcgosFssxPA3TKntTXK22s7sswC/WdYJTv9GesFa YusyKezlsBi7oFPXJdby8nXrNI55X7x4demWMVCINpeXWsWdfwKL501tWZIBOz838V56 8ioYQvzNFlL1gVbQ5K9ZzgxtOs3FDY5tAPdU4ywG1DbtyxWFcqjZstnj0jdOT+5mRMzE sO3Vj2OsNdMvFXNAiVft0hPGXk6VMGYTuJgmoZty0nPHmPzsc08/F9JW1pwQ1NwOkysp 9dRA== X-Gm-Message-State: AKGB3mJlAAxiaOMAG5RNSejASj0s2yy1fy/VYRKiNBIPQo4aqWxB59qM FK0zkKfm5cBP71C/YjjKtxMzDJ/m X-Google-Smtp-Source: AGs4zMbe+Wdn0hMLbQyvcM9n9E6jRKrnxgs5whU6jc+pVAZ2d/k9+Y93AGkrxy4LhiLvYv6DWFWVMw== X-Received: by 10.55.186.71 with SMTP id k68mr23759724qkf.58.1512507224854; Tue, 05 Dec 2017 12:53:44 -0800 (PST) Received: from lbrmn-lnxub113.ric.broadcom.com ([192.19.224.250]) by smtp.gmail.com with ESMTPSA id l9sm731104qkh.2.2017.12.05.12.53.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Dec 2017 12:53:44 -0800 (PST) From: Scott Branden To: "John W. Linville" Cc: BCM Kernel Feedback , Steve Lin , Michael Chan , netdev@vger.kernel.org, Paul Greenwalt , Stephen Hemminger , Scott Branden Subject: [PATCH v2 3/3] ethtool: Add ETHTOOL_RESET support via --reset command Date: Tue, 5 Dec 2017 12:53:23 -0800 Message-Id: <1512507203-17693-4-git-send-email-scott.branden@broadcom.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1512507203-17693-1-git-send-email-scott.branden@broadcom.com> References: <1512507203-17693-1-git-send-email-scott.branden@broadcom.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add ETHTOOL_RESET support via --reset command. ie. ethtool --reset DEVNAME flagnames currently match the ETH_RESET_xxx names: mgmt,irq,dma,filter,offload,mac,phy,ram,dedicated,all Alternatively, you can specific component bitfield directly using ethtool --reset DEVNAME flags %x Signed-off-by: Scott Branden --- ethtool.8.in | 58 +++++++++++++++++++++++++++++++++++++++++++++- ethtool.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+), 1 deletion(-) diff --git a/ethtool.8.in b/ethtool.8.in index 90ead41..e77ecd3 100644 --- a/ethtool.8.in +++ b/ethtool.8.in @@ -354,6 +354,21 @@ ethtool \- query or control network driver and hardware settings .B ethtool \-\-get\-phy\-tunable .I devname .RB [ downshift ] +.HP +.B ethtool \-\-reset +.I devname +.BN flags +.RB [ mgmt ] +.RB [ irq ] +.RB [ dma ] +.RB [ filter ] +.RB [ offload ] +.RB [ mac ] +.RB [ phy ] +.RB [ ram ] +.RB [ ap ] +.RB [ dedicated ] +.RB [ all ] . .\" Adjust lines (i.e. full justification) and hyphenate. .ad @@ -1006,6 +1021,46 @@ Downshift is useful where cable does not have the 4 pairs instance. Gets the PHY downshift count/status. .RE +.TP +.B \-\-reset +Reset hardware components specified by flags and components listed below +.RS 4 +.TP +.BI flags \ N +Resets the components based on direct flags mask +.TP +.B mgmt +Management processor +.TP +.B irq +Interrupt requester +.TP +.B dma +DMA engine +.TP +.B filter +Filtering/flow direction +.TP +.B offload +Protocol offload +.TP +.B mac +Media access controller +.TP +.B phy +Transceiver/PHY +.TP +.B ram +RAM shared between multiple components +.B ap +Application Processor +.TP +.B dedicated +All components dedicated to this interface +.TP +.B all +All components used by this interface, even if shared +.RE .SH BUGS Not supported (in part or whole) on all network drivers. .SH AUTHOR @@ -1023,7 +1078,8 @@ Andi Kleen, Alexander Duyck, Sucheta Chakraborty, Jesse Brandeburg, -Ben Hutchings. +Ben Hutchings, +Scott Branden. .SH AVAILABILITY .B ethtool is available from diff --git a/ethtool.c b/ethtool.c index c89b660..5bcf5d2 100644 --- a/ethtool.c +++ b/ethtool.c @@ -4636,6 +4636,68 @@ static int do_get_phy_tunable(struct cmd_context *ctx) return err; } +static int do_reset(struct cmd_context *ctx) +{ + struct ethtool_value resetinfo; + int argc = ctx->argc; + char **argp = ctx->argp; + int i; + + if (argc == 0) + exit_bad_args(); + + resetinfo.data = 0; + + for (i = 0; i < argc; i++) { + if (!strcmp(argp[i], "flags")) { + __u32 flags; + + i++; + if (i >= argc) + exit_bad_args(); + flags = strtoul(argp[i], NULL, 0); + if (flags == 0) + exit_bad_args(); + else + resetinfo.data |= flags; + } else if (!strcmp(argp[i], "mgmt")) { + resetinfo.data |= ETH_RESET_MGMT; + } else if (!strcmp(argp[i], "irq")) { + resetinfo.data |= ETH_RESET_IRQ; + } else if (!strcmp(argp[i], "dma")) { + resetinfo.data |= ETH_RESET_DMA; + } else if (!strcmp(argp[i], "filter")) { + resetinfo.data |= ETH_RESET_FILTER; + } else if (!strcmp(argp[i], "offload")) { + resetinfo.data |= ETH_RESET_OFFLOAD; + } else if (!strcmp(argp[i], "mac")) { + resetinfo.data |= ETH_RESET_MAC; + } else if (!strcmp(argp[i], "phy")) { + resetinfo.data |= ETH_RESET_PHY; + } else if (!strcmp(argp[i], "ram")) { + resetinfo.data |= ETH_RESET_RAM; + } else if (!strcmp(argp[i], "ap")) { + resetinfo.data |= ETH_RESET_AP; + } else if (!strcmp(argp[i], "dedicated")) { + resetinfo.data |= ETH_RESET_DEDICATED; + } else if (!strcmp(argp[i], "all")) { + resetinfo.data |= ETH_RESET_ALL; + } else { + exit_bad_args(); + } + } + + resetinfo.cmd = ETHTOOL_RESET; + + if (send_ioctl(ctx, &resetinfo)) { + perror("Cannot issue RESET"); + return 1; + } + fprintf(stdout, "RESET 0x%x issued\n", resetinfo.data); + + return 0; +} + static int parse_named_bool(struct cmd_context *ctx, const char *name, u8 *on) { if (ctx->argc < 2) @@ -4898,6 +4960,19 @@ static const struct option { " [ downshift on|off [count N] ]\n"}, { "--get-phy-tunable", 1, do_get_phy_tunable, "Get PHY tunable", " [ downshift ]\n"}, + { "--reset", 1, do_reset, "Reset components", + " [ flags %x ]\n" + " [ mgmt ]\n" + " [ irq ]\n" + " [ dma ]\n" + " [ filter ]\n" + " [ offload ]\n" + " [ mac ]\n" + " [ phy ]\n" + " [ ram ]\n" + " [ ap ]\n" + " [ dedicated ]\n" + " [ all ]\n"}, { "-h|--help", 0, show_usage, "Show this help" }, { "--version", 0, do_version, "Show version number" }, {}