Переглянути джерело

[netdevice] Add netdev argument to link-layer push and pull handlers

In order to construct outgoing link-layer frames or parse incoming
ones properly, some protocols (such as 802.11) need more state than is
available in the existing variables passed to the link-layer protocol
handlers. To remedy this, add struct net_device *netdev as the first
argument to each of these functions, so that more information can be
fetched from the link layer-private part of the network device.

Updated all three call sites (netdevice.c, efi_snp.c, pxe_undi.c) and
both implementations (ethernet.c, ipoib.c) of ll_protocol to use the
new argument.

Signed-off-by: Michael Brown <mcb30@etherboot.org>
tags/v0.9.8
Joshua Oreman 15 роки тому
джерело
коміт
eb3ca2a36f

+ 3
- 3
src/arch/i386/interface/pxe/pxe_undi.c Переглянути файл

@@ -270,7 +270,7 @@ PXENV_EXIT_t pxenv_undi_transmit ( struct s_PXENV_UNDI_TRANSMIT
270 270
 		}
271 271
 
272 272
 		/* Add link-layer header */
273
-		if ( ( rc = ll_protocol->push ( iobuf, ll_dest,
273
+		if ( ( rc = ll_protocol->push ( pxe_netdev, iobuf, ll_dest,
274 274
 						pxe_netdev->ll_addr,
275 275
 						net_protocol->net_proto ))!=0){
276 276
 			free_iob ( iobuf );
@@ -630,8 +630,8 @@ PXENV_EXIT_t pxenv_undi_isr ( struct s_PXENV_UNDI_ISR *undi_isr ) {
630 630
 
631 631
 		/* Strip link-layer header */
632 632
 		ll_protocol = pxe_netdev->ll_protocol;
633
-		if ( ( rc = ll_protocol->pull ( iobuf, &ll_dest, &ll_source,
634
-						&net_proto ) ) != 0 ) {
633
+		if ( ( rc = ll_protocol->pull ( pxe_netdev, iobuf, &ll_dest,
634
+						&ll_source, &net_proto )) !=0){
635 635
 			/* Assume unknown net_proto and no ll_source */
636 636
 			net_proto = 0;
637 637
 			ll_source = NULL;

+ 6
- 2
src/drivers/net/ipoib.c Переглянути файл

@@ -238,13 +238,15 @@ ipoib_cache_peer ( const struct ib_gid *gid, unsigned long qpn ) {
238 238
 /**
239 239
  * Add IPoIB link-layer header
240 240
  *
241
+ * @v netdev		Network device
241 242
  * @v iobuf		I/O buffer
242 243
  * @v ll_dest		Link-layer destination address
243 244
  * @v ll_source		Source link-layer address
244 245
  * @v net_proto		Network-layer protocol, in network-byte order
245 246
  * @ret rc		Return status code
246 247
  */
247
-static int ipoib_push ( struct io_buffer *iobuf, const void *ll_dest,
248
+static int ipoib_push ( struct net_device *netdev __unused,
249
+			struct io_buffer *iobuf, const void *ll_dest,
248 250
 			const void *ll_source __unused, uint16_t net_proto ) {
249 251
 	struct ipoib_hdr *ipoib_hdr =
250 252
 		iob_push ( iobuf, sizeof ( *ipoib_hdr ) );
@@ -268,13 +270,15 @@ static int ipoib_push ( struct io_buffer *iobuf, const void *ll_dest,
268 270
 /**
269 271
  * Remove IPoIB link-layer header
270 272
  *
273
+ * @v netdev		Network device
271 274
  * @v iobuf		I/O buffer
272 275
  * @ret ll_dest		Link-layer destination address
273 276
  * @ret ll_source	Source link-layer address
274 277
  * @ret net_proto	Network-layer protocol, in network-byte order
275 278
  * @ret rc		Return status code
276 279
  */
277
-static int ipoib_pull ( struct io_buffer *iobuf, const void **ll_dest,
280
+static int ipoib_pull ( struct net_device *netdev __unused,
281
+			struct io_buffer *iobuf, const void **ll_dest,
278 282
 			const void **ll_source, uint16_t *net_proto ) {
279 283
 	struct ipoib_hdr *ipoib_hdr = iobuf->data;
280 284
 	struct ipoib_peer *dest;

+ 8
- 4
src/include/gpxe/netdevice.h Переглянути файл

@@ -88,25 +88,29 @@ struct ll_protocol {
88 88
 	/**
89 89
 	 * Add link-layer header
90 90
 	 *
91
+	 * @v netdev		Network device
91 92
 	 * @v iobuf		I/O buffer
92 93
 	 * @v ll_dest		Link-layer destination address
93 94
 	 * @v ll_source		Source link-layer address
94 95
 	 * @v net_proto		Network-layer protocol, in network-byte order
95 96
 	 * @ret rc		Return status code
96 97
 	 */
97
-	int ( * push ) ( struct io_buffer *iobuf, const void *ll_dest,
98
-			 const void *ll_source, uint16_t net_proto );
98
+	int ( * push ) ( struct net_device *netdev, struct io_buffer *iobuf,
99
+			 const void *ll_dest, const void *ll_source,
100
+			 uint16_t net_proto );
99 101
 	/**
100 102
 	 * Remove link-layer header
101 103
 	 *
104
+	 * @v netdev		Network device
102 105
 	 * @v iobuf		I/O buffer
103 106
 	 * @ret ll_dest		Link-layer destination address
104 107
 	 * @ret ll_source	Source link-layer address
105 108
 	 * @ret net_proto	Network-layer protocol, in network-byte order
106 109
 	 * @ret rc		Return status code
107 110
 	 */
108
-	int ( * pull ) ( struct io_buffer *iobuf, const void **ll_dest,
109
-			 const void **ll_source, uint16_t *net_proto );
111
+	int ( * pull ) ( struct net_device *netdev, struct io_buffer *iobuf,
112
+			 const void **ll_dest, const void **ll_source,
113
+			 uint16_t *net_proto );
110 114
 	/**
111 115
 	 * Transcribe link-layer address
112 116
 	 *

+ 4
- 3
src/interface/efi/efi_snp.c Переглянути файл

@@ -594,7 +594,8 @@ efi_snp_transmit ( EFI_SIMPLE_NETWORK_PROTOCOL *snp,
594 594
 	/* Create link-layer header, if specified */
595 595
 	if ( ll_header_len ) {
596 596
 		iob_pull ( iobuf, ll_header_len );
597
-		if ( ( rc = ll_protocol->push ( iobuf, ll_dest, ll_src,
597
+		if ( ( rc = ll_protocol->push ( snpdev->netdev,
598
+						iobuf, ll_dest, ll_src,
598 599
 						htons ( *net_proto ) )) != 0 ){
599 600
 			DBGC ( snpdev, "SNPDEV %p TX could not construct "
600 601
 			       "header: %s\n", snpdev, strerror ( rc ) );
@@ -672,8 +673,8 @@ efi_snp_receive ( EFI_SIMPLE_NETWORK_PROTOCOL *snp,
672 673
 	*len = iob_len ( iobuf );
673 674
 
674 675
 	/* Attempt to decode link-layer header */
675
-	if ( ( rc = ll_protocol->pull ( iobuf, &iob_ll_dest, &iob_ll_src,
676
-					&iob_net_proto ) ) != 0 ) {
676
+	if ( ( rc = ll_protocol->pull ( snpdev->netdev, iobuf, &iob_ll_dest,
677
+					&iob_ll_src, &iob_net_proto ) ) != 0 ){
677 678
 		DBGC ( snpdev, "SNPDEV %p could not parse header: %s\n",
678 679
 		       snpdev, strerror ( rc ) );
679 680
 		efirc = RC_TO_EFIRC ( rc );

+ 6
- 2
src/net/ethernet.c Переглянути файл

@@ -43,13 +43,15 @@ static uint8_t eth_broadcast[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
43 43
 /**
44 44
  * Add Ethernet link-layer header
45 45
  *
46
+ * @v netdev		Network device
46 47
  * @v iobuf		I/O buffer
47 48
  * @v ll_dest		Link-layer destination address
48 49
  * @v ll_source		Source link-layer address
49 50
  * @v net_proto		Network-layer protocol, in network-byte order
50 51
  * @ret rc		Return status code
51 52
  */
52
-static int eth_push ( struct io_buffer *iobuf, const void *ll_dest,
53
+static int eth_push ( struct net_device *netdev __unused,
54
+		      struct io_buffer *iobuf, const void *ll_dest,
53 55
 		      const void *ll_source, uint16_t net_proto ) {
54 56
 	struct ethhdr *ethhdr = iob_push ( iobuf, sizeof ( *ethhdr ) );
55 57
 
@@ -64,13 +66,15 @@ static int eth_push ( struct io_buffer *iobuf, const void *ll_dest,
64 66
 /**
65 67
  * Remove Ethernet link-layer header
66 68
  *
69
+ * @v netdev		Network device
67 70
  * @v iobuf		I/O buffer
68 71
  * @ret ll_dest		Link-layer destination address
69 72
  * @ret ll_source	Source link-layer address
70 73
  * @ret net_proto	Network-layer protocol, in network-byte order
71 74
  * @ret rc		Return status code
72 75
  */
73
-static int eth_pull ( struct io_buffer *iobuf, const void **ll_dest,
76
+static int eth_pull ( struct net_device *netdev __unused, 
77
+		      struct io_buffer *iobuf, const void **ll_dest,
74 78
 		      const void **ll_source, uint16_t *net_proto ) {
75 79
 	struct ethhdr *ethhdr = iobuf->data;
76 80
 

+ 3
- 3
src/net/netdevice.c Переглянути файл

@@ -509,7 +509,7 @@ int net_tx ( struct io_buffer *iobuf, struct net_device *netdev,
509 509
 	netdev_poll ( netdev );
510 510
 
511 511
 	/* Add link-layer header */
512
-	if ( ( rc = ll_protocol->push ( iobuf, ll_dest, netdev->ll_addr,
512
+	if ( ( rc = ll_protocol->push ( netdev, iobuf, ll_dest, netdev->ll_addr,
513 513
 					net_protocol->net_proto ) ) != 0 ) {
514 514
 		free_iob ( iobuf );
515 515
 		return rc;
@@ -581,8 +581,8 @@ static void net_step ( struct process *process __unused ) {
581 581
 
582 582
 			/* Remove link-layer header */
583 583
 			ll_protocol = netdev->ll_protocol;
584
-			if ( ( rc = ll_protocol->pull ( iobuf, &ll_dest,
585
-							&ll_source,
584
+			if ( ( rc = ll_protocol->pull ( netdev, iobuf,
585
+							&ll_dest, &ll_source,
586 586
 							&net_proto ) ) != 0 ) {
587 587
 				free_iob ( iobuf );
588 588
 				continue;

Завантаження…
Відмінити
Зберегти