david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

[netdevice] Make ll_broadcast per-netdevice rather than per-ll_protocol

IPoIB has a link-layer broadcast address that varies according to the
partition key.  We currently go through several contortions to pretend
that the link-layer address is a fixed constant; by making the
broadcast address a property of the network device rather than the
link-layer protocol it will be possible to simplify IPoIB's broadcast
handling.
This commit is contained in:
Michael Brown 2009-07-17 22:48:31 +01:00
parent 54ec3673cc
commit d09290161e
12 changed files with 49 additions and 58 deletions

View File

@ -300,7 +300,7 @@ PXENV_EXIT_t pxenv_undi_transmit ( struct s_PXENV_UNDI_TRANSMIT
ll_dest = destaddr;
DBG2 ( " DEST %s", ll_protocol->ntoa ( ll_dest ) );
} else {
ll_dest = ll_protocol->ll_broadcast;
ll_dest = pxe_netdev->ll_broadcast;
DBG2 ( " BCAST" );
}

View File

@ -348,7 +348,6 @@ struct ll_protocol ipoib_protocol __ll_protocol = {
.ll_proto = htons ( ARPHRD_INFINIBAND ),
.ll_addr_len = IPOIB_ALEN,
.ll_header_len = IPOIB_HLEN,
.ll_broadcast = ( uint8_t * ) &ipoib_broadcast,
.push = ipoib_push,
.pull = ipoib_pull,
.ntoa = ipoib_ntoa,
@ -1132,3 +1131,21 @@ void ipoib_remove ( struct ib_device *ibdev ) {
netdev_nullify ( netdev );
netdev_put ( netdev );
}
/**
* Allocate IPoIB device
*
* @v priv_size Size of driver private data
* @ret netdev Network device, or NULL
*/
struct net_device * alloc_ipoibdev ( size_t priv_size ) {
struct net_device *netdev;
netdev = alloc_netdev ( priv_size );
if ( netdev ) {
netdev->ll_protocol = &ipoib_protocol;
netdev->ll_broadcast = ( uint8_t * ) &ipoib_broadcast;
netdev->max_pkt_len = IPOIB_PKT_LEN;
}
return netdev;
}

View File

@ -122,7 +122,7 @@ int legacy_probe ( void *hwdev,
/* Do not remove this message */
printf ( "WARNING: Using legacy NIC wrapper on %s\n",
ethernet_protocol.ntoa ( nic.node_addr ) );
netdev->ll_protocol->ntoa ( nic.node_addr ) );
legacy_registered = 1;
return 0;

View File

@ -1156,7 +1156,7 @@ static int phantom_open ( struct net_device *netdev ) {
* firmware doesn't currently support this.
*/
if ( ( rc = phantom_add_macaddr ( phantom,
netdev->ll_protocol->ll_broadcast ) ) != 0 )
netdev->ll_broadcast ) ) != 0 )
goto err_add_macaddr_broadcast;
if ( ( rc = phantom_add_macaddr ( phantom,
netdev->ll_addr ) ) != 0 )
@ -1166,8 +1166,7 @@ static int phantom_open ( struct net_device *netdev ) {
phantom_del_macaddr ( phantom, netdev->ll_addr );
err_add_macaddr_unicast:
phantom_del_macaddr ( phantom,
netdev->ll_protocol->ll_broadcast );
phantom_del_macaddr ( phantom, netdev->ll_broadcast );
err_add_macaddr_broadcast:
phantom_destroy_tx_ctx ( phantom );
err_create_tx_ctx:
@ -1191,8 +1190,7 @@ static void phantom_close ( struct net_device *netdev ) {
/* Shut down the port */
phantom_del_macaddr ( phantom, netdev->ll_addr );
phantom_del_macaddr ( phantom,
netdev->ll_protocol->ll_broadcast );
phantom_del_macaddr ( phantom, netdev->ll_broadcast );
phantom_destroy_tx_ctx ( phantom );
phantom_destroy_rx_ctx ( phantom );
free_dma ( phantom->desc, sizeof ( *(phantom->desc) ) );

View File

@ -10,28 +10,8 @@
FILE_LICENCE ( GPL2_OR_LATER );
#include <stdint.h>
#include <gpxe/netdevice.h>
#include <gpxe/if_ether.h>
extern struct ll_protocol ethernet_protocol;
extern const char * eth_ntoa ( const void *ll_addr );
/**
* Allocate Ethernet device
*
* @v priv_size Size of driver private data
* @ret netdev Network device, or NULL
*/
static inline struct net_device * alloc_etherdev ( size_t priv_size ) {
struct net_device *netdev;
netdev = alloc_netdev ( priv_size );
if ( netdev ) {
netdev->ll_protocol = &ethernet_protocol;
netdev->max_pkt_len = ETH_FRAME_LEN;
}
return netdev;
}
extern struct net_device * alloc_etherdev ( size_t priv_size );
#endif /* _GPXE_ETHERNET_H */

View File

@ -54,29 +54,10 @@ struct ipoib_hdr {
} __attribute__ (( packed )) u;
} __attribute__ (( packed ));
extern struct ll_protocol ipoib_protocol;
extern const char * ipoib_ntoa ( const void *ll_addr );
/**
* Allocate IPoIB device
*
* @v priv_size Size of driver private data
* @ret netdev Network device, or NULL
*/
static inline struct net_device * alloc_ipoibdev ( size_t priv_size ) {
struct net_device *netdev;
netdev = alloc_netdev ( priv_size );
if ( netdev ) {
netdev->ll_protocol = &ipoib_protocol;
netdev->max_pkt_len = IPOIB_PKT_LEN;
}
return netdev;
}
extern void ipoib_link_state_changed ( struct ib_device *ibdev );
extern int ipoib_probe ( struct ib_device *ibdev );
extern void ipoib_remove ( struct ib_device *ibdev );
extern struct net_device * alloc_ipoibdev ( size_t priv_size );
#endif /* _GPXE_IPOIB_H */

View File

@ -144,8 +144,6 @@ struct ll_protocol {
uint8_t ll_addr_len;
/** Link-layer header length */
uint8_t ll_header_len;
/** Link-layer broadcast address */
const uint8_t *ll_broadcast;
};
/** Network device operations */
@ -261,6 +259,8 @@ struct net_device {
* For Ethernet, this is the MAC address.
*/
uint8_t ll_addr[MAX_LL_ADDR_LEN];
/** Link-layer broadcast address */
const uint8_t *ll_broadcast;
/** Current device state
*

View File

@ -129,8 +129,7 @@ static void efi_snp_set_mode ( struct efi_snp_device *snpdev ) {
EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST );
assert ( ll_addr_len <= sizeof ( mode->CurrentAddress ) );
memcpy ( &mode->CurrentAddress, netdev->ll_addr, ll_addr_len );
memcpy ( &mode->BroadcastAddress, netdev->ll_protocol->ll_broadcast,
ll_addr_len );
memcpy ( &mode->BroadcastAddress, netdev->ll_broadcast, ll_addr_len );
memcpy ( &mode->PermanentAddress, netdev->ll_addr, ll_addr_len );
mode->IfType = ntohs ( netdev->ll_protocol->ll_proto );
mode->MacAddressChangeable = TRUE;

View File

@ -440,8 +440,7 @@ int aoe_attach ( struct ata_device *ata, struct net_device *netdev,
return -ENOMEM;
aoe->refcnt.free = aoe_free;
aoe->netdev = netdev_get ( netdev );
memcpy ( aoe->target, ethernet_protocol.ll_broadcast,
sizeof ( aoe->target ) );
memcpy ( aoe->target, netdev->ll_broadcast, sizeof ( aoe->target ) );
aoe->tag = AOE_TAG_MAGIC;
aoe->timer.expired = aoe_timer_expired;

View File

@ -156,7 +156,7 @@ int arp_resolve ( struct net_device *netdev, struct net_protocol *net_protocol,
/* Transmit ARP request */
if ( ( rc = net_tx ( iobuf, netdev, &arp_protocol,
ll_protocol->ll_broadcast ) ) != 0 )
netdev->ll_broadcast ) ) != 0 )
return rc;
return -ENOENT;

