Skip to content

Commit 04e8c42

Browse files
lucypaabrandnewusername
authored andcommitted
Trivial: Style
Signed-off-by: Lucy <[email protected]>
1 parent e1bcd55 commit 04e8c42

File tree

5 files changed

+41
-43
lines changed

5 files changed

+41
-43
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright 2022, UNSW (ABN 57 195 873 179)
2+
# Copyright 2022, UNSW
33
# SPDX-License-Identifier: BSD-2-Clause
44
#
55

libsharedringbuffer/README.md

+22-23
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,66 @@
11
<!--
2-
Copyright 2022, UNSW (ABN 57 195 873 179)
2+
Copyright 2022, UNSW
33
SPDX-License-Identifier: CC-BY-SA-4.0
44
-->
55

66
libsharedringbuffer
77
-------------------
88

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
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
1111
communication mechanism between system components for bulk data transfer,
1212
and was originally created as a data plane between an ethernet driver and
1313
network stack for the sDDF. This library doesn't contain any code that
14-
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
1515
memory regions and notification/signalling handlers to this library.
1616

1717
To use this library in a project you can link `shared_ringbuffer` in your
1818
target applications CMake configuration.
1919

20-
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
2121
example, an ethernet driver produces data for a network stack to consume.
2222
2 separate shared memory regions are required for each ring handle; one
2323
to store available buffers and one to store used buffers. Each ring buffer
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
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
2626
writes of a small integer are atomic, we can keep memory consistent
2727
without locks.
2828
The size of the ring buffers can be set with the cmake config option,
2929
`LIB_SHARED_RINGBUFFER_DESC_COUNT` but defaults to 512. The user must
30-
ensure that the shared memory regions handed to the library are of
31-
appropriate size to match this.
30+
ensure that the shared memory regions handed to the library are of
31+
appropriate size to match this.
3232

3333
Use case
3434
---------
3535

3636
This library is intended to be used with a separate shared memory region,
3737
usually allocated for DMA for a driver. The ring buffers can then contain
3838
pointers into this shared memory, indicating which buffers are in use or
39-
available to be used by either component.
39+
available to be used by either component.
4040
Typically, 2 shared ring buffers are required, with separate structures
4141
required on the recieve path and transmit path. Thus there are 4 regions
42-
of shared memory required: 1 storing pointers to available RX buffers,
42+
of shared memory required: 1 storing pointers to available RX buffers,
4343
1 storing pointers to used RX buffers, 1 storing pointers to TX
4444
buffers, and another storing pointers to available TX buffers.
4545

46-
On initialisation, both the producer and consumer should allocate their
46+
On initialisation, both the producer and consumer should allocate their
4747
own ring handles (`struct ring_handle`). These data structures simply
48-
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
4949
interface with this library. The ring handle should then be passed into
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
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
5252
whether the read/write indices need to be initialised (note that only one
53-
side of the shared memory regions needs to do this).
53+
side of the shared memory regions needs to do this).
5454

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

59-
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
6060
available ring.
61-
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
6262
then enqueues the pointer to it into the used ring.
63-
3. The driver can then notify the reciever.
64-
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,
6565
processes the data, and once finished, can enqueue it back into
6666
the available ring to be used once more by the driver.
67-

libsharedringbuffer/include/shared_ringbuffer/shared_ringbuffer.h

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/*
2-
* Copyright 2022, UNSW (ABN 57 195 873 179)
2+
* Copyright 2022, UNSW
33
*
44
* SPDX-License-Identifier: BSD-2-Clause
55
*/
66

7-
#pragma once
7+
#pragma once
88

