From patchwork Tue Apr 24 23:08:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10361185 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 7EBC46038F for ; Tue, 24 Apr 2018 23:09:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6FE1E28D53 for ; Tue, 24 Apr 2018 23:09:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 64BD128E89; Tue, 24 Apr 2018 23:09:16 +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 85DC828D53 for ; Tue, 24 Apr 2018 23:09:15 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40VzY55YmpzF24H for ; Wed, 25 Apr 2018 09:09:13 +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="iaTgu3o9"; 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:fe1e::616; helo=eur01-he1-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="iaTgu3o9"; dkim-atps=neutral Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0616.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe1e::616]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40VzXz1ZkbzDqRk for ; Wed, 25 Apr 2018 09:09:07 +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=iaTgu3o9lJPLplCJ4ml9frxIZ5c7JSPk+yU/qQQcYdKkPUuVqfaRBE4gytoTxKSnMEKKD9mb67FNw/VhEH/vpSbbkjAD6GkSJGqSi51ticVfZUexSI32fLPVkZLFVl5tRZyLLdspk+TwNbuIyMTDLp8SFuWTVOhPb/ynqUawFNY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (89.177.127.115) by DB7PR05MB4188.eurprd05.prod.outlook.com (2603:10a6:5:18::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.696.12; Tue, 24 Apr 2018 23:08:57 +0000 From: Petr Machata To: Subject: [PATCH net-next mlxsw v2 2/7] mlxsw: spectrum: Extract mlxsw_sp_stp_spms_state() In-Reply-To: References: Message-Id: <66489e2afdaa48efa372fb950cc78e0bc9c4bbe6.1524610426.git.petrm@mellanox.com> Date: Wed, 25 Apr 2018 01:08:52 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 X-Originating-IP: [89.177.127.115] X-ClientProxiedBy: AM5PR0602CA0004.eurprd06.prod.outlook.com (2603:10a6:203:a3::14) To DB7PR05MB4188.eurprd05.prod.outlook.com (2603:10a6:5:18::29) 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:DB7PR05MB4188; X-Microsoft-Exchange-Diagnostics: 1; DB7PR05MB4188; 3:PP/jf5mSHbYl7FNzydpBbFFNCi3oU+mVZtp2oi+SWxRbIbMSsodH/eguBNkxA7/bzrNPxzNUjUWm9UR9yvDx3w7kVkVZ6DVGaRT3koSgqm5Eh7ghJ8wovMm98LP/ot4M/lk4ZGpjt1uhyOriKm1fEonCbfzqkT2EATNAAFFYjCBinUIVhckn21m2PazVBloweLeO+dv3De4NVWC/P29HHwtj5nXLFacYElkXlHpMGeGwaJ0bTu2M7jzSfsSusC5w; 25:1nqA+tUL1ko3eHlfL/aMHFb8pmHiCLfGmVW5ZQCDkcwViefFpfbavmWNZ39+YgiUdWiz3KgBOJugBqdE3mIP7Ci/CNHlXzs4PTGi8pLFaSYnd+XKEwhl8v+swcu2VJhLo8R/lhm78IPhwSuSUJX7bEZzT4Oru/kTOffao9MYQyfhmesdVsjFwPwnVztC8A5Yux1tn2IyUcqs9vL3f+phA30pjZewSGqenyjKe4V15TVGACmCyiSPKAcWe58W0MCI2AwXr/9sPe5vhHqjDnXUeoTAASuzW0bBlG9J1LMd38j74UQE+Gv5yS390cmQ7HNk/EwaZTjw4lyfjSTM30ayyw==; 31:8Gs5z0bBIAhWUQ7W7aEM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h9REEmPQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3002001)(3231232)(944501410)(52105095)(6055026)(6041310)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(6072148)(201708071742011); SRVR:DB7PR05MB4188; BCL:0; PCL:0; RULEID:; SRVR:DB7PR05MB4188; X-Forefront-PRVS: 0652EA5565 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39380400002)(366004)(396003)(39860400002)(376002)(346002)(199004)(189003)(6486002)(81156014)(106356001)(386003)(48376002)(305945005)(68736007)(81166006)(59450400001)(105586002)(118296001)(107886003)(2906002)(478600001)(2351001)(50466002)(86362001)(8676002)(25786009)(76176011)(6666003)(51416003)(6916009)(4326008)(52116002)(58126008)(476003)(16586007)(2616005)(11346002)(446003)(956004)(316002)(8936002)(6496006)(66066001)(16526019)(53936002)(47776003)(7736002)(97736004)(36756003)(5660300001)(6116002)(26005)(3846002)(486006); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR05MB4188; 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; DB7PR05MB4188; 23:d0N+pYix7h1rS6bpLCppxlZgccy2khJQu1Y09Q0nS?= =?us-ascii?Q?TtUPNKWaJ3MVBrJ1gutkwUGNeyQU9L1Yod5eg6t3AcQxFVlMLcB5tp/bUkrI?= =?us-ascii?Q?ABUu0rd6DwtBRzF2mpMZyn1oxBC+dWFoisCEObO6mH85rSoKSVg6qI+jdXOk?= =?us-ascii?Q?EiCg64M2rP7cpzOvU2Dv5NUF5IZnW94WEm0ZuzMftgn6n0AzgQoS87nrTC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y6mOku/tBjKP7zPkxq8Dx6u9EmABE=; 24:0wMZpWF3HqO6FNARaNAZQtbWqkyExT1w/PxKWHgXNbp/ubStrWXGBmJAdHsVfKykNaQ9iK5fvugPO2ZXnE3+jCzE24tjsv5XO7HaQSS75GQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB7PR05MB4188; 7:7xERKHJX1pONnu6gB/Ody4CH/aSF3YUh4wXvgFBFi776AHYJf+aki79OznwsGPGqlj8Y9SNSH8nfsUa02RXYNcue0n6nOH+uo6kiJwDfMDaDsVq2d9cRZU45NDM7Kh7CZmqCKy1zM7WahBLM19Mep3qdqRPauHfOCfoq7/VfMtiu6zAIO9NBZc/6hJrBBrLwufbePHniFI1AkykXCDzSY07DCgRNOdK17ZSCHz4LxHo85vyCpCA57sHzKPk3Zn6t X-MS-Office365-Filtering-Correlation-Id: 60f0bf9d-8af0-4cd5-2c71-08d5aa385b85 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2018 23:08:57.0406 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 60f0bf9d-8af0-4cd5-2c71-08d5aa385b85 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR05MB4188 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);