All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Jijie Shao <shaojijie@huawei.com>
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, andrew+netdev@lunn.ch, shenjian15@huawei.com,
	wangpeiyang1@huawei.com, liuyonglong@huawei.com,
	chenhao418@huawei.com, sudongming1@huawei.com,
	xujunsheng@huawei.com, shiyongbang@huawei.com,
	libaihan@huawei.com, jonathan.cameron@huawei.com,
	shameerali.kolothum.thodi@huawei.com, salil.mehta@huawei.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH V3 net-next 3/7] net: hibmcge: Add unicast frame filter supported in this module
Date: Wed, 13 Nov 2024 13:33:01 +0000	[thread overview]
Message-ID: <20241113133301.GZ4507@kernel.org> (raw)
In-Reply-To: <20241111145558.1965325-4-shaojijie@huawei.com>

On Mon, Nov 11, 2024 at 10:55:54PM +0800, Jijie Shao wrote:
> MAC supports filtering unmatched unicast packets according to
> the MAC address table. This patch adds the support for
> unicast frame filtering.
> 
> To support automatic restoration of MAC entries
> after reset, the driver saves a copy of MAC entries in the driver.
> 
> Signed-off-by: Jijie Shao <shaojijie@huawei.com>

...

> diff --git a/drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c b/drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c

...

>  static int hbg_net_set_mac_address(struct net_device *netdev, void *addr)
>  {
>  	struct hbg_priv *priv = netdev_priv(netdev);
>  	u8 *mac_addr;
> +	bool is_exists;
> +	u32 index;

nit: If you have to respin for some other reason,
     please arrange these local variables in reverse
     xmas tree order - longest line to shortest.

     Also, from an English language PoV, is_exists is a bit tautological.
     Not that it really matters, but maybe addr_exists would work?

>  
>  	mac_addr = ((struct sockaddr *)addr)->sa_data;
>  
>  	if (!is_valid_ether_addr(mac_addr))
>  		return -EADDRNOTAVAIL;
>  
> -	hbg_hw_set_uc_addr(priv, ether_addr_to_u64(mac_addr));
> -	dev_addr_set(netdev, mac_addr);
> +	/* The index of host mac is always 0.
> +	 * If new mac address already exists,
> +	 * delete the existing mac address and
> +	 * add it to the position with index 0.
> +	 */
> +	is_exists = !hbg_get_index_from_mac_table(priv, mac_addr, &index);
> +	hbg_set_mac_to_mac_table(priv, 0, mac_addr);
> +	if (is_exists)
> +		hbg_set_mac_to_mac_table(priv, index, NULL);
>  
> +	dev_addr_set(netdev, mac_addr);
>  	return 0;
>  }
>  

...

  reply	other threads:[~2024-11-13 13:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-11 14:55 [PATCH V3 net-next 0/7] Support some features for the HIBMCGE driver Jijie Shao
2024-11-11 14:55 ` [PATCH V3 net-next 1/7] net: hibmcge: Add debugfs supported in this module Jijie Shao
2024-11-11 14:55 ` [PATCH V3 net-next 2/7] net: hibmcge: Add irq_info file to debugfs Jijie Shao
2024-11-11 14:55 ` [PATCH V3 net-next 3/7] net: hibmcge: Add unicast frame filter supported in this module Jijie Shao
2024-11-13 13:33   ` Simon Horman [this message]
2024-11-11 14:55 ` [PATCH V3 net-next 4/7] net: hibmcge: Add register dump " Jijie Shao
2024-11-11 14:55 ` [PATCH V3 net-next 5/7] net: hibmcge: Add pauseparam " Jijie Shao
2024-11-11 17:58   ` Andrew Lunn
2024-11-12 14:37     ` Jijie Shao
2024-11-12 16:32       ` Andrew Lunn
2024-11-13  3:20         ` Jijie Shao
2024-11-13 20:41           ` Andrew Lunn
2024-11-11 14:55 ` [PATCH V3 net-next 6/7] net: hibmcge: Add reset " Jijie Shao
2024-11-11 14:55 ` [PATCH V3 net-next 7/7] net: hibmcge: Add nway_reset " Jijie Shao

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=20241113133301.GZ4507@kernel.org \
    --to=horms@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=chenhao418@huawei.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=kuba@kernel.org \
    --cc=libaihan@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liuyonglong@huawei.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=salil.mehta@huawei.com \
    --cc=shameerali.kolothum.thodi@huawei.com \
    --cc=shaojijie@huawei.com \
    --cc=shenjian15@huawei.com \
    --cc=shiyongbang@huawei.com \
    --cc=sudongming1@huawei.com \
    --cc=wangpeiyang1@huawei.com \
    --cc=xujunsheng@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 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.