1 # Copyright (c) 2020 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
14 echo Loading vpp functions...\n
18 # The vector length is 8 bytes before the vector pointer
21 p/d ((u32 *)((u8 *)(($arg0))-8))[0]
25 Prints the length of a vector
29 # pe, aka pool_elts; the number of elements in the vector, minus the
30 # length of the free element vector. The free element vector is at
31 # offset -40 from the user pointer
33 echo pool_elts ($arg0):
34 p/d ((((u32 *)((u8 *)(($arg0))-8))[0]) - (((u32 *)((u8 *)(($arg0))-40))[0]))
38 Prints the number of active elements in a pool
42 # pifi, aka pool_is_free_index. Print 1 if the pool index is free, 0 if
45 # If the index is less than the pool vector
46 # length, see if the indicated bit in the indicated bitmap word is set.
47 # Otherwise, the index is not in use
49 # If you wonder why you might want a gdb macro to work this out when looking
50 # at a core file, just look at the expression...
53 echo pool_is_free_index ($arg0, $arg1)
54 p ($arg1 < (((u32 *)((u8 *)(($arg0))-8))[0])) ? (((1ULL<<(($arg1)%64)) & \
55 ((u64 **)(((u8 *)($arg0)-48)))[0][($arg1)/64]) !=0) : 1
58 Usage: pifi <pool-pointer> <index>
59 Print 1 if a specific pool index is free (or out of range), 0 if it's in-use
62 echo Load node_name_from_index\n
63 define node_name_from_index
64 p vlib_global_main.node_main.nodes[$arg0].name
66 document node_name_from_index
67 Usage: node_name_from_index <index>
68 Print node name given a node index (or node runtime index)
71 echo Load vnet_buffer_opaque\n
72 define vnet_buffer_opaque
73 p ((vnet_buffer_opaque_t *)(&((vlib_buffer_t *)($arg0))->opaque[0]))[0]
75 document vnet_buffer_opaque
76 Usage: vnet_buffer_opaque <vlib_buffer_t pointer>
77 Print the vnet buffer opaque given a vlib_buffer_t
80 echo Load vnet_buffer_opaque2\n
81 define vnet_buffer_opaque2
82 p ((vnet_buffer_opaque2_t *)(&((vlib_buffer_t *)($arg0))->opaque2[0]))[0]
84 document vnet_buffer_opaque2
85 Usage: vnet_buffer_opaque2 <vlib_buffer_t pointer>
86 Print the vnet buffer opaque2 given a vlib_buffer_t
89 echo Load bitmap_get\n
91 echo bitmap get ($arg0, $arg1):
92 p ($arg1/64 < ((u32 *)((u8 *)($arg0)-8))[0]) ? (((1ULL<<(($arg1)%64)) & \
93 ((u64 *)(($arg0)))[($arg1)/64]) != 0) : 0
96 Usage: bitmap_get <bitmap> <index>
97 Print 1 if a specific bitmap index is set, 0 if it's not set or out of range
100 echo Done loading vpp functions...\n