From patchwork Fri Dec 4 17:09:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 11952011 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,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 3F235C4361B for ; Fri, 4 Dec 2020 17:11:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 08F4320769 for ; Fri, 4 Dec 2020 17:11:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388573AbgLDRKu (ORCPT ); Fri, 4 Dec 2020 12:10:50 -0500 Received: from mail-eopbgr50069.outbound.protection.outlook.com ([40.107.5.69]:7598 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388544AbgLDRKs (ORCPT ); Fri, 4 Dec 2020 12:10:48 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SxLtHfSBRrJSGPcjmFq9LuXe4evGFF/jHhl9cG70tTpoywS8rO0LidWsAMOTCIfiiNopCUo2uVJUMUTiunWWmUDdfDcvOGW7+MIYJPwRe9pDGzczk0yweQ54xhLiRDFpnoX0KZIcwWeXKvFl21Uzw+XQAAvRKz7XXJGweyA8oGCOqiIRb9+p7vroVrHa9u5dS1OT/W5KZLWr0JUEhraPJcRRjv8BL5bKY5gb9XZbWIIKqFX4Oe/hYlTMfJxz5uasaxqw8z5ofUmvxPqBWTD81XZEfNFr9qnD75wEcP8ZVjSj/CLJjs3ewlAe8d/FvAGjn0JtrVxnphG3uRFE/6gRoQ== 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-SenderADCheck; bh=FzsADw+6e0jMmgnY/Wtvd6fWnRodbQeeOAml8RW+DNg=; b=fDRnfHBIDihb71TeHCEYSXAhE3C+v+DZyq6eWzJDeUHAhyzkzt0jJp4GbHipSrCOG+sjiLNUYkP2PAZAY+xkj5L7M7S7zmRAOdAQki3HHiJdrAgvmc/Wu9s4FgcJjFdNjxHXiwMdeV5K4Amn86BSR3F00SDZ7tKqC89NLv/3QIMicj73SuD2vI2HCL6V1SvSAwozC6V1daHD58cvDLUx0d//kML+1M1RvbxRn8cVqDcpfpdTg+lXqkiQgDyXaOiI2L/4u5A0oUaEBYJ7WJhxled306uMwZ2nxuDPCuYtssem5EXNN1BMqBTe2uQuJUdRfIrRWktFR5wiYcZMhDZbIg== 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=FzsADw+6e0jMmgnY/Wtvd6fWnRodbQeeOAml8RW+DNg=; b=WMuYMKlK21gkuVqpar5di3+YnmwRW6FmUmmAPgERGddcIRcZS4um4hhIwxk0LWQfbz8Tn0a/MErXxtQ0uQEonLDB+4ufbxgiGbTOA+gA2AIF7uJdQz6jR0B2JVlzToFHOuoVhZTMJJdznguScB5DLiM6LFg17Q8BVPfaxSKwVro= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VI1PR0402MB3616.eurprd04.prod.outlook.com (2603:10a6:803:8::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3611.25; Fri, 4 Dec 2020 17:09:56 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84%5]) with mapi id 15.20.3632.021; Fri, 4 Dec 2020 17:09:56 +0000 From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, UNGLinuxDriver@microchip.com, Alexandre Belloni , Andrew Lunn , Florian Fainelli , Vivien Didelot , Horatiu Vultur , "Allan W . Nielsen" , Claudiu Manoil , Steen Hegelund Subject: [PATCH net] net: mscc: ocelot: install MAC addresses in .ndo_set_rx_mode from process context Date: Fri, 4 Dec 2020 19:09:38 +0200 Message-Id: <20201204170938.1415582-1-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 X-Originating-IP: [188.25.2.120] X-ClientProxiedBy: AM3PR05CA0123.eurprd05.prod.outlook.com (2603:10a6:207:2::25) To VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.2.120) by AM3PR05CA0123.eurprd05.prod.outlook.com (2603:10a6:207:2::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.18 via Frontend Transport; Fri, 4 Dec 2020 17:09:55 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 4b05626e-9aa3-422f-d807-08d898776c94 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3616: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3276; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: th6mBM5FwOqpq8xn83A1cLA+Va4pOt43JDXCmzEmip4CNWJxz77m6HhZG3+ooa0ZM36IMkPdCguPpvYnve1qQR/jo5yy0iWrtendI0f0LmSkZJ1gsVnOqSZi7wsHX6z7VxjUzP5uo6ozD3fSHuYxII/cFSQCvloTnurjbOPamIcSEeYUKuf6DcQrB90vP80leK2u679/4FyuLJhcwtVyrMfIOCWDoRDrhv2dPQiL4FiJgGWYbUJtuEM9rZ27wETr1YhfNSFC+SukHCad0e+leZgbN+X1qRViXE6decX3BcbRQJ3chJ2gma0YPXDjvanvYpOFXNJ5BbwclVkI5vU+MtJOEVT2kIxRlKFo22Hqlqg4sf77Zf+jhLzINY/EiBJVvALF2fITI3pJ3S6SiqDXqHetxQMtbxwp5KQaenl3jgY= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5696.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(366004)(376002)(39860400002)(346002)(396003)(26005)(478600001)(6506007)(6512007)(6666004)(186003)(16526019)(4326008)(52116002)(44832011)(36756003)(8936002)(2616005)(956004)(8676002)(1076003)(5660300002)(54906003)(110136005)(7416002)(69590400008)(83380400001)(316002)(66556008)(66476007)(66946007)(6486002)(86362001)(2906002)(142923001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 2RqNnNkeOD4+KuCxIU+0S4NCtlqQp0cDYACpWS9hQs44jt3jZeHTVqW+hSxiHEPK05ooK3f8jQP+6Yy7KtMP98UietBAZ11QXLFJHQxW6wfMfF/5Mq+WPGh4HF9xSodlxuyreChn4WJnAC1Gvj+FWWyfbCIOwPVF2l06oJbD7ZrnLmP82A12VIr9Xiz8jpGRRyF4XMaDgJzuk4dKGGFMUsNL4+2bnoNcOhJ0I9to3H9pNNb+yeovm53fiIXzDWlzEjvuwgjYRMn2Jms3ABhhM8p6BLzCZuts0icR35vlxB63gYd5vyuzVXODMT9EO9i9nYYHN24tGTYXkX4Sj8OeJBQ6YL5V7w6cpNY7e4G0OlWX34QWtu/bVFYnQ+kYdcF1D6ctKql6+TsV67Yk4hwBUuyDWdjDlTISTv+LuC1da6k5CPjCHiBOB0Qy6pyioY7l37poa+4iyWVdW3VeQnVobxzPEAkoJKica6Hb8yN+NFiHQREtDPFK0r54fxww/T1iTeLx7WcgCjZyE1/EwfbXN2C3kdH4xEfhGWy6txe4NofXSBSo/HmVHV+9oTvT3xjluH1aSvwcpKqzmey+SKK7KyHQ+C50YRkp26Q20UEnTHJ5FbjVMic6zMmhaQQOUqnaWzlg7RVjaeUDCHbQGavfDnpERxCk10ZorSR9Q2oQ0gcuhH053yH9znXfHSoL7npoKSlY1LuGU21+/quty8o+ifbwfgDqcx2xmiM7XCOyT+WtepvVZdjDc2wK/iQ1nPqEiXCNYHUAwwEwMLkAs7+0YD2Q5fGrixD2CHLEFrDNLr/seLpswyWAoII1ceECtxxQdbJaTkCxT1NT9bCx/MS7AH1q6TBl4IhoHjmpqn42Cd+YoEvYSFLiHa8Uqn7Y1C1ydeTO+WkFpFPYkNyn7vFGWWNSUVAo3WwWJaw9Y0MrLRkp4xbqR9lj7EXYmyvO4p7WfFYIjxSsP3hAXSC7hEqYFh/H+NhF4FHqzrhjTAU43wr90lCZ6zl/qEpP4xtwbt5P X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4b05626e-9aa3-422f-d807-08d898776c94 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2020 17:09:56.6407 (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: LTbu/6g0fZYQTEDDHV3rztSNg7A0wwNuSwTUBG2bEaahJJWsZQWn6/1cTQtEuUtMfcl5cDc4I2TEXRbQlRqt4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3616 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Currently ocelot_set_rx_mode calls ocelot_mact_learn directly, which has a very nice ocelot_mact_wait_for_completion at the end. Introduced in commit 639c1b2625af ("net: mscc: ocelot: Register poll timeout should be wall time not attempts"), this function uses readx_poll_timeout which triggers a lot of lockdep warnings and is also dangerous to use from atomic context, leading to lockups and panics. Steen Hegelund added a poll timeout of 100 ms for checking the MAC table, a duration which is clearly absurd to poll in atomic context. So we need to defer the MAC table access to process context, which we do via a dynamically allocated workqueue which contains all there is to know about the MAC table operation it has to do. Signed-off-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- drivers/net/ethernet/mscc/ocelot_net.c | 81 +++++++++++++++++++++++++- 1 file changed, 78 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c index c65ae6f75a16..2f536692d61e 100644 --- a/drivers/net/ethernet/mscc/ocelot_net.c +++ b/drivers/net/ethernet/mscc/ocelot_net.c @@ -414,13 +414,82 @@ static int ocelot_port_xmit(struct sk_buff *skb, struct net_device *dev) return NETDEV_TX_OK; } +enum ocelot_action_type { + OCELOT_MACT_LEARN, + OCELOT_MACT_FORGET, +}; + +struct ocelot_mact_work_ctx { + struct work_struct work; + struct ocelot *ocelot; + enum ocelot_action_type type; + union { + /* OCELOT_MACT_LEARN */ + struct { + int pgid; + enum macaccess_entry_type entry_type; + unsigned char addr[ETH_ALEN]; + u16 vid; + } learn; + /* OCELOT_MACT_FORGET */ + struct { + unsigned char addr[ETH_ALEN]; + u16 vid; + } forget; + }; +}; + +#define ocelot_work_to_ctx(x) \ + container_of((x), struct ocelot_mact_work_ctx, work) + +static void ocelot_mact_work(struct work_struct *work) +{ + struct ocelot_mact_work_ctx *w = ocelot_work_to_ctx(work); + struct ocelot *ocelot = w->ocelot; + + switch (w->type) { + case OCELOT_MACT_LEARN: + ocelot_mact_learn(ocelot, w->learn.pgid, w->learn.addr, + w->learn.vid, w->learn.entry_type); + break; + case OCELOT_MACT_FORGET: + ocelot_mact_forget(ocelot, w->forget.addr, w->forget.vid); + break; + default: + break; + }; + + kfree(w); +} + +static int ocelot_enqueue_mact_action(struct ocelot *ocelot, + const struct ocelot_mact_work_ctx *ctx) +{ + struct ocelot_mact_work_ctx *w = kmalloc(sizeof(*w), GFP_ATOMIC); + + if (!w) + return -ENOMEM; + + memcpy(w, ctx, sizeof(*w)); + w->ocelot = ocelot; + INIT_WORK(&w->work, ocelot_mact_work); + schedule_work(&w->work); + + return 0; +} + static int ocelot_mc_unsync(struct net_device *dev, const unsigned char *addr) { struct ocelot_port_private *priv = netdev_priv(dev); struct ocelot_port *ocelot_port = &priv->port; struct ocelot *ocelot = ocelot_port->ocelot; + struct ocelot_mact_work_ctx w; + + ether_addr_copy(w.forget.addr, addr); + w.forget.vid = ocelot_port->pvid_vlan.vid; + w.type = OCELOT_MACT_FORGET; - return ocelot_mact_forget(ocelot, addr, ocelot_port->pvid_vlan.vid); + return ocelot_enqueue_mact_action(ocelot, &w); } static int ocelot_mc_sync(struct net_device *dev, const unsigned char *addr) @@ -428,9 +497,15 @@ static int ocelot_mc_sync(struct net_device *dev, const unsigned char *addr) struct ocelot_port_private *priv = netdev_priv(dev); struct ocelot_port *ocelot_port = &priv->port; struct ocelot *ocelot = ocelot_port->ocelot; + struct ocelot_mact_work_ctx w; + + ether_addr_copy(w.learn.addr, addr); + w.learn.vid = ocelot_port->pvid_vlan.vid; + w.learn.pgid = PGID_CPU; + w.learn.entry_type = ENTRYTYPE_LOCKED; + w.type = OCELOT_MACT_LEARN; - return ocelot_mact_learn(ocelot, PGID_CPU, addr, - ocelot_port->pvid_vlan.vid, ENTRYTYPE_LOCKED); + return ocelot_enqueue_mact_action(ocelot, &w); } static void ocelot_set_rx_mode(struct net_device *dev)