Linux Kernel
3.7.1
|
#include <linux/kernel.h>
#include <linux/spinlock.h>
#include <linux/stddef.h>
#include <linux/scatterlist.h>
Go to the source code of this file.
Data Structures | |
struct | __kfifo |
#define __STRUCT_KFIFO_COMMON | ( | datatype, | |
recsize, | |||
ptrtype | |||
) |
#define __STRUCT_KFIFO_PTR | ( | type, | |
recsize, | |||
ptrtype | |||
) |
#define DECLARE_KFIFO_PTR | ( | fifo, | |
type | |||
) | STRUCT_KFIFO_PTR(type) fifo |
DEFINE_KFIFO - macro to define and initialize a fifo : name of the declared fifo datatype : type of the fifo elements : the number of elements in the fifo, this must be a power of 2
Note: the macro can be used for global and local fifo data type variables.
#define INIT_KFIFO | ( | fifo | ) |
kfifo_alloc - dynamically allocates a new fifo buffer : pointer to the fifo : the number of elements in the fifo, this must be a power of 2 : get_free_pages mask, passed to kmalloc()
This macro dynamically allocates a new fifo buffer.
The numer of elements will be rounded-up to a power of 2. The fifo will be release with kfifo_free(). Return 0 if no error, otherwise an error code.
#define kfifo_avail | ( | fifo | ) |
kfifo_avail - returns the number of unused elements in the fifo : address of the fifo to be used
kfifo_dma_in_finish - finish a DMA IN operation : address of the fifo to be used : number of bytes to received
This macro finish a DMA IN operation. The in counter will be updated by the len parameter. No error checking will be done.
Note that with only one concurrent reader and one concurrent writer, you don't need extra locking to use these macros.
kfifo_dma_in_prepare - setup a scatterlist for DMA input : address of the fifo to be used : pointer to the scatterlist array : number of entries in the scatterlist array : number of elements to transfer
This macro fills a scatterlist for DMA input. It returns the number entries in the scatterlist array.
Note that with only one concurrent reader and one concurrent writer, you don't need extra locking to use these macros.
kfifo_dma_out_finish - finish a DMA OUT operation : address of the fifo to be used : number of bytes transferd
This macro finish a DMA OUT operation. The out counter will be updated by the len parameter. No error checking will be done.
Note that with only one concurrent reader and one concurrent writer, you don't need extra locking to use these macros.
kfifo_dma_out_prepare - setup a scatterlist for DMA output : address of the fifo to be used : pointer to the scatterlist array : number of entries in the scatterlist array : number of elements to transfer
This macro fills a scatterlist for DMA output which at most bytes to transfer. It returns the number entries in the scatterlist array. A zero means there is no space available and the scatterlist is not filled.
Note that with only one concurrent reader and one concurrent writer, you don't need extra locking to use these macros.
#define kfifo_free | ( | fifo | ) |
kfifo_from_user - puts some data from user space into the fifo : address of the fifo to be used : pointer to the data to be added : the length of the data to be added : pointer to output variable to store the number of copied bytes
This macro copies at most bytes from the into the fifo, depending of the available space and returns -EFAULT/0.
Note that with only one concurrent reader and one concurrent writer, you don't need extra locking to use these macro.
kfifo_get - get data from the fifo : address of the fifo to be used : the var where to store the data to be added
This macro reads the data from the fifo. It returns 0 if the fifo was empty. Otherwise it returns the number processed elements.
Note that with only one concurrent reader and one concurrent writer, you don't need extra locking to use these macro.
kfifo_in - put data into the fifo : address of the fifo to be used : the data to be added
: number of elements to be added
This macro copies the given buffer into the fifo and returns the number of copied elements.
Note that with only one concurrent reader and one concurrent writer, you don't need extra locking to use these macro.
kfifo_in_spinlocked - put data into the fifo using a spinlock for locking : address of the fifo to be used : the data to be added
: number of elements to be added : pointer to the spinlock to use for locking
This macro copies the given values buffer into the fifo and returns the number of copied elements.
kfifo_init - initialize a fifo using a preallocated buffer : the fifo to assign the buffer : the preallocated buffer to be used : the size of the internal buffer, this have to be a power of 2
This macro initialize a fifo using a preallocated buffer.
The numer of elements will be rounded-up to a power of 2. Return 0 if no error, otherwise an error code.
#define kfifo_initialized | ( | fifo | ) | ((fifo)->kfifo.mask) |
#define kfifo_is_empty | ( | fifo | ) |
#define kfifo_is_full | ( | fifo | ) |
#define kfifo_len | ( | fifo | ) |
kfifo_out - get data from the fifo : address of the fifo to be used : pointer to the storage buffer
: max. number of elements to get
This macro get some data from the fifo and return the numbers of elements copied.
Note that with only one concurrent reader and one concurrent writer, you don't need extra locking to use these macro.
kfifo_out_peek - gets some data from the fifo : address of the fifo to be used : pointer to the storage buffer
: max. number of elements to get
This macro get the data from the fifo and return the numbers of elements copied. The data is not removed from the fifo.
Note that with only one concurrent reader and one concurrent writer, you don't need extra locking to use these macro.
kfifo_out_spinlocked - get data from the fifo using a spinlock for locking : address of the fifo to be used : pointer to the storage buffer
: max. number of elements to get : pointer to the spinlock to use for locking
This macro get the data from the fifo and return the numbers of elements copied.
kfifo_peek - get data from the fifo without removing : address of the fifo to be used : the var where to store the data to be added
This reads the data from the fifo without removing it from the fifo. It returns 0 if the fifo was empty. Otherwise it returns the number processed elements.
Note that with only one concurrent reader and one concurrent writer, you don't need extra locking to use these macro.
#define kfifo_peek_len | ( | fifo | ) |
kfifo_put - put data into the fifo : address of the fifo to be used : the data to be added
This macro copies the given value into the fifo. It returns 0 if the fifo was full. Otherwise it returns the number processed elements.
Note that with only one concurrent reader and one concurrent writer, you don't need extra locking to use these macro.
#define kfifo_reset | ( | fifo | ) |
kfifo_reset - removes the entire fifo content : address of the fifo to be used
Note: usage of kfifo_reset() is dangerous. It should be only called when the fifo is exclusived locked or when it is secured that no other thread is accessing the fifo.
#define kfifo_reset_out | ( | fifo | ) |
kfifo_reset_out - skip fifo content : address of the fifo to be used
Note: The usage of kfifo_reset_out() is safe until it will be only called from the reader thread and there is only one concurrent reader. Otherwise it is dangerous and must be handled in the same way as kfifo_reset().
#define kfifo_size | ( | fifo | ) | ((fifo)->kfifo.mask + 1) |
#define kfifo_skip | ( | fifo | ) |
kfifo_to_user - copies data from the fifo into user space : address of the fifo to be used : where the data must be copied : the size of the destination buffer : pointer to output variable to store the number of copied bytes
This macro copies at most bytes from the fifo into the buffer and returns -EFAULT/0.
Note that with only one concurrent reader and one concurrent writer, you don't need extra locking to use these macro.
#define STRUCT_KFIFO_PTR | ( | type | ) | struct __STRUCT_KFIFO_PTR(type, 0, type) |