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