@@ -20,11 +20,14 @@ package vppmemif
20
20
//go:generate go run git.fd.io/govpp.git/cmd/binapi-generator --output-dir=../../bin_api
21
21
22
22
import (
23
- "net"
23
+ // "net"
24
+
24
25
"os"
25
26
"path/filepath"
26
27
27
28
"git.fd.io/govpp.git/api"
29
+
30
+ "github.com/intel/userspace-cni-network-plugin/cnivpp/bin_api/interfaces"
28
31
"github.com/intel/userspace-cni-network-plugin/cnivpp/bin_api/memif"
29
32
30
33
"github.com/intel/userspace-cni-network-plugin/logging"
@@ -62,15 +65,16 @@ var stateStr = [...]string{"dn", "up"}
62
65
63
66
// Attempt to create a MemIf Interface.
64
67
// Input:
65
- // ch api.Channel
66
- // socketId uint32
67
- // role MemifRole - RoleMaster or RoleSlave
68
- func CreateMemifInterface (ch api.Channel , socketId uint32 , role MemifRole , mode MemifMode ) (swIfIndex uint32 , err error ) {
68
+ //
69
+ // ch api.Channel
70
+ // socketId uint32
71
+ // role MemifRole - RoleMaster or RoleSlave
72
+ func CreateMemifInterface (ch api.Channel , socketId uint32 , role memif.MemifRole , mode memif.MemifMode ) (swIfIndex interfaces.InterfaceIndex , err error ) {
69
73
70
74
// Populate the Add Structure
71
75
req := & memif.MemifCreate {
72
- Role : uint8 ( role ) ,
73
- Mode : uint8 ( mode ) ,
76
+ Role : role ,
77
+ Mode : mode ,
74
78
RxQueues : 1 ,
75
79
TxQueues : 1 ,
76
80
ID : 0 ,
@@ -91,7 +95,7 @@ func CreateMemifInterface(ch api.Channel, socketId uint32, role MemifRole, mode
91
95
}
92
96
return
93
97
} else {
94
- swIfIndex = reply .SwIfIndex
98
+ swIfIndex = interfaces . InterfaceIndex ( reply .SwIfIndex )
95
99
}
96
100
97
101
return
@@ -100,7 +104,7 @@ func CreateMemifInterface(ch api.Channel, socketId uint32, role MemifRole, mode
100
104
// Attempt to delete a memif interface. If the deleted MemIf Interface
101
105
// is the last interface associated with a socketfile, this function
102
106
// will attempt to delete it.
103
- func DeleteMemifInterface (ch api.Channel , swIfIndex uint32 ) (err error ) {
107
+ func DeleteMemifInterface (ch api.Channel , swIfIndex memif. InterfaceIndex ) (err error ) {
104
108
105
109
// Determine if memif interface exists
106
110
socketId , exist := findMemifInterface (ch , swIfIndex )
@@ -169,19 +173,20 @@ func DumpMemif(ch api.Channel) {
169
173
}
170
174
//logging.Verbosef("%+v", reply)
171
175
172
- macAddr := net . HardwareAddr ( reply .HwAddr )
173
- logging .Verbosef (" SwIfId=%d ID=%d Socket=%d Role=%s Mode=%s IfName=%s HwAddr=%s RingSz=%d BufferSz=%d Admin=%s Link=%s " ,
176
+ macAddr := reply .HwAddr
177
+ logging .Verbosef (" SwIfId=%d ID=%d Socket=%d Role=%s Mode=%s IfName=%s HwAddr=%v RingSz=%d BufferSz=%d" ,
174
178
reply .SwIfIndex ,
175
179
reply .ID ,
176
180
reply .SocketID ,
177
181
roleStr [reply .Role ],
178
182
modeStr [reply .Mode ],
179
183
string (reply .IfName ),
180
- macAddr . String () ,
184
+ macAddr ,
181
185
reply .RingSize ,
182
- reply .BufferSize ,
183
- stateStr [reply .AdminUpDown ],
184
- stateStr [reply .LinkUpDown ])
186
+ )
187
+ // reply.BufferSize,
188
+ // stateStr[reply.AdminUpDown],
189
+ // stateStr[reply.LinkUpDown])
185
190
186
191
count ++
187
192
}
@@ -224,9 +229,9 @@ func CreateMemifSocket(ch api.Channel, socketFile string) (socketId uint32, err
224
229
225
230
// Populate the Request Structure
226
231
req := & memif.MemifSocketFilenameAddDel {
227
- IsAdd : 1 ,
232
+ IsAdd : true ,
228
233
SocketID : socketId ,
229
- SocketFilename : [] byte ( socketFile ) ,
234
+ SocketFilename : socketFile ,
230
235
}
231
236
232
237
reply := & memif.MemifSocketFilenameAddDelReply {}
@@ -248,7 +253,7 @@ func CreateMemifSocket(ch api.Channel, socketFile string) (socketId uint32, err
248
253
func DeleteMemifSocket (ch api.Channel , socketId uint32 ) (err error ) {
249
254
// Populate the Add Structure
250
255
req := & memif.MemifSocketFilenameAddDel {
251
- IsAdd : 0 ,
256
+ IsAdd : false ,
252
257
SocketID : socketId ,
253
258
}
254
259
@@ -301,7 +306,7 @@ func DumpMemifSocket(ch api.Channel) {
301
306
//
302
307
303
308
// Find the given memif interface and return socketId if it exists
304
- func findMemifInterface (ch api.Channel , swIfIndex uint32 ) (socketId uint32 , found bool ) {
309
+ func findMemifInterface (ch api.Channel , swIfIndex memif. InterfaceIndex ) (socketId uint32 , found bool ) {
305
310
306
311
// Populate the Message Structure
307
312
req := & memif.MemifDump {}
@@ -380,9 +385,10 @@ func findMemifSocketCnt(ch api.Channel, socketId uint32) (count uint32) {
380
385
// socketFile exists. If it does, return the associated socketId.
381
386
// If it doesn't, return the next available socketId.
382
387
// Returns:
383
- // bool - Found flag
384
- // uint32 - If found is true: associated socketId.
385
- // If found is false: next free socketId.
388
+ //
389
+ // bool - Found flag
390
+ // uint32 - If found is true: associated socketId.
391
+ // If found is false: next free socketId.
386
392
func findMemifSocket (ch api.Channel , socketFilename string ) (found bool , socketId uint32 ) {
387
393
388
394
var count int
0 commit comments