binapigen: fix union size
[govpp.git] / binapi / rdma / rdma.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/plugins/rdma.api.json
6
7 // Package rdma contains generated bindings for API file rdma.api.
8 //
9 // Contents:
10 //   1 enum
11 //   4 messages
12 //
13 package rdma
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    = "rdma"
31         APIVersion = "1.0.0"
32         VersionCrc = 0x8b33158c
33 )
34
35 // RdmaMode defines enum 'rdma_mode'.
36 type RdmaMode uint32
37
38 const (
39         RDMA_API_MODE_AUTO RdmaMode = 0
40         RDMA_API_MODE_IBV  RdmaMode = 1
41         RDMA_API_MODE_DV   RdmaMode = 2
42 )
43
44 var (
45         RdmaMode_name = map[uint32]string{
46                 0: "RDMA_API_MODE_AUTO",
47                 1: "RDMA_API_MODE_IBV",
48                 2: "RDMA_API_MODE_DV",
49         }
50         RdmaMode_value = map[string]uint32{
51                 "RDMA_API_MODE_AUTO": 0,
52                 "RDMA_API_MODE_IBV":  1,
53                 "RDMA_API_MODE_DV":   2,
54         }
55 )
56
57 func (x RdmaMode) String() string {
58         s, ok := RdmaMode_name[uint32(x)]
59         if ok {
60                 return s
61         }
62         return "RdmaMode(" + strconv.Itoa(int(x)) + ")"
63 }
64
65 // RdmaCreate defines message 'rdma_create'.
66 type RdmaCreate struct {
67         HostIf  string   `binapi:"string[64],name=host_if" json:"host_if,omitempty"`
68         Name    string   `binapi:"string[64],name=name" json:"name,omitempty"`
69         RxqNum  uint16   `binapi:"u16,name=rxq_num,default=1" json:"rxq_num,omitempty"`
70         RxqSize uint16   `binapi:"u16,name=rxq_size,default=1024" json:"rxq_size,omitempty"`
71         TxqSize uint16   `binapi:"u16,name=txq_size,default=1024" json:"txq_size,omitempty"`
72         Mode    RdmaMode `binapi:"rdma_mode,name=mode,default=0" json:"mode,omitempty"`
73 }
74
75 func (m *RdmaCreate) Reset()               { *m = RdmaCreate{} }
76 func (*RdmaCreate) GetMessageName() string { return "rdma_create" }
77 func (*RdmaCreate) GetCrcString() string   { return "076fe418" }
78 func (*RdmaCreate) GetMessageType() api.MessageType {
79         return api.RequestMessage
80 }
81
82 func (m *RdmaCreate) Size() (size int) {
83         if m == nil {
84                 return 0
85         }
86         size += 64 // m.HostIf
87         size += 64 // m.Name
88         size += 2  // m.RxqNum
89         size += 2  // m.RxqSize
90         size += 2  // m.TxqSize
91         size += 4  // m.Mode
92         return size
93 }
94 func (m *RdmaCreate) Marshal(b []byte) ([]byte, error) {
95         if b == nil {
96                 b = make([]byte, m.Size())
97         }
98         buf := codec.NewBuffer(b)
99         buf.EncodeString(m.HostIf, 64)
100         buf.EncodeString(m.Name, 64)
101         buf.EncodeUint16(m.RxqNum)
102         buf.EncodeUint16(m.RxqSize)
103         buf.EncodeUint16(m.TxqSize)
104         buf.EncodeUint32(uint32(m.Mode))
105         return buf.Bytes(), nil
106 }
107 func (m *RdmaCreate) Unmarshal(b []byte) error {
108         buf := codec.NewBuffer(b)
109         m.HostIf = buf.DecodeString(64)
110         m.Name = buf.DecodeString(64)
111         m.RxqNum = buf.DecodeUint16()
112         m.RxqSize = buf.DecodeUint16()
113         m.TxqSize = buf.DecodeUint16()
114         m.Mode = RdmaMode(buf.DecodeUint32())
115         return nil
116 }
117
118 // RdmaCreateReply defines message 'rdma_create_reply'.
119 type RdmaCreateReply struct {
120         Retval    int32                          `binapi:"i32,name=retval" json:"retval,omitempty"`
121         SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
122 }
123
124 func (m *RdmaCreateReply) Reset()               { *m = RdmaCreateReply{} }
125 func (*RdmaCreateReply) GetMessageName() string { return "rdma_create_reply" }
126 func (*RdmaCreateReply) GetCrcString() string   { return "5383d31f" }
127 func (*RdmaCreateReply) GetMessageType() api.MessageType {
128         return api.ReplyMessage
129 }
130
131 func (m *RdmaCreateReply) Size() (size int) {
132         if m == nil {
133                 return 0
134         }
135         size += 4 // m.Retval
136         size += 4 // m.SwIfIndex
137         return size
138 }
139 func (m *RdmaCreateReply) Marshal(b []byte) ([]byte, error) {
140         if b == nil {
141                 b = make([]byte, m.Size())
142         }
143         buf := codec.NewBuffer(b)
144         buf.EncodeInt32(m.Retval)
145         buf.EncodeUint32(uint32(m.SwIfIndex))
146         return buf.Bytes(), nil
147 }
148 func (m *RdmaCreateReply) Unmarshal(b []byte) error {
149         buf := codec.NewBuffer(b)
150         m.Retval = buf.DecodeInt32()
151         m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32())
152         return nil
153 }
154
155 // RdmaDelete defines message 'rdma_delete'.
156 type RdmaDelete struct {
157         SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
158 }
159
160 func (m *RdmaDelete) Reset()               { *m = RdmaDelete{} }
161 func (*RdmaDelete) GetMessageName() string { return "rdma_delete" }
162 func (*RdmaDelete) GetCrcString() string   { return "f9e6675e" }
163 func (*RdmaDelete) GetMessageType() api.MessageType {
164         return api.RequestMessage
165 }
166
167 func (m *RdmaDelete) Size() (size int) {
168         if m == nil {
169                 return 0
170         }
171         size += 4 // m.SwIfIndex
172         return size
173 }
174 func (m *RdmaDelete) Marshal(b []byte) ([]byte, error) {
175         if b == nil {
176                 b = make([]byte, m.Size())
177         }
178         buf := codec.NewBuffer(b)
179         buf.EncodeUint32(uint32(m.SwIfIndex))
180         return buf.Bytes(), nil
181 }
182 func (m *RdmaDelete) Unmarshal(b []byte) error {
183         buf := codec.NewBuffer(b)
184         m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32())
185         return nil
186 }
187
188 // RdmaDeleteReply defines message 'rdma_delete_reply'.
189 type RdmaDeleteReply struct {
190         Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
191 }
192
193 func (m *RdmaDeleteReply) Reset()               { *m = RdmaDeleteReply{} }
194 func (*RdmaDeleteReply) GetMessageName() string { return "rdma_delete_reply" }
195 func (*RdmaDeleteReply) GetCrcString() string   { return "e8d4e804" }
196 func (*RdmaDeleteReply) GetMessageType() api.MessageType {
197         return api.ReplyMessage
198 }
199
200 func (m *RdmaDeleteReply) Size() (size int) {
201         if m == nil {
202                 return 0
203         }
204         size += 4 // m.Retval
205         return size
206 }
207 func (m *RdmaDeleteReply) Marshal(b []byte) ([]byte, error) {
208         if b == nil {
209                 b = make([]byte, m.Size())
210         }
211         buf := codec.NewBuffer(b)
212         buf.EncodeInt32(m.Retval)
213         return buf.Bytes(), nil
214 }
215 func (m *RdmaDeleteReply) Unmarshal(b []byte) error {
216         buf := codec.NewBuffer(b)
217         m.Retval = buf.DecodeInt32()
218         return nil
219 }
220
221 func init() { file_rdma_binapi_init() }
222 func file_rdma_binapi_init() {
223         api.RegisterMessage((*RdmaCreate)(nil), "rdma_create_076fe418")
224         api.RegisterMessage((*RdmaCreateReply)(nil), "rdma_create_reply_5383d31f")
225         api.RegisterMessage((*RdmaDelete)(nil), "rdma_delete_f9e6675e")
226         api.RegisterMessage((*RdmaDeleteReply)(nil), "rdma_delete_reply_e8d4e804")
227 }
228
229 // Messages returns list of all messages in this module.
230 func AllMessages() []api.Message {
231         return []api.Message{
232                 (*RdmaCreate)(nil),
233                 (*RdmaCreateReply)(nil),
234                 (*RdmaDelete)(nil),
235                 (*RdmaDeleteReply)(nil),
236         }
237 }