From patchwork Tue Mar 30 02:16:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Grundler X-Patchwork-Id: 12171433 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A49FC433E1 for ; Tue, 30 Mar 2021 02:18:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0CB66619B1 for ; Tue, 30 Mar 2021 02:18:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231187AbhC3CSF (ORCPT ); Mon, 29 Mar 2021 22:18:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230418AbhC3CR4 (ORCPT ); Mon, 29 Mar 2021 22:17:56 -0400 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2D29C061762 for ; Mon, 29 Mar 2021 19:17:55 -0700 (PDT) Received: by mail-qk1-x72b.google.com with SMTP id v70so14525788qkb.8 for ; Mon, 29 Mar 2021 19:17:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=V+WEIPsEAGA7jwvYy6qQleq6biy6Etghzkh4svXjlzI=; b=mxbrMN0KUGYxWEwnuqf7m43QXjYnDDjx9RHSHF366hBPMip6E2rMj1d4OP0kNepxXn je5w2E1GzeyNfBx4tySOGJdflPL9gj3yAf1rP+o0EHeyXkBZmDuBq1x1k98OYwDujMQn NC5ROKgjnz6+w6qg45L6kIbnvgFzWjwTzggOA= 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:mime-version:content-transfer-encoding; bh=V+WEIPsEAGA7jwvYy6qQleq6biy6Etghzkh4svXjlzI=; b=gTdbmhMzNINRFRfFbTjKYZ/leO3ySRSMUO3jGjDWvhbtiz1APEHiRd1l3dCrbwUsK8 GBzD/TgT+mFIxrt291TT+lJx0v20anZMNZ5Gj+dcdAj7yTtqWq4ddO7cm9SxYgqHfKtA H28wDDglXwg0YzGPOAmkMCcclv0AsfTjLblyP+4nLnAyuO65XKgqaaw3EMIuhs6ZP8Jk 88TN08a1a/9AbXWfoXH+TC1RPy5bZP3fAOSt8mtqrnrHzR3TAGklwZwXVwOex5IsG7o7 OKpnG3jx2sZtwWkw+8E0KUVLgGlgjthuPlauZ2rtzXNuatydjziU5p3m+4c/CRzVLZfr 88nQ== X-Gm-Message-State: AOAM532BXo3CWdF0ueHsNj7qvsY0ALwNrS1QjaO7uD2gb0Q+e2yhfJcj HZ+y4SnhFMuYV+f3cKtGfC/eCw== X-Google-Smtp-Source: ABdhPJxRnUy9QDa1LT3bSLnnKFUd9Yg1R6EZAXA80fzqjMLlJqaGUmYG1m94hIjc1YAgtkSt6r72BQ== X-Received: by 2002:a05:620a:15eb:: with SMTP id p11mr27697293qkm.454.1617070675110; Mon, 29 Mar 2021 19:17:55 -0700 (PDT) Received: from grundler-glapstation.lan ([70.134.62.80]) by smtp.gmail.com with ESMTPSA id j30sm12433067qtv.90.2021.03.29.19.17.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Mar 2021 19:17:54 -0700 (PDT) From: Grant Grundler To: Oliver Neukum , Jakub Kicinski Cc: Roland Dreier , nic_swsd , netdev , "David S . Miller" , LKML , Andrew Lunn , Grant Grundler Subject: [PATCHv4 1/4] usbnet: add _mii suffix to usbnet_set/get_link_ksettings Date: Mon, 29 Mar 2021 19:16:48 -0700 Message-Id: <20210330021651.30906-2-grundler@chromium.org> X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog In-Reply-To: <20210330021651.30906-1-grundler@chromium.org> References: <20210330021651.30906-1-grundler@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Oliver Neukum The generic functions assumed devices provided an MDIO interface (accessed via older mii code, not phylib). This is true only for genuine ethernet. Devices with a higher level of abstraction or based on different technologies do not have MDIO. To support this case, first rename the existing functions with _mii suffix. v2: rebased on changed upstream v3: changed names to clearly say that this does NOT use phylib v4: moved hunks to correct patch; reworded commmit messages Signed-off-by : Oliver Neukum Tested-by: Roland Dreier Reviewed-by: Grant Grundler Tested-by: Grant Grundler Reviewed-by: Andrew Lunn --- drivers/net/usb/asix_devices.c | 12 ++++++------ drivers/net/usb/cdc_ncm.c | 4 ++-- drivers/net/usb/dm9601.c | 4 ++-- drivers/net/usb/mcs7830.c | 4 ++-- drivers/net/usb/sierra_net.c | 4 ++-- drivers/net/usb/smsc75xx.c | 4 ++-- drivers/net/usb/sr9700.c | 4 ++-- drivers/net/usb/sr9800.c | 4 ++-- drivers/net/usb/usbnet.c | 15 +++++++++------ include/linux/usb/usbnet.h | 4 ++-- 10 files changed, 31 insertions(+), 28 deletions(-) I'm reposting this with corrections to "misplaced" patch hunks that I pointed out on Feb 19. Code otherwise should be the same and Oliver Neukum should be listed as author in git. diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c index 6e13d8165852..19a8fafb8f04 100644 --- a/drivers/net/usb/asix_devices.c +++ b/drivers/net/usb/asix_devices.c @@ -125,8 +125,8 @@ static const struct ethtool_ops ax88172_ethtool_ops = { .get_eeprom = asix_get_eeprom, .set_eeprom = asix_set_eeprom, .nway_reset = usbnet_nway_reset, - .get_link_ksettings = usbnet_get_link_ksettings, - .set_link_ksettings = usbnet_set_link_ksettings, + .get_link_ksettings = usbnet_get_link_ksettings_mii, + .set_link_ksettings = usbnet_set_link_ksettings_mii, }; static void ax88172_set_multicast(struct net_device *net) @@ -291,8 +291,8 @@ static const struct ethtool_ops ax88772_ethtool_ops = { .get_eeprom = asix_get_eeprom, .set_eeprom = asix_set_eeprom, .nway_reset = usbnet_nway_reset, - .get_link_ksettings = usbnet_get_link_ksettings, - .set_link_ksettings = usbnet_set_link_ksettings, + .get_link_ksettings = usbnet_get_link_ksettings_mii, + .set_link_ksettings = usbnet_set_link_ksettings_mii, }; static int ax88772_link_reset(struct usbnet *dev) @@ -782,8 +782,8 @@ static const struct ethtool_ops ax88178_ethtool_ops = { .get_eeprom = asix_get_eeprom, .set_eeprom = asix_set_eeprom, .nway_reset = usbnet_nway_reset, - .get_link_ksettings = usbnet_get_link_ksettings, - .set_link_ksettings = usbnet_set_link_ksettings, + .get_link_ksettings = usbnet_get_link_ksettings_mii, + .set_link_ksettings = usbnet_set_link_ksettings_mii, }; static int marvell_phy_init(struct usbnet *dev) diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c index 8acf30115428..2644234d4c4d 100644 --- a/drivers/net/usb/cdc_ncm.c +++ b/drivers/net/usb/cdc_ncm.c @@ -142,8 +142,8 @@ static const struct ethtool_ops cdc_ncm_ethtool_ops = { .get_sset_count = cdc_ncm_get_sset_count, .get_strings = cdc_ncm_get_strings, .get_ethtool_stats = cdc_ncm_get_ethtool_stats, - .get_link_ksettings = usbnet_get_link_ksettings, - .set_link_ksettings = usbnet_set_link_ksettings, + .get_link_ksettings = usbnet_get_link_ksettings_mii, + .set_link_ksettings = usbnet_set_link_ksettings_mii, }; static u32 cdc_ncm_check_rx_max(struct usbnet *dev, u32 new_rx) diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c index b5d2ac55a874..89cc61d7a675 100644 --- a/drivers/net/usb/dm9601.c +++ b/drivers/net/usb/dm9601.c @@ -282,8 +282,8 @@ static const struct ethtool_ops dm9601_ethtool_ops = { .get_eeprom_len = dm9601_get_eeprom_len, .get_eeprom = dm9601_get_eeprom, .nway_reset = usbnet_nway_reset, - .get_link_ksettings = usbnet_get_link_ksettings, - .set_link_ksettings = usbnet_set_link_ksettings, + .get_link_ksettings = usbnet_get_link_ksettings_mii, + .set_link_ksettings = usbnet_set_link_ksettings_mii, }; static void dm9601_set_multicast(struct net_device *net) diff --git a/drivers/net/usb/mcs7830.c b/drivers/net/usb/mcs7830.c index fc512b780d15..9f9352a4522f 100644 --- a/drivers/net/usb/mcs7830.c +++ b/drivers/net/usb/mcs7830.c @@ -452,8 +452,8 @@ static const struct ethtool_ops mcs7830_ethtool_ops = { .get_msglevel = usbnet_get_msglevel, .set_msglevel = usbnet_set_msglevel, .nway_reset = usbnet_nway_reset, - .get_link_ksettings = usbnet_get_link_ksettings, - .set_link_ksettings = usbnet_set_link_ksettings, + .get_link_ksettings = usbnet_get_link_ksettings_mii, + .set_link_ksettings = usbnet_set_link_ksettings_mii, }; static const struct net_device_ops mcs7830_netdev_ops = { diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c index 55a244eca5ca..55025202dc4f 100644 --- a/drivers/net/usb/sierra_net.c +++ b/drivers/net/usb/sierra_net.c @@ -629,8 +629,8 @@ static const struct ethtool_ops sierra_net_ethtool_ops = { .get_msglevel = usbnet_get_msglevel, .set_msglevel = usbnet_set_msglevel, .nway_reset = usbnet_nway_reset, - .get_link_ksettings = usbnet_get_link_ksettings, - .set_link_ksettings = usbnet_set_link_ksettings, + .get_link_ksettings = usbnet_get_link_ksettings_mii, + .set_link_ksettings = usbnet_set_link_ksettings_mii, }; static int sierra_net_get_fw_attr(struct usbnet *dev, u16 *datap) diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c index 4353b370249f..f8cdabb9ef5a 100644 --- a/drivers/net/usb/smsc75xx.c +++ b/drivers/net/usb/smsc75xx.c @@ -741,8 +741,8 @@ static const struct ethtool_ops smsc75xx_ethtool_ops = { .set_eeprom = smsc75xx_ethtool_set_eeprom, .get_wol = smsc75xx_ethtool_get_wol, .set_wol = smsc75xx_ethtool_set_wol, - .get_link_ksettings = usbnet_get_link_ksettings, - .set_link_ksettings = usbnet_set_link_ksettings, + .get_link_ksettings = usbnet_get_link_ksettings_mii, + .set_link_ksettings = usbnet_set_link_ksettings_mii, }; static int smsc75xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd) diff --git a/drivers/net/usb/sr9700.c b/drivers/net/usb/sr9700.c index 878557ad03ad..ce29261263cd 100644 --- a/drivers/net/usb/sr9700.c +++ b/drivers/net/usb/sr9700.c @@ -250,8 +250,8 @@ static const struct ethtool_ops sr9700_ethtool_ops = { .get_eeprom_len = sr9700_get_eeprom_len, .get_eeprom = sr9700_get_eeprom, .nway_reset = usbnet_nway_reset, - .get_link_ksettings = usbnet_get_link_ksettings, - .set_link_ksettings = usbnet_set_link_ksettings, + .get_link_ksettings = usbnet_get_link_ksettings_mii, + .set_link_ksettings = usbnet_set_link_ksettings_mii, }; static void sr9700_set_multicast(struct net_device *netdev) diff --git a/drivers/net/usb/sr9800.c b/drivers/net/usb/sr9800.c index da56735d7755..a822d81310d5 100644 --- a/drivers/net/usb/sr9800.c +++ b/drivers/net/usb/sr9800.c @@ -527,8 +527,8 @@ static const struct ethtool_ops sr9800_ethtool_ops = { .get_eeprom_len = sr_get_eeprom_len, .get_eeprom = sr_get_eeprom, .nway_reset = usbnet_nway_reset, - .get_link_ksettings = usbnet_get_link_ksettings, - .set_link_ksettings = usbnet_set_link_ksettings, + .get_link_ksettings = usbnet_get_link_ksettings_mii, + .set_link_ksettings = usbnet_set_link_ksettings_mii, }; static int sr9800_link_reset(struct usbnet *dev) diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index f4f37ecfed58..5b4629c80b4b 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c @@ -944,7 +944,10 @@ EXPORT_SYMBOL_GPL(usbnet_open); * they'll probably want to use this base set. */ -int usbnet_get_link_ksettings(struct net_device *net, +/* These methods are written on the assumption that the device + * uses MII + */ +int usbnet_get_link_ksettings_mii(struct net_device *net, struct ethtool_link_ksettings *cmd) { struct usbnet *dev = netdev_priv(net); @@ -956,9 +959,9 @@ int usbnet_get_link_ksettings(struct net_device *net, return 0; } -EXPORT_SYMBOL_GPL(usbnet_get_link_ksettings); +EXPORT_SYMBOL_GPL(usbnet_get_link_ksettings_mii); -int usbnet_set_link_ksettings(struct net_device *net, +int usbnet_set_link_ksettings_mii(struct net_device *net, const struct ethtool_link_ksettings *cmd) { struct usbnet *dev = netdev_priv(net); @@ -978,7 +981,7 @@ int usbnet_set_link_ksettings(struct net_device *net, return retval; } -EXPORT_SYMBOL_GPL(usbnet_set_link_ksettings); +EXPORT_SYMBOL_GPL(usbnet_set_link_ksettings_mii); u32 usbnet_get_link (struct net_device *net) { @@ -1043,8 +1046,8 @@ static const struct ethtool_ops usbnet_ethtool_ops = { .get_msglevel = usbnet_get_msglevel, .set_msglevel = usbnet_set_msglevel, .get_ts_info = ethtool_op_get_ts_info, - .get_link_ksettings = usbnet_get_link_ksettings, - .set_link_ksettings = usbnet_set_link_ksettings, + .get_link_ksettings = usbnet_get_link_ksettings_mii, + .set_link_ksettings = usbnet_set_link_ksettings_mii, }; /*-------------------------------------------------------------------------*/ diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h index cfbfd6fe01df..a89e1452107d 100644 --- a/include/linux/usb/usbnet.h +++ b/include/linux/usb/usbnet.h @@ -267,9 +267,9 @@ extern void usbnet_pause_rx(struct usbnet *); extern void usbnet_resume_rx(struct usbnet *); extern void usbnet_purge_paused_rxq(struct usbnet *); -extern int usbnet_get_link_ksettings(struct net_device *net, +extern int usbnet_get_link_ksettings_mii(struct net_device *net, struct ethtool_link_ksettings *cmd); -extern int usbnet_set_link_ksettings(struct net_device *net, +extern int usbnet_set_link_ksettings_mii(struct net_device *net, const struct ethtool_link_ksettings *cmd); extern u32 usbnet_get_link(struct net_device *net); extern u32 usbnet_get_msglevel(struct net_device *); From patchwork Tue Mar 30 02:16:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Grundler X-Patchwork-Id: 12171435 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E3D2C433E4 for ; Tue, 30 Mar 2021 02:18:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3C24061989 for ; Tue, 30 Mar 2021 02:18:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230220AbhC3CSG (ORCPT ); Mon, 29 Mar 2021 22:18:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230446AbhC3CR5 (ORCPT ); Mon, 29 Mar 2021 22:17:57 -0400 Received: from mail-qk1-x735.google.com (mail-qk1-x735.google.com [IPv6:2607:f8b0:4864:20::735]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24CBAC061762 for ; Mon, 29 Mar 2021 19:17:57 -0700 (PDT) Received: by mail-qk1-x735.google.com with SMTP id c3so14521759qkc.5 for ; Mon, 29 Mar 2021 19:17:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BrKJq+y1GuzRwfKPTCvE+h8pj1S9+lGN2zn6+F+gTD0=; b=RgaXnkoyiz9Kv5mSthUwx7jaTmw5Cd2y2v4qktPE7hSXwUEaK5vdu5ZiTXzOWIGHx+ /8nzbhOL6BMJIk93RQmgi0mb4+TKNGWtkHXy8uX5jeHwQJrpjLbDLD1NGQdmggEa59pH 7JxTAukmP7UO6pj8zoSvmzgw1+2E5uHfriags= 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:mime-version:content-transfer-encoding; bh=BrKJq+y1GuzRwfKPTCvE+h8pj1S9+lGN2zn6+F+gTD0=; b=B94zI03dL0YxgWGn2/eGuyDMavw8naJsMZWDEugi6Yp9W5e3TDNSe9KEZ6f2G4DdZ/ j0gAM1J2wL43NACTrfOYBwx7wYi0DUSOwq+i+SNB82OWtAYOTRQnOA/VXzrtJfcrEj5Q 5Mmsgn948kBw6yU6gbW5LDPoMlLZge3CeQpeSob3lsj1ea56vF5ROFL81r4cGGBSjdXD QhYJJ42HH696At9ufZ+b/qDNETgFO7YEyPyQuEfss8jmO3+OiAbB9HQVjUO8KM8zR5Xa 7hF070iDHBwWCqlzCg3Cb4YMuIs/bxIMWvYnDaRsrVNPDUEBDIgnwMuCCWrQysrkTs6B azVw== X-Gm-Message-State: AOAM531oGAapt+yZwaevZU/9x2gIsgAQN02e+T836e7dpjeFbxp5ITRB sOvtqOv0eClSLzV+IIryG+H9jw== X-Google-Smtp-Source: ABdhPJzjBf4u008tnjanJIgqSreQm2rbNiVZJTlGJVO3M99eOIY6v7OeOT5y3zcmeOTT77jgUOTchQ== X-Received: by 2002:a05:620a:a8b:: with SMTP id v11mr27007279qkg.414.1617070676435; Mon, 29 Mar 2021 19:17:56 -0700 (PDT) Received: from grundler-glapstation.lan ([70.134.62.80]) by smtp.gmail.com with ESMTPSA id j30sm12433067qtv.90.2021.03.29.19.17.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Mar 2021 19:17:56 -0700 (PDT) From: Grant Grundler To: Oliver Neukum , Jakub Kicinski Cc: Roland Dreier , nic_swsd , netdev , "David S . Miller" , LKML , Andrew Lunn , Grant Grundler Subject: [PATCHv4 2/4] usbnet: add method for reporting speed without MII Date: Mon, 29 Mar 2021 19:16:49 -0700 Message-Id: <20210330021651.30906-3-grundler@chromium.org> X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog In-Reply-To: <20210330021651.30906-1-grundler@chromium.org> References: <20210330021651.30906-1-grundler@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Oliver Neukum The old method for reporting link speed assumed a driver uses the generic phy (mii) MDIO read/write functions. CDC devices don't expose the phy. Add a primitive internal version reporting back directly what the CDC notification/status operations recorded. v2: rebased on upstream v3: changed names and made clear which units are used v4: moved hunks to correct patch; rewrote commmit messages Signed-off-by: Oliver Neukum Tested-by: Roland Dreier Reviewed-by: Grant Grundler Tested-by: Grant Grundler Reviewed-by: Andrew Lunn --- drivers/net/usb/usbnet.c | 23 +++++++++++++++++++++++ include/linux/usb/usbnet.h | 7 +++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index 5b4629c80b4b..ecf62849f4c1 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c @@ -961,6 +961,27 @@ int usbnet_get_link_ksettings_mii(struct net_device *net, } EXPORT_SYMBOL_GPL(usbnet_get_link_ksettings_mii); +int usbnet_get_link_ksettings_internal(struct net_device *net, + struct ethtool_link_ksettings *cmd) +{ + struct usbnet *dev = netdev_priv(net); + + /* the assumption that speed is equal on tx and rx + * is deeply engrained into the networking layer. + * For wireless stuff it is not true. + * We assume that rx_speed matters more. + */ + if (dev->rx_speed != SPEED_UNSET) + cmd->base.speed = dev->rx_speed / 1000000; + else if (dev->tx_speed != SPEED_UNSET) + cmd->base.speed = dev->tx_speed / 1000000; + else + cmd->base.speed = SPEED_UNKNOWN; + + return 0; +} +EXPORT_SYMBOL_GPL(usbnet_get_link_ksettings_internal); + int usbnet_set_link_ksettings_mii(struct net_device *net, const struct ethtool_link_ksettings *cmd) { @@ -1664,6 +1685,8 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) dev->intf = udev; dev->driver_info = info; dev->driver_name = name; + dev->rx_speed = SPEED_UNSET; + dev->tx_speed = SPEED_UNSET; net->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); if (!net->tstats) diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h index a89e1452107d..8336e86ce606 100644 --- a/include/linux/usb/usbnet.h +++ b/include/linux/usb/usbnet.h @@ -53,6 +53,9 @@ struct usbnet { u32 hard_mtu; /* count any extra framing */ size_t rx_urb_size; /* size for rx urbs */ struct mii_if_info mii; + long rx_speed; /* If MII not used */ + long tx_speed; /* If MII not used */ +# define SPEED_UNSET -1 /* various kinds of pending driver work */ struct sk_buff_head rxq; @@ -81,8 +84,6 @@ struct usbnet { # define EVENT_LINK_CHANGE 11 # define EVENT_SET_RX_MODE 12 # define EVENT_NO_IP_ALIGN 13 - u32 rx_speed; /* in bps - NOT Mbps */ - u32 tx_speed; /* in bps - NOT Mbps */ }; static inline struct usb_driver *driver_of(struct usb_interface *intf) @@ -271,6 +272,8 @@ extern int usbnet_get_link_ksettings_mii(struct net_device *net, struct ethtool_link_ksettings *cmd); extern int usbnet_set_link_ksettings_mii(struct net_device *net, const struct ethtool_link_ksettings *cmd); +extern int usbnet_get_link_ksettings_internal(struct net_device *net, + struct ethtool_link_ksettings *cmd); extern u32 usbnet_get_link(struct net_device *net); extern u32 usbnet_get_msglevel(struct net_device *); extern void usbnet_set_msglevel(struct net_device *, u32); From patchwork Tue Mar 30 02:16:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Grundler X-Patchwork-Id: 12171437 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91916C433E6 for ; Tue, 30 Mar 2021 02:18:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 743D76198F for ; Tue, 30 Mar 2021 02:18:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231237AbhC3CSH (ORCPT ); Mon, 29 Mar 2021 22:18:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230462AbhC3CR6 (ORCPT ); Mon, 29 Mar 2021 22:17:58 -0400 Received: from mail-qt1-x82c.google.com (mail-qt1-x82c.google.com [IPv6:2607:f8b0:4864:20::82c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81244C061764 for ; Mon, 29 Mar 2021 19:17:58 -0700 (PDT) Received: by mail-qt1-x82c.google.com with SMTP id l6so2681486qtq.2 for ; Mon, 29 Mar 2021 19:17:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hfYowgsr4uNI8/wsCDuMmBZBG9pfXasTMUWU2D2WnMU=; b=Fpok5B3efPngrcb9OB7UF0W2xEmhgvC1P3AEJN1pNP1LqctR8Hm4HB4H6pUn77LQtk YhSnGJWFsOq+/3NHja875Fd5kxS8iYNdYzhW8j3XyBxDuwIqG0eVuoKs4WGNcAXWdvih 2LCiSuQVAp2jUpYuak19luHf3um9jnLXEGmsQ= 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:mime-version:content-transfer-encoding; bh=hfYowgsr4uNI8/wsCDuMmBZBG9pfXasTMUWU2D2WnMU=; b=ENNCIqbsgWGET9HDoGngdbMaqS7scySh5lNKLWG1KJ12hBDIovuzrCUeLpTp3n32ZD ZQvPSGyL5EHLKEemHN1ciwRFYH6OjN9ciknBHADAPl2zLMl38eTsE7ZyDyIMcIyBLWat C52jrfIY34TdxvdHp/PEUjxAUX5TRtzcu9+jn4lH3nVKpzgOaHnte+7L34aIJ11WbQLa zcK4JUBT53kf8t2FquK8Eqsmg7QHTxuvmGc1ucwyFVGAc+oyrPfCjHNyVzsZRaCbi+zG ZGNN+W/8wzAHUper0m6gkM3ArXGt2hMRNJvH73fDz/GE+vWv4hbFonGxmO8SCaPU6pZy +w7g== X-Gm-Message-State: AOAM531wIJI2JQkmd1YWKF858ARkZwTBixZrCjRklHGAlncFD4nvkpZ4 voM57RoFbXxqtQVhzf6GCA/hpA== X-Google-Smtp-Source: ABdhPJyQxenxvd0BMvAs3kNjM9RRmdwlDKs2dpfBBBxKxZitdCS+cmSPv4O+ezdi+SA+nt1+q2qPow== X-Received: by 2002:aed:33a4:: with SMTP id v33mr25218790qtd.324.1617070677761; Mon, 29 Mar 2021 19:17:57 -0700 (PDT) Received: from grundler-glapstation.lan ([70.134.62.80]) by smtp.gmail.com with ESMTPSA id j30sm12433067qtv.90.2021.03.29.19.17.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Mar 2021 19:17:57 -0700 (PDT) From: Grant Grundler To: Oliver Neukum , Jakub Kicinski Cc: Roland Dreier , nic_swsd , netdev , "David S . Miller" , LKML , Andrew Lunn , Grant Grundler Subject: [PATCHv4 3/4] net: cdc_ncm: record speed in status method Date: Mon, 29 Mar 2021 19:16:50 -0700 Message-Id: <20210330021651.30906-4-grundler@chromium.org> X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog In-Reply-To: <20210330021651.30906-1-grundler@chromium.org> References: <20210330021651.30906-1-grundler@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Oliver Neukum Until very recently, the usbnet framework only had support functions for devices which reported the link speed by explicitly querying the PHY over a MDIO interface. However, the cdc_ncm devices send notifications when the link state or link speeds change and do not expose the PHY (or modem) directly. Support funtions (e.g. usbnet_get_link_ksettings_internal()) to directly query state recorded by the cdc_ncm driver were added in a previous patch. So instead of cdc_ncm spewing the link speed into the dmesg buffer, record the link speed encoded in these notifications and tell the usbnet framework to use the new functions to get link speed/state. Link speed/state is now available via ethtool. This is especially useful given all current RTL8156 devices emit a connection/speed status notification every 32ms and this would fill the dmesg buffer. This implementation replaces the one recently submitted in de658a195ee23ca6aaffe197d1d2ea040beea0a2 : "net: usb: cdc_ncm: don't spew notifications" v2: rebased on upstream v3: changed variable names v4: rewrote commit message Signed-off-by: Oliver Neukum Tested-by: Roland Dreier Signed-off-by: Grant Grundler Reviewed-by: Andrew Lunn --- drivers/net/usb/cdc_ncm.c | 55 ++++++++++++--------------------------- 1 file changed, 17 insertions(+), 38 deletions(-) diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c index 2644234d4c4d..6f330c7dcad2 100644 --- a/drivers/net/usb/cdc_ncm.c +++ b/drivers/net/usb/cdc_ncm.c @@ -133,17 +133,17 @@ static void cdc_ncm_get_strings(struct net_device __always_unused *netdev, u32 s static void cdc_ncm_update_rxtx_max(struct usbnet *dev, u32 new_rx, u32 new_tx); static const struct ethtool_ops cdc_ncm_ethtool_ops = { - .get_link = usbnet_get_link, - .nway_reset = usbnet_nway_reset, - .get_drvinfo = usbnet_get_drvinfo, - .get_msglevel = usbnet_get_msglevel, - .set_msglevel = usbnet_set_msglevel, - .get_ts_info = ethtool_op_get_ts_info, - .get_sset_count = cdc_ncm_get_sset_count, - .get_strings = cdc_ncm_get_strings, - .get_ethtool_stats = cdc_ncm_get_ethtool_stats, - .get_link_ksettings = usbnet_get_link_ksettings_mii, - .set_link_ksettings = usbnet_set_link_ksettings_mii, + .get_link = usbnet_get_link, + .nway_reset = usbnet_nway_reset, + .get_drvinfo = usbnet_get_drvinfo, + .get_msglevel = usbnet_get_msglevel, + .set_msglevel = usbnet_set_msglevel, + .get_ts_info = ethtool_op_get_ts_info, + .get_sset_count = cdc_ncm_get_sset_count, + .get_strings = cdc_ncm_get_strings, + .get_ethtool_stats = cdc_ncm_get_ethtool_stats, + .get_link_ksettings = usbnet_get_link_ksettings_internal, + .set_link_ksettings = NULL, }; static u32 cdc_ncm_check_rx_max(struct usbnet *dev, u32 new_rx) @@ -1826,33 +1826,9 @@ static void cdc_ncm_speed_change(struct usbnet *dev, struct usb_cdc_speed_change *data) { - uint32_t rx_speed = le32_to_cpu(data->DLBitRRate); - uint32_t tx_speed = le32_to_cpu(data->ULBitRate); - - /* if the speed hasn't changed, don't report it. - * RTL8156 shipped before 2021 sends notification about every 32ms. - */ - if (dev->rx_speed == rx_speed && dev->tx_speed == tx_speed) - return; - - dev->rx_speed = rx_speed; - dev->tx_speed = tx_speed; - - /* - * Currently the USB-NET API does not support reporting the actual - * device speed. Do print it instead. - */ - if ((tx_speed > 1000000) && (rx_speed > 1000000)) { - netif_info(dev, link, dev->net, - "%u mbit/s downlink %u mbit/s uplink\n", - (unsigned int)(rx_speed / 1000000U), - (unsigned int)(tx_speed / 1000000U)); - } else { - netif_info(dev, link, dev->net, - "%u kbit/s downlink %u kbit/s uplink\n", - (unsigned int)(rx_speed / 1000U), - (unsigned int)(tx_speed / 1000U)); - } + /* RTL8156 shipped before 2021 sends notification about every 32ms. */ + dev->rx_speed = le32_to_cpu(data->DLBitRRate); + dev->tx_speed = le32_to_cpu(data->ULBitRate); } static void cdc_ncm_status(struct usbnet *dev, struct urb *urb) @@ -1878,6 +1854,9 @@ static void cdc_ncm_status(struct usbnet *dev, struct urb *urb) * USB_CDC_NOTIFY_NETWORK_CONNECTION notification shall be * sent by device after USB_CDC_NOTIFY_SPEED_CHANGE. */ + /* RTL8156 shipped before 2021 sends notification about + * every 32ms. Don't forward notification if state is same. + */ if (netif_carrier_ok(dev->net) != !!event->wValue) usbnet_link_change(dev, !!event->wValue, 0); break; From patchwork Tue Mar 30 02:16:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Grundler X-Patchwork-Id: 12171439 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C024CC433E9 for ; Tue, 30 Mar 2021 02:18:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A6CAF6198F for ; Tue, 30 Mar 2021 02:18:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231268AbhC3CSI (ORCPT ); Mon, 29 Mar 2021 22:18:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230494AbhC3CSA (ORCPT ); Mon, 29 Mar 2021 22:18:00 -0400 Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC3D6C061762 for ; Mon, 29 Mar 2021 19:17:59 -0700 (PDT) Received: by mail-qk1-x72f.google.com with SMTP id v70so14525882qkb.8 for ; Mon, 29 Mar 2021 19:17:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3M1YTP41PlXxTITYsE3syRY8KTDeYRoNyWTUH2CNJ8g=; b=SI8IPfpc+trSuuLH0HwHwpnxk00kelMK1CatSlBP2Jx7PhU0SCXGX5fYZsOV9kYmt7 cvWcNHGLX2AhVBYO2BQX9LKEXVm06tYMZtbZzqGqUOCKwnuilUz5ibWUMs+7EcqZ5tZt 2NaRnkDmejcbYD3n/4/HgZt4Mu6x2oW5+eIe8= 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:mime-version:content-transfer-encoding; bh=3M1YTP41PlXxTITYsE3syRY8KTDeYRoNyWTUH2CNJ8g=; b=fpeyS3/dwott+YoK3kj84sdfT22iY5wyKppnxGT2twGdpRViITK/8PhNlt9p2DdI0f 3ucCacUaRqkoMB25Btpewm+QwyWhzfsAhEx9d8giZxKNpgO/Y8I0GFVDty7bnZ2hVF7X +KICyYLL7ud8wx3DgZUsHGn17ggAGeO6F3/SmyWsswXq/cBqfn0cmQ+CiXmMt4wG9//n TeT2IU+N0Ymku+Aulunp/5ZYghhMm5Y0to2PLBzbWJ3VgecTZHIEdmXLvmHjyaVJtdr1 6UERTIWwlVxUodlfE7JnxCQgrmxlUXQEx7SqeQdgRaxPxJeqeUxFAXXTpaEG+W8ExitZ R4mw== X-Gm-Message-State: AOAM533SHNjsolrC7NSudjuNeIvFNxcfGGSHnaqrAM+OXnn/s6xuQ66y hGMO81hlE7ZoihXF5JjRJqfYmme/VXq8RA== X-Google-Smtp-Source: ABdhPJyE29DX6J4YPT1wZp2+tnycZ6J7e1Lm9MsiDdgvl9QVdeNTSKQQeAL6xc/upCTWCTaDeQk3Yg== X-Received: by 2002:a37:8743:: with SMTP id j64mr26950647qkd.299.1617070679140; Mon, 29 Mar 2021 19:17:59 -0700 (PDT) Received: from grundler-glapstation.lan ([70.134.62.80]) by smtp.gmail.com with ESMTPSA id j30sm12433067qtv.90.2021.03.29.19.17.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Mar 2021 19:17:58 -0700 (PDT) From: Grant Grundler To: Oliver Neukum , Jakub Kicinski Cc: Roland Dreier , nic_swsd , netdev , "David S . Miller" , LKML , Andrew Lunn , Grant Grundler , Grant Grundler Subject: [PATCHv4 4/4] net: cdc_ether: record speed in status method Date: Mon, 29 Mar 2021 19:16:51 -0700 Message-Id: <20210330021651.30906-5-grundler@chromium.org> X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog In-Reply-To: <20210330021651.30906-1-grundler@chromium.org> References: <20210330021651.30906-1-grundler@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Grant Grundler Until very recently, the usbnet framework only had support functions for devices which reported the link speed by explicitly querying the PHY over a MDIO interface. However, the cdc_ether devices send notifications when the link state or link speeds change and do not expose the PHY (or modem) directly. Support funtions (e.g. usbnet_get_link_ksettings_internal()) to directly query state recorded by the cdc_ether driver were added in a previous patch. Instead of cdc_ether spewing the link speed into the dmesg buffer, record the link speed encoded in these notifications and tell the usbnet framework to use the new functions to get link speed/state. User space can now get the most recent link speed/state using ethtool. v4: added to series since cdc_ether uses same notifications as cdc_ncm driver. Signed-off-by: Grant Grundler Reviewed-by: Andrew Lunn --- drivers/net/usb/cdc_ether.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c index a9b551028659..7eb0109e9baa 100644 --- a/drivers/net/usb/cdc_ether.c +++ b/drivers/net/usb/cdc_ether.c @@ -92,6 +92,18 @@ void usbnet_cdc_update_filter(struct usbnet *dev) } EXPORT_SYMBOL_GPL(usbnet_cdc_update_filter); +/* We need to override usbnet_*_link_ksettings in bind() */ +static const struct ethtool_ops cdc_ether_ethtool_ops = { + .get_link = usbnet_get_link, + .nway_reset = usbnet_nway_reset, + .get_drvinfo = usbnet_get_drvinfo, + .get_msglevel = usbnet_get_msglevel, + .set_msglevel = usbnet_set_msglevel, + .get_ts_info = ethtool_op_get_ts_info, + .get_link_ksettings = usbnet_get_link_ksettings_internal, + .set_link_ksettings = NULL, +}; + /* probes control interface, claims data interface, collects the bulk * endpoints, activates data interface (if needed), maybe sets MTU. * all pure cdc, except for certain firmware workarounds, and knowing @@ -310,6 +322,9 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf) return -ENODEV; } + /* override ethtool_ops */ + dev->net->ethtool_ops = &cdc_ether_ethtool_ops; + return 0; bad_desc: @@ -379,12 +394,10 @@ EXPORT_SYMBOL_GPL(usbnet_cdc_unbind); * (by Brad Hards) talked with, with more functionality. */ -static void dumpspeed(struct usbnet *dev, __le32 *speeds) +static void speed_change(struct usbnet *dev, __le32 *speeds) { - netif_info(dev, timer, dev->net, - "link speeds: %u kbps up, %u kbps down\n", - __le32_to_cpu(speeds[0]) / 1000, - __le32_to_cpu(speeds[1]) / 1000); + dev->tx_speed = __le32_to_cpu(speeds[0]); + dev->rx_speed = __le32_to_cpu(speeds[1]); } void usbnet_cdc_status(struct usbnet *dev, struct urb *urb) @@ -396,7 +409,7 @@ void usbnet_cdc_status(struct usbnet *dev, struct urb *urb) /* SPEED_CHANGE can get split into two 8-byte packets */ if (test_and_clear_bit(EVENT_STS_SPLIT, &dev->flags)) { - dumpspeed(dev, (__le32 *) urb->transfer_buffer); + speed_change(dev, (__le32 *) urb->transfer_buffer); return; } @@ -413,7 +426,7 @@ void usbnet_cdc_status(struct usbnet *dev, struct urb *urb) if (urb->actual_length != (sizeof(*event) + 8)) set_bit(EVENT_STS_SPLIT, &dev->flags); else - dumpspeed(dev, (__le32 *) &event[1]); + speed_change(dev, (__le32 *) &event[1]); break; /* USB_CDC_NOTIFY_RESPONSE_AVAILABLE can happen too (e.g. RNDIS), * but there are no standard formats for the response data.