From patchwork Fri Apr 27 23:00:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10369979 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 0463D6038F for ; Fri, 27 Apr 2018 23:01:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E20BB29551 for ; Fri, 27 Apr 2018 23:01:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DCF78295A1; Fri, 27 Apr 2018 23:01:00 +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 4B1402958C for ; Fri, 27 Apr 2018 23:00:51 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40XqD14PlSzF25F for ; Sat, 28 Apr 2018 09:00:49 +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="SfJlfJ5O"; 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=40.107.1.83; helo=eur02-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="SfJlfJ5O"; dkim-atps=neutral Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10083.outbound.protection.outlook.com [40.107.1.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40XqCv70d1zF24m for ; Sat, 28 Apr 2018 09:00:43 +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=SfJlfJ5OGQk57BHVU89kHUKd7uVPI4RigIakImuULXj5hcHIiPo5V21HuHaERdoc9ZkPcR1bIxSnidf2wksXDaLBEH8T4lLoKJ0Y73DCG/xNI1rXc1frP+ibH3eli3KW2g7JttsOM1Ed6z64FI7jd73lR2EZWFhcLg8nZ1MJ2R8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (89.176.83.59) by VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.696.15; Fri, 27 Apr 2018 23:00:38 +0000 From: Petr Machata To: Subject: [PATCH net-next mlxsw v3 2/6] mlxsw: spectrum: Extract mlxsw_sp_stp_spms_state() In-Reply-To: References: Message-Id: <7fb7e9bad517232450f62f4c1b085151f83c04e4.1524868933.git.petrm@mellanox.com> Date: Sat, 28 Apr 2018 01:00:21 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 X-Originating-IP: [89.176.83.59] X-ClientProxiedBy: HE1PR06CA0155.eurprd06.prod.outlook.com (2603:10a6:7:16::42) To VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) 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:VI1PR05MB4191; X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4191; 3:KaNqQpScmu8qDpiQC2uVbeCQ5VT1398OTUZsAb+dl3e0yvmyjiSM/pzrmx8ecgaEQLEmXsZzX/Pbca3ChELuTsnZpMG/Nm8TLuhtd0CxYmlfVk5ZD+ys+V6F9ybyZoafBZDl5NuRVmvIHjXsGDOHQNZG1DxtDWbmHww3339p5GThmZR1r6cenToyyX8nPDyoy50VEeTaaLO80Y4b6PIhc86EjJVlzYkXYMV0JDnQYQsUOI7QLYF5R5GYKHxdqZbu; 25:61ILucRnrBay5WQ7u2w142jfu9zzdYaG9Zw/nvP4LXppBT1x2OTTxNHVTT5c7ehJ9nnTbWXCUJ3YsoGY/Kv0OUhycj8j0OZdFs3P5hxP9KNa/h4C2Z0EF9S8y+utT8zC0ZYkWmjnQyTCThK/bf/rRGFk9jd0bIbbu7D6TIMYlknC97fR4iTHKi0bsUjg0hZtsro5GApJUXgAXITjw956m+xOdCfSKZ6lu4DBdYcIv12kKenKAFYt76IvytT2oUyTmpT/2ECjDm5ypvXYAV/A+5BARhFOUM6LSp2WhoTqyJsSa5KggqNGlwNyI8yxuHh4Ogk39ghGWw+iK3PiMpChgw==; 31:wj7Mx7HtSYDhIiKHQbQJyFdGHyy3+tZmVn9Rpgs/f57O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-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3231243)(944501410)(52105095)(3002001)(6055026)(6041310)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(6072148)(201708071742011); SRVR:VI1PR05MB4191; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB4191; X-Forefront-PRVS: 0655F9F006 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(39860400002)(39380400002)(396003)(346002)(366004)(189003)(199004)(476003)(2616005)(5660300001)(6486002)(53936002)(66066001)(486006)(86362001)(97736004)(6916009)(305945005)(26005)(48376002)(105586002)(107886003)(6666003)(50466002)(106356001)(956004)(11346002)(6496006)(446003)(16586007)(2351001)(478600001)(2906002)(4326008)(6116002)(25786009)(51416003)(8936002)(81156014)(36756003)(68736007)(8676002)(118296001)(58126008)(81166006)(59450400001)(386003)(316002)(52116002)(47776003)(7736002)(76176011)(3846002)(16526019); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB4191; H:t540p; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR05MB4191; 23:4oVYSMfW+781/nNkcl18ltEir+YxRNchoMb8YEHwd?= =?us-ascii?Q?LJ9IBEhTQZnJcLTi1NCjxNRKclRg41PM/i4RB5SY2N0tOhdqDNL/XK4lT9dA?= =?us-ascii?Q?x9L/kftS4CiI0S8oi/wdE6DW5SBXbekJqYoC49/WQ1dyGQHEfPRik2XhlYqP?= =?us-ascii?Q?6JtVbl+Yad7TDQipNGghk8YABa/t4gMixqEluKZUP5NVImg/NrYJDHMlWipz?= =?us-ascii?Q?cpCO5ngcWvB6HEkYfESIE4emfqq2as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K2wJOkoxo8k3CBah8iV8T2HnfVwRB93HOwB8b+IFoilBPwTPebvFY18ti8YXZkWBmxPNnX3J5hdpBSw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4191; 7:D27RRThSTCrP7bqBREybXxUD86nKKcE9m/9Q/xnfO6kzM3AC+o2ef+bkExvn7/MpdTG+gh7uQbfHbl6CYBLsxDUl9y7x3UQf6h1U8CrFwHUllIyjqfhUCHo8XEnUgHOuEyLARmTYXVTLZ7t4baPA6t7pTRAssRcGC7W3HC7cyDPiJj6s7m99C+57K414pu/Eb0b+8YXK2NnbMCY7EvBmWXK8qA48THyEsaL1RxXUQ2Zo8ROC+QD6qyBeuUDjC/i4 X-MS-Office365-Filtering-Correlation-Id: 781590e3-3576-4fdb-957c-08d5ac92b182 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Apr 2018 23:00:38.0496 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 781590e3-3576-4fdb-957c-08d5ac92b182 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB4191 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);