Bladeren bron

[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.
tags/v0.9.8
Michael Brown 15 jaren geleden
bovenliggende
commit
d09290161e

+ 1
- 1
src/arch/i386/interface/pxe/pxe_undi.c Bestand weergeven

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

+ 18
- 1
src/drivers/net/ipoib.c Bestand weergeven

@@ -348,7 +348,6 @@ struct ll_protocol ipoib_protocol __ll_protocol = {
348 348
 	.ll_proto	= htons ( ARPHRD_INFINIBAND ),
349 349
 	.ll_addr_len	= IPOIB_ALEN,
350 350
 	.ll_header_len	= IPOIB_HLEN,
351
-	.ll_broadcast	= ( uint8_t * ) &ipoib_broadcast,
352 351
 	.push		= ipoib_push,
353 352
 	.pull		= ipoib_pull,
354 353
 	.ntoa		= ipoib_ntoa,
@@ -1132,3 +1131,21 @@ void ipoib_remove ( struct ib_device *ibdev ) {
1132 1131
 	netdev_nullify ( netdev );
1133 1132
 	netdev_put ( netdev );
1134 1133
 }
1134
+
1135
+/**
1136
+ * Allocate IPoIB device
1137
+ *
1138
+ * @v priv_size		Size of driver private data
1139
+ * @ret netdev		Network device, or NULL
1140
+ */
1141
+struct net_device * alloc_ipoibdev ( size_t priv_size ) {
1142
+	struct net_device *netdev;
1143
+
1144
+	netdev = alloc_netdev ( priv_size );
1145
+	if ( netdev ) {
1146
+		netdev->ll_protocol = &ipoib_protocol;
1147
+		netdev->ll_broadcast = ( uint8_t * ) &ipoib_broadcast;
1148
+		netdev->max_pkt_len = IPOIB_PKT_LEN;
1149
+	}
1150
+	return netdev;
1151
+}

+ 1
- 1
src/drivers/net/legacy.c Bestand weergeven

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

+ 3
- 5
src/drivers/net/phantom/phantom.c Bestand weergeven

@@ -1156,7 +1156,7 @@ static int phantom_open ( struct net_device *netdev ) {
1156 1156
 	 * firmware doesn't currently support this.
1157 1157
 	 */
1158 1158
 	if ( ( rc = phantom_add_macaddr ( phantom,
1159
-				   netdev->ll_protocol->ll_broadcast ) ) != 0 )
1159
+					  netdev->ll_broadcast ) ) != 0 )
1160 1160
 		goto err_add_macaddr_broadcast;
1161 1161
 	if ( ( rc = phantom_add_macaddr ( phantom,
1162 1162
 					  netdev->ll_addr ) ) != 0 )
