From patchwork Mon Mar 22 20:58:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 406484 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 3A6E5C433C1 for ; Mon, 22 Mar 2021 21:00:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 08140619A6 for ; Mon, 22 Mar 2021 21:00:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230350AbhCVVAC (ORCPT ); Mon, 22 Mar 2021 17:00:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230305AbhCVU7Z (ORCPT ); Mon, 22 Mar 2021 16:59:25 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B0DDC061574 for ; Mon, 22 Mar 2021 13:59:24 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id ce10so23555741ejb.6 for ; Mon, 22 Mar 2021 13:59:24 -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=BuU1u1y3b2PNxqXWD3n5YK1eZY5chlYDecQQtC6r1xU=; b=Qm+T3TKBxFMJEoEYxTX3tNC4aGtw2qD/U0d4kT0I/CLQpM9cUmxjaL7VD86Xos4FMu t7pfTPb4f+ueBV0DXDmHkUZ3rbNsmX5cnbetX+l+zkTU/KVGuupatyQkFrWUAlQmUoV5 tRwjvwgY1xmF/RWSSXUtMbhnMU03tfOyc3YREOR9quTnfn6uhUeUSz5KPwTLMdyyefBg oFKVc6KZ5albk7ay6+qko40WF7rMM4fiOX8FJ7W1YZMoPN7VgurNZKhH62IN4KxWfmu/ cGTNiJqKsgqlgwdfViHMQPmM9dngm5mtzTS7rTx4a9Mj9oW1vxbfexjY6WapXt1/xw8g jOXA== 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=BuU1u1y3b2PNxqXWD3n5YK1eZY5chlYDecQQtC6r1xU=; b=Sat9eXQeU3MYKrBMoiR+OudBan3kq8GVU4KaLegwGUkkb7lM7567bgHIdvYhEhINFC yTFSSVEvDw0gS7yzg0sPvW4d/j1dm9GmKN6dipPItqhT3fsxyFAlka7C5+ZZpuih86KK sIWYH0wIGnsKK1JL7+UHY/IcKBKPXhdZ36QwNkMup5wR/NO2Utcr3R7l+dRsxWSTQVCZ uW83PE21vJ6mzSBwPwfkIBL8maLOCbr00MTkfcQ6TyTk1sZVp9qdb5W/TdyGcmYhVS6x xzpgjLCRSjHNUwyATq6G731cM+yH8cp3ChUx/N/NEXDBGvzThEOxr/JhsQb0YYZGGw8e xetg== X-Gm-Message-State: AOAM531vIwlHndVupwbvtnL/OQEE6QnDew7YevuK9lARMTv1vCxliGZz eWuuJDO+15V4/8TeTvBWlS4= X-Google-Smtp-Source: ABdhPJy5uY1DQMw1naHTSzST1btHIrPb5Lrg9RlWpGCaJQwI+PYRQM6NwVGu7lJv3w7xIJz+N1xf2w== X-Received: by 2002:a17:906:2e45:: with SMTP id r5mr1589482eji.380.1616446763336; Mon, 22 Mar 2021 13:59:23 -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 v25sm11621074edr.18.2021.03.22.13.59.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 13:59:22 -0700 (PDT) From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Cc: andrew@lunn.ch, f.fainelli@gmail.com, olteanv@gmail.com, Ioana Ciornei Subject: [PATCH net-next 1/6] dpaa2-switch: move the dpaa2_switch_fdb_set_egress_flood function Date: Mon, 22 Mar 2021 22:58:54 +0200 Message-Id: <20210322205859.606704-2-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210322205859.606704-1-ciorneiioana@gmail.com> References: <20210322205859.606704-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Ioana Ciornei In order to avoid a forward declaration in the next patches, move the dpaa2_switch_fdb_set_egress_flood() function to the top of the file. Signed-off-by: Ioana Ciornei --- .../ethernet/freescale/dpaa2/dpaa2-switch.c | 84 +++++++++---------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c index 2fd05dd18d46..5254eae5c86a 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c @@ -110,6 +110,48 @@ static u16 dpaa2_switch_port_set_fdb(struct ethsw_port_priv *port_priv, return 0; } +static int dpaa2_switch_fdb_set_egress_flood(struct ethsw_core *ethsw, u16 fdb_id) +{ + struct dpsw_egress_flood_cfg flood_cfg; + int i = 0, j; + int err; + + /* Add all the DPAA2 switch ports found in the same bridging domain to + * the egress flooding domain + */ + for (j = 0; j < ethsw->sw_attr.num_ifs; j++) + if (ethsw->ports[j] && ethsw->ports[j]->fdb->fdb_id == fdb_id) + flood_cfg.if_id[i++] = ethsw->ports[j]->idx; + + /* Add the CTRL interface to the egress flooding domain */ + flood_cfg.if_id[i++] = ethsw->sw_attr.num_ifs; + + /* Use the FDB of the first dpaa2 switch port added to the bridge */ + flood_cfg.fdb_id = fdb_id; + + /* Setup broadcast flooding domain */ + flood_cfg.flood_type = DPSW_BROADCAST; + flood_cfg.num_ifs = i; + err = dpsw_set_egress_flood(ethsw->mc_io, 0, ethsw->dpsw_handle, + &flood_cfg); + if (err) { + dev_err(ethsw->dev, "dpsw_set_egress_flood() = %d\n", err); + return err; + } + + /* Setup unknown flooding domain */ + flood_cfg.flood_type = DPSW_FLOODING; + flood_cfg.num_ifs = i; + err = dpsw_set_egress_flood(ethsw->mc_io, 0, ethsw->dpsw_handle, + &flood_cfg); + if (err) { + dev_err(ethsw->dev, "dpsw_set_egress_flood() = %d\n", err); + return err; + } + + return 0; +} + static void *dpaa2_iova_to_virt(struct iommu_domain *domain, dma_addr_t iova_addr) { @@ -1442,48 +1484,6 @@ static int dpaa2_switch_port_attr_set_event(struct net_device *netdev, return notifier_from_errno(err); } -static int dpaa2_switch_fdb_set_egress_flood(struct ethsw_core *ethsw, u16 fdb_id) -{ - struct dpsw_egress_flood_cfg flood_cfg; - int i = 0, j; - int err; - - /* Add all the DPAA2 switch ports found in the same bridging domain to - * the egress flooding domain - */ - for (j = 0; j < ethsw->sw_attr.num_ifs; j++) - if (ethsw->ports[j] && ethsw->ports[j]->fdb->fdb_id == fdb_id) - flood_cfg.if_id[i++] = ethsw->ports[j]->idx; - - /* Add the CTRL interface to the egress flooding domain */ - flood_cfg.if_id[i++] = ethsw->sw_attr.num_ifs; - - /* Use the FDB of the first dpaa2 switch port added to the bridge */ - flood_cfg.fdb_id = fdb_id; - - /* Setup broadcast flooding domain */ - flood_cfg.flood_type = DPSW_BROADCAST; - flood_cfg.num_ifs = i; - err = dpsw_set_egress_flood(ethsw->mc_io, 0, ethsw->dpsw_handle, - &flood_cfg); - if (err) { - dev_err(ethsw->dev, "dpsw_set_egress_flood() = %d\n", err); - return err; - } - - /* Setup unknown flooding domain */ - flood_cfg.flood_type = DPSW_FLOODING; - flood_cfg.num_ifs = i; - err = dpsw_set_egress_flood(ethsw->mc_io, 0, ethsw->dpsw_handle, - &flood_cfg); - if (err) { - dev_err(ethsw->dev, "dpsw_set_egress_flood() = %d\n", err); - return err; - } - - return 0; -} - static int dpaa2_switch_port_bridge_join(struct net_device *netdev, struct net_device *upper_dev) { From patchwork Mon Mar 22 20:58:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 407461 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 50676C433E0 for ; Mon, 22 Mar 2021 21:00:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1AACD619A7 for ; Mon, 22 Mar 2021 21:00:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230377AbhCVVAF (ORCPT ); Mon, 22 Mar 2021 17:00:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230195AbhCVU71 (ORCPT ); Mon, 22 Mar 2021 16:59:27 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF569C061756 for ; Mon, 22 Mar 2021 13:59:25 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id w3so23566268ejc.4 for ; Mon, 22 Mar 2021 13:59:25 -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=ZmzXoJ97o1M9rWc1MhfEHbfmJ0FXS8JjeCxK5uigeS4=; b=JFCqzcWc+m20O7pMwh4on0oejbHm5LGIVyI0lFjQDLYRPywD9LZCCW/7fEJ7pLUIWF pTPz8nGpMfRtCy5ie4Jz0YFtj/lWqj0sHLTzcTOTv8yz1H0pC2pcFEndXUvpGc520RPL 2FirJm61Ti/vLNrsnbtyolH/8x25hfCaLrc2aykN2N7Ph5RTnbqG5hoqIqqRDlqlWCSA gUsQFFAWPGWhsYPUZwo1Uh5pvpDdKCFWV7dLytby3b2GKDEs5LJ5Uy0knpQYaEgWJDVd UmRBoSv7sIgmRL6HT0hmY/DXaWTd/mUGVv/suTGhTM3FHRMHnca6NTJv2fwZN1PwDWAj xajQ== 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=ZmzXoJ97o1M9rWc1MhfEHbfmJ0FXS8JjeCxK5uigeS4=; b=k5HjfDzXljUxEnyks+bOiU0+9ASTppmYGWd7mhw7V5COQ5H9EoUl7PU6SMUVaMS738 cikeQOL7kDtgBpOHx+Tgz+6RVGSwTN3cbTLDf5o00yhXZuDgSZ2jGNzwHVmvaeb70lDn RnmO6yCSrcV4Cz6YHvd4D7asv1AdGer5t5rPYT922f+u6wZpagzs5sd9o+5dCBJuV2ea Mdv/wGzZUnfT2dhovM5/vfgcbFnHWzcXHk/OevH/m3FHvrle+aS383n0KmKrAzU8EzoB U/qSRFrQF6p/C7y3ezNJ8ew61akKlYkQWBeumL/AB/Nn5BBX/U/BqG4N4GABoRLbRIi8 JQ7w== X-Gm-Message-State: AOAM532k2Fo92aFMnSaZShEpFMu0erq5tUZ+frb40xNsOda2MGGVBYcg 3Al4/JSQgIj221I0cZbnZco= X-Google-Smtp-Source: ABdhPJy7jbW/NxPHx5fT/SbXbhBNqrb22BvsJQMu3wwijzwloDnQXpzb9F6Mso6dC/16+NOPbyPMpw== X-Received: by 2002:a17:906:f283:: with SMTP id gu3mr1600603ejb.91.1616446764596; Mon, 22 Mar 2021 13:59:24 -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 v25sm11621074edr.18.2021.03.22.13.59.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 13:59:24 -0700 (PDT) From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Cc: andrew@lunn.ch, f.fainelli@gmail.com, olteanv@gmail.com, Ioana Ciornei Subject: [PATCH net-next 2/6] dpaa2-switch: refactor the egress flooding domain setup Date: Mon, 22 Mar 2021 22:58:55 +0200 Message-Id: <20210322205859.606704-3-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210322205859.606704-1-ciorneiioana@gmail.com> References: <20210322205859.606704-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Ioana Ciornei Extract the code that determines the list of egress flood interfaces for a specific flood type into a new function - dpaa2_switch_fdb_get_flood_cfg(). This will help us to not duplicate code when the broadcast and unknown ucast/mcast flooding domains will be individually configurable. Signed-off-by: Ioana Ciornei --- .../ethernet/freescale/dpaa2/dpaa2-switch.c | 38 ++++++++++++------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c index 5254eae5c86a..2db9cd78201d 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c @@ -110,28 +110,41 @@ static u16 dpaa2_switch_port_set_fdb(struct ethsw_port_priv *port_priv, return 0; } -static int dpaa2_switch_fdb_set_egress_flood(struct ethsw_core *ethsw, u16 fdb_id) +static void dpaa2_switch_fdb_get_flood_cfg(struct ethsw_core *ethsw, u16 fdb_id, + enum dpsw_flood_type type, + struct dpsw_egress_flood_cfg *cfg) { - struct dpsw_egress_flood_cfg flood_cfg; int i = 0, j; - int err; + + memset(cfg, 0, sizeof(*cfg)); /* Add all the DPAA2 switch ports found in the same bridging domain to * the egress flooding domain */ - for (j = 0; j < ethsw->sw_attr.num_ifs; j++) - if (ethsw->ports[j] && ethsw->ports[j]->fdb->fdb_id == fdb_id) - flood_cfg.if_id[i++] = ethsw->ports[j]->idx; + for (j = 0; j < ethsw->sw_attr.num_ifs; j++) { + if (!ethsw->ports[j]) + continue; + if (ethsw->ports[j]->fdb->fdb_id != fdb_id) + continue; + + cfg->if_id[i++] = ethsw->ports[j]->idx; + } /* Add the CTRL interface to the egress flooding domain */ - flood_cfg.if_id[i++] = ethsw->sw_attr.num_ifs; + cfg->if_id[i++] = ethsw->sw_attr.num_ifs; + + cfg->fdb_id = fdb_id; + cfg->flood_type = type; + cfg->num_ifs = i; +} - /* Use the FDB of the first dpaa2 switch port added to the bridge */ - flood_cfg.fdb_id = fdb_id; +static int dpaa2_switch_fdb_set_egress_flood(struct ethsw_core *ethsw, u16 fdb_id) +{ + struct dpsw_egress_flood_cfg flood_cfg; + int err; /* Setup broadcast flooding domain */ - flood_cfg.flood_type = DPSW_BROADCAST; - flood_cfg.num_ifs = i; + dpaa2_switch_fdb_get_flood_cfg(ethsw, fdb_id, DPSW_BROADCAST, &flood_cfg); err = dpsw_set_egress_flood(ethsw->mc_io, 0, ethsw->dpsw_handle, &flood_cfg); if (err) { @@ -140,8 +153,7 @@ static int dpaa2_switch_fdb_set_egress_flood(struct ethsw_core *ethsw, u16 fdb_i } /* Setup unknown flooding domain */ - flood_cfg.flood_type = DPSW_FLOODING; - flood_cfg.num_ifs = i; + dpaa2_switch_fdb_get_flood_cfg(ethsw, fdb_id, DPSW_FLOODING, &flood_cfg); err = dpsw_set_egress_flood(ethsw->mc_io, 0, ethsw->dpsw_handle, &flood_cfg); if (err) { From patchwork Mon Mar 22 20:58:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 406483 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, 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 69EA1C433E2 for ; Mon, 22 Mar 2021 21:00:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2F844619A5 for ; Mon, 22 Mar 2021 21:00:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230459AbhCVVAI (ORCPT ); Mon, 22 Mar 2021 17:00:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230196AbhCVU71 (ORCPT ); Mon, 22 Mar 2021 16:59:27 -0400 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14504C061574 for ; Mon, 22 Mar 2021 13:59:27 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id kt15so14073794ejb.12 for ; Mon, 22 Mar 2021 13:59:27 -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=545Q87iQ2gBZTtR8ldP7hxSlGyj5mrVoEHjdmE0uY+I=; b=Fk6eqeVmOU6j5dWyOFc5N83z3Q0rYPre/6BL1M6HbNHNLmCo4a3arTsB9ySRiRZHaO YDPU2gZkuSUJieJYdZRO46Z01w0iB44xV2CFXHOoWzSm528kp4tsaFHbSl5UDa3FlhcF CPoDH30+H2GgKZ2hhlpSLXn0+beVuKywQCAWnolA5V2fTzv53w6D59hUKF5kC6Xs4lAZ sEJs/hVMYgHKoCBKZkjsAAjDqGwM2pf0aIrW5aTG5AycwYRkEeL+NwX6hxPXRc4aKGCv vKKdv26qx3qkBX2dM6gtOW6NJf7Uv4dYJcOgLylnkddwz7yMgp1U1QXAy3nxLnLNBKpy BBqQ== 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=545Q87iQ2gBZTtR8ldP7hxSlGyj5mrVoEHjdmE0uY+I=; b=bNtKWxq64x8s/1noUjLoLCvZysyT1A13z9erUFGHp7bONjoY+12Z60YGF23ZT/Rvwy CYMK18nzE7tfpLhUkOla3wAs30VUXZJMN8/onb/3tOw/vgqdkMYeXn8VqVxg4ng6CyM1 LHkutOz4TMXfnUzGyRFJqYsEUBJ64muEqOxT+5oiAEhL/gl/hLTJyDNQcSIXcU3enU9r 7m4gRw/Th3CFnV51XTspGMxYgAPG9aEiyQFwG5qGQVq5EZ8ZRqbVRlAY4rzR+S5pQfsx MXYUnsSNIs4ypX6wO3QtGX3/ks5xfQSooiaGyCztrG9/wuqDjy+wTniM+0yJZkwq6CX/ UXEQ== X-Gm-Message-State: AOAM532jIGWclCDuhgmks05jn3KrARjUw1XHoAyw4kEHOIN0cCpNFA2y 9sFlBmuA56XcE273C0pNsxY= X-Google-Smtp-Source: ABdhPJyubgwyN1qDgODHrL0MzLGy4pOnoE8L8q+6mIsiK91rTsg99Muzpd2Qql4hcjkeETMNmqLs7g== X-Received: by 2002:a17:907:ea3:: with SMTP id ho35mr1605399ejc.219.1616446765761; Mon, 22 Mar 2021 13:59:25 -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 v25sm11621074edr.18.2021.03.22.13.59.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 13:59:25 -0700 (PDT) From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Cc: andrew@lunn.ch, f.fainelli@gmail.com, olteanv@gmail.com, Ioana Ciornei Subject: [PATCH net-next 3/6] dpaa2-switch: add support for configuring learning state per port Date: Mon, 22 Mar 2021 22:58:56 +0200 Message-Id: <20210322205859.606704-4-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210322205859.606704-1-ciorneiioana@gmail.com> References: <20210322205859.606704-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Ioana Ciornei Add support for configuring the learning state of a switch port. When the user requests the HW learning to be disabled, a fast-age procedure on that specific port is run so that previously learnt addresses do not linger. At device probe as well as on a bridge leave action, the ports are configured with HW learning disabled since they are basically a standalone port. At the same time, at bridge join we inherit the bridge port BR_LEARNING flag state and configure it on the switch port. There were already some MC firmware ABI functions for changing the learning state, but those were per FDB (bridging domain) and not per port so we need to adjust those to use the new MC fw command which is per port. Signed-off-by: Ioana Ciornei --- .../ethernet/freescale/dpaa2/dpaa2-switch.c | 70 +++++++++++++++++++ .../net/ethernet/freescale/dpaa2/dpsw-cmd.h | 10 +++ drivers/net/ethernet/freescale/dpaa2/dpsw.c | 27 +++++++ drivers/net/ethernet/freescale/dpaa2/dpsw.h | 25 ++++--- 4 files changed, 121 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c index 2db9cd78201d..2ea3a4dac49d 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c @@ -1238,6 +1238,56 @@ static int dpaa2_switch_port_attr_stp_state_set(struct net_device *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; + enum dpsw_learning_mode learn_mode; + int err; + + if (enable) + learn_mode = DPSW_LEARNING_MODE_HW; + else + learn_mode = DPSW_LEARNING_MODE_DIS; + + err = dpsw_if_set_learning_mode(ethsw->mc_io, 0, ethsw->dpsw_handle, + port_priv->idx, learn_mode); + if (err) + netdev_err(port_priv->netdev, "dpsw_if_set_learning_mode err %d\n", err); + + if (!enable) + dpaa2_switch_port_fast_age(port_priv); + + return err; +} + +static int dpaa2_switch_port_pre_bridge_flags(struct net_device *netdev, + struct switchdev_brport_flags flags, + struct netlink_ext_ack *extack) +{ + if (flags.mask & ~(BR_LEARNING)) + return -EINVAL; + + return 0; +} + +static int dpaa2_switch_port_bridge_flags(struct net_device *netdev, + struct switchdev_brport_flags flags, + struct netlink_ext_ack *extack) +{ + struct ethsw_port_priv *port_priv = netdev_priv(netdev); + int err; + + if (flags.mask & BR_LEARNING) { + bool learn_ena = !!(flags.val & BR_LEARNING); + + err = dpaa2_switch_port_set_learning(port_priv, learn_ena); + if (err) + return err; + } + + return 0; +} + static int dpaa2_switch_port_attr_set(struct net_device *netdev, const struct switchdev_attr *attr, struct netlink_ext_ack *extack) @@ -1256,6 +1306,12 @@ static int dpaa2_switch_port_attr_set(struct net_device *netdev, return -EOPNOTSUPP; } break; + case SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS: + err = dpaa2_switch_port_pre_bridge_flags(netdev, attr->u.brport_flags, extack); + break; + case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS: + err = dpaa2_switch_port_bridge_flags(netdev, attr->u.brport_flags, extack); + break; default: err = -EOPNOTSUPP; break; @@ -1504,6 +1560,7 @@ static int dpaa2_switch_port_bridge_join(struct net_device *netdev, struct ethsw_port_priv *other_port_priv; struct net_device *other_dev; struct list_head *iter; + bool learn_ena; int err; netdev_for_each_lower_dev(upper_dev, other_dev, iter) { @@ -1525,6 +1582,10 @@ static int dpaa2_switch_port_bridge_join(struct net_device *netdev, dpaa2_switch_port_set_fdb(port_priv, upper_dev); + /* Inherit the initial bridge port learning state */ + learn_ena = br_port_flag_is_set(netdev, BR_LEARNING); + err = dpaa2_switch_port_set_learning(port_priv, learn_ena); + /* Setup the egress flood policy (broadcast, unknown unicast) */ err = dpaa2_switch_fdb_set_egress_flood(ethsw, port_priv->fdb->fdb_id); if (err) @@ -1595,6 +1656,11 @@ static int dpaa2_switch_port_bridge_leave(struct net_device *netdev) if (err) return err; + /* No HW learning when not under a bridge */ + err = dpaa2_switch_port_set_learning(port_priv, false); + if (err) + return err; + /* Add the VLAN 1 as PVID when not under a bridge. We need this since * the dpaa2 switch interfaces are not capable to be VLAN unaware */ @@ -2684,6 +2750,10 @@ static int dpaa2_switch_probe_port(struct ethsw_core *ethsw, if (err) goto err_port_probe; + err = dpaa2_switch_port_set_learning(port_priv, false); + if (err) + goto err_port_probe; + return 0; err_port_probe: diff --git a/drivers/net/ethernet/freescale/dpaa2/dpsw-cmd.h b/drivers/net/ethernet/freescale/dpaa2/dpsw-cmd.h index 996a59dcd01d..24b17d6e09af 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpsw-cmd.h +++ b/drivers/net/ethernet/freescale/dpaa2/dpsw-cmd.h @@ -83,6 +83,7 @@ #define DPSW_CMDID_CTRL_IF_SET_QUEUE DPSW_CMD_ID(0x0A6) #define DPSW_CMDID_SET_EGRESS_FLOOD DPSW_CMD_ID(0x0AC) +#define DPSW_CMDID_IF_SET_LEARNING_MODE DPSW_CMD_ID(0x0AD) /* Macros for accessing command fields smaller than 1byte */ #define DPSW_MASK(field) \ @@ -447,5 +448,14 @@ struct dpsw_cmd_set_egress_flood { u8 pad[5]; __le64 if_id; }; + +#define DPSW_LEARNING_MODE_SHIFT 0 +#define DPSW_LEARNING_MODE_SIZE 4 + +struct dpsw_cmd_if_set_learning_mode { + __le16 if_id; + /* only the first 4 bits from LSB */ + u8 mode; +}; #pragma pack(pop) #endif /* __FSL_DPSW_CMD_H */ diff --git a/drivers/net/ethernet/freescale/dpaa2/dpsw.c b/drivers/net/ethernet/freescale/dpaa2/dpsw.c index 56f3c23fce07..6c787d4b85f9 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpsw.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpsw.c @@ -1327,3 +1327,30 @@ int dpsw_set_egress_flood(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, return mc_send_command(mc_io, &cmd); } + +/** + * dpsw_if_set_learning_mode() - Configure the learning mode on an interface. + * If this API is used, it will take precedence over the FDB configuration. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPSW object + * @if_id: InterfaceID + * @mode: Learning mode + * + * Return: Completion status. '0' on Success; Error code otherwise. + */ +int dpsw_if_set_learning_mode(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + u16 if_id, enum dpsw_learning_mode mode) +{ + struct dpsw_cmd_if_set_learning_mode *cmd_params; + struct fsl_mc_command cmd = { 0 }; + + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_LEARNING_MODE, + cmd_flags, + token); + cmd_params = (struct dpsw_cmd_if_set_learning_mode *)cmd.params; + cmd_params->if_id = cpu_to_le16(if_id); + dpsw_set_field(cmd_params->mode, LEARNING_MODE, mode); + + return mc_send_command(mc_io, &cmd); +} diff --git a/drivers/net/ethernet/freescale/dpaa2/dpsw.h b/drivers/net/ethernet/freescale/dpaa2/dpsw.h index f108cc61bb27..96837b10cc94 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpsw.h +++ b/drivers/net/ethernet/freescale/dpaa2/dpsw.h @@ -532,11 +532,11 @@ int dpsw_fdb_remove_multicast(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 fdb_id, const struct dpsw_fdb_multicast_cfg *cfg); /** - * enum dpsw_fdb_learning_mode - Auto-learning modes - * @DPSW_FDB_LEARNING_MODE_DIS: Disable Auto-learning - * @DPSW_FDB_LEARNING_MODE_HW: Enable HW auto-Learning - * @DPSW_FDB_LEARNING_MODE_NON_SECURE: Enable None secure learning by CPU - * @DPSW_FDB_LEARNING_MODE_SECURE: Enable secure learning by CPU + * enum dpsw_learning_mode - Auto-learning modes + * @DPSW_LEARNING_MODE_DIS: Disable Auto-learning + * @DPSW_LEARNING_MODE_HW: Enable HW auto-Learning + * @DPSW_LEARNING_MODE_NON_SECURE: Enable None secure learning by CPU + * @DPSW_LEARNING_MODE_SECURE: Enable secure learning by CPU * * NONE - SECURE LEARNING * SMAC found DMAC found CTLU Action @@ -561,11 +561,11 @@ int dpsw_fdb_remove_multicast(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, * - - Forward frame to * 1. Control interface */ -enum dpsw_fdb_learning_mode { - DPSW_FDB_LEARNING_MODE_DIS = 0, - DPSW_FDB_LEARNING_MODE_HW = 1, - DPSW_FDB_LEARNING_MODE_NON_SECURE = 2, - DPSW_FDB_LEARNING_MODE_SECURE = 3 +enum dpsw_learning_mode { + DPSW_LEARNING_MODE_DIS = 0, + DPSW_LEARNING_MODE_HW = 1, + DPSW_LEARNING_MODE_NON_SECURE = 2, + DPSW_LEARNING_MODE_SECURE = 3 }; /** @@ -579,7 +579,7 @@ enum dpsw_fdb_learning_mode { struct dpsw_fdb_attr { u16 max_fdb_entries; u16 fdb_ageing_time; - enum dpsw_fdb_learning_mode learning_mode; + enum dpsw_learning_mode learning_mode; u16 num_fdb_mc_groups; u16 max_fdb_mc_groups; }; @@ -625,4 +625,7 @@ struct dpsw_egress_flood_cfg { int dpsw_set_egress_flood(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, const struct dpsw_egress_flood_cfg *cfg); +int dpsw_if_set_learning_mode(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + u16 if_id, enum dpsw_learning_mode mode); + #endif /* __FSL_DPSW_H */ From patchwork Mon Mar 22 20:58:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 407462 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, 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 9A6AFC433E3 for ; Mon, 22 Mar 2021 21:00:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 59C48619AF for ; Mon, 22 Mar 2021 21:00:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231162AbhCVVAS (ORCPT ); Mon, 22 Mar 2021 17:00:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230274AbhCVU72 (ORCPT ); Mon, 22 Mar 2021 16:59:28 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01118C061756 for ; Mon, 22 Mar 2021 13:59:28 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id e14so5352484ejz.11 for ; Mon, 22 Mar 2021 13:59:27 -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=+qkY7r0ZE2yJZqukhmqaqDgUB9c+oVFs+zy9IRdKvxM=; b=rpYGnu87i4JNbjvTqxZsBtedI0b2BDCya6MhnHM0/IkTt6DIzEf97FSvWl0s4oiUZ6 DwNbjy7f1WN+mgbFq0oAM/B+8gkBmRRhvicOxV8/X41v7vzfilC5I6KmOrfWZpm3LGOa PduMChWryOJJlygOZliTfZAXkKbeTEQ5jgtU2zoauoa3uXLgF+SSPk1F10EEfIv8A7WA S/aPeKH0xfn3D06DfxFf+R5+VQgrpkeqVJcRuZqAGeDv2irLoH9DJwupcOTHc6maPUaD FLTqKtUTv2hDyZnWCVevc8fa2f2apOS0f22anzDVuiZeEzW9lhPsXZwp3ezdbfa+EDQK bNqg== 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=+qkY7r0ZE2yJZqukhmqaqDgUB9c+oVFs+zy9IRdKvxM=; b=SbfCGsu8c/Xnm7V9QBj7hRZ4wZiotaBiTysrLa+6t4/+fN4Y0r8klOUngbpalU9VWF jfT+owYX7Ho7AR4BbNsQsRfr3SWhF25b4WPCosYpniyC0X0aeeKgv7kyuZLUrV0uRq7d BBMcfJ8Ezd6CHckUZglfFPKzA3FL3IP3Np8Oa2ugkDd36+kk6Aw52W8cK8pYvWlZvcDM xUCcKd1mGnGReJGTZZjBXYSBjEKV2/hY57dWzWc0uiOBO2xQM7DrSchyyLPG8aV8lA43 FaiIMF7+hC3pB/GAERERVV4em8aXbubM7SRMcJ3NZWyk7kiRVeo9tRODmRZYWdYWamyu 0CMA== X-Gm-Message-State: AOAM530ZNJoZ0k+YBl+ZclHbXglsSr/zigv87of0IL0cmXK6lb+JYipB /aMgT3w+QYtRtvFWeWCTkro= X-Google-Smtp-Source: ABdhPJw+wSX6ZXrnvr2g8LcBbuGo7IEk3Y7DSFapMjkLjF5PRpolRD1ZTGOq+LqHQeljhSuXS/aljA== X-Received: by 2002:a17:906:7946:: with SMTP id l6mr1594690ejo.500.1616446766740; Mon, 22 Mar 2021 13:59:26 -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 v25sm11621074edr.18.2021.03.22.13.59.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 13:59:26 -0700 (PDT) From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Cc: andrew@lunn.ch, f.fainelli@gmail.com, olteanv@gmail.com, Ioana Ciornei Subject: [PATCH net-next 4/6] dpaa2-switch: add support for configuring per port broadcast flooding Date: Mon, 22 Mar 2021 22:58:57 +0200 Message-Id: <20210322205859.606704-5-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210322205859.606704-1-ciorneiioana@gmail.com> References: <20210322205859.606704-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Ioana Ciornei The BR_BCAST_FLOOD bridge port flag is now accepted by the driver and a change in its state will determine a reconfiguration of the broadcast egress flooding list on the FDB associated with the port. Signed-off-by: Ioana Ciornei --- .../ethernet/freescale/dpaa2/dpaa2-switch.c | 32 +++++++++++++++++-- .../ethernet/freescale/dpaa2/dpaa2-switch.h | 2 +- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c index 2ea3a4dac49d..2ae4faf81b1f 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c @@ -127,7 +127,10 @@ static void dpaa2_switch_fdb_get_flood_cfg(struct ethsw_core *ethsw, u16 fdb_id, if (ethsw->ports[j]->fdb->fdb_id != fdb_id) continue; - cfg->if_id[i++] = ethsw->ports[j]->idx; + if (type == DPSW_BROADCAST && ethsw->ports[j]->bcast_flood) + cfg->if_id[i++] = ethsw->ports[j]->idx; + else if (type == DPSW_FLOODING) + cfg->if_id[i++] = ethsw->ports[j]->idx; } /* Add the CTRL interface to the egress flooding domain */ @@ -1260,11 +1263,22 @@ static int dpaa2_switch_port_set_learning(struct ethsw_port_priv *port_priv, boo return err; } +static int dpaa2_switch_port_flood(struct ethsw_port_priv *port_priv, + struct switchdev_brport_flags flags) +{ + struct ethsw_core *ethsw = port_priv->ethsw_data; + + if (flags.mask & BR_BCAST_FLOOD) + port_priv->bcast_flood = !!(flags.val & BR_BCAST_FLOOD); + + return dpaa2_switch_fdb_set_egress_flood(ethsw, port_priv->fdb->fdb_id); +} + static int dpaa2_switch_port_pre_bridge_flags(struct net_device *netdev, struct switchdev_brport_flags flags, struct netlink_ext_ack *extack) { - if (flags.mask & ~(BR_LEARNING)) + if (flags.mask & ~(BR_LEARNING | BR_BCAST_FLOOD)) return -EINVAL; return 0; @@ -1285,6 +1299,12 @@ static int dpaa2_switch_port_bridge_flags(struct net_device *netdev, return err; } + if (flags.mask & BR_BCAST_FLOOD) { + err = dpaa2_switch_port_flood(port_priv, flags); + if (err) + return err; + } + return 0; } @@ -1643,6 +1663,12 @@ static int dpaa2_switch_port_bridge_leave(struct net_device *netdev) if (err) netdev_err(netdev, "Unable to restore RX VLANs to the new FDB, err (%d)\n", err); + /* Reset the flooding state to denote that this port can send any + * packet in standalone mode. With this, we are also ensuring that any + * later bridge join will have the flooding flag on. + */ + port_priv->bcast_flood = true; + /* Setup the egress flood policy (broadcast, unknown unicast). * When the port is not under a bridge, only the CTRL interface is part * of the flooding domain besides the actual port @@ -2728,6 +2754,8 @@ static int dpaa2_switch_probe_port(struct ethsw_core *ethsw, port_netdev->needed_headroom = DPAA2_SWITCH_NEEDED_HEADROOM; + port_priv->bcast_flood = true; + /* Set MTU limits */ port_netdev->min_mtu = ETH_MIN_MTU; port_netdev->max_mtu = ETHSW_MAX_FRAME_LENGTH; diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.h b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.h index 933563064015..65ede6036870 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.h +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.h @@ -105,13 +105,13 @@ struct ethsw_port_priv { struct ethsw_core *ethsw_data; u8 link_state; u8 stp_state; - bool flood; u8 vlans[VLAN_VID_MASK + 1]; u16 pvid; u16 tx_qdid; struct dpaa2_switch_fdb *fdb; + bool bcast_flood; }; /* Switch data */ From patchwork Mon Mar 22 20:58:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 406482 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, 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 862BDC433E4 for ; Mon, 22 Mar 2021 21:00:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6D3A96191C for ; Mon, 22 Mar 2021 21:00:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231224AbhCVVAV (ORCPT ); Mon, 22 Mar 2021 17:00:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230321AbhCVU73 (ORCPT ); Mon, 22 Mar 2021 16:59:29 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFD7FC061762 for ; Mon, 22 Mar 2021 13:59:28 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id ce10so23556047ejb.6 for ; Mon, 22 Mar 2021 13:59:28 -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=UI6QUETnwQ0x6h1xBD+ow6sFO/yryKz1p1XoSX3FONM=; b=uuq3wbNBlHo8BMcXwk+rZdM/htSTdymK24jBXfgaR3XnB0tdZ7dGrVdgGtz0OUA21R /ag7G6io3Skdc+6rEqya/Mr0KhlI1oDPkXFHf05hCjVbJaoiBAQKPoFUOC132M/+VneD 3wMMWcSlgHE9ulaBxMKZe449Su8r6XT8aQrTXnVA6e+YsmAa0cek2fy0qF0GnQPEkXGO 74DNu+tlSpE7Q3AZGWus4TgevYepZDu0SQ2a2hBHeD48N84GXdoKm7Q9XpRJ+D0fBeN5 b2t/AHgb58/qhUeA61swhZrkWyhbAkUqMhfYxFVrDgl6oT2Rs0twQB90O4reZcCv27jJ aB2A== 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=UI6QUETnwQ0x6h1xBD+ow6sFO/yryKz1p1XoSX3FONM=; b=OVGcC9hHXOs4fL6xwmiZVG0cJ3k/z7o6GmWcGg8oTPeEyrA2yMaQlwQC9zr6KThe/o PuZkgFzTmKtovlbRZ084ZW7aw2crIF2OzUt4AURZnz6DfjSVD2VwuZfYw+2xGmsEI2J9 OGBTHiKX2UdpXeK09D2/bfaKNhTQgT7RkGshMfOceqFfU2/gHhLHk+s7zEoE6ZMWIYqm QBcbssPm9hUClM+DSWYscBykNaw3QuYFQVSzqjdST6jkhGxknXXIFB2llhdZl5uThspL eIzm6ZR8A+eVM+/6VCbBo/64BeDesVPF/aZ+xWswD9v0XIefAuDpydKK0A7D8qGLjbvZ tS4Q== X-Gm-Message-State: AOAM530R4JUwuWiVWRGy/qL2En5h7xY5HltoRCRMf4WhHHFzUpHhEkg2 /rVJkkS7N4g48TLhTqlomVDg9lTGTOcqmg== X-Google-Smtp-Source: ABdhPJxTwR0JKFqYTIKq/hoHHJFGdEQSe0Lzgt99gmm0jiQT+Ep1j8RwExfw1ofecvnYTHua433x6A== X-Received: by 2002:a17:907:6289:: with SMTP id nd9mr1639930ejc.384.1616446767596; Mon, 22 Mar 2021 13:59:27 -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 v25sm11621074edr.18.2021.03.22.13.59.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 13:59:27 -0700 (PDT) From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Cc: andrew@lunn.ch, f.fainelli@gmail.com, olteanv@gmail.com, Ioana Ciornei Subject: [PATCH net-next 5/6] dpaa2-switch: add support for configuring per port unknown flooding Date: Mon, 22 Mar 2021 22:58:58 +0200 Message-Id: <20210322205859.606704-6-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210322205859.606704-1-ciorneiioana@gmail.com> References: <20210322205859.606704-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Ioana Ciornei Add support for configuring per port unknown flooding by accepting both BR_FLOOD and BR_MCAST_FLOOD as offloadable bridge port flags. The DPAA2 switch does not support at the moment configuration of unknown multicast flooding independently of unknown unicast flooding, therefore check that both BR_FLOOD and BR_MCAST_FLOOD have the same state. Signed-off-by: Ioana Ciornei --- .../ethernet/freescale/dpaa2/dpaa2-switch.c | 23 ++++++++++++++++--- .../ethernet/freescale/dpaa2/dpaa2-switch.h | 1 + 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c index 2ae4faf81b1f..9f1a59219435 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c @@ -129,7 +129,7 @@ static void dpaa2_switch_fdb_get_flood_cfg(struct ethsw_core *ethsw, u16 fdb_id, if (type == DPSW_BROADCAST && ethsw->ports[j]->bcast_flood) cfg->if_id[i++] = ethsw->ports[j]->idx; - else if (type == DPSW_FLOODING) + else if (type == DPSW_FLOODING && ethsw->ports[j]->ucast_flood) cfg->if_id[i++] = ethsw->ports[j]->idx; } @@ -1271,6 +1271,9 @@ static int dpaa2_switch_port_flood(struct ethsw_port_priv *port_priv, if (flags.mask & BR_BCAST_FLOOD) port_priv->bcast_flood = !!(flags.val & BR_BCAST_FLOOD); + if (flags.mask & BR_FLOOD) + port_priv->ucast_flood = !!(flags.val & BR_FLOOD); + return dpaa2_switch_fdb_set_egress_flood(ethsw, port_priv->fdb->fdb_id); } @@ -1278,9 +1281,21 @@ static int dpaa2_switch_port_pre_bridge_flags(struct net_device *netdev, struct switchdev_brport_flags flags, struct netlink_ext_ack *extack) { - if (flags.mask & ~(BR_LEARNING | BR_BCAST_FLOOD)) + if (flags.mask & ~(BR_LEARNING | BR_BCAST_FLOOD | BR_FLOOD | + BR_MCAST_FLOOD)) return -EINVAL; + if (flags.mask & (BR_FLOOD | BR_MCAST_FLOOD)) { + bool multicast = !!(flags.val & BR_MCAST_FLOOD); + bool unicast = !!(flags.val & BR_FLOOD); + + if (unicast != multicast) { + NL_SET_ERR_MSG_MOD(extack, + "Cannot configure multicast flooding independently of unicast"); + return -EINVAL; + } + } + return 0; } @@ -1299,7 +1314,7 @@ static int dpaa2_switch_port_bridge_flags(struct net_device *netdev, return err; } - if (flags.mask & BR_BCAST_FLOOD) { + if (flags.mask & (BR_BCAST_FLOOD | BR_FLOOD | BR_MCAST_FLOOD)) { err = dpaa2_switch_port_flood(port_priv, flags); if (err) return err; @@ -1668,6 +1683,7 @@ static int dpaa2_switch_port_bridge_leave(struct net_device *netdev) * later bridge join will have the flooding flag on. */ port_priv->bcast_flood = true; + port_priv->ucast_flood = true; /* Setup the egress flood policy (broadcast, unknown unicast). * When the port is not under a bridge, only the CTRL interface is part @@ -2755,6 +2771,7 @@ static int dpaa2_switch_probe_port(struct ethsw_core *ethsw, port_netdev->needed_headroom = DPAA2_SWITCH_NEEDED_HEADROOM; port_priv->bcast_flood = true; + port_priv->ucast_flood = true; /* Set MTU limits */ port_netdev->min_mtu = ETH_MIN_MTU; diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.h b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.h index 65ede6036870..549218994243 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.h +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.h @@ -112,6 +112,7 @@ struct ethsw_port_priv { struct dpaa2_switch_fdb *fdb; bool bcast_flood; + bool ucast_flood; }; /* Switch data */ From patchwork Mon Mar 22 20:58:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 407463 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 7441FC433E1 for ; Mon, 22 Mar 2021 21:00:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 411BE619B0 for ; Mon, 22 Mar 2021 21:00:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230527AbhCVVAM (ORCPT ); Mon, 22 Mar 2021 17:00:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230325AbhCVU7a (ORCPT ); Mon, 22 Mar 2021 16:59:30 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5039C061763 for ; Mon, 22 Mar 2021 13:59:29 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id w3so23566490ejc.4 for ; Mon, 22 Mar 2021 13:59:29 -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=Fe3BoLQtT+MYeWphkgPPUy4gZYSXnnDRm0wnWDtqhuM=; b=ERKxET+J9tC+CGRqZLrAZbe3Kc3WWQdA2UclKl/rXaK00KJIP0RVTfoBgyZ1qbrs/l Wx3ak6/aDLNEI2Mco2PeurDUda6eHQIYNyAWgsgwQ9rVAVjWxYK4YnD8hIOo0W9WnMi2 gx8f1vgrYmOt5hZWiavbcjpY7AI0gLYabMmTcqFBGS7th1DfQi/v6ZyhHExHd0QFIJJg jLZ9R8sEqtFlL8/+zXeWceWRKDAGOzR7UFJBkV9ApqSpyNzvUp9RRCEksM0UspB+TM8C wlDuiuDWu8zvklM+8K8rKaaL3Q0tu51UvPDoQnUE3EyP3WmSge3nO3JAS0GokkfM2Cin inWA== 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=Fe3BoLQtT+MYeWphkgPPUy4gZYSXnnDRm0wnWDtqhuM=; b=BDhDtRYUIBtsi4xWQzDcIjfyklHMdz+s43a3DnGKBnDu/T/YA14B6f2vB+6AeW42zP Huw+S6o/CAJZs/fX2LGnjemsc8PgiVbOjvx7cITStgqtqcnHIcQsfmtzT2bVc+Q0PTQU yFfE0fcGXN6QxGc7/dZ6mQhI9SSZe6s0vOVosJ8vh7I9AxKlqr63/UQ9P0QQDcgUYb4w rs7Do7GjdGS3gYb7AAi4VIVmNBK+PobxwaTCrCap5oZdTlyYWnQR+77/kkpTz7clDNx6 QC88Y6OhvPq3OFuvS/7EUu5rvWqtxPDTJU+dl1gbWUC7jmvuOqnAVZQNlJr3Xx+IcluB WATQ== X-Gm-Message-State: AOAM533/g/76gmm/L+1UYnU+C4tWPesmyCNVQ76sUWMdlSSsZBXbzGEf uV41E9Y63/yGD8XBR0aABKyPySgtt3DSwQ== X-Google-Smtp-Source: ABdhPJwuB4Qodpvhr56cguVhch1SJzPZqztFfg8kFVxCuEm4T51QSg/o4oww0d4iZd334X1Zq2k4jQ== X-Received: by 2002:a17:906:f1d6:: with SMTP id gx22mr1617304ejb.59.1616446768434; Mon, 22 Mar 2021 13:59:28 -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 v25sm11621074edr.18.2021.03.22.13.59.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 13:59:28 -0700 (PDT) From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Cc: andrew@lunn.ch, f.fainelli@gmail.com, olteanv@gmail.com, Ioana Ciornei Subject: [PATCH net-next 6/6] dpaa2-switch: mark skbs with offload_fwd_mark Date: Mon, 22 Mar 2021 22:58:59 +0200 Message-Id: <20210322205859.606704-7-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210322205859.606704-1-ciorneiioana@gmail.com> References: <20210322205859.606704-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Ioana Ciornei If a switch port is under a bridge, the offload_fwd_mark should be setup before sending the skb towards the stack so that the bridge does not try to flood the packet on the other switch ports. Signed-off-by: Ioana Ciornei --- drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c index 9f1a59219435..a9b30a72ddad 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c @@ -2005,6 +2005,9 @@ static void dpaa2_switch_rx(struct dpaa2_switch_fq *fq, skb->dev = netdev; skb->protocol = eth_type_trans(skb, skb->dev); + /* Setup the offload_fwd_mark only if the port is under a bridge */ + skb->offload_fwd_mark = !!(port_priv->fdb->bridge_dev); + netif_receive_skb(skb); return;