View File

@ -145,9 +145,26 @@ struct ll_protocol ethernet_protocol __ll_protocol = {
.ll_proto = htons ( ARPHRD_ETHER ),
.ll_addr_len = ETH_ALEN,
.ll_header_len = ETH_HLEN,
.ll_broadcast = eth_broadcast,
.push = eth_push,
.pull = eth_pull,
.ntoa = eth_ntoa,
.mc_hash = eth_mc_hash,
};
/**
* Allocate Ethernet device
*
* @v priv_size Size of driver private data
* @ret netdev Network device, or NULL
*/
struct net_device * alloc_etherdev ( size_t priv_size ) {
struct net_device *netdev;
netdev = alloc_netdev ( priv_size );
if ( netdev ) {
netdev->ll_protocol = &ethernet_protocol;
netdev->ll_broadcast = eth_broadcast;
netdev->max_pkt_len = ETH_FRAME_LEN;
}
return netdev;
}

View File

@ -271,7 +271,7 @@ static int ipv4_ll_addr ( struct in_addr dest, struct in_addr src,
if ( dest.s_addr == INADDR_BROADCAST ) {
/* Broadcast address */
memcpy ( ll_dest, ll_protocol->ll_broadcast,
memcpy ( ll_dest, netdev->ll_broadcast,
ll_protocol->ll_addr_len );
return 0;
} else if ( IN_MULTICAST ( ntohl ( dest.s_addr ) ) ) {