summaryrefslogtreecommitdiffstats
path: root/src/net/netdevice.c
diff options
context:
space:
mode:
authorMichael Brown2006-06-16 02:19:46 +0200
committerMichael Brown2006-06-16 02:19:46 +0200
commitbbd9e2806115961a1d1d218a3eeb31924a114cfd (patch)
tree90baf335d6ee455ff30d0d4554fd89b95d288418 /src/net/netdevice.c
parentAdded iSCSI boot test code (diff)
downloadipxe-bbd9e2806115961a1d1d218a3eeb31924a114cfd.tar.gz
ipxe-bbd9e2806115961a1d1d218a3eeb31924a114cfd.tar.xz
ipxe-bbd9e2806115961a1d1d218a3eeb31924a114cfd.zip
Simplify TX datapath.
Diffstat (limited to 'src/net/netdevice.c')
-rw-r--r--src/net/netdevice.c129
1 files changed, 46 insertions, 83 deletions
diff --git a/src/net/netdevice.c b/src/net/netdevice.c
index 3d4640a8..1825a55b 100644
--- a/src/net/netdevice.c
+++ b/src/net/netdevice.c
@@ -62,6 +62,50 @@ static struct net_address static_single_netdev_addresses_end[0]
/** Recevied packet queue */
static LIST_HEAD ( rx_queue );
+#warning "Remove this static IP address hack"
+#include <ip.h>
+#include <gpxe/ip.h>
+
+/**
+ * Register network device
+ *
+ * @v netdev Network device
+ * @ret rc Return status code
+ *
+ * Adds the network device to the list of network devices.
+ */
+int register_netdev ( struct net_device *netdev ) {
+
+#warning "Remove this static IP address hack"
+ {
+ const struct in_addr static_address = { htonl ( 0x0afefe01 ) };
+ const struct in_addr static_netmask = { htonl ( 0xffffff00 ) };
+ const struct in_addr static_gateway = { INADDR_NONE };
+ int rc;
+
+ if ( ( rc = add_ipv4_address ( netdev, static_address,
+ static_netmask,
+ static_gateway ) ) != 0 )
+ return rc;
+ }
+
+ return 0;
+}
+
+/**
+ * Unregister network device
+ *
+ * @v netdev Network device
+ *
+ * Removes the network device from the list of network devices.
+ */
+void unregister_netdev ( struct net_device *netdev ) {
+
+#warning "Remove this static IP address hack"
+ del_ipv4_address ( netdev );
+
+}
+
/**
* Add packet to receive queue
*
@@ -129,88 +173,6 @@ find_netdev_by_net_addr ( struct net_protocol *net_protocol,
}
/**
- * Transmit packet via a network device
- *
- * @v pkb Packet buffer
- * @v netdev Network device, or NULL
- * @ret rc Return status code
- *
- * Transmits the packet via the specified network device. The packet
- * must begin with a network-layer header, and the @c net_protocol
- * field must have been filled in. If @c netdev is NULL, the network
- * device is identified via the packet contents, if possible. This
- * function takes ownership of the packet buffer.
- */
-int net_transmit_via ( struct pk_buff *pkb, struct net_device *netdev ) {
- struct net_protocol *net_protocol;
- struct net_header nethdr;
- struct ll_protocol *ll_protocol;
- struct ll_header llhdr;
- int rc;
-
- /* Perform network-layer routing */
- net_protocol = pkb->net_protocol;
- nethdr.net_protocol = net_protocol;
- if ( ( rc = net_protocol->route ( pkb, &nethdr ) ) != 0 ) {
- DBG ( "Could not route to %s address %s\n",
- net_protocol->name,
- net_protocol->ntoa ( nethdr.dest_net_addr ) );
- free_pkb ( pkb );
- return rc;
- }
-
- /* Identify transmitting network device, if not specified */
- if ( ! netdev ) {
- netdev = find_netdev_by_net_addr ( net_protocol,
- nethdr.source_net_addr );
- if ( ! netdev ) {
- DBG ( "No network device for %s address %s\n",
- net_protocol->name,
- net_protocol->ntoa ( nethdr.source_net_addr ) );
- free_pkb ( pkb );
- return -EHOSTUNREACH;
- }
- }
-
- /* Perform link-layer routing */
- ll_protocol = netdev->ll_protocol;
- llhdr.ll_protocol = ll_protocol;
- if ( ( rc = ll_protocol->route ( netdev, &nethdr, &llhdr ) ) != 0 ) {
- DBG ( "No link-layer route to %s address %s\n",
- net_protocol->name,
- net_protocol->ntoa ( nethdr.dest_net_addr ) );
- free_pkb ( pkb );
- return rc;
- }
-
- /* Prepend link-layer header */
- pkb_push ( pkb, ll_protocol->ll_header_len );
- ll_protocol->fill_llh ( &llhdr, pkb );
-
- /* Hand off packet to network device */
- if ( ( rc = netdev->transmit ( netdev, pkb ) ) != 0 ) {
- DBG ( "Device failed to transmit packet\n" );
- return rc;
- }
-
- DBG ( "Packet transmitted\n" );
- return 0;
-}
-
-/**
- * Transmit packet
- *
- * @v pkb Packet buffer
- * @ret rc Return status code
- *
- * Transmits the packet via the appropriate network device. This
- * function takes ownership of the packet buffer.
- */
-int net_transmit ( struct pk_buff *pkb ) {
- return net_transmit_via ( pkb, NULL );
-}
-
-/**
* Poll for packet on all network devices
*
* @ret True There are packets present in the receive queue
@@ -277,7 +239,8 @@ int net_rx_process ( struct pk_buff *pkb ) {
pkb->net_protocol = net_protocol;
/* Strip off link-layer header */
- pkb_pull ( pkb, ll_protocol->ll_header_len );
+#warning "Temporary hack"
+ pkb_pull ( pkb, ETH_HLEN );
/* Hand off to network layer */
if ( ( rc = net_protocol->rx_process ( pkb ) ) != 0 ) {