blob: b88997e66f01e52ba2d5500eb100378ab11f501f [file] [log] [blame]
Dave Barach17c45312020-06-23 17:36:12 -04001# 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:
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
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.
13
14echo Loading vpp functions...\n
15
16echo Load vl
17# vl, aka vec_len (x)
18# The vector length is 8 bytes before the vector pointer
19define vl
20 echo vec_len ($arg0):
21 p/d ((u32 *)((u8 *)(($arg0))-8))[0]
22end
23document vl
24 Usage: vl <vector>
25 Prints the length of a vector
26end
27
28echo Load pe\n
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
32define pe
33 echo pool_elts ($arg0):
34 p/d ((((u32 *)((u8 *)(($arg0))-8))[0]) - (((u32 *)((u8 *)(($arg0))-40))[0]))
35end
36document pe
37 Usage: pe <pool>
38 Prints the number of active elements in a pool
39end
40
41echo Load pifi\n
42# pifi, aka pool_is_free_index. Print 1 if the pool index is free, 0 if
43# it's in-use.
44#
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
48#
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...
51
52define pifi
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
56end
57document pifi
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
60end
61
62echo Load node_name_from_index\n
63define node_name_from_index
64 p vlib_global_main.node_main.nodes[$arg0].name
65end
66document node_name_from_index
67 Usage: node_name_from_index <index>
68 Print node name given a node index (or node runtime index)
69end
70
71echo Load vnet_buffer_opaque\n
72define vnet_buffer_opaque
73 p ((vnet_buffer_opaque_t *)(&((vlib_buffer_t *)($arg0))->opaque[0]))[0]
74end
75document vnet_buffer_opaque
76 Usage: vnet_buffer_opaque <vlib_buffer_t pointer>
77 Print the vnet buffer opaque given a vlib_buffer_t
78end
79
80echo Load vnet_buffer_opaque2\n
81define vnet_buffer_opaque2
82 p ((vnet_buffer_opaque2_t *)(&((vlib_buffer_t *)($arg0))->opaque2[0]))[0]
83end
84document vnet_buffer_opaque2
85 Usage: vnet_buffer_opaque2 <vlib_buffer_t pointer>
86 Print the vnet buffer opaque2 given a vlib_buffer_t
87end
88
89echo Load bitmap_get\n
90define bitmap_get
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
94end
95document bitmap_get
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
98end
99
100echo Done loading vpp functions...\n