Skip to content

Commit 9584008

Browse files
henrikbrixandersenaescolar
authored andcommitted
net: buf: deprecate special putter and getter functions
Deprecate the net_buf_put() and net_buf_get() functions. Special handling of net_bufs in k_fifos is no longer needed after commit 3d306c1, since these actions are now atomic regardless of any net_buf fragments. Signed-off-by: Henrik Brix Andersen <[email protected]>
1 parent 69fe9b0 commit 9584008

File tree

3 files changed

+16
-24
lines changed

3 files changed

+16
-24
lines changed

doc/connectivity/networking/api/net_buf.rst

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,11 @@ Both the maximum data and user data capacity of the buffers is
5050
compile-time defined when declaring the buffer pool.
5151

5252
The buffers have native support for being passed through k_fifo kernel
53-
objects. This is a very practical feature when the buffers need to be
54-
passed from one thread to another. However, since a net_buf may have a
55-
fragment chain attached to it, instead of using the :c:func:`k_fifo_put`
56-
and :c:func:`k_fifo_get` APIs, special :c:func:`net_buf_put` and
57-
:c:func:`net_buf_get` APIs must be used when passing buffers through
58-
FIFOs. These APIs ensure that the buffer chains stay intact. The same
59-
applies for passing buffers through a singly linked list, in which case
60-
the :c:func:`net_buf_slist_put` and :c:func:`net_buf_slist_get`
53+
objects. Use :c:func:`k_fifo_put` and :c:func:`k_fifo_get` to pass buffer
54+
from one thread to another.
55+
56+
Special functions exist for dealing with buffers in single linked lists,
57+
where the :c:func:`net_buf_slist_put` and :c:func:`net_buf_slist_get`
6158
functions must be used instead of :c:func:`sys_slist_append` and
6259
:c:func:`sys_slist_get`.
6360

doc/releases/release-notes-4.0.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ Removed APIs in this release
3030
Deprecated in this release
3131
==========================
3232

33+
* Deprecated the :c:func:`net_buf_put` and :c:func:`net_buf_get` API functions in favor of
34+
:c:func:`k_fifo_put` and :c:func:`k_fifo_get`.
35+
3336
Architectures
3437
*************
3538

include/zephyr/net/buf.h

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,8 +1437,7 @@ struct net_buf * __must_check net_buf_alloc_with_data(struct net_buf_pool *pool,
14371437
/**
14381438
* @brief Get a buffer from a FIFO.
14391439
*
1440-
* This function is NOT thread-safe if the buffers in the FIFO contain
1441-
* fragments.
1440+
* @deprecated Use @a k_fifo_get() instead.
14421441
*
14431442
* @param fifo Which FIFO to take the buffer from.
14441443
* @param timeout Affects the action taken should the FIFO be empty.
@@ -1448,14 +1447,14 @@ struct net_buf * __must_check net_buf_alloc_with_data(struct net_buf_pool *pool,
14481447
* @return New buffer or NULL if the FIFO is empty.
14491448
*/
14501449
#if defined(CONFIG_NET_BUF_LOG)
1451-
struct net_buf * __must_check net_buf_get_debug(struct k_fifo *fifo,
1452-
k_timeout_t timeout,
1453-
const char *func, int line);
1450+
__deprecated struct net_buf * __must_check net_buf_get_debug(struct k_fifo *fifo,
1451+
k_timeout_t timeout,
1452+
const char *func, int line);
14541453
#define net_buf_get(_fifo, _timeout) \
14551454
net_buf_get_debug(_fifo, _timeout, __func__, __LINE__)
14561455
#else
1457-
struct net_buf * __must_check net_buf_get(struct k_fifo *fifo,
1458-
k_timeout_t timeout);
1456+
__deprecated struct net_buf * __must_check net_buf_get(struct k_fifo *fifo,
1457+
k_timeout_t timeout);
14591458
#endif
14601459

14611460
/**
@@ -1503,9 +1502,6 @@ void net_buf_simple_reserve(struct net_buf_simple *buf, size_t reserve);
15031502
/**
15041503
* @brief Put a buffer into a list
15051504
*
1506-
* If the buffer contains follow-up fragments this function will take care of
1507-
* inserting them as well into the list.
1508-
*
15091505
* @param list Which list to append the buffer to.
15101506
* @param buf Buffer.
15111507
*/
@@ -1514,9 +1510,6 @@ void net_buf_slist_put(sys_slist_t *list, struct net_buf *buf);
15141510
/**
15151511
* @brief Get a buffer from a list.
15161512
*
1517-
* If the buffer had any fragments, these will automatically be recovered from
1518-
* the list as well and be placed to the buffer's fragment list.
1519-
*
15201513
* @param list Which list to take the buffer from.
15211514
*
15221515
* @return New buffer or NULL if the FIFO is empty.
@@ -1526,13 +1519,12 @@ struct net_buf * __must_check net_buf_slist_get(sys_slist_t *list);
15261519
/**
15271520
* @brief Put a buffer to the end of a FIFO.
15281521
*
1529-
* If the buffer contains follow-up fragments this function will take care of
1530-
* inserting them as well into the FIFO.
1522+
* @deprecated Use @a k_fifo_put() instead.
15311523
*
15321524
* @param fifo Which FIFO to put the buffer to.
15331525
* @param buf Buffer.
15341526
*/
1535-
void net_buf_put(struct k_fifo *fifo, struct net_buf *buf);
1527+
__deprecated void net_buf_put(struct k_fifo *fifo, struct net_buf *buf);
15361528

15371529
/**
15381530
* @brief Decrements the reference count of a buffer.

0 commit comments

Comments
 (0)