dpdk: Add support for Mellanox ConnectX-4 devices
[vpp.git] / src / vlibmemory / unix_shared_memory_queue.h
1 /*
2  *------------------------------------------------------------------
3  * unix_shared_memory_queue.h - shared-memory queues
4  *
5  * Copyright (c) 2009 Cisco and/or its affiliates.
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at:
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *------------------------------------------------------------------
18  */
19
20 #ifndef included_unix_shared_memory_queue_h
21 #define included_unix_shared_memory_queue_h
22
23 #include <pthread.h>
24 #include <vppinfra/mem.h>
25
26 typedef struct _unix_shared_memory_queue
27 {
28   pthread_mutex_t mutex;        /* 8 bytes */
29   pthread_cond_t condvar;       /* 8 bytes */
30   int head;
31   int tail;
32   int cursize;
33   int maxsize;
34   int elsize;
35   int consumer_pid;
36   int signal_when_queue_non_empty;
37   char data[0];
38 } unix_shared_memory_queue_t;
39
40 unix_shared_memory_queue_t *unix_shared_memory_queue_init (int nels,
41                                                            int elsize,
42                                                            int consumer_pid,
43                                                            int
44                                                            signal_when_queue_non_empty);
45 void unix_shared_memory_queue_free (unix_shared_memory_queue_t * q);
46 int unix_shared_memory_queue_add (unix_shared_memory_queue_t * q,
47                                   u8 * elem, int nowait);
48 int unix_shared_memory_queue_sub (unix_shared_memory_queue_t * q,
49                                   u8 * elem, int nowait);
50 void unix_shared_memory_queue_lock (unix_shared_memory_queue_t * q);
51 void unix_shared_memory_queue_unlock (unix_shared_memory_queue_t * q);
52 int unix_shared_memory_queue_is_full (unix_shared_memory_queue_t * q);
53 int unix_shared_memory_queue_add_nolock (unix_shared_memory_queue_t * q,
54                                          u8 * elem);
55
56 int unix_shared_memory_queue_sub_raw (unix_shared_memory_queue_t * q,
57                                       u8 * elem);
58 int unix_shared_memory_queue_add_raw (unix_shared_memory_queue_t * q,
59                                       u8 * elem);
60
61 #endif /* included_unix_shared_memory_queue_h */
62
63 /*
64  * fd.io coding-style-patch-verification: ON
65  *
66  * Local Variables:
67  * eval: (c-set-style "gnu")
68  * End:
69  */