All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next v2] net: bcmgenet: add RX_CLS_LOC_ANY support
@ 2022-10-19 21:51 Doug Berger
  2022-10-19 22:00 ` Florian Fainelli
  2022-10-21  5:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Doug Berger @ 2022-10-19 21:51 UTC (permalink / raw)
  To: David S. Miller
  Cc: Florian Fainelli, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	bcm-kernel-feedback-list, netdev, linux-kernel, Doug Berger

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 <opendmb@gmail.com>
---
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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next v2] net: bcmgenet: add RX_CLS_LOC_ANY support
  2022-10-19 21:51 [PATCH net-next v2] net: bcmgenet: add RX_CLS_LOC_ANY support Doug Berger
@ 2022-10-19 22:00 ` Florian Fainelli
  2022-10-21  5:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Florian Fainelli @ 2022-10-19 22:00 UTC (permalink / raw)
  To: Doug Berger, David S. Miller
  Cc: Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	bcm-kernel-feedback-list, netdev, linux-kernel

On 10/19/22 14:51, Doug Berger wrote:
> 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 <opendmb@gmail.com>

Acked-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next v2] net: bcmgenet: add RX_CLS_LOC_ANY support
  2022-10-19 21:51 [PATCH net-next v2] net: bcmgenet: add RX_CLS_LOC_ANY support Doug Berger
  2022-10-19 22:00 ` Florian Fainelli
@ 2022-10-21  5:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-10-21  5:10 UTC (permalink / raw)
  To: Doug Berger
  Cc: davem, f.fainelli, edumazet, kuba, pabeni,
	bcm-kernel-feedback-list, netdev, linux-kernel

Hello:

This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 19 Oct 2022 14:51:23 -0700 you wrote:
> 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 <opendmb@gmail.com>
> ---
> changes since v1:
>  - removed __u32 tmp variable. Thanks Jakub!
> 
> [...]

Here is the summary with links:
  - [net-next,v2] net: bcmgenet: add RX_CLS_LOC_ANY support
    https://git.kernel.org/netdev/net-next/c/070f822d077f

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-10-21  5:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-19 21:51 [PATCH net-next v2] net: bcmgenet: add RX_CLS_LOC_ANY support Doug Berger
2022-10-19 22:00 ` Florian Fainelli
2022-10-21  5:10 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.