]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/dtrace/mbuf.d
sys/{x86,amd64}: remove one of doubled ;s
[FreeBSD/FreeBSD.git] / share / dtrace / mbuf.d
1 /*
2  * Copyright (c) 2016 George V. Neville-Neil
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * $FreeBSD$
27  *
28  * Translators and flags for the mbuf structure.  FreeBSD specific code.
29  */
30
31 #pragma D depends_on module kernel
32
33 /*
34  * mbuf flags of global significance and layer crossing.
35  * Those of only protocol/layer specific significance are to be mapped
36  * to M_PROTO[1-12] and cleared at layer handoff boundaries.
37  * NB: Limited to the lower 24 bits.
38  */
39
40 #pragma D binding "1.6.3" M_EXT
41 inline int M_EXT =      0x00000001; /* has associated external storage */
42 #pragma D binding "1.6.3" M_PKTHDR
43 inline int M_PKTHDR =   0x00000002; /* start of record */
44 #pragma D binding "1.6.3" M_EOR
45 inline int M_EOR =      0x00000004; /* end of record */
46 #pragma D binding "1.6.3" M_RDONLY
47 inline int M_RDONLY =   0x00000008; /* associated data is marked read-only */
48 #pragma D binding "1.6.3" M_BCAST
49 inline int M_BCAST =    0x00000010; /* send/received as link-level broadcast */
50 #pragma D binding "1.6.3" M_MCAST
51 inline int M_MCAST =    0x00000020; /* send/received as link-level multicast */
52 #pragma D binding "1.6.3" M_PROMISC
53 inline int M_PROMISC =  0x00000040; /* packet was not for us */
54 #pragma D binding "1.6.3" M_VLANTAG
55 inline int M_VLANTAG =  0x00000080; /* ether_vtag is valid */
56 #pragma D binding "1.6.3" M_UNUSED_8
57 inline int M_UNUSED_8 = 0x00000100; /* --available-- */
58 #pragma D binding "1.6.3" M_NOFREE
59 inline int M_NOFREE =   0x00000200; /* do not free mbuf, embedded in cluster */
60
61 #pragma D binding "1.6.3" M_PROTO1
62 inline int M_PROTO1 =   0x00001000; /* protocol-specific */
63 #pragma D binding "1.6.3" M_PROTO2
64 inline int M_PROTO2 =   0x00002000; /* protocol-specific */
65 #pragma D binding "1.6.3" M_PROTO3
66 inline int M_PROTO3 =   0x00004000; /* protocol-specific */
67 #pragma D binding "1.6.3" M_PROTO4
68 inline int M_PROTO4 =   0x00008000; /* protocol-specific */
69 #pragma D binding "1.6.3" M_PROTO5
70 inline int M_PROTO5 =   0x00010000; /* protocol-specific */
71 #pragma D binding "1.6.3" M_PROTO6
72 inline int M_PROTO6 =   0x00020000; /* protocol-specific */
73 #pragma D binding "1.6.3" M_PROTO7
74 inline int M_PROTO7 =   0x00040000; /* protocol-specific */
75 #pragma D binding "1.6.3" M_PROTO8
76 inline int M_PROTO8 =   0x00080000; /* protocol-specific */
77 #pragma D binding "1.6.3" M_PROTO9
78 inline int M_PROTO9 =   0x00100000; /* protocol-specific */
79 #pragma D binding "1.6.3" M_PROTO10
80 inline int M_PROTO10 =  0x00200000; /* protocol-specific */
81 #pragma D binding "1.6.3" M_PROTO11
82 inline int M_PROTO11 =  0x00400000; /* protocol-specific */
83 #pragma D binding "1.6.3" M_PROTO12
84 inline int M_PROTO12 =  0x00800000; /* protocol-specific */
85
86 #pragma D binding "1.6.3" mbufflags_string
87 inline string mbufflags_string[uint32_t flags] =
88     flags & M_EXT ? "M_EXT" :
89     flags & M_PKTHDR ? "M_PKTHDR" :
90     flags & M_EOR  ? "M_EOR" :
91     flags & M_RDONLY  ? "M_RDONLY" :
92     flags & M_BCAST  ? "M_BCAST" :
93     flags & M_MCAST     ? "M_MCAST" :
94     flags & M_PROMISC   ? "M_PROMISC" :
95     flags & M_VLANTAG   ? "M_VLANTAG" :
96     flags & M_UNUSED_8  ? "M_UNUSED_8" :
97     flags & M_NOFREE  ? "M_NOFREE" :
98     flags & M_PROTO1  ? "M_PROTO1" :
99     flags & M_PROTO2 ? "M_PROTO2" :
100     flags & M_PROTO3 ? "M_PROTO3" :
101     flags & M_PROTO4 ? "M_PROTO4" :
102     flags & M_PROTO5 ? "M_PROTO5" :
103     flags & M_PROTO6 ? "M_PROTO6" :
104     flags & M_PROTO7 ? "M_PROTO7" :
105     flags & M_PROTO8 ? "M_PROTO8" :
106     flags & M_PROTO9 ? "M_PROTO9" :
107     flags & M_PROTO10 ? "M_PROTO10" :
108     flags & M_PROTO11 ? "M_PROTO11" :
109     flags & M_PROTO12 ? "M_PROTO12" :
110     "none" ;
111
112 typedef struct mbufinfo {
113         uintptr_t mbuf_addr;
114         caddr_t m_data;
115         int32_t m_len;
116         uint8_t m_type;
117         uint32_t m_flags;
118 } mbufinfo_t;
119
120 translator mbufinfo_t < struct mbuf *p > {
121         mbuf_addr = (uintptr_t)p;
122         m_data = p->m_data;
123         m_len = p->m_len;
124         m_type = p->m_type & 0xff000000;
125         m_flags = p->m_type & 0x00ffffff;
126 };