FD.io VPP
v16.09
Vector Packet Processing
Main Page
Related Pages
Data Structures
Source
Files
Symbols
jvpp_common.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2016 Cisco and/or its affiliates.
3
* Licensed under the Apache License, Version 2.0 (the "License");
4
* you may not use this file except in compliance with the License.
5
* You may obtain a copy of the License at:
6
*
7
* http://www.apache.org/licenses/LICENSE-2.0
8
*
9
* Unless required by applicable law or agreed to in writing, software
10
* distributed under the License is distributed on an "AS IS" BASIS,
11
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
* See the License for the specific language governing permissions and
13
* limitations under the License.
14
*/
15
#ifndef __included_jvpp_common_h__
16
#define __included_jvpp_common_h__
17
//
18
#include <
vppinfra/types.h
>
19
#include <
vlibapi/api.h
>
20
#include <
vlibmemory/api.h
>
21
#include <jni.h>
22
23
typedef
struct
{
24
/* Unique identifier used for matching replays with requests */
25
volatile
u32
context_id
;
26
27
/* Spinlock */
28
volatile
u32
lock
;
29
u32
tag
;
30
31
/* JNI Native Method Interface pointer for message handlers */
32
JNIEnv *
jenv
;
33
34
/* JNI Invoke Interface pointer for attachment of rx thread to java thread */
35
JavaVM *
jvm
;
36
37
/* Convenience */
38
unix_shared_memory_queue_t
*
vl_input_queue
;
39
u32
my_client_index
;
40
}
jvpp_main_t
;
41
42
extern
jvpp_main_t
jvpp_main
__attribute__((aligned (64)));
43
44
static_always_inline
u32
vppjni_get_context_id
(
jvpp_main_t
* jm) {
45
return
__sync_add_and_fetch(&jm->
context_id
, 1);
46
}
47
48
static_always_inline
void
vppjni_lock
(
jvpp_main_t
* jm,
u32
tag) {
49
while
(__sync_lock_test_and_set(&jm->
lock
, 1))
50
;
51
jm->
tag
= tag;
52
}
53
54
static_always_inline
void
vppjni_unlock
(
jvpp_main_t
* jm) {
55
jm->
tag
= 0;
56
CLIB_MEMORY_BARRIER
();
57
jm->
lock
= 0;
58
}
59
60
/**
61
* Calls onError callback on callbackObject reference. Passes instance of callbackExceptionClass as parameter.
62
*/
63
void
call_on_error
(
const
char
* callName,
int
contextId,
int
retval,
64
jclass callbackClass, jobject callbackObject,
65
jclass callbackExceptionClass);
66
67
#endif
/* __included_jvpp_common_h__ */
types.h
vppjni_get_context_id
static_always_inline u32 vppjni_get_context_id(jvpp_main_t *jm)
Definition:
jvpp_common.h:44
jvpp_main_t::lock
volatile u32 lock
Definition:
jvpp_common.h:28
static_always_inline
#define static_always_inline
Definition:
clib.h:85
jvpp_main
jvpp_main_t jvpp_main
Definition:
jvpp_common.c:30
api.h
call_on_error
void call_on_error(const char *callName, int contextId, int retval, jclass callbackClass, jobject callbackObject, jclass callbackExceptionClass)
Calls onError callback on callbackObject reference.
Definition:
jvpp_common.c:32
jvpp_main_t::jvm
JavaVM * jvm
Definition:
jvpp_common.h:35
jvpp_main_t::jenv
JNIEnv * jenv
Definition:
jvpp_common.h:32
vppjni_lock
static_always_inline void vppjni_lock(jvpp_main_t *jm, u32 tag)
Definition:
jvpp_common.h:48
u32
unsigned int u32
Definition:
types.h:88
vppjni_unlock
static_always_inline void vppjni_unlock(jvpp_main_t *jm)
Definition:
jvpp_common.h:54
jvpp_main_t::tag
u32 tag
Definition:
jvpp_common.h:29
jvpp_main_t
Definition:
jvpp_common.h:23
api.h
jvpp_main_t::my_client_index
u32 my_client_index
Definition:
jvpp_common.h:39
jvpp_main_t::vl_input_queue
unix_shared_memory_queue_t * vl_input_queue
Definition:
jvpp_common.h:38
CLIB_MEMORY_BARRIER
#define CLIB_MEMORY_BARRIER()
Definition:
clib.h:101
jvpp_main_t::context_id
volatile u32 context_id
Definition:
jvpp_common.h:25
unix_shared_memory_queue_t
struct _unix_shared_memory_queue unix_shared_memory_queue_t
vpp-api
java
jvpp-common
jvpp_common.h
Generated on Fri Nov 18 2016 06:18:03 for FD.io VPP by
1.8.11