From patchwork Thu Aug 19 17:40:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 500192 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 55A6BC4338F for ; Thu, 19 Aug 2021 17:40:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 34A84610A1 for ; Thu, 19 Aug 2021 17:40:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232456AbhHSRlO (ORCPT ); Thu, 19 Aug 2021 13:41:14 -0400 Received: from mail-eopbgr00081.outbound.protection.outlook.com ([40.107.0.81]:62067 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229520AbhHSRlM (ORCPT ); Thu, 19 Aug 2021 13:41:12 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hTDBhCeNT6mZVkxyNiqhrk0SvC7G47OrgmN+Nqb6y3FhKMUDQkABRg6XPEtHhLKkU1b/q7z1BYsp9YWPATmcnCB9oDXI9WGVDchO9oVPcUis8zfkS/o4ZmB0nfBkR/S6gcIQA/tljGSGAg6MSKbgj45Q9ioWV5hdYXNtZx4zDROP2Z7Kpzr9EOri2IOb92LUyKftIh6Lr6gy2fBrnPxe27bXWxu6QyrN0yrVg2TO5NpaE7Fs2kFQXNblpml+gkuYa3t+jMGvwGu9OYmB7Xa4lnNYqKKSFq3ENYeIcbM3MgolkNzhP39j65nyOYMkxT2n/ljdNLBNs2pBPYc9qEpFFw== 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=3WQCwH5GbFPvs5E2VGIWrR+dDYLsA6Qori/cPxi4Lqo=; b=h77ISEC5pH5vEBzyxld4B40MvV7ypj3v8Wq34MKIr4qXWsM0RD4faqLIPXVEX0IABYxSbGyAEMBhD3wrEWbkC7gP4bmLKqzflFjzuFzONQ34hAvgKXuxFLmvn7KiQZA+OGt404YvzBLaXZ+EhsKLnD1T3Rckbxxx4xuN42guVosCWARNReTzTpEz0MOsmt+IsMq86loFhL5rk8Cx9C5RvucQ7SrKDipkJRiY9QnIZbnFanj9FoR0PlKB6vVnPUn6yleIITIzblAcALS5xbh4NAuuDwuhE4Zi8U9/R9vYJZFCSkn3evtKMOPrLXJHw++/+OKZnIppKm4djVmdDcxbSw== 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=3WQCwH5GbFPvs5E2VGIWrR+dDYLsA6Qori/cPxi4Lqo=; b=Smv6VfeJS2DOowKTrwyyxuOVIj1F2y0g6Uhfauj34OIlJoPWvnulbKio7I3/a3qrDaHWZgckEmRqS0WPU1C73UoXCwKyHoaEdSIac11S1Z4bVB9fQ8hQnZ8iMpq096lSR/6bjr6HKsVldXuvmrSGGWl5Fn1KPIMK9lL7J/OPZ68= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0401MB2686.eurprd04.prod.outlook.com (2603:10a6:800:5b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17; Thu, 19 Aug 2021 17:40:33 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4436.019; Thu, 19 Aug 2021 17:40:33 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Alexandre Belloni , Florian Fainelli , Andrew Lunn , Vivien Didelot , Claudiu Manoil , UNGLinuxDriver@microchip.com Subject: [PATCH v2 net-next 1/3] net: mscc: ocelot: transmit the "native VLAN" error via extack Date: Thu, 19 Aug 2021 20:40:06 +0300 Message-Id: <20210819174008.2268874-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210819174008.2268874-1-vladimir.oltean@nxp.com> References: <20210819174008.2268874-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR02CA0191.eurprd02.prod.outlook.com (2603:10a6:20b:28e::28) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.144.60) by AM0PR02CA0191.eurprd02.prod.outlook.com (2603:10a6:20b:28e::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Thu, 19 Aug 2021 17:40:32 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 041e1e6a-6cf0-4fd9-edd8-08d9633871d3 X-MS-TrafficTypeDiagnostic: VI1PR0401MB2686: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 26D1ibyKN6p95vqkHt6x/zNmqo3i0B937kdVPmOuhPmrgwzoP32flGatuBjauidtP4vl54XeOB9TC7dq4eFRKHSsTR3N5MjBXjkhlA6XlxVgeh9JF41MNLdb+amCYwJmocWSmRsuL8kDzDXdGlarE9XiF8kAwBR87kpL5Q8GZdkYE/zENRKdUAkozAzWjIm90SBHctchFtbUsI/xp8mU3FL4aJ2Or+f+0/Vf6n0r31EqCTHlFDH3r/HHJyWK4g+IfhdoyH0W7VYylJUksnzziBWSZzUrtWhvyNDhOuGAaWZ4V6hOUVuQviHHeJO0EEScvI/3C8LTLxiRVGyFMR9E1Zjbco34lxHWokvoEe0ndtNlI4gQEVuA8BOccoF1z31OE3mkWJ/NTSBqPLguVPG0Ewz8LyZbOIl4rxG5j/MclNoCZqGYWqU8z3jf4CR4KaF2Q47KPphV82bzT0rqapV5UExAi8PpdeY1xhB7bHpxEzNlWmZUrDuSJwjW5Qi9XLvS0ygfMg6VOK0TvEmhu9RUmqSC6bDJse2opq4lK6um8kE/vJgHimbiqo/4cjGtAS6Q/KOPWQx0rTCVnUMBhXbBUTqUiDQrH4yZ6NnYvc3tSI5Ml0FJwyThLAMm3yAus8Q8qdAYcYgrqd56MQZL6Zwjzf7ZH8xie8ru4vxkm7/wTIUUf4shEu6akcEe95gYC1/xCzcJT/tpNBi9JCbJ+3eqYQ== 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:(4636009)(136003)(366004)(396003)(346002)(39850400004)(376002)(6486002)(316002)(6666004)(44832011)(83380400001)(110136005)(54906003)(1076003)(8936002)(36756003)(186003)(26005)(38350700002)(8676002)(5660300002)(6506007)(6512007)(86362001)(38100700002)(4326008)(956004)(2616005)(478600001)(66476007)(66556008)(66946007)(2906002)(52116002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: o5ce7OdFFnXrlqUbo+iHFh9Q6GM27RcO25cYpEFkc0tau8B7kRU6OUxiR88THkssa7OSveeqDNahLNxNrDPo+nuC+ITMs0HjZEKxhLDTtRHXUCoFDPksww/XhR6Rf4Jfrx8xipKaD59rfSdEsi/Me1qBAwmitq5Wrz1iDm8Z2JkTWc+aJRalvXT8amNgvLlFKcQ6bbC33yyDymjMUh3NgLGNGNIYszQRg7ZkmQkeODyaTaxRGyOOT26ewjDasbGOOJIjRKuRCeYTS63M+1p6y6eVc+GNN1RBsIRhTotYoO9kW8EYcGHSiiEgN9/luXxl8E1cuueuP7xYDLTarnLKEEYkUHWsb2hHoLRLNzjopvJmbgQIi8KK9lpzT/hJ4V5Zz3CdgHwBhKNAYMPe0hAcn40xyEpU4WyRiKbQ+x/FgFLH+6KAkHrAWNH6Fw0s9ousfQ+ceUUVE0YYAf89M5ma0RhrnrAmbpUz82NPRCJCs6/B+j9FhtWYffUxsp/9nOwJio64l4FOVkMhIXnNPGaTX+VqJD+OuNHYzWlRt6+J4fOr9hcAzYXybtbkt+1v9ZQ06aUgLsnoIiIdMxxIl+X1shUKZFzhRKnvJP7XBvub0uquT9VzSqdxK078Cs8RogOFRAbnrd7W59b9TNuSDSX37sh80pUu6elnOdyZggY2y0cdY0CyE/Psuo889Yuj1L+Xlb1S2D8FLThDDZMRkw7/brCfjZpWilvXqbJUDYGk6h8VALjt9yKePXyuAt4PfddC6PimQfh/9D9NIE7FzmU4xUD2pDH/YULQ0gIo2SJ1cm2p9nKLW1wkCaaZ+ldkzvBhzuaWqHHsJB+KpcqzdlXlUKKERCsTaW1yuNm92wOJpFUITgYqN0fzAlfm1xtPWWBtv2yWKXW6mHR2xoaILDaTbhV2SAJJnXQ88kZb4cNgilq37FN1iE/8TY/qv8FzqJTgTOsNuzycotoP7soIn6wYLRRcZ7mOJ168cp/mWyzJnVKWJ+3spkYefYNhjeDWhjSAMof2JKw8y0DQH0BufZFPszLW6E5U6FXg5oPBUyczxPGuwHUO8GHmG0qTp84ZsUCKlLKiHLrv9qAWESLuALBgrbJaqrY6n7rj5zZAkLdEz0rOFHfUMAeQTitnUTivwCN+8a/aXEppNNRz9L/v/o3Vc0pC2PlFbsBQp1J9YygPpoSqPQIknqHllLTYm9s9XTnyvqFt3KDHiJN6cgFHakCBxSYh9y2DHwdK85dXiWrtkCSDaJnHPaGx9uAbz1VusACdEZdhmginIWnyGFSBj6/Wzf77eSwwymKy/f/EtWF1nTuitAtMIFm8R+ZtVG66KS4j X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 041e1e6a-6cf0-4fd9-edd8-08d9633871d3 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Aug 2021 17:40:33.0217 (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: eezxJwBbm3SpV2oWyeUYQHaDEk+l7qBXDNlGyDm8aOYRqcUQ0edxBno+TeVOhzOjUF4zyzyAHR/btySmY5bI6g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB2686 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We need to reject some more configurations in future patches, convert the existing one to netlink extack. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/ocelot/felix.c | 8 ++++--- drivers/net/ethernet/mscc/ocelot.c | 7 +++--- drivers/net/ethernet/mscc/ocelot_net.c | 30 ++++++++++++++------------ include/soc/mscc/ocelot.h | 2 +- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index e764d8646d0b..0b3f7345d13d 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -740,7 +740,8 @@ static int felix_lag_change(struct dsa_switch *ds, int port) } static int felix_vlan_prepare(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_vlan *vlan) + const struct switchdev_obj_port_vlan *vlan, + struct netlink_ext_ack *extack) { struct ocelot *ocelot = ds->priv; u16 flags = vlan->flags; @@ -758,7 +759,8 @@ static int felix_vlan_prepare(struct dsa_switch *ds, int port, return ocelot_vlan_prepare(ocelot, port, vlan->vid, flags & BRIDGE_VLAN_INFO_PVID, - flags & BRIDGE_VLAN_INFO_UNTAGGED); + flags & BRIDGE_VLAN_INFO_UNTAGGED, + extack); } static int felix_vlan_filtering(struct dsa_switch *ds, int port, bool enabled, @@ -777,7 +779,7 @@ static int felix_vlan_add(struct dsa_switch *ds, int port, u16 flags = vlan->flags; int err; - err = felix_vlan_prepare(ds, port, vlan); + err = felix_vlan_prepare(ds, port, vlan, extack); if (err) return err; diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 8ec194178aa2..ccb8a9863890 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -259,16 +259,15 @@ int ocelot_port_vlan_filtering(struct ocelot *ocelot, int port, EXPORT_SYMBOL(ocelot_port_vlan_filtering); int ocelot_vlan_prepare(struct ocelot *ocelot, int port, u16 vid, bool pvid, - bool untagged) + bool untagged, struct netlink_ext_ack *extack) { struct ocelot_port *ocelot_port = ocelot->ports[port]; /* Deny changing the native VLAN, but always permit deleting it */ if (untagged && ocelot_port->native_vlan.vid != vid && ocelot_port->native_vlan.valid) { - dev_err(ocelot->dev, - "Port already has a native VLAN: %d\n", - ocelot_port->native_vlan.vid); + NL_SET_ERR_MSG_MOD(extack, + "Port already has a native VLAN"); return -EBUSY; } diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c index 04ca55ff0fd0..133634852ecf 100644 --- a/drivers/net/ethernet/mscc/ocelot_net.c +++ b/drivers/net/ethernet/mscc/ocelot_net.c @@ -385,17 +385,6 @@ static int ocelot_setup_tc(struct net_device *dev, enum tc_setup_type type, return 0; } -static int ocelot_vlan_vid_prepare(struct net_device *dev, u16 vid, bool pvid, - bool untagged) -{ - struct ocelot_port_private *priv = netdev_priv(dev); - struct ocelot_port *ocelot_port = &priv->port; - struct ocelot *ocelot = ocelot_port->ocelot; - int port = priv->chip_port; - - return ocelot_vlan_prepare(ocelot, port, vid, pvid, untagged); -} - static int ocelot_vlan_vid_add(struct net_device *dev, u16 vid, bool pvid, bool untagged) { @@ -943,14 +932,26 @@ static int ocelot_port_attr_set(struct net_device *dev, const void *ctx, return err; } +static int ocelot_vlan_vid_prepare(struct net_device *dev, u16 vid, bool pvid, + bool untagged, struct netlink_ext_ack *extack) +{ + struct ocelot_port_private *priv = netdev_priv(dev); + struct ocelot_port *ocelot_port = &priv->port; + struct ocelot *ocelot = ocelot_port->ocelot; + int port = priv->chip_port; + + return ocelot_vlan_prepare(ocelot, port, vid, pvid, untagged, extack); +} + static int ocelot_port_obj_add_vlan(struct net_device *dev, - const struct switchdev_obj_port_vlan *vlan) + const struct switchdev_obj_port_vlan *vlan, + struct netlink_ext_ack *extack) { bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED; bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID; int ret; - ret = ocelot_vlan_vid_prepare(dev, vlan->vid, pvid, untagged); + ret = ocelot_vlan_vid_prepare(dev, vlan->vid, pvid, untagged, extack); if (ret) return ret; @@ -1038,7 +1039,8 @@ static int ocelot_port_obj_add(struct net_device *dev, const void *ctx, switch (obj->id) { case SWITCHDEV_OBJ_ID_PORT_VLAN: ret = ocelot_port_obj_add_vlan(dev, - SWITCHDEV_OBJ_PORT_VLAN(obj)); + SWITCHDEV_OBJ_PORT_VLAN(obj), + extack); break; case SWITCHDEV_OBJ_ID_PORT_MDB: ret = ocelot_port_obj_add_mdb(dev, SWITCHDEV_OBJ_PORT_MDB(obj)); diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index fb5681f7e61b..ac072303dadf 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -825,7 +825,7 @@ int ocelot_fdb_add(struct ocelot *ocelot, int port, int ocelot_fdb_del(struct ocelot *ocelot, int port, const unsigned char *addr, u16 vid); int ocelot_vlan_prepare(struct ocelot *ocelot, int port, u16 vid, bool pvid, - bool untagged); + bool untagged, struct netlink_ext_ack *extack); int ocelot_vlan_add(struct ocelot *ocelot, int port, u16 vid, bool pvid, bool untagged); int ocelot_vlan_del(struct ocelot *ocelot, int port, u16 vid); From patchwork Thu Aug 19 17:40:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 500191 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 ADAD6C4320A for ; Thu, 19 Aug 2021 17:40:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9398C6108F for ; Thu, 19 Aug 2021 17:40:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233365AbhHSRlU (ORCPT ); Thu, 19 Aug 2021 13:41:20 -0400 Received: from mail-eopbgr00081.outbound.protection.outlook.com ([40.107.0.81]:62067 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232481AbhHSRlP (ORCPT ); Thu, 19 Aug 2021 13:41:15 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Yw8G5Bxg1swaGvHDkdk00vpvM8I0AUbmaeIV0X2UXIeEt5s6+8QiO88NLHCoEKDi9akvCTk5MAnpVksf2sdByBr4moiFWyn3NIeB9yC2SgjxniMbcLN1YBvWtaQWwHbpidUvwZTeaig2Isk1Ovq5sdWlwbrIzAW81FN6rI5Z8+kmAwD/oOonSUUeuYi3tRJXT1LuAC7xjPgzMt7pTLN1rwLkhU2IK4wkdk9iuL0werLVfJIPNf6S54RFL/hbdoUtOIVNXQ8V5xVCe36eorvVdqlsp6jdaWkvb96eZ4sBw/BHQsX9eRZ/hG5LnPL4oDzPE0eWY/mLsJoiCml+A29juQ== 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=zhImt1syFqdWJrYlFm96xbsLOURwpTwXQrNslGfzI0M=; b=cdLfAXwHzWEQhBpCrGQy5UUdFqyYUaXjfCOywFEjI/yZKmXeN9HMev3L1/6lx9IXvVG8CvdVmaDwxjwRyFC9wzjJ5YSPg/0F7GrobbdgH5LIQ0Az6p+Ib8f1kpEKtuNDdzoiZqRNWiRW4zBJx1IMW6XCYBS0xAvemqeKaIc8TQRFlm4aDiSiO4Q+NxmxrljjDt7r89oHyzzYty52pqYSDoMfTWo6meSgXEXBCqxmp6MCYtS8X8n6tS66X18GBO51OAmi9P/vczVqx1brcmfhor0DETopZpDtkCVGEdOxx37aMzLHeRW2pulC3WMRLQezp2z8kirKdMOM2Q+VZ5JeZA== 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=zhImt1syFqdWJrYlFm96xbsLOURwpTwXQrNslGfzI0M=; b=QhF39yBu234W2lZaUUOyIMvW7AWsplxVuR/e7tx1xlXfN524O7YeQgogFIBoBKFPwr3mMC24zyxfHVgfSPsOKVUNGjzY9NLnxfWwogF7gPhudEmypRpJdsqSSrifABFFIKkh1fDJ8PxljtmkhJ3odfuveosIBRS42+JlYbgnTU0= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0401MB2686.eurprd04.prod.outlook.com (2603:10a6:800:5b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17; Thu, 19 Aug 2021 17:40:35 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4436.019; Thu, 19 Aug 2021 17:40:35 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Alexandre Belloni , Florian Fainelli , Andrew Lunn , Vivien Didelot , Claudiu Manoil , UNGLinuxDriver@microchip.com Subject: [PATCH v2 net-next 3/3] net: mscc: ocelot: use helpers for port VLAN membership Date: Thu, 19 Aug 2021 20:40:08 +0300 Message-Id: <20210819174008.2268874-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210819174008.2268874-1-vladimir.oltean@nxp.com> References: <20210819174008.2268874-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR02CA0191.eurprd02.prod.outlook.com (2603:10a6:20b:28e::28) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.144.60) by AM0PR02CA0191.eurprd02.prod.outlook.com (2603:10a6:20b:28e::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Thu, 19 Aug 2021 17:40:34 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e23fb2a2-c62f-446b-5d60-08d963387319 X-MS-TrafficTypeDiagnostic: VI1PR0401MB2686: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u7itYSFm3bKmtoRrVBkSQVovLFz+qTFFqXAvnDetzWGwjRy1NDUx22fqo6JvKmRDf5uegJciI+itvjnlKdQQ1dYhMOdUNGcSJDxe09NBuSZXZWyxBJDXYW74sqwmV4hflLCUn3DZiPTYrAWF1W1UfZ3fLRG1juVdHKoeAcfUI7bHdBkp3PbhrlV8hqF+nmTJWy3NwxYJlaLF91+qEdCqV4WYjoZXJoGU6AcAM7+dQ0IAg2WLYQxyFVPKyjwCkfsg+OjaLejL+zyDfLW/oUgxC/ghx87jMmw8TsHZbSellHpbfpk/d8GdCuSGHG+c768kqyJUKJ8a8ufoWpj55Q/EH3U/pcjTpedAww1tz5Zp/qq5MTbC3uxTeEjrM+jnsU8wZJ/L02TooAWr08yXtWzbZBVjeTwWZ4AA0iJ2q3mqbJ4Uke3IDv959IcZ4vGNl+w0sJwH4GwTIBYU60q4n+qOyBO9lJQ8z7M8PDHJ8VHR8LabtMKtoXnXyEANGJRQP4EEP9/P2UMWHZGxxDPJlua41WQ6cFC6kmiq2/SUnE2skT3bf9K06QRfjLyKvduq1UMpuiXB+7KwDsVrS4MD5cTIURoRjT7qFP7nQfxO4wrPZ0t2OViEO1dEg6105ciH1Kw0FDKi7iSOwZtGf2PkQkc5xlGoNnonVlVmBkDp0ofzuvl/7A1NgpFIMh+2Wcp68d5Sc8LAwew4J87Ji30PdtiRPg== 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:(4636009)(136003)(366004)(396003)(346002)(39850400004)(376002)(6486002)(316002)(6666004)(44832011)(83380400001)(110136005)(54906003)(1076003)(8936002)(36756003)(186003)(26005)(38350700002)(8676002)(5660300002)(6506007)(6512007)(86362001)(38100700002)(4326008)(956004)(2616005)(478600001)(66476007)(66556008)(66946007)(2906002)(52116002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LBvS9s8B+UdGjCCDFSLYNo3VRtAOqL8YZP8AxG/sgxbQFPw4WqfiSB4/rph+8s2Kv81kicu45qItHHmsiPHcJbIaJfA98G7MDDpJiD/+IwukTtzQLZjfluCduJmt9b9CcCErYMm/3i6OUAlZPhSkJ9K7ly5x3DQTxq1SbkeYr/458a5/0NtyQBLnY6LztsiGNh9UHhupbpj8dWL6DbBbyRY+hliV4pRepzXnzkAPOJoSQUCWbVFuLXpu8aXfM+FZmHbI7AY7b0yZjpaVkEp5OX1UJ9+jamaHzHyld8A+Ka4rA3LrLWQ5NpQ+GAxkpnH9RrDCx1J24L6twQi4yOfdTCbVQaMgHhEb4F68jS9VI8ZwxzYTeUByZPEWooYycn5FHOjoq54OhlxounoN4sTIMtdSylbfgUpK4AMLTEyPE6wf1uBjKzd2xJMBTlhLweymldMscQigD41gSf0lipeXrDgOW4Qc5qBygIanHtP7jbk/lRDr8qWx+hoD1IEE1hH12OzwpgeWL5myyFp9jf4Cf9ujRL2JnyL2ddKDt9F+mBkzLIQC64v1Aj6DaBbait5gLW1mk32XO6vOPAlusagSRxiVtvLnLu2U3aNqObXk7ANX2cwvnjUlrohCQCzjihQMDzQM4kEUf5iZZKKmXrzjprBOjo78B6Bbq4b3OYdcGWTTgjSXyinWX+k1RDZXD3LD8RwRLkDBZCRREke06LMLQcXhxsr9f42a+lN5NmxPR2sQ4745nqXa/iqzKa8RRA+1uS/Fiw4cGMUQiSd9ck/R33I+Ur//LEGQypwGqK3F7v0MeEOL2yGPTmxW0Dlz+vU6Jz1TvMfl8gZISZQBA/J7mOyakieJBjpGS3LrLDb27+niP+dKd5zTscUg2RYJwP+Csb4QHXM2EL3rIZmUtQRIMolREAITmtAxi3P4IU4/IwSY0rUh/4H6pc6bTwRIbF89WJRLpjbrTijnQsMgsAfaTMTvun/4pACCRLLcXXMk3HYYGiDBkZei9A6HtcqxS9Kzd97dyADRaup/zF9pTJqT5vLwK2pat/wO0DPaM0CQ601SG7TvZS3Fn8gnnc/A82/Re/LNT9Fzn31snZzz/o7+osgk3FWOAYXMPWB6v5gDc/q857kxJ/bI+UuRFybBTxDRAgmLmPkz6egqFDgsZoTu8uxyMQQAlDs4mZfMnPKfLBBktlK7eT8BvBvOIrqjKbO3Ls+3hXZV1UZvVHgNdFQgHiCRaOqDDm5RW/6ogTkC/sIs+JRGvXJtsFE88vX8Iba4TMkQEQ6VbgunZ8xgd79ruq/VLtjNSco/6dAZbomC07B/SpA0oPHQUeLU/JPg8gEV X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e23fb2a2-c62f-446b-5d60-08d963387319 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Aug 2021 17:40:35.1145 (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: hKkkzPGKqgQ/Qg7QYKGYH869s9Yb5FYV+cdFgq5ec8UUQIVn1C6MfUOZEtrrvqFj1X0i2pxVfwgv0ZF4d5Fl4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB2686 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This is a mostly cosmetic patch that creates some helpers for accessing the VLAN table. These helpers are also a bit more careful in that they do not modify the ocelot->vlan_mask unless the hardware operation succeeded. Not all callers check the return value (the init code doesn't), but anyway. Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/mscc/ocelot.c | 60 ++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index e848e0379b5a..c581b955efb3 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -222,6 +222,33 @@ static void ocelot_port_set_pvid(struct ocelot *ocelot, int port, ANA_PORT_DROP_CFG, port); } +static int ocelot_vlan_member_set(struct ocelot *ocelot, u32 vlan_mask, u16 vid) +{ + int err; + + err = ocelot_vlant_set_mask(ocelot, vid, vlan_mask); + if (err) + return err; + + ocelot->vlan_mask[vid] = vlan_mask; + + return 0; +} + +static int ocelot_vlan_member_add(struct ocelot *ocelot, int port, u16 vid) +{ + return ocelot_vlan_member_set(ocelot, + ocelot->vlan_mask[vid] | BIT(port), + vid); +} + +static int ocelot_vlan_member_del(struct ocelot *ocelot, int port, u16 vid) +{ + return ocelot_vlan_member_set(ocelot, + ocelot->vlan_mask[vid] & ~BIT(port), + vid); +} + int ocelot_port_vlan_filtering(struct ocelot *ocelot, int port, bool vlan_aware, struct netlink_ext_ack *extack) { @@ -278,13 +305,11 @@ EXPORT_SYMBOL(ocelot_vlan_prepare); int ocelot_vlan_add(struct ocelot *ocelot, int port, u16 vid, bool pvid, bool untagged) { - int ret; + int err; - /* Make the port a member of the VLAN */ - ocelot->vlan_mask[vid] |= BIT(port); - ret = ocelot_vlant_set_mask(ocelot, vid, ocelot->vlan_mask[vid]); - if (ret) - return ret; + err = ocelot_vlan_member_add(ocelot, port, vid); + if (err) + return err; /* Default ingress vlan classification */ if (pvid) { @@ -311,13 +336,11 @@ EXPORT_SYMBOL(ocelot_vlan_add); int ocelot_vlan_del(struct ocelot *ocelot, int port, u16 vid) { struct ocelot_port *ocelot_port = ocelot->ports[port]; - int ret; + int err; - /* Stop the port from being a member of the vlan */ - ocelot->vlan_mask[vid] &= ~BIT(port); - ret = ocelot_vlant_set_mask(ocelot, vid, ocelot->vlan_mask[vid]); - if (ret) - return ret; + err = ocelot_vlan_member_del(ocelot, port, vid); + if (err) + return err; /* Ingress */ if (ocelot_port->pvid_vlan.vid == vid) { @@ -339,6 +362,7 @@ EXPORT_SYMBOL(ocelot_vlan_del); static void ocelot_vlan_init(struct ocelot *ocelot) { + unsigned long all_ports = GENMASK(ocelot->num_phys_ports - 1, 0); u16 port, vid; /* Clear VLAN table, by default all ports are members of all VLANs */ @@ -347,23 +371,19 @@ static void ocelot_vlan_init(struct ocelot *ocelot) ocelot_vlant_wait_for_completion(ocelot); /* Configure the port VLAN memberships */ - for (vid = 1; vid < VLAN_N_VID; vid++) { - ocelot->vlan_mask[vid] = 0; - ocelot_vlant_set_mask(ocelot, vid, ocelot->vlan_mask[vid]); - } + for (vid = 1; vid < VLAN_N_VID; vid++) + ocelot_vlan_member_set(ocelot, 0, vid); /* Because VLAN filtering is enabled, we need VID 0 to get untagged * traffic. It is added automatically if 8021q module is loaded, but * we can't rely on it since module may be not loaded. */ - ocelot->vlan_mask[0] = GENMASK(ocelot->num_phys_ports - 1, 0); - ocelot_vlant_set_mask(ocelot, 0, ocelot->vlan_mask[0]); + ocelot_vlan_member_set(ocelot, all_ports, 0); /* Set vlan ingress filter mask to all ports but the CPU port by * default. */ - ocelot_write(ocelot, GENMASK(ocelot->num_phys_ports - 1, 0), - ANA_VLANMASK); + ocelot_write(ocelot, all_ports, ANA_VLANMASK); for (port = 0; port < ocelot->num_phys_ports; port++) { ocelot_write_gix(ocelot, 0, REW_PORT_VLAN_CFG, port);