鲲鹏社区首页
中文
注册
我要评分
文档获取效率
文档正确性
内容完整性
文档易理解
在线提单
论坛求助

COMP算法类相关接口

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
enum wcrypto_comp_flush_type {
WCRYPTO_INVALID_FLUSH,

/* output as much data as we can to improve performance */
WCRYPTO_NO_FLUSH,

/* output as bytes aligning or some other conditions satisfied */
WCRYPTO_SYNC_FLUSH,

/* indicates the end of the file/data */
WCRYPTO_FINISH,
};
enum wcrypto_comp_level {
WCRYPTO_COMP_L1 = 1,/* Compression level 1 */
WCRYPTO_COMP_L2,    /* Compression level 2 */
WCRYPTO_COMP_L3,    /* Compression level 3 */
WCRYPTO_COMP_L4, /* Compression level 4 */
WCRYPTO_COMP_L5, /* Compression level 5 */
WCRYPTO_COMP_L6, /* Compression level 6 */
WCRYPTO_COMP_L7, /* Compression level 7 */
WCRYPTO_COMP_L8, /* Compression level 8 */
WCRYPTO_COMP_L9 /* Compression level 9 */
};

enum wcrypto_comp_win_type {
WCRYPTO_COMP_WS_4K,/* 4k bytes window size */
WCRYPTO_COMP_WS_8K,/* 8k bytes window size */
WCRYPTO_COMP_WS_16K,/* 16k bytes window size */
WCRYPTO_COMP_WS_32K,/* 32k bytes window size */
};
/* Comp message format of Warpdrive */
struct wcrypto_comp_msg {
__u8 alg_type;/* Denoted by enum wcrypto_comp_alg_type */
__u8 op_type;/* Denoted by enum wcrypto_comp_op_type */
__u8 flush_type;/* indicates the output mode, from enum wcrypto_comp_flush_type */
__u8 stream_mode;/* Denoted by enum wcrypto_comp_state */
__u8 stream_pos;/* Denoted by enum wcrypto_stream_status */
__u8 comp_lv;/* Denoted by enum wcrypto_comp_level */
__u8 data_fmt;/* Data format, denoted by enum wd_buff_type */
__u8 win_sz;/* Denoted by enum wcrypto_comp_win_type */
__u32 in_size;    /* Input data bytes */
__u32 avail_out;/* Output buffer size */
__u32 in_cons;/* consumed bytes of input data */
__u32 produced;/* produced bytes of current operation */
__u8 *src;/* Input data VA, buf should be DMA-able. */
__u8 *dst;/* Output data VA pointer */
__u32 tag;       /* User-defined request identifier */
__u32 win_size;/* Denoted by enum wcrypto_comp_win_type */
__u32 status;/* Data format, denoted by WD error code and enum wcrypto_op_result */
__u32 isize;/* Denoted by gzip isize */
__u32 checksum;/* Denoted by zlib/gzip CRC */
__u32 ctx_priv0;/* Denoted HW priv */
__u32 ctx_priv1;/* Denoted HW priv */
__u32 ctx_priv2;/* Denoted HW priv */
void *ctx_buf;/* Denoted HW ctx cache */
__u64 udata;/* Input user tag, used for indentify data stream/user:struct wcrypto_cb_tag */
};

enum wcrypto_comp_alg_type {
WCRYPTO_ZLIB,
WCRYPTO_GZIP,
};

/* Compression operational types */
enum wcrypto_comp_op_type {
WCRYPTO_DEFLATE,/* Data Compression */
WCRYPTO_INFLATE, /* Data Decompression */
};

enum wcrypto_comp_state {
WCRYPTO_COMP_STATELESS,
WCRYPTO_COMP_STATEFUL,
};

enum wcrypto_stream_status {
WCRYPTO_COMP_STREAM_OLD,
WCRYPTO_COMP_STREAM_NEW,  /* indicates the first packet */
};

/* context setup parameters */
struct wcrypto_comp_ctx_setup {
wcrypto_cb cb;/* User call back */
__u8 alg_type; /* wcrypto_comp_alg_type */
__u8 op_type; /* wcrypto_comp_op_type */
__u8 stream_mode; /* wcrypto_comp_state */
__u8 comp_lv; /* compression level */
__u16 win_size; /* window size */
__u16 data_fmt;/* buffer format */
struct wd_mm_br br;  /* memory operations from user */
};

struct wcrypto_comp_op_data {
__u8 alg_type;/* Denoted by enum wcrypto_comp_alg_type */
__u8 flush; /* indicates from enum wcrypto_comp_flush_type */
__u8 stream_pos;  /* Denoted by enum wcrypto_stream_status */
__u8 status;/* Denoted by WD error code and enum wcrypto_op_result */
__u8 *in; /* Input VA, buffer should be DMA buffer. */
__u8 *out;/* Output data VA pointer, buffer should be DMA-able */
__u32 in_len;/* input data bytes */
__u32 avail_out; /* output buffer size */
__u32 consumed;  /* bytes consumed by the operation */
__u32 produced; /* bytes output by the operation */
__u32 isize;/* gzip isize */
__u32 checksum; /* Will be updated to the checksum of data produced by the operation */
void *priv;       /* private field for extend */
};

函数原型

void * wcrypto_create_comp_ctx (struct wd_queue *q, struct wcrypto_comp_ctx_setup *setup);

函数功能

基于Warpdrive queue创建COMP算法context

输入说明

q:warpdrive queue

setup:用户对于context的创建输入参数

输出说明

返回值说明

Context地址

NULL:失败

非NULL:成功

使用说明

支持多线程

注意事项

  

函数原型

int wcrypto_do_comp(void *ctx, struct wcrypto_comp_op_data *opdata, void *tag);

函数功能

基于COMP context的COMP算法操作

输入说明

ctx:COMP context

opdata:COMP操作参数,包括输入输出以及操作类型等

tag:用户回调表示,为NULL时,为同步接口,否则为异步接口

输出说明

返回值说明

0:成功

否则失败(错误码含义请参考WD消息错误码接口定义

使用说明

同一个ctx仅支持单线程

注意事项

  

函数原型

int wcrypto_comp_poll(struct wd_queue *q, unsigned int num);

函数功能

基于warpdrive queue的COMP算法poll操作

输入说明

q:Warpdrive COMP queue

num:0---表示将队列q中所有回应消息全部收上来,非0---表示将队列中num个回应消息收上来

输出说明

返回值说明

大于0:成功收到对应个数的回应消息

0:没有收到任何回应

负值:poll发生错误

使用说明

同一个q仅支持单线程

注意事项

  

函数原型

void wcrypto_del_comp_ctx (void *ctx);

函数功能

删除一个COMP的context

输入说明

ctx:需要删除的COMP context

输出说明

返回值说明

使用说明

  

注意事项