From patchwork Mon Jul 6 04:27:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 1323313 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; 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.a=rsa-sha256 header.s=20161025 header.b=WWDlW5Fz; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4B0Xck381Vz9sRN for ; Mon, 6 Jul 2020 14:28:22 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728731AbgGFE2H (ORCPT ); Mon, 6 Jul 2020 00:28:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725892AbgGFE2G (ORCPT ); Mon, 6 Jul 2020 00:28:06 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32A83C061794; Sun, 5 Jul 2020 21:28:06 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id t11so11586739pfq.11; Sun, 05 Jul 2020 21:28:06 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=HkDXGrpzcbv2pQ2Q2j+5F77apxMKGENskOQG8vm8n4Q=; b=WWDlW5FzJALhGkPj99JWuXJrJ8f38K8PQaQXGOXRAPwBJk3goQPCbbj2i2286nK0ar tVFQ4dsfBkCoYo7GAOm8XjZI2T0TUgqWVxJPTjga20XAJd5v0hT6bnP76D2tFh0sIblh aYqoe0s3opoARDqJS7BCu9q+U6hmHqBJztWLNjhGkPky4iiwdADQh8ScIgsffNcgPczA Xn06c1eMrREd31A7tdwA54ipH8a8J5e57IRN82Ci5mpMDmH5TDtMaU4uiianp/GYshI+ iITdAxkd4RKpZFgXZB3302sLuGJqWiwFimejoFap+6QtxEdfugrpvn/GMPoPvvAanF7f 0rrg== 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=HkDXGrpzcbv2pQ2Q2j+5F77apxMKGENskOQG8vm8n4Q=; b=ChmdqclVQaxIvFcMpBjd7eer27bmRqL3+9QLC6bxh9HUFn2gtYJd7lAr3DqGlgCvTy cYRbcQy9XmjKCNgiOVc71vQ8WUzAdhqmLLZbsAbQPXSE/HGcmOgIpLfZNSm96Uo6iS/r 8NjfpQcGsa2NZkOZRYGd+S/+fbx3R5nT5awngbRIEHRXaZKzX44YTSZMWUAY37vBwWTI ICLeyJScoT+GwV8eQ4dD0TW4/hGMnfn8nF1jTt4Yzre3/I/pjD0A1c16nG0RNzCi9Vnj jQpD7INqqOPNlK/QgV9kzFJy//DBTGSIbhX26Rl6L9Q/fZKukTMGuKVEjsuKt+c+czEi DEvg== X-Gm-Message-State: AOAM530X6asEKTRZX7XJzQyu5VHKyr2OoDNIKxLjwsJUHlbepo9gFF6g svDY6pX+RDmH/URuireY7zHYc79O X-Google-Smtp-Source: ABdhPJz4ALl968h5Zk7sbcF3uSnkKVPZg1BAxNzxK9NXXLQSeopDHt50gjinix4Dzl1CMf7WdBpIcg== X-Received: by 2002:aa7:8b4b:: with SMTP id i11mr43489224pfd.123.1594009685324; Sun, 05 Jul 2020 21:28:05 -0700 (PDT) Received: from localhost.localdomain (ip68-111-84-250.oc.oc.cox.net. [68.111.84.250]) by smtp.gmail.com with ESMTPSA id ia13sm16558680pjb.42.2020.07.05.21.28.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jul 2020 21:28:04 -0700 (PDT) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Jakub Kicinski , Michal Kubecek , linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next v2 1/3] net: ethtool: Introduce ethtool_phy_ops Date: Sun, 5 Jul 2020 21:27:56 -0700 Message-Id: <20200706042758.168819-2-f.fainelli@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200706042758.168819-1-f.fainelli@gmail.com> References: <20200706042758.168819-1-f.fainelli@gmail.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In order to decouple ethtool from its PHY library dependency, define an ethtool_phy_ops singleton which can be overriden by the PHY library when it loads with an appropriate set of function pointers. Signed-off-by: Florian Fainelli --- include/linux/ethtool.h | 25 +++++++++++++++++++++++++ net/ethtool/common.c | 11 +++++++++++ net/ethtool/common.h | 2 ++ 3 files changed, 38 insertions(+) diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 48ad3b6a0150..0c139a93b67a 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -502,5 +502,30 @@ int ethtool_virtdev_set_link_ksettings(struct net_device *dev, const struct ethtool_link_ksettings *cmd, u32 *dev_speed, u8 *dev_duplex); +struct netlink_ext_ack; +struct phy_device; +struct phy_tdr_config; + +/** + * struct ethtool_phy_ops - Optional PHY device options + * @start_cable_test - Start a cable test + * @start_cable_test_tdr - Start a Time Domain Reflectometry cable test + * + * All operations are optional (i.e. the function pointer may be set to %NULL) + * and callers must take this into account. Callers must hold the RTNL lock. + */ +struct ethtool_phy_ops { + int (*start_cable_test)(struct phy_device *phydev, + struct netlink_ext_ack *extack); + int (*start_cable_test_tdr)(struct phy_device *phydev, + struct netlink_ext_ack *extack, + const struct phy_tdr_config *config); +}; + +/** + * ethtool_set_ethtool_phy_ops - Set the ethtool_phy_ops singleton + * @ops: Ethtool PHY operations to set + */ +void ethtool_set_ethtool_phy_ops(const struct ethtool_phy_ops *ops); #endif /* _LINUX_ETHTOOL_H */ diff --git a/net/ethtool/common.c b/net/ethtool/common.c index aaecfc916a4d..ce4dbae5a943 100644 --- a/net/ethtool/common.c +++ b/net/ethtool/common.c @@ -2,6 +2,7 @@ #include #include +#include #include "common.h" @@ -373,3 +374,13 @@ int __ethtool_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info) return 0; } + +const struct ethtool_phy_ops *ethtool_phy_ops; + +void ethtool_set_ethtool_phy_ops(const struct ethtool_phy_ops *ops) +{ + rtnl_lock(); + ethtool_phy_ops = ops; + rtnl_unlock(); +} +EXPORT_SYMBOL_GPL(ethtool_set_ethtool_phy_ops); diff --git a/net/ethtool/common.h b/net/ethtool/common.h index a62f68ccc43a..b83bef38368c 100644 --- a/net/ethtool/common.h +++ b/net/ethtool/common.h @@ -37,4 +37,6 @@ bool convert_legacy_settings_to_link_ksettings( int ethtool_get_max_rxfh_channel(struct net_device *dev, u32 *max); int __ethtool_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info); +extern const struct ethtool_phy_ops *ethtool_phy_ops; + #endif /* _ETHTOOL_COMMON_H */ From patchwork Mon Jul 6 04:27:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 1323314 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; 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.a=rsa-sha256 header.s=20161025 header.b=kbhTQ/a2; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4B0Xck5kCdz9sRR for ; Mon, 6 Jul 2020 14:28:22 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728763AbgGFE2I (ORCPT ); Mon, 6 Jul 2020 00:28:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725892AbgGFE2H (ORCPT ); Mon, 6 Jul 2020 00:28:07 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94B4EC061794; Sun, 5 Jul 2020 21:28:07 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id j20so770968pfe.5; Sun, 05 Jul 2020 21:28:07 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=v8CLcC3ysliK6+4sr4xmqbMa0bZ4Dm3ZHnrxJuH9exM=; b=kbhTQ/a2J56gJybm542XyAxj3WJntcZnxGMoE7eudEkv+nyq6aMgfIDTRjjk8ibT1/ mEZOa19zIk2pCI7Tr04uP46Gk1pkqInW4zTppSeQGcoZROTjARL3dEzSnvKVbxdJOKWu qVgiS/do/JC1C8JlDZpzYcibmKV/30QZ5Yo4ZZOhwpQM0jK0LcLmi7sxdEIU9oEr8vsX bg/h4g4tjxQlE+KK75DF/mEHSok7fs/s5GJLA0CG7WtXzciNeIuR6vUY4YNq+w13sEFb F4yJX0J1Uydx8HPB4cMBZv60Vhdg4m6pjgd5d+OGNmeACnXxk+vhqqBHpKbkgqxqEuDh Besw== 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=v8CLcC3ysliK6+4sr4xmqbMa0bZ4Dm3ZHnrxJuH9exM=; b=qnA0HfVuqabvK1+LvJVDx8gOSJq0JtCr9e5uIUEFJXJu3QlGLsHCMBTfPYPkD/UIHK rDQfOScoDBV27DjIJQf/cJf0qp/H27uGxnZP2ftX4xW0UOQnKNNImIbpIjNAwkSWqdZ6 lotFod+YpP4FeF5tKkouEhXITvxXcrA/kuIWNyePvKTO7uIEEOYdYP8nDpKxUsWQHX10 zg3bpCQFrKQqbaiYo5dfcFkxicCxUYMxf5zjuxOSkzfhhSWe4qYjgmxTWv9uVox1Qtkk uikZvdi21RSIQQ2JHBh2DUipT0cZda+Bq9w5d7vjeWzZLWJVtZH7Ck/aoU1lTkmLYkXO RbgQ== X-Gm-Message-State: AOAM531MJs2Tde6VuP/jF2e63xKaFTABaSO6Xh9kCqSatXdtCPJI2VLC 76t3jALVMIdK8GRGyAEL4mIeIIF4 X-Google-Smtp-Source: ABdhPJwpMktroHvkI9HxHCORyeJLKApJPpGKz+krKplES+ZZ5aRN5OATty3DjREunag0tYZUycfWIw== X-Received: by 2002:a05:6a00:1342:: with SMTP id k2mr41987550pfu.32.1594009686770; Sun, 05 Jul 2020 21:28:06 -0700 (PDT) Received: from localhost.localdomain (ip68-111-84-250.oc.oc.cox.net. [68.111.84.250]) by smtp.gmail.com with ESMTPSA id ia13sm16558680pjb.42.2020.07.05.21.28.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jul 2020 21:28:06 -0700 (PDT) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Jakub Kicinski , Michal Kubecek , linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next v2 2/3] net: phy: Register ethtool PHY operations Date: Sun, 5 Jul 2020 21:27:57 -0700 Message-Id: <20200706042758.168819-3-f.fainelli@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200706042758.168819-1-f.fainelli@gmail.com> References: <20200706042758.168819-1-f.fainelli@gmail.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Utilize ethtool_set_ethtool_phy_ops to register a suitable set of PHY ethtool operations in a dynamic fashion such that ethtool will no longer directy reference PHY library symbols. Signed-off-by: Florian Fainelli --- drivers/net/phy/phy_device.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index eb1068a77ce1..94a5aa30b70f 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -3029,6 +3029,11 @@ static struct phy_driver genphy_driver = { .set_loopback = genphy_loopback, }; +static const struct ethtool_phy_ops phy_ethtool_phy_ops = { + .start_cable_test = phy_start_cable_test, + .start_cable_test_tdr = phy_start_cable_test_tdr, +}; + static int __init phy_init(void) { int rc; @@ -3037,6 +3042,7 @@ static int __init phy_init(void) if (rc) return rc; + ethtool_set_ethtool_phy_ops(&phy_ethtool_phy_ops); features_init(); rc = phy_driver_register(&genphy_c45_driver, THIS_MODULE); @@ -3058,6 +3064,7 @@ static void __exit phy_exit(void) phy_driver_unregister(&genphy_c45_driver); phy_driver_unregister(&genphy_driver); mdio_bus_exit(); + ethtool_set_ethtool_phy_ops(NULL); } subsys_initcall(phy_init); From patchwork Mon Jul 6 04:27:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 1323315 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; 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.a=rsa-sha256 header.s=20161025 header.b=e4eUU+y0; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4B0Xcl5svBz9sRk for ; Mon, 6 Jul 2020 14:28:23 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728780AbgGFE2O (ORCPT ); Mon, 6 Jul 2020 00:28:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725892AbgGFE2K (ORCPT ); Mon, 6 Jul 2020 00:28:10 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D145C061794; Sun, 5 Jul 2020 21:28:10 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id ch3so1288961pjb.5; Sun, 05 Jul 2020 21:28:10 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=4MlAhZczNRoqPKGUQQKqbIHChSjJilXrVIKMIUGfFJo=; b=e4eUU+y0yRdFRQmTArc78FB+m1IGUgO9ipMZdeLBHqozpK9t1b3BuqvtqAHHybftm0 NoiZxF4uLvGfgN2vkH8doiaPEmuHRVNKnWE7mRP9pZ7oIsUjjLrk2akmo3fCBWnO1vbZ 8Mil7aOhkpG53zf76/ZQv7v+w27Q1xwUg0oxV6VnNY0l+tdLXW6+QMmqpilJWojE9rW6 gtkCgHNRiE3FzSp2/xmGq7GVRYM8gygpeF+aM2/HaN2XzuX6ENNJ2qAU765oL/2huYHC /ya6mBBdw4I+cG16SQk2ntzKe2paZAmWcc0ujEfoX2RFjxQe29s3O3Suji4G2qMDBxou BIPw== 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=4MlAhZczNRoqPKGUQQKqbIHChSjJilXrVIKMIUGfFJo=; b=dag5/zob24O6qy147sOnB0u0qyu5T+YlUIOxGNwRItdg3au+y0VPfD6w+kmI7uaxUt mMUlRcKbSycw9H0olw4e6towfyRd1pExZOelu0qBBIdCCwPDciMxY2HJAzK0VDDrsfNm G2dZDodv/Hkb1DeRopJksbsqYHGriL4gjiWmEW3o8bKoB1Q1/apkvVKW4w0Z09ulGdzo 5Hg2jTo5s6o6DG1SZOYIP5Hdxeum+dZw2pPJGZBburfYTJ7U0DRrnZ8DNNHsA0Aq4vcx 4mzwiNhNQmcAt2QxheXGKAje+zPgt8JcLIz9JKDgV+ZW2+Q01qqI2vAvqSsScgD9W/hh dB4g== X-Gm-Message-State: AOAM530XZN02v0JySim0VRSipd29Jl4ivGJVQ8wyiVKYXLWB19raIwFn u7YS2LiBNSwL9IWYsP7/RG3D7+Ui X-Google-Smtp-Source: ABdhPJyNr0MmeEJTS1nk6sRDU2qdjE1022dVc4M/5jzXLV3q+1CNErL+jn0UTVhVcw2t2ktyhFpVcQ== X-Received: by 2002:a17:902:c206:: with SMTP id 6mr17438764pll.30.1594009688279; Sun, 05 Jul 2020 21:28:08 -0700 (PDT) Received: from localhost.localdomain (ip68-111-84-250.oc.oc.cox.net. [68.111.84.250]) by smtp.gmail.com with ESMTPSA id ia13sm16558680pjb.42.2020.07.05.21.28.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jul 2020 21:28:07 -0700 (PDT) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Jakub Kicinski , Michal Kubecek , linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next v2 3/3] net: ethtool: Remove PHYLIB direct dependency Date: Sun, 5 Jul 2020 21:27:58 -0700 Message-Id: <20200706042758.168819-4-f.fainelli@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200706042758.168819-1-f.fainelli@gmail.com> References: <20200706042758.168819-1-f.fainelli@gmail.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Now that we have introduced ethtool_phy_ops and the PHY library dynamically registers its operations with that function pointer, we can remove the direct PHYLIB dependency in favor of using dynamic operations. Signed-off-by: Florian Fainelli --- net/Kconfig | 1 - net/ethtool/cabletest.c | 18 ++++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/net/Kconfig b/net/Kconfig index d1672280d6a4..3831206977a1 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -455,7 +455,6 @@ config FAILOVER config ETHTOOL_NETLINK bool "Netlink interface for ethtool" default y - depends on PHYLIB=y || PHYLIB=n help An alternative userspace interface for ethtool based on generic netlink. It provides better extensibility and some new features, diff --git a/net/ethtool/cabletest.c b/net/ethtool/cabletest.c index 7194956aa09e..4f9fbdf7610c 100644 --- a/net/ethtool/cabletest.c +++ b/net/ethtool/cabletest.c @@ -58,6 +58,7 @@ int ethnl_act_cable_test(struct sk_buff *skb, struct genl_info *info) { struct nlattr *tb[ETHTOOL_A_CABLE_TEST_MAX + 1]; struct ethnl_req_info req_info = {}; + const struct ethtool_phy_ops *ops; struct net_device *dev; int ret; @@ -81,11 +82,17 @@ int ethnl_act_cable_test(struct sk_buff *skb, struct genl_info *info) } rtnl_lock(); + ops = ethtool_phy_ops; + if (!ops || !ops->start_cable_test) { + ret = -EOPNOTSUPP; + goto out_rtnl; + } + ret = ethnl_ops_begin(dev); if (ret < 0) goto out_rtnl; - ret = phy_start_cable_test(dev->phydev, info->extack); + ret = ops->start_cable_test(dev->phydev, info->extack); ethnl_ops_complete(dev); @@ -308,6 +315,7 @@ int ethnl_act_cable_test_tdr(struct sk_buff *skb, struct genl_info *info) { struct nlattr *tb[ETHTOOL_A_CABLE_TEST_TDR_MAX + 1]; struct ethnl_req_info req_info = {}; + const struct ethtool_phy_ops *ops; struct phy_tdr_config cfg; struct net_device *dev; int ret; @@ -337,11 +345,17 @@ int ethnl_act_cable_test_tdr(struct sk_buff *skb, struct genl_info *info) goto out_dev_put; rtnl_lock(); + ops = ethtool_phy_ops; + if (!ops || !ops->start_cable_test_tdr) { + ret = -EOPNOTSUPP; + goto out_rtnl; + } + ret = ethnl_ops_begin(dev); if (ret < 0) goto out_rtnl; - ret = phy_start_cable_test_tdr(dev->phydev, info->extack, &cfg); + ret = ops->start_cable_test_tdr(dev->phydev, info->extack, &cfg); ethnl_ops_complete(dev);