DPDK  18.11.11
rte_bbdev_op.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017 Intel Corporation
3  */
4 
5 #ifndef _RTE_BBDEV_OP_H_
6 #define _RTE_BBDEV_OP_H_
7 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 #include <stdint.h>
22 
23 #include <rte_common.h>
24 #include <rte_mbuf.h>
25 #include <rte_memory.h>
26 #include <rte_mempool.h>
27 
28 /* Number of columns in sub-block interleaver (36.212, section 5.1.4.1.1) */
29 #define RTE_BBDEV_C_SUBBLOCK (32)
30 /* Maximum size of Transport Block (36.213, Table, Table 7.1.7.2.5-1) */
31 #define RTE_BBDEV_MAX_TB_SIZE (391656)
32 /* Maximum size of Code Block (36.212, Table 5.1.3-3) */
33 #define RTE_BBDEV_MAX_CB_SIZE (6144)
34 /* Minimum size of Code Block (36.212, Table 5.1.3-3) */
35 #define RTE_BBDEV_MIN_CB_SIZE (40)
36 /* Maximum size of circular buffer */
37 #define RTE_BBDEV_MAX_KW (18528)
38 /*
39  * Maximum number of Code Blocks in Transport Block. It is calculated based on
40  * maximum size of one Code Block and one Transport Block (considering CRC24A
41  * and CRC24B):
42  * (391656 + 24) / (6144 - 24) = 64
43  */
44 #define RTE_BBDEV_MAX_CODE_BLOCKS (64)
45 
103  RTE_BBDEV_TURBO_MAP_DEC = (1ULL << 14),
109  RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP = (1ULL << 16)
110 };
111 
125  RTE_BBDEV_TURBO_ENC_SCATTER_GATHER = (1ULL << 5)
126 };
127 
129 struct rte_bbdev_op_data {
159  struct rte_mbuf *data;
167  uint32_t offset;
180  uint32_t length;
181 };
182 
183 struct rte_bbdev_op_dec_cb_params {
189  uint16_t k;
193  uint32_t e;
194 };
195 
200  uint16_t k_neg;
204  uint16_t k_pos;
206  uint8_t c_neg;
208  uint8_t c;
210  uint8_t cab;
214  uint32_t ea;
218  uint32_t eb;
219 };
220 
249 struct rte_bbdev_op_turbo_dec {
251  struct rte_bbdev_op_data input;
255  struct rte_bbdev_op_data hard_output;
257  struct rte_bbdev_op_data soft_output;
258 
259  uint32_t op_flags;
260  uint8_t rv_index;
264  uint8_t iter_min:4;
268  uint8_t iter_max:4;
272  uint8_t iter_count;
274  uint8_t ext_scale;
278  uint8_t num_maps;
279 
281  uint8_t code_block_mode;
282  union {
284  struct rte_bbdev_op_dec_cb_params cb_params;
286  struct rte_bbdev_op_dec_tb_params tb_params;
287  };
288 };
289 
290 struct rte_bbdev_op_enc_cb_params {
296  uint16_t k;
300  uint32_t e;
304  uint16_t ncb;
305 };
306 
313  uint16_t k_neg;
319  uint16_t k_pos;
321  uint8_t c_neg;
323  uint8_t c;
325  uint8_t cab;
329  uint32_t ea;
333  uint32_t eb;
337  uint16_t ncb_neg;
341  uint16_t ncb_pos;
343  uint8_t r;
344 };
345 
367  struct rte_bbdev_op_data input;
369  struct rte_bbdev_op_data output;
370 
371  uint32_t op_flags;
372  uint8_t rv_index;
374  uint8_t code_block_mode;
375  union {
377  struct rte_bbdev_op_enc_cb_params cb_params;
379  struct rte_bbdev_op_enc_tb_params tb_params;
380  };
381 };
382 
391  uint8_t num_buffers_src;
395  uint8_t num_buffers_soft_out;
396 };
397 
399 struct rte_bbdev_op_cap_turbo_enc {
401  uint32_t capability_flags;
402  uint8_t num_buffers_src;
403  uint8_t num_buffers_dst;
404 };
405 
412 };
413 
415 enum {
416  RTE_BBDEV_DRV_ERROR,
417  RTE_BBDEV_DATA_ERROR,
418  RTE_BBDEV_CRC_ERROR,
419 };
420 
424  int status;
428  void *opaque_data;
431 };
432 
435  int status;
437  void *opaque_data;
439  struct rte_bbdev_op_turbo_dec turbo_dec;
440 };
441 
443 struct rte_bbdev_op_cap {
444  enum rte_bbdev_op_type type;
445  union {
446  struct rte_bbdev_op_cap_turbo_dec turbo_dec;
447  struct rte_bbdev_op_cap_turbo_enc turbo_enc;
448  } cap;
449 };
450 
452 struct rte_bbdev_op_pool_private {
453  enum rte_bbdev_op_type type;
454 };
455 
466 const char*
468 
489 struct rte_mempool *
490 rte_bbdev_op_pool_create(const char *name, enum rte_bbdev_op_type type,
491  unsigned int num_elements, unsigned int cache_size,
492  int socket_id);
493 
508 static inline int
510  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
511 {
512  struct rte_bbdev_op_pool_private *priv;
513  int ret;
514 
515  /* Check type */
516  priv = (struct rte_bbdev_op_pool_private *)
517  rte_mempool_get_priv(mempool);
518  if (unlikely(priv->type != RTE_BBDEV_OP_TURBO_ENC))
519  return -EINVAL;
520 
521  /* Get elements */
522  ret = rte_mempool_get_bulk(mempool, (void **)ops, num_ops);
523  if (unlikely(ret < 0))
524  return ret;
525 
526  return 0;
527 }
528 
543 static inline int
545  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
546 {
547  struct rte_bbdev_op_pool_private *priv;
548  int ret;
549 
550  /* Check type */
551  priv = (struct rte_bbdev_op_pool_private *)
552  rte_mempool_get_priv(mempool);
553  if (unlikely(priv->type != RTE_BBDEV_OP_TURBO_DEC))
554  return -EINVAL;
555 
556  /* Get elements */
557  ret = rte_mempool_get_bulk(mempool, (void **)ops, num_ops);
558  if (unlikely(ret < 0))
559  return ret;
560 
561  return 0;
562 }
563 
574 static inline void
575 rte_bbdev_dec_op_free_bulk(struct rte_bbdev_dec_op **ops, unsigned int num_ops)
576 {
577  if (num_ops > 0)
578  rte_mempool_put_bulk(ops[0]->mempool, (void **)ops, num_ops);
579 }
580 
591 static inline void
592 rte_bbdev_enc_op_free_bulk(struct rte_bbdev_enc_op **ops, unsigned int num_ops)
593 {
594  if (num_ops > 0)
595  rte_mempool_put_bulk(ops[0]->mempool, (void **)ops, num_ops);
596 }
597 
598 #ifdef __cplusplus
599 }
600 #endif
601 
602 #endif /* _RTE_BBDEV_OP_H_ */
struct rte_bbdev_op_enc_cb_params cb_params
Definition: rte_bbdev_op.h:377
static __rte_always_inline void rte_mempool_put_bulk(struct rte_mempool *mp, void *const *obj_table, unsigned int n)
Definition: rte_mempool.h:1303
struct rte_mempool * rte_bbdev_op_pool_create(const char *name, enum rte_bbdev_op_type type, unsigned int num_elements, unsigned int cache_size, int socket_id)
rte_bbdev_op_type
Definition: rte_bbdev_op.h:407
rte_bbdev_op_td_flag_bitmasks
Definition: rte_bbdev_op.h:47
uint32_t cache_size
Definition: rte_mempool.h:230
#define unlikely(x)
struct rte_mempool * mempool
Definition: rte_bbdev_op.h:436
static __rte_always_inline int rte_mempool_get_bulk(struct rte_mempool *mp, void **obj_table, unsigned int n)
Definition: rte_mempool.h:1455
rte_bbdev_op_te_flag_bitmasks
Definition: rte_bbdev_op.h:113
static int rte_bbdev_dec_op_alloc_bulk(struct rte_mempool *mempool, struct rte_bbdev_dec_op **ops, uint16_t num_ops)
Definition: rte_bbdev_op.h:544
static int rte_bbdev_enc_op_alloc_bulk(struct rte_mempool *mempool, struct rte_bbdev_enc_op **ops, uint16_t num_ops)
Definition: rte_bbdev_op.h:509
struct rte_bbdev_op_turbo_enc turbo_enc
Definition: rte_bbdev_op.h:430
struct rte_mempool * mempool
Definition: rte_bbdev_op.h:426
const char * rte_bbdev_op_type_str(enum rte_bbdev_op_type op_type)
static void * rte_mempool_get_priv(struct rte_mempool *mp)
Definition: rte_mempool.h:1637
char name[RTE_MEMZONE_NAMESIZE]
Definition: rte_mempool.h:219
static void rte_bbdev_enc_op_free_bulk(struct rte_bbdev_enc_op **ops, unsigned int num_ops)
Definition: rte_bbdev_op.h:592
static void rte_bbdev_dec_op_free_bulk(struct rte_bbdev_dec_op **ops, unsigned int num_ops)
Definition: rte_bbdev_op.h:575
struct rte_bbdev_op_data input
Definition: rte_bbdev_op.h:367