Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Enumerations | Functions
nx-842.c File Reference
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/nx842.h>
#include <linux/of.h>
#include <linux/slab.h>
#include <asm/page.h>
#include <asm/pSeries_reconfig.h>
#include <asm/vio.h>
#include "nx_csbcpb.h"

Go to the source code of this file.

Data Structures

struct  nx842_header
 
struct  ibm_nx842_counters
 
struct  nx842_devdata
 
struct  nx842_slentry
 
struct  nx842_scatterlist
 
struct  sw842_fifo
 
struct  nx842_workmem
 

Macros

#define MODULE_NAME   "nx-compress"
 
#define SHIFT_4K   12
 
#define SHIFT_64K   16
 
#define SIZE_4K   (1UL << SHIFT_4K)
 
#define SIZE_64K   (1UL << SHIFT_64K)
 
#define IO_BUFFER_ALIGN   128
 
#define NX842_CSBCBP_VALID_CHK(x)   (x & BIT_MASK(7))
 
#define NX842_CSBCPB_CE0(x)   (x & BIT_MASK(7))
 
#define NX842_CSBCPB_CE1(x)   (x & BIT_MASK(6))
 
#define NX842_CSBCPB_CE2(x)   (x & BIT_MASK(5))
 
#define NX842_HW_PAGE_SHIFT   SHIFT_4K
 
#define NX842_HW_PAGE_SIZE   (ASM_CONST(1) << NX842_HW_PAGE_SHIFT)
 
#define NX842_HW_PAGE_MASK   (~(NX842_HW_PAGE_SIZE-1))
 
#define NX842_COUNTER_INC(_x)
 
#define NX842_HIST_SLOTS   16
 
#define NX842_OP_COMPRESS   0x0
 
#define NX842_OP_CRC   0x1
 
#define NX842_OP_DECOMPRESS   0x2
 
#define NX842_OP_COMPRESS_CRC   (NX842_OP_COMPRESS | NX842_OP_CRC)
 
#define NX842_OP_DECOMPRESS_CRC   (NX842_OP_DECOMPRESS | NX842_OP_CRC)
 
#define NX842_OP_ASYNC   (1<<23)
 
#define NX842_OP_NOTIFY   (1<<22)
 
#define NX842_OP_NOTIFY_INT(x)   ((x & 0xff)<<8)
 
#define nx842_counter_read(_name)
 
#define NX842DEV_COUNTER_ATTR_RO(_name)
 
#define SW842_TMPL_REPEAT   0x1B
 
#define SW842_TMPL_ZEROS   0x1C
 
#define SW842_TMPL_EOF   0x1E
 

Typedefs

typedef int(* sw842_template_op )(const char **, int *, unsigned char **, struct sw842_fifo *)
 

Enumerations

enum  nx842_status { UNAVAILABLE, AVAILABLE }
 

Functions

 MODULE_LICENSE ("GPL")
 
 MODULE_AUTHOR ("Robert Jennings <[email protected]>")
 
 MODULE_DESCRIPTION ("842 H/W Compression driver for IBM Power processors")
 
 NX842_COUNTER_INC (comp_complete)
 
 NX842_COUNTER_INC (comp_failed)
 
 NX842_COUNTER_INC (decomp_complete)
 
 NX842_COUNTER_INC (decomp_failed)
 
 NX842_COUNTER_INC (swdecomp)
 
int nx842_get_workmem_size (void)
 
 EXPORT_SYMBOL_GPL (nx842_get_workmem_size)
 
int nx842_get_workmem_size_aligned (void)
 
 EXPORT_SYMBOL_GPL (nx842_get_workmem_size_aligned)
 
int nx842_compress (const unsigned char *in, unsigned int inlen, unsigned char *out, unsigned int *outlen, void *wmem)
 
 EXPORT_SYMBOL_GPL (nx842_compress)
 
