From patchwork Wed Apr 25 14:06:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10363279 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 85F38601D3 for ; Wed, 25 Apr 2018 14:08:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7648120182 for ; Wed, 25 Apr 2018 14:08:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6AE84289E3; Wed, 25 Apr 2018 14:08:05 +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 8B2D320182 for ; Wed, 25 Apr 2018 14:08:04 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40WMVB6WkvzF24L for ; Thu, 26 Apr 2018 00:08:02 +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="Knq+Fzgl"; 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:fe08::611; helo=eur03-am5-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="Knq+Fzgl"; dkim-atps=neutral Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-am5eur03on0611.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe08::611]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40WMV46YcwzDrDT for ; Thu, 26 Apr 2018 00:07:56 +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=Knq+Fzgl25QsQdZchsCmiC5qFW1+mA1M3A47+adbADoG2D/JiYVpMiatqrLA1qol20ccjq/6hzrEjCINhQtqWcVvZy8GkRb2l5TVBO+l2wY2rhwd6+Kkc0vpsZNbV3Twdmqs5lEKE+v+K86FltqvB9pCIsYpjMUXdpd/1ZKdXLw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (89.177.127.115) by VI1PR05MB4189.eurprd05.prod.outlook.com (2603:10a6:803:4e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.696.13; Wed, 25 Apr 2018 14:07:49 +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: <990dc242e1814bb6a9aa995d1bc642b9a70a6135.1524654206.git.petrm@mellanox.com> Date: Wed, 25 Apr 2018 16:06:53 +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: VI1P189CA0028.EURP189.PROD.OUTLOOK.COM (2603:10a6:802:2a::41) To VI1PR05MB4189.eurprd05.prod.outlook.com (2603:10a6:803:4e::15) 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:VI1PR05MB4189; X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4189; 3:YW61IPpYyOhxm5F++8S49mcC+tT6bh3Alsjd183n40tQNAe+UBU0jj8bc4dWyrlbUTDzPGjA2tg7VOWamR2LemfC6fWKLb0hlQKMrnpr/1rl4RqiILAb1NlWunMCgbhdViIs5GqR2uztbT0RutQqSDgOQsBVQnill6QDeqr5mT/ZnnkZvLs96T4ZrrmAw7eCzXdWarrOZqkw+IPNak9/PeknqQ3jD0GKIuLRMqhmgm0FJKbFc1XqaFpb8DDdMni6; 25:/bk5cR3fBp1X7pF3NASA1IrjYtY67v61dGlAX0XPS7hCTW917rAJs0Y7Tpd7feUwE5/Rx6ZPCw+pk9KEXQ5TmJajaq3AvRkdn3mQ6F471kG/D/dOE9T8tefhmB6Y+P1XdyDhXub9Z7aTP6kb4VywQZ5dRTIMzgNV39+ysvhEsPrbG8n4yNjgK9mKR/Crhcr8xSRyr4Hu9TXEA9KMC4UdDzdM9CWMXv+CEQ8k02Z0PpdKYbDjYBjtd6KBLy3usoVsqDVmj0GCJYdioJENDWQ5rP/9QSFPY044nP8QaHfrsQSTeytzoWKcRoHij7IWMkpIEzRUsmRlXwQyx91eTlIqzQ==; 31:1fwuJu0YcNi8wW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lg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231232)(944501410)(52105095)(93006095)(93001095)(3002001)(10201501046)(6055026)(6041310)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(6072148)(201708071742011); SRVR:VI1PR05MB4189; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB4189; X-Forefront-PRVS: 06530126A4 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(39860400002)(346002)(396003)(366004)(39380400002)(189003)(199004)(68736007)(5660300001)(86362001)(2906002)(48376002)(118296001)(305945005)(6496006)(47776003)(8676002)(107886003)(51416003)(52116002)(6116002)(6486002)(50466002)(59450400001)(16526019)(386003)(446003)(76176011)(66066001)(3846002)(316002)(16586007)(11346002)(36756003)(26005)(105586002)(25786009)(7736002)(2351001)(8936002)(81156014)(81166006)(476003)(97736004)(956004)(53936002)(2616005)(478600001)(6916009)(486006)(6666003)(58126008)(4326008)(106356001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB4189; 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; VI1PR05MB4189; 23:jX0m3ELENNap9wityPyz8Dmf/nmdgbsZdeQBCU/Cm?= =?us-ascii?Q?KcRQmNmxGtOGwigk8GOnP++BAANkMRYbRXExTu6sgKt4aa1uoWscmzNp2FC7?= =?us-ascii?Q?VWdwf0ukBCgMqrit1tNRfMaKNj6IQ0Au9oc0KNapHFCGAdQ0mF9hGedMKSYG?= =?us-ascii?Q?zO95DLFdcD14EXw4WZzd3TrNlQ2gEM3iz/QEz7Yo7ILse3GDQD7xAUtYCOZc?= =?us-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fw=; 24:to0zqHznBa2qX5CkRhLMT4VfoZN8Dc8DKfmnWfSOAUjBRIF3YwBTtFsEGI0z8M8e4G8wxEFF7iP6fr6EEJ24eD5IYXk5rCr7WW3WC0p21NQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4189; 7:89Ke5HVfZfQJuU8323XTdEdXbYuF6p8A/VPaTt9TvTBVIDefeqcW3WoNGvCkf1BzNT2VbYwEfLHH/kfxQ1itOMQH7d1lB/aeNeTqClrMrjDykZq2JbcMTW3cuX/ukVggH96sP680AouRck9QRPQTM2DwM+0MXTYfVaNfyExDONXKa96+IKXq7gdlthLoENQQD3OYIzBsFeCkX+W+hAlMJrh1J/FW11qw6/oqJHbIYzFLJtXZZAF6r5TosVpV1K1n X-MS-Office365-Filtering-Correlation-Id: 201ddff4-ffb2-42ca-8956-08d5aab5ed75 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2018 14:07:49.1561 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 201ddff4-ffb2-42ca-8956-08d5aab5ed75 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB4189 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);