diff options
Diffstat (limited to 'src/include/gpxe')
-rw-r--r-- | src/include/gpxe/ip.h | 8 | ||||
-rw-r--r-- | src/include/gpxe/ip6.h | 10 | ||||
-rw-r--r-- | src/include/gpxe/ndp.h | 4 | ||||
-rw-r--r-- | src/include/gpxe/netdevice.h | 42 | ||||
-rw-r--r-- | src/include/gpxe/pkbuff.h | 163 | ||||
-rw-r--r-- | src/include/gpxe/tcp.h | 6 | ||||
-rw-r--r-- | src/include/gpxe/tcpip.h | 18 | ||||
-rw-r--r-- | src/include/gpxe/udp.h | 8 |
8 files changed, 48 insertions, 211 deletions
diff --git a/src/include/gpxe/ip.h b/src/include/gpxe/ip.h index d212b3ef7..9a5b7a81f 100644 --- a/src/include/gpxe/ip.h +++ b/src/include/gpxe/ip.h @@ -25,7 +25,7 @@ #define IP_TOS 0 #define IP_TTL 64 -#define IP_FRAG_PKB_SIZE 1500 +#define IP_FRAG_IOB_SIZE 1500 #define IP_FRAG_TIMEOUT 50 /* IP4 pseudo header */ @@ -63,15 +63,15 @@ struct frag_buffer { struct in_addr src; /* Destination network address */ struct in_addr dest; - /* Reassembled packet buffer */ - struct pk_buff *frag_pkb; + /* Reassembled I/O buffer */ + struct io_buffer *frag_iob; /* Reassembly timer */ struct retry_timer frag_timer; /* List of fragment reassembly buffers */ struct list_head list; }; -struct pk_buff; +struct io_buffer; struct net_device; struct net_protocol; struct tcpip_protocol; diff --git a/src/include/gpxe/ip6.h b/src/include/gpxe/ip6.h index 0ba17120e..37c0781dd 100644 --- a/src/include/gpxe/ip6.h +++ b/src/include/gpxe/ip6.h @@ -16,12 +16,12 @@ #define IP6_HOP_LIMIT 255 /** - * Packet buffer contents - * This is duplicated in tcp.h and here. Ideally it should go into pkbuff.h + * I/O buffer contents + * This is duplicated in tcp.h and here. Ideally it should go into iobuf.h */ #define MAX_HDR_LEN 100 -#define MAX_PKB_LEN 1500 -#define MIN_PKB_LEN MAX_HDR_LEN + 100 /* To account for padding by LL */ +#define MAX_IOB_LEN 1500 +#define MIN_IOB_LEN MAX_HDR_LEN + 100 /* To account for padding by LL */ #define IP6_EQUAL( in6_addr1, in6_addr2 ) \ ( strncmp ( ( char* ) &( in6_addr1 ), ( char* ) &( in6_addr2 ),\ @@ -61,7 +61,7 @@ struct ipv6_pseudo_header { #define IP6_ICMP6 0x58 #define IP6_NO_HEADER 0x59 -struct pk_buff; +struct io_buffer; struct net_device; struct net_protocol; diff --git a/src/include/gpxe/ndp.h b/src/include/gpxe/ndp.h index ed9411f93..e3711b5da 100644 --- a/src/include/gpxe/ndp.h +++ b/src/include/gpxe/ndp.h @@ -6,7 +6,7 @@ #include <gpxe/ip6.h> #include <gpxe/in.h> #include <gpxe/netdevice.h> -#include <gpxe/pkbuff.h> +#include <gpxe/iobuf.h> #include <gpxe/tcpip.h> #define NDP_STATE_INVALID 0 @@ -19,5 +19,5 @@ static struct ndp_entry * ndp_find_entry ( struct in6_addr *in6 ); int ndp_resolve ( struct net_device *netdev, struct in6_addr *src, struct in6_addr *dest, void *dest_ll_addr ); -int ndp_process_advert ( struct pk_buff *pkb, struct sockaddr_tcpip *st_src, +int ndp_process_advert ( struct io_buffer *iobuf, struct sockaddr_tcpip *st_src, struct sockaddr_tcpip *st_dest ); diff --git a/src/include/gpxe/netdevice.h b/src/include/gpxe/netdevice.h index f9d507bf9..c71c09284 100644 --- a/src/include/gpxe/netdevice.h +++ b/src/include/gpxe/netdevice.h @@ -12,7 +12,7 @@ #include <gpxe/tables.h> #include <gpxe/hotplug.h> -struct pk_buff; +struct io_buffer; struct net_device; struct net_protocol; struct ll_protocol; @@ -37,13 +37,13 @@ struct net_protocol { /** * Process received packet * - * @v pkb Packet buffer + * @v iobuf I/O buffer * @v netdev Network device * @v ll_source Link-layer source address * - * This method takes ownership of the packet buffer. + * This method takes ownership of the I/O buffer. */ - int ( * rx ) ( struct pk_buff *pkb, struct net_device *netdev, + int ( * rx ) ( struct io_buffer *iobuf, struct net_device *netdev, const void *ll_source ); /** * Transcribe network-layer address @@ -77,7 +77,7 @@ struct ll_protocol { /** * Transmit network-layer packet via network device * - * @v pkb Packet buffer + * @v iobuf I/O buffer * @v netdev Network device * @v net_protocol Network-layer protocol * @v ll_dest Link-layer destination address @@ -85,15 +85,15 @@ struct ll_protocol { * * This method should prepend in the link-layer header * (e.g. the Ethernet DIX header) and transmit the packet. - * This method takes ownership of the packet buffer. + * This method takes ownership of the I/O buffer. */ - int ( * tx ) ( struct pk_buff *pkb, struct net_device *netdev, + int ( * tx ) ( struct io_buffer *iobuf, struct net_device *netdev, struct net_protocol *net_protocol, const void *ll_dest ); /** * Handle received packet * - * @v pkb Packet buffer + * @v iobuf I/O buffer * @v netdev Network device * * This method should strip off the link-layer header @@ -101,7 +101,7 @@ struct ll_protocol { * net_rx(). This method takes ownership of the packet * buffer. */ - int ( * rx ) ( struct pk_buff *pkb, struct net_device *netdev ); + int ( * rx ) ( struct io_buffer *iobuf, struct net_device *netdev ); /** * Transcribe link-layer address * @@ -151,7 +151,7 @@ struct net_device { * @v netdev Network device * @ret rc Return status code * - * This method should allocate RX packet buffers and enable + * This method should allocate RX I/O buffers and enable * the hardware to start transmitting and receiving packets. */ int ( * open ) ( struct net_device *netdev ); @@ -166,22 +166,22 @@ struct net_device { /** Transmit packet * * @v netdev Network device - * @v pkb Packet buffer + * @v iobuf I/O buffer * @ret rc Return status code * * This method should cause the hardware to initiate - * transmission of the packet buffer. + * transmission of the I/O buffer. * - * If this method returns success, the packet buffer remains + * If this method returns success, the I/O buffer remains * owned by the net device's TX queue, and the net device must * eventually call netdev_tx_complete() to free the buffer. - * If this method returns failure, the packet buffer is + * If this method returns failure, the I/O buffer is * immediately released. * * This method is guaranteed to be called only when the device * is open. */ - int ( * transmit ) ( struct net_device *netdev, struct pk_buff *pkb ); + int ( * transmit ) ( struct net_device *netdev, struct io_buffer *iobuf ); /** Poll for received packet * * @v netdev Network device @@ -251,12 +251,12 @@ static inline int have_netdevs ( void ) { return ( ! list_empty ( &net_devices ) ); } -extern int netdev_tx ( struct net_device *netdev, struct pk_buff *pkb ); -void netdev_tx_complete ( struct net_device *netdev, struct pk_buff *pkb ); +extern int netdev_tx ( struct net_device *netdev, struct io_buffer *iobuf ); +void netdev_tx_complete ( struct net_device *netdev, struct io_buffer *iobuf ); void netdev_tx_complete_next ( struct net_device *netdev ); -extern void netdev_rx ( struct net_device *netdev, struct pk_buff *pkb ); +extern void netdev_rx ( struct net_device *netdev, struct io_buffer *iobuf ); extern int netdev_poll ( struct net_device *netdev, unsigned int rx_quota ); -extern struct pk_buff * netdev_rx_dequeue ( struct net_device *netdev ); +extern struct io_buffer * 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 ); @@ -266,9 +266,9 @@ extern void free_netdev ( struct net_device *netdev ); struct net_device * find_netdev ( const char *name ); struct net_device * find_pci_netdev ( unsigned int busdevfn ); -extern int net_tx ( struct pk_buff *pkb, struct net_device *netdev, +extern int net_tx ( struct io_buffer *iobuf, struct net_device *netdev, struct net_protocol *net_protocol, const void *ll_dest ); -extern int net_rx ( struct pk_buff *pkb, struct net_device *netdev, +extern int net_rx ( struct io_buffer *iobuf, struct net_device *netdev, uint16_t net_proto, const void *ll_source ); #endif /* _GPXE_NETDEVICE_H */ diff --git a/src/include/gpxe/pkbuff.h b/src/include/gpxe/pkbuff.h deleted file mode 100644 index 85bcc0369..000000000 --- a/src/include/gpxe/pkbuff.h +++ /dev/null @@ -1,163 +0,0 @@ -#ifndef _GPXE_PKBUFF_H -#define _GPXE_PKBUFF_H - -/** @file - * - * Packet buffers - * - * Packet buffers are used to contain network packets. Methods are - * provided for appending, prepending, etc. data. - * - */ - -#include <stdint.h> -#include <assert.h> -#include <gpxe/list.h> - -/** - * Packet buffer alignment - * - * Packet buffers allocated via alloc_pkb() are guaranteed to be - * physically aligned to this boundary. Some cards cannot DMA across - * a 4kB boundary. With a standard Ethernet MTU, aligning to a 2kB - * boundary is sufficient to guarantee no 4kB boundary crossings. For - * a jumbo Ethernet MTU, a packet may be larger than 4kB anyway. - */ -#define PKBUFF_ALIGN 2048 - -/** - * Minimum packet buffer length - * - * alloc_pkb() will round up the allocated length to this size if - * necessary. This is used on behalf of hardware that is not capable - * of auto-padding. - */ -#define PKB_ZLEN 64 - -/** A packet buffer - * - * This structure is used to represent a network packet within gPXE. - */ -struct pk_buff { - /** List of which this buffer is a member */ - struct list_head list; - - /** Start of the buffer */ - void *head; - /** Start of data */ - void *data; - /** End of data */ - void *tail; - /** End of the buffer */ - void *end; -}; - -/** - * Reserve space at start of packet buffer - * - * @v pkb Packet buffer - * @v len Length to reserve - * @ret data Pointer to new start of buffer - */ -static inline void * pkb_reserve ( struct pk_buff *pkb, size_t len ) { - pkb->data += len; - pkb->tail += len; - assert ( pkb->tail <= pkb->end ); - return pkb->data; -} - -/** - * Add data to start of packet buffer - * - * @v pkb Packet buffer - * @v len Length to add - * @ret data Pointer to new start of buffer - */ -static inline void * pkb_push ( struct pk_buff *pkb, size_t len ) { - pkb->data -= len; - assert ( pkb->data >= pkb->head ); - return pkb->data; -} - -/** - * Remove data from start of packet buffer - * - * @v pkb Packet buffer - * @v len Length to remove - * @ret data Pointer to new start of buffer - */ -static inline void * pkb_pull ( struct pk_buff *pkb, size_t len ) { - pkb->data += len; - assert ( pkb->data <= pkb->tail ); - return pkb->data; -} - -/** - * Add data to end of packet buffer - * - * @v pkb Packet buffer - * @v len Length to add - * @ret data Pointer to newly added space - */ -static inline void * pkb_put ( struct pk_buff *pkb, size_t len ) { - void *old_tail = pkb->tail; - pkb->tail += len; - assert ( pkb->tail <= pkb->end ); - return old_tail; -} - -/** - * Remove data from end of packet buffer - * - * @v pkb Packet buffer - * @v len Length to remove - */ -static inline void pkb_unput ( struct pk_buff *pkb, size_t len ) { - pkb->tail -= len; - assert ( pkb->tail >= pkb->data ); -} - -/** - * Empty a packet buffer - * - * @v pkb Packet buffer - */ -static inline void pkb_empty ( struct pk_buff *pkb ) { - pkb->tail = pkb->data; -} - -/** - * Calculate length of data in a packet buffer - * - * @v pkb Packet buffer - * @ret len Length of data in buffer - */ -static inline size_t pkb_len ( struct pk_buff *pkb ) { - return ( pkb->tail - pkb->data ); -} - -/** - * Calculate available space at start of a packet buffer - * - * @v pkb Packet buffer - * @ret len Length of data available at start of buffer - */ -static inline size_t pkb_headroom ( struct pk_buff *pkb ) { - return ( pkb->data - pkb->head ); -} - -/** - * Calculate available space at end of a packet buffer - * - * @v pkb Packet buffer - * @ret len Length of data available at end of buffer - */ -static inline size_t pkb_tailroom ( struct pk_buff *pkb ) { - return ( pkb->end - pkb->tail ); -} - -extern struct pk_buff * alloc_pkb ( size_t len ); -extern void free_pkb ( struct pk_buff *pkb ); -extern void pkb_pad ( struct pk_buff *pkb, size_t min_len ); - -#endif /* _GPXE_PKBUFF_H */ diff --git a/src/include/gpxe/tcp.h b/src/include/gpxe/tcp.h index 576898e86..f16ca0880 100644 --- a/src/include/gpxe/tcp.h +++ b/src/include/gpxe/tcp.h @@ -206,10 +206,10 @@ struct tcp_mss_option { /** Smallest port number on which a TCP connection can listen */ #define TCP_MIN_PORT 1 -/* Some PKB constants */ +/* Some IOB constants */ #define MAX_HDR_LEN 100 -#define MAX_PKB_LEN 1500 -#define MIN_PKB_LEN MAX_HDR_LEN + 100 /* To account for padding by LL */ +#define MAX_IOB_LEN 1500 +#define MIN_IOB_LEN MAX_HDR_LEN + 100 /* To account for padding by LL */ /** * Maxmimum advertised TCP window size diff --git a/src/include/gpxe/tcpip.h b/src/include/gpxe/tcpip.h index ec708bc6f..c0fadd23d 100644 --- a/src/include/gpxe/tcpip.h +++ b/src/include/gpxe/tcpip.h @@ -12,7 +12,7 @@ #include <gpxe/in.h> #include <gpxe/tables.h> -struct pk_buff; +struct io_buffer; struct net_device; /** Empty checksum value @@ -51,15 +51,15 @@ struct tcpip_protocol { /** * Process received packet * - * @v pkb Packet buffer + * @v iobuf I/O buffer * @v st_src Partially-filled source address * @v st_dest Partially-filled destination address * @v pshdr_csum Pseudo-header checksum * @ret rc Return status code * - * This method takes ownership of the packet buffer. + * This method takes ownership of the I/O buffer. */ - int ( * rx ) ( struct pk_buff *pkb, struct sockaddr_tcpip *st_src, + int ( * rx ) ( struct io_buffer *iobuf, struct sockaddr_tcpip *st_src, struct sockaddr_tcpip *st_dest, uint16_t pshdr_csum ); /** * Transport-layer protocol number @@ -80,16 +80,16 @@ struct tcpip_net_protocol { /** * Transmit packet * - * @v pkb Packet buffer + * @v iobuf I/O buffer * @v tcpip_protocol Transport-layer protocol * @v st_dest Destination address * @v netdev Network device (or NULL to route automatically) * @v trans_csum Transport-layer checksum to complete, or NULL * @ret rc Return status code * - * This function takes ownership of the packet buffer. + * This function takes ownership of the I/O buffer. */ - int ( * tx ) ( struct pk_buff *pkb, + int ( * tx ) ( struct io_buffer *iobuf, struct tcpip_protocol *tcpip_protocol, struct sockaddr_tcpip *st_dest, struct net_device *netdev, @@ -104,10 +104,10 @@ struct tcpip_net_protocol { #define __tcpip_net_protocol \ __table ( struct tcpip_net_protocol, tcpip_net_protocols, 01 ) -extern int tcpip_rx ( struct pk_buff *pkb, uint8_t tcpip_proto, +extern int tcpip_rx ( struct io_buffer *iobuf, uint8_t tcpip_proto, struct sockaddr_tcpip *st_src, struct sockaddr_tcpip *st_dest, uint16_t pshdr_csum ); -extern int tcpip_tx ( struct pk_buff *pkb, struct tcpip_protocol *tcpip, +extern int tcpip_tx ( struct io_buffer *iobuf, struct tcpip_protocol *tcpip, struct sockaddr_tcpip *st_dest, struct net_device *netdev, uint16_t *trans_csum ); diff --git a/src/include/gpxe/udp.h b/src/include/gpxe/udp.h index 074c5e1dd..0ca77b4d6 100644 --- a/src/include/gpxe/udp.h +++ b/src/include/gpxe/udp.h @@ -10,7 +10,7 @@ */ #include <stddef.h> -#include <gpxe/pkbuff.h> +#include <gpxe/iobuf.h> #include <gpxe/tcpip.h> #include <gpxe/if_ether.h> @@ -21,8 +21,8 @@ struct net_device; */ #define UDP_MAX_HLEN 72 -#define UDP_MAX_TXPKB ETH_MAX_MTU -#define UDP_MIN_TXPKB ETH_ZLEN +#define UDP_MAX_TXIOB ETH_MAX_MTU +#define UDP_MIN_TXIOB ETH_ZLEN typedef uint16_t port_t; @@ -86,7 +86,7 @@ struct udp_connection { /** Local port on which the connection receives packets */ port_t local_port; /** Transmit buffer */ - struct pk_buff *tx_pkb; + struct io_buffer *tx_iob; /** List of registered connections */ struct list_head list; /** Operations table for this connection */ |