forked from usnistgov/ndn-dpdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrxmemif.go
62 lines (50 loc) · 1.06 KB
/
rxmemif.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package ethport
/*
#include "../../csrc/ethface/face.h"
*/
import "C"
import (
"errors"
"github.com/usnistgov/ndn-dpdk/dpdk/ethdev"
"github.com/usnistgov/ndn-dpdk/iface"
)
type rxMemif struct{}
func (rxMemif) String() string {
return "RxMemif"
}
func (rxMemif) List(port *Port) (list []iface.RxGroup) {
for _, face := range port.faces {
list = append(list, face.rxf[0])
}
return
}
func (impl *rxMemif) Init(port *Port) error {
if port.devInfo.Driver() != ethdev.DriverMemif {
return errors.New("cannot use RxMemif on non-memif port")
}
return nil
}
func (impl *rxMemif) Start(face *Face) error {
if e := face.port.startDev(1, false); e != nil {
return e
}
locC := face.loc.EthLocatorC()
C.EthFace_SetupRxMemif(face.priv, locC.ptr())
rxf := &rxgFlow{
face: face,
index: 0,
}
face.rxf = []*rxgFlow{rxf}
iface.ActivateRxGroup(rxf)
return nil
}
func (impl *rxMemif) Stop(face *Face) error {
for _, rxf := range face.rxf {
iface.DeactivateRxGroup(rxf)
}
face.rxf = nil
return nil
}
func (impl *rxMemif) Close(port *Port) error {
return nil
}