mbuf.h (254799) | mbuf.h (254804) |
---|---|
1/*- 2 * Copyright (c) 1982, 1986, 1988, 1993 3 * The Regents of the University of California. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 14 unchanged lines hidden (view full) --- 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 * 30 * @(#)mbuf.h 8.5 (Berkeley) 2/19/95 | 1/*- 2 * Copyright (c) 1982, 1986, 1988, 1993 3 * The Regents of the University of California. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 14 unchanged lines hidden (view full) --- 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 * 30 * @(#)mbuf.h 8.5 (Berkeley) 2/19/95 |
31 * $FreeBSD: head/sys/sys/mbuf.h 254799 2013-08-24 16:57:44Z andre $ | 31 * $FreeBSD: head/sys/sys/mbuf.h 254804 2013-08-24 19:51:18Z andre $ |
32 */ 33 34#ifndef _SYS_MBUF_H_ 35#define _SYS_MBUF_H_ 36 37/* XXX: These includes suck. Sorry! */ 38#include <sys/queue.h> 39#ifdef _KERNEL --- 67 unchanged lines hidden (view full) --- 107 u_int16_t m_tag_id; /* Tag ID */ 108 u_int16_t m_tag_len; /* Length of data */ 109 u_int32_t m_tag_cookie; /* ABI/Module ID */ 110 void (*m_tag_free)(struct m_tag *); 111}; 112 113/* 114 * Record/packet header in first mbuf of chain; valid only if M_PKTHDR is set. | 32 */ 33 34#ifndef _SYS_MBUF_H_ 35#define _SYS_MBUF_H_ 36 37/* XXX: These includes suck. Sorry! */ 38#include <sys/queue.h> 39#ifdef _KERNEL --- 67 unchanged lines hidden (view full) --- 107 u_int16_t m_tag_id; /* Tag ID */ 108 u_int16_t m_tag_len; /* Length of data */ 109 u_int32_t m_tag_cookie; /* ABI/Module ID */ 110 void (*m_tag_free)(struct m_tag *); 111}; 112 113/* 114 * Record/packet header in first mbuf of chain; valid only if M_PKTHDR is set. |
115 * Size ILP32: 48 116 * LP64: 56 |
|
115 */ 116struct pkthdr { 117 struct ifnet *rcvif; /* rcv interface */ | 117 */ 118struct pkthdr { 119 struct ifnet *rcvif; /* rcv interface */ |
118 /* variables for ip and tcp reassembly */ 119 void *header; /* pointer to packet header */ 120 int len; /* total packet length */ 121 uint32_t flowid; /* packet's 4-tuple system 122 * flow identifier 123 */ 124 /* variables for hardware checksum */ 125 int csum_flags; /* flags regarding checksum */ 126 int csum_data; /* data field used by csum routines */ 127 u_int16_t tso_segsz; /* TSO segment size */ 128 union { 129 u_int16_t vt_vtag; /* Ethernet 802.1p+q vlan tag */ 130 u_int16_t vt_nrecs; /* # of IGMPv3 records in this chain */ 131 } PH_vt; 132 u_int16_t fibnum; /* this packet should use this fib */ 133 u_int16_t pad2; /* align to 32 bits */ | |
134 SLIST_HEAD(packet_tags, m_tag) tags; /* list of packet tags */ | 120 SLIST_HEAD(packet_tags, m_tag) tags; /* list of packet tags */ |
121 int32_t len; /* total packet length */ 122 123 /* Layer crossing persistent information. */ 124 uint32_t flowid; /* packet's 4-tuple system */ 125 uint64_t csum_flags; /* checksum and offload features */ 126 uint16_t fibnum; /* this packet should use this fib */ 127 uint8_t cosqos; /* class/quality of service */ 128 uint8_t rsstype; /* hash type */ 129 uint8_t l2hlen; /* layer 2 header length */ 130 uint8_t l3hlen; /* layer 3 header length */ 131 uint8_t l4hlen; /* layer 4 header length */ 132 uint8_t l5hlen; /* layer 5 header length */ 133 union { 134 uint8_t eigth[8]; 135 uint16_t sixteen[4]; 136 uint32_t thirtytwo[2]; 137 uint64_t sixtyfour[1]; 138 uintptr_t unintptr[1]; 139 void *ptr; 140 } PH_per; 141 142 /* Layer specific non-persistent local storage for reassembly, etc. */ 143 union { 144 uint8_t eigth[8]; 145 uint16_t sixteen[4]; 146 uint32_t thirtytwo[2]; 147 uint64_t sixtyfour[1]; 148 uintptr_t unintptr[1]; 149 void *ptr; 150 } PH_loc; |
|
135}; | 151}; |
136#define ether_vtag PH_vt.vt_vtag | 152#define ether_vtag PH_per.sixteen[0] 153#define PH_vt PH_per 154#define vt_nrecs sixteen[0] 155#define tso_segsz PH_per.sixteen[1] 156#define csum_phsum PH_per.sixteen[2] 157#define csum_data PH_per.thirtytwo[1] |
137 138/* 139 * Description of external storage mapped into mbuf; valid only if M_EXT is 140 * set. 141 * Size ILP32: 28 142 * LP64: 48 143 */ 144struct m_ext { --- 59 unchanged lines hidden (view full) --- 204#define M_PROTO6 0x00020000 /* protocol-specific */ 205#define M_PROTO7 0x00040000 /* protocol-specific */ 206#define M_PROTO8 0x00080000 /* protocol-specific */ 207#define M_PROTO9 0x00100000 /* protocol-specific */ 208#define M_PROTO10 0x00200000 /* protocol-specific */ 209#define M_PROTO11 0x00400000 /* protocol-specific */ 210#define M_PROTO12 0x00800000 /* protocol-specific */ 211 | 158 159/* 160 * Description of external storage mapped into mbuf; valid only if M_EXT is 161 * set. 162 * Size ILP32: 28 163 * LP64: 48 164 */ 165struct m_ext { --- 59 unchanged lines hidden (view full) --- 225#define M_PROTO6 0x00020000 /* protocol-specific */ 226#define M_PROTO7 0x00040000 /* protocol-specific */ 227#define M_PROTO8 0x00080000 /* protocol-specific */ 228#define M_PROTO9 0x00100000 /* protocol-specific */ 229#define M_PROTO10 0x00200000 /* protocol-specific */ 230#define M_PROTO11 0x00400000 /* protocol-specific */ 231#define M_PROTO12 0x00800000 /* protocol-specific */ 232 |
212#define M_HASHTYPEBITS 0x0F000000 /* mask of bits holding flowid hash type */ 213 | |
214/* 215 * Flags to purge when crossing layers. 216 */ 217#define M_PROTOFLAGS \ 218 (M_PROTO1|M_PROTO2|M_PROTO3|M_PROTO4|M_PROTO5|M_PROTO6|M_PROTO7|M_PROTO8|\ 219 M_PROTO9|M_PROTO10|M_PROTO11|M_PROTO12) 220 221/* | 233/* 234 * Flags to purge when crossing layers. 235 */ 236#define M_PROTOFLAGS \ 237 (M_PROTO1|M_PROTO2|M_PROTO3|M_PROTO4|M_PROTO5|M_PROTO6|M_PROTO7|M_PROTO8|\ 238 M_PROTO9|M_PROTO10|M_PROTO11|M_PROTO12) 239 240/* |
241 * Flags preserved when copying m_pkthdr. 242 */ 243#define M_COPYFLAGS \ 244 (M_PKTHDR|M_EOR|M_RDONLY|M_BCAST|M_MCAST|M_VLANTAG|M_PROMISC| \ 245 M_PROTOFLAGS) 246 247/* |
|
222 * Mbuf flag description for use with printf(9) %b identifier. 223 */ 224#define M_FLAG_BITS \ 225 "\20\1M_EXT\2M_PKTHDR\3M_EOR\4M_RDONLY\5M_BCAST\6M_MCAST" \ 226 "\7M_PROMISC\10M_VLANTAG\11M_FLOWID" 227#define M_FLAG_PROTOBITS \ 228 "\15M_PROTO1\16M_PROTO2\17M_PROTO3\20M_PROTO4\21M_PROTO5" \ 229 "\22M_PROTO6\23M_PROTO7\24M_PROTO8\25M_PROTO9\26M_PROTO10" \ --- 10 unchanged lines hidden (view full) --- 240 * network stack. 241 * 242 * Most NICs support RSS, which provides ordering and explicit affinity, and 243 * use the hash m_flag bits to indicate what header fields were covered by 244 * the hash. M_HASHTYPE_OPAQUE can be set by non-RSS cards or configurations 245 * that provide an opaque flow identifier, allowing for ordering and 246 * distribution without explicit affinity. 247 */ | 248 * Mbuf flag description for use with printf(9) %b identifier. 249 */ 250#define M_FLAG_BITS \ 251 "\20\1M_EXT\2M_PKTHDR\3M_EOR\4M_RDONLY\5M_BCAST\6M_MCAST" \ 252 "\7M_PROMISC\10M_VLANTAG\11M_FLOWID" 253#define M_FLAG_PROTOBITS \ 254 "\15M_PROTO1\16M_PROTO2\17M_PROTO3\20M_PROTO4\21M_PROTO5" \ 255 "\22M_PROTO6\23M_PROTO7\24M_PROTO8\25M_PROTO9\26M_PROTO10" \ --- 10 unchanged lines hidden (view full) --- 266 * network stack. 267 * 268 * Most NICs support RSS, which provides ordering and explicit affinity, and 269 * use the hash m_flag bits to indicate what header fields were covered by 270 * the hash. M_HASHTYPE_OPAQUE can be set by non-RSS cards or configurations 271 * that provide an opaque flow identifier, allowing for ordering and 272 * distribution without explicit affinity. 273 */ |
248#define M_HASHTYPE_SHIFT 24 249#define M_HASHTYPE_NONE 0x0 250#define M_HASHTYPE_RSS_IPV4 0x1 /* IPv4 2-tuple */ 251#define M_HASHTYPE_RSS_TCP_IPV4 0x2 /* TCPv4 4-tuple */ 252#define M_HASHTYPE_RSS_IPV6 0x3 /* IPv6 2-tuple */ 253#define M_HASHTYPE_RSS_TCP_IPV6 0x4 /* TCPv6 4-tuple */ 254#define M_HASHTYPE_RSS_IPV6_EX 0x5 /* IPv6 2-tuple + ext hdrs */ 255#define M_HASHTYPE_RSS_TCP_IPV6_EX 0x6 /* TCPv6 4-tiple + ext hdrs */ 256#define M_HASHTYPE_OPAQUE 0xf /* ordering, not affinity */ | 274#define M_HASHTYPE_NONE 0 275#define M_HASHTYPE_RSS_IPV4 1 /* IPv4 2-tuple */ 276#define M_HASHTYPE_RSS_TCP_IPV4 2 /* TCPv4 4-tuple */ 277#define M_HASHTYPE_RSS_IPV6 3 /* IPv6 2-tuple */ 278#define M_HASHTYPE_RSS_TCP_IPV6 4 /* TCPv6 4-tuple */ 279#define M_HASHTYPE_RSS_IPV6_EX 5 /* IPv6 2-tuple + ext hdrs */ 280#define M_HASHTYPE_RSS_TCP_IPV6_EX 6 /* TCPv6 4-tiple + ext hdrs */ 281#define M_HASHTYPE_OPAQUE 255 /* ordering, not affinity */ |
257 | 282 |
258#define M_HASHTYPE_CLEAR(m) (m)->m_flags &= ~(M_HASHTYPEBITS) 259#define M_HASHTYPE_GET(m) (((m)->m_flags & M_HASHTYPEBITS) >> \ 260 M_HASHTYPE_SHIFT) 261#define M_HASHTYPE_SET(m, v) do { \ 262 (m)->m_flags &= ~M_HASHTYPEBITS; \ 263 (m)->m_flags |= ((v) << M_HASHTYPE_SHIFT); \ 264} while (0) | 283#define M_HASHTYPE_CLEAR(m) ((m)->m_pkthdr.rsstype = 0) 284#define M_HASHTYPE_GET(m) ((m)->m_pkthdr.rsstype) 285#define M_HASHTYPE_SET(m, v) ((m)->m_pkthdr.rsstype = (v)) |
265#define M_HASHTYPE_TEST(m, v) (M_HASHTYPE_GET(m) == (v)) 266 267/* | 286#define M_HASHTYPE_TEST(m, v) (M_HASHTYPE_GET(m) == (v)) 287 288/* |
268 * Flags preserved when copying m_pkthdr. | 289 * COS/QOS class and quality of service tags. 290 * It uses DSCP code points as base. |
269 */ | 291 */ |
270#define M_COPYFLAGS \ 271 (M_PKTHDR|M_EOR|M_RDONLY|M_BCAST|M_MCAST|M_VLANTAG|M_PROMISC| \ 272 M_PROTOFLAGS|M_HASHTYPEBITS) | 292#define QOS_DSCP_CS0 0x00 293#define QOS_DSCP_DEF QOS_DSCP_CS0 294#define QOS_DSCP_CS1 0x20 295#define QOS_DSCP_AF11 0x28 296#define QOS_DSCP_AF12 0x30 297#define QOS_DSCP_AF13 0x38 298#define QOS_DSCP_CS2 0x40 299#define QOS_DSCP_AF21 0x48 300#define QOS_DSCP_AF22 0x50 301#define QOS_DSCP_AF23 0x58 302#define QOS_DSCP_CS3 0x60 303#define QOS_DSCP_AF31 0x68 304#define QOS_DSCP_AF32 0x70 305#define QOS_DSCP_AF33 0x78 306#define QOS_DSCP_CS4 0x80 307#define QOS_DSCP_AF41 0x88 308#define QOS_DSCP_AF42 0x90 309#define QOS_DSCP_AF43 0x98 310#define QOS_DSCP_CS5 0xa0 311#define QOS_DSCP_EF 0xb8 312#define QOS_DSCP_CS6 0xc0 313#define QOS_DSCP_CS7 0xe0 |
273 274/* 275 * External mbuf storage buffer types. 276 */ 277#define EXT_CLUSTER 1 /* mbuf cluster */ 278#define EXT_SFBUF 2 /* sendfile(2)'s sf_bufs */ 279#define EXT_JUMBOP 3 /* jumbo cluster 4096 bytes */ 280#define EXT_JUMBO9 4 /* jumbo cluster 9216 bytes */ --- 39 unchanged lines hidden (view full) --- 320 */ 321#define EXT_FLAG_BITS \ 322 "\20\1EXT_FLAG_EMBREF\2EXT_FLAG_EXTREF\5EXT_FLAG_NOFREE" \ 323 "\21EXT_FLAG_VENDOR1\22EXT_FLAG_VENDOR2\23EXT_FLAG_VENDOR3" \ 324 "\24EXT_FLAG_VENDOR4\25EXT_FLAG_EXP1\26EXT_FLAG_EXP2\27EXT_FLAG_EXP3" \ 325 "\30EXT_FLAG_EXP4" 326 327/* | 314 315/* 316 * External mbuf storage buffer types. 317 */ 318#define EXT_CLUSTER 1 /* mbuf cluster */ 319#define EXT_SFBUF 2 /* sendfile(2)'s sf_bufs */ 320#define EXT_JUMBOP 3 /* jumbo cluster 4096 bytes */ 321#define EXT_JUMBO9 4 /* jumbo cluster 9216 bytes */ --- 39 unchanged lines hidden (view full) --- 361 */ 362#define EXT_FLAG_BITS \ 363 "\20\1EXT_FLAG_EMBREF\2EXT_FLAG_EXTREF\5EXT_FLAG_NOFREE" \ 364 "\21EXT_FLAG_VENDOR1\22EXT_FLAG_VENDOR2\23EXT_FLAG_VENDOR3" \ 365 "\24EXT_FLAG_VENDOR4\25EXT_FLAG_EXP1\26EXT_FLAG_EXP2\27EXT_FLAG_EXP3" \ 366 "\30EXT_FLAG_EXP4" 367 368/* |
328 * Flags indicating hw checksum support and sw checksum requirements. This 329 * field can be directly tested against if_data.ifi_hwassist. | 369 * Flags indicating checksum, segmentation and other offload work to be 370 * done, or already done, by hardware or lower layers. It is split into 371 * separate inbound and outbound flags. 372 * 373 * Outbound flags that are set by upper protocol layers requesting lower 374 * layers, or ideally the hardware, to perform these offloading tasks. 375 * For outbound packets this field and its flags can be directly tested 376 * against if_data.ifi_hwassist. |
330 */ | 377 */ |
331#define CSUM_IP 0x0001 /* will csum IP */ 332#define CSUM_TCP 0x0002 /* will csum TCP */ 333#define CSUM_UDP 0x0004 /* will csum UDP */ 334#define CSUM_FRAGMENT 0x0010 /* will do IP fragmentation */ 335#define CSUM_TSO 0x0020 /* will do TSO */ 336#define CSUM_SCTP 0x0040 /* will csum SCTP */ 337#define CSUM_SCTP_IPV6 0x0080 /* will csum IPv6/SCTP */ | 378#define CSUM_IP 0x00000001 /* IP header checksum offload */ 379#define CSUM_IP_UDP 0x00000002 /* UDP checksum offload */ 380#define CSUM_IP_TCP 0x00000004 /* TCP checksum offload */ 381#define CSUM_IP_SCTP 0x00000008 /* SCTP checksum offload */ 382#define CSUM_IP_TSO 0x00000010 /* TCP segmentation offload */ 383#define CSUM_IP_ISCSI 0x00000020 /* iSCSI checksum offload */ |
338 | 384 |
339#define CSUM_IP_CHECKED 0x0100 /* did csum IP */ 340#define CSUM_IP_VALID 0x0200 /* ... the csum is valid */ 341#define CSUM_DATA_VALID 0x0400 /* csum_data field is valid */ 342#define CSUM_PSEUDO_HDR 0x0800 /* csum_data has pseudo hdr */ 343#define CSUM_SCTP_VALID 0x1000 /* SCTP checksum is valid */ 344#define CSUM_UDP_IPV6 0x2000 /* will csum IPv6/UDP */ 345#define CSUM_TCP_IPV6 0x4000 /* will csum IPv6/TCP */ 346/* CSUM_TSO_IPV6 0x8000 will do IPv6/TSO */ | 385#define CSUM_IP6_UDP 0x00000200 /* UDP checksum offload */ 386#define CSUM_IP6_TCP 0x00000400 /* TCP checksum offload */ 387#define CSUM_IP6_SCTP 0x00000800 /* SCTP checksum offload */ 388#define CSUM_IP6_TSO 0x00001000 /* TCP segmentation offload */ 389#define CSUM_IP6_ISCSI 0x00002000 /* iSCSI checksum offload */ |
347 | 390 |
348/* CSUM_FRAGMENT_IPV6 0x10000 will do IPv6 fragementation */ | 391/* Inbound checksum support where the checksum was verified by hardware. */ 392#define CSUM_L3_CALC 0x01000000 /* calculated layer 3 csum */ 393#define CSUM_L3_VALID 0x02000000 /* checksum is correct */ 394#define CSUM_L4_CALC 0x04000000 /* calculated layer 4 csum */ 395#define CSUM_L4_VALID 0x08000000 /* checksum is correct */ 396#define CSUM_L5_CALC 0x10000000 /* calculated layer 5 csum */ 397#define CSUM_L5_VALID 0x20000000 /* checksum is correct */ 398#define CSUM_COALESED 0x40000000 /* contains merged segments */ |
349 | 399 |
350#define CSUM_DELAY_DATA_IPV6 (CSUM_TCP_IPV6 | CSUM_UDP_IPV6) | 400/* 401 * CSUM flag description for use with printf(9) %b identifier. 402 */ 403#define CSUM_BITS \ 404 "\20\1CSUM_IP\2CSUM_IP_UDP\3CSUM_IP_TCP\4CSUM_IP_SCTP\5CSUM_IP_TSO" \ 405 "\6CSUM_IP_ISCSI" \ 406 "\12CSUM_IP6_UDP\13CSUM_IP6_TCP\14CSUM_IP6_SCTP\15CSUM_IP6_TSO" \ 407 "\16CSUM_IP6_ISCSI" \ 408 "\31CSUM_L3_CALC\32CSUM_L3_VALID\33CSUM_L4_CALC\34CSUM_L4_VALID" \ 409 "\35CSUM_L5_CALC\36CSUM_L5_VALID\37CSUM_COALESED" 410 411/* CSUM flags compatibility mappings. */ 412#define CSUM_IP_CHECKED CSUM_L3_CALC 413#define CSUM_IP_VALID CSUM_L3_VALID 414#define CSUM_DATA_VALID CSUM_L4_VALID 415#define CSUM_PSEUDO_HDR CSUM_L4_CALC 416#define CSUM_SCTP_VALID CSUM_L3_VALID 417#define CSUM_DELAY_DATA (CSUM_TCP|CSUM_UDP) 418#define CSUM_DELAY_IP CSUM_IP /* Only v4, no v6 IP hdr csum */ 419#define CSUM_DELAY_DATA_IPV6 (CSUM_TCP_IPV6|CSUM_UDP_IPV6) |
351#define CSUM_DATA_VALID_IPV6 CSUM_DATA_VALID | 420#define CSUM_DATA_VALID_IPV6 CSUM_DATA_VALID |
421#define CSUM_TCP CSUM_IP_TCP 422#define CSUM_UDP CSUM_IP_UDP 423#define CSUM_SCTP CSUM_IP_SCTP 424#define CSUM_TSO (CSUM_IP_TSO|CSUM_IP6_TSO) 425#define CSUM_UDP_IPV6 CSUM_IP6_UDP 426#define CSUM_TCP_IPV6 CSUM_IP6_TCP 427#define CSUM_SCTP_IPV6 CSUM_IP6_SCTP 428#define CSUM_FRAGMENT 0x0 /* Unused */ |
|
352 | 429 |
353#define CSUM_DELAY_DATA (CSUM_TCP | CSUM_UDP) 354#define CSUM_DELAY_IP (CSUM_IP) /* Only v4, no v6 IP hdr csum */ 355 | |
356/* 357 * mbuf types. 358 */ 359#define MT_NOTMBUF 0 /* USED INTERNALLY ONLY! Object is not mbuf */ 360#define MT_DATA 1 /* dynamic (data) allocation */ 361#define MT_HEADER MT_DATA /* packet header, use M_PKTHDR instead */ 362#define MT_SONAME 8 /* socket name */ 363#define MT_CONTROL 14 /* extra-data protocol message */ --- 703 unchanged lines hidden --- | 430/* 431 * mbuf types. 432 */ 433#define MT_NOTMBUF 0 /* USED INTERNALLY ONLY! Object is not mbuf */ 434#define MT_DATA 1 /* dynamic (data) allocation */ 435#define MT_HEADER MT_DATA /* packet header, use M_PKTHDR instead */ 436#define MT_SONAME 8 /* socket name */ 437#define MT_CONTROL 14 /* extra-data protocol message */ --- 703 unchanged lines hidden --- |