Browse Source

[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 years ago
parent
commit
eb3ca2a36f

+ 3
- 3
src/arch/i386/interface/pxe/pxe_undi.c View File

270
 		}
270
 		}
271
 
271
 
272
 		/* Add link-layer header */
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
 						pxe_netdev->ll_addr,
274
 						pxe_netdev->ll_addr,
275
 						net_protocol->net_proto ))!=0){
275
 						net_protocol->net_proto ))!=0){
276
 			free_iob ( iobuf );
276
 			free_iob ( iobuf );
630
 
630
 
631
 		/* Strip link-layer header */
631
 		/* Strip link-layer header */
632
 		ll_protocol = pxe_netdev->ll_protocol;
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
 			/* Assume unknown net_proto and no ll_source */
635
 			/* Assume unknown net_proto and no ll_source */
636
 			net_proto = 0;
636
 			net_proto = 0;
637
 			ll_source = NULL;
637
 			ll_source = NULL;

+ 6
- 2
src/drivers/net/ipoib.c View File

238
 /**
238
 /**
239
  * Add IPoIB link-layer header
239
  * Add IPoIB link-layer header
240
  *
240
  *
241
+ * @v netdev		Network device
241
  * @v iobuf		I/O buffer
242
  * @v iobuf		I/O buffer
242
  * @v ll_dest		Link-layer destination address
243
  * @v ll_dest		Link-layer destination address
243
  * @v ll_source		Source link-layer address
244
  * @v ll_source		Source link-layer address
244
  * @v net_proto		Network-layer protocol, in network-byte order
245
  * @v net_proto		Network-layer protocol, in network-byte order
245
  * @ret rc		Return status code
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
 			const void *ll_source __unused, uint16_t net_proto ) {
250
 			const void *ll_source __unused, uint16_t net_proto ) {
249
 	struct ipoib_hdr *ipoib_hdr =
251
 	struct ipoib_hdr *ipoib_hdr =
250
 		iob_push ( iobuf, sizeof ( *ipoib_hdr ) );
252
 		iob_push ( iobuf, sizeof ( *ipoib_hdr ) );
268
 /**
270
 /**
269
  * Remove IPoIB link-layer header
271
  * Remove IPoIB link-layer header
270
  *
272
  *
273
+ * @v netdev		Network device
271
  * @v iobuf		I/O buffer
274
  * @v iobuf		I/O buffer
272
  * @ret ll_dest		Link-layer destination address
275
  * @ret ll_dest		Link-layer destination address
273
  * @ret ll_source	Source link-layer address
276
  * @ret ll_source	Source link-layer address
274
  * @ret net_proto	Network-layer protocol, in network-byte order
277
  * @ret net_proto	Network-layer protocol, in network-byte order
275
  * @ret rc		Return status code
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
 			const void **ll_source, uint16_t *net_proto ) {
282
 			const void **ll_source, uint16_t *net_proto ) {
279
 	struct ipoib_hdr *ipoib_hdr = iobuf->data;
283
 	struct ipoib_hdr *ipoib_hdr = iobuf->data;
280
 	struct ipoib_peer *dest;
284
 	struct ipoib_peer *dest;

+ 8
- 4
src/include/gpxe/netdevice.h View File

88
 	/**
88
 	/**
89
 	 * Add link-layer header
89
 	 * Add link-layer header
90
 	 *
90
 	 *
91
+	 * @v netdev		Network device
91
 	 * @v iobuf		I/O buffer
92
 	 * @v iobuf		I/O buffer
92
 	 * @v ll_dest		Link-layer destination address
93
 	 * @v ll_dest		Link-layer destination address
93
 	 * @v ll_source		Source link-layer address
94
 	 * @v ll_source		Source link-layer address
94
 	 * @v net_proto		Network-layer protocol, in network-byte order
95
 	 * @v net_proto		Network-layer protocol, in network-byte order
95
 	 * @ret rc		Return status code
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
 	 * Remove link-layer header
102
 	 * Remove link-layer header
101
 	 *
103
 	 *
104
+	 * @v netdev		Network device
102
 	 * @v iobuf		I/O buffer
105
 	 * @v iobuf		I/O buffer
103
 	 * @ret ll_dest		Link-layer destination address
106
 	 * @ret ll_dest		Link-layer destination address
104
 	 * @ret ll_source	Source link-layer address
107
 	 * @ret ll_source	Source link-layer address
105
 	 * @ret net_proto	Network-layer protocol, in network-byte order
108
 	 * @ret net_proto	Network-layer protocol, in network-byte order
106
 	 * @ret rc		Return status code
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
 	 * Transcribe link-layer address
115
 	 * Transcribe link-layer address
112
 	 *
116
 	 *

+ 4
- 3
src/interface/efi/efi_snp.c View File

594
 	/* Create link-layer header, if specified */
594
 	/* Create link-layer header, if specified */
595
 	if ( ll_header_len ) {
595
 	if ( ll_header_len ) {
596
 		iob_pull ( iobuf, ll_header_len );
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
 						htons ( *net_proto ) )) != 0 ){
599
 						htons ( *net_proto ) )) != 0 ){
599
 			DBGC ( snpdev, "SNPDEV %p TX could not construct "
600
 			DBGC ( snpdev, "SNPDEV %p TX could not construct "
600
 			       "header: %s\n", snpdev, strerror ( rc ) );
601
 			       "header: %s\n", snpdev, strerror ( rc ) );
672
 	*len = iob_len ( iobuf );
673
 	*len = iob_len ( iobuf );
673
 
674
 
674
 	/* Attempt to decode link-layer header */
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
 		DBGC ( snpdev, "SNPDEV %p could not parse header: %s\n",
678
 		DBGC ( snpdev, "SNPDEV %p could not parse header: %s\n",
678
 		       snpdev, strerror ( rc ) );
679
 		       snpdev, strerror ( rc ) );
679
 		efirc = RC_TO_EFIRC ( rc );
680
 		efirc = RC_TO_EFIRC ( rc );

+ 6
- 2
src/net/ethernet.c View File

43
 /**
43
 /**
44
  * Add Ethernet link-layer header
44
  * Add Ethernet link-layer header
45
  *
45
  *
46
+ * @v netdev		Network device
46
  * @v iobuf		I/O buffer
47
  * @v iobuf		I/O buffer
47
  * @v ll_dest		Link-layer destination address
48
  * @v ll_dest		Link-layer destination address
48
  * @v ll_source		Source link-layer address
49
  * @v ll_source		Source link-layer address
49
  * @v net_proto		Network-layer protocol, in network-byte order
50
  * @v net_proto		Network-layer protocol, in network-byte order
50
  * @ret rc		Return status code
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
 		      const void *ll_source, uint16_t net_proto ) {
55
 		      const void *ll_source, uint16_t net_proto ) {
54
 	struct ethhdr *ethhdr = iob_push ( iobuf, sizeof ( *ethhdr ) );
56
 	struct ethhdr *ethhdr = iob_push ( iobuf, sizeof ( *ethhdr ) );
55
 
57
 
64
 /**
66
 /**
65
  * Remove Ethernet link-layer header
67
  * Remove Ethernet link-layer header
66
  *
68
  *
69
+ * @v netdev		Network device
67
  * @v iobuf		I/O buffer
70
  * @v iobuf		I/O buffer
68
  * @ret ll_dest		Link-layer destination address
71
  * @ret ll_dest		Link-layer destination address
69
  * @ret ll_source	Source link-layer address
72
  * @ret ll_source	Source link-layer address
70
  * @ret net_proto	Network-layer protocol, in network-byte order
73
  * @ret net_proto	Network-layer protocol, in network-byte order
71
  * @ret rc		Return status code
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
 		      const void **ll_source, uint16_t *net_proto ) {
78
 		      const void **ll_source, uint16_t *net_proto ) {
75
 	struct ethhdr *ethhdr = iobuf->data;
79
 	struct ethhdr *ethhdr = iobuf->data;
76
 
80
 

+ 3
- 3
src/net/netdevice.c View File

509
 	netdev_poll ( netdev );
509
 	netdev_poll ( netdev );
510
 
510
 
511
 	/* Add link-layer header */
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
 					net_protocol->net_proto ) ) != 0 ) {
513
 					net_protocol->net_proto ) ) != 0 ) {
514
 		free_iob ( iobuf );
514
 		free_iob ( iobuf );
515
 		return rc;
515
 		return rc;
581
 
581
 
582
 			/* Remove link-layer header */
582
 			/* Remove link-layer header */
583
 			ll_protocol = netdev->ll_protocol;
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
 							&net_proto ) ) != 0 ) {
586
 							&net_proto ) ) != 0 ) {
587
 				free_iob ( iobuf );
587
 				free_iob ( iobuf );
588
 				continue;
588
 				continue;

Loading…
Cancel
Save