{net,IB}/{rxe,usnic}: Utilize generic mac to eui32 function
This logic seems to be duplicated in (at least) three separate files. Move it to one place so code can be re-use. Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com> Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
This commit is contained in:
committed by
Doug Ledford
parent
a7c81326ca
commit
4d6f28591f
@@ -103,12 +103,24 @@ int addrconf_prefix_rcv_add_addr(struct net *net, struct net_device *dev,
|
||||
u32 addr_flags, bool sllao, bool tokenized,
|
||||
__u32 valid_lft, u32 prefered_lft);
|
||||
|
||||
static inline void addrconf_addr_eui48_base(u8 *eui, const char *const addr)
|
||||
{
|
||||
memcpy(eui, addr, 3);
|
||||
eui[3] = 0xFF;
|
||||
eui[4] = 0xFE;
|
||||
memcpy(eui + 5, addr + 3, 3);
|
||||
}
|
||||
|
||||
static inline void addrconf_addr_eui48(u8 *eui, const char *const addr)
|
||||
{
|
||||
addrconf_addr_eui48_base(eui, addr);
|
||||
eui[0] ^= 2;
|
||||
}
|
||||
|
||||
static inline int addrconf_ifid_eui48(u8 *eui, struct net_device *dev)
|
||||
{
|
||||
if (dev->addr_len != ETH_ALEN)
|
||||
return -1;
|
||||
memcpy(eui, dev->dev_addr, 3);
|
||||
memcpy(eui + 5, dev->dev_addr + 3, 3);
|
||||
|
||||
/*
|
||||
* The zSeries OSA network cards can be shared among various
|
||||
@@ -123,14 +135,16 @@ static inline int addrconf_ifid_eui48(u8 *eui, struct net_device *dev)
|
||||
* case. Hence the resulting interface identifier has local
|
||||
* scope according to RFC2373.
|
||||
*/
|
||||
|
||||
addrconf_addr_eui48_base(eui, dev->dev_addr);
|
||||
|
||||
if (dev->dev_id) {
|
||||
eui[3] = (dev->dev_id >> 8) & 0xFF;
|
||||
eui[4] = dev->dev_id & 0xFF;
|
||||
} else {
|
||||
eui[3] = 0xFF;
|
||||
eui[4] = 0xFE;
|
||||
eui[0] ^= 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user