mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 21:36:28 +08:00
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:
@@ -88,6 +88,8 @@
|
|||||||
# define IOB_QEMPTY(q) ((q)->qh_head == NULL)
|
# define IOB_QEMPTY(q) ((q)->qh_head == NULL)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define IOB_BUFSIZE(p) CONFIG_IOB_BUFSIZE
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Types
|
* Public Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
+3
-3
@@ -139,7 +139,7 @@ int iob_clone_partial(FAR struct iob_s *iob1, unsigned int len,
|
|||||||
|
|
||||||
while (iob2 != NULL)
|
while (iob2 != NULL)
|
||||||
{
|
{
|
||||||
avail2 = CONFIG_IOB_BUFSIZE - iob2->io_offset;
|
avail2 = IOB_BUFSIZE(iob2) - iob2->io_offset;
|
||||||
if ((int)(offset2 - avail2) < 0)
|
if ((int)(offset2 - avail2) < 0)
|
||||||
{
|
{
|
||||||
break;
|
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];
|
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
|
/* Copy the smaller of the two and update the srce and destination
|
||||||
* offsets.
|
* offsets.
|
||||||
@@ -218,7 +218,7 @@ int iob_clone_partial(FAR struct iob_s *iob1, unsigned int len,
|
|||||||
* transferred?
|
* transferred?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ((int)(offset2 + iob2->io_offset - CONFIG_IOB_BUFSIZE) >= 0 &&
|
if ((int)(offset2 + iob2->io_offset - IOB_BUFSIZE(iob2)) >= 0 &&
|
||||||
iob1 != NULL)
|
iob1 != NULL)
|
||||||
{
|
{
|
||||||
ret = iob_next(iob2, throttled, block);
|
ret = iob_next(iob2, throttled, block);
|
||||||
|
|||||||
+1
-1
@@ -57,7 +57,7 @@ int iob_contig(FAR struct iob_s *iob, unsigned int len)
|
|||||||
* then you will need to increase CONFIG_IOB_BUFSIZE.
|
* 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
|
/* Check if there is already sufficient, contiguous space at the beginning
|
||||||
* of the packet
|
* of the packet
|
||||||
|
|||||||
+1
-1
@@ -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. */
|
/* 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,
|
/* This is the new buffer length that we need. Of course,
|
||||||
* clipped to the maximum possible size in this buffer.
|
* clipped to the maximum possible size in this buffer.
|
||||||
|
|||||||
+1
-1
@@ -86,7 +86,7 @@ FAR struct iob_s *iob_pack(FAR struct iob_s *iob)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
ncopy = next->io_len;
|
ncopy = next->io_len;
|
||||||
navail = CONFIG_IOB_BUFSIZE - iob->io_len;
|
navail = IOB_BUFSIZE(iob) - iob->io_len;
|
||||||
if (ncopy > navail)
|
if (ncopy > navail)
|
||||||
{
|
{
|
||||||
ncopy = navail;
|
ncopy = navail;
|
||||||
|
|||||||
@@ -49,9 +49,9 @@ void iob_reserve(FAR struct iob_s *iob, unsigned int reserved)
|
|||||||
|
|
||||||
while (iob != NULL && reserved > 0)
|
while (iob != NULL && reserved > 0)
|
||||||
{
|
{
|
||||||
if (reserved > CONFIG_IOB_BUFSIZE)
|
if (reserved > IOB_BUFSIZE(iob))
|
||||||
{
|
{
|
||||||
offset = CONFIG_IOB_BUFSIZE;
|
offset = IOB_BUFSIZE(iob);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -48,5 +48,5 @@ unsigned int iob_tailroom(FAR struct iob_s *iob)
|
|||||||
iob = iob->io_flink;
|
iob = iob->io_flink;
|
||||||
}
|
}
|
||||||
|
|
||||||
return CONFIG_IOB_BUFSIZE - (iob->io_offset + iob->io_len);
|
return IOB_BUFSIZE(iob) - (iob->io_offset + iob->io_len);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,8 +74,7 @@ int iob_update_pktlen(FAR struct iob_s *iob, unsigned int pktlen,
|
|||||||
|
|
||||||
/* Trim inqueue entries if needed */
|
/* Trim inqueue entries if needed */
|
||||||
|
|
||||||
nrequire = (pktlen + offset + CONFIG_IOB_BUFSIZE - 1) /
|
nrequire = (pktlen + offset + IOB_BUFSIZE(iob) - 1) / IOB_BUFSIZE(iob);
|
||||||
CONFIG_IOB_BUFSIZE;
|
|
||||||
if (nrequire == 0)
|
if (nrequire == 0)
|
||||||
{
|
{
|
||||||
nrequire = 1;
|
nrequire = 1;
|
||||||
@@ -130,9 +129,9 @@ int iob_update_pktlen(FAR struct iob_s *iob, unsigned int pktlen,
|
|||||||
next = iob;
|
next = iob;
|
||||||
while (next != NULL && pktlen > 0)
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user