[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).
This commit is contained in:
Michael Brown
2009-08-11 23:40:27 +01:00
parent 37a0aab4ff
commit 4eab5bc8ca
8 changed files with 66 additions and 17 deletions

View File

@@ -11,6 +11,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <stdint.h>
extern void eth_init_addr ( const void *hw_addr, void *ll_addr );
extern const char * eth_ntoa ( const void *ll_addr );
extern struct net_device * alloc_etherdev ( size_t priv_size );

View File

@@ -21,6 +21,12 @@ struct net_protocol;
struct ll_protocol;
struct device;
/** Maximum length of a hardware address
*
* The longest currently-supported link-layer address is for IPoIB.
*/
#define MAX_HW_ADDR_LEN 8
/** Maximum length of a link-layer address
*
* The longest currently-supported link-layer address is for IPoIB.
@@ -112,6 +118,13 @@ struct ll_protocol {
int ( * pull ) ( struct net_device *netdev, struct io_buffer *iobuf,
const void **ll_dest, const void **ll_source,
uint16_t *net_proto );
/**
* Initialise link-layer address
*
* @v hw_addr Hardware address
* @v ll_addr Link-layer address to fill in
*/
void ( * init_addr ) ( const void *hw_addr, void *ll_addr );
/**
* Transcribe link-layer address
*
@@ -124,7 +137,7 @@ struct ll_protocol {
* The buffer used to hold the transcription is statically
* allocated.
*/
const char * ( * ntoa ) ( const void * ll_addr );
const char * ( * ntoa ) ( const void *ll_addr );
/**
* Hash multicast address
*
@@ -140,6 +153,8 @@ struct ll_protocol {
* This is an ARPHRD_XXX constant, in network byte order.
*/
uint16_t ll_proto;
/** Hardware address length */
uint8_t hw_addr_len;
/** Link-layer address length */
uint8_t ll_addr_len;
/** Link-layer header length */
@@ -258,8 +273,11 @@ struct net_device {
*
* This is an address which is an intrinsic property of the
* hardware, e.g. an address held in EEPROM.
*
* Note that the hardware address may not be the same length
* as the link-layer address.
*/
uint8_t hw_addr[MAX_LL_ADDR_LEN];
uint8_t hw_addr[MAX_HW_ADDR_LEN];
/** Link-layer address
*
* This is the current link-layer address assigned to the