int nx842_decompress (const unsigned char *in, unsigned int inlen, unsigned char *out, unsigned int *outlen, void *wmem)
 
 EXPORT_SYMBOL_GPL (nx842_decompress)
 
 NX842DEV_COUNTER_ATTR_RO (comp_complete)
 
 NX842DEV_COUNTER_ATTR_RO (comp_failed)
 
 NX842DEV_COUNTER_ATTR_RO (decomp_complete)
 
 NX842DEV_COUNTER_ATTR_RO (decomp_failed)
 
 NX842DEV_COUNTER_ATTR_RO (swdecomp)
 
 module_init (nx842_init)
 
 module_exit (nx842_exit)
 

Macro Definition Documentation

#define IO_BUFFER_ALIGN   128

Definition at line 47 of file nx-842.c.

#define MODULE_NAME   "nx-compress"

Definition at line 36 of file nx-842.c.

#define NX842_COUNTER_INC (   _x)
Value:
static inline void nx842_inc_##_x( \
const struct nx842_devdata *dev) { \
if (dev) \
atomic64_inc(&dev->counters->_x); \
}

Definition at line 104 of file nx-842.c.

#define nx842_counter_read (   _name)
Value:
static ssize_t nx842_##_name##_show(struct device *dev, \
char *buf) { \
struct nx842_devdata *local_devdata; \
int p = 0; \
rcu_read_lock(); \
local_devdata = rcu_dereference(devdata); \
if (local_devdata) \
p = snprintf(buf, PAGE_SIZE, "%ld\n", \
atomic64_read(&local_devdata->counters->_name)); \
rcu_read_unlock(); \
return p; \
}

Definition at line 1047 of file nx-842.c.

#define NX842_CSBCBP_VALID_CHK (   x)    (x & BIT_MASK(7))

Definition at line 63 of file nx-842.c.

#define NX842_CSBCPB_CE0 (   x)    (x & BIT_MASK(7))

Definition at line 69 of file nx-842.c.

#define NX842_CSBCPB_CE1 (   x)    (x & BIT_MASK(6))

Definition at line 70 of file nx-842.c.

#define NX842_CSBCPB_CE2 (   x)    (x & BIT_MASK(5))

Definition at line 71 of file nx-842.c.

#define NX842_HIST_SLOTS   16

Definition at line 116 of file nx-842.c.

#define NX842_HW_PAGE_MASK   (~(NX842_HW_PAGE_SIZE-1))

Definition at line 76 of file nx-842.c.

#define NX842_HW_PAGE_SHIFT   SHIFT_4K

Definition at line 74 of file nx-842.c.

#define NX842_HW_PAGE_SIZE   (ASM_CONST(1) << NX842_HW_PAGE_SHIFT)

Definition at line 75 of file nx-842.c.

#define NX842_OP_ASYNC   (1<<23)

Definition at line 134 of file nx-842.c.

#define NX842_OP_COMPRESS   0x0

Definition at line 129 of file nx-842.c.

#define NX842_OP_COMPRESS_CRC   (NX842_OP_COMPRESS | NX842_OP_CRC)

Definition at line 132 of file nx-842.c.

#define NX842_OP_CRC   0x1

Definition at line 130 of file nx-842.c.

#define NX842_OP_DECOMPRESS   0x2

Definition at line 131 of file nx-842.c.

#define NX842_OP_DECOMPRESS_CRC   (NX842_OP_DECOMPRESS | NX842_OP_CRC)

Definition at line 133 of file nx-842.c.

#define NX842_OP_NOTIFY   (1<<22)

Definition at line 135 of file nx-842.c.

#define NX842_OP_NOTIFY_INT (   x)    ((x & 0xff)<<8)

Definition at line 136 of file nx-842.c.

#define NX842DEV_COUNTER_ATTR_RO (   _name)
Value:
static struct device_attribute dev_attr_##_name = __ATTR(_name, \
0444, \
nx842_##_name##_show,\
NULL);

Definition at line 1062 of file nx-842.c.

#define SHIFT_4K   12

Definition at line 41 of file nx-842.c.

#define SHIFT_64K   16

Definition at line 42 of file nx-842.c.

#define SIZE_4K   (1UL << SHIFT_4K)

Definition at line 43 of file nx-842.c.

#define SIZE_64K   (1UL << SHIFT_64K)

Definition at line 44 of file nx-842.c.

