linux/drivers/crypto/qat/qat_common/adf_common_drv.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) */
   2/* Copyright(c) 2014 - 2020 Intel Corporation */
   3#ifndef ADF_DRV_H
   4#define ADF_DRV_H
   5
   6#include <linux/list.h>
   7#include <linux/pci.h>
   8#include "adf_accel_devices.h"
   9#include "icp_qat_fw_loader_handle.h"
  10#include "icp_qat_hal.h"
  11
  12#define ADF_MAJOR_VERSION       0
  13#define ADF_MINOR_VERSION       6
  14#define ADF_BUILD_VERSION       0
  15#define ADF_DRV_VERSION         __stringify(ADF_MAJOR_VERSION) "." \
  16                                __stringify(ADF_MINOR_VERSION) "." \
  17                                __stringify(ADF_BUILD_VERSION)
  18
  19#define ADF_STATUS_RESTARTING 0
  20#define ADF_STATUS_STARTING 1
  21#define ADF_STATUS_CONFIGURED 2
  22#define ADF_STATUS_STARTED 3
  23#define ADF_STATUS_AE_INITIALISED 4
  24#define ADF_STATUS_AE_UCODE_LOADED 5
  25#define ADF_STATUS_AE_STARTED 6
  26#define ADF_STATUS_PF_RUNNING 7
  27#define ADF_STATUS_IRQ_ALLOCATED 8
  28
  29enum adf_dev_reset_mode {
  30        ADF_DEV_RESET_ASYNC = 0,
  31        ADF_DEV_RESET_SYNC
  32};
  33
  34enum adf_event {
  35        ADF_EVENT_INIT = 0,
  36        ADF_EVENT_START,
  37        ADF_EVENT_STOP,
  38        ADF_EVENT_SHUTDOWN,
  39        ADF_EVENT_RESTARTING,
  40        ADF_EVENT_RESTARTED,
  41};
  42
  43struct service_hndl {
  44        int (*event_hld)(struct adf_accel_dev *accel_dev,
  45                         enum adf_event event);
  46        unsigned long init_status[ADF_DEVS_ARRAY_SIZE];
  47        unsigned long start_status[ADF_DEVS_ARRAY_SIZE];
  48        char *name;
  49        struct list_head list;
  50};
  51
  52static inline int get_current_node(void)
  53{
  54        return topology_physical_package_id(raw_smp_processor_id());
  55}
  56
  57int adf_service_register(struct service_hndl *service);
  58int adf_service_unregister(struct service_hndl *service);
  59
  60int adf_dev_init(struct adf_accel_dev *accel_dev);
  61int adf_dev_start(struct adf_accel_dev *accel_dev);
  62void adf_dev_stop(struct adf_accel_dev *accel_dev);
  63void adf_dev_shutdown(struct adf_accel_dev *accel_dev);
  64
  65int adf_iov_putmsg(struct adf_accel_dev *accel_dev, u32 msg, u8 vf_nr);
  66void adf_pf2vf_notify_restarting(struct adf_accel_dev *accel_dev);
  67int adf_enable_vf2pf_comms(struct adf_accel_dev *accel_dev);
  68void adf_vf2pf_req_hndl(struct adf_accel_vf_info *vf_info);
  69void adf_devmgr_update_class_index(struct adf_hw_device_data *hw_data);
  70void adf_clean_vf_map(bool);
  71
  72int adf_ctl_dev_register(void);
  73void adf_ctl_dev_unregister(void);
  74int adf_processes_dev_register(void);
  75void adf_processes_dev_unregister(void);
  76
  77int adf_devmgr_add_dev(struct adf_accel_dev *accel_dev,
  78                       struct adf_accel_dev *pf);
  79void adf_devmgr_rm_dev(struct adf_accel_dev *accel_dev,
  80                       struct adf_accel_dev *pf);
  81struct list_head *adf_devmgr_get_head(void);
  82struct adf_accel_dev *adf_devmgr_get_dev_by_id(u32 id);
  83struct adf_accel_dev *adf_devmgr_get_first(void);
  84struct adf_accel_dev *adf_devmgr_pci_to_accel_dev(struct pci_dev *pci_dev);
  85int adf_devmgr_verify_id(u32 id);
  86void adf_devmgr_get_num_dev(u32 *num);
  87int adf_devmgr_in_reset(struct adf_accel_dev *accel_dev);
  88int adf_dev_started(struct adf_accel_dev *accel_dev);
  89int adf_dev_restarting_notify(struct adf_accel_dev *accel_dev);
  90int adf_dev_restarted_notify(struct adf_accel_dev *accel_dev);
  91int adf_ae_init(struct adf_accel_dev *accel_dev);
  92int adf_ae_shutdown(struct adf_accel_dev *accel_dev);
  93int adf_ae_fw_load(struct adf_accel_dev *accel_dev);
  94void adf_ae_fw_release(struct adf_accel_dev *accel_dev);
  95int adf_ae_start(struct adf_accel_dev *accel_dev);
  96int adf_ae_stop(struct adf_accel_dev *accel_dev);
  97
  98int adf_enable_aer(struct adf_accel_dev *accel_dev);
  99void adf_disable_aer(struct adf_accel_dev *accel_dev);
 100void adf_reset_sbr(struct adf_accel_dev *accel_dev);
 101void adf_reset_flr(struct adf_accel_dev *accel_dev);
 102void adf_dev_restore(struct adf_accel_dev *accel_dev);
 103int adf_init_aer(void);
 104void adf_exit_aer(void);
 105int adf_init_admin_comms(struct adf_accel_dev *accel_dev);
 106void adf_exit_admin_comms(struct adf_accel_dev *accel_dev);
 107int adf_send_admin_init(struct adf_accel_dev *accel_dev);
 108int adf_init_arb(struct adf_accel_dev *accel_dev);
 109void adf_exit_arb(struct adf_accel_dev *accel_dev);
 110void adf_update_ring_arb(struct adf_etr_ring_data *ring);
 111
 112int adf_dev_get(struct adf_accel_dev *accel_dev);
 113void adf_dev_put(struct adf_accel_dev *accel_dev);
 114int adf_dev_in_use(struct adf_accel_dev *accel_dev);
 115int adf_init_etr_data(struct adf_accel_dev *accel_dev);
 116void adf_cleanup_etr_data(struct adf_accel_dev *accel_dev);
 117int qat_crypto_register(void);
 118int qat_crypto_unregister(void);
 119int qat_crypto_dev_config(struct adf_accel_dev *accel_dev);
 120struct qat_crypto_instance *qat_crypto_get_instance_node(int node);
 121void qat_crypto_put_instance(struct qat_crypto_instance *inst);
 122void qat_alg_callback(void *resp);
 123void qat_alg_asym_callback(void *resp);
 124int qat_algs_register(void);
 125void qat_algs_unregister(void);
 126int qat_asym_algs_register(void);
 127void qat_asym_algs_unregister(void);
 128
 129int adf_isr_resource_alloc(struct adf_accel_dev *accel_dev);
 130void adf_isr_resource_free(struct adf_accel_dev *accel_dev);
 131int adf_vf_isr_resource_alloc(struct adf_accel_dev *accel_dev);
 132void adf_vf_isr_resource_free(struct adf_accel_dev *accel_dev);
 133
 134int qat_hal_init(struct adf_accel_dev *accel_dev);
 135void qat_hal_deinit(struct icp_qat_fw_loader_handle *handle);
 136int qat_hal_start(struct icp_qat_fw_loader_handle *handle);
 137void qat_hal_stop(struct icp_qat_fw_loader_handle *handle, unsigned char ae,
 138                  unsigned int ctx_mask);
 139void qat_hal_reset(struct icp_qat_fw_loader_handle *handle);
 140int qat_hal_clr_reset(struct icp_qat_fw_loader_handle *handle);
 141void qat_hal_set_live_ctx(struct icp_qat_fw_loader_handle *handle,
 142                          unsigned char ae, unsigned int ctx_mask);
 143int qat_hal_check_ae_active(struct icp_qat_fw_loader_handle *handle,
 144                            unsigned int ae);
 145int qat_hal_set_ae_lm_mode(struct icp_qat_fw_loader_handle *handle,
 146                           unsigned char ae, enum icp_qat_uof_regtype lm_type,
 147                           unsigned char mode);
 148int qat_hal_set_ae_ctx_mode(struct icp_qat_fw_loader_handle *handle,
 149                            unsigned char ae, unsigned char mode);
 150int qat_hal_set_ae_nn_mode(struct icp_qat_fw_loader_handle *handle,
 151                           unsigned char ae, unsigned char mode);
 152void qat_hal_set_pc(struct icp_qat_fw_loader_handle *handle,
 153                    unsigned char ae, unsigned int ctx_mask, unsigned int upc);
 154void qat_hal_wr_uwords(struct icp_qat_fw_loader_handle *handle,
 155                       unsigned char ae, unsigned int uaddr,
 156                       unsigned int words_num, u64 *uword);
 157void qat_hal_wr_umem(struct icp_qat_fw_loader_handle *handle, unsigned char ae,
 158                     unsigned int uword_addr, unsigned int words_num,
 159                     unsigned int *data);
 160int qat_hal_get_ins_num(void);
 161int qat_hal_batch_wr_lm(struct icp_qat_fw_loader_handle *handle,
 162                        unsigned char ae,
 163                        struct icp_qat_uof_batch_init *lm_init_header);
 164int qat_hal_init_gpr(struct icp_qat_fw_loader_handle *handle,
 165                     unsigned char ae, unsigned long ctx_mask,
 166                     enum icp_qat_uof_regtype reg_type,
 167                     unsigned short reg_num, unsigned int regdata);
 168int qat_hal_init_wr_xfer(struct icp_qat_fw_loader_handle *handle,
 169                         unsigned char ae, unsigned long ctx_mask,
 170                         enum icp_qat_uof_regtype reg_type,
 171                         unsigned short reg_num, unsigned int regdata);
 172int qat_hal_init_rd_xfer(struct icp_qat_fw_loader_handle *handle,
 173                         unsigned char ae, unsigned long ctx_mask,
 174                         enum icp_qat_uof_regtype reg_type,
 175                         unsigned short reg_num, unsigned int regdata);
 176int qat_hal_init_nn(struct icp_qat_fw_loader_handle *handle,
 177                    unsigned char ae, unsigned long ctx_mask,
 178                    unsigned short reg_num, unsigned int regdata);
 179int qat_hal_wr_lm(struct icp_qat_fw_loader_handle *handle,
 180                  unsigned char ae, unsigned short lm_addr, unsigned int value);
 181void qat_hal_set_ae_tindex_mode(struct icp_qat_fw_loader_handle *handle,
 182                                unsigned char ae, unsigned char mode);
 183int qat_uclo_wr_all_uimage(struct icp_qat_fw_loader_handle *handle);
 184void qat_uclo_del_obj(struct icp_qat_fw_loader_handle *handle);
 185int qat_uclo_wr_mimage(struct icp_qat_fw_loader_handle *handle, void *addr_ptr,
 186                       int mem_size);
 187int qat_uclo_map_obj(struct icp_qat_fw_loader_handle *handle,
 188                     void *addr_ptr, u32 mem_size, char *obj_name);
 189int qat_uclo_set_cfg_ae_mask(struct icp_qat_fw_loader_handle *handle,
 190                             unsigned int cfg_ae_mask);
 191#if defined(CONFIG_PCI_IOV)
 192int adf_sriov_configure(struct pci_dev *pdev, int numvfs);
 193void adf_disable_sriov(struct adf_accel_dev *accel_dev);
 194void adf_disable_vf2pf_interrupts(struct adf_accel_dev *accel_dev,
 195                                  u32 vf_mask);
 196void adf_enable_vf2pf_interrupts(struct adf_accel_dev *accel_dev,
 197                                 u32 vf_mask);
 198void adf_enable_pf2vf_interrupts(struct adf_accel_dev *accel_dev);
 199void adf_disable_pf2vf_interrupts(struct adf_accel_dev *accel_dev);
 200
 201int adf_vf2pf_init(struct adf_accel_dev *accel_dev);
 202void adf_vf2pf_shutdown(struct adf_accel_dev *accel_dev);
 203int adf_init_pf_wq(void);
 204void adf_exit_pf_wq(void);
 205int adf_init_vf_wq(void);
 206void adf_exit_vf_wq(void);
 207#else
 208static inline int adf_sriov_configure(struct pci_dev *pdev, int numvfs)
 209{
 210        return 0;
 211}
 212
 213static inline void adf_disable_sriov(struct adf_accel_dev *accel_dev)
 214{
 215}
 216
 217static inline void adf_enable_pf2vf_interrupts(struct adf_accel_dev *accel_dev)
 218{
 219}
 220
 221static inline void adf_disable_pf2vf_interrupts(struct adf_accel_dev *accel_dev)
 222{
 223}
 224
 225static inline int adf_vf2pf_init(struct adf_accel_dev *accel_dev)
 226{
 227        return 0;
 228}
 229
 230static inline void adf_vf2pf_shutdown(struct adf_accel_dev *accel_dev)
 231{
 232}
 233
 234static inline int adf_init_pf_wq(void)
 235{
 236        return 0;
 237}
 238
 239static inline void adf_exit_pf_wq(void)
 240{
 241}
 242
 243static inline int adf_init_vf_wq(void)
 244{
 245        return 0;
 246}
 247
 248static inline void adf_exit_vf_wq(void)
 249{
 250}
 251
 252#endif
 253#endif
 254