Commit b77049f0 authored by Li Zetao's avatar Li Zetao Committed by Jakub Kicinski

ethernet: s2io: Use ether_addr_to_u64() to convert ethernet address

Use ether_addr_to_u64() to convert an Ethernet address into a u64 value,
instead of directly calculating, as this is exactly what
this function does.
Signed-off-by: default avatarLi Zetao <lizetao1@huawei.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/20230808113849.4033657-1-lizetao1@huawei.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 052059b6
...@@ -5091,13 +5091,10 @@ static void do_s2io_restore_unicast_mc(struct s2io_nic *sp) ...@@ -5091,13 +5091,10 @@ static void do_s2io_restore_unicast_mc(struct s2io_nic *sp)
static int do_s2io_add_mc(struct s2io_nic *sp, u8 *addr) static int do_s2io_add_mc(struct s2io_nic *sp, u8 *addr)
{ {
int i; int i;
u64 mac_addr = 0; u64 mac_addr;
struct config_param *config = &sp->config; struct config_param *config = &sp->config;
for (i = 0; i < ETH_ALEN; i++) { mac_addr = ether_addr_to_u64(addr);
mac_addr <<= 8;
mac_addr |= addr[i];
}
if ((0ULL == mac_addr) || (mac_addr == S2IO_DISABLE_MAC_ENTRY)) if ((0ULL == mac_addr) || (mac_addr == S2IO_DISABLE_MAC_ENTRY))
return SUCCESS; return SUCCESS;
...@@ -5220,7 +5217,7 @@ static int s2io_set_mac_addr(struct net_device *dev, void *p) ...@@ -5220,7 +5217,7 @@ static int s2io_set_mac_addr(struct net_device *dev, void *p)
static int do_s2io_prog_unicast(struct net_device *dev, const u8 *addr) static int do_s2io_prog_unicast(struct net_device *dev, const u8 *addr)
{ {
struct s2io_nic *sp = netdev_priv(dev); struct s2io_nic *sp = netdev_priv(dev);
register u64 mac_addr = 0, perm_addr = 0; register u64 mac_addr, perm_addr;
int i; int i;
u64 tmp64; u64 tmp64;
struct config_param *config = &sp->config; struct config_param *config = &sp->config;
...@@ -5230,12 +5227,8 @@ static int do_s2io_prog_unicast(struct net_device *dev, const u8 *addr) ...@@ -5230,12 +5227,8 @@ static int do_s2io_prog_unicast(struct net_device *dev, const u8 *addr)
* change on the device address registered with the OS. It will be * change on the device address registered with the OS. It will be
* at offset 0. * at offset 0.
*/ */
for (i = 0; i < ETH_ALEN; i++) { mac_addr = ether_addr_to_u64(addr);
mac_addr <<= 8; perm_addr = ether_addr_to_u64(sp->def_mac_addr[0].mac_addr);
mac_addr |= addr[i];
perm_addr <<= 8;
perm_addr |= sp->def_mac_addr[0].mac_addr[i];
}
/* check if the dev_addr is different than perm_addr */ /* check if the dev_addr is different than perm_addr */
if (mac_addr == perm_addr) if (mac_addr == perm_addr)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment