Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
memory.c File Reference
#include <linux/module.h>
#include <linux/i2o.h>
#include <linux/delay.h>
#include <linux/string.h>
#include <linux/slab.h>
#include "core.h"

Go to the source code of this file.

Functions

u16 i2o_sg_tablesize (struct i2o_controller *c, u16 body_size)
 
 EXPORT_SYMBOL_GPL (i2o_sg_tablesize)
 
dma_addr_t i2o_dma_map_single (struct i2o_controller *c, void *ptr, size_t size, enum dma_data_direction direction, u32 **sg_ptr)
 
 EXPORT_SYMBOL_GPL (i2o_dma_map_single)
 
int i2o_dma_map_sg (struct i2o_controller *c, struct scatterlist *sg, int sg_count, enum dma_data_direction direction, u32 **sg_ptr)
 
 EXPORT_SYMBOL_GPL (i2o_dma_map_sg)
 
int i2o_dma_alloc (struct device *dev, struct i2o_dma *addr, size_t len)
 
 EXPORT_SYMBOL_GPL (i2o_dma_alloc)
 
void i2o_dma_free (struct device *dev, struct i2o_dma *addr)
 
 EXPORT_SYMBOL_GPL (i2o_dma_free)
 
int i2o_dma_realloc (struct device *dev, struct i2o_dma *addr, size_t len)
 
 EXPORT_SYMBOL_GPL (i2o_dma_realloc)
 
int i2o_pool_alloc (struct i2o_pool *pool, const char *name, size_t size, int min_nr)
 
 EXPORT_SYMBOL_GPL (i2o_pool_alloc)
 
void i2o_pool_free (struct i2o_pool *pool)
 
 EXPORT_SYMBOL_GPL (i2o_pool_free)
 

Function Documentation

EXPORT_SYMBOL_GPL ( i2o_sg_tablesize  )
EXPORT_SYMBOL_GPL ( i2o_dma_map_single  )
EXPORT_SYMBOL_GPL ( i2o_dma_map_sg  )
EXPORT_SYMBOL_GPL ( i2o_dma_alloc  )
EXPORT_SYMBOL_GPL ( i2o_dma_free  )
EXPORT_SYMBOL_GPL ( i2o_dma_realloc  )
EXPORT_SYMBOL_GPL ( i2o_pool_alloc  )
EXPORT_SYMBOL_GPL ( i2o_pool_free  )
int i2o_dma_alloc ( struct device dev,
struct i2o_dma addr,
size_t  len 
)

i2o_dma_alloc - Allocate DMA memory : struct device pointer to the PCI device of the I2O controller : i2o_dma struct which should get the DMA buffer : length of the new DMA memory

Allocate a coherent DMA memory and write the pointers into addr.

Returns 0 on success or -ENOMEM on failure.

Definition at line 182 of file memory.c.

void i2o_dma_free ( struct device dev,
struct i2o_dma addr 
)

i2o_dma_free - Free DMA memory : struct device pointer to the PCI device of the I2O controller : i2o_dma struct which contains the DMA buffer

Free a coherent DMA memory and set virtual address of addr to NULL.

Definition at line 221 of file memory.c.

int i2o_dma_map_sg ( struct i2o_controller c,
struct scatterlist sg,
int  sg_count,
enum dma_data_direction  direction,
u32 **  sg_ptr 
)

i2o_dma_map_sg - Map a SG List to controller and fill in I2O message. : I2O controller : SG list to be mapped : number of elements in the SG list : DMA_TO_DEVICE / DMA_FROM_DEVICE : pointer to the SG list inside the I2O message

This function does all necessary DMA handling and also writes the I2O SGL elements into the I2O message. For details on DMA handling see also dma_map_sg(). The pointer sg_ptr will only be set to the end of the SG list if the allocation was successful.

Returns 0 on failure or 1 on success.

Definition at line 127 of file memory.c.

dma_addr_t i2o_dma_map_single ( struct i2o_controller c,
void ptr,
size_t  size,
enum dma_data_direction  direction,
u32 **  sg_ptr 
)

i2o_dma_map_single - Map pointer to controller and fill in I2O message. : I2O controller : pointer to the data which should be mapped : size of data in bytes : DMA_TO_DEVICE / DMA_FROM_DEVICE : pointer to the SG list inside the I2O message

This function does all necessary DMA handling and also writes the I2O SGL elements into the I2O message. For details on DMA handling see also dma_map_single(). The pointer sg_ptr will only be set to the end of the SG list if the allocation was successful.

Returns DMA address which must be checked for failures using dma_mapping_error().

Definition at line 71 of file memory.c.

int i2o_dma_realloc ( struct device dev,
struct i2o_dma addr,
size_t  len 
)

i2o_dma_realloc - Realloc DMA memory : struct device pointer to the PCI device of the I2O controller : pointer to a i2o_dma struct DMA buffer : new length of memory

If there was something allocated in the addr, free it first. If len > 0 than try to allocate it and write the addresses back to the addr structure. If len == 0 set the virtual address to NULL.

Returns the 0 on success or negative error code on failure.

Definition at line 247 of file memory.c.

int i2o_pool_alloc ( struct i2o_pool pool,
const char name,
size_t  size,
int  min_nr 
)

Definition at line 270 of file memory.c.

void i2o_pool_free ( struct i2o_pool pool)

Definition at line 307 of file memory.c.

u16 i2o_sg_tablesize ( struct i2o_controller c,
u16  body_size 
)

i2o_sg_tablesize - Calculate the maximum number of elements in a SGL : I2O controller for which the calculation should be done : maximum body size used for message in 32-bit words.

Return the maximum number of SG elements in a SG list.

Definition at line 30 of file memory.c.