netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: netdev@vger.kernel.org
Cc: Florian Fainelli <f.fainelli@gmail.com>,
	andrew@lunn.ch, vivien.didelot@gmail.com, davem@davemloft.net,
	kuba@kernel.org
Subject: [PATCH net-next 3/4] net: dsa: b53: Bound check ARL searches
Date: Thu, 30 Apr 2020 11:49:10 -0700	[thread overview]
Message-ID: <20200430184911.29660-4-f.fainelli@gmail.com> (raw)
In-Reply-To: <20200430184911.29660-1-f.fainelli@gmail.com>

ARL searches are done by reading two ARL entries at a time, do not cap
the search at 1024 which would only limit us to half of the possible ARL
capacity, but use b53_max_arl_entries() instead which does the right
multiplication between bins and indexes.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/dsa/b53/b53_common.c | 2 +-
 drivers/net/dsa/b53/b53_priv.h   | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index aa0836ac751c..9550d972f8c5 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -1702,7 +1702,7 @@ int b53_fdb_dump(struct dsa_switch *ds, int port,
 				break;
 		}
 
-	} while (count++ < 1024);
+	} while (count++ < b53_max_arl_entries(priv) / 2);
 
 	return 0;
 }
diff --git a/drivers/net/dsa/b53/b53_priv.h b/drivers/net/dsa/b53/b53_priv.h
index 694e26cdfd4d..e942c60e4365 100644
--- a/drivers/net/dsa/b53/b53_priv.h
+++ b/drivers/net/dsa/b53/b53_priv.h
@@ -213,6 +213,11 @@ static inline int is58xx(struct b53_device *dev)
 #define B53_CPU_PORT_25	5
 #define B53_CPU_PORT	8
 
+static inline unsigned int b53_max_arl_entries(struct b53_device *dev)
+{
+	return dev->num_arl_buckets * dev->num_arl_bins;
+}
+
 struct b53_device *b53_switch_alloc(struct device *base,
 				    const struct b53_io_ops *ops,
 				    void *priv);
-- 
2.17.1


  parent reply	other threads:[~2020-04-30 18:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-30 18:49 [PATCH net-next 0/4] net: dsa: b53: ARL improvements Florian Fainelli
2020-04-30 18:49 ` [PATCH net-next 1/4] net: dsa: b53: Rename num_arl_entries to num_arl_bins Florian Fainelli
2020-04-30 19:19   ` Andrew Lunn
2020-04-30 18:49 ` [PATCH net-next 2/4] net: dsa: b53: Provide number of ARL buckets Florian Fainelli
2020-04-30 19:20   ` Andrew Lunn
2020-04-30 18:49 ` Florian Fainelli [this message]
2020-04-30 19:23   ` [PATCH net-next 3/4] net: dsa: b53: Bound check ARL searches Andrew Lunn
2020-04-30 18:49 ` [PATCH net-next 4/4] net: dsa: b53: Remove is_static argument to b53_read_op() Florian Fainelli
2020-04-30 19:25   ` Andrew Lunn
2020-05-01  0:43 ` [PATCH net-next 0/4] net: dsa: b53: ARL improvements David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200430184911.29660-4-f.fainelli@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).