Received: by 10.213.65.68 with SMTP id h4csp364583imn; Tue, 13 Mar 2018 06:53:57 -0700 (PDT) X-Google-Smtp-Source: AG47ELvR4z5Isq9FVvZSaG1ErMNDN9puQ4nlRUBciJzGAMHAnQoLLgpQ0KW6r9KUC7JRSOXusSOn X-Received: by 10.98.19.21 with SMTP id b21mr706921pfj.236.1520949237201; Tue, 13 Mar 2018 06:53:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520949237; cv=none; d=google.com; s=arc-20160816; b=0kNjWYvit6tBH0X3DEEnLUYIa+L+ziBqY/+gc9fdYiDCtXYCbVGPAceFvCbh/KrsTe W5/ge3YRutF3/VliBPa3+2SaPy4CzVm4z9ChjSElFIwyf/andwtNzHsz2CPlHzMxzPsx H47mYNWdcducPK473X2uv4lIlXL49TNeLWRhlvinK46DBOkmZx1cRxTlZ42hroHhaWID VBwf4CRT2KQjdA8tbOgvladnyNCt+X2qJNWVu3liIK/Nb0W3LSXN301BSVtD+pAA01Xg fhoXX0achC6X7T0Wcxa05WI9bplpDK461iKMGOI+nRqc5fegMYua9DnJbe2TZ4NOIRQZ XxhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:arc-authentication-results; bh=BbCLVwVmk7VGdsv7OJ2hBKKdr/YyLqlnvhKtdJEEpJ0=; b=06vVhRIizl/KeGZAhLY3t2GjkLH9hK0ioIoXwfuFCaR7WBBvlzPm1Xj/lFPK+eUpc/ TrZ19CEqZxyxMqbsoxkBNj12q3PinTZwd/Ai7lBHYklQFcSVkFmJPWsJQLs2D4uOun56 z7bo48lUhGoX23jqXxQ5OVNkEIjT/Uvnj95hEamK9bASQ3mvHvn5BlHpcwhN3t+Goinh kpKs8sF5+YESjJf5xzE4MtKIYCdDMNFujqV9Kos13s45PiPpL/ZfXDyzET0sKxoagXID ix9OmjQ0EsEQSsVIc0j0Hldw1+sornhngA6rCmTQfbYMX1vgUv1t1uCBY1OG9cpYBXks rgdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector1 header.b=u8wh27uf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e3-v6si177616plb.100.2018.03.13.06.53.42; Tue, 13 Mar 2018 06:53:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector1 header.b=u8wh27uf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753160AbeCMNwd (ORCPT + 99 others); Tue, 13 Mar 2018 09:52:33 -0400 Received: from mail-he1eur01on0082.outbound.protection.outlook.com ([104.47.0.82]:52000 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753133AbeCMNwZ (ORCPT ); Tue, 13 Mar 2018 09:52:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=BbCLVwVmk7VGdsv7OJ2hBKKdr/YyLqlnvhKtdJEEpJ0=; b=u8wh27ufcKuC3L9WQx0mUo9oIcKiQZ50hKXcJrUUze3mp4ROiGSGUs67lJN1vMyFQzD08R2eNdl6Imn3iyS81Xn8aqdVK3DC/UofT/wPQlopC4Lw7gFp1jrwIhII4hNNyFq+imrYrqBYlcMj+A/v/nSoGHxgScGS+WHCSJ+JwBU= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=razvan.stefanescu@nxp.com; Received: from rhuath.am.freescale.net (192.88.168.1) by DB3PR04MB0747.eurprd04.prod.outlook.com (2a01:111:e400:9440::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.567.14; Tue, 13 Mar 2018 13:52:15 +0000 From: Razvan Stefanescu To: gregkh@linuxfoundation.org Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, agraf@suse.de, arnd@arndb.de, alexandru.marginean@nxp.com, ruxandra.radulescu@nxp.com, ioana.ciornei@nxp.com, laurentiu.tudor@nxp.com, stuyoder@gmail.com Subject: [PATCH v5 3/6] staging: fsl-dpaa2/ethsw: Add ethtool support Date: Tue, 13 Mar 2018 08:51:53 -0500 Message-Id: <20180313135156.3322-4-razvan.stefanescu@nxp.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180313135156.3322-1-razvan.stefanescu@nxp.com> References: <20180313135156.3322-1-razvan.stefanescu@nxp.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [192.88.168.1] X-ClientProxiedBy: DM3PR12CA0069.namprd12.prod.outlook.com (2603:10b6:0:57::13) To DB3PR04MB0747.eurprd04.prod.outlook.com (2a01:111:e400:9440::15) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: a5e536fd-3ef0-488c-ba19-08d588e9a217 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020);SRVR:DB3PR04MB0747; X-Microsoft-Exchange-Diagnostics: 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bD5KBJCmxuJHp4bOSiZtMgNlM/rVoHtGbZAC2+gar+qTaepp8doEbqGVbldXPu7l7ND3xZdlcHmYEMSuw3bg3OAGOHma2IbBjlbtiJU76GjfoLD8V2W1kZjsc3VB6EzzrFuifKWlQwgbJ2Mpo7HW9/BET1WRgoKkUnVCayVeooN1ypGnr0/eKYf1NYiEIX87h7GF1hgRY//cs6w8kazxg1+WF4Fnw1RMFNawV1GAr1iDRUHVMMHxrS6j+1M5QIsLE8hg0OVEACs1Mu1UTF5XH8MKduxZHEkzI+L23PJT57MTDx/tEDV3UTKOtyKF1Rfff8hUpmCxRe5pjOZDHs64cEA+T+x4txlF6V8inyWbqjcRLdBAR9Ah9tlYmk0ifRltQL8JVuweXR6b380Dqr9Z2706I;4:KH67xYEAT36IoM2FdmFJqF4+3rGTxOlur+dgY6kAN03NokPMRkn9myUebO9xicc7hDXTG1x0uxI3keMv+E8ujM1iOV7BKCN6xAP/qxc2G5cmL9tJ4+eVyYhvuLEjts2mUdCP9FpZeIIGowOyW/GDFIJveR9ddCHgMj+fGAPk0zoiJYZ7iMf298HTvM4am2hdFWWZss0KNdf8E/3Lwk0ByAIJQzg8mrszAUxvXZyirgJkl/6A4bLkQG7cn6Ew2uR9S0ONhHICywv9g1YONRyhQIuwS1GMSK/7QVgkY3pFci4x6GQb3uWkaAsHvypPh2l3myV6jSORBMon+6jFN1ZRAEAaZb6KRgWyj9qO9bUsp2Y= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(275809806118684); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3231221)(944501244)(52105095)(3002001)(6055026)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123564045)(20161123558120)(6072148)(201708071742011);SRVR:DB3PR04MB0747;BCL:0;PCL:0;RULEID:;SRVR:DB3PR04MB0747; X-Forefront-PRVS: 0610D16BBE X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(376002)(39380400002)(366004)(39860400002)(346002)(396003)(54534003)(189003)(199004)(1076002)(16526019)(186003)(6916009)(5660300001)(478600001)(50466002)(48376002)(3846002)(6116002)(8676002)(47776003)(6666003)(26005)(2906002)(7736002)(81156014)(2950100002)(66066001)(575784001)(81166006)(6506007)(59450400001)(305945005)(76176011)(386003)(25786009)(50226002)(52116002)(86362001)(8936002)(316002)(16586007)(39060400002)(36756003)(51416003)(106356001)(68736007)(6486002)(53936002)(2351001)(2361001)(4326008)(6512007)(97736004)(105586002)(2004002);DIR:OUT;SFP:1101;SCL:1;SRVR:DB3PR04MB0747;H:rhuath.am.freescale.net;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DB3PR04MB0747;23:GXs926Cpb1yngQnbBwsP41i7EVV+6DmrnaJoPzK/L?= =?us-ascii?Q?SLb3blzJQOX+Bj1DZZKddkhxtgwbBz6VdUUoOTtATBYu9tZR7VultkFRlcbB?= =?us-ascii?Q?wXiyaQF/z+sI6WpqUtxZpR7KDdyKRecq4Oer1QNJtovzQAv3mwUIir/CgVEY?= =?us-ascii?Q?7QQWr3gfiVMyMvMfUev60RVBfo2eOLgcknj+0FfV4yFe7G6S7RCTdFBwSRH+?= =?us-ascii?Q?DHxVHpIRIvBMPAsmxLmXiwF3/f6+uTiqKOioGObmi6aK1oRtk8y9++ggWvGi?= =?us-ascii?Q?T9kIt9Cv54n1R6yII7nAgFB/xfBStAsEKQy6x1x3wd1+f2wdMpBM5I4uj+0t?= =?us-ascii?Q?zjUUJMB7Xs6mw3vOG7Uvx57PQWIkJpkwuJf8CvhLkoEPyBSRN+pZ4zfcDedX?= =?us-ascii?Q?Gkz8MDgHcC5YzQ/mLRrZnv89VttE0SJUy0qQvJ9siADN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asOYZvfPO4c+9mB1Ty5s1PNUmeZXyldQE4xCgTr/tc7/hK SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Mar 2018 13:52:15.0857 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a5e536fd-3ef0-488c-ba19-08d588e9a217 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR04MB0747 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add driver information, link details and hardware statistics to be reported via ethtool -S. Signed-off-by: Razvan Stefanescu --- Changelog: v2: - no changes v3: - removed driver version v4: - no changes v5: - no changes drivers/staging/fsl-dpaa2/ethsw/Makefile | 2 +- drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h | 13 ++ drivers/staging/fsl-dpaa2/ethsw/dpsw.c | 32 ++++ drivers/staging/fsl-dpaa2/ethsw/dpsw.h | 32 ++++ drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c | 206 ++++++++++++++++++++++++ drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 1 + drivers/staging/fsl-dpaa2/ethsw/ethsw.h | 2 + 7 files changed, 287 insertions(+), 1 deletion(-) create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c diff --git a/drivers/staging/fsl-dpaa2/ethsw/Makefile b/drivers/staging/fsl-dpaa2/ethsw/Makefile index a6d72d1..de92cd9 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/Makefile +++ b/drivers/staging/fsl-dpaa2/ethsw/Makefile @@ -4,4 +4,4 @@ obj-$(CONFIG_FSL_DPAA2_ETHSW) += dpaa2-ethsw.o -dpaa2-ethsw-objs := ethsw.o dpsw.o +dpaa2-ethsw-objs := ethsw.o ethsw-ethtool.o dpsw.o diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h index 36edef6..c45f001 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h +++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h @@ -74,6 +74,8 @@ #define DPSW_CMDID_IF_SET_FLOODING DPSW_CMD_ID(0x047) #define DPSW_CMDID_IF_SET_BROADCAST DPSW_CMD_ID(0x048) +#define DPSW_CMDID_IF_SET_LINK_CFG DPSW_CMD_ID(0x04C) + #define DPSW_CMDID_VLAN_ADD DPSW_CMD_ID(0x060) #define DPSW_CMDID_VLAN_ADD_IF DPSW_CMD_ID(0x061) #define DPSW_CMDID_VLAN_ADD_IF_UNTAGGED DPSW_CMD_ID(0x062) @@ -262,6 +264,17 @@ struct dpsw_cmd_if_set_max_frame_length { __le16 frame_length; }; +struct dpsw_cmd_if_set_link_cfg { + /* cmd word 0 */ + __le16 if_id; + u8 pad[6]; + /* cmd word 1 */ + __le32 rate; + __le32 pad1; + /* cmd word 2 */ + __le64 options; +}; + struct dpsw_cmd_if_get_link_state { __le16 if_id; }; diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw.c b/drivers/staging/fsl-dpaa2/ethsw/dpsw.c index 8e52d74..e63531d 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/dpsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw.c @@ -383,6 +383,38 @@ int dpsw_get_attributes(struct fsl_mc_io *mc_io, } /** + * dpsw_if_set_link_cfg() - Set the link configuration. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPSW object + * @if_id: Interface id + * @cfg: Link configuration + * + * Return: '0' on Success; Error code otherwise. + */ +int dpsw_if_set_link_cfg(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token, + u16 if_id, + struct dpsw_link_cfg *cfg) +{ + struct mc_command cmd = { 0 }; + struct dpsw_cmd_if_set_link_cfg *cmd_params; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_LINK_CFG, + cmd_flags, + token); + cmd_params = (struct dpsw_cmd_if_set_link_cfg *)cmd.params; + cmd_params->if_id = cpu_to_le16(if_id); + cmd_params->rate = cpu_to_le32(cfg->rate); + cmd_params->options = cpu_to_le64(cfg->options); + + /* send command to mc*/ + return mc_send_command(mc_io, &cmd); +} + +/** * dpsw_if_get_link_state - Return the link state * @mc_io: Pointer to MC portal's I/O object * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw.h b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h index d13970c..5a0c7ad 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/dpsw.h +++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h @@ -245,6 +245,38 @@ enum dpsw_action { }; /** + * Enable auto-negotiation + */ +#define DPSW_LINK_OPT_AUTONEG 0x0000000000000001ULL +/** + * Enable half-duplex mode + */ +#define DPSW_LINK_OPT_HALF_DUPLEX 0x0000000000000002ULL +/** + * Enable pause frames + */ +#define DPSW_LINK_OPT_PAUSE 0x0000000000000004ULL +/** + * Enable a-symmetric pause frames + */ +#define DPSW_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL + +/** + * struct dpsw_link_cfg - Structure representing DPSW link configuration + * @rate: Rate + * @options: Mask of available options; use 'DPSW_LINK_OPT_' values + */ +struct dpsw_link_cfg { + u32 rate; + u64 options; +}; + +int dpsw_if_set_link_cfg(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token, + u16 if_id, + struct dpsw_link_cfg *cfg); +/** * struct dpsw_link_state - Structure representing DPSW link state * @rate: Rate * @options: Mask of available options; use 'DPSW_LINK_OPT_' values diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c new file mode 100644 index 0000000..2853105 --- /dev/null +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c @@ -0,0 +1,206 @@ +/* Copyright 2014-2016 Freescale Semiconductor Inc. + * Copyright 2017-2018 NXP + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the above-listed copyright holders nor the + * names of any contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * + * ALTERNATIVELY, this software may be distributed under the terms of the + * GNU General Public License ("GPL") as published by the Free Software + * Foundation, either version 2 of that License or (at your option) any + * later version. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "ethsw.h" + +static struct { + enum dpsw_counter id; + char name[ETH_GSTRING_LEN]; +} ethsw_ethtool_counters[] = { + {DPSW_CNT_ING_FRAME, "rx frames"}, + {DPSW_CNT_ING_BYTE, "rx bytes"}, + {DPSW_CNT_ING_FLTR_FRAME, "rx filtered frames"}, + {DPSW_CNT_ING_FRAME_DISCARD, "rx discarded frames"}, + {DPSW_CNT_ING_BCAST_FRAME, "rx b-cast frames"}, + {DPSW_CNT_ING_BCAST_BYTES, "rx b-cast bytes"}, + {DPSW_CNT_ING_MCAST_FRAME, "rx m-cast frames"}, + {DPSW_CNT_ING_MCAST_BYTE, "rx m-cast bytes"}, + {DPSW_CNT_EGR_FRAME, "tx frames"}, + {DPSW_CNT_EGR_BYTE, "tx bytes"}, + {DPSW_CNT_EGR_FRAME_DISCARD, "tx discarded frames"}, + +}; + +#define ETHSW_NUM_COUNTERS ARRAY_SIZE(ethsw_ethtool_counters) + +static void ethsw_get_drvinfo(struct net_device *netdev, + struct ethtool_drvinfo *drvinfo) +{ + struct ethsw_port_priv *port_priv = netdev_priv(netdev); + u16 version_major, version_minor; + int err; + + strlcpy(drvinfo->driver, KBUILD_MODNAME, sizeof(drvinfo->driver)); + + err = dpsw_get_api_version(port_priv->ethsw_data->mc_io, 0, + &version_major, + &version_minor); + if (err) + strlcpy(drvinfo->fw_version, "N/A", + sizeof(drvinfo->fw_version)); + else + snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), + "%u.%u", version_major, version_minor); + + strlcpy(drvinfo->bus_info, dev_name(netdev->dev.parent->parent), + sizeof(drvinfo->bus_info)); +} + +static int +ethsw_get_link_ksettings(struct net_device *netdev, + struct ethtool_link_ksettings *link_ksettings) +{ + struct ethsw_port_priv *port_priv = netdev_priv(netdev); + struct dpsw_link_state state = {0}; + int err = 0; + + err = dpsw_if_get_link_state(port_priv->ethsw_data->mc_io, 0, + port_priv->ethsw_data->dpsw_handle, + port_priv->idx, + &state); + if (err) { + netdev_err(netdev, "ERROR %d getting link state", err); + goto out; + } + + /* At the moment, we have no way of interrogating the DPMAC + * from the DPSW side or there may not exist a DPMAC at all. + * Report only autoneg state, duplexity and speed. + */ + if (state.options & DPSW_LINK_OPT_AUTONEG) + link_ksettings->base.autoneg = AUTONEG_ENABLE; + if (!(state.options & DPSW_LINK_OPT_HALF_DUPLEX)) + link_ksettings->base.duplex = DUPLEX_FULL; + link_ksettings->base.speed = state.rate; + +out: + return err; +} + +static int +ethsw_set_link_ksettings(struct net_device *netdev, + const struct ethtool_link_ksettings *link_ksettings) +{ + struct ethsw_port_priv *port_priv = netdev_priv(netdev); + struct dpsw_link_cfg cfg = {0}; + int err = 0; + + netdev_dbg(netdev, "Setting link parameters..."); + + /* Due to a temporary MC limitation, the DPSW port must be down + * in order to be able to change link settings. Taking steps to let + * the user know that. + */ + if (netif_running(netdev)) { + netdev_info(netdev, "Sorry, interface must be brought down first.\n"); + return -EACCES; + } + + cfg.rate = link_ksettings->base.speed; + if (link_ksettings->base.autoneg == AUTONEG_ENABLE) + cfg.options |= DPSW_LINK_OPT_AUTONEG; + else + cfg.options &= ~DPSW_LINK_OPT_AUTONEG; + if (link_ksettings->base.duplex == DUPLEX_HALF) + cfg.options |= DPSW_LINK_OPT_HALF_DUPLEX; + else + cfg.options &= ~DPSW_LINK_OPT_HALF_DUPLEX; + + err = dpsw_if_set_link_cfg(port_priv->ethsw_data->mc_io, 0, + port_priv->ethsw_data->dpsw_handle, + port_priv->idx, + &cfg); + if (err) + /* ethtool will be loud enough if we return an error; no point + * in putting our own error message on the console by default + */ + netdev_dbg(netdev, "ERROR %d setting link cfg", err); + + return err; +} + +static int ethsw_ethtool_get_sset_count(struct net_device *dev, int sset) +{ + switch (sset) { + case ETH_SS_STATS: + return ETHSW_NUM_COUNTERS; + default: + return -EOPNOTSUPP; + } +} + +static void ethsw_ethtool_get_strings(struct net_device *netdev, + u32 stringset, u8 *data) +{ + int i; + + switch (stringset) { + case ETH_SS_STATS: + for (i = 0; i < ETHSW_NUM_COUNTERS; i++) + memcpy(data + i * ETH_GSTRING_LEN, + ethsw_ethtool_counters[i].name, ETH_GSTRING_LEN); + break; + } +} + +static void ethsw_ethtool_get_stats(struct net_device *netdev, + struct ethtool_stats *stats, + u64 *data) +{ + struct ethsw_port_priv *port_priv = netdev_priv(netdev); + int i, err; + + memset(data, 0, + sizeof(u64) * ETHSW_NUM_COUNTERS); + + for (i = 0; i < ETHSW_NUM_COUNTERS; i++) { + err = dpsw_if_get_counter(port_priv->ethsw_data->mc_io, 0, + port_priv->ethsw_data->dpsw_handle, + port_priv->idx, + ethsw_ethtool_counters[i].id, + &data[i]); + if (err) + netdev_err(netdev, "dpsw_if_get_counter[%s] err %d\n", + ethsw_ethtool_counters[i].name, err); + } +} + +const struct ethtool_ops ethsw_port_ethtool_ops = { + .get_drvinfo = ethsw_get_drvinfo, + .get_link = ethtool_op_get_link, + .get_link_ksettings = ethsw_get_link_ksettings, + .set_link_ksettings = ethsw_set_link_ksettings, + .get_strings = ethsw_ethtool_get_strings, + .get_ethtool_stats = ethsw_ethtool_get_stats, + .get_sset_count = ethsw_ethtool_get_sset_count, +}; diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index 2127037..f410671 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -1400,6 +1400,7 @@ static int ethsw_probe_port(struct ethsw_core *ethsw, u16 port_idx) SET_NETDEV_DEV(port_netdev, dev); port_netdev->netdev_ops = ðsw_port_ops; + port_netdev->ethtool_ops = ðsw_port_ethtool_ops; port_netdev->switchdev_ops = ðsw_port_switchdev_ops; /* Set MTU limits */ diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.h b/drivers/staging/fsl-dpaa2/ethsw/ethsw.h index e4d5ac8..03139e8 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.h +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.h @@ -57,6 +57,8 @@ #define ETHSW_MAX_FRAME_LENGTH (DPAA2_MFL - VLAN_ETH_HLEN - ETH_FCS_LEN) #define ETHSW_L2_MAX_FRM(mtu) ((mtu) + VLAN_ETH_HLEN + ETH_FCS_LEN) +extern const struct ethtool_ops ethsw_port_ethtool_ops; + struct ethsw_core; /* Per port private data */ -- 1.9.1