From patchwork Tue Apr 13 13:24:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 420675 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.7 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 113B8C433ED for ; Tue, 13 Apr 2021 13:26:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E82EF613B1 for ; Tue, 13 Apr 2021 13:26:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345913AbhDMN0W (ORCPT ); Tue, 13 Apr 2021 09:26:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241658AbhDMN0R (ORCPT ); Tue, 13 Apr 2021 09:26:17 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13822C061574 for ; Tue, 13 Apr 2021 06:25:56 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id s14so3616012pjl.5 for ; Tue, 13 Apr 2021 06:25:56 -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=JMtB3sTR+OLp053ETHSfMwDWfNuUQ0eFZhxyaM8Kg78=; b=Y5k68lrtZD3rwlPLfIsn6XsnrCDZ3QPLJNN1VmVSCT+lJr862+WEI2DaC8llyWtrrb goUhVXv8HqvA2GF9DesywhGw5ff6j7ORaf4ciDSpOCiUfGui5gRq9EA1eVcrlUT+ag8n 0p8oOmu8wNHXEaVufGwuwvY+8WROIOmtETPy6IfxP82GG2Ced/F0PGFdbi4O9RDCTtXH VtNYOX8oCQ7s5K+d8rqPQdRbEi/MwyKKU0GaXFrQO3a/MsfsCTkGFT3pDMF0xl+P5jcs P1JmSZ+Nm/U8a9nMYyTsLQRKjO/NssjzmcfVFCEbMEF7LYloII7wv8VOH1mKL+gifrZT TU1w== 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=JMtB3sTR+OLp053ETHSfMwDWfNuUQ0eFZhxyaM8Kg78=; b=PJxi7SOPppgtILGeU5sImIHxF8dQ4fxc6uojHm5tmt2wlybuibdJ86UZQLJFoxqyVu 4OvR6ZFgptwFdYFjSdHwaVD6vf8GQ5jMClHxwKH4Oh5iQN1S7+Q507pzCyDH3NYZoW/0 aYZ1U/CbAHfjtco/z5dBsx2oIvM7AedbppLcV7m5+uzGvI1cx40GylUqwMv9L7p/HpVS b6oZJCYjSbB7GfTv2eKC+RlvxTGQDTZpkswOE1eB1TB51QIpqNaM3ACsd8pfECzrjw4+ vHX/FDd16snpKfbQj757JuYuiPK2uvdp+bmbjBS75s7hWuvD8dACsburlsyMPM6edD5q 8Zew== X-Gm-Message-State: AOAM531LsxiHeCAOU0nsZ5w3CmPwAhb1VSqdHTrhsiTDmPeLvmMf/9HJ U4rpbX5uNeYtZsngWvdfhig= X-Google-Smtp-Source: ABdhPJzYK3EV5jPdzovCexfLOjszJtYcA6s4BPmw73D3uDWdWvhc0crVqBgPeWGuiq+UWKakL2VMyg== X-Received: by 2002:a17:90a:28a1:: with SMTP id f30mr20006pjd.198.1618320355601; Tue, 13 Apr 2021 06:25:55 -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 z18sm12417650pfa.39.2021.04.13.06.25.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Apr 2021 06:25:55 -0700 (PDT) From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Cc: ruxandra.radulescu@nxp.com, Ioana Ciornei Subject: [PATCH net-next 2/5] dpaa2-switch: install default STP trap rule with the highest priority Date: Tue, 13 Apr 2021 16:24:45 +0300 Message-Id: <20210413132448.4141787-3-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210413132448.4141787-1-ciorneiioana@gmail.com> References: <20210413132448.4141787-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Ioana Ciornei Change the default ACL trap rule for STP frames to have the highest priority. In the same ACL table will reside both default rules added by the driver for its internal use as well as rules added with tc flower. In this case, the default rules such as the STP one that we already have should have the highest priority. Also, remove the check for a full ACL table since we already know that it's sized so that we don't hit this case. The last thing changes is that default trap filters will not be counted in the acl_tbl's num_rules variable since their number doesn't change. Signed-off-by: Ioana Ciornei --- drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c index 351ee8f7461c..fc9e2eb0ad11 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c @@ -2700,11 +2700,6 @@ static int dpaa2_switch_port_trap_mac_addr(struct ethsw_port_priv *port_priv, acl_h = &acl_key.match; acl_m = &acl_key.mask; - if (port_priv->acl_tbl->num_rules >= DPAA2_ETHSW_PORT_MAX_ACL_ENTRIES) { - netdev_err(netdev, "ACL full\n"); - return -ENOMEM; - } - memset(&acl_entry_cfg, 0, sizeof(acl_entry_cfg)); memset(&acl_key, 0, sizeof(acl_key)); @@ -2718,7 +2713,7 @@ static int dpaa2_switch_port_trap_mac_addr(struct ethsw_port_priv *port_priv, dpsw_acl_prepare_entry_cfg(&acl_key, cmd_buff); memset(&acl_entry_cfg, 0, sizeof(acl_entry_cfg)); - acl_entry_cfg.precedence = port_priv->acl_tbl->num_rules; + acl_entry_cfg.precedence = 0; acl_entry_cfg.result.action = DPSW_ACL_ACTION_REDIRECT_TO_CTRL_IF; acl_entry_cfg.key_iova = dma_map_single(dev, cmd_buff, DPAA2_ETHSW_PORT_ACL_CMD_BUF_SIZE, @@ -2739,8 +2734,6 @@ static int dpaa2_switch_port_trap_mac_addr(struct ethsw_port_priv *port_priv, return err; } - port_priv->acl_tbl->num_rules++; - return 0; } From patchwork Tue Apr 13 13:24:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 420674 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.7 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 06AFBC433ED for ; Tue, 13 Apr 2021 13:26:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DCB5661369 for ; Tue, 13 Apr 2021 13:26:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345967AbhDMN0c (ORCPT ); Tue, 13 Apr 2021 09:26:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345738AbhDMN00 (ORCPT ); Tue, 13 Apr 2021 09:26:26 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C725CC061574 for ; Tue, 13 Apr 2021 06:26:06 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id lr1-20020a17090b4b81b02900ea0a3f38c1so1327925pjb.0 for ; Tue, 13 Apr 2021 06:26:06 -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=cgu8hmxXAkpNCdeO9Q62EwQ7P/NjTWNkUUJyq5bafN0=; b=n3F68KbhRBZP1fuv/TbJA8EywHCVUc+GprP7hEjdxc5Vd1PMFbqpSmzcqa85aEr8b1 zBx0szrcz90jq1NZf1eUjGIg3f0juKiduCo/a6aNYO1XPsRjaBitCbDx2Q9ZrpqLhfXs ydL7YTV4/E4rsBorrNDFl987o/TaH3f/D2ZrBn4Egg601GyrlgSFbYFmYlvN60UQxQ98 BUyFlgEb4oj0XP+1MJPjy+Ysq4Tb6vVaS3UgC80osVuVP8a+1usVwUoPypd/bRxmPWhJ KNzk3k+/byMtzHopQmy9RaGoeyipj5Rdt8V8kcdT37eRxQPr+sQw5AddHieXfHoLiofZ HdOQ== 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=cgu8hmxXAkpNCdeO9Q62EwQ7P/NjTWNkUUJyq5bafN0=; b=AAwhhKvPILYl3GPUQmuFM/vW0QKNUxrBPM6LPzf0O5LssK68fr/sjd0hNH8NizFwKn 6wXOO8rpZmQwFUrw2LCWA6gLq+suwQpbch4IBSV8E0JGlLNHpYYSa0Qe/QHyHSjoJEec i7SNt2ponQvQEhhNt2EAzTACeangG76mxPQ2kTeF0ZAlqSoPM2cm62cHyxy9jzZo9F4b jOaPQLSl33R2emolM5teTMItoTSOEv2PC9LiVlzFv2C5GkX71eD769MxdPxpCPX0QIe6 t23G2m66bZvvru04cDssjTg5cb0rx82avva237rO8IUKcabIMqz8rIH7/muR9Fi5iBo3 NNpg== X-Gm-Message-State: AOAM530idDHVJNmIMGrH3S/jpzkZlMGabpP5OPcATjzoyPZTDFZ3KUrb WRQVpEqjC4oWSG6NelFOW24= X-Google-Smtp-Source: ABdhPJw91tUHyxIOOL+ms25PUmCnuMTJo7bcoCrU+avgxmi8fBcg8qp4oBg1pFCPO98VG8ALcY2Fmw== X-Received: by 2002:a17:90b:714:: with SMTP id s20mr43206pjz.62.1618320366303; Tue, 13 Apr 2021 06:26:06 -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 z18sm12417650pfa.39.2021.04.13.06.26.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Apr 2021 06:26:05 -0700 (PDT) From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Cc: ruxandra.radulescu@nxp.com, Ioana Ciornei Subject: [PATCH net-next 4/5] dpaa2-switch: add tc matchall filter support Date: Tue, 13 Apr 2021 16:24:47 +0300 Message-Id: <20210413132448.4141787-5-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210413132448.4141787-1-ciorneiioana@gmail.com> References: <20210413132448.4141787-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Ioana Ciornei Add support TC_SETUP_CLSMATCHALL by using the same ACL table entries framework as for tc flower. Adding a matchall rule is done by installing an entry which has a mask of all zeroes, thus matching on any packet. This can be used as a catch-all type of rule if used correctly, ie the priority of the matchall filter should be kept as the lowest one in the entire filter block. Signed-off-by: Ioana Ciornei --- .../freescale/dpaa2/dpaa2-switch-flower.c | 56 +++++++++++++++++++ .../ethernet/freescale/dpaa2/dpaa2-switch.c | 16 ++++++ .../ethernet/freescale/dpaa2/dpaa2-switch.h | 7 +++ 3 files changed, 79 insertions(+) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-flower.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-flower.c index ee987fa02f0d..b4807ddc2011 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-flower.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-flower.c @@ -434,3 +434,59 @@ int dpaa2_switch_cls_flower_destroy(struct dpaa2_switch_acl_tbl *acl_tbl, return dpaa2_switch_acl_tbl_remove_entry(acl_tbl, entry); } + +int dpaa2_switch_cls_matchall_replace(struct dpaa2_switch_acl_tbl *acl_tbl, + struct tc_cls_matchall_offload *cls) +{ + struct netlink_ext_ack *extack = cls->common.extack; + struct ethsw_core *ethsw = acl_tbl->ethsw; + struct dpaa2_switch_acl_entry *acl_entry; + struct flow_action_entry *act; + int err; + + if (!flow_offload_has_one_action(&cls->rule->action)) { + NL_SET_ERR_MSG(extack, "Only singular actions are supported"); + return -EOPNOTSUPP; + } + + if (dpaa2_switch_acl_tbl_is_full(acl_tbl)) { + NL_SET_ERR_MSG(extack, "Maximum filter capacity reached"); + return -ENOMEM; + } + + acl_entry = kzalloc(sizeof(*acl_entry), GFP_KERNEL); + if (!acl_entry) + return -ENOMEM; + + act = &cls->rule->action.entries[0]; + err = dpaa2_switch_tc_parse_action(ethsw, act, + &acl_entry->cfg.result, extack); + if (err) + goto free_acl_entry; + + acl_entry->prio = cls->common.prio; + acl_entry->cookie = cls->cookie; + + err = dpaa2_switch_acl_tbl_add_entry(acl_tbl, acl_entry); + if (err) + goto free_acl_entry; + + return 0; + +free_acl_entry: + kfree(acl_entry); + + return err; +} + +int dpaa2_switch_cls_matchall_destroy(struct dpaa2_switch_acl_tbl *acl_tbl, + struct tc_cls_matchall_offload *cls) +{ + struct dpaa2_switch_acl_entry *entry; + + entry = dpaa2_switch_acl_tbl_find_entry_by_cookie(acl_tbl, cls->cookie); + if (!entry) + return 0; + + return dpaa2_switch_acl_tbl_remove_entry(acl_tbl, entry); +} diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c index 5080788c692b..adf9e5880d89 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c @@ -1140,6 +1140,20 @@ dpaa2_switch_setup_tc_cls_flower(struct dpaa2_switch_acl_tbl *acl_tbl, } } +static int +dpaa2_switch_setup_tc_cls_matchall(struct dpaa2_switch_acl_tbl *acl_tbl, + struct tc_cls_matchall_offload *f) +{ + switch (f->command) { + case TC_CLSMATCHALL_REPLACE: + return dpaa2_switch_cls_matchall_replace(acl_tbl, f); + case TC_CLSMATCHALL_DESTROY: + return dpaa2_switch_cls_matchall_destroy(acl_tbl, f); + default: + return -EOPNOTSUPP; + } +} + static int dpaa2_switch_port_setup_tc_block_cb_ig(enum tc_setup_type type, void *type_data, void *cb_priv) @@ -1147,6 +1161,8 @@ static int dpaa2_switch_port_setup_tc_block_cb_ig(enum tc_setup_type type, switch (type) { case TC_SETUP_CLSFLOWER: return dpaa2_switch_setup_tc_cls_flower(cb_priv, type_data); + case TC_SETUP_CLSMATCHALL: + return dpaa2_switch_setup_tc_cls_matchall(cb_priv, type_data); default: return -EOPNOTSUPP; } diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.h b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.h index 629186208b58..8575eed02d15 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.h +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include "dpsw.h" @@ -233,4 +234,10 @@ int dpaa2_switch_cls_flower_replace(struct dpaa2_switch_acl_tbl *acl_tbl, int dpaa2_switch_cls_flower_destroy(struct dpaa2_switch_acl_tbl *acl_tbl, struct flow_cls_offload *cls); + +int dpaa2_switch_cls_matchall_replace(struct dpaa2_switch_acl_tbl *acl_tbl, + struct tc_cls_matchall_offload *cls); + +int dpaa2_switch_cls_matchall_destroy(struct dpaa2_switch_acl_tbl *acl_tbl, + struct tc_cls_matchall_offload *cls); #endif /* __ETHSW_H */