@@ -1166,8 +1166,7 @@ static int phantom_open ( struct net_device *netdev ) {
1166 1166
 
1167 1167
 	phantom_del_macaddr ( phantom, netdev->ll_addr );
1168 1168
  err_add_macaddr_unicast:
1169
-	phantom_del_macaddr ( phantom,
1170
-			      netdev->ll_protocol->ll_broadcast );
1169
+	phantom_del_macaddr ( phantom, netdev->ll_broadcast );
1171 1170
  err_add_macaddr_broadcast:
1172 1171
 	phantom_destroy_tx_ctx ( phantom );
1173 1172
  err_create_tx_ctx:
@@ -1191,8 +1190,7 @@ static void phantom_close ( struct net_device *netdev ) {
1191 1190
 
1192 1191
 	/* Shut down the port */
1193 1192
 	phantom_del_macaddr ( phantom, netdev->ll_addr );
1194
-	phantom_del_macaddr ( phantom,
1195
-			      netdev->ll_protocol->ll_broadcast );
1193
+	phantom_del_macaddr ( phantom, netdev->ll_broadcast );
1196 1194
 	phantom_destroy_tx_ctx ( phantom );
1197 1195
 	phantom_destroy_rx_ctx ( phantom );
1198 1196
 	free_dma ( phantom->desc, sizeof ( *(phantom->desc) ) );

+ 1
- 21
src/include/gpxe/ethernet.h Bestand weergeven

@@ -10,28 +10,8 @@
10 10
 FILE_LICENCE ( GPL2_OR_LATER );
11 11
 
12 12
 #include <stdint.h>
13
-#include <gpxe/netdevice.h>
14
-#include <gpxe/if_ether.h>
15
-
16
-extern struct ll_protocol ethernet_protocol;
17 13
 
18 14
 extern const char * eth_ntoa ( const void *ll_addr );
19
-
20
-/**
21
- * Allocate Ethernet device
22
- *
23
- * @v priv_size		Size of driver private data
24
- * @ret netdev		Network device, or NULL
25
- */
26
-static inline struct net_device * alloc_etherdev ( size_t priv_size ) {
27
-	struct net_device *netdev;
28
-
29
-	netdev = alloc_netdev ( priv_size );
30
-	if ( netdev ) {
31
-		netdev->ll_protocol = &ethernet_protocol;
32
-		netdev->max_pkt_len = ETH_FRAME_LEN;
33
-	}
34
-	return netdev;
35
-}
15
+extern struct net_device * alloc_etherdev ( size_t priv_size );
36 16
 
37 17
 #endif /* _GPXE_ETHERNET_H */

+ 1
- 20
src/include/gpxe/ipoib.h Bestand weergeven

@@ -54,29 +54,10 @@ struct ipoib_hdr {
54 54
 	} __attribute__ (( packed )) u;
55 55
 } __attribute__ (( packed ));
56 56
 
57
-extern struct ll_protocol ipoib_protocol;
58
-
59 57
 extern const char * ipoib_ntoa ( const void *ll_addr );
60
-
61
-/**
62
- * Allocate IPoIB device
63
- *
64
- * @v priv_size		Size of driver private data
65
- * @ret netdev		Network device, or NULL
66
- */
67
-static inline struct net_device * alloc_ipoibdev ( size_t priv_size ) {
68
-	struct net_device *netdev;
69
-
70
-	netdev = alloc_netdev ( priv_size );
71
-	if ( netdev ) {
72
-		netdev->ll_protocol = &ipoib_protocol;
73
-		netdev->max_pkt_len = IPOIB_PKT_LEN;
74
-	}
75
-	return netdev;
76
-}
77
-
78 58
 extern void ipoib_link_state_changed ( struct ib_device *ibdev );
79 59
 extern int ipoib_probe ( struct ib_device *ibdev );
80 60
 extern void ipoib_remove ( struct ib_device *ibdev );
61
+extern struct net_device * alloc_ipoibdev ( size_t priv_size );
81 62
 
82 63
 #endif /* _GPXE_IPOIB_H */

+ 2
- 2
src/include/gpxe/netdevice.h Bestand weergeven

@@ -144,8 +144,6 @@ struct ll_protocol {
144 144
 	uint8_t ll_addr_len;
145 145
 	/** Link-layer header length */
146 146
 	uint8_t ll_header_len;
147
-	/** Link-layer broadcast address */
148
-	const uint8_t *ll_broadcast;
149 147
 };
150 148
 
151 149
 /** Network device operations */
@@ -261,6 +259,8 @@ struct net_device {
261 259
 	 * For Ethernet, this is the MAC address.
262 260
 	 */
263 261
 	uint8_t ll_addr[MAX_LL_ADDR_LEN];
262
+	/** Link-layer broadcast address */
263
+	const uint8_t *ll_broadcast;
264 264
 
265 265
 	/** Current device state
266 266
 	 *

+ 1
- 2
src/interface/efi/efi_snp.c Bestand weergeven

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

+ 1
- 2
src/net/aoe.c Bestand weergeven

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

+ 1
- 1
src/net/arp.c Bestand weergeven

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

+ 18
- 1
src/net/ethernet.c Bestand weergeven

@@ -145,9 +145,26 @@ struct ll_protocol ethernet_protocol __ll_protocol = {
145 145
 	.ll_proto	= htons ( ARPHRD_ETHER ),
146 146
 	.ll_addr_len	= ETH_ALEN,
147 147
 	.ll_header_len	= ETH_HLEN,
148
-	.ll_broadcast	= eth_broadcast,
149 148
 	.push		= eth_push,
150 149
 	.pull		= eth_pull,
151 150
 	.ntoa		= eth_ntoa,
152 151
 	.mc_hash	= eth_mc_hash,
153 152
 };
153
+
154
+/**
155
+ * Allocate Ethernet device
156
+ *
157
+ * @v priv_size		Size of driver private data
158
+ * @ret netdev		Network device, or NULL
159
+ */
160
+struct net_device * alloc_etherdev ( size_t priv_size ) {
161
+	struct net_device *netdev;
162
+
163
+	netdev = alloc_netdev ( priv_size );
164
+	if ( netdev ) {
165
+		netdev->ll_protocol = &ethernet_protocol;
166
+		netdev->ll_broadcast = eth_broadcast;
167
+		netdev->max_pkt_len = ETH_FRAME_LEN;
168
+	}
169
+	return netdev;
170
+}

+ 1
- 1
src/net/ipv4.c Bestand weergeven

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

Laden…
Annuleren
Opslaan