From patchwork Tue Mar 30 14:54:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 412274 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=-14.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, 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 D8E77C433F1 for ; Tue, 30 Mar 2021 14:55:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CAE1561921 for ; Tue, 30 Mar 2021 14:55:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232285AbhC3OzK (ORCPT ); Tue, 30 Mar 2021 10:55:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231719AbhC3Oyc (ORCPT ); Tue, 30 Mar 2021 10:54:32 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 820D3C061762 for ; Tue, 30 Mar 2021 07:54:31 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id x21so18553016eds.4 for ; Tue, 30 Mar 2021 07:54:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=c0e5bfMQeB45LqDwZPaeES/kzrcpabV+H5DsnQ+4B4I=; b=lVzAB7QEl1lzeZR2HUOq4erJHQMMZLQDMnOzSCE5xauWCVfB/efbBfSjOeenMGfiEB ra51iXvWh2UEaiYQrgPmES8Wszrg9qedHHxSPuPZRtas59N2ahlq1m4fQAzvirzedv9e 3GV8V8vrbgyr3zjIMRiaox26q9Zt5nmp74cmrW9NmPKhbECDCsGQlkojFlawrhVEWS25 RTRbnR6AhiEWzsD0r4pm2m38jBA9H9BOOKD0vnevn2vQg0NwgUw/2V7jqRgSDUUNTNaM pSMGIZV27skJjzLDy4UtbyFqlwwEEBQXHvbtgIZMg4Rr+qgFZK93BGY+fvnBx7MKWvRA arKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=c0e5bfMQeB45LqDwZPaeES/kzrcpabV+H5DsnQ+4B4I=; b=qxE10grNWVd3ozotrnv0lIVgFV/d9Df/3T5dh0TYI+Dib4S6hslzHaMO1iRUVVu+vJ ouH+s1t5zAttnv1ovCIb/jLLuyWrLLiBaLh73Gi7mry33Enqfs6MbdaqNrgQWek2K834 YxH8m1J8ggffn62CRhjE8gb8cLUb5B3w06Sfbiu+aRhswK2LSGg/Ty5eyO0wm590ArZW w/nYpIyPxX0s/2FDT6BuBtToKd+p8FWpaimKpWTK7RfmsX9Mjr+u18Gqxbw4Pi3leWUc 11MXQsF9Do8jSaAxRgzNKeC+KSL6MfTZKmYuqNY74D3Vhm3qcc8sIRaGDKIsGUXuaIaa poJQ== X-Gm-Message-State: AOAM530oqQdXwQmw4OkrZKoNPL4dmXfF9yBSjMRZJCPlYFmUPW42hQ/e AwYgTasyNzLjyMY/0YuLzLs= X-Google-Smtp-Source: ABdhPJxFCbItpX3c95XtOP1pJlo1gwGAylBbRZJkwbJEff35I/NkGyLVYulpd/xlV10e4FwZZowr8A== X-Received: by 2002:a05:6402:1517:: with SMTP id f23mr35003364edw.272.1617116070195; Tue, 30 Mar 2021 07:54:30 -0700 (PDT) Received: from yoga-910.localhost (5-12-16-165.residential.rdsnet.ro. [5.12.16.165]) by smtp.gmail.com with ESMTPSA id la15sm10284625ejb.46.2021.03.30.07.54.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 07:54:29 -0700 (PDT) From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Cc: olteanv@gmail.com, andrew@lunn.ch, f.fainelli@gmail.com, Ioana Ciornei Subject: [PATCH net-next 1/5] dpaa2-switch: fix the translation between the bridge and dpsw STP states Date: Tue, 30 Mar 2021 17:54:15 +0300 Message-Id: <20210330145419.381355-2-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210330145419.381355-1-ciorneiioana@gmail.com> References: <20210330145419.381355-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Ioana Ciornei The numerical values used for STP states are different between the bridge and the MC ABI therefore, the direct usage of the BR_STATE_* macros directly in the structures passed to the firmware is incorrect. Create a separate function that translates between the bridge STP states and the enum that holds the STP state as seen by the Management Complex. Signed-off-by: Ioana Ciornei --- .../ethernet/freescale/dpaa2/dpaa2-switch.c | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c index a9b30a72ddad..073316d0a77c 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c @@ -318,17 +318,34 @@ static int dpaa2_switch_port_add_vlan(struct ethsw_port_priv *port_priv, return 0; } +static enum dpsw_stp_state br_stp_state_to_dpsw(u8 state) +{ + switch (state) { + case BR_STATE_DISABLED: + return DPSW_STP_STATE_DISABLED; + case BR_STATE_LISTENING: + return DPSW_STP_STATE_LISTENING; + case BR_STATE_LEARNING: + return DPSW_STP_STATE_LEARNING; + case BR_STATE_FORWARDING: + return DPSW_STP_STATE_FORWARDING; + case BR_STATE_BLOCKING: + return DPSW_STP_STATE_BLOCKING; + default: + return DPSW_STP_STATE_DISABLED; + } +} + static int dpaa2_switch_port_set_stp_state(struct ethsw_port_priv *port_priv, u8 state) { - struct dpsw_stp_cfg stp_cfg = { - .state = state, - }; + struct dpsw_stp_cfg stp_cfg = {0}; int err; u16 vid; if (!netif_running(port_priv->netdev) || state == port_priv->stp_state) return 0; /* Nothing to do */ + stp_cfg.state = br_stp_state_to_dpsw(state); for (vid = 0; vid <= VLAN_VID_MASK; vid++) { if (port_priv->vlans[vid] & ETHSW_VLAN_MEMBER) { stp_cfg.vlan_id = vid; From patchwork Tue Mar 30 14:54:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 412275 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=-14.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, 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 11A2DC433E1 for ; Tue, 30 Mar 2021 14:55:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BD454619E9 for ; Tue, 30 Mar 2021 14:55:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232088AbhC3OzA (ORCPT ); Tue, 30 Mar 2021 10:55:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231794AbhC3Oyf (ORCPT ); Tue, 30 Mar 2021 10:54:35 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DCD8C061764 for ; Tue, 30 Mar 2021 07:54:35 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id dm8so18570206edb.2 for ; Tue, 30 Mar 2021 07:54:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BdsP1ZW4mSaGfjx1+f6l0OI23FJr15hztFckhKv01eA=; b=W4dBDgWTdB1HIMPVlao1P6yedSJ3NMZ/CI4THsemLchAoPa3OYI0+988OBooId5/ik bHadgHPvFB7jS60ItaEMRLQht+nlTFER6HewLApGf8I+OCK/svcD71VI58BzUNABsfc8 a8kpzL7oST00EjyI8iPM07ezAzOAXQXjApVZdyT4YDYcn/K4h0A8shl9pkkOeWoyAb5K kE2/NaeDDkvSrPIowWWNeII2XKbg9keuPAKTzs3MdcpHrE/uCtKWqI+PWXD2vtWXdJgn bM2pNLmlY06x8X8lRLhsAgRFHLPr97t1Rg2gyf6VxERBOJoOH0kP92KAwoQCI2EQzOPf 4m4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BdsP1ZW4mSaGfjx1+f6l0OI23FJr15hztFckhKv01eA=; b=rJLsf7p4SzJYJckaVtagX12050gGDa7O2RulbhGCZN8aY7c8ok/KT+AZtEd7g56Nen cM31g6xXNFlGwJG/rWCdD/MeWFIT79/KmUGVMLUXdR+n6c0pgn5+5eLtRdAjisCFrAyi uyPBJmmVMi8jv6Y2y8SeDm9JZwqSPbtbYn4/z5vnS6CtM4cz9W5inVlkC6AJ5aWgDLzy JWSYBqII6j9X5F1PT+6MVMhy6X4g84xicjdBPeR2jW+OVKoYgSdt39eMoNh93yYWtSLY ile44osT7b1FGaSUDirm0k0Z8tyCazSqaY/WpnncAiak2UN1N80agqqzzCLPBQxgz6rU H67A== X-Gm-Message-State: AOAM532e4jqa7VKy/cnQmLrgclhbRDdc0/mlB7M4V/SLssYyjgtsY4rG EYCo/MnrE1OSh1QCVBovBFQ= X-Google-Smtp-Source: ABdhPJwr1x/m/fBqAWZ303OKAHU+AVichc7x2dacdsx3sm56hqqBt1q78yplvD73k0IERHV6h2BJVg== X-Received: by 2002:a05:6402:3592:: with SMTP id y18mr28745064edc.360.1617116073813; Tue, 30 Mar 2021 07:54:33 -0700 (PDT) Received: from yoga-910.localhost (5-12-16-165.residential.rdsnet.ro. [5.12.16.165]) by smtp.gmail.com with ESMTPSA id la15sm10284625ejb.46.2021.03.30.07.54.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 07:54:33 -0700 (PDT) From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Cc: olteanv@gmail.com, andrew@lunn.ch, f.fainelli@gmail.com, Ioana Ciornei Subject: [PATCH net-next 5/5] dpaa2-switch: setup learning state on STP state change Date: Tue, 30 Mar 2021 17:54:19 +0300 Message-Id: <20210330145419.381355-6-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210330145419.381355-1-ciorneiioana@gmail.com> References: <20210330145419.381355-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Ioana Ciornei Depending on what STP state a port is in, the learning on that port should be enabled or disabled. When the STP state is DISABLED, BLOCKING or LISTENING no learning should be happening irrespective of what the bridge previously requested. The learning state is changed to be the one setup by the bridge when the STP state is LEARNING or FORWARDING. Signed-off-by: Ioana Ciornei --- .../ethernet/freescale/dpaa2/dpaa2-switch.c | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c index 72b7ba003538..80efc8116963 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c @@ -1250,14 +1250,6 @@ static void dpaa2_switch_teardown_irqs(struct fsl_mc_device *sw_dev) fsl_mc_free_irqs(sw_dev); } -static int dpaa2_switch_port_attr_stp_state_set(struct net_device *netdev, - u8 state) -{ - struct ethsw_port_priv *port_priv = netdev_priv(netdev); - - return dpaa2_switch_port_set_stp_state(port_priv, state); -} - static int dpaa2_switch_port_set_learning(struct ethsw_port_priv *port_priv, bool enable) { struct ethsw_core *ethsw = port_priv->ethsw_data; @@ -1280,6 +1272,32 @@ static int dpaa2_switch_port_set_learning(struct ethsw_port_priv *port_priv, boo return err; } +static int dpaa2_switch_port_attr_stp_state_set(struct net_device *netdev, + u8 state) +{ + struct ethsw_port_priv *port_priv = netdev_priv(netdev); + int err; + + err = dpaa2_switch_port_set_stp_state(port_priv, state); + if (err) + return err; + + switch (state) { + case BR_STATE_DISABLED: + case BR_STATE_BLOCKING: + case BR_STATE_LISTENING: + err = dpaa2_switch_port_set_learning(port_priv, false); + break; + case BR_STATE_LEARNING: + case BR_STATE_FORWARDING: + err = dpaa2_switch_port_set_learning(port_priv, + port_priv->learn_ena); + break; + } + + return err; +} + static int dpaa2_switch_port_flood(struct ethsw_port_priv *port_priv, struct switchdev_brport_flags flags) {