public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: Kurt Kanzenbach <kurt@kmk-computers.de>
Cc: Andrew Lunn <andrew@lunn.ch>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org
Subject: Re: [PATCH net-next v2 3/4] net: dsa: hellcreek: Move common code to helper
Date: Sat, 13 Mar 2021 13:44:48 +0200	[thread overview]
Message-ID: <20210313114448.xlkiesdhwwvnjv6y@skbuf> (raw)
In-Reply-To: <20210313093939.15179-4-kurt@kmk-computers.de>

On Sat, Mar 13, 2021 at 10:39:38AM +0100, Kurt Kanzenbach wrote:
> There are two functions which need to populate fdb entries. Move that to a
> helper function.
> 
> Signed-off-by: Kurt Kanzenbach <kurt@kmk-computers.de>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> ---
>  drivers/net/dsa/hirschmann/hellcreek.c | 85 +++++++++++++-------------
>  1 file changed, 43 insertions(+), 42 deletions(-)
> 
> diff --git a/drivers/net/dsa/hirschmann/hellcreek.c b/drivers/net/dsa/hirschmann/hellcreek.c
> index edac39462a07..38ff0f12e8a4 100644
> --- a/drivers/net/dsa/hirschmann/hellcreek.c
> +++ b/drivers/net/dsa/hirschmann/hellcreek.c
> @@ -670,6 +670,40 @@ static int __hellcreek_fdb_del(struct hellcreek *hellcreek,
>  	return hellcreek_wait_fdb_ready(hellcreek);
>  }
>  
> +static void hellcreek_populate_fdb_entry(struct hellcreek *hellcreek,
> +					 struct hellcreek_fdb_entry *entry,
> +					 size_t idx)
> +{
> +	unsigned char addr[ETH_ALEN];

You could have assigned:

	unsigned char *addr = entry->mac;

and avoided the memcpy, but it doesn't really matter much.

> +	u16 meta, mac;
> +
> +	/* Read values */
> +	meta	= hellcreek_read(hellcreek, HR_FDBMDRD);
> +	mac	= hellcreek_read(hellcreek, HR_FDBRDL);
> +	addr[5] = mac & 0xff;
> +	addr[4] = (mac & 0xff00) >> 8;
> +	mac	= hellcreek_read(hellcreek, HR_FDBRDM);
> +	addr[3] = mac & 0xff;
> +	addr[2] = (mac & 0xff00) >> 8;
> +	mac	= hellcreek_read(hellcreek, HR_FDBRDH);
> +	addr[1] = mac & 0xff;
> +	addr[0] = (mac & 0xff00) >> 8;
> +
> +	/* Populate @entry */
> +	memcpy(entry->mac, addr, sizeof(addr));
> +	entry->idx	    = idx;
> +	entry->portmask	    = (meta & HR_FDBMDRD_PORTMASK_MASK) >>
> +		HR_FDBMDRD_PORTMASK_SHIFT;
> +	entry->age	    = (meta & HR_FDBMDRD_AGE_MASK) >>
> +		HR_FDBMDRD_AGE_SHIFT;
> +	entry->is_obt	    = !!(meta & HR_FDBMDRD_OBT);
> +	entry->pass_blocked = !!(meta & HR_FDBMDRD_PASS_BLOCKED);
> +	entry->is_static    = !!(meta & HR_FDBMDRD_STATIC);
> +	entry->reprio_tc    = (meta & HR_FDBMDRD_REPRIO_TC_MASK) >>
> +		HR_FDBMDRD_REPRIO_TC_SHIFT;
> +	entry->reprio_en    = !!(meta & HR_FDBMDRD_REPRIO_EN);
> +}
> +

Reviewed-by: Vladimir Oltean <olteanv@gmail.com>

  reply	other threads:[~2021-03-13 11:45 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-13  9:39 [PATCH net-next v2 0/4] net: dsa: hellcreek: Add support for dumping tables Kurt Kanzenbach
2021-03-13  9:39 ` [PATCH net-next v2 1/4] net: dsa: hellcreek: Add devlink VLAN region Kurt Kanzenbach
2021-03-13 11:38   ` Vladimir Oltean
2021-03-14  1:40   ` Florian Fainelli
2021-03-13  9:39 ` [PATCH net-next v2 2/4] net: dsa: hellcreek: Use boolean value Kurt Kanzenbach
2021-03-13 11:39   ` Vladimir Oltean
2021-03-14  1:39   ` Florian Fainelli
2021-03-13  9:39 ` [PATCH net-next v2 3/4] net: dsa: hellcreek: Move common code to helper Kurt Kanzenbach
2021-03-13 11:44   ` Vladimir Oltean [this message]
2021-03-14  1:41   ` Florian Fainelli
2021-03-13  9:39 ` [PATCH net-next v2 4/4] net: dsa: hellcreek: Add devlink FDB region Kurt Kanzenbach
2021-03-13 11:46   ` Vladimir Oltean
2021-03-14 13:00     ` Kurt Kanzenbach
2021-03-20 11:31       ` Kurt Kanzenbach
2021-03-14  1:41   ` Florian Fainelli
2021-03-13 22:40 ` [PATCH net-next v2 0/4] net: dsa: hellcreek: Add support for dumping tables 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=20210313114448.xlkiesdhwwvnjv6y@skbuf \
    --to=olteanv@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=kurt@kmk-computers.de \
    --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