From: Simon Horman <simon.horman@corigine.com>
To: Daniel Machon <daniel.machon@microchip.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, lars.povlsen@microchip.com,
Steen.Hegelund@microchip.com, UNGLinuxDriver@microchip.com,
joe@perches.com, richardcochran@gmail.com,
casper.casan@gmail.com, horatiu.vultur@microchip.com,
shangxiaojing@huawei.com, rmk+kernel@armlinux.org.uk,
nhuck@google.com, error27@gmail.com,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH net-next 03/10] net: microchip: sparx5: add support for Service Dual Leacky Buckets
Date: Sat, 4 Feb 2023 13:53:24 +0100 [thread overview]
Message-ID: <Y95VRJWV4NfSDYUR@corigine.com> (raw)
In-Reply-To: <20230202104355.1612823-4-daniel.machon@microchip.com>
On Thu, Feb 02, 2023 at 11:43:48AM +0100, Daniel Machon wrote:
> Add support for Service Dual Leacky Buckets (SDLB), used to implement
> PSFP flow-meters. Buckets are linked together in a leak chain of a leak
> group. Leak groups a preconfigured to serve buckets within a certain
> rate interval.
>
> Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
...
> diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_sdlb.c b/drivers/net/ethernet/microchip/sparx5/sparx5_sdlb.c
> new file mode 100644
> index 000000000000..f5267218caeb
> --- /dev/null
> +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_sdlb.c
...
> +static u32 sparx5_sdlb_group_get_next(struct sparx5 *sparx5, u32 group,
> + u32 lb)
> +{
> + u32 val;
> +
> + val = spx5_rd(sparx5, ANA_AC_SDLB_XLB_NEXT(lb));
> +
> + return ANA_AC_SDLB_XLB_NEXT_LBSET_NEXT_GET(val);
> +}
...
> +static u32 sparx5_sdlb_group_get_last(struct sparx5 *sparx5, u32 group)
> +{
> + u32 itr, next;
> +
> + itr = sparx5_sdlb_group_get_first(sparx5, group);
> +
> + for (;;) {
Unbounded loops like this give me some apprehension.
Will they always terminate?
> + next = sparx5_sdlb_group_get_next(sparx5, group, itr);
> + if (itr == next)
> + return itr;
> +
> + itr = next;
> + }
> +}
...
> +static int sparx5_sdlb_group_get_adjacent(struct sparx5 *sparx5, u32 group,
> + u32 idx, u32 *prev, u32 *next,
> + u32 *first)
> +{
> + u32 itr;
> +
> + *first = sparx5_sdlb_group_get_first(sparx5, group);
> + *prev = *first;
> + *next = *first;
> + itr = *first;
> +
> + for (;;) {
> + *next = sparx5_sdlb_group_get_next(sparx5, group, itr);
> +
> + if (itr == idx)
> + return 0; /* Found it */
> +
> + if (itr == *next)
> + return -EINVAL; /* Was not found */
> +
> + *prev = itr;
> + itr = *next;
> + }
> +}
> +
> +static int sparx5_sdlb_group_get_count(struct sparx5 *sparx5, u32 group)
> +{
> + u32 itr, next;
> + int count = 0;
> +
> + itr = sparx5_sdlb_group_get_first(sparx5, group);
> +
> + for (;;) {
> + next = sparx5_sdlb_group_get_next(sparx5, group, itr);
> + if (itr == next)
> + return count;
> +
> + itr = next;
> + count++;
> + }
> +}
...
> +int sparx5_sdlb_group_get_by_index(struct sparx5 *sparx5, u32 idx, u32 *group)
> +{
> + u32 itr, next;
> + int i;
> +
> + for (i = 0; i < SPX5_SDLB_GROUP_CNT; i++) {
> + if (sparx5_sdlb_group_is_empty(sparx5, i))
> + continue;
> +
> + itr = sparx5_sdlb_group_get_first(sparx5, i);
> +
> + for (;;) {
> + next = sparx5_sdlb_group_get_next(sparx5, i, itr);
> +
> + if (itr == idx) {
> + *group = i;
> + return 0; /* Found it */
> + }
> + if (itr == next)
> + break; /* Was not found */
> +
> + itr = next;
> + }
> + }
> +
> + return -EINVAL;
> +}
...
next prev parent reply other threads:[~2023-02-04 12:53 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-02 10:43 [PATCH net-next 00/10] Add support for PSFP in Sparx5 Daniel Machon
2023-02-02 10:43 ` [PATCH net-next 01/10] net: microchip: add registers needed for PSFP Daniel Machon
2023-02-04 12:47 ` Simon Horman
2023-02-02 10:43 ` [PATCH net-next 02/10] net: microchip: sparx5: add resource pools Daniel Machon
2023-02-04 12:47 ` Simon Horman
2023-02-02 10:43 ` [PATCH net-next 03/10] net: microchip: sparx5: add support for Service Dual Leacky Buckets Daniel Machon
2023-02-04 12:53 ` Simon Horman [this message]
2023-02-05 20:11 ` Daniel.Machon
2023-02-06 10:18 ` Simon Horman
2023-02-02 10:43 ` [PATCH net-next 04/10] net: microchip: sparx5: add support for service policers Daniel Machon
2023-02-04 12:53 ` Simon Horman
2023-02-02 10:43 ` [PATCH net-next 05/10] net: microchip: sparx5: add support for PSFP flow-meters Daniel Machon
2023-02-04 12:54 ` Simon Horman
2023-02-02 10:43 ` [PATCH net-next 06/10] net: microchip: sparx5: add function for calculating PTP basetime Daniel Machon
2023-02-04 12:55 ` Simon Horman
2023-02-02 10:43 ` [PATCH net-next 07/10] net: microchip: sparx5: add support for PSFP stream gates Daniel Machon
2023-02-04 12:56 ` Simon Horman
2023-02-02 10:43 ` [PATCH net-next 08/10] net: microchip: sparx5: add support for PSFP stream filters Daniel Machon
2023-02-04 12:56 ` Simon Horman
2023-02-02 10:43 ` [PATCH net-next 09/10] net: microchip: sparx5: initialize PSFP Daniel Machon
2023-02-04 12:46 ` Simon Horman
2023-02-02 10:43 ` [PATCH net-next 10/10] sparx5: add support for configuring PSFP via tc Daniel Machon
2023-02-04 12:57 ` Simon Horman
2023-02-06 8:50 ` [PATCH net-next 00/10] Add support for PSFP in Sparx5 patchwork-bot+netdevbpf
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=Y95VRJWV4NfSDYUR@corigine.com \
--to=simon.horman@corigine.com \
--cc=Steen.Hegelund@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=casper.casan@gmail.com \
--cc=daniel.machon@microchip.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=error27@gmail.com \
--cc=horatiu.vultur@microchip.com \
--cc=joe@perches.com \
--cc=kuba@kernel.org \
--cc=lars.povlsen@microchip.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nhuck@google.com \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=rmk+kernel@armlinux.org.uk \
--cc=shangxiaojing@huawei.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).