net: nbuf: Split one global DATA pool to RX and TX DATA pools

If we receive lot of packets, it might happen that we exhaust
all the DATA buffers in the system. This would prevent from
us sending anything to the network.
Change this by splitting the DATA buffer pool into RX and TX
parts. This way RX flooding cannot consume all DATA buffers
that needs to be sent.

Change-Id: I8e8934c6d5fdd47b579ffa6268721b5eb3d64b6d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2017-02-23 23:53:59 +02:00
parent 2478dd250b
commit d32503f57e
105 changed files with 428 additions and 239 deletions

View file

@ -565,7 +565,7 @@ static int eth_enc28j60_rx(struct device *dev)
size_t spi_frame_len;
/* Reserve a data frag to receive the frame */
pkt_buf = net_nbuf_get_reserve_data(0, K_NO_WAIT);
pkt_buf = net_nbuf_get_reserve_rx_data(0, K_NO_WAIT);
if (!pkt_buf) {
SYS_LOG_ERR("Could not allocate data buffer");
net_buf_unref(buf);

View file

@ -419,7 +419,7 @@ static void eth_rx(struct device *iface)
struct net_buf *pkt_buf;
size_t frag_len;
pkt_buf = net_nbuf_get_reserve_data(0, K_NO_WAIT);
pkt_buf = net_nbuf_get_reserve_rx_data(0, K_NO_WAIT);
if (!pkt_buf) {
irq_unlock(imask);
SYS_LOG_ERR("Failed to get fragment buf\n");

View file

@ -38,8 +38,8 @@
* Verify Kconfig configuration
*/
#if CONFIG_NET_NBUF_DATA_COUNT <= CONFIG_ETH_SAM_GMAC_NBUF_DATA_COUNT
#error CONFIG_NET_NBUF_DATA_COUNT has to be larger than \
#if CONFIG_NET_NBUF_RX_DATA_COUNT <= CONFIG_ETH_SAM_GMAC_NBUF_DATA_COUNT
#error CONFIG_NET_NBUF_RX_DATA_COUNT has to be larger than \
CONFIG_ETH_SAM_GMAC_NBUF_DATA_COUNT
#endif
@ -49,9 +49,9 @@
large enough to hold a full frame
#endif
#if CONFIG_NET_NBUF_DATA_SIZE * CONFIG_NET_NBUF_DATA_COUNT \
#if CONFIG_NET_NBUF_DATA_SIZE * CONFIG_NET_NBUF_RX_DATA_COUNT \
< 2 * GMAC_FRAME_SIZE_MAX
#error CONFIG_NET_NBUF_DATA_SIZE * CONFIG_NET_NBUF_DATA_COUNT is not large\
#error CONFIG_NET_NBUF_DATA_SIZE * CONFIG_NET_NBUF_RX_DATA_COUNT is not large\
enough to hold two full frames
#endif
@ -162,7 +162,7 @@ static int rx_descriptors_init(Gmac *gmac, struct gmac_queue *queue)
rx_nbuf_list->tail = 0;
for (int i = 0; i < rx_desc_list->len; i++) {
rx_buf = net_nbuf_get_reserve_data(0, K_NO_WAIT);
rx_buf = net_nbuf_get_reserve_rx_data(0, K_NO_WAIT);
if (rx_buf == NULL) {
free_rx_bufs(rx_nbuf_list);
SYS_LOG_ERR("Failed to reserve data net buffers");
@ -509,7 +509,7 @@ static struct net_buf *frame_get(struct gmac_queue *queue)
DCACHE_INVALIDATE(frag_data, frag_len);
/* Get a new data net buffer from the buffer pool */
new_frag = net_nbuf_get_reserve_data(0, K_NO_WAIT);
new_frag = net_nbuf_get_reserve_rx_data(0, K_NO_WAIT);
if (new_frag == NULL) {
queue->err_rx_frames_dropped++;
net_buf_unref(rx_frame);

View file

@ -22,7 +22,7 @@
/** RX descriptors count for main queue */
#define MAIN_QUEUE_RX_DESC_COUNT CONFIG_ETH_SAM_GMAC_NBUF_DATA_COUNT
/** TX descriptors count for main queue */
#define MAIN_QUEUE_TX_DESC_COUNT (CONFIG_NET_NBUF_DATA_COUNT - \
#define MAIN_QUEUE_TX_DESC_COUNT (CONFIG_NET_NBUF_RX_DATA_COUNT - \
CONFIG_ETH_SAM_GMAC_NBUF_DATA_COUNT + 1)
/** RX/TX descriptors count for priority queues */
#define PRIORITY_QUEUE_DESC_COUNT 1

View file

@ -604,9 +604,9 @@ static void cc2520_rx(int arg)
/**
* Reserve 1 byte for length
*/
pkt_buf = net_nbuf_get_reserve_data(1, K_NO_WAIT);
pkt_buf = net_nbuf_get_reserve_rx_data(1, K_NO_WAIT);
#else
pkt_buf = net_nbuf_get_reserve_data(0, K_NO_WAIT);
pkt_buf = net_nbuf_get_reserve_rx_data(0, K_NO_WAIT);
#endif
if (!pkt_buf) {
SYS_LOG_ERR("No pkt_buf available");

View file

@ -558,9 +558,9 @@ static inline void mcr20a_rx(struct mcr20a_context *mcr20a, uint8_t len)
/**
* Reserve 1 byte for length
*/
pkt_buf = net_nbuf_get_reserve_data(1, K_NO_WAIT);
pkt_buf = net_nbuf_get_reserve_rx_data(1, K_NO_WAIT);
#else
pkt_buf = net_nbuf_get_reserve_data(0, K_NO_WAIT);
pkt_buf = net_nbuf_get_reserve_rx_data(0, K_NO_WAIT);
#endif
if (!pkt_buf) {
SYS_LOG_ERR("No pkt_buf available");

View file

@ -77,7 +77,7 @@ static void nrf5_rx_thread(void *arg1, void *arg2, void *arg3)
goto out;
}
pkt_buf = net_nbuf_get_reserve_data(0, K_NO_WAIT);
pkt_buf = net_nbuf_get_reserve_rx_data(0, K_NO_WAIT);
if (!pkt_buf) {
SYS_LOG_ERR("No pkt_buf available");
goto out;

View file

@ -60,7 +60,7 @@ static uint8_t *upipe_rx(uint8_t *buf, size_t *off)
goto flush;
}
pkt_buf = net_nbuf_get_reserve_data(0, K_NO_WAIT);
pkt_buf = net_nbuf_get_reserve_rx_data(0, K_NO_WAIT);
if (!pkt_buf) {
SYS_LOG_DBG("No fragment available");
goto out;

View file

@ -298,7 +298,7 @@ static inline int slip_input_byte(struct slip_context *slip,
return 0;
}
slip->last = net_nbuf_get_reserve_data(0, K_NO_WAIT);
slip->last = net_nbuf_get_reserve_rx_data(0, K_NO_WAIT);
if (!slip->last) {
net_nbuf_unref(slip->rx);
slip->rx = NULL;
@ -316,7 +316,7 @@ static inline int slip_input_byte(struct slip_context *slip,
/* We need to allocate a new fragment */
struct net_buf *frag;
frag = net_nbuf_get_reserve_data(0, K_NO_WAIT);
frag = net_nbuf_get_reserve_rx_data(0, K_NO_WAIT);
if (!frag) {
SYS_LOG_ERR("[%p] cannot allocate data fragment",
slip);

View file

@ -33,6 +33,14 @@ extern "C" {
struct net_context;
enum net_dir {
/* TX must be first and must have value 0 so that it is selected
* by default.
*/
NET_TX = 0,
NET_RX = 1,
};
struct net_nbuf {
/** Network connection context */
struct net_context *context;
@ -60,6 +68,7 @@ struct net_nbuf {
uint8_t ip_hdr_len; /* pre-filled in order to avoid func call */
uint8_t ext_len; /* length of extension headers */
uint8_t ext_bitmap;
uint8_t net_dir; /* is this RX or TX buf */
#if defined(CONFIG_NET_IPV6)
uint8_t ext_opt_len; /* IPv6 ND option length */
@ -166,6 +175,16 @@ static inline void net_nbuf_add_ext_bitmap(struct net_buf *buf, uint8_t bm)
((struct net_nbuf *)net_buf_user_data(buf))->ext_bitmap |= bm;
}
static inline uint8_t net_nbuf_dir(struct net_buf *buf)
{
return ((struct net_nbuf *)net_buf_user_data(buf))->net_dir;
}
static inline void net_nbuf_set_dir(struct net_buf *buf, enum net_dir dir)
{
((struct net_nbuf *)net_buf_user_data(buf))->net_dir = dir;
}
static inline uint8_t *net_nbuf_next_hdr(struct net_buf *buf)
{
return ((struct net_nbuf *)net_buf_user_data(buf))->next_hdr;
@ -387,11 +406,19 @@ struct net_buf *net_nbuf_get_reserve_tx_debug(uint16_t reserve_head,
#define net_nbuf_get_reserve_tx(res, timeout) \
net_nbuf_get_reserve_tx_debug(res, timeout, __func__, __LINE__)
struct net_buf *net_nbuf_get_reserve_data_debug(uint16_t reserve_head,
int32_t timeout,
const char *caller, int line);
#define net_nbuf_get_reserve_data(res, timeout) \
net_nbuf_get_reserve_data_debug(res, timeout, __func__, __LINE__)
struct net_buf *net_nbuf_get_reserve_rx_data_debug(uint16_t reserve_head,
int32_t timeout,
const char *caller,
int line);
#define net_nbuf_get_reserve_rx_data(res, timeout) \
net_nbuf_get_reserve_rx_data_debug(res, timeout, __func__, __LINE__)
struct net_buf *net_nbuf_get_reserve_tx_data_debug(uint16_t reserve_head,
int32_t timeout,
const char *caller,
int line);
#define net_nbuf_get_reserve_tx_data(res, timeout) \
net_nbuf_get_reserve_tx_data_debug(res, timeout, __func__, __LINE__)
struct net_buf *net_nbuf_get_frag_debug(struct net_buf *buf,
int32_t timeout,
@ -529,7 +556,7 @@ struct net_buf *net_nbuf_get_reserve_tx(uint16_t reserve_head,
int32_t timeout);
/**
* @brief Get DATA buffer from pool but also reserve headroom for
* @brief Get RX DATA buffer from pool but also reserve headroom for
* potential headers.
*
* @details Normally this version is not useful for applications
@ -543,8 +570,26 @@ struct net_buf *net_nbuf_get_reserve_tx(uint16_t reserve_head,
*
* @return Network buffer if successful, NULL otherwise.
*/
struct net_buf *net_nbuf_get_reserve_data(uint16_t reserve_head,
int32_t timeout);
struct net_buf *net_nbuf_get_reserve_rx_data(uint16_t reserve_head,
int32_t timeout);
/**
* @brief Get TX DATA buffer from pool but also reserve headroom for
* potential headers.
*
* @details Normally this version is not useful for applications
* but is mainly used by network fragmentation code.
*
* @param reserve_head How many bytes to reserve for headroom.
* @param timeout Affects the action taken should the net buf pool be empty.
* If K_NO_WAIT, then return immediately. If K_FOREVER, then
* wait as long as necessary. Otherwise, wait up to the specified
* number of milliseconds before timing out.
*
* @return Network buffer if successful, NULL otherwise.
*/
struct net_buf *net_nbuf_get_reserve_tx_data(uint16_t reserve_head,
int32_t timeout);
/**
* @brief Get a data fragment that might be from user specific
@ -1040,11 +1085,13 @@ static inline bool net_nbuf_insert_be32(struct net_buf *buf,
*
* @param rx Pointer to RX pool is returned.
* @param tx Pointer to TX pool is returned.
* @param data Pointer to DATA pool is returned.
* @param rx_data Pointer to RX DATA pool is returned.
* @param tx_data Pointer to TX DATA pool is returned.
*/
void net_nbuf_get_info(struct net_buf_pool **rx,
struct net_buf_pool **tx,
struct net_buf_pool **data);
struct net_buf_pool **rx_data,
struct net_buf_pool **tx_data);
#if defined(CONFIG_NET_DEBUG_NET_BUF)
/**

View file

@ -19,7 +19,8 @@ CONFIG_INIT_STACKS=y
CONFIG_NET_STATISTICS=y
CONFIG_NET_NBUF_RX_COUNT=14
CONFIG_NET_NBUF_TX_COUNT=14
CONFIG_NET_NBUF_DATA_COUNT=30
CONFIG_NET_NBUF_RX_DATA_COUNT=20
CONFIG_NET_NBUF_TX_DATA_COUNT=20
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=2
CONFIG_NET_MAX_CONTEXTS=10

View file

@ -11,7 +11,8 @@ CONFIG_PRINTK=y
CONFIG_NET_STATISTICS=y
CONFIG_NET_NBUF_RX_COUNT=14
CONFIG_NET_NBUF_TX_COUNT=14
CONFIG_NET_NBUF_DATA_COUNT=30
CONFIG_NET_NBUF_RX_DATA_COUNT=30
CONFIG_NET_NBUF_TX_DATA_COUNT=30
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=2
CONFIG_NET_MAX_CONTEXTS=10

View file

@ -12,7 +12,8 @@ CONFIG_PRINTK=y
CONFIG_NET_STATISTICS=y
CONFIG_NET_NBUF_RX_COUNT=14
CONFIG_NET_NBUF_TX_COUNT=14
CONFIG_NET_NBUF_DATA_COUNT=30
CONFIG_NET_NBUF_RX_DATA_COUNT=30
CONFIG_NET_NBUF_TX_DATA_COUNT=30
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=2
CONFIG_NET_MAX_CONTEXTS=10

View file

@ -7,7 +7,8 @@ CONFIG_NET_DHCPV4=y
CONFIG_NET_BUF=y
CONFIG_NET_NBUF_RX_COUNT=4
CONFIG_NET_NBUF_TX_COUNT=4
CONFIG_NET_NBUF_DATA_COUNT=10
CONFIG_NET_NBUF_RX_DATA_COUNT=5
CONFIG_NET_NBUF_TX_DATA_COUNT=5
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT=1

View file

@ -6,7 +6,8 @@ CONFIG_NET_UDP=y
CONFIG_NET_DHCPV4=y
CONFIG_NET_NBUF_RX_COUNT=4
CONFIG_NET_NBUF_TX_COUNT=4
CONFIG_NET_NBUF_DATA_COUNT=16
CONFIG_NET_NBUF_RX_DATA_COUNT=16
CONFIG_NET_NBUF_TX_DATA_COUNT=16
CONFIG_INIT_STACKS=y

View file

@ -8,7 +8,8 @@ CONFIG_NET_SLIP_TAP=y
CONFIG_NET_NBUF_RX_COUNT=4
CONFIG_NET_NBUF_TX_COUNT=4
CONFIG_NET_NBUF_DATA_COUNT=14
CONFIG_NET_NBUF_RX_DATA_COUNT=14
CONFIG_NET_NBUF_TX_DATA_COUNT=14
CONFIG_TEST_RANDOM_GENERATOR=y

View file

@ -8,7 +8,8 @@ CONFIG_NET_LOG=y
CONFIG_INIT_STACKS=y
CONFIG_NET_NBUF_RX_COUNT=16
CONFIG_NET_NBUF_TX_COUNT=16
CONFIG_NET_NBUF_DATA_COUNT=16
CONFIG_NET_NBUF_RX_DATA_COUNT=10
CONFIG_NET_NBUF_TX_DATA_COUNT=10
CONFIG_NET_IPV6_RA_RDNSS=y
CONFIG_NET_IFACE_UNICAST_IPV4_ADDR_COUNT=3

View file

@ -7,7 +7,8 @@ CONFIG_NET_LOG=y
CONFIG_INIT_STACKS=y
CONFIG_NET_NBUF_RX_COUNT=16
CONFIG_NET_NBUF_TX_COUNT=16
CONFIG_NET_NBUF_DATA_COUNT=16
CONFIG_NET_NBUF_RX_DATA_COUNT=16
CONFIG_NET_NBUF_TX_DATA_COUNT=16
CONFIG_NET_IPV6_RA_RDNSS=y
CONFIG_NET_IFACE_UNICAST_IPV4_ADDR_COUNT=3

View file

@ -13,7 +13,8 @@ CONFIG_NET_BUF=y
CONFIG_NET_IFACE_UNICAST_IPV4_ADDR_COUNT=3
CONFIG_NET_NBUF_RX_COUNT=2
CONFIG_NET_NBUF_TX_COUNT=3
CONFIG_NET_NBUF_DATA_COUNT=12
CONFIG_NET_NBUF_RX_DATA_COUNT=6
CONFIG_NET_NBUF_TX_DATA_COUNT=6
# ENC28J60 Ethernet Device
CONFIG_ETH_ENC28J60=y

View file

@ -3,7 +3,8 @@ CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NET_NBUF_RX_COUNT=20
CONFIG_NET_NBUF_TX_COUNT=5
CONFIG_NET_NBUF_DATA_COUNT=40
CONFIG_NET_NBUF_RX_DATA_COUNT=20
CONFIG_NET_NBUF_TX_DATA_COUNT=20
CONFIG_NET_IPV4=n
CONFIG_NET_IPV6=y

View file

@ -20,7 +20,8 @@ CONFIG_PRINTK=y
CONFIG_NET_STATISTICS=y
CONFIG_NET_NBUF_RX_COUNT=14
CONFIG_NET_NBUF_TX_COUNT=14
CONFIG_NET_NBUF_DATA_COUNT=30
CONFIG_NET_NBUF_RX_DATA_COUNT=20
CONFIG_NET_NBUF_TX_DATA_COUNT=20
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=2
CONFIG_NET_MAX_CONTEXTS=10

View file

@ -5,7 +5,8 @@ CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NET_NBUF_RX_COUNT=20
CONFIG_NET_NBUF_TX_COUNT=5
CONFIG_NET_NBUF_DATA_COUNT=40
CONFIG_NET_NBUF_RX_DATA_COUNT=40
CONFIG_NET_NBUF_TX_DATA_COUNT=40
CONFIG_NET_IPV4=n
CONFIG_NET_IPV6=y

View file

@ -3,7 +3,8 @@ CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NET_NBUF_RX_COUNT=20
CONFIG_NET_NBUF_TX_COUNT=5
CONFIG_NET_NBUF_DATA_COUNT=40
CONFIG_NET_NBUF_RX_DATA_COUNT=20
CONFIG_NET_NBUF_TX_DATA_COUNT=20
CONFIG_NET_IPV4=n
CONFIG_NET_IPV6=y

View file

@ -2,7 +2,8 @@ CONFIG_NETWORKING=y
CONFIG_NET_NBUF_RX_COUNT=20
CONFIG_NET_NBUF_TX_COUNT=5
CONFIG_NET_NBUF_DATA_COUNT=40
CONFIG_NET_NBUF_RX_DATA_COUNT=40
CONFIG_NET_NBUF_TX_DATA_COUNT=40
CONFIG_NET_IPV4=n
CONFIG_NET_IPV6=y

View file

@ -6,7 +6,8 @@ CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NET_NBUF_RX_COUNT=20
CONFIG_NET_NBUF_TX_COUNT=5
CONFIG_NET_NBUF_DATA_COUNT=80
CONFIG_NET_NBUF_RX_DATA_COUNT=40
CONFIG_NET_NBUF_TX_DATA_COUNT=40
CONFIG_NET_TX_STACK_SIZE=2048
CONFIG_NET_RX_STACK_SIZE=2048

View file

@ -3,7 +3,8 @@ CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NET_NBUF_RX_COUNT=20
CONFIG_NET_NBUF_TX_COUNT=5
CONFIG_NET_NBUF_DATA_COUNT=40
CONFIG_NET_NBUF_RX_DATA_COUNT=40
CONFIG_NET_NBUF_TX_DATA_COUNT=40
CONFIG_NET_IPV4=n
CONFIG_NET_IPV6=y

View file

@ -12,7 +12,8 @@ CONFIG_PRINTK=y
CONFIG_NET_STATISTICS=y
CONFIG_NET_NBUF_RX_COUNT=14
CONFIG_NET_NBUF_TX_COUNT=14
CONFIG_NET_NBUF_DATA_COUNT=30
CONFIG_NET_NBUF_RX_DATA_COUNT=30
CONFIG_NET_NBUF_TX_DATA_COUNT=30
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=2
CONFIG_NET_MAX_CONTEXTS=10

View file

@ -15,7 +15,8 @@ CONFIG_PRINTK=y
CONFIG_NET_STATISTICS=y
CONFIG_NET_NBUF_RX_COUNT=10
CONFIG_NET_NBUF_TX_COUNT=10
CONFIG_NET_NBUF_DATA_COUNT=20
CONFIG_NET_NBUF_RX_DATA_COUNT=20
CONFIG_NET_NBUF_TX_DATA_COUNT=20
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=2
CONFIG_NET_MAX_CONTEXTS=10

View file

@ -11,9 +11,10 @@ CONFIG_NET_IPV4=y
CONFIG_NET_IPV6=n
CONFIG_NET_BUF=y
CONFIG_NET_IFACE_UNICAST_IPV4_ADDR_COUNT=3
CONFIG_NET_NBUF_RX_COUNT=10
CONFIG_NET_NBUF_RX_COUNT=5
CONFIG_NET_NBUF_TX_COUNT=2
CONFIG_NET_NBUF_DATA_COUNT=12
CONFIG_NET_NBUF_RX_DATA_COUNT=10
CONFIG_NET_NBUF_TX_DATA_COUNT=6
# ENC28J60 Ethernet Device
CONFIG_ETH_ENC28J60=y

View file

@ -1,9 +1,10 @@
CONFIG_NETWORKING=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NET_NBUF_RX_COUNT=20
CONFIG_NET_NBUF_RX_COUNT=10
CONFIG_NET_NBUF_TX_COUNT=5
CONFIG_NET_NBUF_DATA_COUNT=40
CONFIG_NET_NBUF_RX_DATA_COUNT=20
CONFIG_NET_NBUF_TX_DATA_COUNT=20
CONFIG_NET_IPV4=n
CONFIG_NET_IPV6=y

View file

@ -21,7 +21,8 @@ CONFIG_PRINTK=y
CONFIG_NET_STATISTICS=y
CONFIG_NET_NBUF_RX_COUNT=14
CONFIG_NET_NBUF_TX_COUNT=14
CONFIG_NET_NBUF_DATA_COUNT=30
CONFIG_NET_NBUF_RX_DATA_COUNT=30
CONFIG_NET_NBUF_TX_DATA_COUNT=30
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=2
CONFIG_NET_MAX_CONTEXTS=10

View file

@ -5,7 +5,8 @@ CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NET_NBUF_RX_COUNT=20
CONFIG_NET_NBUF_TX_COUNT=5
CONFIG_NET_NBUF_DATA_COUNT=40
CONFIG_NET_NBUF_RX_DATA_COUNT=40
CONFIG_NET_NBUF_TX_DATA_COUNT=40
CONFIG_NET_IPV4=n
CONFIG_NET_IPV6=y

View file

@ -10,7 +10,8 @@ CONFIG_NET_STATISTICS=y
CONFIG_NET_NBUF_RX_COUNT=14
CONFIG_NET_NBUF_TX_COUNT=14
CONFIG_NET_NBUF_DATA_COUNT=30
CONFIG_NET_NBUF_RX_DATA_COUNT=30
CONFIG_NET_NBUF_TX_DATA_COUNT=30
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=5
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=5
CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT=1

View file

@ -3,7 +3,8 @@ CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NET_NBUF_RX_COUNT=20
CONFIG_NET_NBUF_TX_COUNT=5
CONFIG_NET_NBUF_DATA_COUNT=40
CONFIG_NET_NBUF_RX_DATA_COUNT=30
CONFIG_NET_NBUF_TX_DATA_COUNT=20
CONFIG_NET_IPV4=n
CONFIG_NET_IPV6=y

View file

@ -2,7 +2,8 @@ CONFIG_NETWORKING=y
CONFIG_NET_NBUF_RX_COUNT=20
CONFIG_NET_NBUF_TX_COUNT=5
CONFIG_NET_NBUF_DATA_COUNT=40
CONFIG_NET_NBUF_RX_DATA_COUNT=30
CONFIG_NET_NBUF_TX_DATA_COUNT=20
CONFIG_NET_IPV4=n
CONFIG_NET_IPV6=y

View file

@ -6,7 +6,8 @@ CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NET_NBUF_RX_COUNT=20
CONFIG_NET_NBUF_TX_COUNT=5
CONFIG_NET_NBUF_DATA_COUNT=80
CONFIG_NET_NBUF_RX_DATA_COUNT=40
CONFIG_NET_NBUF_TX_DATA_COUNT=40
CONFIG_NET_TX_STACK_SIZE=4096

View file

@ -3,7 +3,8 @@ CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NET_NBUF_RX_COUNT=10
CONFIG_NET_NBUF_TX_COUNT=5
CONFIG_NET_NBUF_DATA_COUNT=40
CONFIG_NET_NBUF_RX_DATA_COUNT=40
CONFIG_NET_NBUF_TX_DATA_COUNT=40
CONFIG_NET_IPV4=n
CONFIG_NET_IPV6=y

View file

@ -13,7 +13,8 @@ CONFIG_PRINTK=y
CONFIG_NET_STATISTICS=y
CONFIG_NET_NBUF_RX_COUNT=16
CONFIG_NET_NBUF_TX_COUNT=16
CONFIG_NET_NBUF_DATA_COUNT=40
CONFIG_NET_NBUF_RX_DATA_COUNT=40
CONFIG_NET_NBUF_TX_DATA_COUNT=40
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=2
CONFIG_NET_MAX_CONTEXTS=16

View file

@ -15,7 +15,8 @@ CONFIG_PRINTK=y
CONFIG_NET_STATISTICS=y
CONFIG_NET_NBUF_RX_COUNT=10
CONFIG_NET_NBUF_TX_COUNT=10
CONFIG_NET_NBUF_DATA_COUNT=20
CONFIG_NET_NBUF_RX_DATA_COUNT=20
CONFIG_NET_NBUF_TX_DATA_COUNT=20
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=2
CONFIG_NET_MAX_CONTEXTS=10

View file

@ -10,7 +10,8 @@ CONFIG_NET_STATISTICS=n
CONFIG_NET_NBUF_RX_COUNT=14
CONFIG_NET_NBUF_TX_COUNT=14
CONFIG_NET_NBUF_DATA_COUNT=72
CONFIG_NET_NBUF_RX_DATA_COUNT=36
CONFIG_NET_NBUF_TX_DATA_COUNT=36
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=2
CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT=1
CONFIG_NET_MAX_CONTEXTS=10

View file

@ -10,7 +10,8 @@ CONFIG_NET_IFACE_UNICAST_IPV4_ADDR_COUNT=3
CONFIG_NET_NBUF_RX_COUNT=64
CONFIG_NET_NBUF_TX_COUNT=64
CONFIG_NET_NBUF_DATA_COUNT=16
CONFIG_NET_NBUF_RX_DATA_COUNT=16
CONFIG_NET_NBUF_TX_DATA_COUNT=16
CONFIG_NET_IPV4=n
CONFIG_NET_IPV6=y

View file

@ -8,7 +8,8 @@ CONFIG_INIT_STACKS=y
CONFIG_NET_NBUF_RX_COUNT=16
CONFIG_NET_NBUF_TX_COUNT=16
CONFIG_NET_NBUF_DATA_COUNT=16
CONFIG_NET_NBUF_RX_DATA_COUNT=16
CONFIG_NET_NBUF_TX_DATA_COUNT=16
CONFIG_NET_IPV6_RA_RDNSS=y
CONFIG_NET_IFACE_UNICAST_IPV4_ADDR_COUNT=3

View file

@ -8,7 +8,8 @@ CONFIG_INIT_STACKS=y
CONFIG_NET_NBUF_RX_COUNT=16
CONFIG_NET_NBUF_TX_COUNT=16
CONFIG_NET_NBUF_DATA_COUNT=16
CONFIG_NET_NBUF_RX_DATA_COUNT=8
CONFIG_NET_NBUF_TX_DATA_COUNT=8
CONFIG_NET_IPV6_RA_RDNSS=y
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3

View file

@ -5,7 +5,8 @@ CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NET_NBUF_RX_COUNT=6
CONFIG_NET_NBUF_TX_COUNT=6
CONFIG_NET_NBUF_DATA_COUNT=10
CONFIG_NET_NBUF_RX_DATA_COUNT=10
CONFIG_NET_NBUF_TX_DATA_COUNT=10
CONFIG_NET_IPV4=n
CONFIG_NET_IPV6=y

View file

@ -6,7 +6,8 @@ CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NET_NBUF_RX_COUNT=6
CONFIG_NET_NBUF_TX_COUNT=6
CONFIG_NET_NBUF_DATA_COUNT=10
CONFIG_NET_NBUF_RX_DATA_COUNT=10
CONFIG_NET_NBUF_TX_DATA_COUNT=10
CONFIG_NET_IPV4=n
CONFIG_NET_IPV6=y

View file

@ -6,7 +6,8 @@ CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NET_NBUF_RX_COUNT=6
CONFIG_NET_NBUF_TX_COUNT=6
CONFIG_NET_NBUF_DATA_COUNT=10
CONFIG_NET_NBUF_RX_DATA_COUNT=10
CONFIG_NET_NBUF_TX_DATA_COUNT=10
CONFIG_NET_IPV4=n
CONFIG_NET_IPV6=y

View file

@ -3,7 +3,8 @@ CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NET_NBUF_RX_COUNT=6
CONFIG_NET_NBUF_TX_COUNT=6
CONFIG_NET_NBUF_DATA_COUNT=10
CONFIG_NET_NBUF_RX_DATA_COUNT=10
CONFIG_NET_NBUF_TX_DATA_COUNT=10
CONFIG_NET_IPV4=n
CONFIG_NET_IPV6=y

View file

@ -3,7 +3,8 @@ CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NET_NBUF_RX_COUNT=6
CONFIG_NET_NBUF_TX_COUNT=6
CONFIG_NET_NBUF_DATA_COUNT=10
CONFIG_NET_NBUF_RX_DATA_COUNT=10
CONFIG_NET_NBUF_TX_DATA_COUNT=10
CONFIG_NET_IPV4=n
CONFIG_NET_IPV6=y

View file

@ -3,7 +3,8 @@ CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NET_NBUF_RX_COUNT=6
CONFIG_NET_NBUF_TX_COUNT=6
CONFIG_NET_NBUF_DATA_COUNT=10
CONFIG_NET_NBUF_RX_DATA_COUNT=10
CONFIG_NET_NBUF_TX_DATA_COUNT=10
CONFIG_NET_IPV4=n
CONFIG_NET_IPV6=y

View file

@ -9,7 +9,8 @@ CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT=3
CONFIG_NET_IPV6=y
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
CONFIG_NET_MAX_CONTEXTS=10
CONFIG_NET_NBUF_DATA_COUNT=30
CONFIG_NET_NBUF_RX_DATA_COUNT=30
CONFIG_NET_NBUF_TX_DATA_COUNT=30
CONFIG_NET_NBUF_RX_COUNT=14
CONFIG_NET_NBUF_TX_COUNT=14
CONFIG_NET_SHELL=y

View file

@ -9,7 +9,8 @@ CONFIG_NET_IPV6=y
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
CONFIG_NET_LOG=y
CONFIG_NET_MAX_CONTEXTS=10
CONFIG_NET_NBUF_DATA_COUNT=30
CONFIG_NET_NBUF_RX_DATA_COUNT=30
CONFIG_NET_NBUF_TX_DATA_COUNT=30
CONFIG_NET_NBUF_RX_COUNT=14
CONFIG_NET_NBUF_TX_COUNT=14
CONFIG_NET_SHELL=y

View file

@ -13,7 +13,8 @@ CONFIG_NET_BUF=y
CONFIG_NET_IFACE_UNICAST_IPV4_ADDR_COUNT=3
CONFIG_NET_NBUF_RX_COUNT=2
CONFIG_NET_NBUF_TX_COUNT=3
CONFIG_NET_NBUF_DATA_COUNT=12
CONFIG_NET_NBUF_RX_DATA_COUNT=10
CONFIG_NET_NBUF_TX_DATA_COUNT=10
CONFIG_ETH_ENC28J60=y
CONFIG_ETH_ENC28J60_0=y

View file

@ -14,7 +14,8 @@ CONFIG_NET_BUF=y
CONFIG_NET_IFACE_UNICAST_IPV4_ADDR_COUNT=3
CONFIG_NET_NBUF_RX_COUNT=4
CONFIG_NET_NBUF_TX_COUNT=4
CONFIG_NET_NBUF_DATA_COUNT=12
CONFIG_NET_NBUF_RX_DATA_COUNT=6
CONFIG_NET_NBUF_TX_DATA_COUNT=6
CONFIG_ETH_ENC28J60=y
CONFIG_ETH_ENC28J60_0=y

View file

@ -17,7 +17,8 @@ CONFIG_NET_SHELL=y
CONFIG_NET_NBUF_RX_COUNT=16
CONFIG_NET_NBUF_TX_COUNT=16
CONFIG_NET_NBUF_DATA_SIZE=256
CONFIG_NET_NBUF_DATA_COUNT=30
CONFIG_NET_NBUF_RX_DATA_COUNT=15
CONFIG_NET_NBUF_TX_DATA_COUNT=15
CONFIG_NET_SAMPLES_IP_ADDRESSES=y
CONFIG_NET_SAMPLES_MY_IPV6_ADDR="2001:db8::1"

View file

@ -8,7 +8,8 @@ CONFIG_INIT_STACKS=y
CONFIG_NET_NBUF_RX_COUNT=16
CONFIG_NET_NBUF_TX_COUNT=16
CONFIG_NET_NBUF_DATA_COUNT=16
CONFIG_NET_NBUF_RX_DATA_COUNT=16
CONFIG_NET_NBUF_TX_DATA_COUNT=16
CONFIG_NET_IPV6_RA_RDNSS=y
CONFIG_NET_IFACE_UNICAST_IPV4_ADDR_COUNT=3

View file

@ -8,7 +8,8 @@ CONFIG_INIT_STACKS=y
CONFIG_NET_NBUF_RX_COUNT=16
CONFIG_NET_NBUF_TX_COUNT=16
CONFIG_NET_NBUF_DATA_COUNT=16
CONFIG_NET_NBUF_RX_DATA_COUNT=16
CONFIG_NET_NBUF_TX_DATA_COUNT=16
CONFIG_NET_IPV6_RA_RDNSS=y
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3

View file

@ -18,7 +18,8 @@ CONFIG_NET_MAX_CONTEXTS=10
CONFIG_NET_NBUF_RX_COUNT=10
CONFIG_NET_NBUF_TX_COUNT=10
CONFIG_NET_NBUF_DATA_COUNT=40
CONFIG_NET_NBUF_RX_DATA_COUNT=20
CONFIG_NET_NBUF_TX_DATA_COUNT=20
CONFIG_TEST_RANDOM_GENERATOR=y

View file

@ -18,7 +18,8 @@ CONFIG_NET_MAX_CONTEXTS=10
CONFIG_NET_NBUF_RX_COUNT=10
CONFIG_NET_NBUF_TX_COUNT=10
CONFIG_NET_NBUF_DATA_COUNT=40
CONFIG_NET_NBUF_RX_DATA_COUNT=20
CONFIG_NET_NBUF_TX_DATA_COUNT=20
CONFIG_TEST_RANDOM_GENERATOR=y

View file

@ -18,7 +18,8 @@ CONFIG_NET_MAX_CONTEXTS=10
CONFIG_NET_NBUF_RX_COUNT=10
CONFIG_NET_NBUF_TX_COUNT=10
CONFIG_NET_NBUF_DATA_COUNT=40
CONFIG_NET_NBUF_RX_DATA_COUNT=20
CONFIG_NET_NBUF_TX_DATA_COUNT=20
CONFIG_TEST_RANDOM_GENERATOR=y

View file

@ -148,7 +148,7 @@ static int slip_process_byte(unsigned char c)
SYS_LOG_ERR("No more buffers");
return 0;
}
buf = net_nbuf_get_reserve_data(0, K_NO_WAIT);
buf = net_nbuf_get_reserve_rx_data(0, K_NO_WAIT);
if (!buf) {
SYS_LOG_ERR("No more buffers");
net_nbuf_unref(pkt_curr);
@ -226,7 +226,7 @@ static void send_data(uint8_t *cfg, uint8_t *data, size_t len)
return;
}
buf = net_nbuf_get_reserve_data(0, K_NO_WAIT);
buf = net_nbuf_get_reserve_rx_data(0, K_NO_WAIT);
if (!buf) {
SYS_LOG_DBG("No fragment available");
net_nbuf_unref(pkt);

View file

@ -387,7 +387,7 @@ static int wpanusb_vendor_handler(struct usb_setup_packet *setup,
return -ENOMEM;
}
buf = net_nbuf_get_reserve_data(0, K_NO_WAIT);
buf = net_nbuf_get_reserve_tx_data(0, K_NO_WAIT);
if (!buf) {
net_nbuf_unref(pkt);
return -ENOMEM;

View file

@ -7,7 +7,8 @@ CONFIG_NET_STATISTICS=y
CONFIG_NET_NBUF_RX_COUNT=14
CONFIG_NET_NBUF_TX_COUNT=14
CONFIG_NET_NBUF_DATA_COUNT=28
CONFIG_NET_NBUF_RX_DATA_COUNT=28
CONFIG_NET_NBUF_TX_DATA_COUNT=28
CONFIG_NET_NBUF_DATA_SIZE=512
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=5
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=5

View file

@ -9,7 +9,8 @@ CONFIG_NET_STATISTICS=y
CONFIG_NET_NBUF_RX_COUNT=100
CONFIG_NET_NBUF_TX_COUNT=100
CONFIG_NET_NBUF_DATA_COUNT=200
CONFIG_NET_NBUF_RX_DATA_COUNT=100
CONFIG_NET_NBUF_TX_DATA_COUNT=100
CONFIG_NET_NBUF_DATA_SIZE=128
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=2

View file

@ -9,7 +9,8 @@ CONFIG_NET_STATISTICS=y
CONFIG_NET_NBUF_RX_COUNT=14
CONFIG_NET_NBUF_TX_COUNT=14
CONFIG_NET_NBUF_DATA_COUNT=30
CONFIG_NET_NBUF_RX_DATA_COUNT=30
CONFIG_NET_NBUF_TX_DATA_COUNT=30
CONFIG_NET_NBUF_DATA_SIZE=128
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=5
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=5

View file

@ -9,7 +9,8 @@ CONFIG_NET_STATISTICS=y
CONFIG_NET_NBUF_RX_COUNT=14
CONFIG_NET_NBUF_TX_COUNT=14
CONFIG_NET_NBUF_DATA_COUNT=28
CONFIG_NET_NBUF_RX_DATA_COUNT=28
CONFIG_NET_NBUF_TX_DATA_COUNT=28
CONFIG_NET_NBUF_DATA_SIZE=512
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=5
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=5

View file

@ -8,7 +8,8 @@ CONFIG_NET_STATISTICS=y
CONFIG_NET_NBUF_RX_COUNT=100
CONFIG_NET_NBUF_TX_COUNT=100
CONFIG_NET_NBUF_DATA_COUNT=100
CONFIG_NET_NBUF_RX_DATA_COUNT=50
CONFIG_NET_NBUF_TX_DATA_COUNT=50
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=2
CONFIG_NET_MAX_CONTEXTS=10

View file

@ -243,8 +243,15 @@ config NET_NBUF_TX_COUNT
Each TX buffer will occupy smallish amount of memory.
See include/net/nbuf.h and the sizeof(struct nbuf)
config NET_NBUF_DATA_COUNT
int "How many network data buffers are allocated"
config NET_NBUF_RX_DATA_COUNT
int "How many network data buffers are allocated for receiving data"
default 16
help
Each data buffer will occupy CONFIG_NBUF_DATA_SIZE + smallish
header (sizeof(struct net_buf)) amount of data.
config NET_NBUF_TX_DATA_COUNT
int "How many network data buffers are allocated for sending data"
default 16
help
Each data buffer will occupy CONFIG_NBUF_DATA_SIZE + smallish

View file

@ -289,8 +289,8 @@ static struct net_buf *prepare_message(struct net_if *iface, uint8_t type,
buf = net_nbuf_get_reserve_tx(0, K_FOREVER);
frag = net_nbuf_get_reserve_data(net_if_get_ll_reserve(iface, NULL),
K_FOREVER);
frag = net_nbuf_get_reserve_tx_data(net_if_get_ll_reserve(iface, NULL),
K_FOREVER);
net_nbuf_set_ll_reserve(buf, net_buf_headroom(frag));
net_nbuf_set_iface(buf, iface);

View file

@ -115,7 +115,7 @@ int net_icmpv4_send_echo_request(struct net_if *iface,
reserve = net_if_get_ll_reserve(iface,
(const struct in6_addr *)dst);
frag = net_nbuf_get_reserve_data(reserve, K_FOREVER);
frag = net_nbuf_get_reserve_tx_data(reserve, K_FOREVER);
net_buf_frag_add(buf, frag);
net_nbuf_set_family(buf, AF_INET);

View file

@ -908,8 +908,8 @@ int net_ipv6_send_na(struct net_if *iface, struct in6_addr *src,
NET_ASSERT_INFO(buf, "Out of TX buffers");
frag = net_nbuf_get_reserve_data(net_if_get_ll_reserve(iface, dst),
K_FOREVER);
frag = net_nbuf_get_reserve_tx_data(net_if_get_ll_reserve(iface, dst),
K_FOREVER);
NET_ASSERT_INFO(frag, "Out of DATA buffers");
@ -1511,8 +1511,8 @@ int net_ipv6_send_ns(struct net_if *iface,
NET_ASSERT_INFO(buf, "Out of TX buffers");
frag = net_nbuf_get_reserve_data(net_if_get_ll_reserve(iface, dst),
K_FOREVER);
frag = net_nbuf_get_reserve_tx_data(net_if_get_ll_reserve(iface, dst),
K_FOREVER);
NET_ASSERT_INFO(frag, "Out of DATA buffers");
@ -1645,7 +1645,7 @@ int net_ipv6_send_rs(struct net_if *iface)
buf = net_nbuf_get_reserve_tx(0, K_FOREVER);
frag = net_nbuf_get_reserve_data(
frag = net_nbuf_get_reserve_tx_data(
net_if_get_ll_reserve(iface, &NET_IPV6_BUF(buf)->dst),
K_FOREVER);

View file

@ -112,8 +112,8 @@ static inline struct net_buf *prepare_arp(struct net_if *iface,
goto fail;
}
frag = net_nbuf_get_reserve_data(sizeof(struct net_eth_hdr),
K_FOREVER);
frag = net_nbuf_get_reserve_tx_data(sizeof(struct net_eth_hdr),
K_FOREVER);
if (!frag) {
goto fail;
}
@ -203,8 +203,8 @@ struct net_buf *net_arp_prepare(struct net_buf *buf)
net_nbuf_set_ll_reserve(buf, sizeof(struct net_eth_hdr));
header = net_nbuf_get_reserve_data(sizeof(struct net_eth_hdr),
K_FOREVER);
header = net_nbuf_get_reserve_tx_data(
sizeof(struct net_eth_hdr), K_FOREVER);
hdr = (struct net_eth_hdr *)(header->data -
net_nbuf_ll_reserve(buf));
@ -380,8 +380,8 @@ static inline struct net_buf *prepare_arp_reply(struct net_if *iface,
goto fail;
}
frag = net_nbuf_get_reserve_data(sizeof(struct net_eth_hdr),
K_FOREVER);
frag = net_nbuf_get_reserve_tx_data(sizeof(struct net_eth_hdr),
K_FOREVER);
if (!frag) {
goto fail;
}

View file

@ -220,7 +220,7 @@ static struct net_buf *ipsp_alloc_buf(struct bt_l2cap_chan *chan)
{
NET_DBG("Channel %p requires buffer", chan);
return net_nbuf_get_reserve_data(0, K_FOREVER);
return net_nbuf_get_reserve_rx_data(0, K_FOREVER);
}
static struct bt_l2cap_chan_ops ipsp_ops = {

View file

@ -97,7 +97,8 @@ static inline void ieee802154_acknowledge(struct net_if *iface,
return;
}
frag = net_nbuf_get_reserve_data(IEEE802154_ACK_PKT_LENGTH, K_FOREVER);
frag = net_nbuf_get_reserve_tx_data(IEEE802154_ACK_PKT_LENGTH,
K_FOREVER);
net_buf_frag_insert(buf, frag);
net_nbuf_set_ll_reserve(buf, net_buf_headroom(frag));

View file

@ -640,7 +640,7 @@ ieee802154_create_mac_cmd_frame(struct net_if *iface,
return NULL;
}
frag = net_nbuf_get_reserve_data(0, K_FOREVER);
frag = net_nbuf_get_reserve_tx_data(0, K_FOREVER);
if (!frag) {
goto error;
}

View file

@ -31,11 +31,12 @@
#include "net_private.h"
/* Available (free) buffers queue */
#define NBUF_RX_COUNT CONFIG_NET_NBUF_RX_COUNT
#define NBUF_TX_COUNT CONFIG_NET_NBUF_TX_COUNT
#define NBUF_DATA_COUNT CONFIG_NET_NBUF_DATA_COUNT
#define NBUF_DATA_LEN CONFIG_NET_NBUF_DATA_SIZE
#define NBUF_USER_DATA_LEN CONFIG_NET_NBUF_USER_DATA_SIZE
#define NBUF_RX_COUNT CONFIG_NET_NBUF_RX_COUNT
#define NBUF_TX_COUNT CONFIG_NET_NBUF_TX_COUNT
#define NBUF_RX_DATA_COUNT CONFIG_NET_NBUF_RX_DATA_COUNT
#define NBUF_TX_DATA_COUNT CONFIG_NET_NBUF_TX_DATA_COUNT
#define NBUF_DATA_LEN CONFIG_NET_NBUF_DATA_SIZE
#define NBUF_USER_DATA_LEN CONFIG_NET_NBUF_USER_DATA_SIZE
#if defined(CONFIG_NET_TCP)
#define APP_PROTO_LEN NET_TCPH_LEN
@ -77,13 +78,16 @@
#error "Too small net_buf fragment size"
#endif
NET_BUF_POOL_DEFINE(rx_buffers, NBUF_RX_COUNT, 0, sizeof(struct net_nbuf),
NET_BUF_POOL_DEFINE(rx_bufs, NBUF_RX_COUNT, 0, sizeof(struct net_nbuf),
NULL);
NET_BUF_POOL_DEFINE(tx_buffers, NBUF_TX_COUNT, 0, sizeof(struct net_nbuf),
NET_BUF_POOL_DEFINE(tx_bufs, NBUF_TX_COUNT, 0, sizeof(struct net_nbuf),
NULL);
/* The data fragment pool is for storing network data. */
NET_BUF_POOL_DEFINE(data_buffers, NBUF_DATA_COUNT, NBUF_DATA_LEN,
NET_BUF_POOL_DEFINE(data_rx_bufs, NBUF_RX_DATA_COUNT, NBUF_DATA_LEN,
NBUF_USER_DATA_LEN, NULL);
NET_BUF_POOL_DEFINE(data_tx_bufs, NBUF_TX_DATA_COUNT, NBUF_DATA_LEN,
NBUF_USER_DATA_LEN, NULL);
#if defined(CONFIG_NET_DEBUG_NET_BUF)
@ -150,8 +154,8 @@ static inline struct net_buf_pool *get_data_pool(struct net_context *context)
static inline bool is_external_pool(struct net_buf_pool *pool)
{
if (pool != &rx_buffers && pool != &tx_buffers &&
pool != &data_buffers) {
if (pool != &rx_bufs && pool != &tx_bufs &&
pool != &data_rx_bufs && pool != &data_tx_bufs) {
return true;
}
@ -161,12 +165,14 @@ static inline bool is_external_pool(struct net_buf_pool *pool)
#if defined(CONFIG_NET_DEBUG_NET_BUF)
static inline const char *pool2str(struct net_buf_pool *pool)
{
if (pool == &rx_buffers) {
if (pool == &rx_bufs) {
return "RX";
} else if (pool == &tx_buffers) {
} else if (pool == &tx_bufs) {
return "TX";
} else if (pool == &data_buffers) {
return "DATA";
} else if (pool == &data_rx_bufs) {
return "RDATA";
} else if (pool == &data_tx_bufs) {
return "TDATA";
} else if (is_data_pool(pool)) {
return "EDATA";
}
@ -241,6 +247,13 @@ struct net_buf *net_nbuf_get_reserve(struct net_buf_pool *pool,
net_buf_reserve(buf, reserve_head);
} else {
memset(net_buf_user_data(buf), 0, sizeof(struct net_nbuf));
/* Remember the RX vs. TX so that the fragments can be
* allocated from correct DATA pool.
*/
if (pool == &rx_bufs) {
net_nbuf_set_dir(buf, NET_RX);
}
}
NET_BUF_CHECK_IF_NOT_IN_USE(buf, buf->ref + 1);
@ -291,11 +304,22 @@ struct net_buf *net_nbuf_get_frag(struct net_buf *buf,
}
#endif /* CONFIG_NET_CONTEXT_NBUF_POOL */
if (net_nbuf_dir(buf) == NET_RX) {
#if defined(CONFIG_NET_DEBUG_NET_BUF)
return net_nbuf_get_reserve_data_debug(net_nbuf_ll_reserve(buf),
timeout, caller, line);
return net_nbuf_get_reserve_rx_data_debug(
net_nbuf_ll_reserve(buf), timeout, caller, line);
#else
return net_nbuf_get_reserve_data(net_nbuf_ll_reserve(buf), timeout);
return net_nbuf_get_reserve_rx_data(net_nbuf_ll_reserve(buf),
timeout);
#endif
}
#if defined(CONFIG_NET_DEBUG_NET_BUF)
return net_nbuf_get_reserve_tx_data_debug(net_nbuf_ll_reserve(buf),
timeout, caller, line);
#else
return net_nbuf_get_reserve_tx_data(net_nbuf_ll_reserve(buf),
timeout);
#endif
}
@ -304,7 +328,7 @@ struct net_buf *net_nbuf_get_reserve_rx_debug(uint16_t reserve_head,
int32_t timeout,
const char *caller, int line)
{
return net_nbuf_get_reserve_debug(&rx_buffers, reserve_head, timeout,
return net_nbuf_get_reserve_debug(&rx_bufs, reserve_head, timeout,
caller, line);
}
@ -312,15 +336,23 @@ struct net_buf *net_nbuf_get_reserve_tx_debug(uint16_t reserve_head,
int32_t timeout,
const char *caller, int line)
{
return net_nbuf_get_reserve_debug(&tx_buffers, reserve_head, timeout,
return net_nbuf_get_reserve_debug(&tx_bufs, reserve_head, timeout,
caller, line);
}
struct net_buf *net_nbuf_get_reserve_data_debug(uint16_t reserve_head,
int32_t timeout,
const char *caller, int line)
struct net_buf *net_nbuf_get_reserve_rx_data_debug(uint16_t reserve_head,
int32_t timeout,
const char *caller, int line)
{
return net_nbuf_get_reserve_debug(&data_buffers, reserve_head,
return net_nbuf_get_reserve_debug(&data_rx_bufs, reserve_head,
timeout, caller, line);
}
struct net_buf *net_nbuf_get_reserve_tx_data_debug(uint16_t reserve_head,
int32_t timeout,
const char *caller, int line)
{
return net_nbuf_get_reserve_debug(&data_tx_bufs, reserve_head,
timeout, caller, line);
}
@ -329,19 +361,25 @@ struct net_buf *net_nbuf_get_reserve_data_debug(uint16_t reserve_head,
struct net_buf *net_nbuf_get_reserve_rx(uint16_t reserve_head,
int32_t timeout)
{
return net_nbuf_get_reserve(&rx_buffers, reserve_head, timeout);
return net_nbuf_get_reserve(&rx_bufs, reserve_head, timeout);
}
struct net_buf *net_nbuf_get_reserve_tx(uint16_t reserve_head,
int32_t timeout)
{
return net_nbuf_get_reserve(&tx_buffers, reserve_head, timeout);
return net_nbuf_get_reserve(&tx_bufs, reserve_head, timeout);
}
struct net_buf *net_nbuf_get_reserve_data(uint16_t reserve_head,
int32_t timeout)
struct net_buf *net_nbuf_get_reserve_rx_data(uint16_t reserve_head,
int32_t timeout)
{
return net_nbuf_get_reserve(&data_buffers, reserve_head, timeout);
return net_nbuf_get_reserve(&data_rx_bufs, reserve_head, timeout);
}
struct net_buf *net_nbuf_get_reserve_tx_data(uint16_t reserve_head,
int32_t timeout)
{
return net_nbuf_get_reserve(&data_tx_bufs, reserve_head, timeout);
}
#endif /* CONFIG_NET_DEBUG_NET_BUF */
@ -405,7 +443,7 @@ struct net_buf *net_nbuf_get_rx_debug(struct net_context *context,
int32_t timeout,
const char *caller, int line)
{
return net_nbuf_get_debug(&rx_buffers, context, timeout, caller, line);
return net_nbuf_get_debug(&rx_bufs, context, timeout, caller, line);
}
struct net_buf *net_nbuf_get_tx_debug(struct net_context *context,
@ -414,7 +452,7 @@ struct net_buf *net_nbuf_get_tx_debug(struct net_context *context,
{
struct net_buf_pool *pool = get_tx_pool(context);
return net_nbuf_get_debug(pool ? pool : &tx_buffers, context,
return net_nbuf_get_debug(pool ? pool : &tx_bufs, context,
timeout, caller, line);
}
@ -424,7 +462,7 @@ struct net_buf *net_nbuf_get_data_debug(struct net_context *context,
{
struct net_buf_pool *pool = get_data_pool(context);
return net_nbuf_get_debug(pool ? pool : &data_buffers, context,
return net_nbuf_get_debug(pool ? pool : &data_tx_bufs, context,
timeout, caller, line);
}
@ -434,7 +472,7 @@ struct net_buf *net_nbuf_get_rx(struct net_context *context, int32_t timeout)
{
NET_ASSERT_INFO(context, "RX context not set");
return net_nbuf_get(&rx_buffers, context, timeout);
return net_nbuf_get(&rx_bufs, context, timeout);
}
struct net_buf *net_nbuf_get_tx(struct net_context *context, int32_t timeout)
@ -445,7 +483,7 @@ struct net_buf *net_nbuf_get_tx(struct net_context *context, int32_t timeout)
pool = get_tx_pool(context);
return net_nbuf_get(pool ? pool : &tx_buffers, context, timeout);
return net_nbuf_get(pool ? pool : &tx_bufs, context, timeout);
}
struct net_buf *net_nbuf_get_data(struct net_context *context, int32_t timeout)
@ -456,7 +494,10 @@ struct net_buf *net_nbuf_get_data(struct net_context *context, int32_t timeout)
pool = get_data_pool(context);
return net_nbuf_get(pool ? pool : &data_buffers, context, timeout);
/* The context is not known in RX path so we can only have TX
* data here.
*/
return net_nbuf_get(pool ? pool : &data_tx_bufs, context, timeout);
}
#endif /* CONFIG_NET_DEBUG_NET_BUF */
@ -1309,34 +1350,41 @@ bool net_nbuf_insert(struct net_buf *buf, struct net_buf *frag,
void net_nbuf_get_info(struct net_buf_pool **rx,
struct net_buf_pool **tx,
struct net_buf_pool **data)
struct net_buf_pool **rx_data,
struct net_buf_pool **tx_data)
{
if (rx) {
*rx = &rx_buffers;
*rx = &rx_bufs;
}
if (tx) {
*tx = &tx_buffers;
*tx = &tx_bufs;
}
if (data) {
*data = &data_buffers;
if (rx_data) {
*rx_data = &data_rx_bufs;
}
if (tx_data) {
*tx_data = &data_tx_bufs;
}
}
#if defined(CONFIG_NET_DEBUG_NET_BUF)
void net_nbuf_print(void)
{
NET_DBG("TX %d RX %d DATA %d", tx_buffers.avail_count,
rx_buffers.avail_count, data_buffers.avail_count);
NET_DBG("TX %d RX %d RDATA %d TDATA %d", tx_bufs.avail_count,
rx_bufs.avail_count, data_rx_bufs.avail_count,
data_tx_bufs.avail_count);
}
#endif /* CONFIG_NET_DEBUG_NET_BUF */
void net_nbuf_init(void)
{
NET_DBG("Allocating %d RX (%u bytes), %d TX (%u bytes) "
"and %d data (%u bytes) buffers",
get_frees(&rx_buffers), rx_buffers.pool_size,
get_frees(&tx_buffers), tx_buffers.pool_size,
get_frees(&data_buffers), data_buffers.pool_size);
NET_DBG("Allocating %d RX (%u bytes), %d TX (%u bytes), "
"%d RX data (%u bytes) and %d TX data (%u bytes) buffers",
get_frees(&rx_bufs), rx_bufs.pool_size,
get_frees(&tx_bufs), tx_bufs.pool_size,
get_frees(&data_rx_bufs), data_rx_bufs.pool_size,
get_frees(&data_tx_bufs), data_tx_bufs.pool_size);
}

View file

@ -627,12 +627,12 @@ static void context_info(struct net_context *context, void *user_data)
static int shell_cmd_mem(int argc, char *argv[])
{
struct net_buf_pool *tx, *rx, *data;
struct net_buf_pool *tx, *rx, *rx_data, *tx_data;
ARG_UNUSED(argc);
ARG_UNUSED(argv);
net_nbuf_get_info(&rx, &tx, &data);
net_nbuf_get_info(&rx, &tx, &rx_data, &tx_data);
printk("Fragment length %d bytes\n", CONFIG_NET_NBUF_DATA_SIZE);
@ -647,15 +647,20 @@ static int shell_cmd_mem(int argc, char *argv[])
printk("TX (%s) \t%d\t%d\t%d\t%p\n",
tx->name, tx->pool_size, tx->buf_count, tx->avail_count, tx);
printk("DATA (%s)\t%d\t%d\t%d\t%p\n",
data->name, data->pool_size, data->buf_count,
data->avail_count, data);
printk("RX DATA (%s)\t%d\t%d\t%d\t%p\n",
rx_data->name, rx_data->pool_size, rx_data->buf_count,
rx_data->avail_count, rx_data);
printk("TX DATA (%s)\t%d\t%d\t%d\t%p\n",
tx_data->name, tx_data->pool_size, tx_data->buf_count,
tx_data->avail_count, tx_data);
#else
printk("Name \tCount\tAddress\n");
printk("RX \t%d\t%p\n", rx->buf_count, rx);
printk("TX \t%d\t%p\n", tx->buf_count, tx);
printk("DATA \t%d\t%p\n", data->buf_count, data);
printk("RX DATA \t%d\t%p\n", rx_data->buf_count, rx_data);
printk("TX DATA \t%d\t%p\n", tx_data->buf_count, tx_data);
#endif /* CONFIG_NET_DEBUG_NET_BUF */
if (IS_ENABLED(CONFIG_NET_CONTEXT_NBUF_POOL)) {

View file

@ -10,7 +10,8 @@ CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_MAIN_STACK_SIZE=5048
CONFIG_NET_NBUF_RX_COUNT=1
CONFIG_NET_NBUF_TX_COUNT=1
CONFIG_NET_NBUF_DATA_COUNT=3
CONFIG_NET_NBUF_RX_DATA_COUNT=3
CONFIG_NET_NBUF_TX_DATA_COUNT=3
CONFIG_NET_LOG=y
CONFIG_SYS_LOG_SHOW_COLOR=y
CONFIG_NET_DEBUG_IF=y

View file

@ -322,7 +322,7 @@ static struct net_buf *create_buf(struct net_6lo_data *data)
net_nbuf_ll_dst(buf)->addr = dst_mac;
net_nbuf_ll_dst(buf)->len = 8;
frag = net_nbuf_get_reserve_data(0, K_FOREVER);
frag = net_nbuf_get_reserve_tx_data(0, K_FOREVER);
if (!frag) {
net_nbuf_unref(buf);
return NULL;
@ -384,7 +384,7 @@ static struct net_buf *create_buf(struct net_6lo_data *data)
net_buf_frag_add(buf, frag);
if (remaining > 0) {
frag = net_nbuf_get_reserve_data(0, K_FOREVER);
frag = net_nbuf_get_reserve_tx_data(0, K_FOREVER);
}
}

View file

@ -6,7 +6,8 @@ CONFIG_NET_BUF=y
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_NET_NBUF_RX_COUNT=5
CONFIG_NET_NBUF_TX_COUNT=5
CONFIG_NET_NBUF_DATA_COUNT=10
CONFIG_NET_NBUF_RX_DATA_COUNT=5
CONFIG_NET_NBUF_TX_DATA_COUNT=5
CONFIG_NET_LOG=y
CONFIG_SYS_LOG_SHOW_COLOR=y
CONFIG_RANDOM_GENERATOR=y

View file

@ -174,7 +174,8 @@ static inline struct net_buf *prepare_arp_reply(struct net_if *iface,
goto fail;
}
frag = net_nbuf_get_reserve_data(sizeof(struct net_eth_hdr), K_FOREVER);
frag = net_nbuf_get_reserve_tx_data(sizeof(struct net_eth_hdr),
K_FOREVER);
if (!frag) {
goto fail;
}
@ -228,8 +229,8 @@ static inline struct net_buf *prepare_arp_request(struct net_if *iface,
goto fail;
}
frag = net_nbuf_get_reserve_data(sizeof(struct net_eth_hdr),
K_FOREVER);
frag = net_nbuf_get_reserve_rx_data(sizeof(struct net_eth_hdr),
K_FOREVER);
if (!frag) {
goto fail;
}
@ -340,8 +341,8 @@ static bool run_tests(void)
return false;
}
frag = net_nbuf_get_reserve_data(sizeof(struct net_eth_hdr),
K_FOREVER);
frag = net_nbuf_get_reserve_tx_data(sizeof(struct net_eth_hdr),
K_FOREVER);
if (!frag) {
printk("Out of mem DATA\n");
return false;
@ -568,8 +569,8 @@ static bool run_tests(void)
}
printk("%d buf %p\n", __LINE__, buf);
frag = net_nbuf_get_reserve_data(sizeof(struct net_eth_hdr),
K_FOREVER);
frag = net_nbuf_get_reserve_rx_data(sizeof(struct net_eth_hdr),
K_FOREVER);
if (!frag) {
printk("Out of mem DATA reply\n");
return false;
@ -624,8 +625,8 @@ static bool run_tests(void)
return false;
}
frag = net_nbuf_get_reserve_data(sizeof(struct net_eth_hdr),
K_FOREVER);
frag = net_nbuf_get_reserve_rx_data(sizeof(struct net_eth_hdr),
K_FOREVER);
if (!frag) {
printk("Out of mem DATA request\n");
return false;

View file

@ -15,7 +15,8 @@ CONFIG_NET_IPV6_ND=n
CONFIG_NET_IPV6_DAD=n
CONFIG_NET_NBUF_TX_COUNT=10
CONFIG_NET_NBUF_RX_COUNT=5
CONFIG_NET_NBUF_DATA_COUNT=10
CONFIG_NET_NBUF_RX_DATA_COUNT=10
CONFIG_NET_NBUF_TX_DATA_COUNT=10
#CONFIG_NET_DEBUG_CONTEXT=y
#CONFIG_NET_DEBUG_CORE=y
#CONFIG_NET_DEBUG_IF=y

View file

@ -6,7 +6,8 @@ CONFIG_NET_DHCPV4=y
CONFIG_NET_BUF=y
CONFIG_NET_NBUF_RX_COUNT=4
CONFIG_NET_NBUF_TX_COUNT=4
CONFIG_NET_NBUF_DATA_COUNT=14
CONFIG_NET_NBUF_RX_DATA_COUNT=7
CONFIG_NET_NBUF_TX_DATA_COUNT=7
CONFIG_NET_LOG=y
CONFIG_SYS_LOG_SHOW_COLOR=y
CONFIG_RANDOM_GENERATOR=y

View file

@ -206,8 +206,8 @@ static struct net_buf *nbuf_get_data(struct net_if *iface)
struct net_buf *buf;
struct net_eth_hdr *hdr;
buf = net_nbuf_get_reserve_data(net_if_get_ll_reserve(iface, NULL),
K_FOREVER);
buf = net_nbuf_get_reserve_rx_data(net_if_get_ll_reserve(iface, NULL),
K_FOREVER);
if (!buf) {
return NULL;
}

View file

@ -5,7 +5,8 @@ CONFIG_NET_BUF=y
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_NET_NBUF_RX_COUNT=2
CONFIG_NET_NBUF_TX_COUNT=2
CONFIG_NET_NBUF_DATA_COUNT=5
CONFIG_NET_NBUF_RX_DATA_COUNT=5
CONFIG_NET_NBUF_TX_DATA_COUNT=5
CONFIG_NET_LOG=y
CONFIG_SYS_LOG_SHOW_COLOR=y
CONFIG_RANDOM_GENERATOR=y

View file

@ -11,7 +11,8 @@ CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_MAIN_STACK_SIZE=5048
CONFIG_NET_NBUF_RX_COUNT=2
CONFIG_NET_NBUF_TX_COUNT=2
CONFIG_NET_NBUF_DATA_COUNT=35
CONFIG_NET_NBUF_RX_DATA_COUNT=35
CONFIG_NET_NBUF_TX_DATA_COUNT=35
CONFIG_NET_LOG=y
CONFIG_SYS_LOG_SHOW_COLOR=y

View file

@ -230,7 +230,7 @@ static struct net_buf *create_buf(struct net_fragment_data *data)
net_nbuf_set_iface(buf, net_if_get_default());
net_nbuf_set_ip_hdr_len(buf, NET_IPV6H_LEN);
frag = net_nbuf_get_reserve_data(0, K_FOREVER);
frag = net_nbuf_get_reserve_tx_data(0, K_FOREVER);
if (!frag) {
net_nbuf_unref(buf);
return NULL;
@ -271,7 +271,7 @@ static struct net_buf *create_buf(struct net_fragment_data *data)
net_buf_frag_add(buf, frag);
if (remaining > 0) {
frag = net_nbuf_get_reserve_data(0, K_FOREVER);
frag = net_nbuf_get_reserve_tx_data(0, K_FOREVER);
}
}
@ -453,7 +453,7 @@ static int test_fragment(struct net_fragment_data *data)
net_nbuf_set_ll_reserve(rxbuf, 0);
dfrag = net_nbuf_get_reserve_data(0, K_FOREVER);
dfrag = net_nbuf_get_reserve_rx_data(0, K_FOREVER);
if (!dfrag) {
goto end;
}

View file

@ -6,7 +6,8 @@ CONFIG_NET_L2_IEEE802154_DEBUG=y
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_NET_NBUF_RX_COUNT=5
CONFIG_NET_NBUF_TX_COUNT=5
CONFIG_NET_NBUF_DATA_COUNT=10
CONFIG_NET_NBUF_RX_DATA_COUNT=10
CONFIG_NET_NBUF_TX_DATA_COUNT=10
CONFIG_NET_LOG=y
CONFIG_SYS_LOG_SHOW_COLOR=y
CONFIG_RANDOM_GENERATOR=y

View file

@ -12,7 +12,8 @@ CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NET_IPV6_DAD=n
CONFIG_NET_NBUF_TX_COUNT=10
CONFIG_NET_NBUF_RX_COUNT=5
CONFIG_NET_NBUF_DATA_COUNT=10
CONFIG_NET_NBUF_RX_DATA_COUNT=10
CONFIG_NET_NBUF_TX_DATA_COUNT=10
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=6
CONFIG_NET_MAX_NEXTHOPS=8
CONFIG_NET_IPV6_MAX_NEIGHBORS=8

View file

@ -7,7 +7,8 @@ CONFIG_NET_BUF=y
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_NET_NBUF_RX_COUNT=2
CONFIG_NET_NBUF_TX_COUNT=2
CONFIG_NET_NBUF_DATA_COUNT=5
CONFIG_NET_NBUF_RX_DATA_COUNT=5
CONFIG_NET_NBUF_TX_DATA_COUNT=5
CONFIG_NET_LOG=y
CONFIG_SYS_LOG_SHOW_COLOR=y
CONFIG_RANDOM_GENERATOR=y

View file

@ -12,7 +12,8 @@ CONFIG_NET_IPV6_ND=y
CONFIG_NET_IPV6_DAD=y
CONFIG_NET_NBUF_TX_COUNT=3
CONFIG_NET_NBUF_RX_COUNT=4
CONFIG_NET_NBUF_DATA_COUNT=7
CONFIG_NET_NBUF_RX_DATA_COUNT=7
CONFIG_NET_NBUF_TX_DATA_COUNT=7
CONFIG_NET_6LO=y
CONFIG_NET_6LO_CONTEXT=y
#CONFIG_NET_DEBUG_IF=y

View file

@ -177,7 +177,7 @@ static struct net_buf *prepare_ra_message(void)
reserve = net_if_get_ll_reserve(iface, NULL);
frag = net_nbuf_get_reserve_data(reserve, K_FOREVER);
frag = net_nbuf_get_reserve_rx_data(reserve, K_FOREVER);
net_buf_frag_add(buf, frag);
@ -422,7 +422,7 @@ static bool net_test_send_ns_extra_options(void)
reserve = net_if_get_ll_reserve(iface, NULL);
frag = net_nbuf_get_reserve_data(reserve, K_FOREVER);
frag = net_nbuf_get_reserve_tx_data(reserve, K_FOREVER);
net_buf_frag_add(buf, frag);
@ -458,7 +458,7 @@ static bool net_test_send_ns_no_options(void)
reserve = net_if_get_ll_reserve(iface, NULL);
frag = net_nbuf_get_reserve_data(reserve, K_FOREVER);
frag = net_nbuf_get_reserve_tx_data(reserve, K_FOREVER);
net_buf_frag_add(buf, frag);
@ -578,7 +578,7 @@ static bool net_test_hbho_message(void)
reserve = net_if_get_ll_reserve(iface, NULL);
frag = net_nbuf_get_reserve_data(reserve, K_FOREVER);
frag = net_nbuf_get_reserve_tx_data(reserve, K_FOREVER);
net_buf_frag_add(buf, frag);
@ -623,7 +623,7 @@ static bool net_test_change_ll_addr(void)
reserve = net_if_get_ll_reserve(iface, NULL);
frag = net_nbuf_get_reserve_data(reserve, K_FOREVER);
frag = net_nbuf_get_reserve_tx_data(reserve, K_FOREVER);
net_buf_frag_add(buf, frag);

View file

@ -3,7 +3,8 @@ CONFIG_NET_BUF=y
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_NET_NBUF_RX_COUNT=5
CONFIG_NET_NBUF_TX_COUNT=5
CONFIG_NET_NBUF_DATA_COUNT=10
CONFIG_NET_NBUF_RX_DATA_COUNT=5
CONFIG_NET_NBUF_TX_DATA_COUNT=5
CONFIG_NET_LOG=y
CONFIG_SYS_LOG_SHOW_COLOR=y
CONFIG_RANDOM_GENERATOR=y

View file

@ -6,7 +6,8 @@ CONFIG_NET_BUF=y
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_NET_NBUF_RX_COUNT=4
CONFIG_NET_NBUF_TX_COUNT=4
CONFIG_NET_NBUF_DATA_COUNT=34
CONFIG_NET_NBUF_RX_DATA_COUNT=34
CONFIG_NET_NBUF_TX_DATA_COUNT=34
# The data size is calculated to be this, do not change
# it without fixing the tests.
CONFIG_NET_NBUF_DATA_SIZE=100

View file

@ -63,7 +63,7 @@ static int test_ipv6_multi_frags(void)
/* Example of multi fragment scenario with IPv6 */
buf = net_nbuf_get_reserve_rx(0, K_FOREVER);
frag = net_nbuf_get_reserve_data(LL_RESERVE, K_FOREVER);
frag = net_nbuf_get_reserve_rx_data(LL_RESERVE, K_FOREVER);
/* Place the IP + UDP header in the first fragment */
if (!net_buf_tailroom(frag)) {
@ -91,7 +91,7 @@ static int test_ipv6_multi_frags(void)
net_buf_frag_add(buf, frag);
/* Put some data to rest of the fragments */
frag = net_nbuf_get_reserve_data(LL_RESERVE, K_FOREVER);
frag = net_nbuf_get_reserve_rx_data(LL_RESERVE, K_FOREVER);
if (net_buf_tailroom(frag) -
(CONFIG_NET_NBUF_DATA_SIZE - LL_RESERVE)) {
printk("Invalid number of bytes available in the buf, "
@ -130,8 +130,8 @@ static int test_ipv6_multi_frags(void)
net_buf_frag_add(buf, frag);
if (remaining > 0) {
frag = net_nbuf_get_reserve_data(LL_RESERVE,
K_FOREVER);
frag = net_nbuf_get_reserve_rx_data(LL_RESERVE,
K_FOREVER);
}
}
@ -186,7 +186,7 @@ static int test_fragment_copy(void)
int pos;
buf = net_nbuf_get_reserve_rx(0, K_FOREVER);
frag = net_nbuf_get_reserve_data(LL_RESERVE, K_FOREVER);
frag = net_nbuf_get_reserve_rx_data(LL_RESERVE, K_FOREVER);
/* Place the IP + UDP header in the first fragment */
if (net_buf_tailroom(frag)) {
@ -324,7 +324,7 @@ static int test_fragment_pull(void)
frag = NULL;
for (i = 0; i < FRAG_COUNT; i++) {
frags[i] = net_nbuf_get_reserve_data(12, K_FOREVER);
frags[i] = net_nbuf_get_reserve_tx_data(12, K_FOREVER);
if (frag) {
net_buf_frag_add(frag, frags[i]);
@ -376,13 +376,13 @@ static int test_fragment_pull(void)
net_nbuf_unref(buf);
/* Trying without TX or RX buf as a first element */
frags[0] = net_nbuf_get_reserve_data(12, K_FOREVER);
frags[0] = net_nbuf_get_reserve_tx_data(12, K_FOREVER);
frag = frags[0];
memcpy(net_buf_add(frags[0], sizeof(test_data)),
test_data, sizeof(test_data));
for (i = 1; i < FRAG_COUNT; i++) {
frags[i] = net_nbuf_get_reserve_data(12, K_FOREVER);
frags[i] = net_nbuf_get_reserve_tx_data(12, K_FOREVER);
if (frag) {
net_buf_frag_add(frag, frags[i]);
@ -480,7 +480,7 @@ static int test_nbuf_read_append(void)
/* Example of multi fragment read, append and skip APS's */
buf = net_nbuf_get_reserve_rx(0, K_FOREVER);
frag = net_nbuf_get_reserve_data(LL_RESERVE, K_FOREVER);
frag = net_nbuf_get_reserve_rx_data(LL_RESERVE, K_FOREVER);
/* Place the IP + UDP header in the first fragment */
if (!net_buf_tailroom(frag)) {
@ -508,7 +508,7 @@ static int test_nbuf_read_append(void)
net_buf_frag_add(buf, frag);
/* Put some data to rest of the fragments */
frag = net_nbuf_get_reserve_data(LL_RESERVE, K_FOREVER);
frag = net_nbuf_get_reserve_rx_data(LL_RESERVE, K_FOREVER);
if (net_buf_tailroom(frag) -
(CONFIG_NET_NBUF_DATA_SIZE - LL_RESERVE)) {
printk("Invalid number of bytes available in the buf, "
@ -547,8 +547,8 @@ static int test_nbuf_read_append(void)
net_buf_frag_add(buf, frag);
if (remaining > 0) {
frag = net_nbuf_get_reserve_data(LL_RESERVE,
K_FOREVER);
frag = net_nbuf_get_reserve_rx_data(LL_RESERVE,
K_FOREVER);
}
}
@ -714,7 +714,8 @@ static int test_nbuf_read_write_insert(void)
buf = net_nbuf_get_reserve_rx(0, K_FOREVER);
net_nbuf_set_ll_reserve(buf, LL_RESERVE);
frag = net_nbuf_get_reserve_data(net_nbuf_ll_reserve(buf), K_FOREVER);
frag = net_nbuf_get_reserve_rx_data(net_nbuf_ll_reserve(buf),
K_FOREVER);
net_buf_frag_add(buf, frag);
/* 1) Offset is with in input fragment.
@ -826,7 +827,8 @@ static int test_nbuf_read_write_insert(void)
buf = net_nbuf_get_reserve_rx(0, K_FOREVER);
net_nbuf_set_ll_reserve(buf, LL_RESERVE);
frag = net_nbuf_get_reserve_data(net_nbuf_ll_reserve(buf), K_FOREVER);
frag = net_nbuf_get_reserve_rx_data(net_nbuf_ll_reserve(buf),
K_FOREVER);
net_buf_frag_add(buf, frag);
/* Create 10 bytes space. */
@ -865,14 +867,16 @@ static int test_nbuf_read_write_insert(void)
net_nbuf_set_ll_reserve(buf, LL_RESERVE);
/* First fragment make it fully occupied. */
frag = net_nbuf_get_reserve_data(net_nbuf_ll_reserve(buf), K_FOREVER);
frag = net_nbuf_get_reserve_rx_data(net_nbuf_ll_reserve(buf),
K_FOREVER);
net_buf_frag_add(buf, frag);
len = net_buf_tailroom(frag);
net_buf_add(frag, len);
/* 2nd fragment last 10 bytes tailroom, rest occupied */
frag = net_nbuf_get_reserve_data(net_nbuf_ll_reserve(buf), K_FOREVER);
frag = net_nbuf_get_reserve_rx_data(net_nbuf_ll_reserve(buf),
K_FOREVER);
net_buf_frag_add(buf, frag);
len = net_buf_tailroom(frag);
@ -882,7 +886,8 @@ static int test_nbuf_read_write_insert(void)
read_pos = frag->len - 10;
/* 3rd fragment, only 5 bytes occupied */
frag = net_nbuf_get_reserve_data(net_nbuf_ll_reserve(buf), K_FOREVER);
frag = net_nbuf_get_reserve_rx_data(net_nbuf_ll_reserve(buf),
K_FOREVER);
net_buf_frag_add(buf, frag);
net_buf_add(frag, 5);
@ -919,7 +924,8 @@ static int test_nbuf_read_write_insert(void)
net_nbuf_set_ll_reserve(buf, LL_RESERVE);
/* First fragment make it fully occupied. */
frag = net_nbuf_get_reserve_data(net_nbuf_ll_reserve(buf), K_FOREVER);
frag = net_nbuf_get_reserve_rx_data(net_nbuf_ll_reserve(buf),
K_FOREVER);
net_buf_frag_add(buf, frag);
frag = net_nbuf_write(buf, frag, NET_IPV6UDPH_LEN, &pos, 10,
@ -980,7 +986,8 @@ static int test_nbuf_read_write_insert(void)
net_nbuf_set_ll_reserve(buf, LL_RESERVE);
/* First fragment make it fully occupied. */
frag = net_nbuf_get_reserve_data(net_nbuf_ll_reserve(buf), K_FOREVER);
frag = net_nbuf_get_reserve_rx_data(net_nbuf_ll_reserve(buf),
K_FOREVER);
net_buf_frag_add(buf, frag);
frag = net_nbuf_write(buf, frag, NET_IPV6UDPH_LEN, &pos, 10,
@ -1047,7 +1054,7 @@ static int test_fragment_compact(void)
frag = NULL;
for (i = 0, total = 0; i < FRAG_COUNT; i++) {
frags[i] = net_nbuf_get_reserve_data(12, K_FOREVER);
frags[i] = net_nbuf_get_reserve_rx_data(12, K_FOREVER);
if (frag) {
net_buf_frag_add(frag, frags[i]);
@ -1112,7 +1119,7 @@ static int test_fragment_compact(void)
/* Add empty fragment at the end and compact, the last fragment
* should be removed.
*/
frag = net_nbuf_get_reserve_data(0, K_FOREVER);
frag = net_nbuf_get_reserve_rx_data(0, K_FOREVER);
net_buf_frag_add(buf, frag);
@ -1137,11 +1144,11 @@ static int test_fragment_compact(void)
/* Add two empty fragments at the end and compact, the last two
* fragment should be removed.
*/
frag = net_nbuf_get_reserve_data(0, K_FOREVER);
frag = net_nbuf_get_reserve_rx_data(0, K_FOREVER);
net_buf_frag_add(buf, frag);
frag = net_nbuf_get_reserve_data(0, K_FOREVER);
frag = net_nbuf_get_reserve_rx_data(0, K_FOREVER);
net_buf_frag_add(buf, frag);
@ -1166,11 +1173,11 @@ static int test_fragment_compact(void)
/* Add empty fragment at the beginning and at the end, and then
* compact, the two fragment should be removed.
*/
frag = net_nbuf_get_reserve_data(0, K_FOREVER);
frag = net_nbuf_get_reserve_rx_data(0, K_FOREVER);
net_buf_frag_insert(buf, frag);
frag = net_nbuf_get_reserve_data(0, K_FOREVER);
frag = net_nbuf_get_reserve_rx_data(0, K_FOREVER);
net_buf_frag_add(buf, frag);

View file

@ -4,7 +4,8 @@ CONFIG_NET_BUF=y
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_NET_NBUF_RX_COUNT=3
CONFIG_NET_NBUF_TX_COUNT=4
CONFIG_NET_NBUF_DATA_COUNT=7
CONFIG_NET_NBUF_RX_DATA_COUNT=7
CONFIG_NET_NBUF_TX_DATA_COUNT=7
CONFIG_NET_LOG=y
CONFIG_SYS_LOG_SHOW_COLOR=y
CONFIG_RANDOM_GENERATOR=y

View file

@ -12,7 +12,8 @@ CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NET_IPV6_DAD=n
CONFIG_NET_NBUF_TX_COUNT=10
CONFIG_NET_NBUF_RX_COUNT=5
CONFIG_NET_NBUF_DATA_COUNT=10
CONFIG_NET_NBUF_RX_DATA_COUNT=5
CONFIG_NET_NBUF_TX_DATA_COUNT=5
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=6
CONFIG_NET_MAX_ROUTES=4
CONFIG_NET_MAX_NEXTHOPS=8

View file

@ -365,7 +365,7 @@ static bool net_test_send_na(struct net_if *iface,
buf = net_ipv6_create_raw(buf, net_if_get_ll_reserve(iface, dst),
addr, dst, iface, IPPROTO_ICMPV6);
frag = net_nbuf_get_reserve_data(0, K_FOREVER);
frag = net_nbuf_get_reserve_tx_data(0, K_FOREVER);
NET_ASSERT_INFO(frag, "Out of DATA buffers");

View file

@ -14,7 +14,8 @@ CONFIG_NET_IPV6_DAD=n
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=3
CONFIG_NET_NBUF_TX_COUNT=10
CONFIG_NET_NBUF_RX_COUNT=5
CONFIG_NET_NBUF_DATA_COUNT=10
CONFIG_NET_NBUF_RX_DATA_COUNT=10
CONFIG_NET_NBUF_TX_DATA_COUNT=10
CONFIG_NET_RPL=y
CONFIG_NET_RPL_MAX_DAG_PER_INSTANCE=2
CONFIG_NET_RPL_MAX_INSTANCES=3

View file

@ -9,7 +9,8 @@ CONFIG_NET_BUF=y
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_NET_NBUF_RX_COUNT=5
CONFIG_NET_NBUF_TX_COUNT=5
CONFIG_NET_NBUF_DATA_COUNT=10
CONFIG_NET_NBUF_RX_DATA_COUNT=5
CONFIG_NET_NBUF_TX_DATA_COUNT=5
CONFIG_NET_MAX_CONTEXTS=4
CONFIG_NET_LOG=y
CONFIG_SYS_LOG_SHOW_COLOR=y

View file

@ -326,7 +326,7 @@ static bool send_ipv6_tcp_msg(struct net_if *iface,
int ret;
buf = net_nbuf_get_reserve_tx(0, K_FOREVER);
frag = net_nbuf_get_reserve_data(0, K_FOREVER);
frag = net_nbuf_get_reserve_tx_data(0, K_FOREVER);
net_buf_frag_add(buf, frag);
net_nbuf_set_iface(buf, iface);
@ -374,7 +374,7 @@ static bool send_ipv4_tcp_msg(struct net_if *iface,
int ret;
buf = net_nbuf_get_reserve_tx(0, K_FOREVER);
frag = net_nbuf_get_reserve_data(0, K_FOREVER);
frag = net_nbuf_get_reserve_tx_data(0, K_FOREVER);
net_buf_frag_add(buf, frag);
net_nbuf_set_iface(buf, iface);

Some files were not shown because too many files have changed in this diff Show more