summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brown2009-07-17 23:48:31 +0200
committerMichael Brown2009-07-18 00:02:48 +0200
commitd09290161e33574d8f0fa900ebe739214d17fe1a (patch)
tree9cb59387262344ed50fc755362154206017ab220
parent[ata] Make ATA command issuing partially asynchronous (diff)
downloadipxe-d09290161e33574d8f0fa900ebe739214d17fe1a.tar.gz
ipxe-d09290161e33574d8f0fa900ebe739214d17fe1a.tar.xz
ipxe-d09290161e33574d8f0fa900ebe739214d17fe1a.zip
[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.
-rw-r--r--src/arch/i386/interface/pxe/pxe_undi.c2
-rw-r--r--src/drivers/net/ipoib.c19
-rw-r--r--src/drivers/net/legacy.c2
-rw-r--r--src/drivers/net/phantom/phantom.c8
-rw-r--r--src/include/gpxe/ethernet.h22
-rw-r--r--src/include/gpxe/ipoib.h21
-rw-r--r--src/include/gpxe/netdevice.h4
-rw-r--r--src/interface/efi/efi_snp.c3
-rw-r--r--src/net/aoe.c3
-rw-r--r--src/net/arp.c2
-rw-r--r--src/net/ethernet.c19
-rw-r--r--src/net/ipv4.c2
12 files changed, 49 insertions, 58 deletions
diff --git a/src/arch/i386/interface/pxe/pxe_undi.c b/src/arch/i386/interface/pxe/pxe_undi.c
index bd387ea5..4dcae44e 100644
--- a/src/arch/i386/interface/pxe/pxe_undi.c
+++ b/src/arch/i386/interface/pxe/pxe_undi.c
@@ -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" );
}
diff --git a/src/drivers/net/ipoib.c b/src/drivers/net/ipoib.c
index bb8757b4..d330d5a5 100644
--- a/src/drivers/net/ipoib.c
+++ b/src/drivers/net/ipoib.c
@@ -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;
+}
diff --git a/src/drivers/net/legacy.c b/src/drivers/net/legacy.c
index 4977076c..c4bfc96a 100644
--- a/src/drivers/net/legacy.c
+++ b/src/drivers/net/legacy.c
@@ -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;
diff --git a/src/drivers/net/phantom/phantom.c b/src/drivers/net/phantom/phantom.c
index ad17cdfe..85949c29 100644
--- a/src/drivers/net/phantom/phantom.c
+++ b/src/drivers/net/phantom/phantom.c
@@ -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) ) );
diff --git a/src/include/gpxe/ethernet.h b/src/include/gpxe/ethernet.h
index 45ab9a09..9bd3455c 100644
--- a/src/include/gpxe/ethernet.h
+++ b/src/include/gpxe/ethernet.h
@@ -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 */
diff --git a/src/include/gpxe/ipoib.h b/src/include/gpxe/ipoib.h
index 5db23847..79d7b3fb 100644
--- a/src/include/gpxe/ipoib.h
+++ b/src/include/gpxe/ipoib.h
@@ -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 */
diff --git a/src/include/gpxe/netdevice.h b/src/include/gpxe/netdevice.h
index 70644af1..0f191dd6 100644
--- a/src/include/gpxe/netdevice.h
+++ b/src/include/gpxe/netdevice.h
@@ -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
*
diff --git a/src/interface/efi/efi_snp.c b/src/interface/efi/efi_snp.c
index 4bdb7806..f96984fa 100644
--- a/src/interface/efi/efi_snp.c
+++ b/src/interface/efi/efi_snp.c
@@ -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;
diff --git a/src/net/aoe.c b/src/net/aoe.c
index f274ddf5..839a875b 100644
--- a/src/net/aoe.c
+++ b/src/net/aoe.c
@@ -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;
diff --git a/src/net/arp.c b/src/net/arp.c
index 8bc83958..124a856e 100644
--- a/src/net/arp.c
+++ b/src/net/arp.c
@@ -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;
diff --git a/src/net/ethernet.c b/src/net/ethernet.c
index 6c5f7879..5e2793f9 100644
--- a/src/net/ethernet.c
+++ b/src/net/ethernet.c
@@ -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;
+}
diff --git a/src/net/ipv4.c b/src/net/ipv4.c
index 79fa9ea6..64d294e5 100644
--- a/src/net/ipv4.c
+++ b/src/net/ipv4.c
@@ -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 ) ) ) {