From patchwork Wed Oct 19 21:51:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 5854 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp551947wrs; Wed, 19 Oct 2022 14:57:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Gv4ENCggFS2Ori+sMMQtCudRl5amDKxWQPZk6DoP67TcavGphG7QOtYcOchRRrFciTort X-Received: by 2002:a17:90b:3cb:b0:211:9f71:46de with SMTP id go11-20020a17090b03cb00b002119f7146demr602731pjb.151.1666216647954; Wed, 19 Oct 2022 14:57:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666216647; cv=none; d=google.com; s=arc-20160816; b=ngBNajphT8zRLFmF32t/VOPIJW/xaS4w/hNwscxTWGySV78gZT0pVhpGykeEP7uxay b6WeUUxl35h54iZmrKZhRb/3vkefYoSNO25OQiT/EJFh42Ej0+FByMzwDPPzqESJ+Cvx Jz9+kaB3e0I/yvEJ9hD8Rn8Bbb3Lu9B5UbpjBKbhgnjhWDNR5CHB/BGo7sOzcqwy49gd uCC00CHqDTN2bZtHnxWg2s62nyVVxSqxazbjmvcU+3ydw6LrxSGnOQjqrxM6eq1NEk26 geoW5IRr4CH80X7zXlpLKEsUY34P6mXY+e7y8ao3mzbh9TUE90z3h6R0qmXojwiiOIgR bHyQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h62-20020a638341000000b0046b2bed9c97si17820493pge.757.2022.10.19.14.57.14; Wed, 19 Oct 2022 14:57:27 -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 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?1747154788056839907?= X-GMAIL-MSGID: =?utf-8?q?1747154788056839907?= 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 --- 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);