1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /* Copyright(c) 2007-2022 Intel Corporation */
3 #ifndef ADF_CFG_H_
4 #define ADF_CFG_H_
5
6 #include <linux/rwsem.h>
7 #include "adf_accel_devices.h"
8 #include "adf_cfg_common.h"
9 #include "adf_cfg_strings.h"
10
11 #define ADF_CFG_MAX_VAL 16
12
13 struct adf_cfg_key_val {
14 char key[ADF_CFG_MAX_KEY_LEN_IN_BYTES];
15 char val[ADF_CFG_MAX_VAL_LEN_IN_BYTES];
16 enum adf_cfg_val_type type;
17 struct list_head list;
18 };
19
20 struct adf_cfg_section {
21 char name[ADF_CFG_MAX_SECTION_LEN_IN_BYTES];
22 bool processed;
23 bool is_derived;
24 struct list_head list;
25 struct list_head param_head;
26 };
27
28 struct adf_cfg_device_data {
29 struct adf_cfg_device *dev;
30 struct list_head sec_list;
31 struct sysctl_oid *debug;
32 struct sx lock;
33 char cfg_services[ADF_CFG_MAX_VAL];
34 char cfg_mode[ADF_CFG_MAX_VAL];
35 u16 num_user_processes;
36 };
37
38 struct adf_cfg_depot_list {
39 struct list_head sec_list;
40 };
41
42 int adf_cfg_dev_add(struct adf_accel_dev *accel_dev);
43 void adf_cfg_dev_remove(struct adf_accel_dev *accel_dev);
44 int adf_cfg_depot_restore_all(struct adf_accel_dev *accel_dev,
45 struct adf_cfg_depot_list *dev_hp_cfg);
46 int adf_cfg_section_add(struct adf_accel_dev *accel_dev, const char *name);
47 void adf_cfg_del_all(struct adf_accel_dev *accel_dev);
48 void adf_cfg_depot_del_all(struct list_head *head);
49 int adf_cfg_add_key_value_param(struct adf_accel_dev *accel_dev,
50 const char *section_name,
51 const char *key,
52 const void *val,
53 enum adf_cfg_val_type type);
54 int adf_cfg_get_param_value(struct adf_accel_dev *accel_dev,
55 const char *section,
56 const char *name,
57 char *value);
58 int adf_cfg_save_section(struct adf_accel_dev *accel_dev,
59 const char *name,
60 struct adf_cfg_section *section);
61 int adf_cfg_depot_save_all(struct adf_accel_dev *accel_dev,
62 struct adf_cfg_depot_list *dev_hp_cfg);
63 struct adf_cfg_section *adf_cfg_sec_find(struct adf_accel_dev *accel_dev,
64 const char *sec_name);
65 int adf_cfg_derived_section_add(struct adf_accel_dev *accel_dev,
66 const char *name);
67 int adf_cfg_remove_key_param(struct adf_accel_dev *accel_dev,
68 const char *section_name,
69 const char *key);
70 int adf_cfg_setup_irq(struct adf_accel_dev *accel_dev);
71 void adf_cfg_set_asym_rings_mask(struct adf_accel_dev *accel_dev);
72 void adf_cfg_gen_dispatch_arbiter(struct adf_accel_dev *accel_dev,
73 const u32 *thrd_to_arb_map,
74 u32 *thrd_to_arb_map_gen,
75 u32 total_engines);
76 int adf_cfg_get_fw_image_type(struct adf_accel_dev *accel_dev,
77 enum adf_cfg_fw_image_type *fw_image_type);
78 int adf_cfg_get_services_enabled(struct adf_accel_dev *accel_dev,
79 u16 *ring_to_svc_map);
80 int adf_cfg_restore_section(struct adf_accel_dev *accel_dev,
81 struct adf_cfg_section *section);
82 void adf_cfg_keyval_del_all(struct list_head *head);
83
84 static inline int
adf_cy_inst_cross_banks(struct adf_accel_dev * accel_dev)85 adf_cy_inst_cross_banks(struct adf_accel_dev *accel_dev)
86 {
87 if (accel_dev->hw_device->num_rings_per_bank == 2)
88 return 1;
89 else
90 return 0;
91 }
92
93 #endif
94