Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1793609rwi; Wed, 19 Oct 2022 15:44:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7UMwkumbC1LJrp0azSW4kmg9yGOLiwignKoSrstv4RaB8uJHHJU7Lt6HKYjvwkBBzgDtIh X-Received: by 2002:a62:aa0c:0:b0:567:6e2c:3355 with SMTP id e12-20020a62aa0c000000b005676e2c3355mr7113315pff.83.1666219466359; Wed, 19 Oct 2022 15:44:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666219466; cv=none; d=google.com; s=arc-20160816; b=cp8gFoksZdBCDkVyG7xSyQzpFm67QjP3jm5/hhLhIf+lBHfy6Q6DFdXg7Wo3xFrvUg +q7KdeHN2lu1vFVAPHBbrtGaahJhEJy7TWm+s5iAHZgL0uX58DLfAC/KWERqQviPGEE6 5bY3gVsEGRPDuu9X3cbj3CPm0j5mGJfT+q6nl3RpPBDMxO6xLKGS8cVJ7vVM1V+CW5Bq 6eTxiRhXJBY7lAVTByYuIJq77HgG0XPbFO6hssORYTkG1OoNz7rrJr2MmmFSZVCJSmHR MD4GcOqzL1rfBBdeI0TXowl/RfvYTGMbOIokndEk7qEZYii1OHLe2BeppyxF9VK9vxMI 0uvg== 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=B9BS0OtCWn0ox+Cz86hvmvKcDCubEqsZ4yAMu9/GWbQ=; b=ftVOC+CY05B9c3GQag5YlBOb0sEZDEoDky8ZAa4ugIaCYEqUxAu/21bhY9r3Qu2XGs YfPQ5UsL4QTPVyPYW0aKC0LVnnmBLN/Jmyb1fSPcuam7MiSVb8xXZWZOFvGMpYfMsfPR mgzApkSrW/oU3fmgjio4PvAfNGUDIEw79agNmq++yinJ5hwTu/ymWVvKeX2Fio3qpHWQ OO5xR549N2Nhk20ayHXoo2pMkB0ywkifkQKHpdKD58Tyw8m0OQfzq2jLu8yfenSsKkym TyywdeccXkGSdgtIKNsT6NWtZKCR8N84ji42iFyOgZa6Z30mK/+/w3TDrTBfX2F+r+l0 JY8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Tagbyb82; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b13-20020a6541cd000000b004393c9493ecsi19576712pgq.568.2022.10.19.15.44.13; Wed, 19 Oct 2022 15:44:26 -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=Tagbyb82; 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 S229509AbiJSVvi (ORCPT + 99 others); Wed, 19 Oct 2022 17:51:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230260AbiJSVvh (ORCPT ); Wed, 19 Oct 2022 17:51:37 -0400 Received: from mail-qt1-x82f.google.com (mail-qt1-x82f.google.com [IPv6:2607:f8b0:4864:20::82f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5845F18D448; Wed, 19 Oct 2022 14:51:36 -0700 (PDT) Received: by mail-qt1-x82f.google.com with SMTP id r19so12612470qtx.6; Wed, 19 Oct 2022 14:51:36 -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=B9BS0OtCWn0ox+Cz86hvmvKcDCubEqsZ4yAMu9/GWbQ=; b=Tagbyb82i5ua5ayPP/I9ftNAJ/fWiDjA6JSRz0b5lqGJa7INDFTZwESIQ4Oxcah9TL fH79CdFBvvVMNG/SGRvm6PjRM9jz49KasQKPoctnHA7Qi3sjVzgE44GRxQyX+20X+A/n 3Y6Wor4W5p8cKvCJNA1YGp5rbSg391L0tvN2HE08AN36V6PefOUyAlpnj+JWoVZcHDkJ U0J2+C9c3a7ZTyfww4BWZk2ZoRg2vLwyaJr0quvCdSJXqiSKCUZSaEdM3uZGe9m0SRAT SqNVQ8i6uYB7r95qgUa5c4Y7f4GP2pvzDGNeZtkFpkoj89wLVlNT1qSdzZXNUi+suGvk buew== 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=B9BS0OtCWn0ox+Cz86hvmvKcDCubEqsZ4yAMu9/GWbQ=; b=L4qljsklJkOe2t45WL2fZxZwe8+Gco+giDgzA+d+xIxrJ5fYOzy4lGtPw8kufUbqVh kEqj4uB2GLcbvNMkeLRftN7fBJD13dtkL1j1vG1TjVO9zu0nHQ/LvX8A7gTl27QgD+fr shAbsFUUX7WXz5g+D60iV8+VRIsDGxGX+N3jcq0K/sgh5wXoy6MvusjVrjjf/4ab+iwM hScmXG+p3ETD34A9PI2LPtnpax7Tzt43SHlTjGXMaPny8CXbWS9m6X4XN1SyF2vPHs4x iQ1P+bGObTWz34d9b//g1+hjea/5vj5QvioF+Ro8qoJHMU/Y2PMIi/PUkA0HVpJHOg8f nmOQ== X-Gm-Message-State: ACrzQf2Mbm8re9sQqBYXtCHe0La9EIfBgcBfqCwFmSu9+mTOXbjGbpjL O4t6rgKhFKduXSyR/rr3QmE= X-Received: by 2002:a05:622a:1804:b0:39c:c7ba:4ac1 with SMTP id t4-20020a05622a180400b0039cc7ba4ac1mr8248134qtc.457.1666216295441; Wed, 19 Oct 2022 14:51:35 -0700 (PDT) Received: from stbirv-lnx-3.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id k2-20020a05620a414200b006bba46e5eeasm6225407qko.37.2022.10.19.14.51.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 14:51:34 -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 v2] net: bcmgenet: add RX_CLS_LOC_ANY support Date: Wed, 19 Oct 2022 14:51:23 -0700 Message-Id: <20221019215123.316997-1-opendmb@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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 --- changes since v1: - removed __u32 tmp variable. Thanks Jakub! .../net/ethernet/broadcom/genet/bcmgenet.c | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c index 25c450606985..a8ce8d0cf9c4 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,7 +1453,7 @@ static int bcmgenet_insert_flow(struct net_device *dev, { struct bcmgenet_priv *priv = netdev_priv(dev); struct bcmgenet_rxnfc_rule *loc_rule; - int err; + int err, i; if (priv->hw_params->hfb_filter_size < 128) { netdev_err(dev, "rxnfc: Not supported by this device\n"); @@ -1470,7 +1471,29 @@ 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) { + cmd->fs.location = loc_rule->fs.location; + err = memcmp(&loc_rule->fs, &cmd->fs, + sizeof(struct ethtool_rx_flow_spec)); + if (!err) + /* rule exists so return current location */ + return 0; + } + for (i = 0; i < MAX_NUM_OF_FS_RULES; i++) { + loc_rule = &priv->rxnfc_rules[i]; + if (loc_rule->state == BCMGENET_RXNFC_STATE_UNUSED) { + cmd->fs.location = i; + break; + } + } + if (i == MAX_NUM_OF_FS_RULES) { + cmd->fs.location = RX_CLS_LOC_ANY; + 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 +1606,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); -- 2.25.1