diff options
author | Ondrej Fabry <ofabry@cisco.com> | 2019-04-05 10:31:02 +0200 |
---|---|---|
committer | Ondrej Fabry <ofabry@cisco.com> | 2019-04-05 10:31:02 +0200 |
commit | d19bc1905dc0dcd142495db70f9b012b2f26e881 (patch) | |
tree | 4dd6c6918d78fb1e7e115b120a2b57f4baf1b93d /adapter/vppapiclient/vppapiclient.go | |
parent | 345201eedce4cefae4db6914067a34000a7f978f (diff) |
Exposed input_queue_size argument to user
Change-Id: If617c61bab4c5ee8ea41ec17932132050bf5cdba
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Diffstat (limited to 'adapter/vppapiclient/vppapiclient.go')
-rw-r--r-- | adapter/vppapiclient/vppapiclient.go | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/adapter/vppapiclient/vppapiclient.go b/adapter/vppapiclient/vppapiclient.go index d43c832..cac8c71 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 @@ -97,14 +97,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, } } @@ -114,12 +121,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) |