3d1315733e43a366f465660e2001c3be0024e2cd
[govpp.git] / binapi / af_xdp / af_xdp.ba.go
1 // Code generated by GoVPP's binapi-generator. DO NOT EDIT.
2 // versions:
3 //  binapi-generator: v0.5.0-dev
4 //  VPP:              21.06-release
5 // source: /usr/share/vpp/api/plugins/af_xdp.api.json
6
7 // Package af_xdp contains generated bindings for API file af_xdp.api.
8 //
9 // Contents:
10 //   2 enums
11 //   4 messages
12 //
13 package af_xdp
14
15 import (
16         "strconv"
17
18         api "git.fd.io/govpp.git/api"
19         interface_types "git.fd.io/govpp.git/binapi/interface_types"
20         codec "git.fd.io/govpp.git/codec"
21 )
22
23 // This is a compile-time assertion to ensure that this generated file
24 // is compatible with the GoVPP api package it is being compiled against.
25 // A compilation error at this line likely means your copy of the
26 // GoVPP api package needs to be updated.
27 const _ = api.GoVppAPIPackageIsVersion2
28
29 const (
30         APIFile    = "af_xdp"
31         APIVersion = "0.2.0"
32         VersionCrc = 0x31450826
33 )
34
35 // AfXdpMode defines enum 'af_xdp_mode'.
36 type AfXdpMode uint32
37
38 const (
39         AF_XDP_API_MODE_AUTO      AfXdpMode = 0
40         AF_XDP_API_MODE_COPY      AfXdpMode = 1
41         AF_XDP_API_MODE_ZERO_COPY AfXdpMode = 2
42 )
43
44 var (
45         AfXdpMode_name = map[uint32]string{
46                 0: "AF_XDP_API_MODE_AUTO",
47                 1: "AF_XDP_API_MODE_COPY",
48                 2: "AF_XDP_API_MODE_ZERO_COPY",
49         }
50         AfXdpMode_value = map[string]uint32{
51                 "AF_XDP_API_MODE_AUTO":      0,
52                 "AF_XDP_API_MODE_COPY":      1,
53                 "AF_XDP_API_MODE_ZERO_COPY": 2,
54         }
55 )
56
57 func (x AfXdpMode) String() string {
58         s, ok := AfXdpMode_name[uint32(x)]
59         if ok {
60                 return s
61         }
62         return "AfXdpMode(" + strconv.Itoa(int(x)) + ")"
63 }
64
65 // AfXdpFlag defines enum 'af_xdp_flag'.
66 type AfXdpFlag uint8
67
68 const (
69         AF_XDP_API_FLAGS_NO_SYSCALL_LOCK AfXdpFlag = 1
70 )
71
72 var (
73         AfXdpFlag_name = map[uint8]string{
74                 1: "AF_XDP_API_FLAGS_NO_SYSCALL_LOCK",
75         }
76         AfXdpFlag_value = map[string]uint8{
77                 "AF_XDP_API_FLAGS_NO_SYSCALL_LOCK": 1,
78         }
79 )
80
81 func (x AfXdpFlag) String() string {
82         s, ok := AfXdpFlag_name[uint8(x)]
83         if ok {
84                 return s
85         }
86         str := func(n uint8) string {
87                 s, ok := AfXdpFlag_name[uint8(n)]
88                 if ok {
89                         return s
90                 }
91                 return "AfXdpFlag(" + strconv.Itoa(int(n)) + ")"
92         }
93         for i := uint8(0); i <= 8; i++ {
94                 val := uint8(x)
95                 if val&(1<<i) != 0 {
96                         if s != "" {
97                                 s += "|"
98                         }
99                         s += str(1 << i)
100                 }
101         }
102         if s == "" {
103                 return str(uint8(x))
104         }
105         return s
106 }
107
108 // AfXdpCreate defines message 'af_xdp_create'.
109 // InProgress: the message form may change in the future versions
110 type AfXdpCreate struct {
111         HostIf  string    `binapi:"string[64],name=host_if" json:"host_if,omitempty"`
112         Name    string    `binapi:"string[64],name=name" json:"name,omitempty"`
113         RxqNum  uint16    `binapi:"u16,name=rxq_num,default=1" json:"rxq_num,omitempty"`
114         RxqSize uint16    `binapi:"u16,name=rxq_size,default=0" json:"rxq_size,omitempty"`
115         TxqSize uint16    `binapi:"u16,name=txq_size,default=0" json:"txq_size,omitempty"`
116         Mode    AfXdpMode `binapi:"af_xdp_mode,name=mode,default=0" json:"mode,omitempty"`
117         Flags   AfXdpFlag `binapi:"af_xdp_flag,name=flags,default=0" json:"flags,omitempty"`
118         Prog    string    `binapi:"string[256],name=prog" json:"prog,omitempty"`
119 }
120
121 func (m *AfXdpCreate) Reset()               { *m = AfXdpCreate{} }
122 func (*AfXdpCreate) GetMessageName() string { return "af_xdp_create" }
123 func (*AfXdpCreate) GetCrcString() string   { return "21226c99" }
124 func (*AfXdpCreate) GetMessageType() api.MessageType {
125         return api.RequestMessage
126 }
127
128 func (m *AfXdpCreate) Size() (size int) {
129         if m == nil {
130                 return 0
131         }
132         size += 64  // m.HostIf
133         size += 64  // m.Name
134         size += 2   // m.RxqNum
135         size += 2   // m.RxqSize
136         size += 2   // m.TxqSize
137         size += 4   // m.Mode
138         size += 1   // m.Flags
139         size += 256 // m.Prog
140         return size
141 }
142 func (m *AfXdpCreate) Marshal(b []byte) ([]byte, error) {
143         if b == nil {
144                 b = make([]byte, m.Size())
145         }
146         buf := codec.NewBuffer(b)
147         buf.EncodeString(m.HostIf, 64)
148         buf.EncodeString(m.Name, 64)
149         buf.EncodeUint16(m.RxqNum)
150         buf.EncodeUint16(m.RxqSize)
151         buf.EncodeUint16(m.TxqSize)
152         buf.EncodeUint32(uint32(m.Mode))
153         buf.EncodeUint8(uint8(m.Flags))
154         buf.EncodeString(m.Prog, 256)
155         return buf.Bytes(), nil
156 }
157 func (m *AfXdpCreate) Unmarshal(b []byte) error {
158         buf := codec.NewBuffer(b)
159         m.HostIf = buf.DecodeString(64)
160         m.Name = buf.DecodeString(64)
161         m.RxqNum = buf.DecodeUint16()
162         m.RxqSize = buf.DecodeUint16()
163         m.TxqSize = buf.DecodeUint16()
164         m.Mode = AfXdpMode(buf.DecodeUint32())
165         m.Flags = AfXdpFlag(buf.DecodeUint8())
166         m.Prog = buf.DecodeString(256)
167         return nil
168 }
169
170 // AfXdpCreateReply defines message 'af_xdp_create_reply'.
171 // InProgress: the message form may change in the future versions
172 type AfXdpCreateReply struct {
173         Retval    int32                          `binapi:"i32,name=retval" json:"retval,omitempty"`
174         SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
175 }
176
177 func (m *AfXdpCreateReply) Reset()               { *m = AfXdpCreateReply{} }
178 func (*AfXdpCreateReply) GetMessageName() string { return "af_xdp_create_reply" }
179 func (*AfXdpCreateReply) GetCrcString() string   { return "5383d31f" }
180 func (*AfXdpCreateReply) GetMessageType() api.MessageType {
181         return api.ReplyMessage
182 }
183
184 func (m *AfXdpCreateReply) Size() (size int) {
185         if m == nil {
186                 return 0
187         }
188         size += 4 // m.Retval
189         size += 4 // m.SwIfIndex
190         return size
191 }
192 func (m *AfXdpCreateReply) Marshal(b []byte) ([]byte, error) {
193         if b == nil {
194                 b = make([]byte, m.Size())
195         }
196         buf := codec.NewBuffer(b)
197         buf.EncodeInt32(m.Retval)
198         buf.EncodeUint32(uint32(m.SwIfIndex))
199         return buf.Bytes(), nil
200 }
201 func (m *AfXdpCreateReply) Unmarshal(b []byte) error {
202         buf := codec.NewBuffer(b)
203         m.Retval = buf.DecodeInt32()
204         m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32())
205         return nil
206 }
207
208 // AfXdpDelete defines message 'af_xdp_delete'.
209 // InProgress: the message form may change in the future versions
210 type AfXdpDelete struct {
211         SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
212 }
213
214 func (m *AfXdpDelete) Reset()               { *m = AfXdpDelete{} }
215 func (*AfXdpDelete) GetMessageName() string { return "af_xdp_delete" }
216 func (*AfXdpDelete) GetCrcString() string   { return "f9e6675e" }
217 func (*AfXdpDelete) GetMessageType() api.MessageType {
218         return api.RequestMessage
219 }
220
221 func (m *AfXdpDelete) Size() (size int) {
222         if m == nil {
223                 return 0
224         }
225         size += 4 // m.SwIfIndex
226         return size
227 }
228 func (m *AfXdpDelete) Marshal(b []byte) ([]byte, error) {
229         if b == nil {
230                 b = make([]byte, m.Size())
231         }
232         buf := codec.NewBuffer(b)
233         buf.EncodeUint32(uint32(m.SwIfIndex))
234         return buf.Bytes(), nil
235 }
236 func (m *AfXdpDelete) Unmarshal(b []byte) error {
237         buf := codec.NewBuffer(b)
238         m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32())
239         return nil
240 }
241
242 // AfXdpDeleteReply defines message 'af_xdp_delete_reply'.
243 // InProgress: the message form may change in the future versions
244 type AfXdpDeleteReply struct {
245         Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
246 }
247
248 func (m *AfXdpDeleteReply) Reset()               { *m = AfXdpDeleteReply{} }
249 func (*AfXdpDeleteReply) GetMessageName() string { return "af_xdp_delete_reply" }
250 func (*AfXdpDeleteReply) GetCrcString() string   { return "e8d4e804" }
251 func (*AfXdpDeleteReply) GetMessageType() api.MessageType {
252         return api.ReplyMessage
253 }
254
255 func (m *AfXdpDeleteReply) Size() (size int) {
256         if m == nil {
257                 return 0
258         }
259         size += 4 // m.Retval
260         return size
261 }
262 func (m *AfXdpDeleteReply) Marshal(b []byte) ([]byte, error) {
263         if b == nil {
264                 b = make([]byte, m.Size())
265         }
266         buf := codec.NewBuffer(b)
267         buf.EncodeInt32(m.Retval)
268         return buf.Bytes(), nil
269 }
270 func (m *AfXdpDeleteReply) Unmarshal(b []byte) error {
271         buf := codec.NewBuffer(b)
272         m.Retval = buf.DecodeInt32()
273         return nil
274 }
275
276 func init() { file_af_xdp_binapi_init() }
277 func file_af_xdp_binapi_init() {
278         api.RegisterMessage((*AfXdpCreate)(nil), "af_xdp_create_21226c99")
279         api.RegisterMessage((*AfXdpCreateReply)(nil), "af_xdp_create_reply_5383d31f")
280         api.RegisterMessage((*AfXdpDelete)(nil), "af_xdp_delete_f9e6675e")
281         api.RegisterMessage((*AfXdpDeleteReply)(nil), "af_xdp_delete_reply_e8d4e804")
282 }
283
284 // Messages returns list of all messages in this module.
285 func AllMessages() []api.Message {
286         return []api.Message{
287                 (*AfXdpCreate)(nil),
288                 (*AfXdpCreateReply)(nil),
289                 (*AfXdpDelete)(nil),
290                 (*AfXdpDeleteReply)(nil),
291         }
292 }