summaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
authorMichael Brown2007-01-04 05:20:08 +0100
committerMichael Brown2007-01-04 05:20:08 +0100
commit0c03bb5a9a0649ec7009e334c0e42290af330437 (patch)
treed523c7ba2ae84b0998b7e8121d70a603d6fd087a /src/include
parentWe *should* use the persistent reference API for our netdev reference, (diff)
downloadipxe-0c03bb5a9a0649ec7009e334c0e42290af330437.tar.gz
ipxe-0c03bb5a9a0649ec7009e334c0e42290af330437.tar.xz
ipxe-0c03bb5a9a0649ec7009e334c0e42290af330437.zip
Make open() and close() an official part of the netdevice API.
Call netdevice's poll() and transmit() methods only when device is open.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gpxe/netdevice.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/include/gpxe/netdevice.h b/src/include/gpxe/netdevice.h
index 7551be74d..20df79193 100644
--- a/src/include/gpxe/netdevice.h
+++ b/src/include/gpxe/netdevice.h
@@ -142,6 +142,23 @@ struct net_device {
/** List of persistent reference holders */
struct list_head references;
+ /** Open network device
+ *
+ * @v netdev Network device
+ * @ret rc Return status code
+ *
+ * This method should allocate RX packet buffers and enable
+ * the hardware to start transmitting and receiving packets.
+ */
+ int ( * open ) ( struct net_device *netdev );
+ /** Close network device
+ *
+ * @v netdev Network device
+ *
+ * This method should stop the flow of packets, and free up
+ * any packets that are currently in the device's TX queue.
+ */
+ void ( * close ) ( struct net_device *netdev );
/** Transmit packet
*
* @v netdev Network device
@@ -154,6 +171,9 @@ struct net_device {
* Ownership of the packet buffer is transferred to the @c
* net_device, which must eventually call free_pkb() to
* release the buffer.
+ *
+ * This method is guaranteed to be called only when the device
+ * is open.
*/
int ( * transmit ) ( struct net_device *netdev, struct pk_buff *pkb );
/** Poll for received packet
@@ -163,6 +183,9 @@ struct net_device {
* This method should cause the hardware to check for received
* packets. Any received packets should be delivered via
* netdev_rx().
+ *
+ * This method is guaranteed to be called only when the device
+ * is open.
*/
void ( * poll ) ( struct net_device *netdev );
@@ -174,6 +197,11 @@ struct net_device {
*/
uint8_t ll_addr[MAX_LL_ADDR_LEN];
+ /** Current device state
+ *
+ * This is the bitwise-OR of zero or more NETDEV_XXX constants.
+ */
+ unsigned int state;
/** Received packet queue */
struct list_head rx_queue;
@@ -181,6 +209,9 @@ struct net_device {
void *priv;
};
+/** Network device is open */
+#define NETDEV_OPEN 0x0001
+
/** Declare a link-layer protocol */
#define __ll_protocol __table ( ll_protocols, 01 )
@@ -209,6 +240,8 @@ extern int netdev_poll ( struct net_device *netdev );
extern struct pk_buff * netdev_rx_dequeue ( struct net_device *netdev );
extern struct net_device * alloc_netdev ( size_t priv_size );
extern int register_netdev ( struct net_device *netdev );
+extern int netdev_open ( struct net_device *netdev );
+extern void netdev_close ( struct net_device *netdev );
extern void unregister_netdev ( struct net_device *netdev );
extern void free_netdev ( struct net_device *netdev );
extern struct net_device * next_netdev ( void );