From mboxrd@z Thu Jan 1 00:00:00 1970 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=-1.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS, URIBL_BLOCKED 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 6E163C43381 for ; Thu, 28 Mar 2019 17:59:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 34FFF20651 for ; Thu, 28 Mar 2019 17:59:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=Mellanox.com header.i=@Mellanox.com header.b="bZBkhhr6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726715AbfC1R7z (ORCPT ); Thu, 28 Mar 2019 13:59:55 -0400 Received: from mail-eopbgr130049.outbound.protection.outlook.com ([40.107.13.49]:30664 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726082AbfC1R7z (ORCPT ); Thu, 28 Mar 2019 13:59:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=humOoSwVfYKG+9h/DEgTUFQSzqgrE0WegK4pEk/yw64=; b=bZBkhhr6diiX7utSz4GRPICGzt5XPjb+qJsZZJVy3174MxHjjKMs2mkChE12ads0bEd8h/1jQFJo+VQm+77XeOzizCAAn57j6OtPZ8nDuSOrr8R/d5p8tIhR8kwTWseLoKH1sECekbmFtqJv0N+2bVby6dT2CURi2uFb6x1YQhE= Received: from AM6PR05MB6133.eurprd05.prod.outlook.com (20.179.3.144) by AM6PR05MB5847.eurprd05.prod.outlook.com (20.179.0.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1750.15; Thu, 28 Mar 2019 17:59:50 +0000 Received: from AM6PR05MB6133.eurprd05.prod.outlook.com ([fe80::b43b:8a06:4870:82cc]) by AM6PR05MB6133.eurprd05.prod.outlook.com ([fe80::b43b:8a06:4870:82cc%2]) with mapi id 15.20.1750.014; Thu, 28 Mar 2019 17:59:50 +0000 From: Petr Machata To: Andrew Lunn CC: Roopa Prabhu , "netdev@vger.kernel.org" , Jiri Pirko , Ido Schimmel , "davem@davemloft.net" , Tariq Toukan , "jakub.kicinski@netronome.com" , "stephen@networkplumber.org" Subject: Re: [RFC PATCH net-next 1/3] net: rtnetlink: Add link-down reason to RTNL messages Thread-Topic: [RFC PATCH net-next 1/3] net: rtnetlink: Add link-down reason to RTNL messages Thread-Index: AQHU21hddEVxaeti1Ey0mD5+skDyyqYQbX2AgAAXxgCAEOQbgA== Date: Thu, 28 Mar 2019 17:59:50 +0000 Message-ID: <87zhpeg9rg.fsf@mellanox.com> References: <3a247e91ebe81cdae4bae27ec1631c5015fb943f.1552672441.git.petrm@mellanox.com> <20190318000312.GB30224@lunn.ch> In-Reply-To: <20190318000312.GB30224@lunn.ch> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: LO2P265CA0266.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a1::14) To AM6PR05MB6133.eurprd05.prod.outlook.com (2603:10a6:20b:af::16) authentication-results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [78.45.160.211] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 6460b32f-fe1c-4c33-6868-08d6b3a72c18 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4618075)(2017052603328)(7153060)(7193020);SRVR:AM6PR05MB5847; x-ms-traffictypediagnostic: AM6PR05MB5847: x-microsoft-antispam-prvs: x-forefront-prvs: 0990C54589 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(376002)(136003)(366004)(346002)(396003)(39860400002)(189003)(199004)(6506007)(386003)(6246003)(102836004)(305945005)(5660300002)(76176011)(7736002)(25786009)(52116002)(53936002)(186003)(6512007)(4326008)(71190400001)(71200400001)(105586002)(106356001)(6116002)(3846002)(36756003)(486006)(6486002)(8676002)(81166006)(8936002)(6916009)(97736004)(81156014)(2906002)(478600001)(229853002)(256004)(6436002)(2616005)(11346002)(476003)(14454004)(99286004)(26005)(86362001)(446003)(54906003)(68736007)(93886005)(66066001)(316002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM6PR05MB5847;H:AM6PR05MB6133.eurprd05.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: gfZWTSOvS1XVN16WpJydZMFwrmM1usruEmV758IwaJYB6MLtgZbvsHkxSvCCJKDeZ9fXSVUGNfSUFgmppT6xI4mnyLWMytBC2tga3Aq+xNClKYHX8jWTBmiMLqMS9aJe2YQxIEI7H9GvwbUX3EZ6F8GUR5g5LVm+IlNBNlOL1zXuGHr4K6sp8ad0EE9fpd105cHhAwE3FOXI8T7tt6nPPQbMwU0qU4qqgTWAKReUKxzISbpgv3ZuLcM0P+lHUAqsIWxIwmfOIsZzqQSnPRgbXtJQxU5jDGcGRVM4ZgqRDsRWDpdVUMKMpPtBRZsL3+pshGOXsKnh9J4ymA/gCYK5BjLXL1xIhFRBWVxUfHpvDvP7OVuQxQymRBxWECGvK0KCF7PYAlIsHLCSASmJn+lESWndwxoT94LFNLwPKiJLZ7k= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6460b32f-fe1c-4c33-6868-08d6b3a72c18 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Mar 2019 17:59:50.4534 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR05MB5847 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Andrew Lunn writes: > I argued this is a PHY layer status information. We don't really want > to have to modify every MAC driver to call into phylib/phylink. Yes, > we can have a netdev_ops for those drivers which ignore the Linux PHY > layer, but ideally we want to transparently call into the PHY layer to > get this information, if the MAC is not doing odd things. >From what I see, there are four places where the information could be collected: - MAC driver: dev->ethtool_ops->get_link_down_reason (At least mlxsw and mlx5 need this.) modified include/linux/ethtool.h @@ -395,4 +395,7 @@ struct ethtool_ops { struct ethtool_fecparam *); void (*get_ethtool_phy_stats)(struct net_device *, struct ethtool_stats *, u64 *); + int (*get_link_down_reason)(const struct net_device *, + enum link_down_reason_major *, + u32 *minor); }; Return -ENODATA to indicate there's nothing to report. - PHY driver: dev->phydev->drv->get_link_down_reason Certain PHY drivers might want to have a custom handling for some PHY-specific insight. Something like: modified include/linux/phy.h @@ -636,4 +636,7 @@ struct phy_driver { struct ethtool_tunable *tuna, const void *data); int (*set_loopback)(struct phy_device *dev, bool enable); + int (*get_link_down_reason)(struct phy_device *dev, + enum link_down_reason_major *major, + u32 *minor); }; Return -ENODATA to indicate there's nothing to report. - Generic PHY It would be possible to add a function that e.g. consults the PHY state machine to figure out what went wrong. Phy as such may have to be extended to keep track of e.g. why the state machine is PHY_HALTED, or possibly other problems worthy of reporting. - phylink I'm not sure how to generically plug in the phylink library, because it is a private property of a MAC driver. There are currently only three drivers using phylink (mvvp2, mvneta, DSA), but it looks as if the intention is that phylink is used much more widely. So maybe it would make sense to have an NDO like get_phylink and use that to call into the phylink library for some generic handling. Speaking specifically, my patch set would only do the first step above, because neither mlxsw nor mlx5 use the PHY subsystem. But it would be easy enough to extend for the other cases above. Thoughts? Thanks, Petr