1 /* SPDX-License-Identifier: BSD-3-Clause */ 2 /* Copyright(c) 2007-2022 Intel Corporation */ 3 /* $FreeBSD$ */ 4 #include "qat_utils.h" 5 #include <sys/sx.h> 6 7 CpaStatus 8 qatUtilsLockInit(struct mtx *pLock) 9 { 10 if (!pLock) 11 return CPA_STATUS_FAIL; 12 memset(pLock, 0, sizeof(*pLock)); 13 mtx_init(pLock, "qat spin", NULL, MTX_DEF | MTX_DUPOK); 14 15 return CPA_STATUS_SUCCESS; 16 } 17 18 CpaStatus 19 qatUtilsLock(struct mtx *pLock) 20 { 21 if (!pLock) 22 return CPA_STATUS_FAIL; 23 mtx_lock(pLock); 24 25 return CPA_STATUS_SUCCESS; 26 } 27 28 CpaStatus 29 qatUtilsUnlock(struct mtx *pLock) 30 { 31 if (!pLock) 32 return CPA_STATUS_FAIL; 33 mtx_unlock(pLock); 34 35 return CPA_STATUS_SUCCESS; 36 } 37 38 CpaStatus 39 qatUtilsLockDestroy(struct mtx *pLock) 40 { 41 if (!pLock) 42 return CPA_STATUS_FAIL; 43 mtx_destroy(pLock); 44 return CPA_STATUS_SUCCESS; 45 } 46