From patchwork Thu Apr 26 16:32:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10366371 X-Patchwork-Delegate: idosch@idosch.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CEF436032C for ; Thu, 26 Apr 2018 16:32:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5FBDE288EE for ; Thu, 26 Apr 2018 16:32:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54403288E2; Thu, 26 Apr 2018 16:32:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, MAILING_LIST_MULTI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9B3C928492 for ; Thu, 26 Apr 2018 16:32:55 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40X2ft0pYJzF252 for ; Fri, 27 Apr 2018 02:32:54 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=mellanox.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=Mellanox.com header.i=@Mellanox.com header.b="v4bjPLq5"; dkim-atps=neutral X-Original-To: linux-mlxsw@lists.ozlabs.org Delivered-To: linux-mlxsw@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=mellanox.com (client-ip=2a01:111:f400:fe0a::628; helo=eur03-db5-obe.outbound.protection.outlook.com; envelope-from=petrm@mellanox.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=mellanox.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=Mellanox.com header.i=@Mellanox.com header.b="v4bjPLq5"; dkim-atps=neutral Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-db5eur03on0628.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0a::628]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40X2fn67w8zF259 for ; Fri, 27 Apr 2018 02:32:49 +1000 (AEST) 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; bh=viT4kgKvLaT/HlZFFYLgqqPQcZ3JFfI/Mq6hHzBrIr4=; b=v4bjPLq5QwzQcWrenfwurjGAYHA33lZB5f93yJemzCvB7sPdrMyNhMXtyeA9vbRpSCMDjKu5ZpOi0onEDGDpSnqgULzASRzi+ZP/C5LqSP6wzAqycJX5Gk831HUqO/1k9q0LY1iG1pmE/6kBx1lgVNboA9xpJoSPe5ZTYjY/y+Y= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (78.45.160.211) by AM0PR05MB4178.eurprd05.prod.outlook.com (2603:10a6:208:57::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.696.15; Thu, 26 Apr 2018 16:32:42 +0000 From: Petr Machata To: Subject: [PATCH net-next mlxsw v2 2/6] mlxsw: spectrum: Extract mlxsw_sp_stp_spms_state() In-Reply-To: References: Message-Id: <877fc161447981c7938190bc268da4c891ff942f.1524759641.git.petrm@mellanox.com> Date: Thu, 26 Apr 2018 18:32:37 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 X-Originating-IP: [78.45.160.211] X-ClientProxiedBy: PR2P264CA0043.FRAP264.PROD.OUTLOOK.COM (2603:10a6:101:1::31) To AM0PR05MB4178.eurprd05.prod.outlook.com (2603:10a6:208:57::27) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(2017052603328)(7153060)(7193020); SRVR:AM0PR05MB4178; X-Microsoft-Exchange-Diagnostics: 1; AM0PR05MB4178; 3:A5HICXiCg4oN9ysQ4Ppb0+c7xuK0dQ9TApUpmzIinu5noqs+kQzLiMjPyozk5ffJS1ZUAHLnXHgWdYjAeC4st21+WnER3lIRw0+UUO1ayhtSrzLVXReIF0uamctk27wicd+aGylWJubuOtlYuGIsEKotwbbuiAgA8TBHkfyFhcJ/TuQpvnYtVN0MklJAXJZkgWku+vzmCWdrlw0jb9AuUd+rRMsnmJDBL/g+6okOXo2KMb1IKKAcrm6LwvLwwxWv; 25:xp+3QQM3M71/3FLtOZjoI/8vHcDpr6FbjGhhJMFK3NbG+iSM2AD7eBHGp48IFcKBpiC8WmElGTk18a8ZJ188DgsGasTLf/r7OYd0dlJlXPPTeIzhJE5qwh0+hWxKIlitHId8z4FQhli8Bz/MjnNuXx2DWtNP/VeRGB2kuoAe9gHu5AwhKDfXakfi/5l0yD/1/K9Kjc3NS5HgfkkkyKBW8sFdZC9bJOje1JlwGS+M/UIkisdYDYo+rbtoWLDhZmU7CmPAGEXYjG8gRBm4KOddMdBBxxpOm7Q1h65YSdE7PFhK/Atpl2wV8FaqNIJZv97GpeN+j0i/j/jHSM6jfGTK8A==; 31:oPqWJn1rRCvNro8RBHgN8tUJ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oft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3002001)(93006095)(93001095)(3231232)(944501410)(52105095)(6055026)(6041310)(20161123562045)(20161123560045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:AM0PR05MB4178; BCL:0; PCL:0; RULEID:; SRVR:AM0PR05MB4178; X-Forefront-PRVS: 0654257CF5 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(39380400002)(346002)(39860400002)(376002)(396003)(199004)(189003)(76176011)(386003)(36756003)(6666003)(6916009)(2351001)(51416003)(52116002)(48376002)(105586002)(305945005)(50466002)(8936002)(3846002)(81166006)(107886003)(7736002)(47776003)(81156014)(6496006)(53936002)(6116002)(8676002)(58126008)(66066001)(68736007)(5660300001)(2906002)(476003)(118296001)(106356001)(25786009)(16586007)(4326008)(26005)(2616005)(97736004)(956004)(11346002)(86362001)(59450400001)(16526019)(486006)(6486002)(446003)(316002)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR05MB4178; H:t540p; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM0PR05MB4178; 23:GTp411wJ0WMT/5WOa5H2Dgs6yrfRc7Jz+tR0s3giX?= =?us-ascii?Q?BC5oxjLx5MkM4+AJOWD2m5tBX3UkiyR5LOJT+9cMhN4fDI0SPfjGuJqFglHp?= =?us-ascii?Q?CiFyrvOtR7ACFw7RgzmGmsjsQc/uD135zzh3YDHyY4wUgOm65nl29q1/KA2/?= =?us-ascii?Q?ugUa8df77zBWdlm8RDskmPya89pWvemAP3HbtSKFlL4Kp6VV/kTwjI2xqRNs?= =?us-ascii?Q?/z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zqSWpHfuDC3Kt17vhw0Dj?= =?us-ascii?Q?6m+bgHYiE+qijb92IAiUQYVPJVp9/k0elBbwvLgJiVCyNlxBAoIkl9T8MpBU?= =?us-ascii?Q?DHfw0sYZP6+z849xhjJAaANeszWpatln1rCU7pMtf7yvEnVGLRYpebwbg=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Antispam-Message-Info: VfVAPjV3fUaqcGW6GUlg+v6t4mtOV0CrURm2pVG6eLKKQPL7BmPDc9ZayHirIkWtGoEbBIL/5RaVl/vvAqJEaT40/6JyzgEnvP18J/wsiV7cejirqxW42NIxz4kamyeVvSBcRwPwehCfPlWL9A2H1+LXQllkEVar0RsavPHazSxe7bbm0KsDI0r11fjUswvR X-Microsoft-Exchange-Diagnostics: 1; AM0PR05MB4178; 6:2JiHF/GDF/Ut8mSTV1W0K6IenouomIURCxgcCcztRAl91y2PIb8V/L8v/Qm6DQZVkHKbrCrMQp7TerDZ/QnT1A7+KHlnubKnibx/c7cinebQaE2ReTkKYxiXjapwZCPob7l1lL4mkNRLrE84SxopFoDyitj/nydsvdLw0VdxpuZtkmlMgjeIW6XU4RWjPyNCLJzJjf/+xZxhRIEgFQbDJnQhtw3m49xYXBDUCnFCoSHwTKLdR2m1paeI0m/8km7RcwHRGxQmy5dmXrm4HkcOZOxiCeLh5VLr6OvtgkjyBSlSJguwOOobBbVjsZTlAFQSp4ssVXiooB9ip8Y6gRkDVA0hVn1QmJzapPbbYVkzKJW/z8SXGkarxIixi33wcz4kxPcUezJwH3vJVTN4k7ya+69YzFwZEEpuxwCWquLd8AV+z62dpANVTax30lq4bdprMDUJDxn3ZZEarxH/5xAf4w==; 5:G0SptSqVwK64IQ+udIyy6z9K3KtFIHWLTjyQLsk639hEz4Zp2SVr822ZZR/hplbApUExdWTLfzgpLSW/mi+K79HYKywliwMK/7jti3uiYw7NKM3Hhm+k7V+ouwqdKaN+pXfJylRfZsa+nijVLKNHcjmKuKLA1ZQ+QVW9a7Ev6L0=; 24:Ffn6gm6+27A6LHBxDLmvZE4lvFjAtn+JzTyH0vPIssVLuavQNp886i6fnM8flVYlU5NGaVCq8pKFCB05y/giDy1F3loYTrtr0GSk50p+JxE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM0PR05MB4178; 7:muPp6vEH8585vEn5AhUGp1Heam8sPVkRzPqaRCruqibk1nuc2Zw/MpMcdnX+1G1Yjat9AA8Tx7zdhtZ+zibtGO6taclgdz95hUtW0m9aIAEjjvg2Pemf1/zWBQKUb775ui1aYXN1KoaHTQ/NFJE181rK7h/zxfO7cBvaKMBV2GGUT+hpab/yl9zip0kLVF3bG4GG6dDz0Rb0weEzWUuZKx7Se/kVRoQ3Slqq+oi3e+CE+LiPjuCwbZKdND7gbomk X-MS-Office365-Filtering-Correlation-Id: 3b2104b4-0105-4d7e-10c7-08d5ab9355b1 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2018 16:32:42.6815 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3b2104b4-0105-4d7e-10c7-08d5ab9355b1 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB4178 X-BeenThere: linux-mlxsw@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: mlxsw driver development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-internal@mellanox.com Errors-To: linux-mlxsw-bounces+patchwork-linux-mlxsw=patchwork.kernel.org@lists.ozlabs.org Sender: "Linux-mlxsw" X-Virus-Scanned: ClamAV using ClamSMTP Instead of duplicating the decision regarding port forwarding state made by mlxsw_sp_port_vid_stp_set(), extract the decision-making into a new function and reuse. Signed-off-by: Petr Machata --- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 26 +++++++++++++------------- drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 1 + 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index ca38a30..7317fb8 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -441,29 +441,29 @@ static void mlxsw_sp_txhdr_construct(struct sk_buff *skb, mlxsw_tx_hdr_type_set(txhdr, MLXSW_TXHDR_TYPE_CONTROL); } -int mlxsw_sp_port_vid_stp_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid, - u8 state) +enum mlxsw_reg_spms_state mlxsw_sp_stp_spms_state(u8 state) { - struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; - enum mlxsw_reg_spms_state spms_state; - char *spms_pl; - int err; - switch (state) { case BR_STATE_FORWARDING: - spms_state = MLXSW_REG_SPMS_STATE_FORWARDING; - break; + return MLXSW_REG_SPMS_STATE_FORWARDING; case BR_STATE_LEARNING: - spms_state = MLXSW_REG_SPMS_STATE_LEARNING; - break; + return MLXSW_REG_SPMS_STATE_LEARNING; case BR_STATE_LISTENING: /* fall-through */ case BR_STATE_DISABLED: /* fall-through */ case BR_STATE_BLOCKING: - spms_state = MLXSW_REG_SPMS_STATE_DISCARDING; - break; + return MLXSW_REG_SPMS_STATE_DISCARDING; default: BUG(); } +} + +int mlxsw_sp_port_vid_stp_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid, + u8 state) +{ + enum mlxsw_reg_spms_state spms_state = mlxsw_sp_stp_spms_state(state); + struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; + char *spms_pl; + int err; spms_pl = kmalloc(MLXSW_REG_SPMS_LEN, GFP_KERNEL); if (!spms_pl) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h index 804d4d2..4a519d8 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h @@ -364,6 +364,7 @@ int __mlxsw_sp_port_headroom_set(struct mlxsw_sp_port *mlxsw_sp_port, int mtu, int mlxsw_sp_port_ets_maxrate_set(struct mlxsw_sp_port *mlxsw_sp_port, enum mlxsw_reg_qeec_hr hr, u8 index, u8 next_index, u32 maxrate); +enum mlxsw_reg_spms_state mlxsw_sp_stp_spms_state(u8 stp_state); int mlxsw_sp_port_vid_stp_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid, u8 state); int mlxsw_sp_port_vp_mode_set(struct mlxsw_sp_port *mlxsw_sp_port, bool enable);