DPDK  18.05.1
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 
280  uint8_t code_block_mode;
281  union {
283  struct rte_bbdev_op_dec_cb_params cb_params;
285  struct rte_bbdev_op_dec_tb_params tb_params;
286  };
287 };
288 
289 struct rte_bbdev_op_enc_cb_params {
295  uint16_t k;
299  uint32_t e;
303  uint16_t ncb;
304 };
305 
312  uint16_t k_neg;
318  uint16_t k_pos;
320  uint8_t c_neg;
322  uint8_t c;
324  uint8_t cab;
328  uint32_t ea;
332  uint32_t eb;
336  uint16_t ncb_neg;
340  uint16_t ncb_pos;
342  uint8_t r;
343 };
344 
366  struct rte_bbdev_op_data input;
368  struct rte_bbdev_op_data output;
369 
370  uint32_t op_flags;
371  uint8_t rv_index;
373  uint8_t code_block_mode;
374  union {
376  struct rte_bbdev_op_enc_cb_params cb_params;
378  struct rte_bbdev_op_enc_tb_params tb_params;
379  };
380 };
381 
390  uint8_t num_buffers_src;
392  uint8_t num_buffers_hard_out;
394  uint8_t num_buffers_soft_out;
395 };
396 
398 struct rte_bbdev_op_cap_turbo_enc {
400  uint32_t capability_flags;
401  uint8_t num_buffers_src;
402  uint8_t num_buffers_dst;
403 };
404 
411 };
412 
414 enum {
415  RTE_BBDEV_DRV_ERROR,
416  RTE_BBDEV_DATA_ERROR,
417  RTE_BBDEV_CRC_ERROR,
418 };
419 
422  int status;
424  void *opaque_data;
426  struct rte_bbdev_op_turbo_enc turbo_enc;
427 };
428 
431  int status;
433  void *opaque_data;
435  struct rte_bbdev_op_turbo_dec turbo_dec;
436 };
437 
439 struct rte_bbdev_op_cap {
440  enum rte_bbdev_op_type type;
441  union {
442  struct rte_bbdev_op_cap_turbo_dec turbo_dec;
443  struct rte_bbdev_op_cap_turbo_enc turbo_enc;
444  } cap;
445 };
446 
448 struct rte_bbdev_op_pool_private {
449  enum rte_bbdev_op_type type;
450 };
451 
462 const char*
464 
485 struct rte_mempool *
486 rte_bbdev_op_pool_create(const char *name, enum rte_bbdev_op_type type,
487  unsigned int num_elements, unsigned int cache_size,
488  int socket_id);
489 
504 static inline int
506  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
507 {
508  struct rte_bbdev_op_pool_private *priv;
509  int ret;
510 
511  /* Check type */
512  priv = (struct rte_bbdev_op_pool_private *)
513  rte_mempool_get_priv(mempool);
514  if (unlikely(priv->type != RTE_BBDEV_OP_TURBO_ENC))
515  return -EINVAL;
516 
517  /* Get elements */
518  ret = rte_mempool_get_bulk(mempool, (void **)ops, num_ops);
519  if (unlikely(ret < 0))
520  return ret;
521 
522  return 0;
523 }
524 
539 static inline int
541  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
542 {
543  struct rte_bbdev_op_pool_private *priv;
544  int ret;
545 
546  /* Check type */
547  priv = (struct rte_bbdev_op_pool_private *)
548  rte_mempool_get_priv(mempool);
549  if (unlikely(priv->type != RTE_BBDEV_OP_TURBO_DEC))
550  return -EINVAL;
551 
552  /* Get elements */
553  ret = rte_mempool_get_bulk(mempool, (void **)ops, num_ops);
554  if (unlikely(ret < 0))
555  return ret;
556 
557  return 0;
558 }
559 
570 static inline void
571 rte_bbdev_dec_op_free_bulk(struct rte_bbdev_dec_op **ops, unsigned int num_ops)
572 {
573  if (num_ops > 0)
574  rte_mempool_put_bulk(ops[0]->mempool, (void **)ops, num_ops);
575 }
576 
587 static inline void
588 rte_bbdev_enc_op_free_bulk(struct rte_bbdev_enc_op **ops, unsigned int num_ops)
589 {
590  if (num_ops > 0)
591  rte_mempool_put_bulk(ops[0]->mempool, (void **)ops, num_ops);
592 }
593 
594 #ifdef __cplusplus
595 }
596 #endif
597 
598 #endif /* _RTE_BBDEV_OP_H_ */