aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Oreman <oremanj@rwcr.net>2009-06-15 11:37:43 -0700
committerMichael Brown <mcb30@etherboot.org>2009-06-23 10:41:57 +0100
commiteb3ca2a36f0c613aea5c2f02762bc608d5ec785c (patch)
tree9e0e6b07713bce905f580fc8384711c04290725a
parent743ebc2f4b056673efb26f294ab39a661d77d1a8 (diff)
downloadipxe-eb3ca2a36f0c613aea5c2f02762bc608d5ec785c.zip
ipxe-eb3ca2a36f0c613aea5c2f02762bc608d5ec785c.tar.gz
ipxe-eb3ca2a36f0c613aea5c2f02762bc608d5ec785c.tar.bz2
[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>
-rw-r--r--src/arch/i386/interface/pxe/pxe_undi.c6
-rw-r--r--src/drivers/net/ipoib.c8
-rw-r--r--src/include/gpxe/netdevice.h12
-rw-r--r--src/interface/efi/efi_snp.c7
-rw-r--r--src/net/ethernet.c8
-rw-r--r--src/net/netdevice.c6
6 files changed, 30 insertions, 17 deletions
diff --git a/src/arch/i386/interface/pxe/pxe_undi.c b/src/arch/i386/interface/pxe/pxe_undi.c
index fe124d6..fd2d688 100644
--- a/src/arch/i386/interface/pxe/pxe_undi.c
+++ b/src/arch/i386/interface/pxe/pxe_undi.c
@@ -270,7 +270,7 @@ PXENV_EXIT_t pxenv_undi_transmit ( struct s_PXENV_UNDI_TRANSMIT
}
/* Add link-layer header */
- if ( ( rc = ll_protocol->push ( iobuf, ll_dest,
+ if ( ( rc = ll_protocol->push ( pxe_netdev, iobuf, ll_dest,
pxe_netdev->ll_addr,
net_protocol->net_proto ))!=0){
free_iob ( iobuf );
@@ -630,8 +630,8 @@ PXENV_EXIT_t pxenv_undi_isr ( struct s_PXENV_UNDI_ISR *undi_isr ) {
/* Strip link-layer header */
ll_protocol = pxe_netdev->ll_protocol;
- if ( ( rc = ll_protocol->pull ( iobuf, &ll_dest, &ll_source,
- &net_proto ) ) != 0 ) {
+ if ( ( rc = ll_protocol->pull ( pxe_netdev, iobuf, &ll_dest,
+ &ll_source, &net_proto )) !=0){
/* Assume unknown net_proto and no ll_source */
net_proto = 0;
ll_source = NULL;
diff --git a/src/drivers/net/ipoib.c b/src/drivers/net/ipoib.c
index cb56458..bb8757b 100644
--- a/src/drivers/net/ipoib.c
+++ b/src/drivers/net/ipoib.c
@@ -238,13 +238,15 @@ ipoib_cache_peer ( const struct ib_gid *gid, unsigned long qpn ) {
/**
* Add IPoIB link-layer header
*
+ * @v netdev Network device
* @v iobuf I/O buffer
* @v ll_dest Link-layer destination address
* @v ll_source Source link-layer address
* @v net_proto Network-layer protocol, in network-byte order
* @ret rc Return status code
*/
-static int ipoib_push ( struct io_buffer *iobuf, const void *ll_dest,
+static int ipoib_push ( struct net_device *netdev __unused,
+ struct io_buffer *iobuf, const void *ll_dest,
const void *ll_source __unused, uint16_t net_proto ) {
struct ipoib_hdr *ipoib_hdr =
iob_push ( iobuf, sizeof ( *ipoib_hdr ) );
@@ -268,13 +270,15 @@ static int ipoib_push ( struct io_buffer *iobuf, const void *ll_dest,
/**
* Remove IPoIB link-layer header
*
+ * @v netdev Network device
* @v iobuf I/O buffer
* @ret ll_dest Link-layer destination address
* @ret ll_source Source link-layer address
* @ret net_proto Network-layer protocol, in network-byte order
* @ret rc Return status code
*/
-static int ipoib_pull ( struct io_buffer *iobuf, const void **ll_dest,
+static int ipoib_pull ( struct net_device *netdev __unused,
+ struct io_buffer *iobuf, const void **ll_dest,
const void **ll_source, uint16_t *net_proto ) {
struct ipoib_hdr *ipoib_hdr = iobuf->data;
struct ipoib_peer *dest;
diff --git a/src/include/gpxe/netdevice.h b/src/include/gpxe/netdevice.h
index cfcfb77..2308f8f 100644
--- a/src/include/gpxe/netdevice.h
+++ b/src/include/gpxe/netdevice.h
@@ -88,25 +88,29 @@ struct ll_protocol {
/**
* Add link-layer header
*
+ * @v netdev Network device
* @v iobuf I/O buffer
* @v ll_dest Link-layer destination address
* @v ll_source Source link-layer address
* @v net_proto Network-layer protocol, in network-byte order
* @ret rc Return status code
*/
- int ( * push ) ( struct io_buffer *iobuf, const void *ll_dest,
- const void *ll_source, uint16_t net_proto );
+ int ( * push ) ( struct net_device *netdev, struct io_buffer *iobuf,
+ const void *ll_dest, const void *ll_source,
+ uint16_t net_proto );
/**
* Remove link-layer header
*
+ * @v netdev Network device
* @v iobuf I/O buffer
* @ret ll_dest Link-layer destination address
* @ret ll_source Source link-layer address
* @ret net_proto Network-layer protocol, in network-byte order
* @ret rc Return status code
*/
- int ( * pull ) ( struct io_buffer *iobuf, const void **ll_dest,
- const void **ll_source, uint16_t *net_proto );
+ int ( * pull ) ( struct net_device *netdev, struct io_buffer *iobuf,
+ const void **ll_dest, const void **ll_source,
+ uint16_t *net_proto );
/**
* Transcribe link-layer address
*
diff --git a/src/interface/efi/efi_snp.c b/src/interface/efi/efi_snp.c
index e4b3546..4bdb780 100644
--- a/src/interface/efi/efi_snp.c
+++ b/src/interface/efi/efi_snp.c
@@ -594,7 +594,8 @@ efi_snp_transmit ( EFI_SIMPLE_NETWORK_PROTOCOL *snp,
/* Create link-layer header, if specified */
if ( ll_header_len ) {
iob_pull ( iobuf, ll_header_len );
- if ( ( rc = ll_protocol->push ( iobuf, ll_dest, ll_src,
+ if ( ( rc = ll_protocol->push ( snpdev->netdev,
+ iobuf, ll_dest, ll_src,
htons ( *net_proto ) )) != 0 ){
DBGC ( snpdev, "SNPDEV %p TX could not construct "
"header: %s\n", snpdev, strerror ( rc ) );
@@ -672,8 +673,8 @@ efi_snp_receive ( EFI_SIMPLE_NETWORK_PROTOCOL *snp,
*len = iob_len ( iobuf );
/* Attempt to decode link-layer header */
- if ( ( rc = ll_protocol->pull ( iobuf, &iob_ll_dest, &iob_ll_src,
- &iob_net_proto ) ) != 0 ) {
+ if ( ( rc = ll_protocol->pull ( snpdev->netdev, iobuf, &iob_ll_dest,
+ &iob_ll_src, &iob_net_proto ) ) != 0 ){
DBGC ( snpdev, "SNPDEV %p could not parse header: %s\n",
snpdev, strerror ( rc ) );
efirc = RC_TO_EFIRC ( rc );
diff --git a/src/net/ethernet.c b/src/net/ethernet.c
index 812da86..6c5f787 100644
--- a/src/net/ethernet.c
+++ b/src/net/ethernet.c
@@ -43,13 +43,15 @@ static uint8_t eth_broadcast[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
/**
* Add Ethernet link-layer header
*
+ * @v netdev Network device
* @v iobuf I/O buffer
* @v ll_dest Link-layer destination address
* @v ll_source Source link-layer address
* @v net_proto Network-layer protocol, in network-byte order
* @ret rc Return status code
*/
-static int eth_push ( struct io_buffer *iobuf, const void *ll_dest,
+static int eth_push ( struct net_device *netdev __unused,
+ struct io_buffer *iobuf, const void *ll_dest,
const void *ll_source, uint16_t net_proto ) {
struct ethhdr *ethhdr = iob_push ( iobuf, sizeof ( *ethhdr ) );
@@ -64,13 +66,15 @@ static int eth_push ( struct io_buffer *iobuf, const void *ll_dest,
/**
* Remove Ethernet link-layer header
*
+ * @v netdev Network device
* @v iobuf I/O buffer
* @ret ll_dest Link-layer destination address
* @ret ll_source Source link-layer address
* @ret net_proto Network-layer protocol, in network-byte order
* @ret rc Return status code
*/
-static int eth_pull ( struct io_buffer *iobuf, const void **ll_dest,
+static int eth_pull ( struct net_device *netdev __unused,
+ struct io_buffer *iobuf, const void **ll_dest,
const void **ll_source, uint16_t *net_proto ) {
struct ethhdr *ethhdr = iobuf->data;
diff --git a/src/net/netdevice.c b/src/net/netdevice.c
index 77edbcd..c3551ea 100644
--- a/src/net/netdevice.c
+++ b/src/net/netdevice.c
@@ -509,7 +509,7 @@ int net_tx ( struct io_buffer *iobuf, struct net_device *netdev,
netdev_poll ( netdev );
/* Add link-layer header */
- if ( ( rc = ll_protocol->push ( iobuf, ll_dest, netdev->ll_addr,
+ if ( ( rc = ll_protocol->push ( netdev, iobuf, ll_dest, netdev->ll_addr,
net_protocol->net_proto ) ) != 0 ) {
free_iob ( iobuf );
return rc;
@@ -581,8 +581,8 @@ static void net_step ( struct process *process __unused ) {
/* Remove link-layer header */
ll_protocol = netdev->ll_protocol;
- if ( ( rc = ll_protocol->pull ( iobuf, &ll_dest,
- &ll_source,
+ if ( ( rc = ll_protocol->pull ( netdev, iobuf,
+ &ll_dest, &ll_source,
&net_proto ) ) != 0 ) {
free_iob ( iobuf );
continue;