Преглед на файлове

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;'
tags/v0.9.3
Michael Brown преди 17 години
родител
ревизия
3e2c6b6736

+ 27
- 27
src/arch/i386/drivers/net/undinet.c Целия файл

@@ -22,7 +22,7 @@
22 22
 #include <pic8259.h>
23 23
 #include <biosint.h>
24 24
 #include <pnpbios.h>
25
-#include <gpxe/pkbuff.h>
25
+#include <gpxe/iobuf.h>
26 26
 #include <gpxe/netdevice.h>
27 27
 #include <gpxe/if_ether.h>
28 28
 #include <gpxe/ethernet.h>
@@ -315,11 +315,11 @@ static int undinet_isr_triggered ( void ) {
315 315
  */
316 316
 
317 317
 /** Maximum length of a packet transmitted via the UNDI API */
318
-#define UNDI_PKB_LEN 1514
318
+#define UNDI_IOB_LEN 1514
319 319
 
320
-/** UNDI packet buffer */
321
-static char __data16_array ( undinet_pkb, [UNDI_PKB_LEN] );
322
-#define undinet_pkb __use_data16 ( undinet_pkb )
320
+/** UNDI I/O buffer */
321
+static char __data16_array ( undinet_iob, [UNDI_IOB_LEN] );
322
+#define undinet_iob __use_data16 ( undinet_iob )
323 323
 
324 324
 /** UNDI transmit buffer descriptor */
325 325
 static struct s_PXENV_UNDI_TBD __data16 ( undinet_tbd );
@@ -329,20 +329,20 @@ static struct s_PXENV_UNDI_TBD __data16 ( undinet_tbd );
329 329
  * Transmit packet
330 330
  *
331 331
  * @v netdev		Network device
332
- * @v pkb		Packet buffer
332
+ * @v iobuf		I/O buffer
333 333
  * @ret rc		Return status code
334 334
  */
335 335
 static int undinet_transmit ( struct net_device *netdev,
336
-			      struct pk_buff *pkb ) {
336
+			      struct io_buffer *iobuf ) {
337 337
 	struct undi_nic *undinic = netdev->priv;
338 338
 	struct s_PXENV_UNDI_TRANSMIT undi_transmit;
339
-	size_t len = pkb_len ( pkb );
339
+	size_t len = iob_len ( iobuf );
340 340
 	int rc;
341 341
 
342
-	/* Copy packet to UNDI packet buffer */
343
-	if ( len > sizeof ( undinet_pkb ) )
344
-		len = sizeof ( undinet_pkb );
345
-	memcpy ( &undinet_pkb, pkb->data, len );
342
+	/* Copy packet to UNDI I/O buffer */
343
+	if ( len > sizeof ( undinet_iob ) )
344
+		len = sizeof ( undinet_iob );
345
+	memcpy ( &undinet_iob, iobuf->data, len );
346 346
 
347 347
 	/* Create PXENV_UNDI_TRANSMIT data structure */
348 348
 	memset ( &undi_transmit, 0, sizeof ( undi_transmit ) );
@@ -357,7 +357,7 @@ static int undinet_transmit ( struct net_device *netdev,
357 357
 	undinet_tbd.ImmedLength = len;
358 358
 	undinet_tbd.Xmit.segment = rm_ds;
359 359
 	undinet_tbd.Xmit.offset 
360
-		= ( ( unsigned ) & __from_data16 ( undinet_pkb ) );
360
+		= ( ( unsigned ) & __from_data16 ( undinet_iob ) );
361 361
 
362 362
 	/* Issue PXE API call */
363 363
 	if ( ( rc = undinet_call ( undinic, PXENV_UNDI_TRANSMIT,
@@ -365,8 +365,8 @@ static int undinet_transmit ( struct net_device *netdev,
365 365
 				   sizeof ( undi_transmit ) ) ) != 0 )
366 366
 		goto done;
367 367
 
368
-	/* Free packet buffer */
369
-	netdev_tx_complete ( netdev, pkb );
368
+	/* Free I/O buffer */
369
+	netdev_tx_complete ( netdev, iobuf );
370 370
 
371 371
  done:
372 372
 	return rc;
@@ -397,7 +397,7 @@ static int undinet_transmit ( struct net_device *netdev,
397 397
 static void undinet_poll ( struct net_device *netdev, unsigned int rx_quota ) {
398 398
 	struct undi_nic *undinic = netdev->priv;
399 399
 	struct s_PXENV_UNDI_ISR undi_isr;
400
-	struct pk_buff *pkb = NULL;
400
+	struct io_buffer *iobuf = NULL;
401 401
 	size_t len;
402 402
 	size_t frag_len;
403 403
 	int rc;
@@ -448,26 +448,26 @@ static void undinet_poll ( struct net_device *netdev, unsigned int rx_quota ) {
448 448
 			/* Packet fragment received */
449 449
 			len = undi_isr.FrameLength;
450 450
 			frag_len = undi_isr.BufferLength;
451
-			if ( ! pkb )
452
-				pkb = alloc_pkb ( len );
453
-			if ( ! pkb ) {
451
+			if ( ! iobuf )
452
+				iobuf = alloc_iob ( len );
453
+			if ( ! iobuf ) {
454 454
 				DBGC ( undinic, "UNDINIC %p could not "
455 455
 				       "allocate %zd bytes for RX buffer\n",
456 456
 				       undinic, len );
457 457
 				/* Fragment will be dropped */
458 458
 				goto done;
459 459
 			}
460
-			if ( frag_len > pkb_tailroom ( pkb ) ) {
460
+			if ( frag_len > iob_tailroom ( iobuf ) ) {
461 461
 				DBGC ( undinic, "UNDINIC %p fragment too "
462 462
 				       "large\n", undinic );
463
-				frag_len = pkb_tailroom ( pkb );
463
+				frag_len = iob_tailroom ( iobuf );
464 464
 			}
465
-			copy_from_real ( pkb_put ( pkb, frag_len ),
465
+			copy_from_real ( iob_put ( iobuf, frag_len ),
466 466
 					 undi_isr.Frame.segment,
467 467
 					 undi_isr.Frame.offset, frag_len );
468
-			if ( pkb_len ( pkb ) == len ) {
469
-				netdev_rx ( netdev, pkb );
470
-				pkb = NULL;
468
+			if ( iob_len ( iobuf ) == len ) {
469
+				netdev_rx ( netdev, iobuf );
470
+				iobuf = NULL;
471 471
 				--rx_quota;
472 472
 			}
473 473
 			break;
@@ -486,10 +486,10 @@ static void undinet_poll ( struct net_device *netdev, unsigned int rx_quota ) {
486 486
 	}
487 487
 
488 488
  done:
489
-	if ( pkb ) {
489
+	if ( iobuf ) {
490 490
 		DBGC ( undinic, "UNDINIC %p returned incomplete packet\n",
491 491
 		       undinic );
492
-		netdev_rx ( netdev, pkb );
492
+		netdev_rx ( netdev, iobuf );
493 493
 	}
494 494
 }
495 495
 

+ 15
- 15
src/drivers/net/legacy.c Целия файл

@@ -4,7 +4,7 @@
4 4
 #include <gpxe/if_ether.h>
5 5
 #include <gpxe/netdevice.h>
6 6
 #include <gpxe/ethernet.h>
7
-#include <gpxe/pkbuff.h>
7
+#include <gpxe/iobuf.h>
8 8
 #include <nic.h>
9 9
 
10 10
 /*
@@ -21,38 +21,38 @@ struct nic nic;
21 21
 
22 22
 static int legacy_registered = 0;
23 23
 
24
-static int legacy_transmit ( struct net_device *netdev, struct pk_buff *pkb ) {
24
+static int legacy_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) {
25 25
 	struct nic *nic = netdev->priv;
26
-	struct ethhdr *ethhdr = pkb->data;
26
+	struct ethhdr *ethhdr = iobuf->data;
27 27
 
28
-	DBG ( "Transmitting %d bytes\n", pkb_len ( pkb ) );
29
-	pkb_pad ( pkb, ETH_ZLEN );
30
-	pkb_pull ( pkb, sizeof ( *ethhdr ) );
28
+	DBG ( "Transmitting %d bytes\n", iob_len ( iobuf ) );
29
+	iob_pad ( iobuf, ETH_ZLEN );
30
+	iob_pull ( iobuf, sizeof ( *ethhdr ) );
31 31
 	nic->nic_op->transmit ( nic, ( const char * ) ethhdr->h_dest,
32 32
 				ntohs ( ethhdr->h_protocol ),
33
-				pkb_len ( pkb ), pkb->data );
34
-	netdev_tx_complete ( netdev, pkb );
33
+				iob_len ( iobuf ), iobuf->data );
34
+	netdev_tx_complete ( netdev, iobuf );
35 35
 	return 0;
36 36
 }
37 37
 
38 38
 static void legacy_poll ( struct net_device *netdev, unsigned int rx_quota ) {
39 39
 	struct nic *nic = netdev->priv;
40
-	struct pk_buff *pkb;
40
+	struct io_buffer *iobuf;
41 41
 
42 42
 	if ( ! rx_quota )
43 43
 		return;
44 44
 
45
-	pkb = alloc_pkb ( ETH_FRAME_LEN );
46
-	if ( ! pkb )
45
+	iobuf = alloc_iob ( ETH_FRAME_LEN );
46
+	if ( ! iobuf )
47 47
 		return;
48 48
 
49
-	nic->packet = pkb->data;
49
+	nic->packet = iobuf->data;
50 50
 	if ( nic->nic_op->poll ( nic, 1 ) ) {
51 51
 		DBG ( "Received %d bytes\n", nic->packetlen );
52
-		pkb_put ( pkb, nic->packetlen );
53
-		netdev_rx ( netdev, pkb );
52
+		iob_put ( iobuf, nic->packetlen );
53
+		netdev_rx ( netdev, iobuf );
54 54
 	} else {
55
-		free_pkb ( pkb );
55
+		free_iob ( iobuf );
56 56
 	}
57 57
 }
58 58
 

+ 12
- 12
src/drivers/net/pnic.c Целия файл

@@ -19,7 +19,7 @@ Bochs Pseudo NIC driver for Etherboot
19 19
 #include <gpxe/pci.h>
20 20
 #include <gpxe/if_ether.h>
21 21
 #include <gpxe/ethernet.h>
22
-#include <gpxe/pkbuff.h>
22
+#include <gpxe/iobuf.h>
23 23
 #include <gpxe/netdevice.h>
24 24
 
25 25
 #include "pnic_api.h"
@@ -114,7 +114,7 @@ POLL - Wait for a frame
114 114
 ***************************************************************************/
115 115
 static void pnic_poll ( struct net_device *netdev, unsigned int rx_quota ) {
116 116
 	struct pnic *pnic = netdev->priv;
117
-	struct pk_buff *pkb;
117
+	struct io_buffer *iobuf;
118 118
 	uint16_t length;
119 119
 	uint16_t qlen;
120 120
 
@@ -126,19 +126,19 @@ static void pnic_poll ( struct net_device *netdev, unsigned int rx_quota ) {
126 126
 			break;
127 127
 		if ( qlen == 0 )
128 128
 			break;
129
-		pkb = alloc_pkb ( ETH_FRAME_LEN );
130
-		if ( ! pkb ) {
129
+		iobuf = alloc_iob ( ETH_FRAME_LEN );
130
+		if ( ! iobuf ) {
131 131
 			printf ( "could not allocate buffer\n" );
132 132
 			break;
133 133
 		}
134 134
 		if ( pnic_command ( pnic, PNIC_CMD_RECV, NULL, 0,
135
-				    pkb->data, ETH_FRAME_LEN, &length )
135
+				    iobuf->data, ETH_FRAME_LEN, &length )
136 136
 		     != PNIC_STATUS_OK ) {
137
-			free_pkb ( pkb );
137
+			free_iob ( iobuf );
138 138
 			break;
139 139
 		}
140
-		pkb_put ( pkb, length );
141
-		netdev_rx ( netdev, pkb );
140
+		iob_put ( iobuf, length );
141
+		netdev_rx ( netdev, iobuf );
142 142
 		--rx_quota;
143 143
 	}
144 144
 }
@@ -146,17 +146,17 @@ static void pnic_poll ( struct net_device *netdev, unsigned int rx_quota ) {
146 146
 /**************************************************************************
147 147
 TRANSMIT - Transmit a frame
148 148
 ***************************************************************************/
149
-static int pnic_transmit ( struct net_device *netdev, struct pk_buff *pkb ) {
149
+static int pnic_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) {
150 150
 	struct pnic *pnic = netdev->priv;
151 151
 
152 152
 	/* Pad the packet */
153
-	pkb_pad ( pkb, ETH_ZLEN );
153
+	iob_pad ( iobuf, ETH_ZLEN );
154 154
 
155 155
 	/* Send packet */
156
-	pnic_command ( pnic, PNIC_CMD_XMIT, pkb->data, pkb_len ( pkb ),
156
+	pnic_command ( pnic, PNIC_CMD_XMIT, iobuf->data, iob_len ( iobuf ),
157 157
 		       NULL, 0, NULL );
158 158
 
159
-	netdev_tx_complete ( netdev, pkb );
159
+	netdev_tx_complete ( netdev, iobuf );
160 160
 	return 0;
161 161
 }
162 162
 

+ 19
- 19
src/drivers/net/rtl8139.c Целия файл

@@ -76,7 +76,7 @@
76 76
 #include <gpxe/pci.h>
77 77
 #include <gpxe/if_ether.h>
78 78
 #include <gpxe/ethernet.h>
79
-#include <gpxe/pkbuff.h>
79
+#include <gpxe/iobuf.h>
80 80
 #include <gpxe/netdevice.h>
81 81
 #include <gpxe/spi_bit.h>
82 82
 #include <gpxe/threewire.h>
@@ -86,7 +86,7 @@
86 86
 
87 87
 struct rtl8139_tx {
88 88
 	unsigned int next;
89
-	struct pk_buff *pkb[TX_RING_SIZE];
89
+	struct io_buffer *iobuf[TX_RING_SIZE];
90 90
 };
91 91
 
92 92
 struct rtl8139_rx {
@@ -363,28 +363,28 @@ static void rtl_close ( struct net_device *netdev ) {
363 363
  * Transmit packet
364 364
  *
365 365
  * @v netdev	Network device
366
- * @v pkb	Packet buffer
366
+ * @v iobuf	I/O buffer
367 367
  * @ret rc	Return status code
368 368
  */
369
-static int rtl_transmit ( struct net_device *netdev, struct pk_buff *pkb ) {
369
+static int rtl_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) {
370 370
 	struct rtl8139_nic *rtl = netdev->priv;
371 371
 
372 372
 	/* Check for space in TX ring */
373
-	if ( rtl->tx.pkb[rtl->tx.next] != NULL ) {
373
+	if ( rtl->tx.iobuf[rtl->tx.next] != NULL ) {
374 374
 		printf ( "TX overflow\n" );
375 375
 		return -ENOBUFS;
376 376
 	}
377 377
 
378 378
 	/* Pad and align packet */
379
-	pkb_pad ( pkb, ETH_ZLEN );
379
+	iob_pad ( iobuf, ETH_ZLEN );
380 380
 
381 381
 	/* Add to TX ring */
382 382
 	DBG ( "TX id %d at %lx+%x\n", rtl->tx.next,
383
-	      virt_to_bus ( pkb->data ), pkb_len ( pkb ) );
384
-	rtl->tx.pkb[rtl->tx.next] = pkb;
385
-	outl ( virt_to_bus ( pkb->data ),
383
+	      virt_to_bus ( iobuf->data ), iob_len ( iobuf ) );
384
+	rtl->tx.iobuf[rtl->tx.next] = iobuf;
385
+	outl ( virt_to_bus ( iobuf->data ),
386 386
 	       rtl->ioaddr + TxAddr0 + 4 * rtl->tx.next );
387
-	outl ( ( ( ( TX_FIFO_THRESH & 0x7e0 ) << 11 ) | pkb_len ( pkb ) ),
387
+	outl ( ( ( ( TX_FIFO_THRESH & 0x7e0 ) << 11 ) | iob_len ( iobuf ) ),
388 388
 	       rtl->ioaddr + TxStatus0 + 4 * rtl->tx.next );
389 389
 	rtl->tx.next = ( rtl->tx.next + 1 ) % TX_RING_SIZE;
390 390
 
@@ -403,7 +403,7 @@ static void rtl_poll ( struct net_device *netdev, unsigned int rx_quota ) {
403 403
 	unsigned int tsad;
404 404
 	unsigned int rx_status;
405 405
 	unsigned int rx_len;
406
-	struct pk_buff *rx_pkb;
406
+	struct io_buffer *rx_iob;
407 407
 	int wrapped_len;
408 408
 	int i;
409 409
 
@@ -416,10 +416,10 @@ static void rtl_poll ( struct net_device *netdev, unsigned int rx_quota ) {
416 416
 	/* Handle TX completions */
417 417
 	tsad = inw ( rtl->ioaddr + TxSummary );
418 418
 	for ( i = 0 ; i < TX_RING_SIZE ; i++ ) {
419
-		if ( ( rtl->tx.pkb[i] != NULL ) && ( tsad & ( 1 << i ) ) ) {
419
+		if ( ( rtl->tx.iobuf[i] != NULL ) && ( tsad & ( 1 << i ) ) ) {
420 420
 			DBG ( "TX id %d complete\n", i );
421
-			netdev_tx_complete ( netdev, rtl->tx.pkb[i] );
422
-			rtl->tx.pkb[i] = NULL;
421
+			netdev_tx_complete ( netdev, rtl->tx.iobuf[i] );
422
+			rtl->tx.iobuf[i] = NULL;
423 423
 		}
424 424
 	}
425 425
 
@@ -433,8 +433,8 @@ static void rtl_poll ( struct net_device *netdev, unsigned int rx_quota ) {
433 433
 			DBG ( "RX packet at offset %x+%x\n", rtl->rx.offset,
434 434
 			      rx_len );
435 435
 
436
-			rx_pkb = alloc_pkb ( rx_len );
437
-			if ( ! rx_pkb ) {
436
+			rx_iob = alloc_iob ( rx_len );
437
+			if ( ! rx_iob ) {
438 438
 				/* Leave packet for next call to poll() */
439 439
 				break;
440 440
 			}
@@ -444,13 +444,13 @@ static void rtl_poll ( struct net_device *netdev, unsigned int rx_quota ) {
444 444
 			if ( wrapped_len < 0 )
445 445
 				wrapped_len = 0;
446 446
 
447
-			memcpy ( pkb_put ( rx_pkb, rx_len - wrapped_len ),
447
+			memcpy ( iob_put ( rx_iob, rx_len - wrapped_len ),
448 448
 				 rtl->rx.ring + rtl->rx.offset + 4,
449 449
 				 rx_len - wrapped_len );
450
-			memcpy ( pkb_put ( rx_pkb, wrapped_len ),
450
+			memcpy ( iob_put ( rx_iob, wrapped_len ),
451 451
 				 rtl->rx.ring, wrapped_len );
452 452
 
453
-			netdev_rx ( netdev, rx_pkb );
453
+			netdev_rx ( netdev, rx_iob );
454 454
 			rx_quota--;
455 455
 		} else {
456 456
 			DBG ( "RX bad packet (status %#04x len %d)\n",

+ 4
- 4
src/include/gpxe/ip.h Целия файл

@@ -25,7 +25,7 @@
25 25
 #define IP_TOS		0
26 26
 #define IP_TTL		64
27 27
 
28
-#define IP_FRAG_PKB_SIZE	1500
28
+#define IP_FRAG_IOB_SIZE	1500
29 29
 #define IP_FRAG_TIMEOUT		50
30 30
 
31 31
 /* IP4 pseudo header */
@@ -63,15 +63,15 @@ struct frag_buffer {
63 63
 	struct in_addr src;
64 64
 	/* Destination network address */
65 65
 	struct in_addr dest;
66
-	/* Reassembled packet buffer */
67
-	struct pk_buff *frag_pkb;
66
+	/* Reassembled I/O buffer */
67
+	struct io_buffer *frag_iob;
68 68
 	/* Reassembly timer */
69 69
 	struct retry_timer frag_timer;
70 70
 	/* List of fragment reassembly buffers */
71 71
 	struct list_head list;
72 72
 };
73 73
 
74
-struct pk_buff;
74
+struct io_buffer;
75 75
 struct net_device;
76 76
 struct net_protocol;
77 77
 struct tcpip_protocol;

+ 5
- 5
src/include/gpxe/ip6.h Целия файл

@@ -16,12 +16,12 @@
16 16
 #define IP6_HOP_LIMIT	255
17 17
 
18 18
 /**
19
- * Packet buffer contents
20
- * This is duplicated in tcp.h and here. Ideally it should go into pkbuff.h
19
+ * I/O buffer contents
20
+ * This is duplicated in tcp.h and here. Ideally it should go into iobuf.h
21 21
  */
22 22
 #define MAX_HDR_LEN	100
23
-#define MAX_PKB_LEN	1500
24
-#define MIN_PKB_LEN	MAX_HDR_LEN + 100 /* To account for padding by LL */
23
+#define MAX_IOB_LEN	1500
24
+#define MIN_IOB_LEN	MAX_HDR_LEN + 100 /* To account for padding by LL */
25 25
 
26 26
 #define IP6_EQUAL( in6_addr1, in6_addr2 ) \
27 27
         ( strncmp ( ( char* ) &( in6_addr1 ), ( char* ) &( in6_addr2 ),\
@@ -61,7 +61,7 @@ struct ipv6_pseudo_header {
61 61
 #define IP6_ICMP6		0x58
62 62
 #define IP6_NO_HEADER		0x59
63 63
 
64
-struct pk_buff;
64
+struct io_buffer;
65 65
 struct net_device;
66 66
 struct net_protocol;
67 67
 

+ 2
- 2
src/include/gpxe/ndp.h Целия файл

@@ -6,7 +6,7 @@
6 6
 #include <gpxe/ip6.h>
7 7
 #include <gpxe/in.h>
8 8
 #include <gpxe/netdevice.h>
9
-#include <gpxe/pkbuff.h>
9
+#include <gpxe/iobuf.h>
10 10
 #include <gpxe/tcpip.h>
11 11
 
12 12
 #define NDP_STATE_INVALID 0
@@ -19,5 +19,5 @@
19 19
 static struct ndp_entry * ndp_find_entry ( struct in6_addr *in6 );
20 20
 int ndp_resolve ( struct net_device *netdev, struct in6_addr *src,
21 21
 		  struct in6_addr *dest, void *dest_ll_addr );
22
-int ndp_process_advert ( struct pk_buff *pkb, struct sockaddr_tcpip *st_src,
22
+int ndp_process_advert ( struct io_buffer *iobuf, struct sockaddr_tcpip *st_src,
23 23
 			 struct sockaddr_tcpip *st_dest );

+ 21
- 21
src/include/gpxe/netdevice.h Целия файл

@@ -12,7 +12,7 @@
12 12
 #include <gpxe/tables.h>
13 13
 #include <gpxe/hotplug.h>
14 14
 
15
-struct pk_buff;
15
+struct io_buffer;
16 16
 struct net_device;
17 17
 struct net_protocol;
18 18
 struct ll_protocol;
@@ -37,13 +37,13 @@ struct net_protocol {
37 37
 	/**
38 38
 	 * Process received packet
39 39
 	 *
40
-	 * @v pkb	Packet buffer
40
+	 * @v iobuf	I/O buffer
41 41
 	 * @v netdev	Network device
42 42
 	 * @v ll_source	Link-layer source address
43 43
 	 *
44
-	 * This method takes ownership of the packet buffer.
44
+	 * This method takes ownership of the I/O buffer.
45 45
 	 */
46
-	int ( * rx ) ( struct pk_buff *pkb, struct net_device *netdev,
46
+	int ( * rx ) ( struct io_buffer *iobuf, struct net_device *netdev,
47 47
 		       const void *ll_source );
48 48
 	/**
49 49
 	 * Transcribe network-layer address
@@ -77,7 +77,7 @@ struct ll_protocol {
77 77
 	/**
78 78
 	 * Transmit network-layer packet via network device
79 79
 	 *
80
-	 * @v pkb		Packet buffer
80
+	 * @v iobuf		I/O buffer
81 81
 	 * @v netdev		Network device
82 82
 	 * @v net_protocol	Network-layer protocol
83 83
 	 * @v ll_dest		Link-layer destination address
@@ -85,15 +85,15 @@ struct ll_protocol {
85 85
 	 *
86 86
 	 * This method should prepend in the link-layer header
87 87
 	 * (e.g. the Ethernet DIX header) and transmit the packet.
88
-	 * This method takes ownership of the packet buffer.
88
+	 * This method takes ownership of the I/O buffer.
89 89
 	 */
90
-	int ( * tx ) ( struct pk_buff *pkb, struct net_device *netdev,
90
+	int ( * tx ) ( struct io_buffer *iobuf, struct net_device *netdev,
91 91
 		       struct net_protocol *net_protocol,
92 92
 		       const void *ll_dest );
93 93
 	/**
94 94
 	 * Handle received packet
95 95
 	 *
96
-	 * @v pkb	Packet buffer
96
+	 * @v iobuf	I/O buffer
97 97
 	 * @v netdev	Network device
98 98
 	 *
99 99
 	 * This method should strip off the link-layer header
@@ -101,7 +101,7 @@ struct ll_protocol {
101 101
 	 * net_rx().  This method takes ownership of the packet
102 102
 	 * buffer.
103 103
 	 */
104
-	int ( * rx ) ( struct pk_buff *pkb, struct net_device *netdev );
104
+	int ( * rx ) ( struct io_buffer *iobuf, struct net_device *netdev );
105 105
 	/**
106 106
 	 * Transcribe link-layer address
107 107
 	 *
@@ -151,7 +151,7 @@ struct net_device {
151 151
 	 * @v netdev	Network device
152 152
 	 * @ret rc	Return status code
153 153
 	 *
154
-	 * This method should allocate RX packet buffers and enable
154
+	 * This method should allocate RX I/O buffers and enable
155 155
 	 * the hardware to start transmitting and receiving packets.
156 156
 	 */
157 157
 	int ( * open ) ( struct net_device *netdev );
@@ -166,22 +166,22 @@ struct net_device {
166 166
 	/** Transmit packet
167 167
 	 *
168 168
 	 * @v netdev	Network device
169
-	 * @v pkb	Packet buffer
169
+	 * @v iobuf	I/O buffer
170 170
 	 * @ret rc	Return status code
171 171
 	 *
172 172
 	 * This method should cause the hardware to initiate
173
-	 * transmission of the packet buffer.
173
+	 * transmission of the I/O buffer.
174 174
 	 *
175
-	 * If this method returns success, the packet buffer remains
175
+	 * If this method returns success, the I/O buffer remains
176 176
 	 * owned by the net device's TX queue, and the net device must
177 177
 	 * eventually call netdev_tx_complete() to free the buffer.
178
-	 * If this method returns failure, the packet buffer is
178
+	 * If this method returns failure, the I/O buffer is
179 179
 	 * immediately released.
180 180
 	 *
181 181
 	 * This method is guaranteed to be called only when the device
182 182
 	 * is open.
183 183
 	 */
184
-	int ( * transmit ) ( struct net_device *netdev, struct pk_buff *pkb );
184
+	int ( * transmit ) ( struct net_device *netdev, struct io_buffer *iobuf );
185 185
 	/** Poll for received packet
186 186
 	 *
187 187
 	 * @v netdev	Network device
@@ -251,12 +251,12 @@ static inline int have_netdevs ( void ) {
251 251
 	return ( ! list_empty ( &net_devices ) );
252 252
 }
253 253
 
254
-extern int netdev_tx ( struct net_device *netdev, struct pk_buff *pkb );
255
-void netdev_tx_complete ( struct net_device *netdev, struct pk_buff *pkb );
254
+extern int netdev_tx ( struct net_device *netdev, struct io_buffer *iobuf );
255
+void netdev_tx_complete ( struct net_device *netdev, struct io_buffer *iobuf );
256 256
 void netdev_tx_complete_next ( struct net_device *netdev );
257
-extern void netdev_rx ( struct net_device *netdev, struct pk_buff *pkb );
257
+extern void netdev_rx ( struct net_device *netdev, struct io_buffer *iobuf );
258 258
 extern int netdev_poll ( struct net_device *netdev, unsigned int rx_quota );
259
-extern struct pk_buff * netdev_rx_dequeue ( struct net_device *netdev );
259
+extern struct io_buffer * netdev_rx_dequeue ( struct net_device *netdev );
260 260
 extern struct net_device * alloc_netdev ( size_t priv_size );
261 261
 extern int register_netdev ( struct net_device *netdev );
262 262
 extern int netdev_open ( struct net_device *netdev );
@@ -266,9 +266,9 @@ extern void free_netdev ( struct net_device *netdev );
266 266
 struct net_device * find_netdev ( const char *name );
267 267
 struct net_device * find_pci_netdev ( unsigned int busdevfn );
268 268
 
269
-extern int net_tx ( struct pk_buff *pkb, struct net_device *netdev,
269
+extern int net_tx ( struct io_buffer *iobuf, struct net_device *netdev,
270 270
 		    struct net_protocol *net_protocol, const void *ll_dest );
271
-extern int net_rx ( struct pk_buff *pkb, struct net_device *netdev,
271
+extern int net_rx ( struct io_buffer *iobuf, struct net_device *netdev,
272 272
 		    uint16_t net_proto, const void *ll_source );
273 273
 
274 274
 #endif /* _GPXE_NETDEVICE_H */

+ 0
- 163
src/include/gpxe/pkbuff.h Целия файл

@@ -1,163 +0,0 @@
1
-#ifndef _GPXE_PKBUFF_H
2
-#define _GPXE_PKBUFF_H
3
-
4
-/** @file
5
- *
6
- * Packet buffers
7
- *
8
- * Packet buffers are used to contain network packets.  Methods are
9
- * provided for appending, prepending, etc. data.
10
- *
11
- */
12
-
13
-#include <stdint.h>
14
-#include <assert.h>
15
-#include <gpxe/list.h>
16
-
17
-/**
18
- * Packet buffer alignment
19
- *
20
- * Packet buffers allocated via alloc_pkb() are guaranteed to be
21
- * physically aligned to this boundary.  Some cards cannot DMA across
22
- * a 4kB boundary.  With a standard Ethernet MTU, aligning to a 2kB
23
- * boundary is sufficient to guarantee no 4kB boundary crossings.  For
24
- * a jumbo Ethernet MTU, a packet may be larger than 4kB anyway.
25
- */
26
-#define PKBUFF_ALIGN 2048
27
-
28
-/**
29
- * Minimum packet buffer length
30
- *
31
- * alloc_pkb() will round up the allocated length to this size if
32
- * necessary.  This is used on behalf of hardware that is not capable
33
- * of auto-padding.
34
- */
35
-#define PKB_ZLEN 64
36
-
37
-/** A packet buffer
38
- *
39
- * This structure is used to represent a network packet within gPXE.
40
- */
41
-struct pk_buff {
42
-	/** List of which this buffer is a member */
43
-	struct list_head list;
44
-
45
-	/** Start of the buffer */
46
-	void *head;
47
-	/** Start of data */
48
-	void *data;
49
-	/** End of data */
50
-	void *tail;
51
-	/** End of the buffer */
52
-        void *end;
53
-};
54
-
55
-/**
56
- * Reserve space at start of packet buffer
57
- *
58
- * @v pkb	Packet buffer
59
- * @v len	Length to reserve
60
- * @ret data	Pointer to new start of buffer
61
- */
62
-static inline void * pkb_reserve ( struct pk_buff *pkb, size_t len ) {
63
-	pkb->data += len;
64
-	pkb->tail += len;
65
-	assert ( pkb->tail <= pkb->end );
66
-	return pkb->data;
67
-}
68
-
69
-/**
70
- * Add data to start of packet buffer
71
- *
72
- * @v pkb	Packet buffer
73
- * @v len	Length to add
74
- * @ret data	Pointer to new start of buffer
75
- */
76
-static inline void * pkb_push ( struct pk_buff *pkb, size_t len ) {
77
-	pkb->data -= len;
78
-	assert ( pkb->data >= pkb->head );
79
-	return pkb->data;
80
-}
81
-
82
-/**
83
- * Remove data from start of packet buffer
84
- *
85
- * @v pkb	Packet buffer
86
- * @v len	Length to remove
87
- * @ret data	Pointer to new start of buffer
88
- */
89
-static inline void * pkb_pull ( struct pk_buff *pkb, size_t len ) {
90
-	pkb->data += len;
91
-	assert ( pkb->data <= pkb->tail );
92
-	return pkb->data;
93
-}
94
-
95
-/**
96
- * Add data to end of packet buffer
97
- *
98
- * @v pkb	Packet buffer
99
- * @v len	Length to add
100
- * @ret data	Pointer to newly added space
101
- */
102
-static inline void * pkb_put ( struct pk_buff *pkb, size_t len ) {
103
-	void *old_tail = pkb->tail;
104
-	pkb->tail += len;
105
-	assert ( pkb->tail <= pkb->end );
106
-	return old_tail;
107
-}
108
-
109
-/**
110
- * Remove data from end of packet buffer
111
- *
112
- * @v pkb	Packet buffer
113
- * @v len	Length to remove
114
- */
115
-static inline void pkb_unput ( struct pk_buff *pkb, size_t len ) {
116
-	pkb->tail -= len;
117
-	assert ( pkb->tail >= pkb->data );
118
-}
119
-
120
-/**
121
- * Empty a packet buffer
122
- *
123
- * @v pkb	Packet buffer
124
- */
125
-static inline void pkb_empty ( struct pk_buff *pkb ) {
126
-	pkb->tail = pkb->data;
127
-}
128
-
129
-/**
130
- * Calculate length of data in a packet buffer
131
- *
132
- * @v pkb	Packet buffer
133
- * @ret len	Length of data in buffer
134
- */
135
-static inline size_t pkb_len ( struct pk_buff *pkb ) {
136
-	return ( pkb->tail - pkb->data );
137
-}
138
-
139
-/**
140
- * Calculate available space at start of a packet buffer
141
- *
142
- * @v pkb	Packet buffer
143
- * @ret len	Length of data available at start of buffer
144
- */
145
-static inline size_t pkb_headroom ( struct pk_buff *pkb ) {
146
-	return ( pkb->data - pkb->head );
147
-}
148
-
149
-/**
150
- * Calculate available space at end of a packet buffer
151
- *
152
- * @v pkb	Packet buffer
153
- * @ret len	Length of data available at end of buffer
154
- */
155
-static inline size_t pkb_tailroom ( struct pk_buff *pkb ) {
156
-	return ( pkb->end - pkb->tail );
157
-}
158
-
159
-extern struct pk_buff * alloc_pkb ( size_t len );
160
-extern void free_pkb ( struct pk_buff *pkb );
161
-extern void pkb_pad ( struct pk_buff *pkb, size_t min_len );
162
-
163
-#endif /* _GPXE_PKBUFF_H */

+ 3
- 3
src/include/gpxe/tcp.h Целия файл

@@ -206,10 +206,10 @@ struct tcp_mss_option {
206 206
 /** Smallest port number on which a TCP connection can listen */
207 207
 #define TCP_MIN_PORT 1
208 208
 
209
-/* Some PKB constants */
209
+/* Some IOB constants */
210 210
 #define MAX_HDR_LEN	100
211
-#define MAX_PKB_LEN	1500
212
-#define MIN_PKB_LEN	MAX_HDR_LEN + 100 /* To account for padding by LL */
211
+#define MAX_IOB_LEN	1500
212
+#define MIN_IOB_LEN	MAX_HDR_LEN + 100 /* To account for padding by LL */
213 213
 
214 214
 /**
215 215
  * Maxmimum advertised TCP window size

+ 9
- 9
src/include/gpxe/tcpip.h Целия файл

@@ -12,7 +12,7 @@
12 12
 #include <gpxe/in.h>
13 13
 #include <gpxe/tables.h>
14 14
 
15
-struct pk_buff;
15
+struct io_buffer;
16 16
 struct net_device;
17 17
 
18 18
 /** Empty checksum value
@@ -51,15 +51,15 @@ struct tcpip_protocol {
51 51
        	/**
52 52
          * Process received packet
53 53
          *
54
-         * @v pkb		Packet buffer
54
+         * @v iobuf		I/O buffer
55 55
 	 * @v st_src		Partially-filled source address
56 56
 	 * @v st_dest		Partially-filled destination address
57 57
 	 * @v pshdr_csum	Pseudo-header checksum
58 58
 	 * @ret rc		Return status code
59 59
          *
60
-         * This method takes ownership of the packet buffer.
60
+         * This method takes ownership of the I/O buffer.
61 61
          */
62
-        int ( * rx ) ( struct pk_buff *pkb, struct sockaddr_tcpip *st_src,
62
+        int ( * rx ) ( struct io_buffer *iobuf, struct sockaddr_tcpip *st_src,
63 63
 		       struct sockaddr_tcpip *st_dest, uint16_t pshdr_csum );
64 64
         /** 
65 65
 	 * Transport-layer protocol number
@@ -80,16 +80,16 @@ struct tcpip_net_protocol {
80 80
 	/**
81 81
 	 * Transmit packet
82 82
 	 *
83
-	 * @v pkb		Packet buffer
83
+	 * @v iobuf		I/O buffer
84 84
 	 * @v tcpip_protocol	Transport-layer protocol
85 85
 	 * @v st_dest		Destination address
86 86
 	 * @v netdev		Network device (or NULL to route automatically)
87 87
 	 * @v trans_csum	Transport-layer checksum to complete, or NULL
88 88
 	 * @ret rc		Return status code
89 89
 	 *
90
-	 * This function takes ownership of the packet buffer.
90
+	 * This function takes ownership of the I/O buffer.
91 91
 	 */
92
-	int ( * tx ) ( struct pk_buff *pkb,
92
+	int ( * tx ) ( struct io_buffer *iobuf,
93 93
 		       struct tcpip_protocol *tcpip_protocol,
94 94
 		       struct sockaddr_tcpip *st_dest,
95 95
 		       struct net_device *netdev,
@@ -104,10 +104,10 @@ struct tcpip_net_protocol {
104 104
 #define	__tcpip_net_protocol \
105 105
 	__table ( struct tcpip_net_protocol, tcpip_net_protocols, 01 )
106 106
 
107
-extern int tcpip_rx ( struct pk_buff *pkb, uint8_t tcpip_proto,
107
+extern int tcpip_rx ( struct io_buffer *iobuf, uint8_t tcpip_proto,
108 108
 		      struct sockaddr_tcpip *st_src,
109 109
 		      struct sockaddr_tcpip *st_dest, uint16_t pshdr_csum );
110
-extern int tcpip_tx ( struct pk_buff *pkb, struct tcpip_protocol *tcpip, 
110
+extern int tcpip_tx ( struct io_buffer *iobuf, struct tcpip_protocol *tcpip, 
111 111
 		      struct sockaddr_tcpip *st_dest,
112 112
 		      struct net_device *netdev,
113 113
 		      uint16_t *trans_csum );

+ 4
- 4
src/include/gpxe/udp.h Целия файл

@@ -10,7 +10,7 @@
10 10
  */
11 11
 
12 12
 #include <stddef.h>
13
-#include <gpxe/pkbuff.h>
13
+#include <gpxe/iobuf.h>
14 14
 #include <gpxe/tcpip.h>
15 15
 #include <gpxe/if_ether.h>
16 16
 
@@ -21,8 +21,8 @@ struct net_device;
21 21
  */
22 22
 
23 23
 #define UDP_MAX_HLEN	72
24
-#define UDP_MAX_TXPKB	ETH_MAX_MTU
25
-#define UDP_MIN_TXPKB	ETH_ZLEN
24
+#define UDP_MAX_TXIOB	ETH_MAX_MTU
25
+#define UDP_MIN_TXIOB	ETH_ZLEN
26 26
 
27 27
 typedef uint16_t port_t;
28 28
 
@@ -86,7 +86,7 @@ struct udp_connection {
86 86
 	/** Local port on which the connection receives packets */
87 87
 	port_t local_port;
88 88
 	/** Transmit buffer */
89
-	struct pk_buff *tx_pkb;
89
+	struct io_buffer *tx_iob;
90 90
 	/** List of registered connections */
91 91
 	struct list_head list;
92 92
 	/** Operations table for this connection */

+ 15
- 15
src/net/aoe.c Целия файл

@@ -25,7 +25,7 @@
25 25
 #include <gpxe/list.h>
26 26
 #include <gpxe/if_ether.h>
27 27
 #include <gpxe/ethernet.h>
28
-#include <gpxe/pkbuff.h>
28
+#include <gpxe/iobuf.h>
29 29
 #include <gpxe/uaccess.h>
30 30
 #include <gpxe/ata.h>
31 31
 #include <gpxe/netdevice.h>
@@ -70,7 +70,7 @@ static void aoe_done ( struct aoe_session *aoe, int rc ) {
70 70
  */
71 71
 static int aoe_send_command ( struct aoe_session *aoe ) {
72 72
 	struct ata_command *command = aoe->command;
73
-	struct pk_buff *pkb;
73
+	struct io_buffer *iobuf;
74 74
 	struct aoehdr *aoehdr;
75 75
 	struct aoecmd *aoecmd;
76 76
 	unsigned int count;
@@ -88,14 +88,14 @@ static int aoe_send_command ( struct aoe_session *aoe ) {
88 88
 		count = AOE_MAX_COUNT;
89 89
 	data_out_len = ( command->data_out ? ( count * ATA_SECTOR_SIZE ) : 0 );
90 90
 
91
-	/* Create outgoing packet buffer */
92
-	pkb = alloc_pkb ( ETH_HLEN + sizeof ( *aoehdr ) + sizeof ( *aoecmd ) +
91
+	/* Create outgoing I/O buffer */
92
+	iobuf = alloc_iob ( ETH_HLEN + sizeof ( *aoehdr ) + sizeof ( *aoecmd ) +
93 93
 			  data_out_len );
94
-	if ( ! pkb )
94
+	if ( ! iobuf )
95 95
 		return -ENOMEM;
96
-	pkb_reserve ( pkb, ETH_HLEN );
97
-	aoehdr = pkb_put ( pkb, sizeof ( *aoehdr ) );
98
-	aoecmd = pkb_put ( pkb, sizeof ( *aoecmd ) );
96
+	iob_reserve ( iobuf, ETH_HLEN );
97
+	aoehdr = iob_put ( iobuf, sizeof ( *aoehdr ) );
98
+	aoecmd = iob_put ( iobuf, sizeof ( *aoecmd ) );
99 99
 	memset ( aoehdr, 0, ( sizeof ( *aoehdr ) + sizeof ( *aoecmd ) ) );
100 100
 
101 101
 	/* Fill AoE header */
@@ -117,12 +117,12 @@ static int aoe_send_command ( struct aoe_session *aoe ) {
117 117
 		aoecmd->lba.bytes[3] |= ( command->cb.device & ATA_DEV_MASK );
118 118
 
119 119
 	/* Fill data payload */
120
-	copy_from_user ( pkb_put ( pkb, data_out_len ), command->data_out,
120
+	copy_from_user ( iob_put ( iobuf, data_out_len ), command->data_out,
121 121
 			 aoe->command_offset, data_out_len );
122 122
 
123 123
 	/* Send packet */
124 124
 	start_timer ( &aoe->timer );
125
-	return net_tx ( pkb, aoe->netdev, &aoe_protocol, aoe->target );
125
+	return net_tx ( iobuf, aoe->netdev, &aoe_protocol, aoe->target );
126 126
 }
127 127
 
128 128
 /**
@@ -213,16 +213,16 @@ static int aoe_rx_response ( struct aoe_session *aoe, struct aoehdr *aoehdr,
213 213
 /**
214 214
  * Process incoming AoE packets
215 215
  *
216
- * @v pkb		Packet buffer
216
+ * @v iobuf		I/O buffer
217 217
  * @v netdev		Network device
218 218
  * @v ll_source		Link-layer source address
219 219
  * @ret rc		Return status code
220 220
  *
221 221
  */
222
-static int aoe_rx ( struct pk_buff *pkb, struct net_device *netdev __unused,
222
+static int aoe_rx ( struct io_buffer *iobuf, struct net_device *netdev __unused,
223 223
 		    const void *ll_source ) {
224
-	struct aoehdr *aoehdr = pkb->data;
225
-	unsigned int len = pkb_len ( pkb );
224
+	struct aoehdr *aoehdr = iobuf->data;
225
+	unsigned int len = iob_len ( iobuf );
226 226
 	struct aoe_session *aoe;
227 227
 	int rc = 0;
228 228
 
@@ -254,7 +254,7 @@ static int aoe_rx ( struct pk_buff *pkb, struct net_device *netdev __unused,
254 254
 	}
255 255
 
256 256
  done:
257
-	free_pkb ( pkb );
257
+	free_iob ( iobuf );
258 258
 	return rc;
259 259
 }
260 260
 

+ 17
- 17
src/net/arp.c Целия файл

@@ -22,7 +22,7 @@
22 22
 #include <errno.h>
23 23
 #include <gpxe/if_ether.h>
24 24
 #include <gpxe/if_arp.h>
25
-#include <gpxe/pkbuff.h>
25
+#include <gpxe/iobuf.h>
26 26
 #include <gpxe/netdevice.h>
27 27
 #include <gpxe/arp.h>
28 28
 
@@ -119,7 +119,7 @@ int arp_resolve ( struct net_device *netdev, struct net_protocol *net_protocol,
119 119
 		  void *dest_ll_addr ) {
120 120
 	struct ll_protocol *ll_protocol = netdev->ll_protocol;
121 121
 	const struct arp_entry *arp;
122
-	struct pk_buff *pkb;
122
+	struct io_buffer *iobuf;
123 123
 	struct arphdr *arphdr;
124 124
 	int rc;
125 125
 
@@ -136,30 +136,30 @@ int arp_resolve ( struct net_device *netdev, struct net_protocol *net_protocol,
136 136
 	      net_protocol->ntoa ( dest_net_addr ) );
137 137
 
138 138
 	/* Allocate ARP packet */
139
-	pkb = alloc_pkb ( MAX_LL_HEADER_LEN + sizeof ( *arphdr ) +
139
+	iobuf = alloc_iob ( MAX_LL_HEADER_LEN + sizeof ( *arphdr ) +
140 140
 			  2 * ( MAX_LL_ADDR_LEN + MAX_NET_ADDR_LEN ) );
141
-	if ( ! pkb )
141
+	if ( ! iobuf )
142 142
 		return -ENOMEM;
143
-	pkb_reserve ( pkb, MAX_LL_HEADER_LEN );
143
+	iob_reserve ( iobuf, MAX_LL_HEADER_LEN );
144 144
 
145 145
 	/* Build up ARP request */
146
-	arphdr = pkb_put ( pkb, sizeof ( *arphdr ) );
146
+	arphdr = iob_put ( iobuf, sizeof ( *arphdr ) );
147 147
 	arphdr->ar_hrd = ll_protocol->ll_proto;
148 148
 	arphdr->ar_hln = ll_protocol->ll_addr_len;
149 149
 	arphdr->ar_pro = net_protocol->net_proto;
150 150
 	arphdr->ar_pln = net_protocol->net_addr_len;
151 151
 	arphdr->ar_op = htons ( ARPOP_REQUEST );
152
-	memcpy ( pkb_put ( pkb, ll_protocol->ll_addr_len ),
152
+	memcpy ( iob_put ( iobuf, ll_protocol->ll_addr_len ),
153 153
 		 netdev->ll_addr, ll_protocol->ll_addr_len );
154
-	memcpy ( pkb_put ( pkb, net_protocol->net_addr_len ),
154
+	memcpy ( iob_put ( iobuf, net_protocol->net_addr_len ),
155 155
 		 source_net_addr, net_protocol->net_addr_len );
156
-	memset ( pkb_put ( pkb, ll_protocol->ll_addr_len ),
156
+	memset ( iob_put ( iobuf, ll_protocol->ll_addr_len ),
157 157
 		 0, ll_protocol->ll_addr_len );
158
-	memcpy ( pkb_put ( pkb, net_protocol->net_addr_len ),
158
+	memcpy ( iob_put ( iobuf, net_protocol->net_addr_len ),
159 159
 		 dest_net_addr, net_protocol->net_addr_len );
160 160
 
161 161
 	/* Transmit ARP request */
162
-	if ( ( rc = net_tx ( pkb, netdev, &arp_protocol, 
162
+	if ( ( rc = net_tx ( iobuf, netdev, &arp_protocol, 
163 163
 			     ll_protocol->ll_broadcast ) ) != 0 )
164 164
 		return rc;
165 165
 
@@ -188,7 +188,7 @@ static struct arp_net_protocol * arp_find_protocol ( uint16_t net_proto ) {
188 188
 /**
189 189
  * Process incoming ARP packets
190 190
  *
191
- * @v pkb		Packet buffer
191
+ * @v iobuf		I/O buffer
192 192
  * @v netdev		Network device
193 193
  * @v ll_source		Link-layer source address
194 194
  * @ret rc		Return status code
@@ -199,9 +199,9 @@ static struct arp_net_protocol * arp_find_protocol ( uint16_t net_proto ) {
199 199
  * avoiding the need for extraneous ARP requests; read the RFC for
200 200
  * details.
201 201
  */
202
-static int arp_rx ( struct pk_buff *pkb, struct net_device *netdev,
202
+static int arp_rx ( struct io_buffer *iobuf, struct net_device *netdev,
203 203
 		    const void *ll_source __unused ) {
204
-	struct arphdr *arphdr = pkb->data;
204
+	struct arphdr *arphdr = iobuf->data;
205 205
 	struct arp_net_protocol *arp_net_protocol;
206 206
 	struct net_protocol *net_protocol;
207 207
 	struct ll_protocol *ll_protocol;
@@ -265,11 +265,11 @@ static int arp_rx ( struct pk_buff *pkb, struct net_device *netdev,
265 265
 	memcpy ( arp_sender_ha ( arphdr ), netdev->ll_addr, arphdr->ar_hln );
266 266
 
267 267
 	/* Send reply */
268
-	net_tx ( pkb, netdev, &arp_protocol, arp_target_ha (arphdr ) );
269
-	pkb = NULL;
268
+	net_tx ( iobuf, netdev, &arp_protocol, arp_target_ha (arphdr ) );
269
+	iobuf = NULL;
270 270
 
271 271
  done:
272
-	free_pkb ( pkb );
272
+	free_iob ( iobuf );
273 273
 	return 0;
274 274
 }
275 275
 

+ 13
- 13
src/net/ethernet.c Целия файл

@@ -25,7 +25,7 @@
25 25
 #include <gpxe/if_arp.h>
26 26
 #include <gpxe/if_ether.h>
27 27
 #include <gpxe/netdevice.h>
28
-#include <gpxe/pkbuff.h>
28
+#include <gpxe/iobuf.h>
29 29
 #include <gpxe/ethernet.h>
30 30
 
31 31
 /** @file
@@ -40,16 +40,16 @@ static uint8_t eth_broadcast[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
40 40
 /**
41 41
  * Transmit Ethernet packet
42 42
  *
43
- * @v pkb		Packet buffer
43
+ * @v iobuf		I/O buffer
44 44
  * @v netdev		Network device
45 45
  * @v net_protocol	Network-layer protocol
46 46
  * @v ll_dest		Link-layer destination address
47 47
  *
48 48
  * Prepends the Ethernet link-layer header and transmits the packet.
49 49
  */
50
-static int eth_tx ( struct pk_buff *pkb, struct net_device *netdev,
50
+static int eth_tx ( struct io_buffer *iobuf, struct net_device *netdev,
51 51
 		    struct net_protocol *net_protocol, const void *ll_dest ) {
52
-	struct ethhdr *ethhdr = pkb_push ( pkb, sizeof ( *ethhdr ) );
52
+	struct ethhdr *ethhdr = iob_push ( iobuf, sizeof ( *ethhdr ) );
53 53
 
54 54
 	/* Build Ethernet header */
55 55
 	memcpy ( ethhdr->h_dest, ll_dest, ETH_ALEN );
@@ -57,34 +57,34 @@ static int eth_tx ( struct pk_buff *pkb, struct net_device *netdev,
57 57
 	ethhdr->h_protocol = net_protocol->net_proto;
58 58
 
59 59
 	/* Hand off to network device */
60
-	return netdev_tx ( netdev, pkb );
60
+	return netdev_tx ( netdev, iobuf );
61 61
 }
62 62
 
63 63
 /**
64 64
  * Process received Ethernet packet
65 65
  *
66
- * @v pkb	Packet buffer
66
+ * @v iobuf	I/O buffer
67 67
  * @v netdev	Network device
68 68
  *
69 69
  * Strips off the Ethernet link-layer header and passes up to the
70 70
  * network-layer protocol.
71 71
  */
72
-static int eth_rx ( struct pk_buff *pkb, struct net_device *netdev ) {
73
-	struct ethhdr *ethhdr = pkb->data;
72
+static int eth_rx ( struct io_buffer *iobuf, struct net_device *netdev ) {
73
+	struct ethhdr *ethhdr = iobuf->data;
74 74
 
75 75
 	/* Sanity check */
76
-	if ( pkb_len ( pkb ) < sizeof ( *ethhdr ) ) {
76
+	if ( iob_len ( iobuf ) < sizeof ( *ethhdr ) ) {
77 77
 		DBG ( "Ethernet packet too short (%d bytes)\n",
78
-		      pkb_len ( pkb ) );
79
-		free_pkb ( pkb );
78
+		      iob_len ( iobuf ) );
79
+		free_iob ( iobuf );
80 80
 		return -EINVAL;
81 81
 	}
82 82
 
83 83
 	/* Strip off Ethernet header */
84
-	pkb_pull ( pkb, sizeof ( *ethhdr ) );
84
+	iob_pull ( iobuf, sizeof ( *ethhdr ) );
85 85
 
86 86
 	/* Hand off to network-layer protocol */
87
-	return net_rx ( pkb, netdev, ethhdr->h_protocol, ethhdr->h_source );
87
+	return net_rx ( iobuf, netdev, ethhdr->h_protocol, ethhdr->h_source );
88 88
 }
89 89
 
90 90
 /**

+ 18
- 18
src/net/icmpv6.c Целия файл

@@ -5,7 +5,7 @@
5 5
 #include <gpxe/in.h>
6 6
 #include <gpxe/ip6.h>
7 7
 #include <gpxe/if_ether.h>
8
-#include <gpxe/pkbuff.h>
8
+#include <gpxe/iobuf.h>
9 9
 #include <gpxe/ndp.h>
10 10
 #include <gpxe/icmp6.h>
11 11
 #include <gpxe/tcpip.h>
@@ -31,9 +31,9 @@ int icmp6_send_solicit ( struct net_device *netdev, struct in6_addr *src __unuse
31 31
 	} st_dest;
32 32
 	struct ll_protocol *ll_protocol = netdev->ll_protocol;
33 33
 	struct neighbour_solicit *nsolicit;
34
-	struct pk_buff *pkb = alloc_pkb ( sizeof ( *nsolicit ) + MIN_PKB_LEN );
35
-	pkb_reserve ( pkb, MAX_HDR_LEN );
36
-	nsolicit = pkb_put ( pkb, sizeof ( *nsolicit ) );
34
+	struct io_buffer *iobuf = alloc_iob ( sizeof ( *nsolicit ) + MIN_IOB_LEN );
35
+	iob_reserve ( iobuf, MAX_HDR_LEN );
36
+	nsolicit = iob_put ( iobuf, sizeof ( *nsolicit ) );
37 37
 
38 38
 	/* Fill up the headers */
39 39
 	memset ( nsolicit, 0, sizeof ( *nsolicit ) );
@@ -60,25 +60,25 @@ int icmp6_send_solicit ( struct net_device *netdev, struct in6_addr *src __unuse
60 60
 	st_dest.sin6.sin6_addr.in6_u.u6_addr8[13] = 0xff;
61 61
 	
62 62
 	/* Send packet over IP6 */
63
-	return tcpip_tx ( pkb, &icmp6_protocol, &st_dest.st,
63
+	return tcpip_tx ( iobuf, &icmp6_protocol, &st_dest.st,
64 64
 			  NULL, &nsolicit->csum );
65 65
 }
66 66
 
67 67
 /**
68 68
  * Process ICMP6 headers
69 69
  *
70
- * @v pkb	Packet buffer
70
+ * @v iobuf	I/O buffer
71 71
  * @v st_src	Source address
72 72
  * @v st_dest	Destination address
73 73
  */
74
-static int icmp6_rx ( struct pk_buff *pkb, struct sockaddr_tcpip *st_src,
74
+static int icmp6_rx ( struct io_buffer *iobuf, struct sockaddr_tcpip *st_src,
75 75
 		      struct sockaddr_tcpip *st_dest ) {
76
-	struct icmp6_header *icmp6hdr = pkb->data;
76
+	struct icmp6_header *icmp6hdr = iobuf->data;
77 77
 
78 78
 	/* Sanity check */
79
-	if ( pkb_len ( pkb ) < sizeof ( *icmp6hdr ) ) {
80
-		DBG ( "Packet too short (%d bytes)\n", pkb_len ( pkb ) );
81
-		free_pkb ( pkb );
79
+	if ( iob_len ( iobuf ) < sizeof ( *icmp6hdr ) ) {
80
+		DBG ( "Packet too short (%d bytes)\n", iob_len ( iobuf ) );
81
+		free_iob ( iobuf );
82 82
 		return -EINVAL;
83 83
 	}
84 84
 
@@ -87,7 +87,7 @@ static int icmp6_rx ( struct pk_buff *pkb, struct sockaddr_tcpip *st_src,
87 87
 	/* Process the ICMP header */
88 88
 	switch ( icmp6hdr->type ) {
89 89
 	case ICMP6_NADVERT:
90
-		return ndp_process_advert ( pkb, st_src, st_dest );
90
+		return ndp_process_advert ( iobuf, st_src, st_dest );
91 91
 	}
92 92
 	return -ENOSYS;
93 93
 }
@@ -97,9 +97,9 @@ void icmp6_test_nadvert (struct net_device *netdev, struct sockaddr_in6 *server_
97 97
 
98 98
 		struct sockaddr_in6 server;
99 99
 		memcpy ( &server, server_p, sizeof ( server ) );
100
-                struct pk_buff *rxpkb = alloc_pkb ( 500 );
101
-                pkb_reserve ( rxpkb, MAX_HDR_LEN );
102
-                struct neighbour_advert *nadvert = pkb_put ( rxpkb, sizeof ( *nadvert ) );
100
+                struct io_buffer *rxiobuf = alloc_iob ( 500 );
101
+                iob_reserve ( rxiobuf, MAX_HDR_LEN );
102
+                struct neighbour_advert *nadvert = iob_put ( rxiobuf, sizeof ( *nadvert ) );
103 103
                 nadvert->type = 136;
104 104
                 nadvert->code = 0;
105 105
                 nadvert->flags = ICMP6_FLAGS_SOLICITED;
@@ -108,15 +108,15 @@ void icmp6_test_nadvert (struct net_device *netdev, struct sockaddr_in6 *server_
108 108
                 nadvert->opt_type = 2;
109 109
                 nadvert->opt_len = 1;
110 110
                 memcpy ( nadvert->opt_ll_addr, ll_addr, 6 );
111
-                struct ip6_header *ip6hdr = pkb_push ( rxpkb, sizeof ( *ip6hdr ) );
111
+                struct ip6_header *ip6hdr = iob_push ( rxiobuf, sizeof ( *ip6hdr ) );
112 112
                 ip6hdr->ver_traffic_class_flow_label = htonl ( 0x60000000 );
113 113
 		ip6hdr->hop_limit = 255;
114 114
 		ip6hdr->nxt_hdr = 58;
115 115
 		ip6hdr->payload_len = htons ( sizeof ( *nadvert ) );
116 116
                 ip6hdr->src = server.sin6_addr;
117 117
                 ip6hdr->dest = server.sin6_addr;
118
-		hex_dump ( rxpkb->data, pkb_len ( rxpkb ) );
119
-                net_rx ( rxpkb, netdev, htons ( ETH_P_IPV6 ), ll_addr );
118
+		hex_dump ( rxiobuf->data, iob_len ( rxiobuf ) );
119
+                net_rx ( rxiobuf, netdev, htons ( ETH_P_IPV6 ), ll_addr );
120 120
 }
121 121
 #endif
122 122
 

+ 50
- 50
src/net/ipv4.c Целия файл

@@ -8,7 +8,7 @@
8 8
 #include <gpxe/in.h>
9 9
 #include <gpxe/arp.h>
10 10
 #include <gpxe/if_ether.h>
11
-#include <gpxe/pkbuff.h>
11
+#include <gpxe/iobuf.h>
12 12
 #include <gpxe/netdevice.h>
13 13
 #include <gpxe/ip.h>
14 14
 #include <gpxe/tcpip.h>
@@ -205,11 +205,11 @@ static void free_fragbuf ( struct frag_buffer *fragbuf ) {
205 205
 /**
206 206
  * Fragment reassembler
207 207
  *
208
- * @v pkb		Packet buffer, fragment of the datagram
209
- * @ret frag_pkb	Reassembled packet, or NULL
208
+ * @v iobuf		I/O buffer, fragment of the datagram
209
+ * @ret frag_iob	Reassembled packet, or NULL
210 210
  */
211
-static struct pk_buff * ipv4_reassemble ( struct pk_buff * pkb ) {
212
-	struct iphdr *iphdr = pkb->data;
211
+static struct io_buffer * ipv4_reassemble ( struct io_buffer * iobuf ) {
212
+	struct iphdr *iphdr = iobuf->data;
213 213
 	struct frag_buffer *fragbuf;
214 214
 	
215 215
 	/**
@@ -223,31 +223,31 @@ static struct pk_buff * ipv4_reassemble ( struct pk_buff * pkb ) {
223 223
 			 * 
224 224
 			 * The offset of the new packet must be equal to the
225 225
 			 * length of the data accumulated so far (the length of
226
-			 * the reassembled packet buffer
226
+			 * the reassembled I/O buffer
227 227
 			 */
228
-			if ( pkb_len ( fragbuf->frag_pkb ) == 
228
+			if ( iob_len ( fragbuf->frag_iob ) == 
229 229
 			      ( iphdr->frags & IP_MASK_OFFSET ) ) {
230 230
 				/**
231 231
 				 * Append the contents of the fragment to the
232
-				 * reassembled packet buffer
232
+				 * reassembled I/O buffer
233 233
 				 */
234
-				pkb_pull ( pkb, sizeof ( *iphdr ) );
235
-				memcpy ( pkb_put ( fragbuf->frag_pkb,
236
-							pkb_len ( pkb ) ),
237
-					 pkb->data, pkb_len ( pkb ) );
238
-				free_pkb ( pkb );
234
+				iob_pull ( iobuf, sizeof ( *iphdr ) );
235
+				memcpy ( iob_put ( fragbuf->frag_iob,
236
+							iob_len ( iobuf ) ),
237
+					 iobuf->data, iob_len ( iobuf ) );
238
+				free_iob ( iobuf );
239 239
 
240 240
 				/** Check if the fragment series is over */
241 241
 				if ( !iphdr->frags & IP_MASK_MOREFRAGS ) {
242
-					pkb = fragbuf->frag_pkb;
242
+					iobuf = fragbuf->frag_iob;
243 243
 					free_fragbuf ( fragbuf );
244
-					return pkb;
244
+					return iobuf;
245 245
 				}
246 246
 
247 247
 			} else {
248 248
 				/* Discard the fragment series */
249 249
 				free_fragbuf ( fragbuf );
250
-				free_pkb ( pkb );
250
+				free_iob ( iobuf );
251 251
 			}
252 252
 			return NULL;
253 253
 		}
@@ -262,12 +262,12 @@ static struct pk_buff * ipv4_reassemble ( struct pk_buff * pkb ) {
262 262
 		fragbuf->ident = iphdr->ident;
263 263
 		fragbuf->src = iphdr->src;
264 264
 
265
-		/* Set up the reassembly packet buffer */
266
-		fragbuf->frag_pkb = alloc_pkb ( IP_FRAG_PKB_SIZE );
267
-		pkb_pull ( pkb, sizeof ( *iphdr ) );
268
-		memcpy ( pkb_put ( fragbuf->frag_pkb, pkb_len ( pkb ) ),
269
-			 pkb->data, pkb_len ( pkb ) );
270
-		free_pkb ( pkb );
265
+		/* Set up the reassembly I/O buffer */
266
+		fragbuf->frag_iob = alloc_iob ( IP_FRAG_IOB_SIZE );
267
+		iob_pull ( iobuf, sizeof ( *iphdr ) );
268
+		memcpy ( iob_put ( fragbuf->frag_iob, iob_len ( iobuf ) ),
269
+			 iobuf->data, iob_len ( iobuf ) );
270
+		free_iob ( iobuf );
271 271
 
272 272
 		/* Set the reassembly timer */
273 273
 		fragbuf->frag_timer.timeout = IP_FRAG_TIMEOUT;
@@ -284,13 +284,13 @@ static struct pk_buff * ipv4_reassemble ( struct pk_buff * pkb ) {
284 284
 /**
285 285
  * Add IPv4 pseudo-header checksum to existing checksum
286 286
  *
287
- * @v pkb		Packet buffer
287
+ * @v iobuf		I/O buffer
288 288
  * @v csum		Existing checksum
289 289
  * @ret csum		Updated checksum
290 290
  */
291
-static uint16_t ipv4_pshdr_chksum ( struct pk_buff *pkb, uint16_t csum ) {
291
+static uint16_t ipv4_pshdr_chksum ( struct io_buffer *iobuf, uint16_t csum ) {
292 292
 	struct ipv4_pseudo_header pshdr;
293
-	struct iphdr *iphdr = pkb->data;
293
+	struct iphdr *iphdr = iobuf->data;
294 294
 	size_t hdrlen = ( ( iphdr->verhdrlen & IP_MASK_HLEN ) * 4 );
295 295
 
296 296
 	/* Build pseudo-header */
@@ -298,7 +298,7 @@ static uint16_t ipv4_pshdr_chksum ( struct pk_buff *pkb, uint16_t csum ) {
298 298
 	pshdr.dest = iphdr->dest;
299 299
 	pshdr.zero_padding = 0x00;
300 300
 	pshdr.protocol = iphdr->protocol;
301
-	pshdr.len = htons ( pkb_len ( pkb ) - hdrlen );
301
+	pshdr.len = htons ( iob_len ( iobuf ) - hdrlen );
302 302
 
303 303
 	/* Update the checksum value */
304 304
 	return tcpip_continue_chksum ( csum, &pshdr, sizeof ( pshdr ) );
@@ -345,7 +345,7 @@ static int ipv4_ll_addr ( struct in_addr dest, struct in_addr src,
345 345
 /**
346 346
  * Transmit IP packet
347 347
  *
348
- * @v pkb		Packet buffer
348
+ * @v iobuf		I/O buffer
349 349
  * @v tcpip		Transport-layer protocol
350 350
  * @v st_dest		Destination network-layer address
351 351
  * @v netdev		Network device to use if no route found, or NULL
@@ -354,12 +354,12 @@ static int ipv4_ll_addr ( struct in_addr dest, struct in_addr src,
354 354
  *
355 355
  * This function expects a transport-layer segment and prepends the IP header
356 356
  */
357
-static int ipv4_tx ( struct pk_buff *pkb,
357
+static int ipv4_tx ( struct io_buffer *iobuf,
358 358
 		     struct tcpip_protocol *tcpip_protocol,
359 359
 		     struct sockaddr_tcpip *st_dest,
360 360
 		     struct net_device *netdev,
361 361
 		     uint16_t *trans_csum ) {
362
-	struct iphdr *iphdr = pkb_push ( pkb, sizeof ( *iphdr ) );
362
+	struct iphdr *iphdr = iob_push ( iobuf, sizeof ( *iphdr ) );
363 363
 	struct sockaddr_in *sin_dest = ( ( struct sockaddr_in * ) st_dest );
364 364
 	struct ipv4_miniroute *miniroute;
365 365
 	struct in_addr next_hop;
@@ -370,7 +370,7 @@ static int ipv4_tx ( struct pk_buff *pkb,
370 370
 	memset ( iphdr, 0, sizeof ( *iphdr ) );
371 371
 	iphdr->verhdrlen = ( IP_VER | ( sizeof ( *iphdr ) / 4 ) );
372 372
 	iphdr->service = IP_TOS;
373
-	iphdr->len = htons ( pkb_len ( pkb ) );	
373
+	iphdr->len = htons ( iob_len ( iobuf ) );	
374 374
 	iphdr->ident = htons ( ++next_ident );
375 375
 	iphdr->ttl = IP_TTL;
376 376
 	iphdr->protocol = tcpip_protocol->tcpip_proto;
@@ -398,7 +398,7 @@ static int ipv4_tx ( struct pk_buff *pkb,
398 398
 
399 399
 	/* Fix up checksums */
400 400
 	if ( trans_csum )
401
-		*trans_csum = ipv4_pshdr_chksum ( pkb, *trans_csum );
401
+		*trans_csum = ipv4_pshdr_chksum ( iobuf, *trans_csum );
402 402
 	iphdr->chksum = tcpip_chksum ( iphdr, sizeof ( *iphdr ) );
403 403
 
404 404
 	/* Print IP4 header for debugging */
@@ -408,7 +408,7 @@ static int ipv4_tx ( struct pk_buff *pkb,
408 408
 	      ntohs ( iphdr->ident ), ntohs ( iphdr->chksum ) );
409 409
 
410 410
 	/* Hand off to link layer */
411
-	if ( ( rc = net_tx ( pkb, netdev, &ipv4_protocol, ll_dest ) ) != 0 ) {
411
+	if ( ( rc = net_tx ( iobuf, netdev, &ipv4_protocol, ll_dest ) ) != 0 ) {
412 412
 		DBG ( "IPv4 could not transmit packet via %s: %s\n",
413 413
 		      netdev->name, strerror ( rc ) );
414 414
 		return rc;
@@ -417,23 +417,23 @@ static int ipv4_tx ( struct pk_buff *pkb,
417 417
 	return 0;
418 418
 
419 419
  err:
420
-	free_pkb ( pkb );
420
+	free_iob ( iobuf );
421 421
 	return rc;
422 422
 }
423 423
 
424 424
 /**
425 425
  * Process incoming packets
426 426
  *
427
- * @v pkb	Packet buffer
427
+ * @v iobuf	I/O buffer
428 428
  * @v netdev	Network device
429 429
  * @v ll_source	Link-layer destination source
430 430
  *
431 431
  * This function expects an IP4 network datagram. It processes the headers 
432 432
  * and sends it to the transport layer.
433 433
  */
434
-static int ipv4_rx ( struct pk_buff *pkb, struct net_device *netdev __unused,
434
+static int ipv4_rx ( struct io_buffer *iobuf, struct net_device *netdev __unused,
435 435
 		     const void *ll_source __unused ) {
436
-	struct iphdr *iphdr = pkb->data;
436
+	struct iphdr *iphdr = iobuf->data;
437 437
 	size_t hdrlen;
438 438
 	size_t len;
439 439
 	union {
@@ -445,9 +445,9 @@ static int ipv4_rx ( struct pk_buff *pkb, struct net_device *netdev __unused,
445 445
 	int rc;
446 446
 
447 447
 	/* Sanity check the IPv4 header */
448
-	if ( pkb_len ( pkb ) < sizeof ( *iphdr ) ) {
448
+	if ( iob_len ( iobuf ) < sizeof ( *iphdr ) ) {
449 449
 		DBG ( "IPv4 packet too short at %d bytes (min %d bytes)\n",
450
-		      pkb_len ( pkb ), sizeof ( *iphdr ) );
450
+		      iob_len ( iobuf ), sizeof ( *iphdr ) );
451 451
 		goto err;
452 452
 	}
453 453
 	if ( ( iphdr->verhdrlen & IP_MASK_VER ) != IP_VER ) {
@@ -460,9 +460,9 @@ static int ipv4_rx ( struct pk_buff *pkb, struct net_device *netdev __unused,
460 460
 		      hdrlen, sizeof ( *iphdr ) );
461 461
 		goto err;
462 462
 	}
463
-	if ( hdrlen > pkb_len ( pkb ) ) {
463
+	if ( hdrlen > iob_len ( iobuf ) ) {
464 464
 		DBG ( "IPv4 header too long at %d bytes "
465
-		      "(packet is %d bytes)\n", hdrlen, pkb_len ( pkb ) );
465
+		      "(packet is %d bytes)\n", hdrlen, iob_len ( iobuf ) );
466 466
 		goto err;
467 467
 	}
468 468
 	if ( ( csum = tcpip_chksum ( iphdr, hdrlen ) ) != 0 ) {
@@ -476,9 +476,9 @@ static int ipv4_rx ( struct pk_buff *pkb, struct net_device *netdev __unused,
476 476
 		      "(header is %d bytes)\n", len, hdrlen );
477 477
 		goto err;
478 478
 	}
479
-	if ( len > pkb_len ( pkb ) ) {
479
+	if ( len > iob_len ( iobuf ) ) {
480 480
 		DBG ( "IPv4 length too long at %d bytes "
481
-		      "(packet is %d bytes)\n", len, pkb_len ( pkb ) );
481
+		      "(packet is %d bytes)\n", len, iob_len ( iobuf ) );
482 482
 		goto err;
483 483
 	}
484 484
 
@@ -491,18 +491,18 @@ static int ipv4_rx ( struct pk_buff *pkb, struct net_device *netdev __unused,
491 491
 	/* Truncate packet to correct length, calculate pseudo-header
492 492
 	 * checksum and then strip off the IPv4 header.
493 493
 	 */
494
-	pkb_unput ( pkb, ( pkb_len ( pkb ) - len ) );
495
-	pshdr_csum = ipv4_pshdr_chksum ( pkb, TCPIP_EMPTY_CSUM );
496
-	pkb_pull ( pkb, hdrlen );
494
+	iob_unput ( iobuf, ( iob_len ( iobuf ) - len ) );
495
+	pshdr_csum = ipv4_pshdr_chksum ( iobuf, TCPIP_EMPTY_CSUM );
496
+	iob_pull ( iobuf, hdrlen );
497 497
 
498 498
 	/* Fragment reassembly */
499 499
 	if ( ( iphdr->frags & htons ( IP_MASK_MOREFRAGS ) ) || 
500 500
 	     ( ( iphdr->frags & htons ( IP_MASK_OFFSET ) ) != 0 ) ) {
501 501
 		/* Pass the fragment to ipv4_reassemble() which either
502
-		 * returns a fully reassembled packet buffer or NULL.
502
+		 * returns a fully reassembled I/O buffer or NULL.
503 503
 		 */
504
-		pkb = ipv4_reassemble ( pkb );
505
-		if ( ! pkb )
504
+		iobuf = ipv4_reassemble ( iobuf );
505
+		if ( ! iobuf )
506 506
 			return 0;
507 507
 	}
508 508
 
@@ -513,7 +513,7 @@ static int ipv4_rx ( struct pk_buff *pkb, struct net_device *netdev __unused,
513 513
 	memset ( &dest, 0, sizeof ( dest ) );
514 514
 	dest.sin.sin_family = AF_INET;
515 515
 	dest.sin.sin_addr = iphdr->dest;
516
-	if ( ( rc = tcpip_rx ( pkb, iphdr->protocol, &src.st,
516
+	if ( ( rc = tcpip_rx ( iobuf, iphdr->protocol, &src.st,
517 517
 			       &dest.st, pshdr_csum ) ) != 0 ) {
518 518
 		DBG ( "IPv4 received packet rejected by stack: %s\n",
519 519
 		      strerror ( rc ) );
@@ -523,7 +523,7 @@ static int ipv4_rx ( struct pk_buff *pkb, struct net_device *netdev __unused,
523 523
 	return 0;
524 524
 
525 525
  err:
526
-	free_pkb ( pkb );
526
+	free_iob ( iobuf );
527 527
 	return -EINVAL;
528 528
 }
529 529
 

+ 25
- 25
src/net/ipv6.c Целия файл

@@ -11,7 +11,7 @@
11 11
 #include <gpxe/icmp6.h>
12 12
 #include <gpxe/tcpip.h>
13 13
 #include <gpxe/socket.h>
14
-#include <gpxe/pkbuff.h>
14
+#include <gpxe/iobuf.h>
15 15
 #include <gpxe/netdevice.h>
16 16
 #include <gpxe/if_ether.h>
17 17
 
@@ -157,21 +157,21 @@ void del_ipv6_address ( struct net_device *netdev ) {
157 157
 /**
158 158
  * Calculate TCPIP checksum
159 159
  *
160
- * @v pkb	Packet buffer
160
+ * @v iobuf	I/O buffer
161 161
  * @v tcpip	TCP/IP protocol
162 162
  *
163 163
  * This function constructs the pseudo header and completes the checksum in the
164 164
  * upper layer header.
165 165
  */
166
-static uint16_t ipv6_tx_csum ( struct pk_buff *pkb, uint16_t csum ) {
167
-	struct ip6_header *ip6hdr = pkb->data;
166
+static uint16_t ipv6_tx_csum ( struct io_buffer *iobuf, uint16_t csum ) {
167
+	struct ip6_header *ip6hdr = iobuf->data;
168 168
 	struct ipv6_pseudo_header pshdr;
169 169
 
170 170
 	/* Calculate pseudo header */
171 171
 	memset ( &pshdr, 0, sizeof ( pshdr ) );
172 172
 	pshdr.src = ip6hdr->src;
173 173
 	pshdr.dest = ip6hdr->dest;
174
-	pshdr.len = htons ( pkb_len ( pkb ) - sizeof ( *ip6hdr ) );
174
+	pshdr.len = htons ( iob_len ( iobuf ) - sizeof ( *ip6hdr ) );
175 175
 	pshdr.nxt_hdr = ip6hdr->nxt_hdr;
176 176
 
177 177
 	/* Update checksum value */
@@ -192,13 +192,13 @@ void ipv6_dump ( struct ip6_header *ip6hdr ) {
192 192
 /**
193 193
  * Transmit IP6 packet
194 194
  *
195
- * pkb		Packet buffer
195
+ * iobuf		I/O buffer
196 196
  * tcpip	TCP/IP protocol
197 197
  * st_dest	Destination socket address
198 198
  *
199 199
  * This function prepends the IPv6 headers to the payload an transmits it.
200 200
  */
201
-static int ipv6_tx ( struct pk_buff *pkb,
201
+static int ipv6_tx ( struct io_buffer *iobuf,
202 202
 		     struct tcpip_protocol *tcpip,
203 203
 		     struct sockaddr_tcpip *st_dest,
204 204
 		     struct net_device *netdev,
@@ -211,10 +211,10 @@ static int ipv6_tx ( struct pk_buff *pkb,
211 211
 	int rc;
212 212
 
213 213
 	/* Construct the IPv6 packet */
214
-	struct ip6_header *ip6hdr = pkb_push ( pkb, sizeof ( *ip6hdr ) );
214
+	struct ip6_header *ip6hdr = iob_push ( iobuf, sizeof ( *ip6hdr ) );
215 215
 	memset ( ip6hdr, 0, sizeof ( *ip6hdr) );
216 216
 	ip6hdr->ver_traffic_class_flow_label = htonl ( 0x60000000 );//IP6_VERSION;
217
-	ip6hdr->payload_len = htons ( pkb_len ( pkb ) - sizeof ( *ip6hdr ) );
217
+	ip6hdr->payload_len = htons ( iob_len ( iobuf ) - sizeof ( *ip6hdr ) );
218 218
 	ip6hdr->nxt_hdr = tcpip->tcpip_proto;
219 219
 	ip6hdr->hop_limit = IP6_HOP_LIMIT; // 255
220 220
 
@@ -244,7 +244,7 @@ static int ipv6_tx ( struct pk_buff *pkb,
244 244
 
245 245
 	/* Complete the transport layer checksum */
246 246
 	if ( trans_csum )
247
-		*trans_csum = ipv6_tx_csum ( pkb, *trans_csum );
247
+		*trans_csum = ipv6_tx_csum ( iobuf, *trans_csum );
248 248
 
249 249
 	/* Print IPv6 header */
250 250
 	ipv6_dump ( ip6hdr );
@@ -267,24 +267,24 @@ static int ipv6_tx ( struct pk_buff *pkb,
267 267
 	}
268 268
 
269 269
 	/* Transmit packet */
270
-	return net_tx ( pkb, netdev, &ipv6_protocol, ll_dest );
270
+	return net_tx ( iobuf, netdev, &ipv6_protocol, ll_dest );
271 271
 
272 272
   err:
273
-	free_pkb ( pkb );
273
+	free_iob ( iobuf );
274 274
 	return rc;
275 275
 }
276 276
 
277 277
 /**
278 278
  * Process next IP6 header
279 279
  *
280
- * @v pkb	Packet buffer
280
+ * @v iobuf	I/O buffer
281 281
  * @v nxt_hdr	Next header number
282 282
  * @v src	Source socket address
283 283
  * @v dest	Destination socket address
284 284
  *
285 285
  * Refer http://www.iana.org/assignments/ipv6-parameters for the numbers
286 286
  */
287
-static int ipv6_process_nxt_hdr ( struct pk_buff *pkb, uint8_t nxt_hdr,
287
+static int ipv6_process_nxt_hdr ( struct io_buffer *iobuf, uint8_t nxt_hdr,
288 288
 		struct sockaddr_tcpip *src, struct sockaddr_tcpip *dest ) {
289 289
 	switch ( nxt_hdr ) {
290 290
 	case IP6_HOPBYHOP: 
@@ -302,31 +302,31 @@ static int ipv6_process_nxt_hdr ( struct pk_buff *pkb, uint8_t nxt_hdr,
302 302
 		return 0;
303 303
 	}
304 304
 	/* Next header is not a IPv6 extension header */
305
-	return tcpip_rx ( pkb, nxt_hdr, src, dest, 0 /* fixme */ );
305
+	return tcpip_rx ( iobuf, nxt_hdr, src, dest, 0 /* fixme */ );
306 306
 }
307 307
 
308 308
 /**
309 309
  * Process incoming IP6 packets
310 310
  *
311
- * @v pkb		Packet buffer
311
+ * @v iobuf		I/O buffer
312 312
  * @v netdev		Network device
313 313
  * @v ll_source		Link-layer source address
314 314
  *
315 315
  * This function processes a IPv6 packet
316 316
  */
317
-static int ipv6_rx ( struct pk_buff *pkb,
317
+static int ipv6_rx ( struct io_buffer *iobuf,
318 318
 		     struct net_device *netdev,
319 319
 		     const void *ll_source ) {
320 320
 
321
-	struct ip6_header *ip6hdr = pkb->data;
321
+	struct ip6_header *ip6hdr = iobuf->data;
322 322
 	union {
323 323
 		struct sockaddr_in6 sin6;
324 324
 		struct sockaddr_tcpip st;
325 325
 	} src, dest;
326 326
 
327 327
 	/* Sanity check */
328
-	if ( pkb_len ( pkb ) < sizeof ( *ip6hdr ) ) {
329
-		DBG ( "Packet too short (%d bytes)\n", pkb_len ( pkb ) );
328
+	if ( iob_len ( iobuf ) < sizeof ( *ip6hdr ) ) {
329
+		DBG ( "Packet too short (%d bytes)\n", iob_len ( iobuf ) );
330 330
 		goto drop;
331 331
 	}
332 332
 
@@ -342,7 +342,7 @@ static int ipv6_rx ( struct pk_buff *pkb,
342 342
 	}
343 343
 
344 344
 	/* Check the payload length */
345
-	if ( ntohs ( ip6hdr->payload_len ) > pkb_len ( pkb ) ) {
345
+	if ( ntohs ( ip6hdr->payload_len ) > iob_len ( iobuf ) ) {
346 346
 		DBG ( "Inconsistent packet length (%d bytes)\n",
347 347
 			ip6hdr->payload_len );
348 348
 		goto drop;
@@ -359,16 +359,16 @@ static int ipv6_rx ( struct pk_buff *pkb,
359 359
 	dest.sin6.sin6_addr = ip6hdr->dest;
360 360
 
361 361
 	/* Strip header */
362
-	pkb_unput ( pkb, pkb_len ( pkb ) - ntohs ( ip6hdr->payload_len ) -
362
+	iob_unput ( iobuf, iob_len ( iobuf ) - ntohs ( ip6hdr->payload_len ) -
363 363
 							sizeof ( *ip6hdr ) );
364
-	pkb_pull ( pkb, sizeof ( *ip6hdr ) );
364
+	iob_pull ( iobuf, sizeof ( *ip6hdr ) );
365 365
 
366 366
 	/* Send it to the transport layer */
367
-	return ipv6_process_nxt_hdr ( pkb, ip6hdr->nxt_hdr, &src.st, &dest.st );
367
+	return ipv6_process_nxt_hdr ( iobuf, ip6hdr->nxt_hdr, &src.st, &dest.st );
368 368
 
369 369
   drop:
370 370
 	DBG ( "Packet dropped\n" );
371
-	free_pkb ( pkb );
371
+	free_iob ( iobuf );
372 372
 	return -1;
373 373
 }
374 374
 

+ 6
- 6
src/net/ndp.c Целия файл

@@ -3,7 +3,7 @@
3 3
 #include <byteswap.h>
4 4
 #include <errno.h>
5 5
 #include <gpxe/if_ether.h>
6
-#include <gpxe/pkbuff.h>
6
+#include <gpxe/iobuf.h>
7 7
 #include <gpxe/ndp.h>
8 8
 #include <gpxe/icmp6.h>
9 9
 #include <gpxe/ip6.h>
@@ -143,18 +143,18 @@ int ndp_resolve ( struct net_device *netdev, struct in6_addr *dest,
143 143
 /**
144 144
  * Process neighbour advertisement
145 145
  *
146
- * @v pkb	Packet buffer
146
+ * @v iobuf	I/O buffer
147 147
  * @v st_src	Source address
148 148
  * @v st_dest	Destination address 
149 149
  */
150
-int ndp_process_advert ( struct pk_buff *pkb, struct sockaddr_tcpip *st_src __unused,
150
+int ndp_process_advert ( struct io_buffer *iobuf, struct sockaddr_tcpip *st_src __unused,
151 151
 			   struct sockaddr_tcpip *st_dest __unused ) {
152
-	struct neighbour_advert *nadvert = pkb->data;
152
+	struct neighbour_advert *nadvert = iobuf->data;
153 153
 	struct ndp_entry *ndp;
154 154
 
155 155
 	/* Sanity check */
156
-	if ( pkb_len ( pkb ) < sizeof ( *nadvert ) ) {
157
-		DBG ( "Packet too short (%d bytes)\n", pkb_len ( pkb ) );
156
+	if ( iob_len ( iobuf ) < sizeof ( *nadvert ) ) {
157
+		DBG ( "Packet too short (%d bytes)\n", iob_len ( iobuf ) );
158 158
 		return -EINVAL;
159 159
 	}
160 160
 

+ 47
- 47
src/net/netdevice.c Целия файл

@@ -23,7 +23,7 @@
23 23
 #include <string.h>
24 24
 #include <errno.h>
25 25
 #include <gpxe/if_ether.h>
26
-#include <gpxe/pkbuff.h>
26
+#include <gpxe/iobuf.h>
27 27
 #include <gpxe/tables.h>
28 28
 #include <gpxe/process.h>
29 29
 #include <gpxe/init.h>
@@ -49,34 +49,34 @@ struct list_head net_devices = LIST_HEAD_INIT ( net_devices );
49 49
  * Transmit raw packet via network device
50 50
  *
51 51
  * @v netdev		Network device
52
- * @v pkb		Packet buffer
52
+ * @v iobuf		I/O buffer
53 53
  * @ret rc		Return status code
54 54
  *
55 55
  * Transmits the packet via the specified network device.  This
56
- * function takes ownership of the packet buffer.
56
+ * function takes ownership of the I/O buffer.
57 57
  */
58
-int netdev_tx ( struct net_device *netdev, struct pk_buff *pkb ) {
58
+int netdev_tx ( struct net_device *netdev, struct io_buffer *iobuf ) {
59 59
 	int rc;
60 60
 
61 61
 	DBGC ( netdev, "NETDEV %p transmitting %p (%p+%zx)\n",
62
-	       netdev, pkb, pkb->data, pkb_len ( pkb ) );
62
+	       netdev, iobuf, iobuf->data, iob_len ( iobuf ) );
63 63
 
64
-	list_add_tail ( &pkb->list, &netdev->tx_queue );
64
+	list_add_tail ( &iobuf->list, &netdev->tx_queue );
65 65
 
66 66
 	if ( ! ( netdev->state & NETDEV_OPEN ) ) {
67 67
 		rc = -ENETUNREACH;
68 68
 		goto err;
69 69
 	}
70 70
 		
71
-	if ( ( rc = netdev->transmit ( netdev, pkb ) ) != 0 )
71
+	if ( ( rc = netdev->transmit ( netdev, iobuf ) ) != 0 )
72 72
 		goto err;
73 73
 
74 74
 	return 0;
75 75
 
76 76
  err:
77 77
 	DBGC ( netdev, "NETDEV %p transmission %p failed: %s\n",
78
-	       netdev, pkb, strerror ( rc ) );
79
-	netdev_tx_complete ( netdev, pkb );
78
+	       netdev, iobuf, strerror ( rc ) );
79
+	netdev_tx_complete ( netdev, iobuf );
80 80
 	return rc;
81 81
 }
82 82
 
@@ -84,19 +84,19 @@ int netdev_tx ( struct net_device *netdev, struct pk_buff *pkb ) {
84 84
  * Complete network transmission
85 85
  *
86 86
  * @v netdev		Network device
87
- * @v pkb		Packet buffer
87
+ * @v iobuf		I/O buffer
88 88
  *
89 89
  * The packet must currently be in the network device's TX queue.
90 90
  */
91
-void netdev_tx_complete ( struct net_device *netdev, struct pk_buff *pkb ) {
92
-	DBGC ( netdev, "NETDEV %p transmission %p complete\n", netdev, pkb );
91
+void netdev_tx_complete ( struct net_device *netdev, struct io_buffer *iobuf ) {
92
+	DBGC ( netdev, "NETDEV %p transmission %p complete\n", netdev, iobuf );
93 93
 
94 94
 	/* Catch data corruption as early as possible */
95
-	assert ( pkb->list.next != NULL );
96
-	assert ( pkb->list.prev != NULL );
95
+	assert ( iobuf->list.next != NULL );
96
+	assert ( iobuf->list.prev != NULL );
97 97
 
98
-	list_del ( &pkb->list );
99
-	free_pkb ( pkb );
98
+	list_del ( &iobuf->list );
99
+	free_iob ( iobuf );
100 100
 }
101 101
 
102 102
 /**
@@ -107,10 +107,10 @@ void netdev_tx_complete ( struct net_device *netdev, struct pk_buff *pkb ) {
107 107
  * Completes the oldest outstanding packet in the TX queue.
108 108
  */
109 109
 void netdev_tx_complete_next ( struct net_device *netdev ) {
110
-	struct pk_buff *pkb;
110
+	struct io_buffer *iobuf;
111 111
 
112
-	list_for_each_entry ( pkb, &netdev->tx_queue, list ) {
113
-		netdev_tx_complete ( netdev, pkb );
112
+	list_for_each_entry ( iobuf, &netdev->tx_queue, list ) {
113
+		netdev_tx_complete ( netdev, iobuf );
114 114
 		return;
115 115
 	}
116 116
 }
@@ -119,15 +119,15 @@ void netdev_tx_complete_next ( struct net_device *netdev ) {
119 119
  * Add packet to receive queue
120 120
  *
121 121
  * @v netdev		Network device
122
- * @v pkb		Packet buffer
122
+ * @v iobuf		I/O buffer
123 123
  *
124 124
  * The packet is added to the network device's RX queue.  This
125
- * function takes ownership of the packet buffer.
125
+ * function takes ownership of the I/O buffer.
126 126
  */
127
-void netdev_rx ( struct net_device *netdev, struct pk_buff *pkb ) {
127
+void netdev_rx ( struct net_device *netdev, struct io_buffer *iobuf ) {
128 128
 	DBGC ( netdev, "NETDEV %p received %p (%p+%zx)\n",
129
-	       netdev, pkb, pkb->data, pkb_len ( pkb ) );
130
-	list_add_tail ( &pkb->list, &netdev->rx_queue );
129
+	       netdev, iobuf, iobuf->data, iob_len ( iobuf ) );
130
+	list_add_tail ( &iobuf->list, &netdev->rx_queue );
131 131
 }
132 132
 
133 133
 /**
@@ -153,17 +153,17 @@ int netdev_poll ( struct net_device *netdev, unsigned int rx_quota ) {
153 153
  * Remove packet from device's receive queue
154 154
  *
155 155
  * @v netdev		Network device
156
- * @ret pkb		Packet buffer, or NULL
156
+ * @ret iobuf		I/O buffer, or NULL
157 157
  *
158 158
  * Removes the first packet from the device's RX queue and returns it.
159 159
  * Ownership of the packet is transferred to the caller.
160 160
  */
161
-struct pk_buff * netdev_rx_dequeue ( struct net_device *netdev ) {
162
-	struct pk_buff *pkb;
161
+struct io_buffer * netdev_rx_dequeue ( struct net_device *netdev ) {
162
+	struct io_buffer *iobuf;
163 163
 
164
-	list_for_each_entry ( pkb, &netdev->rx_queue, list ) {
165
-		list_del ( &pkb->list );
166
-		return pkb;
164
+	list_for_each_entry ( iobuf, &netdev->rx_queue, list ) {
165
+		list_del ( &iobuf->list );
166
+		return iobuf;
167 167
 	}
168 168
 	return NULL;
169 169
 }
@@ -247,7 +247,7 @@ int netdev_open ( struct net_device *netdev ) {
247 247
  * @v netdev		Network device
248 248
  */
249 249
 void netdev_close ( struct net_device *netdev ) {
250
-	struct pk_buff *pkb;
250
+	struct io_buffer *iobuf;
251 251
 
252 252
 	/* Do nothing if device is already closed */
253 253
 	if ( ! ( netdev->state & NETDEV_OPEN ) )
@@ -264,10 +264,10 @@ void netdev_close ( struct net_device *netdev ) {
264 264
 	}
265 265
 
266 266
 	/* Discard any packets in the RX queue */
267
-	while ( ( pkb = netdev_rx_dequeue ( netdev ) ) ) {
267
+	while ( ( iobuf = netdev_rx_dequeue ( netdev ) ) ) {
268 268
 		DBGC ( netdev, "NETDEV %p discarding received %p\n",
269
-		       netdev, pkb );
270
-		free_pkb ( pkb );
269
+		       netdev, iobuf );
270
+		free_iob ( iobuf );
271 271
 	}
272 272
 
273 273
 	/* Mark as closed */
@@ -341,31 +341,31 @@ struct net_device * find_pci_netdev ( unsigned int busdevfn ) {
341 341
 /**
342 342
  * Transmit network-layer packet
343 343
  *
344
- * @v pkb		Packet buffer
344
+ * @v iobuf		I/O buffer
345 345
  * @v netdev		Network device
346 346
  * @v net_protocol	Network-layer protocol
347 347
  * @v ll_dest		Destination link-layer address
348 348
  * @ret rc		Return status code
349 349
  *
350
- * Prepends link-layer headers to the packet buffer and transmits the
350
+ * Prepends link-layer headers to the I/O buffer and transmits the
351 351
  * packet via the specified network device.  This function takes
352
- * ownership of the packet buffer.
352
+ * ownership of the I/O buffer.
353 353
  */
354
-int net_tx ( struct pk_buff *pkb, struct net_device *netdev,
354
+int net_tx ( struct io_buffer *iobuf, struct net_device *netdev,
355 355
 	     struct net_protocol *net_protocol, const void *ll_dest ) {
356
-	return netdev->ll_protocol->tx ( pkb, netdev, net_protocol, ll_dest );
356
+	return netdev->ll_protocol->tx ( iobuf, netdev, net_protocol, ll_dest );
357 357
 }
358 358
 
359 359
 /**
360 360
  * Process received network-layer packet
361 361
  *
362
- * @v pkb		Packet buffer
362
+ * @v iobuf		I/O buffer
363 363
  * @v netdev		Network device
364 364
  * @v net_proto		Network-layer protocol, in network-byte order
365 365
  * @v ll_source		Source link-layer address
366 366
  * @ret rc		Return status code
367 367
  */
368
-int net_rx ( struct pk_buff *pkb, struct net_device *netdev,
368
+int net_rx ( struct io_buffer *iobuf, struct net_device *netdev,
369 369
 	     uint16_t net_proto, const void *ll_source ) {
370 370
 	struct net_protocol *net_protocol;
371 371
 
@@ -373,10 +373,10 @@ int net_rx ( struct pk_buff *pkb, struct net_device *netdev,
373 373
 	for ( net_protocol = net_protocols ; net_protocol < net_protocols_end ;
374 374
 	      net_protocol++ ) {
375 375
 		if ( net_protocol->net_proto == net_proto ) {
376
-			return net_protocol->rx ( pkb, netdev, ll_source );
376
+			return net_protocol->rx ( iobuf, netdev, ll_source );
377 377
 		}
378 378
 	}
379
-	free_pkb ( pkb );
379
+	free_iob ( iobuf );
380 380
 	return 0;
381 381
 }
382 382
 
@@ -390,7 +390,7 @@ int net_rx ( struct pk_buff *pkb, struct net_device *netdev,
390 390
  */
391 391
 static void net_step ( struct process *process ) {
392 392
 	struct net_device *netdev;
393
-	struct pk_buff *pkb;
393
+	struct io_buffer *iobuf;
394 394
 
395 395
 	/* Poll and process each network device */
396 396
 	list_for_each_entry ( netdev, &net_devices, list ) {
@@ -404,10 +404,10 @@ static void net_step ( struct process *process ) {
404 404
 		 * that assumes that we can receive packets from the
405 405
 		 * NIC faster than they arrive.
406 406
 		 */
407
-		if ( ( pkb = netdev_rx_dequeue ( netdev ) ) ) {
407
+		if ( ( iobuf = netdev_rx_dequeue ( netdev ) ) ) {
408 408
 			DBGC ( netdev, "NETDEV %p processing %p\n",
409
-			       netdev, pkb );
410
-			netdev->ll_protocol->rx ( pkb, netdev );
409
+			       netdev, iobuf );
410
+			netdev->ll_protocol->rx ( iobuf, netdev );
411 411
 		}
412 412
 	}
413 413
 

+ 20
- 20
src/net/pkbpad.c Целия файл

@@ -19,48 +19,48 @@
19 19
 /**
20 20
  * @file
21 21
  *
22
- * Packet buffer padding
22
+ * I/O buffer padding
23 23
  *
24 24
  */
25 25
 
26 26
 #include <string.h>
27
-#include <gpxe/pkbuff.h>
27
+#include <gpxe/iobuf.h>
28 28
 
29 29
 /**
30
- * Pad packet buffer
30
+ * Pad I/O buffer
31 31
  *
32
- * @v pkb		Packet buffer
32
+ * @v iobuf		I/O buffer
33 33
  * @v min_len		Minimum length
34 34
  *
35
- * This function pads and aligns packet buffers, for devices that
35
+ * This function pads and aligns I/O buffers, for devices that
36 36
  * aren't capable of padding in hardware, or that require specific
37 37
  * alignment in TX buffers.  The packet data will end up aligned to a
38
- * multiple of @c PKB_ALIGN.
38
+ * multiple of @c IOB_ALIGN.
39 39
  *
40
- * @c min_len must not exceed @v PKB_ZLEN.
40
+ * @c min_len must not exceed @v IOB_ZLEN.
41 41
  */
42
-void pkb_pad ( struct pk_buff *pkb, size_t min_len ) {
42
+void iob_pad ( struct io_buffer *iobuf, size_t min_len ) {
43 43
 	void *data;
44 44
 	size_t len;
45 45
 	size_t headroom;
46 46
 	signed int pad_len;
47 47
 
48
-	assert ( min_len <= PKB_ZLEN );
48
+	assert ( min_len <= IOB_ZLEN );
49 49
 
50
-	/* Move packet data to start of packet buffer.  This will both
51
-	 * align the data (since packet buffers are aligned to
52
-	 * PKB_ALIGN) and give us sufficient space for the
50
+	/* Move packet data to start of I/O buffer.  This will both
51
+	 * align the data (since I/O buffers are aligned to
52
+	 * IOB_ALIGN) and give us sufficient space for the
53 53
 	 * zero-padding
54 54
 	 */
55
-	data = pkb->data;
56
-	len = pkb_len ( pkb );
57
-	headroom = pkb_headroom ( pkb );
58
-	pkb_push ( pkb, headroom );
59
-	memmove ( pkb->data, data, len );
60
-	pkb_unput ( pkb, headroom );
55
+	data = iobuf->data;
56
+	len = iob_len ( iobuf );
57
+	headroom = iob_headroom ( iobuf );
58
+	iob_push ( iobuf, headroom );
59
+	memmove ( iobuf->data, data, len );
60
+	iob_unput ( iobuf, headroom );
61 61
 
62 62
 	/* Pad to minimum packet length */
63
-	pad_len = ( min_len - pkb_len ( pkb ) );
63
+	pad_len = ( min_len - iob_len ( iobuf ) );
64 64
 	if ( pad_len > 0 )
65
-		memset ( pkb_put ( pkb, pad_len ), 0, pad_len );
65
+		memset ( iob_put ( iobuf, pad_len ), 0, pad_len );
66 66
 }

+ 0
- 73
src/net/pkbuff.c Целия файл

@@ -1,73 +0,0 @@
1
-/*
2
- * Copyright (C) 2006 Michael Brown <mbrown@fensystems.co.uk>.
3
- *
4
- * This program is free software; you can redistribute it and/or
5
- * modify it under the terms of the GNU General Public License as
6
- * published by the Free Software Foundation; either version 2 of the
7
- * License, or any later version.
8
- *
9
- * This program is distributed in the hope that it will be useful, but
10
- * WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
- * General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU General Public License
15
- * along with this program; if not, write to the Free Software
16
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
- */
18
-
19
-#include <stdint.h>
20
-#include <gpxe/malloc.h>
21
-#include <gpxe/pkbuff.h>
22
-
23
-/** @file
24
- *
25
- * Packet buffers
26
- *
27
- */
28
-
29
-/**
30
- * Allocate packet buffer
31
- *
32
- * @v len	Required length of buffer
33
- * @ret pkb	Packet buffer, or NULL if none available
34
- *
35
- * The packet buffer will be physically aligned to a multiple of
36
- * @c PKBUFF_SIZE.
37
- */
38
-struct pk_buff * alloc_pkb ( size_t len ) {
39
-	struct pk_buff *pkb = NULL;
40
-	void *data;
41
-
42
-	/* Pad to minimum length */
43
-	if ( len < PKB_ZLEN )
44
-		len = PKB_ZLEN;
45
-
46
-	/* Align buffer length */
47
-	len = ( len + __alignof__( *pkb ) - 1 ) & ~( __alignof__( *pkb ) - 1 );
48
-	
49
-	/* Allocate memory for buffer plus descriptor */
50
-	data = malloc_dma ( len + sizeof ( *pkb ), PKBUFF_ALIGN );
51
-	if ( ! data )
52
-		return NULL;
53
-
54
-	pkb = ( struct pk_buff * ) ( data + len );
55
-	pkb->head = pkb->data = pkb->tail = data;
56
-	pkb->end = pkb;
57
-	return pkb;
58
-}
59
-
60
-/**
61
- * Free packet buffer
62
- *
63
- * @v pkb	Packet buffer
64
- */
65
-void free_pkb ( struct pk_buff *pkb ) {
66
-	if ( pkb ) {
67
-		assert ( pkb->head <= pkb->data );
68
-		assert ( pkb->data <= pkb->tail );
69
-		assert ( pkb->tail <= pkb->end );
70
-		free_dma ( pkb->head,
71
-			   ( pkb->end - pkb->head ) + sizeof ( *pkb ) );
72
-	}
73
-}

+ 46
- 46
src/net/tcp.c Целия файл

@@ -5,7 +5,7 @@
5 5
 #include <errno.h>
6 6
 #include <byteswap.h>
7 7
 #include <timer.h>
8
-#include <gpxe/pkbuff.h>
8
+#include <gpxe/iobuf.h>
9 9
 #include <gpxe/malloc.h>
10 10
 #include <gpxe/retry.h>
11 11
 #include <gpxe/stream.h>
@@ -68,12 +68,12 @@ struct tcp_connection {
68 68
 	 */
69 69
 	uint32_t rcv_ack;
70 70
 
71
-	/** Transmit packet buffer
71
+	/** Transmit I/O buffer
72 72
 	 *
73 73
 	 * This buffer is allocated prior to calling the application's
74 74
 	 * senddata() method, to provide temporary storage space.
75 75
 	 */
76
-	struct pk_buff *tx_pkb;
76
+	struct io_buffer *tx_iob;
77 77
 	/** Retransmission timer */
78 78
 	struct retry_timer timer;
79 79
 };
@@ -222,7 +222,7 @@ static void tcp_abort ( struct tcp_connection *tcp, int send_rst, int rc ) {
222 222
  * eventually attempt to retransmit the failed packet.
223 223
  */
224 224
 static int tcp_senddata_conn ( struct tcp_connection *tcp, int force_send ) {
225
-	struct pk_buff *pkb;
225
+	struct io_buffer *iobuf;
226 226
 	struct tcp_header *tcphdr;
227 227
 	struct tcp_mss_option *mssopt;
228 228
 	void *payload;
@@ -233,12 +233,12 @@ static int tcp_senddata_conn ( struct tcp_connection *tcp, int force_send ) {
233 233
 	int rc;
234 234
 
235 235
 	/* Allocate space to the TX buffer */
236
-	pkb = alloc_pkb ( MAX_PKB_LEN );
237
-	if ( ! pkb ) {
236
+	iobuf = alloc_iob ( MAX_IOB_LEN );
237
+	if ( ! iobuf ) {
238 238
 		DBGC ( tcp, "TCP %p could not allocate data buffer\n", tcp );
239 239
 		/* Start the retry timer so that we attempt to
240 240
 		 * retransmit this packet later.  (Start it
241
-		 * unconditionally, since without a packet buffer we
241
+		 * unconditionally, since without a I/O buffer we
242 242
 		 * can't call the senddata() callback, and so may not
243 243
 		 * be able to tell whether or not we have something
244 244
 		 * that actually needs to be retransmitted).
@@ -246,20 +246,20 @@ static int tcp_senddata_conn ( struct tcp_connection *tcp, int force_send ) {
246 246
 		start_timer ( &tcp->timer );
247 247
 		return -ENOMEM;
248 248
 	}
249
-	pkb_reserve ( pkb, MAX_HDR_LEN );
249
+	iob_reserve ( iobuf, MAX_HDR_LEN );
250 250
 
251 251
 	/* If we are connected, call the senddata() method, which may
252 252
 	 * call tcp_send() to queue up a data payload.
253 253
 	 */
254 254
 	if ( TCP_CAN_SEND_DATA ( tcp->tcp_state ) ) {
255
-		tcp->tx_pkb = pkb;
256
-		stream_senddata ( &tcp->stream, pkb->data,
257
-				  pkb_tailroom ( pkb ) );
258
-		tcp->tx_pkb = NULL;
255
+		tcp->tx_iob = iobuf;
256
+		stream_senddata ( &tcp->stream, iobuf->data,
257
+				  iob_tailroom ( iobuf ) );
258
+		tcp->tx_iob = NULL;
259 259
 	}
260 260
 
261 261
 	/* Truncate payload length to fit transmit window */
262
-	len = pkb_len ( pkb );
262
+	len = iob_len ( iobuf );
263 263
 	if ( len > tcp->snd_win )
264 264
 		len = tcp->snd_win;
265 265
 
@@ -276,7 +276,7 @@ static int tcp_senddata_conn ( struct tcp_connection *tcp, int force_send ) {
276 276
 
277 277
 	/* If we have nothing to transmit, drop the packet */
278 278
 	if ( ( seq_len == 0 ) && ! force_send ) {
279
-		free_pkb ( pkb );
279
+		free_iob ( iobuf );
280 280
 		return 0;
281 281
 	}
282 282
 
@@ -294,23 +294,23 @@ static int tcp_senddata_conn ( struct tcp_connection *tcp, int force_send ) {
294 294
 	window &= ~0x03; /* Keep everything dword-aligned */
295 295
 
296 296
 	/* Fill up the TCP header */
297
-	payload = pkb->data;
297
+	payload = iobuf->data;
298 298
 	if ( flags & TCP_SYN ) {
299
-		mssopt = pkb_push ( pkb, sizeof ( *mssopt ) );
299
+		mssopt = iob_push ( iobuf, sizeof ( *mssopt ) );
300 300
 		mssopt->kind = TCP_OPTION_MSS;
301 301
 		mssopt->length = sizeof ( *mssopt );
302 302
 		mssopt->mss = htons ( TCP_MSS );
303 303
 	}
304
-	tcphdr = pkb_push ( pkb, sizeof ( *tcphdr ) );
304
+	tcphdr = iob_push ( iobuf, sizeof ( *tcphdr ) );
305 305
 	memset ( tcphdr, 0, sizeof ( *tcphdr ) );
306 306
 	tcphdr->src = tcp->local_port;
307 307
 	tcphdr->dest = tcp->peer.st_port;
308 308
 	tcphdr->seq = htonl ( tcp->snd_seq );
309 309
 	tcphdr->ack = htonl ( tcp->rcv_ack );
310
-	tcphdr->hlen = ( ( payload - pkb->data ) << 2 );
310
+	tcphdr->hlen = ( ( payload - iobuf->data ) << 2 );
311 311
 	tcphdr->flags = flags;
312 312
 	tcphdr->win = htons ( window );
313
-	tcphdr->csum = tcpip_chksum ( pkb->data, pkb_len ( pkb ) );
313
+	tcphdr->csum = tcpip_chksum ( iobuf->data, iob_len ( iobuf ) );
314 314
 
315 315
 	/* Dump header */
316 316
 	DBGC ( tcp, "TCP %p TX %d->%d %08lx..%08lx           %08lx %4zd",
@@ -321,7 +321,7 @@ static int tcp_senddata_conn ( struct tcp_connection *tcp, int force_send ) {
321 321
 	DBGC ( tcp, "\n" );
322 322
 
323 323
 	/* Transmit packet */
324
-	rc = tcpip_tx ( pkb, &tcp_protocol, &tcp->peer, NULL, &tcphdr->csum );
324
+	rc = tcpip_tx ( iobuf, &tcp_protocol, &tcp->peer, NULL, &tcphdr->csum );
325 325
 
326 326
 	/* If we got -ENETUNREACH, kill the connection immediately
327 327
 	 * because there is no point retrying.  This isn't strictly
@@ -372,22 +372,22 @@ static int tcp_send ( struct stream_connection *stream,
372 372
 		      const void *data, size_t len ) {
373 373
 	struct tcp_connection *tcp =
374 374
 		container_of ( stream, struct tcp_connection, stream );
375
-	struct pk_buff *pkb;
375
+	struct io_buffer *iobuf;
376 376
 
377
-	/* Check that we have a packet buffer to fill */
378
-	pkb = tcp->tx_pkb;
379
-	if ( ! pkb ) {
377
+	/* Check that we have a I/O buffer to fill */
378
+	iobuf = tcp->tx_iob;
379
+	if ( ! iobuf ) {
380 380
 		DBGC ( tcp, "TCP %p tried to send data outside of the "
381 381
 		       "senddata() method\n", tcp );
382 382
 		return -EINVAL;
383 383
 	}
384 384
 
385
-	/* Truncate length to fit packet buffer */
386
-	if ( len > pkb_tailroom ( pkb ) )
387
-		len = pkb_tailroom ( pkb );
385
+	/* Truncate length to fit I/O buffer */
386
+	if ( len > iob_tailroom ( iobuf ) )
387
+		len = iob_tailroom ( iobuf );
388 388
 
389 389
 	/* Copy payload */
390
-	memmove ( pkb_put ( pkb, len ), data, len );
390
+	memmove ( iob_put ( iobuf, len ), data, len );
391 391
 
392 392
 	return 0;
393 393
 }
@@ -434,19 +434,19 @@ static void tcp_expired ( struct retry_timer *timer, int over ) {
434 434
  */
435 435
 static int tcp_send_reset ( struct tcp_connection *tcp,
436 436
 			    struct tcp_header *in_tcphdr ) {
437
-	struct pk_buff *pkb;
437
+	struct io_buffer *iobuf;
438 438
 	struct tcp_header *tcphdr;
439 439
 
440 440
 	/* Allocate space for dataless TX buffer */
441
-	pkb = alloc_pkb ( MAX_HDR_LEN );
442
-	if ( ! pkb ) {
441
+	iobuf = alloc_iob ( MAX_HDR_LEN );
442
+	if ( ! iobuf ) {
443 443
 		DBGC ( tcp, "TCP %p could not allocate data buffer\n", tcp );
444 444
 		return -ENOMEM;
445 445
 	}
446
-	pkb_reserve ( pkb, MAX_HDR_LEN );
446
+	iob_reserve ( iobuf, MAX_HDR_LEN );
447 447
 
448 448
 	/* Construct RST response */
449
-	tcphdr = pkb_push ( pkb, sizeof ( *tcphdr ) );
449
+	tcphdr = iob_push ( iobuf, sizeof ( *tcphdr ) );
450 450
 	memset ( tcphdr, 0, sizeof ( *tcphdr ) );
451 451
 	tcphdr->src = in_tcphdr->dest;
452 452
 	tcphdr->dest = in_tcphdr->src;
@@ -455,7 +455,7 @@ static int tcp_send_reset ( struct tcp_connection *tcp,
455 455
 	tcphdr->hlen = ( ( sizeof ( *tcphdr ) / 4 ) << 4 );
456 456
 	tcphdr->flags = ( TCP_RST | TCP_ACK );
457 457
 	tcphdr->win = htons ( TCP_MAX_WINDOW_SIZE );
458
-	tcphdr->csum = tcpip_chksum ( pkb->data, pkb_len ( pkb ) );
458
+	tcphdr->csum = tcpip_chksum ( iobuf->data, iob_len ( iobuf ) );
459 459
 
460 460
 	/* Dump header */
461 461
 	DBGC ( tcp, "TCP %p TX %d->%d %08lx..%08lx           %08lx %4zd",
@@ -466,7 +466,7 @@ static int tcp_send_reset ( struct tcp_connection *tcp,
466 466
 	DBGC ( tcp, "\n" );
467 467
 
468 468
 	/* Transmit packet */
469
-	return tcpip_tx ( pkb, &tcp_protocol, &tcp->peer,
469
+	return tcpip_tx ( iobuf, &tcp_protocol, &tcp->peer,
470 470
 			  NULL, &tcphdr->csum );
471 471
 }
472 472
 
@@ -662,17 +662,17 @@ static int tcp_rx_rst ( struct tcp_connection *tcp, uint32_t seq ) {
662 662
 /**
663 663
  * Process received packet
664 664
  *
665
- * @v pkb		Packet buffer
665
+ * @v iobuf		I/O buffer
666 666
  * @v st_src		Partially-filled source address
667 667
  * @v st_dest		Partially-filled destination address
668 668
  * @v pshdr_csum	Pseudo-header checksum
669 669
  * @ret rc		Return status code
670 670
   */
671
-static int tcp_rx ( struct pk_buff *pkb,
671
+static int tcp_rx ( struct io_buffer *iobuf,
672 672
 		    struct sockaddr_tcpip *st_src __unused,
673 673
 		    struct sockaddr_tcpip *st_dest __unused,
674 674
 		    uint16_t pshdr_csum ) {
675
-	struct tcp_header *tcphdr = pkb->data;
675
+	struct tcp_header *tcphdr = iobuf->data;
676 676
 	struct tcp_connection *tcp;
677 677
 	unsigned int hlen;
678 678
 	uint16_t csum;
@@ -686,9 +686,9 @@ static int tcp_rx ( struct pk_buff *pkb,
686 686
 	int rc;
687 687
 
688 688
 	/* Sanity check packet */
689
-	if ( pkb_len ( pkb ) < sizeof ( *tcphdr ) ) {
689
+	if ( iob_len ( iobuf ) < sizeof ( *tcphdr ) ) {
690 690
 		DBG ( "TCP packet too short at %d bytes (min %d bytes)\n",
691
-		      pkb_len ( pkb ), sizeof ( *tcphdr ) );
691
+		      iob_len ( iobuf ), sizeof ( *tcphdr ) );
692 692
 		rc = -EINVAL;
693 693
 		goto done;
694 694
 	}
@@ -699,13 +699,13 @@ static int tcp_rx ( struct pk_buff *pkb,
699 699
 		rc = -EINVAL;
700 700
 		goto done;
701 701
 	}
702
-	if ( hlen > pkb_len ( pkb ) ) {
702
+	if ( hlen > iob_len ( iobuf ) ) {
703 703
 		DBG ( "TCP header too long at %d bytes (max %d bytes)\n",
704
-		      hlen, pkb_len ( pkb ) );
704
+		      hlen, iob_len ( iobuf ) );
705 705
 		rc = -EINVAL;
706 706
 		goto done;
707 707
 	}
708
-	csum = tcpip_continue_chksum ( pshdr_csum, pkb->data, pkb_len ( pkb ));
708
+	csum = tcpip_continue_chksum ( pshdr_csum, iobuf->data, iob_len ( iobuf ));
709 709
 	if ( csum != 0 ) {
710 710
 		DBG ( "TCP checksum incorrect (is %04x including checksum "
711 711
 		      "field, should be 0000)\n", csum );
@@ -719,8 +719,8 @@ static int tcp_rx ( struct pk_buff *pkb,
719 719
 	ack = ntohl ( tcphdr->ack );
720 720
 	win = ntohs ( tcphdr->win );
721 721
 	flags = tcphdr->flags;
722
-	data = pkb_pull ( pkb, hlen );
723
-	len = pkb_len ( pkb );
722
+	data = iob_pull ( iobuf, hlen );
723
+	len = iob_len ( iobuf );
724 724
 
725 725
 	/* Dump header */
726 726
 	DBGC ( tcp, "TCP %p RX %d<-%d           %08lx %08lx..%08lx %4zd",
@@ -787,7 +787,7 @@ static int tcp_rx ( struct pk_buff *pkb,
787 787
 	rc = 0;
788 788
  done:
789 789
 	/* Free received packet */
790
-	free_pkb ( pkb );
790
+	free_iob ( iobuf );
791 791
 	return rc;
792 792
 }
793 793
 

+ 9
- 9
src/net/tcpip.c Целия файл

@@ -2,7 +2,7 @@
2 2
 #include <string.h>
3 3
 #include <errno.h>
4 4
 #include <byteswap.h>
5
-#include <gpxe/pkbuff.h>
5
+#include <gpxe/iobuf.h>
6 6
 #include <gpxe/tables.h>
7 7
 #include <gpxe/tcpip.h>
8 8
 
@@ -28,7 +28,7 @@ static struct tcpip_protocol tcpip_protocols_end[0]
28 28
 
29 29
 /** Process a received TCP/IP packet
30 30
  *
31
- * @v pkb		Packet buffer
31
+ * @v iobuf		I/O buffer
32 32
  * @v tcpip_proto	Transport-layer protocol number
33 33
  * @v st_src		Partially-filled source address
34 34
  * @v st_dest		Partially-filled destination address
@@ -41,7 +41,7 @@ static struct tcpip_protocol tcpip_protocols_end[0]
41 41
  * address family and the network-layer addresses, but leave the ports
42 42
  * and the rest of the structures as zero).
43 43
  */
44
-int tcpip_rx ( struct pk_buff *pkb, uint8_t tcpip_proto, 
44
+int tcpip_rx ( struct io_buffer *iobuf, uint8_t tcpip_proto, 
45 45
 	       struct sockaddr_tcpip *st_src,
46 46
 	       struct sockaddr_tcpip *st_dest,
47 47
 	       uint16_t pshdr_csum ) {
@@ -51,25 +51,25 @@ int tcpip_rx ( struct pk_buff *pkb, uint8_t tcpip_proto,
51 51
 	for ( tcpip = tcpip_protocols; tcpip < tcpip_protocols_end; tcpip++ ) {
52 52
 		if ( tcpip->tcpip_proto == tcpip_proto ) {
53 53
 			DBG ( "TCP/IP received %s packet\n", tcpip->name );
54
-			return tcpip->rx ( pkb, st_src, st_dest, pshdr_csum );
54
+			return tcpip->rx ( iobuf, st_src, st_dest, pshdr_csum );
55 55
 		}
56 56
 	}
57 57
 
58 58
 	DBG ( "Unrecognised TCP/IP protocol %d\n", tcpip_proto );
59
-	free_pkb ( pkb );
59
+	free_iob ( iobuf );
60 60
 	return -EPROTONOSUPPORT;
61 61
 }
62 62
 
63 63
 /** Transmit a TCP/IP packet
64 64
  *
65
- * @v pkb		Packet buffer
65
+ * @v iobuf		I/O buffer
66 66
  * @v tcpip_protocol	Transport-layer protocol
67 67
  * @v st_dest		Destination address
68 68
  * @v netdev		Network device to use if no route found, or NULL
69 69
  * @v trans_csum	Transport-layer checksum to complete, or NULL
70 70
  * @ret rc		Return status code
71 71
  */
72
-int tcpip_tx ( struct pk_buff *pkb, struct tcpip_protocol *tcpip_protocol,
72
+int tcpip_tx ( struct io_buffer *iobuf, struct tcpip_protocol *tcpip_protocol,
73 73
 	       struct sockaddr_tcpip *st_dest, struct net_device *netdev,
74 74
 	       uint16_t *trans_csum ) {
75 75
 	struct tcpip_net_protocol *tcpip_net;
@@ -79,13 +79,13 @@ int tcpip_tx ( struct pk_buff *pkb, struct tcpip_protocol *tcpip_protocol,
79 79
 	      tcpip_net < tcpip_net_protocols_end ; tcpip_net++ ) {
80 80
 		if ( tcpip_net->sa_family == st_dest->st_family ) {
81 81
 			DBG ( "TCP/IP sending %s packet\n", tcpip_net->name );
82
-			return tcpip_net->tx ( pkb, tcpip_protocol, st_dest,
82
+			return tcpip_net->tx ( iobuf, tcpip_protocol, st_dest,
83 83
 					       netdev, trans_csum );
84 84
 		}
85 85
 	}
86 86
 	
87 87
 	DBG ( "Unrecognised TCP/IP address family %d\n", st_dest->st_family );
88
-	free_pkb ( pkb );
88
+	free_iob ( iobuf );
89 89
 	return -EAFNOSUPPORT;
90 90
 }
91 91
 

+ 42
- 42
src/net/udp.c Целия файл

@@ -4,7 +4,7 @@
4 4
 #include <byteswap.h>
5 5
 #include <errno.h>
6 6
 #include <gpxe/tcpip.h>
7
-#include <gpxe/pkbuff.h>
7
+#include <gpxe/iobuf.h>
8 8
 #include <gpxe/netdevice.h>
9 9
 #include <gpxe/udp.h>
10 10
 
@@ -89,22 +89,22 @@ void udp_close ( struct udp_connection *conn ) {
89 89
 }
90 90
 
91 91
 /**
92
- * Allocate packet buffer for UDP
92
+ * Allocate I/O buffer for UDP
93 93
  *
94 94
  * @v conn		UDP connection
95
- * @ret pkb		Packet buffer, or NULL
95
+ * @ret iobuf		I/O buffer, or NULL
96 96
  */
97
-static struct pk_buff * udp_alloc_pkb ( struct udp_connection *conn ) {
98
-	struct pk_buff *pkb;
97
+static struct io_buffer * udp_alloc_iob ( struct udp_connection *conn ) {
98
+	struct io_buffer *iobuf;
99 99
 
100
-	pkb = alloc_pkb ( UDP_MAX_TXPKB );
101
-	if ( ! pkb ) {
100
+	iobuf = alloc_iob ( UDP_MAX_TXIOB );
101
+	if ( ! iobuf ) {
102 102
 		DBGC ( conn, "UDP %p cannot allocate buffer of length %d\n",
103
-		       conn, UDP_MAX_TXPKB );
103
+		       conn, UDP_MAX_TXIOB );
104 104
 		return NULL;
105 105
 	}
106
-	pkb_reserve ( pkb, UDP_MAX_HLEN );
107
-	return pkb;
106
+	iob_reserve ( iobuf, UDP_MAX_HLEN );
107
+	return iobuf;
108 108
 }
109 109
 
110 110
 /**
@@ -119,20 +119,20 @@ static struct pk_buff * udp_alloc_pkb ( struct udp_connection *conn ) {
119 119
 int udp_senddata ( struct udp_connection *conn ) {
120 120
 	int rc;
121 121
 
122
-	conn->tx_pkb = udp_alloc_pkb ( conn );
123
-	if ( ! conn->tx_pkb )
122
+	conn->tx_iob = udp_alloc_iob ( conn );
123
+	if ( ! conn->tx_iob )
124 124
 		return -ENOMEM;
125 125
 
126
-	rc = conn->udp_op->senddata ( conn, conn->tx_pkb->data, 
127
-				      pkb_tailroom ( conn->tx_pkb ) );
126
+	rc = conn->udp_op->senddata ( conn, conn->tx_iob->data, 
127
+				      iob_tailroom ( conn->tx_iob ) );
128 128
 	if ( rc != 0 ) {
129 129
 		DBGC ( conn, "UDP %p application could not send packet: %s\n",
130 130
 		       conn, strerror ( rc ) );
131 131
 	}
132 132
 
133
-	if ( conn->tx_pkb ) {
134
-		free_pkb ( conn->tx_pkb );
135
-		conn->tx_pkb = NULL;
133
+	if ( conn->tx_iob ) {
134
+		free_iob ( conn->tx_iob );
135
+		conn->tx_iob = NULL;
136 136
 	}
137 137
 
138 138
 	return rc;
@@ -152,25 +152,25 @@ int udp_sendto_via ( struct udp_connection *conn, struct sockaddr_tcpip *peer,
152 152
 		     struct net_device *netdev, const void *data,
153 153
 		     size_t len ) {
154 154
        	struct udp_header *udphdr;
155
-	struct pk_buff *pkb;
155
+	struct io_buffer *iobuf;
156 156
 	int rc;
157 157
 
158
-	/* Use precreated packet buffer if one is available */
159
-	if ( conn->tx_pkb ) {
160
-		pkb = conn->tx_pkb;
161
-		conn->tx_pkb = NULL;
158
+	/* Use precreated I/O buffer if one is available */
159
+	if ( conn->tx_iob ) {
160
+		iobuf = conn->tx_iob;
161
+		conn->tx_iob = NULL;
162 162
 	} else {
163
-		pkb = udp_alloc_pkb ( conn );
164
-		if ( ! pkb )
163
+		iobuf = udp_alloc_iob ( conn );
164
+		if ( ! iobuf )
165 165
 			return -ENOMEM;
166 166
 	}
167 167
 
168 168
 	/* Avoid overflowing TX buffer */
169
-	if ( len > pkb_tailroom ( pkb ) )
170
-		len = pkb_tailroom ( pkb );
169
+	if ( len > iob_tailroom ( iobuf ) )
170
+		len = iob_tailroom ( iobuf );
171 171
 
172 172
 	/* Copy payload */
173
-	memmove ( pkb_put ( pkb, len ), data, len );
173
+	memmove ( iob_put ( iobuf, len ), data, len );
174 174
 
175 175
 	/*
176 176
 	 * Add the UDP header
@@ -178,10 +178,10 @@ int udp_sendto_via ( struct udp_connection *conn, struct sockaddr_tcpip *peer,
178 178
 	 * Covert all 16- and 32- bit integers into network btye order before
179 179
 	 * sending it over the network
180 180
 	 */
181
-	udphdr = pkb_push ( pkb, sizeof ( *udphdr ) );
181
+	udphdr = iob_push ( iobuf, sizeof ( *udphdr ) );
182 182
 	udphdr->dest_port = peer->st_port;
183 183
 	udphdr->source_port = conn->local_port;
184
-	udphdr->len = htons ( pkb_len ( pkb ) );
184
+	udphdr->len = htons ( iob_len ( iobuf ) );
185 185
 	udphdr->chksum = 0;
186 186
 	udphdr->chksum = tcpip_chksum ( udphdr, sizeof ( *udphdr ) + len );
187 187
 
@@ -191,7 +191,7 @@ int udp_sendto_via ( struct udp_connection *conn, struct sockaddr_tcpip *peer,
191 191
 	       ntohs ( udphdr->len ) );
192 192
 
193 193
 	/* Send it to the next layer for processing */
194
-	if ( ( rc = tcpip_tx ( pkb, &udp_protocol, peer, netdev,
194
+	if ( ( rc = tcpip_tx ( iobuf, &udp_protocol, peer, netdev,
195 195
 			       &udphdr->chksum ) ) != 0 ) {
196 196
 		DBGC ( conn, "UDP %p could not transmit packet: %s\n",
197 197
 		       conn, strerror ( rc ) );
@@ -248,24 +248,24 @@ static struct udp_connection * udp_demux ( uint16_t local_port ) {
248 248
 /**
249 249
  * Process a received packet
250 250
  *
251
- * @v pkb		Packet buffer
251
+ * @v iobuf		I/O buffer
252 252
  * @v st_src		Partially-filled source address
253 253
  * @v st_dest		Partially-filled destination address
254 254
  * @v pshdr_csum	Pseudo-header checksum
255 255
  * @ret rc		Return status code
256 256
  */
257
-static int udp_rx ( struct pk_buff *pkb, struct sockaddr_tcpip *st_src,
257
+static int udp_rx ( struct io_buffer *iobuf, struct sockaddr_tcpip *st_src,
258 258
 		    struct sockaddr_tcpip *st_dest, uint16_t pshdr_csum ) {
259
-	struct udp_header *udphdr = pkb->data;
259
+	struct udp_header *udphdr = iobuf->data;
260 260
 	struct udp_connection *conn;
261 261
 	size_t ulen;
262 262
 	uint16_t csum;
263 263
 	int rc = 0;
264 264
 
265 265
 	/* Sanity check packet */
266
-	if ( pkb_len ( pkb ) < sizeof ( *udphdr ) ) {
266
+	if ( iob_len ( iobuf ) < sizeof ( *udphdr ) ) {
267 267
 		DBG ( "UDP packet too short at %d bytes (min %d bytes)\n",
268
-		      pkb_len ( pkb ), sizeof ( *udphdr ) );
268
+		      iob_len ( iobuf ), sizeof ( *udphdr ) );
269 269
 		
270 270
 		rc = -EINVAL;
271 271
 		goto done;
@@ -277,14 +277,14 @@ static int udp_rx ( struct pk_buff *pkb, struct sockaddr_tcpip *st_src,
277 277
 		rc = -EINVAL;
278 278
 		goto done;
279 279
 	}
280
-	if ( ulen > pkb_len ( pkb ) ) {
280
+	if ( ulen > iob_len ( iobuf ) ) {
281 281
 		DBG ( "UDP length too long at %d bytes (packet is %d bytes)\n",
282
-		      ulen, pkb_len ( pkb ) );
282
+		      ulen, iob_len ( iobuf ) );
283 283
 		rc = -EINVAL;
284 284
 		goto done;
285 285
 	}
286 286
 	if ( udphdr->chksum ) {
287
-		csum = tcpip_continue_chksum ( pshdr_csum, pkb->data, ulen );
287
+		csum = tcpip_continue_chksum ( pshdr_csum, iobuf->data, ulen );
288 288
 		if ( csum != 0 ) {
289 289
 			DBG ( "UDP checksum incorrect (is %04x including "
290 290
 			      "checksum field, should be 0000)\n", csum );
@@ -297,8 +297,8 @@ static int udp_rx ( struct pk_buff *pkb, struct sockaddr_tcpip *st_src,
297 297
 	st_src->st_port = udphdr->source_port;
298 298
 	st_dest->st_port = udphdr->dest_port;
299 299
 	conn = udp_demux ( udphdr->dest_port );
300
-	pkb_unput ( pkb, ( pkb_len ( pkb ) - ulen ) );
301
-	pkb_pull ( pkb, sizeof ( *udphdr ) );
300
+	iob_unput ( iobuf, ( iob_len ( iobuf ) - ulen ) );
301
+	iob_pull ( iobuf, sizeof ( *udphdr ) );
302 302
 
303 303
 	/* Dump debugging information */
304 304
 	DBGC ( conn, "UDP %p RX %d<-%d len %zd\n", conn,
@@ -315,7 +315,7 @@ static int udp_rx ( struct pk_buff *pkb, struct sockaddr_tcpip *st_src,
315 315
 
316 316
 	/* Pass data to application */
317 317
 	if ( conn->udp_op->newdata ) {
318
-		rc = conn->udp_op->newdata ( conn, pkb->data, pkb_len ( pkb ),
318
+		rc = conn->udp_op->newdata ( conn, iobuf->data, iob_len ( iobuf ),
319 319
 				     st_src, st_dest );
320 320
 		if ( rc != 0 ) {
321 321
 			DBGC ( conn, "UDP %p application rejected packet: %s\n",
@@ -327,7 +327,7 @@ static int udp_rx ( struct pk_buff *pkb, struct sockaddr_tcpip *st_src,
327 327
 	}
328 328
 
329 329
  done:
330
-	free_pkb ( pkb );
330
+	free_iob ( iobuf );
331 331
 	return rc;
332 332
 }
333 333
 

Loading…
Отказ
Запис