Skip to content

Commit 09528e8

Browse files
committed
Trivial: Copyright headers
Signed-off-by: Lucy <[email protected]>
1 parent 07af3a0 commit 09528e8

File tree

7 files changed

+55
-56
lines changed

7 files changed

+55
-56
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ add_subdirectory(libvswitch)
1717
add_subdirectory(libfdtgen)
1818
add_subdirectory(libtx2bpmp)
1919
add_subdirectory(libplatsupportports)
20-
add_subdirectory(libsharedringbuffer)
20+
add_subdirectory(libsharedringbuffer)

libsharedringbuffer/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#
2-
# Copyright 2022, Trustworthy Systems, UNSW
3-
#
2+
# Copyright 2022, UNSW
3+
# SPDX-License-Identifier: BSD-2-Clause
44
#
55

66
cmake_minimum_required(VERSION 3.7.2)

libsharedringbuffer/README.md

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,66 @@
11
<!--
2-
Copyright ?
2+
Copyright 2022, UNSW
3+
SPDX-License-Identifier: CC-BY-SA-4.0
34
-->
45

56
libsharedringbuffer
67
-------------------
78

8-
This directory contains a library implementation of shared ring
9-
buffers for the transportation of data. This is intended to be used as a
9+
This directory contains a library implementation of shared ring
10+
buffers for the transportation of data. This is intended to be used as a
1011
communication mechanism between system components for bulk data transfer,
1112
and was originally created as a data plane between an ethernet driver and
1213
network stack for the sDDF. This library doesn't contain any code that
13-
interfaces with seL4. It is expected that the user will provide shared
14+
interfaces with seL4. It is expected that the user will provide shared
1415
memory regions and notification/signalling handlers to this library.
1516

1617
To use this library in a project you can link `shared_ringbuffer` in your
1718
target applications CMake configuration.
1819

19-
This libary is intended to be used by both a producer and consumer. For
20+
This libary is intended to be used by both a producer and a consumer. For
2021
example, an ethernet driver produces data for a network stack to consume.
2122
2 separate shared memory regions are required for each ring handle; one
2223
to store available buffers and one to store used buffers. Each ring buffer
23-
contains a separate read index and write index. The reader only ever
24-
increments the read index, and the writer the write index. As read and
24+
contains a separate read index and write index. The reader only ever
25+
increments the read index, and the writer the write index. As read and
2526
writes of a small integer are atomic, we can keep memory consistent
2627
without locks.
2728
The size of the ring buffers can be set with the cmake config option,
2829
`LIB_SHARED_RINGBUFFER_DESC_COUNT` but defaults to 512. The user must
29-
ensure that the shared memory regions handed to the library are of
30-
appropriate size to match this.
30+
ensure that the shared memory regions handed to the library are of
31+
appropriate size to match this.
3132

3233
Use case
3334
---------
3435

3536
This library is intended to be used with a separate shared memory region,
3637
usually allocated for DMA for a driver. The ring buffers can then contain
3738
pointers into this shared memory, indicating which buffers are in use or
38-
available to be used by either component.
39+
available to be used by either component.
3940
Typically, 2 shared ring buffers are required, with separate structures
4041
required on the recieve path and transmit path. Thus there are 4 regions
41-
of shared memory required: 1 storing pointers to available RX buffers,
42+
of shared memory required: 1 storing pointers to available RX buffers,
4243
1 storing pointers to used RX buffers, 1 storing pointers to TX
4344
buffers, and another storing pointers to available TX buffers.
4445

45-
On initialisation, both the producer and consumer should allocate their
46+
On initialisation, both the producer and consumer should allocate their
4647
own ring handles (`struct ring_handle`). These data structures simply
47-
store pointers to the actual shared memory regions and are used to
48+
store pointers to the actual shared memory regions and are used to
4849
interface with this library. The ring handle should then be passed into
49-
`ring_init` along with 2 shared memory regions, an optional function
50-
pointer to signal the other component, and either 1 or 0 to indicate
50+
`ring_init` along with 2 shared memory regions, an optional function
51+
pointer to signal the other component, and either 1 or 0 to indicate
5152
whether the read/write indices need to be initialised (note that only one
52-
side of the shared memory regions needs to do this).
53+
side of the shared memory regions needs to do this).
5354

