From patchwork Wed Jan 11 16:17:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13096920 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81053C46467 for ; Wed, 11 Jan 2023 16:19:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238429AbjAKQSt (ORCPT ); Wed, 11 Jan 2023 11:18:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236157AbjAKQRw (ORCPT ); Wed, 11 Jan 2023 11:17:52 -0500 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2080.outbound.protection.outlook.com [40.107.247.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 455901C417; Wed, 11 Jan 2023 08:17:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S+LrA46cWmJIYTvaofI8uCWmszO5ej6gNLrYYVYTH8lbsZ1SS4KmsoMJcsKfU/aNjBrI4c8HvK3RPI5U0m5Kdlj2dJ1tTfSHI2dAVqlOJxuZ4uuioRu7Rk+bPALJfqIA4qOm+MGqgBmDrry9Fl3HK55Rvq224x7X5s3iH46XYcW7TuE3s3agrPIe6Fyad00Gh3HE4pd0gjq4PUq+Aju/io1xqPWBQdSOiQpug/1b5yIitPzmsbk470T1/ndWZ8WWyJZ36LC+Wtm25mNdmJzkLLcPZpMfljicWHokMmsynWvNn4HEYVXjbWo1Ho6H/xgP/tdGzkExoe2c6rhdtjv4WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8IzBKz5jWFU9nf2/snHShZyCuIq8lzBpN5hXtoMhRY8=; b=kHCmzf6PFGTEyvBkalMbBPuYZK/JlNZcK++EDg3y6hbsqYY6zPVofHwzd5H8milW3R5qaHVN4SXWBVpNqAoWjknBraMMhkzyEdwB58oEq2H1uXgmXAfqlZxD6CV6pVR8Hc23iWz2xoASMQGvqXzs83d9d7aSsjVv+E2M38zRcibC3nuBnwhE7F7PPHrW8W8I/yC+cZH1ebYUEJlP6e6MUYeTL2MMqurV1dptwQIyxfFeHHj9kv9OXtkha6FzEb6fJl2OVE8y4wI5u4071xo/e4FhacvgX/1GDkpshV8MVUMMUW4uLNfXTegECG+njXD1nTrhvmrEC5CFpX8kKI5fXQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8IzBKz5jWFU9nf2/snHShZyCuIq8lzBpN5hXtoMhRY8=; b=FkAbDuoi17FkaAUT2PtpDMAQWMIMASZAvxjTiejt9stQqxQomZ1I1d3Ig1eO8WljZwLL+uzdCz/oifj9WFLUKFUXlT7+d+OnlPqfa87yFk2gwWczntYXF79ArdUmRKiTgoB5FLRJVhG78OQrVKPDMTpP8ZubRmLjv2xj6hznjiI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DB9PR04MB8462.eurprd04.prod.outlook.com (2603:10a6:10:2cd::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 16:17:28 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%4]) with mapi id 15.20.5986.018; Wed, 11 Jan 2023 16:17:28 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Michal Kubecek , Claudiu Manoil , Vinicius Costa Gomes , Xiaoliang Yang , Kurt Kanzenbach , Rui Sousa , Ferenc Fejes , Pranavi Somisetty , Harini Katakam , Colin Foster , UNGLinuxDriver@microchip.com, Alexandre Belloni , Andrew Lunn , Florian Fainelli Subject: [PATCH v2 net-next 08/12] net: dsa: add plumbing for changing and getting MAC merge layer state Date: Wed, 11 Jan 2023 18:17:02 +0200 Message-Id: <20230111161706.1465242-9-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111161706.1465242-1-vladimir.oltean@nxp.com> References: <20230111161706.1465242-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0163.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:67::8) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DB9PR04MB8462:EE_ X-MS-Office365-Filtering-Correlation-Id: ed5a17c7-1d10-42c0-8302-08daf3ef5570 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jMwtvm9L33IwEO4gZFcXn0L1NiYDVg9uqLHvopRLaFGGxHa+PeGeWkzzStov4/jVKXZ0nCfI4+6yw62hXKZI8VNsW5AI9ItOA8Tg6wBCoVC2B0262MwvQ5wiQflNeaQaQGs6BAkEtIDdTjNBnSKyqUmP2u+b6mu7bjTc3e7t30weFuEjwdSpIjdiAFQEE4cI5J5/YWtnrjO5e+bLDliAEUBRZxzDRHAvXBJcaIInpYmvtERvKlhWczoMSOD5MpuhwW2UkqAec0dDZQV0rGm+FPa5yM//wht8VQCmFXDLXLIwIiOSXvYq6iXM+H1L61DbobKDVKxK9zxpBgh2T4J6B5i57+ovKNHMZ7BjaiWLPIqr3zittpIIB+zRx2VKlXeMzohVGXeNaHmK7pNAqd3EqSU0dlTrfbLfA5GG2uoGcfZzK43tPZrK1wXYVM1gG80q5vSk4mF+jLBvSp1O6knd0WAcESbVT8yAn4sEraa8itBiycgMT0wNMqj5Xha5WnE5Fc8DSg3O0YV5qBuy6/55Fer568pJGE8/lz4Vqjy72E62sQ2vTxkq09t3gWHqwOnzgjhnR5yNlhUE0JXItvJQ8Kj1jiCMIJ79ACSyb30/kIioJp83lDuSOUPLP+QkAs3r3uX45ITuSZKm5hNUszfB+SOugT2ufX5gH0so2et70LQsM1muGR9cvR6yDeDW6TSa X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(39860400002)(376002)(346002)(366004)(451199015)(36756003)(26005)(186003)(8936002)(6666004)(6512007)(6486002)(6506007)(1076003)(2616005)(66946007)(5660300002)(66476007)(66556008)(52116002)(7416002)(6916009)(316002)(4326008)(86362001)(41300700001)(38100700002)(38350700002)(478600001)(54906003)(8676002)(44832011)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2SL44taS+m8GWwHx/El9TiPxZEmTGTmFWOJM+KyivRsdkD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3bifDT+vza08pgSRg6+AWWaSoRjjYntt8uRmdBT3aRm7scjx0SQmq+KxglINrDvF+39zdOINZ1h1sRx3v7pIkUzyQ6cDhqYNXlfdkvSTz20D6Y4VqwF9Ppe9ofYewZ/lpxOQGZavBtnCX76CH9sKAw1DS62dXYolfGfUkEuu9yG9SkYGAxr64Dmrsv10wx6De4bTu/iVgVgI4Zzy6koZTH7Y/WHQzgKVonYFplDkb2b8E+C0w6Cy7bpeJdiP37c49wO0D0JyHylScLRpD5Bp0CH+7+1u5APCK4MXZ3xne9xXs0tx6ME+2dL6tMNj3TLGULPZ2av1Ngxo+sXirurV5ipx+plNCVAyGHKgav2CV6bV7Lxr0asyhK2oQjkKqX9tfoAYWR2VQEH4j2BpG9TapebfPAxbQfNuMGvJ4zKd3DHBSTSdDsWziiuDl1oMjl/3q9AVs/QtiFSXuJ67EMuW3kIXPTlgM+/LxS4DcA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ed5a17c7-1d10-42c0-8302-08daf3ef5570 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 16:17:28.4391 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ULk1GWLB3EQep2+r3xqLDkHw5kZme90fnZ3/gyUHYRKFCB1OBt1VRONP+N7pYYaF6rDKu7ODe/znVLrqWKddAQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8462 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The DSA core is in charge of the ethtool_ops of the net devices associated with switch ports, so in case a hardware driver supports the MAC merge layer, DSA must pass the callbacks through to the driver. Add support for precisely that. Signed-off-by: Vladimir Oltean --- v1->v2: patch is new include/net/dsa.h | 11 +++++++++++ net/dsa/slave.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/include/net/dsa.h b/include/net/dsa.h index 96086289aa9b..51b0dc0d0bc1 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -937,6 +937,17 @@ struct dsa_switch_ops { int (*get_ts_info)(struct dsa_switch *ds, int port, struct ethtool_ts_info *ts); + /* + * ethtool MAC merge layer + */ + void (*get_mm)(struct dsa_switch *ds, int port, + struct ethtool_mm_state *state); + int (*set_mm)(struct dsa_switch *ds, int port, + struct ethtool_mm_cfg *cfg, + struct netlink_ext_ack *extack); + void (*get_mm_stats)(struct dsa_switch *ds, int port, + struct ethtool_mm_stats *stats); + /* * DCB ops */ diff --git a/net/dsa/slave.c b/net/dsa/slave.c index aab79c355224..b6ed0f40a0ef 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -1117,6 +1117,38 @@ static void dsa_slave_net_selftest(struct net_device *ndev, net_selftest(ndev, etest, buf); } +static void dsa_slave_get_mm(struct net_device *dev, + struct ethtool_mm_state *state) +{ + struct dsa_port *dp = dsa_slave_to_port(dev); + struct dsa_switch *ds = dp->ds; + + if (ds->ops->get_mm) + ds->ops->get_mm(ds, dp->index, state); +} + +static int dsa_slave_set_mm(struct net_device *dev, struct ethtool_mm_cfg *cfg, + struct netlink_ext_ack *extack) +{ + struct dsa_port *dp = dsa_slave_to_port(dev); + struct dsa_switch *ds = dp->ds; + + if (!ds->ops->set_mm) + return -EOPNOTSUPP; + + return ds->ops->set_mm(ds, dp->index, cfg, extack); +} + +static void dsa_slave_get_mm_stats(struct net_device *dev, + struct ethtool_mm_stats *stats) +{ + struct dsa_port *dp = dsa_slave_to_port(dev); + struct dsa_switch *ds = dp->ds; + + if (ds->ops->get_mm_stats) + ds->ops->get_mm_stats(ds, dp->index, stats); +} + static void dsa_slave_get_wol(struct net_device *dev, struct ethtool_wolinfo *w) { struct dsa_port *dp = dsa_slave_to_port(dev); @@ -2205,6 +2237,9 @@ static const struct ethtool_ops dsa_slave_ethtool_ops = { .set_rxnfc = dsa_slave_set_rxnfc, .get_ts_info = dsa_slave_get_ts_info, .self_test = dsa_slave_net_selftest, + .get_mm = dsa_slave_get_mm, + .set_mm = dsa_slave_set_mm, + .get_mm_stats = dsa_slave_get_mm_stats, }; static const struct dcbnl_rtnl_ops __maybe_unused dsa_slave_dcbnl_ops = {