mm/iob: add iob_get_queue_size() helper
Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
parent
75bfa4584c
commit
ebf89ff63b
@ -165,6 +165,7 @@ Public Function Prototypes
|
||||
- :c:func:`iob_peek_queue()`
|
||||
- :c:func:`iob_free_queue()`
|
||||
- :c:func:`iob_free_queue_qentry()`
|
||||
- :c:func:`iob_get_queue_size()`
|
||||
- :c:func:`iob_copyin()`
|
||||
- :c:func:`iob_trycopyin()`
|
||||
- :c:func:`iob_copyout()`
|
||||
@ -242,6 +243,10 @@ Public Function Prototypes
|
||||
.. c:function:: void iob_free_queue_qentry(FAR struct iob_s *iob, \
|
||||
FAR struct iob_queue_s *iobq);
|
||||
|
||||
Queue helper for get the iob queue buffer size.
|
||||
|
||||
.. c:function:: unsigned int iob_get_queue_size(FAR struct iob_queue_s *queue);
|
||||
|
||||
Free an iob entire queue of I/O buffer chains.
|
||||
|
||||
.. c:function:: int iob_copyin(FAR struct iob_s *iob, FAR const uint8_t *src, \
|
||||
|
@ -439,6 +439,18 @@ void iob_free_queue_qentry(FAR struct iob_s *iob,
|
||||
enum iob_user_e producerid);
|
||||
#endif /* CONFIG_IOB_NCHAINS > 0 */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iob_get_queue_size
|
||||
*
|
||||
* Description:
|
||||
* Queue helper for get the iob queue buffer size.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if CONFIG_IOB_NCHAINS > 0
|
||||
unsigned int iob_get_queue_size(FAR struct iob_queue_s *queue);
|
||||
#endif /* CONFIG_IOB_NCHAINS > 0 */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iob_copyin
|
||||
*
|
||||
|
@ -28,6 +28,7 @@ CSRCS += iob_free_chain.c iob_free_qentry.c iob_free_queue.c
|
||||
CSRCS += iob_initialize.c iob_pack.c iob_peek_queue.c iob_remove_queue.c
|
||||
CSRCS += iob_statistics.c iob_trimhead.c iob_trimhead_queue.c iob_trimtail.c
|
||||
CSRCS += iob_navail.c iob_free_queue_qentry.c iob_tailroom.c
|
||||
CSRCS += iob_get_queue_size.c
|
||||
|
||||
ifeq ($(CONFIG_IOB_NOTIFIER),y)
|
||||
CSRCS += iob_notifier.c
|
||||
|
58
mm/iob/iob_get_queue_size.c
Normal file
58
mm/iob/iob_get_queue_size.c
Normal file
@ -0,0 +1,58 @@
|
||||
/****************************************************************************
|
||||
* mm/iob/iob_get_queue_size.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/mm/iob.h>
|
||||
#include "iob.h"
|
||||
|
||||
#if CONFIG_IOB_NCHAINS > 0
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iob_get_queue_size
|
||||
*
|
||||
* Description:
|
||||
* Queue helper for get the iob queue buffer size.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
unsigned int iob_get_queue_size(FAR struct iob_queue_s *queue)
|
||||
{
|
||||
FAR struct iob_qentry_s *iobq;
|
||||
unsigned int total = 0;
|
||||
FAR struct iob_s *iob;
|
||||
|
||||
for (iobq = queue->qh_head; iobq != NULL; iobq = iobq->qe_flink)
|
||||
{
|
||||
iob = iobq->qe_head;
|
||||
total += iob->io_pktlen;
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_IOB_NCHAINS > 0 */
|
Loading…
Reference in New Issue
Block a user