Lines Matching +full:layer +full:- +full:buffer +full:- +full:offset
76 file is a user-settable packet filter.
88 .Sh BUFFER MODES
92 The buffer mode is set using the
106 The user process will declare a fixed buffer size that will be used both for
115 Note that an individual packet larger than the buffer size is necessarily
117 .Ss Zero-copy buffer mode
123 Buffers are of fixed (and equal) size, page-aligned, and an even multiple of
125 The maximum zero-copy buffer size is returned by the
128 Note that an individual packet larger than the buffer size is necessarily
136 .Bd -literal
145 is a pointer to the userspace address of the first buffer that will be
148 is a pointer to the second buffer.
152 Each buffer begins with a fixed-length header to hold synchronization and
153 data length information for the buffer:
154 .Bd -literal
157 volatile u_int bzh_kernel_len; /* Length of data in the buffer. */
163 The header structure of each buffer, including all padding, should be zeroed
166 Remaining space in the buffer will be used by the kernel to store packet
170 the buffer header to synchronize access to the buffer: when the header
175 hold the same value, the kernel owns the buffer, and when they differ,
176 userspace owns the buffer.
178 While the kernel owns the buffer, the contents are unstable and may change
179 asynchronously; while the user process owns the buffer, its contents are
180 stable and will not be changed until the buffer has been acknowledged.
182 Initializing the buffer headers to all 0's before registering the buffer has
184 The kernel signals that a buffer has been assigned to userspace by modifying
186 and userspace acknowledges the buffer and returns it to the kernel by setting
192 In order to avoid caching and memory re-ordering effects, the user process
195 .Bd -literal
199 * Return ownership of a buffer to the kernel for reuse.
205 atomic_store_rel_int(&bzh->bzh_user_gen, bzh->bzh_kernel_gen);
209 * Check whether a buffer has been assigned to userspace by the kernel.
210 * Return true if userspace owns the buffer, and false otherwise.
216 return (bzh->bzh_user_gen !=
217 atomic_load_acq_int(&bzh->bzh_kernel_gen));
221 The user process may force the assignment of the next buffer, if any data
225 This allows the user process to retrieve data in a partially filled buffer
226 before the buffer is full, such as following a timeout; the process must
227 recheck for buffer ownership using the header generation numbers, as the
228 buffer will not be assigned to userspace if no data was present.
235 may be used to sleep awaiting the availability of a completed buffer.
236 They will return a readable file descriptor when ownership of the next buffer
241 the invariant that at most one buffer could be assigned to the user process
244 acknowledge a completely processed buffer as quickly as possible, returning
245 it for reuse, and not block waiting on a second buffer while holding another
246 buffer.
254 .Bd -literal
278 .Bl -tag -width BIOCGETBUFMODE
281 Returns the required buffer length for reads on
286 Sets the buffer length for reads on
289 The buffer must be set before the file is attached to an interface
292 If the requested buffer size cannot be accommodated, the closest
296 if it is passed a buffer that is not this size.
299 Returns the type of the data link layer underlying the attached interface.
308 Returns an array of the available types of the data link layer
310 .Bd -literal -offset indent
323 is returned if there is not enough buffer space and
339 Changes the type of the data link layer underlying the attached interface.
347 a listener that opened its interface non-promiscuously may receive
354 Flushes the buffer of incoming packets,
389 .Bd -literal
397 .Bl -hang -offset indent
404 kernel because of buffer overflows
414 Otherwise, a read will block until either the kernel buffer
427 .Bd -literal
474 .Bd -literal
551 to get time stamps in 64-bit
560 to get time stamps in 64-bit
569 to get time stamps in 64-bit
575 All 64-bit time stamp formats are wrapped in
625 zero-copy buffer mode.
628 Set the current zero-copy buffer locations; buffer locations may be
629 set only once zero-copy buffer mode has been selected, and prior to attaching
631 Buffers must be of identical size, page-aligned, and an integer multiple of
642 Get the largest individual zero-copy buffer size allowed.
643 As two buffers are used in zero-copy buffer mode, the limit (in practice) is
645 As zero-copy buffers consume kernel address space, conservative selection of
646 buffer size is suggested, especially when there are multiple
648 descriptors in use on 32-bit systems.
650 Force ownership of the next buffer to be assigned to userspace, if any data
651 present in the buffer.
652 If no data is present, the buffer will remain owned by the kernel.
653 This allows consumers of zero-copy buffering to implement timeouts and
655 In order to handle the case where no data is present in the buffer and
667 which allow the user to do async and/or non-blocking I/O to an open
670 .Bl -tag -width SIOCGIFADDR
679 Sets or clears non-blocking I/O.
680 If arg is non-zero, then doing a
682 when no data is available will return -1 and
686 If arg is zero, non-blocking I/O is disabled.
692 When enabled (arg is non-zero), the process or process group specified by
717 or via a zero-copy buffer:
718 .Bd -literal
738 .Bl -tag -compact -width bh_datalen
752 .\" XXX - not really a function call
768 and the network layer
787 must be taken when accessing the link layer protocol fields on alignment
790 the type field is a short falling on an even offset,
811 .Dl p = (char *)p + BPF_WORDALIGN(p->bh_hdrlen + p->bh_caplen)
814 buffer passed to
820 will always return an aligned buffer.
826 Each instruction performs some action on the pseudo-machine state,
831 .Bd -literal
849 The opcodes are encoded in a semi-hierarchical fashion.
870 P[i:n] gives the data at byte offset
879 - 1.
888 .Bl -tag -width BPF_STXx
895 packet data at a fixed offset
897 packet data at a variable offset
916 .Bd -literal
917 BPF_LD+BPF_W+BPF_ABS A <- P[k:4]
918 BPF_LD+BPF_H+BPF_ABS A <- P[k:2]
919 BPF_LD+BPF_B+BPF_ABS A <- P[k:1]
920 BPF_LD+BPF_W+BPF_IND A <- P[X+k:4]
921 BPF_LD+BPF_H+BPF_IND A <- P[X+k:2]
922 BPF_LD+BPF_B+BPF_IND A <- P[X+k:1]
923 BPF_LD+BPF_W+BPF_LEN A <- len
924 BPF_LD+BPF_IMM A <- k
925 BPF_LD+BPF_MEM A <- M[k]
934 .Bd -literal
935 BPF_LDX+BPF_W+BPF_IMM X <- k
936 BPF_LDX+BPF_W+BPF_MEM X <- M[k]
937 BPF_LDX+BPF_W+BPF_LEN X <- len
938 BPF_LDX+BPF_B+BPF_MSH X <- 4*(P[k:1]&0xf)
944 .Bd -literal
945 BPF_ST M[k] <- A
949 .Bd -literal
950 BPF_STX M[k] <- X
959 .Bd -literal
960 BPF_ALU+BPF_ADD+BPF_K A <- A + k
961 BPF_ALU+BPF_SUB+BPF_K A <- A - k
962 BPF_ALU+BPF_MUL+BPF_K A <- A * k
963 BPF_ALU+BPF_DIV+BPF_K A <- A / k
964 BPF_ALU+BPF_MOD+BPF_K A <- A % k
965 BPF_ALU+BPF_AND+BPF_K A <- A & k
966 BPF_ALU+BPF_OR+BPF_K A <- A | k
967 BPF_ALU+BPF_XOR+BPF_K A <- A ^ k
968 BPF_ALU+BPF_LSH+BPF_K A <- A << k
969 BPF_ALU+BPF_RSH+BPF_K A <- A >> k
970 BPF_ALU+BPF_ADD+BPF_X A <- A + X
971 BPF_ALU+BPF_SUB+BPF_X A <- A - X
972 BPF_ALU+BPF_MUL+BPF_X A <- A * X
973 BPF_ALU+BPF_DIV+BPF_X A <- A / X
974 BPF_ALU+BPF_MOD+BPF_X A <- A % X
975 BPF_ALU+BPF_AND+BPF_X A <- A & X
976 BPF_ALU+BPF_OR+BPF_X A <- A | X
977 BPF_ALU+BPF_XOR+BPF_X A <- A ^ X
978 BPF_ALU+BPF_LSH+BPF_X A <- A << X
979 BPF_ALU+BPF_RSH+BPF_X A <- A >> X
980 BPF_ALU+BPF_NEG A <- -A
989 If the result is true (or non-zero),
996 field as the offset, allowing arbitrarily distant destinations.
998 .Bd -literal
1017 .Bd -literal
1027 .Bd -literal
1028 BPF_MISC+BPF_TAX X <- A
1029 BPF_MISC+BPF_TXA A <- X
1046 .Bl -tag -width indent
1052 makes new BPF users to be attached to write-only interface list until program
1055 This removes any performance degradation for high-speed interfaces.
1059 Permits zero-copy to be used with net BPF readers.
1068 Maximum buffer size to allocate for packets buffer.
1070 Default buffer size to allocate for packets buffer.
1075 .Bd -literal
1089 .Bd -literal
1100 BPF_STMT(BPF_RET+BPF_K, (u_int)-1),
1110 checks that the IP fragment offset is 0 so we are sure
1112 .Bd -literal
1125 BPF_STMT(BPF_RET+BPF_K, (u_int)-1),
1144 Rick Rashid at Carnegie-Mellon University.
1160 .An -nosplit
1167 Support for zero-copy buffers was added by
1171 The read buffer must be of a fixed size (returned by the
1190 and point-to-point interfaces.
1192 broad range of Ethernet-style interfaces.