xref: /freebsd/sys/dev/qat/qat_common/adf_cfg_bundle.h (revision 71625ec9ad2a9bc8c09784fbd23b759830e0ee5f)
1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /* Copyright(c) 2007-2022 Intel Corporation */
3 #ifndef ADF_CFG_BUNDLE_H_
4 #define ADF_CFG_BUNDLE_H_
5 
6 #include "adf_accel_devices.h"
7 #include "adf_cfg_common.h"
8 
9 #define MAX_SECTIONS_PER_BUNDLE 8
10 #define MAX_SECTION_NAME_LEN 64
11 
12 #define TX 0x0
13 #define RX 0x1
14 
15 #define ASSIGN_SERV_TO_RINGS(bund, index, base, stype, rng_per_srv)            \
16 	do {                                                                   \
17 		int j = 0;                                                     \
18 		typeof(bund) b = (bund);                                       \
19 		typeof(index) i = (index);                                     \
20 		typeof(base) s = (base);                                       \
21 		typeof(stype) t = (stype);                                     \
22 		typeof(rng_per_srv) rps = (rng_per_srv);                       \
23 		for (j = 0; j < rps; j++) {                                    \
24 			b->rings[i + j]->serv_type = t;                        \
25 			b->rings[i + j + s]->serv_type = t;                    \
26 		}                                                              \
27 	} while (0)
28 
29 bool adf_cfg_is_free(struct adf_cfg_bundle *bundle);
30 
31 int adf_cfg_get_ring_pairs_from_bundle(struct adf_cfg_bundle *bundle,
32 				       struct adf_cfg_instance *inst,
33 				       const char *process_name,
34 				       struct adf_cfg_instance *bundle_inst);
35 
36 struct adf_cfg_instance *
37 adf_cfg_get_free_instance(struct adf_cfg_device *device,
38 			  struct adf_cfg_bundle *bundle,
39 			  struct adf_cfg_instance *inst,
40 			  const char *process_name);
41 
42 int adf_cfg_bundle_init(struct adf_cfg_bundle *bundle,
43 			struct adf_cfg_device *device,
44 			int bank_num,
45 			struct adf_accel_dev *accel_dev);
46 
47 void adf_cfg_bundle_clear(struct adf_cfg_bundle *bundle,
48 			  struct adf_accel_dev *accel_dev);
49 
50 void adf_cfg_init_ring2serv_mapping(struct adf_accel_dev *accel_dev,
51 				    struct adf_cfg_bundle *bundle,
52 				    struct adf_cfg_device *device);
53 
54 int adf_cfg_rel_ring2serv_mapping(struct adf_cfg_bundle *bundle);
55 
56 static inline void
adf_get_ring_svc_map_data(struct adf_hw_device_data * hw_data,int bundle_num,int ring_pair_index,u8 * serv_type,int * ring_index,int * num_rings_per_srv)57 adf_get_ring_svc_map_data(struct adf_hw_device_data *hw_data,
58 			  int bundle_num,
59 			  int ring_pair_index,
60 			  u8 *serv_type,
61 			  int *ring_index,
62 			  int *num_rings_per_srv)
63 {
64 	if (hw_data->get_ring_svc_map_data)
65 		return hw_data->get_ring_svc_map_data(ring_pair_index,
66 						      hw_data->ring_to_svc_map,
67 						      serv_type,
68 						      ring_index,
69 						      num_rings_per_srv,
70 						      bundle_num);
71 	*serv_type = GET_SRV_TYPE(hw_data->ring_to_svc_map, ring_pair_index);
72 	*num_rings_per_srv =
73 	    hw_data->num_rings_per_bank / (2 * ADF_CFG_NUM_SERVICES);
74 	*ring_index = (*num_rings_per_srv) * ring_pair_index;
75 }
76 #endif
77