summaryrefslogtreecommitdiffstats
path: root/adapter
diff options
context:
space:
mode:
authorOndrej Fabry <ofabry@cisco.com>2019-04-05 08:34:37 +0000
committerGerrit Code Review <gerrit@fd.io>2019-04-05 08:34:37 +0000
commit061dc1ca5dca4f87cb77b0efb4202b2bb863f4cf (patch)
treedbeff1f573de86ddc0a456eeff5781229bbfca79 /adapter
parentf40a43b1a99f488da1400c74482b9c97eaf08515 (diff)
parentd19bc1905dc0dcd142495db70f9b012b2f26e881 (diff)
Merge "Exposed input_queue_size argument to user"
Diffstat (limited to 'adapter')
-rw-r--r--adapter/vppapiclient/vppapiclient.go22
-rw-r--r--adapter/vppapiclient/vppapiclient_stub.go4
2 files changed, 19 insertions, 7 deletions
diff --git a/adapter/vppapiclient/vppapiclient.go b/adapter/vppapiclient/vppapiclient.go
index 037d3ac..f637060 100644
--- a/adapter/vppapiclient/vppapiclient.go
+++ b/adapter/vppapiclient/vppapiclient.go
@@ -54,9 +54,9 @@ govpp_send(uint32_t context, void *data, size_t size)
}
static int
-govpp_connect(char *shm)
+govpp_connect(char *shm, int rx_qlen)
{
- return vac_connect("govpp", shm, govpp_msg_callback, 32);
+ return vac_connect("govpp", shm, govpp_msg_callback, rx_qlen);
}
static int
@@ -104,14 +104,21 @@ var globalVppClient *vppClient
// stubVppClient is the default implementation of the VppAPI.
type vppClient struct {
- shmPrefix string
- msgCallback adapter.MsgCallback
+ shmPrefix string
+ msgCallback adapter.MsgCallback
+ inputQueueSize uint16
}
// NewVppClient returns a new VPP binary API client.
func NewVppClient(shmPrefix string) adapter.VppAPI {
+ return NewVppClientWithInputQueueSize(shmPrefix, 32)
+}
+
+// NewVppClientWithInputQueueSize returns a new VPP binary API client with a custom input queue size.
+func NewVppClientWithInputQueueSize(shmPrefix string, inputQueueSize uint16) adapter.VppAPI {
return &vppClient{
- shmPrefix: shmPrefix,
+ shmPrefix: shmPrefix,
+ inputQueueSize: inputQueueSize,
}
}
@@ -121,12 +128,13 @@ func (a *vppClient) Connect() error {
return fmt.Errorf("already connected to binary API, disconnect first")
}
+ rxQlen := C.int(a.inputQueueSize)
var rc C.int
if a.shmPrefix == "" {
- rc = C.govpp_connect(nil)
+ rc = C.govpp_connect(nil, rxQlen)
} else {
shm := C.CString(a.shmPrefix)
- rc = C.govpp_connect(shm)
+ rc = C.govpp_connect(shm, rxQlen)
}
if rc != 0 {
return fmt.Errorf("connecting to VPP binary API failed (rc=%v)", rc)
diff --git a/adapter/vppapiclient/vppapiclient_stub.go b/adapter/vppapiclient/vppapiclient_stub.go
index c5566c6..4df051c 100644
--- a/adapter/vppapiclient/vppapiclient_stub.go
+++ b/adapter/vppapiclient/vppapiclient_stub.go
@@ -28,6 +28,10 @@ func NewVppClient(string) adapter.VppAPI {
return &stubVppClient{}
}
+func NewVppClientWithInputQueueSize(string, uint16) adapter.VppAPI {
+ return &stubVppClient{}
+}
+
func (a *stubVppClient) Connect() error {
return adapter.ErrNotImplemented
}