[dpdk-dev] [PATCH v4 4/5] compress/zlib: support burst enqueue/dequeue

De Lara Guarch, Pablo pablo.de.lara.guarch at intel.com
Tue Jul 24 00:25:14 CEST 2018



> -----Original Message-----
> From: Shally Verma [mailto:shally.verma at caviumnetworks.com]
> Sent: Monday, July 23, 2018 3:51 PM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch at intel.com>
> Cc: dev at dpdk.org; pathreya at caviumnetworks.com;
> mchalla at caviumnetworks.com; Sunila Sahu <ssahu at caviumnetworks.com>;
> Sunila Sahu <sunila.sahu at caviumnetworks.com>; Ashish Gupta
> <ashish.gupta at caviumnetworks.com>
> Subject: [PATCH v4 4/5] compress/zlib: support burst enqueue/dequeue
> 
> From: Sunila Sahu <ssahu at caviumnetworks.com>
> 
> Signed-off-by: Sunila Sahu <sunila.sahu at caviumnetworks.com>
> Signed-off-by: Shally Verma <shally.verma at caviumnetworks.com>
> Signed-off-by: Ashish Gupta <ashish.gupta at caviumnetworks.com>
> ---
>  drivers/compress/zlib/zlib_pmd.c | 255
> ++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 254 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/compress/zlib/zlib_pmd.c b/drivers/compress/zlib/zlib_pmd.c
> index 47bc73d..dc1e230 100644
> --- a/drivers/compress/zlib/zlib_pmd.c
> +++ b/drivers/compress/zlib/zlib_pmd.c
> @@ -7,7 +7,214 @@
> 
>  #include "zlib_pmd_private.h"
> 
> -/** Parse comp xform and set private xform/stream parameters */
> +/** Compute next mbuf in the list, assign data buffer and length,
> + *  returns 0 if mbuf is NULL
> + */
> +#define COMPUTE_BUF(mbuf, data, len)		\
> +		((mbuf = mbuf->next) ?		\
> +		(data = rte_pktmbuf_mtod(mbuf, uint8_t *)),	\
> +		(len = rte_pktmbuf_data_len(mbuf)) : 0)
> +
> +static void
> +process_zlib_deflate(struct rte_comp_op *op, z_stream *strm) {

...

> +	/* Update z_stream with the inputs provided by application */
> +	strm->next_in = rte_pktmbuf_mtod_offset(mbuf_src, uint8_t *,
> +			op->src.offset);

This is assuming that src buffer is a linear buffer or that offset won't be large enough to cross boundaries between segments.
If an SGL is passed and offset is bigger than the first segment, next_in should point at a different segment, with the remaining part of the offset in that segment
(look at ISA-L SGL patch: http://patches.dpdk.org/patch/43283/). Same applies to avail_in, next_out and avail_out.

> +
> +	strm->avail_in = rte_pktmbuf_data_len(mbuf_src) - op->src.offset;
> +
> +	strm->next_out = rte_pktmbuf_mtod_offset(mbuf_dst, uint8_t *,
> +			op->dst.offset);
> +
> +	strm->avail_out = rte_pktmbuf_data_len(mbuf_dst) - op->dst.offset;
> +

...

> +	strm->next_in = rte_pktmbuf_mtod_offset(mbuf_src, uint8_t *,
> +			op->src.offset);
> +
> +	strm->avail_in = rte_pktmbuf_data_len(mbuf_src) - op->src.offset;
> +
> +	strm->next_out = rte_pktmbuf_mtod_offset(mbuf_dst, uint8_t *,
> +			op->dst.offset);
> +
> +	strm->avail_out = rte_pktmbuf_data_len(mbuf_dst) - op->dst.offset;

Same comments as above (compression).

...

> +static inline int
> +process_zlib_op(struct zlib_qp *qp, struct rte_comp_op *op) {
> +	struct zlib_stream *stream;
> +	struct zlib_priv_xform *private_xform;
> +
> +	if ((op->op_type == RTE_COMP_OP_STATEFUL) ||
> +	    (op->src.offset > rte_pktmbuf_data_len(op->m_src)) ||
> +	    (op->dst.offset > rte_pktmbuf_data_len(op->m_dst))) {

Since m_src and m_dst could be SGLs, pkt_len should be checked, instead of data_len (which would be only for single segment).
Also, you should check the length too, in case of source buffers (src.offset + src.length > m_src->pkt_len).

Lastly, the two lines after the first if line should have double indentation to distinguish clearly against the body of the if.
If line is too long, consider storing the length of the buffers in variables.


> +		op->status = RTE_COMP_OP_STATUS_INVALID_ARGS;
> +		ZLIB_PMD_ERR("Invalid source or destination buffers or "
> +			     "invalid Operation requested\n");



More information about the dev mailing list