Watt-32 tcp/ip  2.2 dev-rel.10
pcqueue.h
Go to the documentation of this file.
1 
3 #ifndef _w32_PCQUEUE_H
4 #define _w32_PCQUEUE_H
5 
6 #include <stddef.h>
7 
8 #ifndef __SYS_WTIME_H
9 #include <sys/wtime.h>
10 #endif
11 
12 #ifndef _w32_PCSED_H
13 #include "pcsed.h"
14 #endif
15 
19 #if defined(WIN32)
20  /*
21  * \todo Make RX_BUFS (i.e. size of thread queue) configurable.
22  * Only the NPF kernel-buffer size is configurable now (pkt_num_rx_bufs).
23  */
24  #define RX_BUFS 50
25 
26 #elif defined(USE_FAST_PKT)
27  #define RX_BUFS 40 /* max # that will fit in 64 kB */
28 
29 #elif (DOSX)
30  #if (DOSX & DOS4GW) /* allocation from DOS is limited to 64kB */
31  #define RX_BUFS 30
32  #else
33  #define RX_BUFS 50 /* # of receive buffers to use in queue */
34  #endif /* should be greater than MAX_FRAGMENT */
35 
36 #else
37  #define RX_BUFS 5
38 #endif
39 
40 #if (DOSX)
41  #define PKT_TMP_SIZE 64 /* scratch buffer only needed for 32-bit DOS */
42 #endif
43 
44 #define PKTQ_MARKER 0xDEAFBABE
45 
46 /*
47  * asmpkt4.asm depends on these structs beeing packed
48  */
49 #if (DOSX & DOS4GW) || defined(USE_FAST_PKT)
50 #include <sys/pack_on.h>
51 #endif
52 
53 #if defined(WIN32)
54  struct pkt_rx_element {
55  uint64 tstamp_put; /* timestamp from recv-thread */
56  uint64 tstamp_get; /* timestamp when polled */
57  WORD rx_length; /* length from PacketReceivePacket() */
58  BYTE rx_buf [ETH_MAX+10]; /* add some margin */
59  };
60 #else
61  struct pkt_rx_element {
62  DWORD tstamp_put[2]; /* RDTSC timestamp on 1st upcall */
63  DWORD tstamp_get[2]; /* RDTSC timestamp when polled */
64  WORD handle; /* Packet-driver handle of upcall */
65  WORD rx_length_1; /* length on 1st upcall */
66  WORD rx_length_2; /* length on 2nd upcall */
67  WORD filler; /* 4 byte alignment */
68  BYTE rx_buf [ETH_MAX+10]; /* add some margin */
69  }; /* = 1548 bytes */
70 #endif
71 
72 /* DOS: 1524+24=1548
73  */
74 #define RX_SIZE sizeof(struct pkt_rx_element)
75 #define RX_ELEMENT_HEAD_SIZE offsetof (struct pkt_rx_element, rx_buf[0])
76 
80 struct pkt_ringbuf {
81  volatile WORD in_index; /* index *ahead* of last buffer put */
82  WORD out_index; /* index of buffer pulled out */
83  WORD buf_size; /* size of each buffer */
84  WORD num_buf; /* number of buffers */
85  volatile DWORD num_drop; /* number of dropped pkts */
86  DWORD_PTR buf_start; /* start of buffer pool (linear addr) */
87 #if (DOSX & (DOS4GW|POWERPAK)) || defined(USE_FAST_PKT)
88  WORD dos_ofs; /* offset of pool, used by rmode stub */
89 #endif /* total size = 26 for DOS4GW/POWERPAK */
90  };
91 
92 #if (DOSX & DOS4GW) || defined(USE_FAST_PKT)
93 #include <sys/pack_off.h>
94 #endif
95 
96 extern int pktq_inc_in (struct pkt_ringbuf *q);
97 extern int pktq_inc_out (struct pkt_ringbuf *q);
98 extern int pktq_check (struct pkt_ringbuf *q);
99 extern void pktq_clear (struct pkt_ringbuf *q);
100 
101 extern int pktq_init (struct pkt_ringbuf *q, int size, int num, char *buf);
102 extern int pktq_in_index (struct pkt_ringbuf *q);
103 extern char *pktq_in_buf (struct pkt_ringbuf *q);
104 extern char *pktq_out_buf (struct pkt_ringbuf *q);
105 extern int pktq_queued (struct pkt_ringbuf *q);
106 
107 #if defined(USE_FAST_PKT) && defined(__MSDOS__)
108  extern DWORD asmpkt_rm_base;
109 
110  /* macros to access runtime location of 'asmpkt_inf'
111  */
112  #define FAR_PEEK_WORD(struc,mbr) PEEKW (0, asmpkt_rm_base + offsetof(struc,mbr))
113  #define FAR_PEEK_DWORD(struc,mbr) PEEKL (0, asmpkt_rm_base + offsetof(struc,mbr))
114 
115  #define FAR_POKE_WORD(struc,mbr,x) POKEW (0, asmpkt_rm_base + offsetof(struc,mbr), x)
116  #define FAR_POKE_DWORD(struc,mbr,x) POKEL (0, asmpkt_rm_base + offsetof(struc,mbr), x)
117 
118  extern int pktq_far_init (int size, int num, DWORD asmpkt_real_base);
119  extern int pktq_far_queued (void);
120  extern int pktq_far_check (struct pkt_ringbuf *q);
121 #endif
122 
123 #endif
unsigned long long uint64
our unsigned "long long" type
Definition: wattcp.h:60