pkbuff->iobuf changeover

Achieved via Perl using:

perl -pi -e 's/pk_buff/io_buffer/g; s/Packet buffer/I\/O buffer/ig; ' \
	-e 's/pkbuff\.h/iobuf.h/g; s/pkb_/iob_/g; s/_pkb/_iob/g; ' \
	-e 's/pkb/iobuf/g; s/PKB/IOB/g;'
This commit is contained in:
Michael Brown
2007-05-19 18:39:40 +00:00
parent 7c0a069f42
commit 3e2c6b6736
25 changed files with 429 additions and 665 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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 );

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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

View File

@@ -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 );

View File

@@ -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 */