54-
After initialisation, a typical use case would look like:
55+
After initialisation, a typical use case would look like:
5556
The driver wants to add some buffer that will be read by another component
56-
(for example, a network stack processing incoming packets).
57+
(for example, a network stack processing incoming packets).
5758

58-
1. The driver dequeues a pointer to an available buffer from the
59+
1. The driver dequeues a pointer to an available buffer from the
5960
available ring.
60-
2. Once data is inserted into the buffer (eg. via DMA), the driver
61+
2. Once data is inserted into the buffer (eg. via DMA), the driver
6162
then enqueues the pointer to it into the used ring.
62-
3. The driver can then notify the reciever.
63-
4. Similarly, the reciever dequeues the pointer from the used ring,
63+
3. The driver can then notify the reciever.
64+
4. Similarly, the reciever dequeues the pointer from the used ring,
6465
processes the data, and once finished, can enqueue it back into
6566
the available ring to be used once more by the driver.
66-

libsharedringbuffer/include/shared_ringbuffer/shared_ringbuffer.h

+24-24
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
/*
2-
* Copyright 2022, UNSW ???
2+
* Copyright 2022, UNSW
3+
*
4+
* SPDX-License-Identifier: BSD-2-Clause
35
*/
46

5-
#pragma once
7+
#pragma once
68

79
#include <stdint.h>
810
#include <stddef.h>
@@ -35,7 +37,6 @@ typedef struct ring_handle {
3537
notify_fn notify;
3638
} ring_handle_t;
3739

38-
3940
/**
4041
* Initialise the shared ring buffer.
4142
*
@@ -44,7 +45,7 @@ typedef struct ring_handle {
4445
* @param used pointer to 'used' ring in shared memory.
4546
* @param notify function pointer used to notify the other user.
4647
* @param buffer_init 1 indicates the read and write indices in shared memory need to be initialised.
47-
* 0 inidicates they do not. Only one side of the shared memory regions needs to do this.
48+
* 0 inidicates they do not. Only one side of the shared memory regions needs to do this.
4849
*/
4950
void ring_init(ring_handle_t *ring, ring_buffer_t *avail, ring_buffer_t *used, notify_fn notify, int buffer_init);
5051

