From patchwork Mon Oct 17 21:32:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 3751 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1653592wrs; Mon, 17 Oct 2022 14:41:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7eDDN1IHICm3Ddt5d3a1EFSgXUx+a5oMiY+wDEkM5IuJ1VoSnJGJ3j20QjC3C0OSIaPZL2 X-Received: by 2002:a05:6402:5409:b0:44f:1e05:1e8 with SMTP id ev9-20020a056402540900b0044f1e0501e8mr11910332edb.373.1666042917193; Mon, 17 Oct 2022 14:41:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666042917; cv=none; d=google.com; s=arc-20160816; b=GNC9Wt25LSC4gOTqOSfDAECtRbYCqAc4eSBAddGVyCKVzzAKtyMGw3y+WrhH2S5TCq dmZU5r7+ifapd1DhxNGJ9bCOdwNGV7KhFKw4g459I1Om1Kb5pLY3KBXUALX2QIiaVpNu zwG7h1MuosrlVRRmD2NFW7lXVEaFi/Z+bUzIXsbWxVD7xvgRewutSPuPDuc/IZI3D8/Z q21HulE1EP8mIjewQ7IcTe7ITUqETKEpQLTKt59M57ej28aRPWUlpiA4Z2XZ8Hlgzt0R PMk0IIrAVo3bvU3oSGaR0ZnD0uUDFU6qyOrN5KjVaoxYzPHgrg1QY/NImHOmjvRPbu2i dnSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=zsL7sE2NY9nd+Z7C5awnq6ymEQUvmX75a8CLY1tINwQ=; b=XsYplXVgo4W65AdpZCjG/pH51viSdawcR4evGE0FDYxLSQ+Q2xMmFjR7EhWmA6ma8V wI+JTZHfaqMpY6KYHmzUyW2etBTUFKwzID/8gVS/v3S80XV8EktIBLKdaAFEmj4c7Hpo y2Yw6zr7puKK7c0svgwAdda9LQjlqffpP5a7VIVyA/LqkjdniyrFPJKh8B9dH7F4lP+l yAgXXZjo35i/2/bgQAuIxGH8Bh+fFC1A5D9M+wZ4QNNvr1i3o3uhQpUZFv4v//U5eJnt TT2Li3TH6AYgN7gKm9KQ4VHVLBVvRYaOPgeWba46U2dRezpV3wU9VYdf1p1M6ij/VomW 4r7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="PgCnWtz/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r10-20020a1709060d4a00b007878144285csi8790235ejh.314.2022.10.17.14.41.31; Mon, 17 Oct 2022 14:41:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="PgCnWtz/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230071AbiJQVdM (ORCPT + 99 others); Mon, 17 Oct 2022 17:33:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230452AbiJQVdG (ORCPT ); Mon, 17 Oct 2022 17:33:06 -0400 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF0217CB66; Mon, 17 Oct 2022 14:33:02 -0700 (PDT) Received: by mail-qk1-x72b.google.com with SMTP id m6so7546190qkm.4; Mon, 17 Oct 2022 14:33:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=zsL7sE2NY9nd+Z7C5awnq6ymEQUvmX75a8CLY1tINwQ=; b=PgCnWtz/NwW1XoM9JOUmaoo+DPu3mJV9uQIVpqFsx5zmy9L6s67Ik5HkOuUxsgZoT0 rlKUJL0BOZZcwSgJJfeazFzj/RW3m4PZPexzzEJ0YX8HgeY3nA4bUPMLzvdksdcwY47e Ufd7B+9FwBwBJhXXgEziuVeaTkU68XCkb/IsaUht+UCeX7ToStClfZR1yNHaL5oT7s+T ITFHNaNs4UXzyFM4urVsFK+S9+9fzWger9iDTFL6KE9up2SBT5rgUoGZZTfRGw72MoZB /+ad0nLeC2k2xpdVDTqFF71hgV9gpHcS+JBp/+9HAtGsHS2Jb/kvOrr1zPMoJTMTMihp sOew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zsL7sE2NY9nd+Z7C5awnq6ymEQUvmX75a8CLY1tINwQ=; b=gprtj8EQmg2wOzeyXX33ZkQz/9sD3QX1MfqnvU+iHlnl1JtKh2jeGPb7U5U8ujMzRR ltNYB/eXSFpp3PC2FdO8XI8jJIiM7re1dr1UDnsqQKLMvDIsSkmAPeU9Hkd6JvVaOfXC VVEk63EfMBbEjWWlLQXaVPAs/8ZSlC7Miaam3EvanUztScUMJkF/3BKE3uA7w1e+z0So USyWxkRUbYVA2wazWr3GWJEKVZ9wJmF/UiPSeXZ/X+rF8RV2tRfT5oFg7EaSPgARYq68 vf/0TvZhdqCFdiCj8olJCe3+ZLKKesPnwhnjcEE4rfZfWdFdcIed9CY0xf9H/8O4S4UB p41g== X-Gm-Message-State: ACrzQf2wiO8BSxKg1qejvT9raoSnlz0XFDpckWAgKNTvU6DMJkVquDHY pFXXPtUI4KzWkQ8C/8Pptg1cMoGorv4= X-Received: by 2002:a05:620a:2b92:b0:6ed:b30a:d564 with SMTP id dz18-20020a05620a2b9200b006edb30ad564mr9368693qkb.234.1666042380839; Mon, 17 Oct 2022 14:33:00 -0700 (PDT) Received: from stbirv-lnx-3.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id s7-20020a05620a254700b006ec59941acasm786335qko.11.2022.10.17.14.32.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 14:33:00 -0700 (PDT) From: Doug Berger To: "David S. Miller" Cc: Florian Fainelli , Eric Dumazet , Jakub Kicinski , Paolo Abeni , bcm-kernel-feedback-list@broadcom.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Doug Berger Subject: [PATCH net-next] net: bcmgenet: add RX_CLS_LOC_ANY support Date: Mon, 17 Oct 2022 14:32:37 -0700 Message-Id: <20221017213237.814861-1-opendmb@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746972617605645554?= X-GMAIL-MSGID: =?utf-8?q?1746972617605645554?= If a matching flow spec exists its current location is as good as ANY. If not add the new flow spec at the first available location. Signed-off-by: Doug Berger Acked-by: Florian Fainelli --- .../net/ethernet/broadcom/genet/bcmgenet.c | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c index 25c450606985..9b1e544547f7 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c @@ -1387,7 +1387,8 @@ static int bcmgenet_validate_flow(struct net_device *dev, struct ethtool_usrip4_spec *l4_mask; struct ethhdr *eth_mask; - if (cmd->fs.location >= MAX_NUM_OF_FS_RULES) { + if (cmd->fs.location >= MAX_NUM_OF_FS_RULES && + cmd->fs.location != RX_CLS_LOC_ANY) { netdev_err(dev, "rxnfc: Invalid location (%d)\n", cmd->fs.location); return -EINVAL; @@ -1452,6 +1453,7 @@ static int bcmgenet_insert_flow(struct net_device *dev, { struct bcmgenet_priv *priv = netdev_priv(dev); struct bcmgenet_rxnfc_rule *loc_rule; + __u32 tmp; int err; if (priv->hw_params->hfb_filter_size < 128) { @@ -1470,7 +1472,31 @@ static int bcmgenet_insert_flow(struct net_device *dev, if (err) return err; - loc_rule = &priv->rxnfc_rules[cmd->fs.location]; + if (cmd->fs.location == RX_CLS_LOC_ANY) { + list_for_each_entry(loc_rule, &priv->rxnfc_list, list) { + tmp = loc_rule->fs.location; + loc_rule->fs.location = cmd->fs.location; + err = memcmp(&loc_rule->fs, &cmd->fs, + sizeof(struct ethtool_rx_flow_spec)); + loc_rule->fs.location = tmp; + if (!err) { + /* rule exists so return current location */ + cmd->fs.location = tmp; + return 0; + } + } + for (tmp = 0; tmp < MAX_NUM_OF_FS_RULES; tmp++) { + loc_rule = &priv->rxnfc_rules[tmp]; + if (loc_rule->state == BCMGENET_RXNFC_STATE_UNUSED) { + cmd->fs.location = tmp; + break; + } + } + if (tmp == MAX_NUM_OF_FS_RULES) + return -ENOSPC; + } else { + loc_rule = &priv->rxnfc_rules[cmd->fs.location]; + } if (loc_rule->state == BCMGENET_RXNFC_STATE_ENABLED) bcmgenet_hfb_disable_filter(priv, cmd->fs.location); if (loc_rule->state != BCMGENET_RXNFC_STATE_UNUSED) { @@ -1583,7 +1609,7 @@ static int bcmgenet_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd, break; case ETHTOOL_GRXCLSRLCNT: cmd->rule_cnt = bcmgenet_get_num_flows(priv); - cmd->data = MAX_NUM_OF_FS_RULES; + cmd->data = MAX_NUM_OF_FS_RULES | RX_CLS_LOC_SPECIAL; break; case ETHTOOL_GRXCLSRULE: err = bcmgenet_get_flow(dev, cmd, cmd->fs.location);