1 /* SPDX-License-Identifier: BSD-3-Clause */ 2 /* Copyright(c) 2007-2022 Intel Corporation */ 3 #include "adf_cfg.h" 4 #include "cpa.h" 5 #include "icp_accel_devices.h" 6 #include "adf_common_drv.h" 7 #include "icp_adf_debug.h" 8 #include "icp_adf_init.h" 9 #include "lac_sal_ctrl.h" 10 11 extern struct mtx *adfDevicesLock; 12 13 static int 14 adf_module_load(void) 15 { 16 CpaStatus ret = CPA_STATUS_SUCCESS; 17 18 qatUtilsMutexInit(&adfDevicesLock); 19 ret = SalCtrl_AdfServicesRegister(); 20 if (ret != CPA_STATUS_SUCCESS) { 21 qatUtilsMutexDestroy(&adfDevicesLock); 22 return EFAULT; 23 } 24 25 return 0; 26 } 27 28 static int 29 adf_module_unload(void) 30 { 31 CpaStatus ret = CPA_STATUS_SUCCESS; 32 33 ret = SalCtrl_AdfServicesUnregister(); 34 if (ret != CPA_STATUS_SUCCESS) { 35 return EBUSY; 36 } 37 qatUtilsMutexDestroy(&adfDevicesLock); 38 39 return 0; 40 } 41 42 static int 43 adf_modevent(module_t mod, int type, void *arg) 44 { 45 int error; 46 47 switch (type) { 48 case MOD_LOAD: 49 error = adf_module_load(); 50 break; 51 case MOD_UNLOAD: 52 error = adf_module_unload(); 53 break; 54 default: 55 error = EOPNOTSUPP; 56 break; 57 } 58 59 return (error); 60 } 61 62 static moduledata_t adf_mod = { "qat_api", adf_modevent, 0 }; 63 64 DECLARE_MODULE(qat_api, adf_mod, SI_SUB_DRIVERS, SI_ORDER_SECOND); 65 MODULE_VERSION(qat_api, 1); 66 MODULE_DEPEND(qat_api, qat_common, 1, 1, 1); 67 MODULE_DEPEND(qat_api, linuxkpi, 1, 1, 1); 68