src/dpdk/drivers/compress/octeontx/otx_zip_pmd.c
static int
zip_set_stream_parameters(struct rte_compressdev *dev,
			const struct rte_comp_xform *xform,
			struct zip_stream *z_stream)
{
	int ret;
	union zip_inst_s *inst;
	struct zip_vf *vf = (struct zip_vf *)dev->data->dev_private;
	void *res;

	/* Allocate resources required by a stream */
	ret = rte_mempool_get_bulk(vf->zip_mp,
			z_stream->bufs, MAX_BUFS_PER_STREAM);
	if (ret < 0)
		return -1;

	/* get one command buffer from pool and set up */
	inst = (union zip_inst_s *)z_stream->bufs[CMD_BUF];
	res = z_stream->bufs[RES_BUF];

	memset(inst->u, 0, sizeof(inst->u));

	/* set bf for only first ops of stream */
	inst->s.bf = 1;

	if (xform->type == RTE_COMP_COMPRESS) {
		inst->s.op = ZIP_OP_E_COMP;

		switch (xform->compress.deflate.huffman) {
		case RTE_COMP_HUFFMAN_DEFAULT:
			inst->s.cc = ZIP_CC_DEFAULT;
			break;
		case RTE_COMP_HUFFMAN_FIXED:
			inst->s.cc = ZIP_CC_FIXED_HUFF;
			break;
		case RTE_COMP_HUFFMAN_DYNAMIC:
			inst->s.cc = ZIP_CC_DYN_HUFF;
			break;
		default:
			ret = -1;
			goto err;
		}

		switch (xform->compress.level) {
		case RTE_COMP_LEVEL_MIN:
			inst->s.ss = ZIP_COMP_E_LEVEL_MIN;
			break;
		case RTE_COMP_LEVEL_MAX:
			inst->s.ss = ZIP_COMP_E_LEVEL_MAX;
			break;
		case RTE_COMP_LEVEL_NONE:
			ZIP_PMD_ERR("Compression level not supported");
			ret = -1;
			goto err;
		default:
			/* for any value between min and max , choose
			 * PMD default.
			 */
			inst->s.ss = ZIP_COMP_E_LEVEL_MED; /** PMD default **/
			break;
		}
	} else if (xform->type == RTE_COMP_DECOMPRESS) {
		inst->s.op = ZIP_OP_E_DECOMP;
		/* from HRM,
		 * For DEFLATE decompression, [CC] must be 0x0.
		 * For decompression, [SS] must be 0x0
		 */
		inst->s.cc = 0;
		/* Speed bit should not be set for decompression */
		inst->s.ss = 0;
		/* decompression context is supported only for STATEFUL
		 * operations. Currently we support STATELESS ONLY so
		 * skip setting of ctx pointer
		 */

	} else {
		ZIP_PMD_ERR("\nxform type not supported");
		ret = -1;
		goto err;
	}

	inst->s.res_ptr_addr.s.addr = rte_mempool_virt2iova(res);
	inst->s.res_ptr_ctl.s.length = 0;

	z_stream->inst = inst;
	z_stream->func = zip_process_op;

	return 0;

err:
	rte_mempool_put_bulk(vf->zip_mp,
			     (void *)&(z_stream->bufs[0]),
			     MAX_BUFS_PER_STREAM);