99
#include <stdint.h>
1010
#include <stddef.h>
@@ -46,7 +46,7 @@ typedef struct ring_handle {
4646
* @param used pointer to 'used' ring in shared memory.
4747
* @param notify function pointer used to notify the other user.
4848
* @param buffer_init 1 indicates the read and write indices in shared memory need to be initialised.
49-
* 0 inidicates they do not. Only one side of the shared memory regions needs to do this.
49+
* 0 inidicates they do not. Only one side of the shared memory regions needs to do this.
5050
*/
5151
void ring_init(ring_handle_t *ring, ring_buffer_t *avail, ring_buffer_t *used, notify_fn notify, int buffer_init);
5252

@@ -57,7 +57,7 @@ void ring_init(ring_handle_t *ring, ring_buffer_t *avail, ring_buffer_t *used, n
5757
*
5858
* @return true indicates the buffer is empty, false otherwise.
5959
*/
60-
static inline int ring_empty(ring_buffer_t *ring)
60+
static inline int ring_empty(ring_buffer_t *ring)
6161
{
6262
return !((ring->write_idx - ring->read_idx) % CONFIG_LIB_SHARED_RINGBUFFER_DESC_COUNT);
6363
}
@@ -91,7 +91,7 @@ static inline void notify(ring_handle_t *ring)
9191
* @param ring Ring buffer to enqueue into.
9292
* @param buffer address into shared memory where data is stored.
9393
* @param len length of data inside the buffer above.
94-
* @param cookie optional pointer to data required on dequeueing.
94+
* @param cookie optional pointer to data required on dequeueing.
9595
*
9696
* @return -1 when ring is empty, 0 on success.
9797
*/
@@ -118,7 +118,7 @@ static inline int enqueue(ring_buffer_t *ring, uintptr_t buffer, unsigned int le
118118
* @param ring Ring buffer to Dequeue from.
119119
* @param buffer pointer to the address of where to store buffer address.
120120
* @param len pointer to variable to store length of data dequeueing.
121-
* @param cookie pointer optional pointer to data required on dequeueing.
121+
* @param cookie pointer optional pointer to data required on dequeueing.
122122
*
123123
* @return -1 when ring is empty, 0 on success.
124124
*/
@@ -141,16 +141,16 @@ static inline int dequeue(ring_buffer_t *ring, uintptr_t *addr, unsigned int *le
141141

142142
/**
143143
* Enqueue an element into an available ring buffer.
144-
* This indicates the buffer address parameter is currently available for use.
144+
* This indicates the buffer address parameter is currently available for use.
145145
*
146146
* @param ring Ring handle to enqueue into.
147147
* @param buffer address into shared memory where data is stored.
148148
* @param len length of data inside the buffer above.
149-
* @param cookie optional pointer to data required on dequeueing.
149+
* @param cookie optional pointer to data required on dequeueing.
150150
*
151151
* @return -1 when ring is empty, 0 on success.
152152
*/
153-
static inline int enqueue_avail(ring_handle_t *ring, uintptr_t addr, unsigned int len, void *cookie)
153+
static inline int enqueue_avail(ring_handle_t *ring, uintptr_t addr, unsigned int len, void *cookie)
154154
{
155155
return enqueue(ring->avail_ring, addr, len, cookie);
156156
}
@@ -162,11 +162,11 @@ static inline int enqueue_avail(ring_handle_t *ring, uintptr_t addr, unsigned in
162162
* @param ring Ring handle to enqueue into.
163163
* @param buffer address into shared memory where data is stored.
164164
* @param len length of data inside the buffer above.
165-
* @param cookie optional pointer to data required on dequeueing.
165+
* @param cookie optional pointer to data required on dequeueing.
166166
*
167167
* @return -1 when ring is empty, 0 on success.
168168
*/
169-
static inline int enqueue_used(ring_handle_t *ring, uintptr_t addr, unsigned int len, void *cookie)
169+
static inline int enqueue_used(ring_handle_t *ring, uintptr_t addr, unsigned int len, void *cookie)
170170
{
171171
return enqueue(ring->used_ring, addr, len, cookie);
172172
}
@@ -177,7 +177,7 @@ static inline int enqueue_used(ring_handle_t *ring, uintptr_t addr, unsigned int
177177
* @param ring Ring handle to dequeue from.
178178
* @param buffer pointer to the address of where to store buffer address.
179179
* @param len pointer to variable to store length of data dequeueing.
180-
* @param cookie pointer optional pointer to data required on dequeueing.
180+
* @param cookie pointer optional pointer to data required on dequeueing.
181181
*
182182
* @return -1 when ring is empty, 0 on success.
183183
*/
@@ -192,7 +192,7 @@ static inline int dequeue_avail(ring_handle_t *ring, uintptr_t *addr, unsigned i
192192
* @param ring Ring handle to dequeue from.
193193
* @param buffer pointer to the address of where to store buffer address.
194194
* @param len pointer to variable to store length of data dequeueing.
195-
* @param cookie pointer optional pointer to data required on dequeueing.
195+
* @param cookie pointer optional pointer to data required on dequeueing.
196196
*
197197
* @return -1 when ring is empty, 0 on success.
198198
*/
@@ -204,7 +204,7 @@ static inline int dequeue_used(ring_handle_t *ring, uintptr_t *addr, unsigned in
204204
/**
205205
* Dequeue an element from a ring buffer.
206206
* This function is intended for use by the driver, to collect a pointer
207-
* into this structure to be passed around as a cookie.
207+
* into this structure to be passed around as a cookie.
208208
*
209209
* @param ring Ring buffer to dequeue from.
210210
* @param addr pointer to the address of where to store buffer address.
@@ -230,4 +230,4 @@ static int driver_dequeue(ring_buffer_t *ring, uintptr_t *addr, unsigned int *le
230230
ring->read_idx++;
231231

232232
return 0;
233-
}
233+
}

libsharedringbuffer/src/shared_ringbuffer.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/*
2-
* Copyright 2022, UNSW (ABN 57 195 873 179)
3-
*
2+
* Copyright 2022, UNSW
43
* SPDX-License-Identifier: BSD-2-Clause
54
*/
65

@@ -18,4 +17,4 @@ void ring_init(ring_handle_t *ring, ring_buffer_t *avail, ring_buffer_t *used, n
1817
ring->avail_ring->write_idx = 0;
1918
ring->avail_ring->read_idx = 0;
2019
}
21-
}
20+
}

0 commit comments

Comments
 (0)