#define SW842_TMPL_EOF   0x1E

Definition at line 1316 of file nx-842.c.

#define SW842_TMPL_REPEAT   0x1B

Definition at line 1314 of file nx-842.c.

#define SW842_TMPL_ZEROS   0x1C

Definition at line 1315 of file nx-842.c.

Typedef Documentation

typedef int(* sw842_template_op)(const char **, int *, unsigned char **, struct sw842_fifo *)

Definition at line 1297 of file nx-842.c.

Enumeration Type Documentation

Enumerator:
UNAVAILABLE 
AVAILABLE 

Definition at line 78 of file nx-842.c.

Function Documentation

EXPORT_SYMBOL_GPL ( nx842_get_workmem_size  )
EXPORT_SYMBOL_GPL ( nx842_get_workmem_size_aligned  )
EXPORT_SYMBOL_GPL ( nx842_compress  )
EXPORT_SYMBOL_GPL ( nx842_decompress  )
MODULE_AUTHOR ( "Robert Jennings <[email protected]>"  )
MODULE_DESCRIPTION ( "842 H/W Compression driver for IBM Power processors"  )
module_exit ( nx842_exit  )
module_init ( nx842_init  )
MODULE_LICENSE ( "GPL"  )
int nx842_compress ( const unsigned char in,
unsigned int  inlen,
unsigned char out,
unsigned int outlen,
void wmem 
)

nx842_compress - Compress data using the 842 algorithm

Compression provide by the NX842 coprocessor on IBM Power systems. The input buffer is compressed and the result is stored in the provided output buffer.

Upon return from this function contains the length of the compressed data. If there is an error then will be 0 and an error will be specified by the return code from this function.

: Pointer to input buffer, must be page aligned : Length of input buffer, must be PAGE_SIZE : Pointer to output buffer : Length of output buffer : ptr to buffer for working memory, size determined by nx842_get_workmem_size()

Returns: 0 Success, output of length stored in the buffer at -ENOMEM Unable to allocate internal buffers -ENOSPC Output buffer is to small -EMSGSIZE XXX Difficult to describe this limitation -EIO Internal error -ENODEV Hardware unavailable

Definition at line 320 of file nx-842.c.

NX842_COUNTER_INC ( comp_complete  )
NX842_COUNTER_INC ( comp_failed  )
NX842_COUNTER_INC ( decomp_complete  )
NX842_COUNTER_INC ( decomp_failed  )
NX842_COUNTER_INC ( swdecomp  )
int nx842_decompress ( const unsigned char in,
unsigned int  inlen,
unsigned char out,
unsigned int outlen,
void wmem 
)

nx842_decompress - Decompress data using the 842 algorithm

Decompression provide by the NX842 coprocessor on IBM Power systems. The input buffer is decompressed and the result is stored in the provided output buffer. The size allocated to the output buffer is provided by the caller of this function in . Upon return from this function contains the length of the decompressed data. If there is an error then will be 0 and an error will be specified by the return code from this function.

: Pointer to input buffer, will use bounce buffer if not 128 byte aligned : Length of input buffer : Pointer to output buffer, must be page aligned : Length of output buffer, must be PAGE_SIZE : ptr to buffer for working memory, size determined by nx842_get_workmem_size()

Returns: 0 Success, output of length stored in the buffer at -ENODEV Hardware decompression device is unavailable -ENOMEM Unable to allocate internal buffers -ENOSPC Output buffer is to small -EINVAL Bad input data encountered when attempting decompress -EIO Internal error

Definition at line 520 of file nx-842.c.

int nx842_get_workmem_size ( void  )

Definition at line 231 of file nx-842.c.

int nx842_get_workmem_size_aligned ( void  )

Definition at line 237 of file nx-842.c.

NX842DEV_COUNTER_ATTR_RO ( comp_complete  )
NX842DEV_COUNTER_ATTR_RO ( comp_failed  )
NX842DEV_COUNTER_ATTR_RO ( decomp_complete  )
NX842DEV_COUNTER_ATTR_RO ( decomp_failed  )
NX842DEV_COUNTER_ATTR_RO ( swdecomp  )