	return ret;
}
/** Parse xform parameters and setup a stream */
Parse xform parameters and setup a stream
Parse xform parameters and setup a stream
static int
zip_set_stream_parameters(struct rte_compressdev *dev,
			const struct rte_comp_xform *xform,
			struct zip_stream *z_stream)
{
	int ret;
	union zip_inst_s *inst;
	struct zip_vf *vf = (struct zip_vf *)dev->data->dev_private;
	void *res;
	ret = rte_mempool_get_bulk(vf->zip_mp,
			z_stream->bufs, MAX_BUFS_PER_STREAM);
	if (ret < 0)
		return -1;
	inst = (union zip_inst_s *)z_stream->bufs[CMD_BUF];
	res = z_stream->bufs[RES_BUF];
	memset(inst->u, 0, sizeof(inst->u));
	inst->s.bf = 1;
	if (xform->type == RTE_COMP_COMPRESS) {
		inst->s.op = ZIP_OP_E_COMP;
		switch (xform->compress.deflate.huffman) {
		case RTE_COMP_HUFFMAN_DEFAULT:
			inst->s.cc = ZIP_CC_DEFAULT;
			break;
		case RTE_COMP_HUFFMAN_FIXED:
			inst->s.cc = ZIP_CC_FIXED_HUFF;
			break;
		case RTE_COMP_HUFFMAN_DYNAMIC:
			inst->s.cc = ZIP_CC_DYN_HUFF;
			break;
		default:
			ret = -1;
			goto err;
		}
		switch (xform->compress.level) {
		case RTE_COMP_LEVEL_MIN:
			inst->s.ss = ZIP_COMP_E_LEVEL_MIN;
			break;
		case RTE_COMP_LEVEL_MAX:
			inst->s.ss = ZIP_COMP_E_LEVEL_MAX;
			break;
		case RTE_COMP_LEVEL_NONE:
			ZIP_PMD_ERR("Compression level not supported");
			ret = -1;
			goto err;
		default:
			inst->s.ss = ZIP_COMP_E_LEVEL_MED; 
			break;
		}
	} else if (xform->type == RTE_COMP_DECOMPRESS) {
		inst->s.op = ZIP_OP_E_DECOMP;
		inst->s.cc = 0;
		inst->s.ss = 0;
	} else {
		ZIP_PMD_ERR("\nxform type not supported");
		ret = -1;
		goto err;
	}
	inst->s.res_ptr_addr.s.addr = rte_mempool_virt2iova(res);
	inst->s.res_ptr_ctl.s.length = 0;
	z_stream->inst = inst;
	z_stream->func = zip_process_op;
	return 0;
err:
	rte_mempool_put_bulk(vf->zip_mp,
			     (void *)&(z_stream->bufs[0]),
			     MAX_BUFS_PER_STREAM);
	return ret;
}
static int zip_set_stream_parameters ( struct rte_compressdev * dev , const struct rte_comp_xform * xform , struct zip_stream * z_stream ) { int ret ; union zip_inst_s * inst ; struct zip_vf * vf = ( struct zip_vf * ) dev -> data -> dev_private ; void * res ; ret = rte_mempool_get_bulk ( vf -> zip_mp , z_stream -> bufs , MAX_BUFS_PER_STREAM ) ; if ( ret < 0 ) return -1 ; inst = ( union zip_inst_s * ) z_stream -> bufs [ CMD_BUF ] ; res = z_stream -> bufs [ RES_BUF ] ; memset ( inst -> u , 0 , sizeof ( inst -> u ) ) ; inst -> s . bf = 1 ; if ( xform -> type == RTE_COMP_COMPRESS ) { inst -> s . op = ZIP_OP_E_COMP ; switch ( xform -> compress . deflate . huffman ) { case RTE_COMP_HUFFMAN_DEFAULT : inst -> s . cc = ZIP_CC_DEFAULT ; break ; case RTE_COMP_HUFFMAN_FIXED : inst -> s . cc = ZIP_CC_FIXED_HUFF ; break ; case RTE_COMP_HUFFMAN_DYNAMIC : inst -> s . cc = ZIP_CC_DYN_HUFF ; break ; default : ret = -1 ; goto err ; } switch ( xform -> compress . level ) { case RTE_COMP_LEVEL_MIN : inst -> s . ss = ZIP_COMP_E_LEVEL_MIN ; break ; case RTE_COMP_LEVEL_MAX : inst -> s . ss = ZIP_COMP_E_LEVEL_MAX ; break ; case RTE_COMP_LEVEL_NONE : ZIP_PMD_ERR ( " " ) ; ret = -1 ; goto err ; default : inst -> s . ss = ZIP_COMP_E_LEVEL_MED ; break ; } } else if ( xform -> type == RTE_COMP_DECOMPRESS ) { inst -> s . op = ZIP_OP_E_DECOMP ; inst -> s . cc = 0 ; inst -> s . ss = 0 ; } else { ZIP_PMD_ERR ( " \n " ) ; ret = -1 ; goto err ; } inst -> s . res_ptr_addr . s . addr = rte_mempool_virt2iova ( res ) ; inst -> s . res_ptr_ctl . s . length = 0 ; z_stream -> inst = inst ; z_stream -> func = zip_process_op ; return 0 ; err : rte_mempool_put_bulk ( vf -> zip_mp , ( void * ) & ( z_stream -> bufs [ 0 ] ) , MAX_BUFS_PER_STREAM ) ; return ret ; }
Parse xform parameters and setup a stream
Parse xform parameters and setup a stream
/* Allocate resources required by a stream */ /* get one command buffer from pool and set up */ /* set bf for only first ops of stream */ /* for any value between min and max , choose
			 * PMD default.
			 */ /** PMD default **/ /* from HRM,
		 * For DEFLATE decompression, [CC] must be 0x0.
		 * For decompression, [SS] must be 0x0
		 */ /* Speed bit should not be set for decompression */ /* decompression context is supported only for STATEFUL
		 * operations. Currently we support STATELESS ONLY so
		 * skip setting of ctx pointer
		 */