mm/iob: replace CONFIG_IOB_BUFSIZE to IOB_BUFSIZE(iob)

Variable length iob can be supported

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
zhanghongyu 2024-04-23 11:01:02 +08:00 committed by Xiang Xiao
parent a51ebeab4b
commit 00d208baf6
8 changed files with 14 additions and 13 deletions

View File

@ -88,6 +88,8 @@
# define IOB_QEMPTY(q) ((q)->qh_head == NULL)
#endif
#define IOB_BUFSIZE(p) CONFIG_IOB_BUFSIZE
/****************************************************************************
* Public Types
****************************************************************************/

View File

@ -139,7 +139,7 @@ int iob_clone_partial(FAR struct iob_s *iob1, unsigned int len,
while (iob2 != NULL)
{
avail2 = CONFIG_IOB_BUFSIZE - iob2->io_offset;
avail2 = IOB_BUFSIZE(iob2) - iob2->io_offset;
if ((int)(offset2 - avail2) < 0)
{
break;
@ -173,7 +173,7 @@ int iob_clone_partial(FAR struct iob_s *iob1, unsigned int len,
*/
dest = &iob2->io_data[iob2->io_offset + offset2];
avail2 = CONFIG_IOB_BUFSIZE - iob2->io_offset - offset2;
avail2 = IOB_BUFSIZE(iob2) - iob2->io_offset - offset2;
/* Copy the smaller of the two and update the srce and destination
* offsets.
@ -218,7 +218,7 @@ int iob_clone_partial(FAR struct iob_s *iob1, unsigned int len,
* transferred?
*/
if ((int)(offset2 + iob2->io_offset - CONFIG_IOB_BUFSIZE) >= 0 &&
if ((int)(offset2 + iob2->io_offset - IOB_BUFSIZE(iob2)) >= 0 &&
iob1 != NULL)
{
ret = iob_next(iob2, throttled, block);

View File

@ -57,7 +57,7 @@ int iob_contig(FAR struct iob_s *iob, unsigned int len)
* then you will need to increase CONFIG_IOB_BUFSIZE.
*/
DEBUGASSERT(len <= CONFIG_IOB_BUFSIZE);
DEBUGASSERT(len <= IOB_BUFSIZE(iob));
/* Check if there is already sufficient, contiguous space at the beginning
* of the packet

View File

@ -128,7 +128,7 @@ static int iob_copyin_internal(FAR struct iob_s *iob, FAR const uint8_t *src,
/* Yes.. We can extend this buffer to the up to the very end. */
maxlen = CONFIG_IOB_BUFSIZE - iob->io_offset;
maxlen = IOB_BUFSIZE(iob) - iob->io_offset;
/* This is the new buffer length that we need. Of course,
* clipped to the maximum possible size in this buffer.

View File

@ -86,7 +86,7 @@ FAR struct iob_s *iob_pack(FAR struct iob_s *iob)
*/
ncopy = next->io_len;
navail = CONFIG_IOB_BUFSIZE - iob->io_len;
navail = IOB_BUFSIZE(iob) - iob->io_len;
if (ncopy > navail)
{
ncopy = navail;

View File

@ -49,9 +49,9 @@ void iob_reserve(FAR struct iob_s *iob, unsigned int reserved)
while (iob != NULL && reserved > 0)
{
if (reserved > CONFIG_IOB_BUFSIZE)
if (reserved > IOB_BUFSIZE(iob))
{
offset = CONFIG_IOB_BUFSIZE;
offset = IOB_BUFSIZE(iob);
}
else
{

View File

@ -48,5 +48,5 @@ unsigned int iob_tailroom(FAR struct iob_s *iob)
iob = iob->io_flink;
}
return CONFIG_IOB_BUFSIZE - (iob->io_offset + iob->io_len);
return IOB_BUFSIZE(iob) - (iob->io_offset + iob->io_len);
}

View File

@ -74,8 +74,7 @@ int iob_update_pktlen(FAR struct iob_s *iob, unsigned int pktlen,
/* Trim inqueue entries if needed */
nrequire = (pktlen + offset + CONFIG_IOB_BUFSIZE - 1) /
CONFIG_IOB_BUFSIZE;
nrequire = (pktlen + offset + IOB_BUFSIZE(iob) - 1) / IOB_BUFSIZE(iob);
if (nrequire == 0)
{
nrequire = 1;
@ -130,9 +129,9 @@ int iob_update_pktlen(FAR struct iob_s *iob, unsigned int pktlen,
next = iob;
while (next != NULL && pktlen > 0)
{
if (pktlen + next->io_offset > CONFIG_IOB_BUFSIZE)
if (pktlen + next->io_offset > IOB_BUFSIZE(next))
{
len = CONFIG_IOB_BUFSIZE - next->io_offset;
len = IOB_BUFSIZE(next) - next->io_offset;
}
else
{