@@ -55,7 +56,7 @@ void ring_init(ring_handle_t *ring, ring_buffer_t *avail, ring_buffer_t *used, n
5556
*
5657
* @return true indicates the buffer is empty, false otherwise.
5758
*/
58-
static inline int ring_empty(ring_buffer_t *ring)
59+
static inline int ring_empty(ring_buffer_t *ring)
5960
{
6061
return !((ring->write_idx - ring->read_idx) % CONFIG_LIB_SHARED_RINGBUFFER_DESC_COUNT);
6162
}
@@ -74,11 +75,11 @@ static inline int ring_full(ring_buffer_t *ring)
7475

7576
/**
7677
* Notify the other user of changes to the shared ring buffers.
77-
*
78+
*
7879
* @param ring the ring handle used.
7980
*
8081
*/
81-
static inline void notify(ring_handle_t *ring)
82+
static inline void notify(ring_handle_t *ring)
8283
{
8384
return ring->notify();
8485
}
@@ -89,15 +90,15 @@ static inline void notify(ring_handle_t *ring)
8990
* @param ring Ring buffer to enqueue into.
9091
* @param buffer address into shared memory where data is stored.
9192
* @param len length of data inside the buffer above.
92-
* @param cookie optional pointer to data required on dequeueing.
93+
* @param cookie optional pointer to data required on dequeueing.
9394
*
9495
* @return -1 when ring is empty, 0 on success.
9596
*/
96-
static inline int enqueue(ring_buffer_t *ring, uintptr_t buffer, unsigned int len, void *cookie)
97+
static inline int enqueue(ring_buffer_t *ring, uintptr_t buffer, unsigned int len, void *cookie)
9798
{
9899
if (ring_full(ring)) {
99100
ZF_LOGE("Ring full");
100-
return -1;
101+
return -1;
101102
}
102103

103104
ring->buffers[ring->write_idx % CONFIG_LIB_SHARED_RINGBUFFER_DESC_COUNT].encoded_addr = buffer;
@@ -116,11 +117,11 @@ static inline int enqueue(ring_buffer_t *ring, uintptr_t buffer, unsigned int le
116117
* @param ring Ring buffer to Dequeue from.
117118
* @param buffer pointer to the address of where to store buffer address.
118119
* @param len pointer to variable to store length of data dequeueing.
119-
* @param cookie pointer optional pointer to data required on dequeueing.
120+
* @param cookie pointer optional pointer to data required on dequeueing.
120121
*
121122
* @return -1 when ring is empty, 0 on success.
122123
*/
123-
static inline int dequeue(ring_buffer_t *ring, uintptr_t *addr, unsigned int *len, void **cookie)
124+
static inline int dequeue(ring_buffer_t *ring, uintptr_t *addr, unsigned int *len, void **cookie)
124125
{
125126
if (ring_empty(ring)) {
126127
ZF_LOGF("Ring is empty");
@@ -139,16 +140,16 @@ static inline int dequeue(ring_buffer_t *ring, uintptr_t *addr, unsigned int *le
139140

140141
/**
141142
* Enqueue an element into an available ring buffer.
142-
* This indicates the buffer address parameter is currently available for use.
143+
* This indicates the buffer address parameter is currently available for use.
143144
*
144145
* @param ring Ring handle to enqueue into.
145146
* @param buffer address into shared memory where data is stored.
146147
* @param len length of data inside the buffer above.
147-
* @param cookie optional pointer to data required on dequeueing.
148+
* @param cookie optional pointer to data required on dequeueing.
148149
*
149150
* @return -1 when ring is empty, 0 on success.
150151
*/
151-
static inline int enqueue_avail(ring_handle_t *ring, uintptr_t addr, unsigned int len, void *cookie)
152+
static inline int enqueue_avail(ring_handle_t *ring, uintptr_t addr, unsigned int len, void *cookie)
152153
{
153154
return enqueue(ring->avail_ring, addr, len, cookie);
154155
}
@@ -160,11 +161,11 @@ static inline int enqueue_avail(ring_handle_t *ring, uintptr_t addr, unsigned in
160161
* @param ring Ring handle to enqueue into.
161162
* @param buffer address into shared memory where data is stored.
162163
* @param len length of data inside the buffer above.
163-
* @param cookie optional pointer to data required on dequeueing.
164+
* @param cookie optional pointer to data required on dequeueing.
164165
*
165166
* @return -1 when ring is empty, 0 on success.
166167
*/
167-
static inline int enqueue_used(ring_handle_t *ring, uintptr_t addr, unsigned int len, void *cookie)
168+
static inline int enqueue_used(ring_handle_t *ring, uintptr_t addr, unsigned int len, void *cookie)
168169
{
169170
return enqueue(ring->used_ring, addr, len, cookie);
170171
}
@@ -175,11 +176,11 @@ static inline int enqueue_used(ring_handle_t *ring, uintptr_t addr, unsigned int
175176
* @param ring Ring handle to dequeue from.
176177
* @param buffer pointer to the address of where to store buffer address.
177178
* @param len pointer to variable to store length of data dequeueing.
178-
* @param cookie pointer optional pointer to data required on dequeueing.
179+
* @param cookie pointer optional pointer to data required on dequeueing.
179180
*
180181
* @return -1 when ring is empty, 0 on success.
181182
*/
182-
static inline int dequeue_avail(ring_handle_t *ring, uintptr_t *addr, unsigned int *len, void **cookie)
183+
static inline int dequeue_avail(ring_handle_t *ring, uintptr_t *addr, unsigned int *len, void **cookie)
183184
{
184185
return dequeue(ring->avail_ring, addr, len, cookie);
185186
}
@@ -190,19 +191,19 @@ static inline int dequeue_avail(ring_handle_t *ring, uintptr_t *addr, unsigned i
190191
* @param ring Ring handle to dequeue from.
191192
* @param buffer pointer to the address of where to store buffer address.
192193
* @param len pointer to variable to store length of data dequeueing.
193-
* @param cookie pointer optional pointer to data required on dequeueing.
194+
* @param cookie pointer optional pointer to data required on dequeueing.
194195
*
195196
* @return -1 when ring is empty, 0 on success.
196197
*/
197-
static inline int dequeue_used(ring_handle_t *ring, uintptr_t *addr, unsigned int *len, void **cookie)
198+
static inline int dequeue_used(ring_handle_t *ring, uintptr_t *addr, unsigned int *len, void **cookie)
198199
{
199200
return dequeue(ring->used_ring, addr, len, cookie);
200201
}
201202

202203
/**
203204
* Dequeue an element from a ring buffer.
204205
* This function is intended for use by the driver, to collect a pointer
205-
* into this structure to be passed around as a cookie.
206+
* into this structure to be passed around as a cookie.
206207
*
207208
* @param ring Ring buffer to dequeue from.
208209
* @param addr pointer to the address of where to store buffer address.
@@ -211,7 +212,6 @@ static inline int dequeue_used(ring_handle_t *ring, uintptr_t *addr, unsigned in
211212
*
212213
* @return -1 when ring is empty, 0 on success.
213214
*/
214-
215215
static int driver_dequeue(ring_buffer_t *ring, uintptr_t *addr, unsigned int *len, void **cookie)
216216
{
217217
if (!((ring->write_idx - ring->read_idx) % CONFIG_LIB_SHARED_RINGBUFFER_DESC_COUNT)) {
@@ -228,4 +228,4 @@ static int driver_dequeue(ring_buffer_t *ring, uintptr_t *addr, unsigned int *le
228228
ring->read_idx++;
229229

230230
return 0;
231-
}
231+
}

libsharedringbuffer/src/shared_ringbuffer.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
2-
* Copyright 2022, UNSW ??
2+
* Copyright 2022, UNSW
3+
* SPDX-License-Identifier: BSD-2-Clause
34
*/
45

56
#include <shared_ringbuffer/shared_ringbuffer.h>
@@ -16,4 +17,4 @@ void ring_init(ring_handle_t *ring, ring_buffer_t *avail, ring_buffer_t *used, n
1617
ring->avail_ring->write_idx = 0;
1718
ring->avail_ring->read_idx = 0;
1819
}
19-
}
20+
}

libvirtqueue/include/virtqueue.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,4 @@ int virtqueue_gather_available(virtqueue_device_t *vq, virtqueue_ring_object_t *
188188
* @return 1 on success, 0 on failure (no more buffer available)
189189
*/
190190
int virtqueue_gather_used(virtqueue_driver_t *vq, virtqueue_ring_object_t *robj,
191-
void **buf, unsigned *len, vq_flags_t *flag);
191+
void **buf, unsigned *len, vq_flags_t *flag);

libvirtqueue/src/virtqueue.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ int virtqueue_add_available_buf(virtqueue_driver_t *vq, virtqueue_ring_object_t
129129
vq->avail_ring->ring[vq->avail_ring->idx] = idx;
130130
vq->avail_ring->idx = (vq->avail_ring->idx + 1) & (vq->queue_len - 1);
131131
}
132-
133132
return 1;
134133
}
135134

@@ -154,7 +153,6 @@ int virtqueue_add_used_buf(virtqueue_device_t *vq, virtqueue_ring_object_t *robj
154153
vq->used_ring->ring[cur].id = robj->first;
155154
vq->used_ring->ring[cur].len = len;
156155
vq->used_ring->idx = (cur + 1) & (vq->queue_len - 1);
157-
158156
return 1;
159157
}
160158

@@ -216,4 +214,4 @@ int virtqueue_gather_used(virtqueue_driver_t *vq, virtqueue_ring_object_t *robj,
216214
}
217215
robj->cur = vq_pop_desc(vq, robj->cur, buf, len, flag);
218216
return 1;
219-
}
217+
}

0 commit comments

Comments
 (0)