1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2020 Intel Corporation
3  */
4 
5 #ifndef _RTE_ACC100_CFG_H_
6 #define _RTE_ACC100_CFG_H_
7 
8 /**
9  * @file rte_acc100_cfg.h
10  *
11  * Functions for configuring ACC100 HW, exposed directly to applications.
12  * Configuration related to encoding/decoding is done through the
13  * librte_bbdev library.
14  *
15  * @warning
16  * @b EXPERIMENTAL: this API may change without prior notice
17  */
18 
19 #include <stdint.h>
20 #include <stdbool.h>
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 /**< Number of Virtual Functions ACC100 supports */
26 #define RTE_ACC100_NUM_VFS 16
27 
28 /**
29  * Definition of Queue Topology for ACC100 Configuration
30  * Some level of details is abstracted out to expose a clean interface
31  * given that comprehensive flexibility is not required
32  */
33 struct rte_acc100_queue_topology {
34 	/** Number of QGroups in incremental order of priority */
35 	uint16_t num_qgroups;
36 	/**
37 	 * All QGroups have the same number of AQs here.
38 	 * Note : Could be made a 16-array if more flexibility is really
39 	 * required
40 	 */
41 	uint16_t num_aqs_per_groups;
42 	/**
43 	 * Depth of the AQs is the same of all QGroups here. Log2 Enum : 2^N
44 	 * Note : Could be made a 16-array if more flexibility is really
45 	 * required
46 	 */
47 	uint16_t aq_depth_log2;
48 	/**
49 	 * Index of the first Queue Group Index - assuming contiguity
50 	 * Initialized as -1
51 	 */
52 	int8_t first_qgroup_index;
53 };
54 
55 /**
56  * Definition of Arbitration related parameters for ACC100 Configuration
57  */
58 struct rte_acc100_arbitration {
59 	/** Default Weight for VF Fairness Arbitration */
60 	uint16_t round_robin_weight;
61 	uint32_t gbr_threshold1; /**< Guaranteed Bitrate Threshold 1 */
62 	uint32_t gbr_threshold2; /**< Guaranteed Bitrate Threshold 2 */
63 };
64 
65 /**
66  * Structure to pass ACC100 configuration.
67  * Note: all VF Bundles will have the same configuration.
68  */
69 struct rte_acc100_conf {
70 	bool pf_mode_en; /**< 1 if PF is used for dataplane, 0 for VFs */
71 	/** 1 if input '1' bit is represented by a positive LLR value, 0 if '1'
72 	 * bit is represented by a negative value.
73 	 */
74 	bool input_pos_llr_1_bit;
75 	/** 1 if output '1' bit is represented by a positive value, 0 if '1'
76 	 * bit is represented by a negative value.
77 	 */
78 	bool output_pos_llr_1_bit;
79 	uint16_t num_vf_bundles; /**< Number of VF bundles to setup */
80 	/** Queue topology for each operation type */
81 	struct rte_acc100_queue_topology q_ul_4g;
82 	struct rte_acc100_queue_topology q_dl_4g;
83 	struct rte_acc100_queue_topology q_ul_5g;
84 	struct rte_acc100_queue_topology q_dl_5g;
85 	/** Arbitration configuration for each operation type */
86 	struct rte_acc100_arbitration arb_ul_4g[RTE_ACC100_NUM_VFS];
87 	struct rte_acc100_arbitration arb_dl_4g[RTE_ACC100_NUM_VFS];
88 	struct rte_acc100_arbitration arb_ul_5g[RTE_ACC100_NUM_VFS];
89 	struct rte_acc100_arbitration arb_dl_5g[RTE_ACC100_NUM_VFS];
90 };
91 
92 /**
93  * Configure a ACC100 device
94  *
95  * @param dev_name
96  *   The name of the device. This is the short form of PCI BDF, e.g. 00:01.0.
97  *   It can also be retrieved for a bbdev device from the dev_name field in the
98  *   rte_bbdev_info structure returned by rte_bbdev_info_get().
99  * @param conf
100  *   Configuration to apply to ACC100 HW.
101  *
102  * @return
103  *   Zero on success, negative value on failure.
104  */
105 __rte_experimental
106 int
107 rte_acc100_configure(const char *dev_name, struct rte_acc100_conf *conf);
108 
109 #ifdef __cplusplus
110 }
111 #endif
112 
113 #endif /* _RTE_ACC100_CFG_H_ */
114