-
Notifications
You must be signed in to change notification settings - Fork 8.1k
net_buf: support large size #97440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
net_buf: support large size #97440
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,10 +95,10 @@ struct net_buf_simple { | |
* | ||
* To determine the max length, use net_buf_simple_max_len(), not #size! | ||
*/ | ||
uint16_t len; | ||
uint32_t len; | ||
|
||
/** Amount of data that net_buf_simple#__buf can store. */ | ||
uint16_t size; | ||
uint32_t size; | ||
|
||
/** Start of the data storage. Not to be accessed directly | ||
* (the data pointer should be used instead). | ||
|
@@ -938,7 +938,7 @@ size_t net_buf_simple_tailroom(const struct net_buf_simple *buf); | |
* | ||
* @return Number of bytes usable behind the net_buf_simple::data pointer. | ||
*/ | ||
uint16_t net_buf_simple_max_len(const struct net_buf_simple *buf); | ||
size_t net_buf_simple_max_len(const struct net_buf_simple *buf); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be in a separate commit, with the commit message explaining that it's just aligning this with the rest of the net_buf APIs. |
||
|
||
/** | ||
* @brief Parsing state of a buffer. | ||
|
@@ -949,9 +949,9 @@ uint16_t net_buf_simple_max_len(const struct net_buf_simple *buf); | |
*/ | ||
struct net_buf_simple_state { | ||
/** Offset of the data pointer from the beginning of the storage */ | ||
uint16_t offset; | ||
uint32_t offset; | ||
/** Length of data */ | ||
uint16_t len; | ||
uint32_t len; | ||
Comment on lines
-952
to
+954
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. This should be build-time conditional. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it, I will add back the
or
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Considering that you need to have the correct type in multiple structs and multiple member variables, I think the typedef would be the simplest option. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That said, I'd appreciate some more thoughts from @jfischer-no, since he seemed to be against this. @jfischer-no changing unconditionally to a larger size will not work without also finding a solution for our memory constrained platforms that can't currently take any additional memory hit wrt to net_buf sizes. |
||
}; | ||
|
||
/** | ||
|
@@ -965,7 +965,7 @@ struct net_buf_simple_state { | |
static inline void net_buf_simple_save(const struct net_buf_simple *buf, | ||
struct net_buf_simple_state *state) | ||
{ | ||
state->offset = (uint16_t)net_buf_simple_headroom(buf); | ||
state->offset = (uint32_t)net_buf_simple_headroom(buf); | ||
state->len = buf->len; | ||
} | ||
|
||
|
@@ -1032,10 +1032,10 @@ struct net_buf { | |
uint8_t *data; | ||
|
||
/** Length of the data behind the data pointer. */ | ||
uint16_t len; | ||
uint32_t len; | ||
|
||
/** Amount of data that this buffer can store. */ | ||
uint16_t size; | ||
uint32_t size; | ||
Comment on lines
-1035
to
+1038
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here. Initially I think we should make the larger size opt in. We can then discuss if eventually it'd be opt-out, and then we make the memory-constrained configurations explicitly select the smaller size. |
||
|
||
/** Start of the data storage. Not to be accessed | ||
* directly (the data pointer should be used | ||
|
@@ -1097,7 +1097,7 @@ struct net_buf_pool { | |
atomic_t avail_count; | ||
|
||
/** Total size of the pool. */ | ||
const uint16_t pool_size; | ||
const uint32_t pool_size; | ||
|
||
/** Maximum count of used buffers. */ | ||
uint16_t max_used; | ||
|
@@ -2523,7 +2523,7 @@ static inline size_t net_buf_headroom(const struct net_buf *buf) | |
* | ||
* @return Number of bytes usable behind the net_buf::data pointer. | ||
*/ | ||
static inline uint16_t net_buf_max_len(const struct net_buf *buf) | ||
static inline size_t net_buf_max_len(const struct net_buf *buf) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Separate commit. |
||
{ | ||
return net_buf_simple_max_len(&buf->b); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -620,7 +620,7 @@ size_t net_buf_simple_tailroom(const struct net_buf_simple *buf) | |
return buf->size - net_buf_simple_headroom(buf) - buf->len; | ||
} | ||
|
||
uint16_t net_buf_simple_max_len(const struct net_buf_simple *buf) | ||
size_t net_buf_simple_max_len(const struct net_buf_simple *buf) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Separate commit |
||
{ | ||
return buf->size - net_buf_simple_headroom(buf); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you misunderstood me a little bit. I wasn't proposing to change this unconditionally to
uint32_t
, rather you'd need some explicit enabling of the larger size, through Kconfig, like you had before. Otherwise you're causing memory overflows to platforms what are very constrained (we have at least some build configurations for 16k platforms where even just a few bytes increase in RAM consumption will cause the build to fail).