binapigen: fix union size
[govpp.git] / binapi / virtio / virtio.ba.go
1 // Code generated by GoVPP's binapi-generator. DO NOT EDIT.
2 // versions:
3 //  binapi-generator: v0.4.0-dev
4 //  VPP:              20.05-release
5 // source: /usr/share/vpp/api/core/virtio.api.json
6
7 // Package virtio contains generated bindings for API file virtio.api.
8 //
9 // Contents:
10 //   6 messages
11 //
12 package virtio
13
14 import (
15         api "git.fd.io/govpp.git/api"
16         ethernet_types "git.fd.io/govpp.git/binapi/ethernet_types"
17         interface_types "git.fd.io/govpp.git/binapi/interface_types"
18         pci_types "git.fd.io/govpp.git/binapi/pci_types"
19         codec "git.fd.io/govpp.git/codec"
20 )
21
22 // This is a compile-time assertion to ensure that this generated file
23 // is compatible with the GoVPP api package it is being compiled against.
24 // A compilation error at this line likely means your copy of the
25 // GoVPP api package needs to be updated.
26 const _ = api.GoVppAPIPackageIsVersion2
27
28 const (
29         APIFile    = "virtio"
30         APIVersion = "2.0.0"
31         VersionCrc = 0x601b1fdc
32 )
33
34 // SwInterfaceVirtioPciDetails defines message 'sw_interface_virtio_pci_details'.
35 type SwInterfaceVirtioPciDetails struct {
36         SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
37         PciAddr   pci_types.PciAddress           `binapi:"pci_address,name=pci_addr" json:"pci_addr,omitempty"`
38         MacAddr   ethernet_types.MacAddress      `binapi:"mac_address,name=mac_addr" json:"mac_addr,omitempty"`
39         TxRingSz  uint16                         `binapi:"u16,name=tx_ring_sz" json:"tx_ring_sz,omitempty"`
40         RxRingSz  uint16                         `binapi:"u16,name=rx_ring_sz" json:"rx_ring_sz,omitempty"`
41         Features  uint64                         `binapi:"u64,name=features" json:"features,omitempty"`
42 }
43
44 func (m *SwInterfaceVirtioPciDetails) Reset()               { *m = SwInterfaceVirtioPciDetails{} }
45 func (*SwInterfaceVirtioPciDetails) GetMessageName() string { return "sw_interface_virtio_pci_details" }
46 func (*SwInterfaceVirtioPciDetails) GetCrcString() string   { return "16187f3a" }
47 func (*SwInterfaceVirtioPciDetails) GetMessageType() api.MessageType {
48         return api.ReplyMessage
49 }
50
51 func (m *SwInterfaceVirtioPciDetails) Size() (size int) {
52         if m == nil {
53                 return 0
54         }
55         size += 4     // m.SwIfIndex
56         size += 2     // m.PciAddr.Domain
57         size += 1     // m.PciAddr.Bus
58         size += 1     // m.PciAddr.Slot
59         size += 1     // m.PciAddr.Function
60         size += 1 * 6 // m.MacAddr
61         size += 2     // m.TxRingSz
62         size += 2     // m.RxRingSz
63         size += 8     // m.Features
64         return size
65 }
66 func (m *SwInterfaceVirtioPciDetails) Marshal(b []byte) ([]byte, error) {
67         if b == nil {
68                 b = make([]byte, m.Size())
69         }
70         buf := codec.NewBuffer(b)
71         buf.EncodeUint32(uint32(m.SwIfIndex))
72         buf.EncodeUint16(m.PciAddr.Domain)
73         buf.EncodeUint8(m.PciAddr.Bus)
74         buf.EncodeUint8(m.PciAddr.Slot)
75         buf.EncodeUint8(m.PciAddr.Function)
76         buf.EncodeBytes(m.MacAddr[:], 6)
77         buf.EncodeUint16(m.TxRingSz)
78         buf.EncodeUint16(m.RxRingSz)
79         buf.EncodeUint64(m.Features)
80         return buf.Bytes(), nil
81 }
82 func (m *SwInterfaceVirtioPciDetails) Unmarshal(b []byte) error {
83         buf := codec.NewBuffer(b)
84         m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32())
85         m.PciAddr.Domain = buf.DecodeUint16()
86         m.PciAddr.Bus = buf.DecodeUint8()
87         m.PciAddr.Slot = buf.DecodeUint8()
88         m.PciAddr.Function = buf.DecodeUint8()
89         copy(m.MacAddr[:], buf.DecodeBytes(6))
90         m.TxRingSz = buf.DecodeUint16()
91         m.RxRingSz = buf.DecodeUint16()
92         m.Features = buf.DecodeUint64()
93         return nil
94 }
95
96 // SwInterfaceVirtioPciDump defines message 'sw_interface_virtio_pci_dump'.
97 type SwInterfaceVirtioPciDump struct{}
98
99 func (m *SwInterfaceVirtioPciDump) Reset()               { *m = SwInterfaceVirtioPciDump{} }
100 func (*SwInterfaceVirtioPciDump) GetMessageName() string { return "sw_interface_virtio_pci_dump" }
101 func (*SwInterfaceVirtioPciDump) GetCrcString() string   { return "51077d14" }
102 func (*SwInterfaceVirtioPciDump) GetMessageType() api.MessageType {
103         return api.RequestMessage
104 }
105
106 func (m *SwInterfaceVirtioPciDump) Size() (size int) {
107         if m == nil {
108                 return 0
109         }
110         return size
111 }
112 func (m *SwInterfaceVirtioPciDump) Marshal(b []byte) ([]byte, error) {
113         if b == nil {
114                 b = make([]byte, m.Size())
115         }
116         buf := codec.NewBuffer(b)
117         return buf.Bytes(), nil
118 }
119 func (m *SwInterfaceVirtioPciDump) Unmarshal(b []byte) error {
120         return nil
121 }
122
123 // VirtioPciCreate defines message 'virtio_pci_create'.
124 type VirtioPciCreate struct {
125         PciAddr                pci_types.PciAddress      `binapi:"pci_address,name=pci_addr" json:"pci_addr,omitempty"`
126         UseRandomMac           bool                      `binapi:"bool,name=use_random_mac" json:"use_random_mac,omitempty"`
127         MacAddress             ethernet_types.MacAddress `binapi:"mac_address,name=mac_address" json:"mac_address,omitempty"`
128         GsoEnabled             bool                      `binapi:"bool,name=gso_enabled" json:"gso_enabled,omitempty"`
129         ChecksumOffloadEnabled bool                      `binapi:"bool,name=checksum_offload_enabled" json:"checksum_offload_enabled,omitempty"`
130         Features               uint64                    `binapi:"u64,name=features" json:"features,omitempty"`
131 }
132
133 func (m *VirtioPciCreate) Reset()               { *m = VirtioPciCreate{} }
134 func (*VirtioPciCreate) GetMessageName() string { return "virtio_pci_create" }
135 func (*VirtioPciCreate) GetCrcString() string   { return "a9f1370c" }
136 func (*VirtioPciCreate) GetMessageType() api.MessageType {
137         return api.RequestMessage
138 }
139
140 func (m *VirtioPciCreate) Size() (size int) {
141         if m == nil {
142                 return 0
143         }
144         size += 2     // m.PciAddr.Domain
145         size += 1     // m.PciAddr.Bus
146         size += 1     // m.PciAddr.Slot
147         size += 1     // m.PciAddr.Function
148         size += 1     // m.UseRandomMac
149         size += 1 * 6 // m.MacAddress
150         size += 1     // m.GsoEnabled
151         size += 1     // m.ChecksumOffloadEnabled
152         size += 8     // m.Features
153         return size
154 }
155 func (m *VirtioPciCreate) Marshal(b []byte) ([]byte, error) {
156         if b == nil {
157                 b = make([]byte, m.Size())
158         }
159         buf := codec.NewBuffer(b)
160         buf.EncodeUint16(m.PciAddr.Domain)
161         buf.EncodeUint8(m.PciAddr.Bus)
162         buf.EncodeUint8(m.PciAddr.Slot)
163         buf.EncodeUint8(m.PciAddr.Function)
164         buf.EncodeBool(m.UseRandomMac)
165         buf.EncodeBytes(m.MacAddress[:], 6)
166         buf.EncodeBool(m.GsoEnabled)
167         buf.EncodeBool(m.ChecksumOffloadEnabled)
168         buf.EncodeUint64(m.Features)
169         return buf.Bytes(), nil
170 }
171 func (m *VirtioPciCreate) Unmarshal(b []byte) error {
172         buf := codec.NewBuffer(b)
173         m.PciAddr.Domain = buf.DecodeUint16()
174         m.PciAddr.Bus = buf.DecodeUint8()
175         m.PciAddr.Slot = buf.DecodeUint8()
176         m.PciAddr.Function = buf.DecodeUint8()
177         m.UseRandomMac = buf.DecodeBool()
178         copy(m.MacAddress[:], buf.DecodeBytes(6))
179         m.GsoEnabled = buf.DecodeBool()
180         m.ChecksumOffloadEnabled = buf.DecodeBool()
181         m.Features = buf.DecodeUint64()
182         return nil
183 }
184
185 // VirtioPciCreateReply defines message 'virtio_pci_create_reply'.
186 type VirtioPciCreateReply struct {
187         Retval    int32                          `binapi:"i32,name=retval" json:"retval,omitempty"`
188         SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
189 }
190
191 func (m *VirtioPciCreateReply) Reset()               { *m = VirtioPciCreateReply{} }
192 func (*VirtioPciCreateReply) GetMessageName() string { return "virtio_pci_create_reply" }
193 func (*VirtioPciCreateReply) GetCrcString() string   { return "5383d31f" }
194 func (*VirtioPciCreateReply) GetMessageType() api.MessageType {
195         return api.ReplyMessage
196 }
197
198 func (m *VirtioPciCreateReply) Size() (size int) {
199         if m == nil {
200                 return 0
201         }
202         size += 4 // m.Retval
203         size += 4 // m.SwIfIndex
204         return size
205 }
206 func (m *VirtioPciCreateReply) Marshal(b []byte) ([]byte, error) {
207         if b == nil {
208                 b = make([]byte, m.Size())
209         }
210         buf := codec.NewBuffer(b)
211         buf.EncodeInt32(m.Retval)
212         buf.EncodeUint32(uint32(m.SwIfIndex))
213         return buf.Bytes(), nil
214 }
215 func (m *VirtioPciCreateReply) Unmarshal(b []byte) error {
216         buf := codec.NewBuffer(b)
217         m.Retval = buf.DecodeInt32()
218         m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32())
219         return nil
220 }
221
222 // VirtioPciDelete defines message 'virtio_pci_delete'.
223 type VirtioPciDelete struct {
224         SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
225 }
226
227 func (m *VirtioPciDelete) Reset()               { *m = VirtioPciDelete{} }
228 func (*VirtioPciDelete) GetMessageName() string { return "virtio_pci_delete" }
229 func (*VirtioPciDelete) GetCrcString() string   { return "f9e6675e" }
230 func (*VirtioPciDelete) GetMessageType() api.MessageType {
231         return api.RequestMessage
232 }
233
234 func (m *VirtioPciDelete) Size() (size int) {
235         if m == nil {
236                 return 0
237         }
238         size += 4 // m.SwIfIndex
239         return size
240 }
241 func (m *VirtioPciDelete) Marshal(b []byte) ([]byte, error) {
242         if b == nil {
243                 b = make([]byte, m.Size())
244         }
245         buf := codec.NewBuffer(b)
246         buf.EncodeUint32(uint32(m.SwIfIndex))
247         return buf.Bytes(), nil
248 }
249 func (m *VirtioPciDelete) Unmarshal(b []byte) error {
250         buf := codec.NewBuffer(b)
251         m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32())
252         return nil
253 }
254
255 // VirtioPciDeleteReply defines message 'virtio_pci_delete_reply'.
256 type VirtioPciDeleteReply struct {
257         Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
258 }
259
260 func (m *VirtioPciDeleteReply) Reset()               { *m = VirtioPciDeleteReply{} }
261 func (*VirtioPciDeleteReply) GetMessageName() string { return "virtio_pci_delete_reply" }
262 func (*VirtioPciDeleteReply) GetCrcString() string   { return "e8d4e804" }
263 func (*VirtioPciDeleteReply) GetMessageType() api.MessageType {
264         return api.ReplyMessage
265 }
266
267 func (m *VirtioPciDeleteReply) Size() (size int) {
268         if m == nil {
269                 return 0
270         }
271         size += 4 // m.Retval
272         return size
273 }
274 func (m *VirtioPciDeleteReply) Marshal(b []byte) ([]byte, error) {
275         if b == nil {
276                 b = make([]byte, m.Size())
277         }
278         buf := codec.NewBuffer(b)
279         buf.EncodeInt32(m.Retval)
280         return buf.Bytes(), nil
281 }
282 func (m *VirtioPciDeleteReply) Unmarshal(b []byte) error {
283         buf := codec.NewBuffer(b)
284         m.Retval = buf.DecodeInt32()
285         return nil
286 }
287
288 func init() { file_virtio_binapi_init() }
289 func file_virtio_binapi_init() {
290         api.RegisterMessage((*SwInterfaceVirtioPciDetails)(nil), "sw_interface_virtio_pci_details_16187f3a")
291         api.RegisterMessage((*SwInterfaceVirtioPciDump)(nil), "sw_interface_virtio_pci_dump_51077d14")
292         api.RegisterMessage((*VirtioPciCreate)(nil), "virtio_pci_create_a9f1370c")
293         api.RegisterMessage((*VirtioPciCreateReply)(nil), "virtio_pci_create_reply_5383d31f")
294         api.RegisterMessage((*VirtioPciDelete)(nil), "virtio_pci_delete_f9e6675e")
295         api.RegisterMessage((*VirtioPciDeleteReply)(nil), "virtio_pci_delete_reply_e8d4e804")
296 }
297
298 // Messages returns list of all messages in this module.
299 func AllMessages() []api.Message {
300         return []api.Message{
301                 (*SwInterfaceVirtioPciDetails)(nil),
302                 (*SwInterfaceVirtioPciDump)(nil),
303                 (*VirtioPciCreate)(nil),
304                 (*VirtioPciCreateReply)(nil),
305                 (*VirtioPciDelete)(nil),
306                 (*VirtioPciDeleteReply)(nil),
307         }
308 }