diff options
author | Michael Brown | 2009-08-12 00:40:27 +0200 |
---|---|---|
committer | Michael Brown | 2009-08-12 01:23:38 +0200 |
commit | 4eab5bc8ca6b66dc965cf188dd4577ad19c5b879 (patch) | |
tree | 840f354a2f0efa010368118729e8f16315abc1c4 /src/drivers/net/ipoib.c | |
parent | [netdevice] Separate out the concept of hardware and link-layer addresses (diff) | |
download | ipxe-4eab5bc8ca6b66dc965cf188dd4577ad19c5b879.tar.gz ipxe-4eab5bc8ca6b66dc965cf188dd4577ad19c5b879.tar.xz ipxe-4eab5bc8ca6b66dc965cf188dd4577ad19c5b879.zip |
[netdevice] Allow the hardware and link-layer addresses to differ in size
IPoIB has a 20-byte link-layer address, of which only eight bytes
represent anything relating to a "hardware address".
The PXE and EFI SNP APIs expect the permanent address to be the same
size as the link-layer address, so fill in the "permanent address"
field with the initial link layer address (as generated by
register_netdev() based upon the real hardware address).
Diffstat (limited to 'src/drivers/net/ipoib.c')
-rw-r--r-- | src/drivers/net/ipoib.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/drivers/net/ipoib.c b/src/drivers/net/ipoib.c index c2a6d349..dde4ee5a 100644 --- a/src/drivers/net/ipoib.c +++ b/src/drivers/net/ipoib.c @@ -250,7 +250,21 @@ static int ipoib_pull ( struct net_device *netdev, } /** - * Transcribe IPoIB address + * Initialise IPoIB link-layer address + * + * @v hw_addr Hardware address + * @v ll_addr Link-layer address + */ +static void ipoib_init_addr ( const void *hw_addr, void *ll_addr ) { + const struct ib_gid_half *guid = hw_addr; + struct ipoib_mac *mac = ll_addr; + + memset ( mac, 0, sizeof ( *mac ) ); + memcpy ( &mac->gid.u.half[1], guid, sizeof ( mac->gid.u.half[1] ) ); +} + +/** + * Transcribe IPoIB link-layer address * * @v ll_addr Link-layer address * @ret string Link-layer address in human-readable format @@ -286,10 +300,12 @@ static int ipoib_mc_hash ( unsigned int af __unused, struct ll_protocol ipoib_protocol __ll_protocol = { .name = "IPoIB", .ll_proto = htons ( ARPHRD_INFINIBAND ), + .hw_addr_len = sizeof ( struct ib_gid_half ), .ll_addr_len = IPOIB_ALEN, .ll_header_len = IPOIB_HLEN, .push = ipoib_push, .pull = ipoib_pull, + .init_addr = ipoib_init_addr, .ntoa = ipoib_ntoa, .mc_hash = ipoib_mc_hash, }; @@ -653,7 +669,6 @@ void ipoib_link_state_changed ( struct ib_device *ibdev ) { int ipoib_probe ( struct ib_device *ibdev ) { struct net_device *netdev; struct ipoib_device *ipoib; - struct ipoib_mac *mac; int rc; /* Allocate network device */ @@ -669,9 +684,8 @@ int ipoib_probe ( struct ib_device *ibdev ) { ipoib->ibdev = ibdev; /* Extract hardware address */ - mac = ( ( struct ipoib_mac * ) netdev->hw_addr ); - memcpy ( &mac->gid.u.half[1], &ibdev->gid.u.half[1], - sizeof ( mac->gid.u.half[1] ) ); + memcpy ( netdev->hw_addr, &ibdev->gid.u.half[1], + sizeof ( ibdev->gid.u.half[1] ) ); /* Set default broadcast address */ memcpy ( &ipoib->broadcast, &ipoib_broadcast, |