The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/qat/qat_api/qat_utils/include/qat_utils.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* SPDX-License-Identifier: BSD-3-Clause */
    2 /* Copyright(c) 2007-2022 Intel Corporation */
    3 /* $FreeBSD$ */
    4 #ifndef QAT_UTILS_H
    5 #define QAT_UTILS_H
    6 
    7 
    8 #include <sys/param.h>
    9 #include <sys/ctype.h>
   10 #include <sys/endian.h>
   11 #include <sys/lock.h>
   12 #include <sys/mutex.h>
   13 #include <sys/systm.h>
   14 #include <sys/types.h>
   15 #include <sys/sema.h>
   16 #include <sys/time.h>
   17 #include <sys/malloc.h>
   18 #include <sys/kernel.h>
   19 #include <sys/sysctl.h>
   20 #include <sys/limits.h>
   21 #include <sys/unistd.h>
   22 #include <sys/libkern.h>
   23 #ifdef __x86_64__
   24 #include <asm/atomic64.h>
   25 #else
   26 #include <asm/atomic.h>
   27 #endif
   28 #include <vm/vm.h>
   29 #include <vm/pmap.h>
   30 
   31 #include <sys/md5.h>
   32 #include <crypto/sha1.h>
   33 #include <crypto/sha2/sha256.h>
   34 #include <crypto/sha2/sha224.h>
   35 #include <crypto/sha2/sha384.h>
   36 #include <crypto/sha2/sha512.h>
   37 #include <crypto/rijndael/rijndael-api-fst.h>
   38 
   39 #include <opencrypto/cryptodev.h>
   40 
   41 #include "cpa.h"
   42 
   43 #define QAT_UTILS_LOG(...) printf("QAT: "__VA_ARGS__)
   44 
   45 #define QAT_UTILS_WAIT_FOREVER (-1)
   46 #define QAT_UTILS_WAIT_NONE 0
   47 
   48 #define QAT_UTILS_HOST_TO_NW_16(uData) QAT_UTILS_OS_HOST_TO_NW_16(uData)
   49 #define QAT_UTILS_HOST_TO_NW_32(uData) QAT_UTILS_OS_HOST_TO_NW_32(uData)
   50 #define QAT_UTILS_HOST_TO_NW_64(uData) QAT_UTILS_OS_HOST_TO_NW_64(uData)
   51 
   52 #define QAT_UTILS_NW_TO_HOST_16(uData) QAT_UTILS_OS_NW_TO_HOST_16(uData)
   53 #define QAT_UTILS_NW_TO_HOST_32(uData) QAT_UTILS_OS_NW_TO_HOST_32(uData)
   54 #define QAT_UTILS_NW_TO_HOST_64(uData) QAT_UTILS_OS_NW_TO_HOST_64(uData)
   55 
   56 #define QAT_UTILS_UDIV64_32(dividend, divisor)                                 \
   57         QAT_UTILS_OS_UDIV64_32(dividend, divisor)
   58 
   59 #define QAT_UTILS_UMOD64_32(dividend, divisor)                                 \
   60         QAT_UTILS_OS_UMOD64_32(dividend, divisor)
   61 
   62 #define ICP_CHECK_FOR_NULL_PARAM(param)                                        \
   63         do {                                                                   \
   64                 if (NULL == param) {                                           \
   65                         QAT_UTILS_LOG("%s(): invalid param: %s\n",             \
   66                                       __FUNCTION__,                            \
   67                                       #param);                                 \
   68                         return CPA_STATUS_INVALID_PARAM;                       \
   69                 }                                                              \
   70         } while (0)
   71 
   72 #define ICP_CHECK_FOR_NULL_PARAM_VOID(param)                                   \
   73         do {                                                                   \
   74                 if (NULL == param) {                                           \
   75                         QAT_UTILS_LOG("%s(): invalid param: %s\n",             \
   76                                       __FUNCTION__,                            \
   77                                       #param);                                 \
   78                         return;                                                \
   79                 }                                                              \
   80         } while (0)
   81 
   82 /*Macro for adding an element to the tail of a doubly linked list*/
   83 /*The currentptr tracks the tail, and the headptr tracks the head.*/
   84 #define ICP_ADD_ELEMENT_TO_END_OF_LIST(elementtoadd, currentptr, headptr)      \
   85         do {                                                                   \
   86                 if (NULL == currentptr) {                                      \
   87                         currentptr = elementtoadd;                             \
   88                         elementtoadd->pNext = NULL;                            \
   89                         elementtoadd->pPrev = NULL;                            \
   90                         headptr = currentptr;                                  \
   91                 } else {                                                       \
   92                         elementtoadd->pPrev = currentptr;                      \
   93                         currentptr->pNext = elementtoadd;                      \
   94                         elementtoadd->pNext = NULL;                            \
   95                         currentptr = elementtoadd;                             \
   96                 }                                                              \
   97         } while (0)
   98 
   99 /*currentptr is not used in this case since we don't track the tail. */
  100 #define ICP_ADD_ELEMENT_TO_HEAD_OF_LIST(elementtoadd, currentptr, headptr)     \
  101         do {                                                                   \
  102                 if (NULL == headptr) {                                         \
  103                         elementtoadd->pNext = NULL;                            \
  104                         elementtoadd->pPrev = NULL;                            \
  105                         headptr = elementtoadd;                                \
  106                 } else {                                                       \
  107                         elementtoadd->pPrev = NULL;                            \
  108                         elementtoadd->pNext = headptr;                         \
  109                         headptr->pPrev = elementtoadd;                         \
  110                         headptr = elementtoadd;                                \
  111                 }                                                              \
  112         } while (0)
  113 
  114 #define ICP_REMOVE_ELEMENT_FROM_LIST(elementtoremove, currentptr, headptr)     \
  115         do {                                                                   \
  116                 /*If the previous pointer is not NULL*/                        \
  117                 if (NULL != elementtoremove->pPrev) {                          \
  118                         elementtoremove->pPrev->pNext =                        \
  119                             elementtoremove->pNext;                            \
  120                         if (elementtoremove->pNext) {                          \
  121                                 elementtoremove->pNext->pPrev =                \
  122                                     elementtoremove->pPrev;                    \
  123                         } else {                                               \
  124                                 /* Move the tail pointer backwards */          \
  125                                 currentptr = elementtoremove->pPrev;           \
  126                         }                                                      \
  127                 } else if (NULL != elementtoremove->pNext) {                   \
  128                         /*Remove the head pointer.*/                           \
  129                         elementtoremove->pNext->pPrev = NULL;                  \
  130                         /*Hence move the head forward.*/                       \
  131                         headptr = elementtoremove->pNext;                      \
  132                 } else {                                                       \
  133                         /*Remove the final entry in the list. */               \
  134                         currentptr = NULL;                                     \
  135                         headptr = NULL;                                        \
  136                 }                                                              \
  137         } while (0)
  138 
  139 MALLOC_DECLARE(M_QAT);
  140 
  141 #ifdef __x86_64__
  142 typedef atomic64_t QatUtilsAtomic;
  143 #else
  144 typedef atomic_t QatUtilsAtomic;
  145 #endif
  146 
  147 #define QAT_UTILS_OS_NW_TO_HOST_16(uData) be16toh(uData)
  148 #define QAT_UTILS_OS_NW_TO_HOST_32(uData) be32toh(uData)
  149 #define QAT_UTILS_OS_NW_TO_HOST_64(uData) be64toh(uData)
  150 
  151 #define QAT_UTILS_OS_HOST_TO_NW_16(uData) htobe16(uData)
  152 #define QAT_UTILS_OS_HOST_TO_NW_32(uData) htobe32(uData)
  153 #define QAT_UTILS_OS_HOST_TO_NW_64(uData) htobe64(uData)
  154 
  155 /**
  156  * @ingroup QatUtils
  157  *
  158  * @brief Atomically read the value of atomic variable
  159  *
  160  * @param  pAtomicVar  IN   - atomic variable
  161  *
  162  * Atomically reads the value of pAtomicVar to the outValue
  163  *
  164  * @li Reentrant: yes
  165  * @li IRQ safe:  yes
  166  *
  167  * @return  pAtomicVar value
  168  */
  169 int64_t qatUtilsAtomicGet(QatUtilsAtomic *pAtomicVar);
  170 
  171 /**
  172  * @ingroup QatUtils
  173  *
  174  * @brief Atomically set the value of atomic variable
  175  *
  176  * @param  inValue    IN   -  atomic variable to be set equal to inValue
  177  *
  178  * @param  pAtomicVar  OUT  - atomic variable
  179  *
  180  * Atomically sets the value of pAtomicVar to the value given
  181  *
  182  * @li Reentrant: yes
  183  * @li IRQ safe:  yes
  184  *
  185  * @return none
  186  */
  187 void qatUtilsAtomicSet(int64_t inValue, QatUtilsAtomic *pAtomicVar);
  188 
  189 /**
  190  * @ingroup QatUtils
  191  *
  192  * @brief add the value to atomic variable
  193  *
  194  * @param  inValue (in)   -  value to be added to the atomic variable
  195  *
  196  * @param  pAtomicVar (in & out)   - atomic variable
  197  *
  198  * Atomically adds the value of inValue to the pAtomicVar
  199  *
  200  * @li Reentrant: yes
  201  * @li IRQ safe:  yes
  202  *
  203  * @return pAtomicVar value after the addition
  204  */
  205 int64_t qatUtilsAtomicAdd(int64_t inValue, QatUtilsAtomic *pAtomicVar);
  206 
  207 /**
  208  * @ingroup QatUtils
  209  *
  210  * @brief subtract the value from atomic variable
  211  *
  212  * @param  inValue   IN     -  atomic variable value to be subtracted by value
  213  *
  214  * @param  pAtomicVar IN/OUT - atomic variable
  215  *
  216  * Atomically subtracts the value of pAtomicVar by inValue
  217  *
  218  * @li Reentrant: yes
  219  * @li IRQ safe:  yes
  220  *
  221  * @return pAtomicVar value after the subtraction
  222  */
  223 int64_t qatUtilsAtomicSub(int64_t inValue, QatUtilsAtomic *pAtomicVar);
  224 
  225 /**
  226  * @ingroup QatUtils
  227  *
  228  * @brief increment value of atomic variable by 1
  229  *
  230  * @param  pAtomicVar IN/OUT   - atomic variable
  231  *
  232  * Atomically increments the value of pAtomicVar by 1.
  233  *
  234  * @li Reentrant: yes
  235  * @li IRQ safe:  yes
  236  *
  237  * @return pAtomicVar value after the increment
  238  */
  239 int64_t qatUtilsAtomicInc(QatUtilsAtomic *pAtomicVar);
  240 
  241 /**
  242  * @ingroup QatUtils
  243  *
  244  * @brief decrement value of atomic variable by 1
  245  *
  246  * @param  pAtomicVar IN/OUT  - atomic variable
  247  *
  248  * Atomically decrements the value of pAtomicVar by 1.
  249  *
  250  * @li Reentrant: yes
  251  * @li IRQ safe:  yes
  252  *
  253  * @return pAtomic value after the decrement
  254  */
  255 int64_t qatUtilsAtomicDec(QatUtilsAtomic *pAtomicVar);
  256 
  257 /**
  258  * @ingroup QatUtils
  259  *
  260  * @brief NUMA aware memory allocation; available on Linux OS only.
  261  *
  262  * @param size - memory size to allocate, in bytes
  263  * @param node - node
  264  * @param alignment - memory boundary alignment (alignment can not be 0)
  265  *
  266  * Allocates a memory zone of a given size on the specified node
  267  * The returned memory is guaraunteed to be physically contiguous if the
  268  * given size is less than 128KB and belonging to the node specified
  269  *
  270  * @li Reentrant: yes
  271  * @li IRQ safe:  no
  272  *
  273  * @return Pointer to the allocated zone or NULL if the allocation failed
  274  */
  275 void *qatUtilsMemAllocContiguousNUMA(uint32_t size,
  276                                      uint32_t node,
  277                                      uint32_t alignment);
  278 
  279 /**
  280  * @ingroup QatUtils
  281  *
  282  * @brief Frees memory allocated by qatUtilsMemAllocContigousNUMA.
  283  *
  284  * @param ptr - pointer to the memory zone
  285  * @param size - size of the pointer previously allocated
  286  *
  287  * Frees a previously allocated memory zone
  288  *
  289  * @li Reentrant: yes
  290  * @li IRQ safe:  no
  291  *
  292  * @return - none
  293  */
  294 void qatUtilsMemFreeNUMA(void *ptr);
  295 
  296 /**
  297  * @ingroup QatUtils
  298  *
  299  * @brief virtual to physical address translation
  300  *
  301  * @param virtAddr - virtual address
  302  *
  303  * Converts a virtual address into its equivalent MMU-mapped physical address
  304  *
  305  * @li Reentrant: yes
  306  * @li IRQ safe:  yes
  307  *
  308  * @return Corresponding physical address
  309  */
  310 #define QAT_UTILS_MMU_VIRT_TO_PHYS(virtAddr)                                   \
  311         ((uint64_t)((virtAddr) ? vtophys(virtAddr) : 0))
  312 
  313 /**
  314  * @ingroup QatUtils
  315  *
  316  * @brief Initializes the SpinLock object
  317  *
  318  * @param pLock - Spinlock handle
  319  *
  320  * Initializes the SpinLock object.
  321  *
  322  * @li Reentrant: yes
  323  * @li IRQ safe:  yes
  324  *
  325  * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL
  326  */
  327 CpaStatus qatUtilsLockInit(struct mtx *pLock);
  328 
  329 /**
  330  * @ingroup QatUtils
  331  *
  332  * @brief Acquires a spin lock
  333  *
  334  * @param pLock - Spinlock handle
  335  *
  336  * This routine acquires a spin lock so the
  337  * caller can synchronize access to shared data in a
  338  * multiprocessor-safe way by raising IRQL.
  339  *
  340  * @li Reentrant: yes
  341  * @li IRQ safe:  yes
  342  *
  343  * @return - Returns CPA_STATUS_SUCCESS if the spinlock is acquired. Returns
  344  * CPA_STATUS_FAIL
  345  * if
  346  *           spinlock handle is NULL. If spinlock is already acquired by any
  347  *           other thread of execution then it tries in busy loop/spins till it
  348  *           gets spinlock.
  349  */
  350 CpaStatus qatUtilsLock(struct mtx *pLock);
  351 
  352 /**
  353  * @ingroup QatUtils
  354  *
  355  * @brief Releases the spin lock
  356  *
  357  * @param pLock - Spinlock handle
  358  *
  359  * This routine releases the spin lock which the thread had acquired
  360  *
  361  * @li Reentrant: yes
  362  * @li IRQ safe:  yes
  363  *
  364  * @return - return CPA_STATUS_SUCCESS if the spinlock is released. Returns
  365  * CPA_STATUS_FAIL
  366  * if
  367  *           spinlockhandle passed is NULL.
  368  */
  369 CpaStatus qatUtilsUnlock(struct mtx *pLock);
  370 
  371 /**
  372  * @ingroup QatUtils
  373  *
  374  * @brief Destroy the spin lock object
  375  *
  376  * @param pLock - Spinlock handle
  377  *
  378  * @li Reentrant: yes
  379  * @li IRQ safe:  yes
  380  *
  381  * @return - returns CPA_STATUS_SUCCESS if plock is destroyed.
  382  *           returns CPA_STATUS_FAIL if plock is NULL.
  383  */
  384 CpaStatus qatUtilsLockDestroy(struct mtx *pLock);
  385 
  386 /**
  387  * @ingroup QatUtils
  388  *
  389  * @brief Initializes a semaphore
  390  *
  391  * @param pSid - semaphore handle
  392  * @param start_value - initial semaphore value
  393  *
  394  * Initializes a semaphore object
  395  * Note: Semaphore initialization qatUtilsSemaphoreInit API must be called
  396  * first before using any QAT Utils Semaphore APIs
  397  *
  398  * @li Reentrant: yes
  399  * @li IRQ safe:  no
  400  *
  401  * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL
  402  */
  403 CpaStatus qatUtilsSemaphoreInit(struct sema **pSid, uint32_t start_value);
  404 
  405 /**
  406  * @ingroup QatUtils
  407  *
  408  * @brief Destroys a semaphore object
  409  *
  410  * @param pSid - semaphore handle
  411  *
  412  * Destroys a semaphore object; the caller should ensure that no thread is
  413  * blocked on this semaphore. If call made when thread blocked on semaphore the
  414  * behaviour is unpredictable
  415  *
  416  * @li Reentrant: yes
  417 ] * @li IRQ safe:  no
  418  *
  419  * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL
  420  */
  421 CpaStatus qatUtilsSemaphoreDestroy(struct sema **pSid);
  422 
  423 /**
  424  * @ingroup QatUtils
  425  *
  426  * @brief Waits on (decrements) a semaphore
  427  *
  428  * @param pSid - semaphore handle
  429  * @param timeout - timeout, in ms; QAT_UTILS_WAIT_FOREVER (-1) if the thread
  430  * is to block indefinitely or QAT_UTILS_WAIT_NONE (0) if the thread is to
  431  * return immediately even if the call fails
  432  *
  433  * Decrements a semaphore, blocking if the semaphore is
  434  * unavailable (value is 0).
  435  *
  436  * @li Reentrant: yes
  437  * @li IRQ safe:  no
  438  *
  439  * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL
  440  */
  441 CpaStatus qatUtilsSemaphoreWait(struct sema **pSid, int32_t timeout);
  442 
  443 /**
  444  * @ingroup QatUtils
  445  *
  446  * @brief Non-blocking wait on semaphore
  447  *
  448  * @param semaphore - semaphore handle
  449  *
  450  * Decrements a semaphore, not blocking the calling thread if the semaphore
  451  * is unavailable
  452  *
  453  * @li Reentrant: yes
  454  * @li IRQ safe:  no
  455  *
  456  * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL
  457  */
  458 CpaStatus qatUtilsSemaphoreTryWait(struct sema **semaphore);
  459 
  460 /**
  461  * @ingroup QatUtils
  462  *
  463  * @brief Posts to (increments) a semaphore
  464  *
  465  * @param pSid - semaphore handle
  466  *
  467  * Increments a semaphore object
  468  *
  469  * @li Reentrant: yes
  470  * @li IRQ safe:  no
  471  *
  472  * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL
  473  */
  474 CpaStatus qatUtilsSemaphorePost(struct sema **pSid);
  475 
  476 /**
  477  * @ingroup QatUtils
  478  *
  479  * @brief initializes a pMutex
  480  *
  481  * @param pMutex - pMutex handle
  482  *
  483  * Initializes a pMutex object
  484  * @note Mutex initialization qatUtilsMutexInit API must be called
  485  * first before using any QAT Utils Mutex APIs
  486  *
  487  * @li Reentrant: yes
  488  * @li IRQ safe:  no
  489  *
  490  * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL
  491  */
  492 CpaStatus qatUtilsMutexInit(struct mtx **pMutex);
  493 
  494 /**
  495  * @ingroup QatUtils
  496  *
  497  * @brief locks a pMutex
  498  *
  499  * @param pMutex - pMutex handle
  500  * @param timeout - timeout in ms; QAT_UTILS_WAIT_FOREVER (-1) to wait forever
  501  *                  or QAT_UTILS_WAIT_NONE to return immediately
  502  *
  503  * Locks a pMutex object
  504  *
  505  * @li Reentrant: yes
  506  * @li IRQ safe:  no
  507  *
  508  * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL
  509  */
  510 CpaStatus qatUtilsMutexLock(struct mtx **pMutex, int32_t timeout);
  511 
  512 /**
  513  * @ingroup QatUtils
  514  *
  515  * @brief Unlocks a pMutex
  516  *
  517  * @param pMutex - pMutex handle
  518  *
  519  * Unlocks a pMutex object
  520  *
  521  * @li Reentrant: yes
  522  * @li IRQ safe:  no
  523  *
  524  * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL
  525  */
  526 CpaStatus qatUtilsMutexUnlock(struct mtx **pMutex);
  527 
  528 /**
  529  * @ingroup QatUtils
  530  *
  531  * @brief Destroys a pMutex object
  532  *
  533  * @param pMutex - pMutex handle
  534  *
  535  * Destroys a pMutex object; the caller should ensure that no thread is
  536  * blocked on this pMutex. If call made when thread blocked on pMutex the
  537  * behaviour is unpredictable
  538  *
  539  * @li Reentrant: yes
  540  * @li IRQ safe:  no
  541  *
  542  * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL
  543  */
  544 CpaStatus qatUtilsMutexDestroy(struct mtx **pMutex);
  545 
  546 /**
  547  * @ingroup QatUtils
  548  *
  549  * @brief Non-blocking attempt to lock a pMutex
  550  *
  551  * @param pMutex - pMutex handle
  552  *
  553  * Attempts to lock a pMutex object, returning immediately with
  554  * CPA_STATUS_SUCCESS if
  555  * the lock was successful or CPA_STATUS_FAIL if the lock failed
  556  *
  557  * @li Reentrant: yes
  558  * @li IRQ safe:  no
  559  *
  560  * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL
  561  */
  562 CpaStatus qatUtilsMutexTryLock(struct mtx **pMutex);
  563 
  564 /**
  565  * @ingroup QatUtils
  566  *
  567  * @brief Yielding sleep for a number of milliseconds
  568  *
  569  * @param milliseconds - number of milliseconds to sleep
  570  *
  571  * The calling thread will sleep for the specified number of milliseconds.
  572  * This sleep is yielding, hence other tasks will be scheduled by the
  573  * operating system during the sleep period. Calling this function with an
  574  * argument of 0 will place the thread at the end of the current scheduling
  575  * loop.
  576  *
  577  * @li Reentrant: yes
  578  * @li IRQ safe:  no
  579  *
  580  * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL
  581  */
  582 CpaStatus qatUtilsSleep(uint32_t milliseconds);
  583 
  584 /**
  585  * @ingroup QatUtils
  586  *
  587  * @brief Yields execution of current thread
  588  *
  589  * Yields the execution of the current thread
  590  *
  591  * @li Reentrant: yes
  592  * @li IRQ safe:  no
  593  *
  594  * @return - none
  595  */
  596 void qatUtilsYield(void);
  597 
  598 /**
  599  * @ingroup QatUtils
  600  *
  601  * @brief  Calculate MD5 transform operation
  602  *
  603  * @param  in - pointer to data to be processed.
  604  *         The buffer needs to be at least md5 block size long as defined in
  605  *         rfc1321 (64 bytes)
  606  *         out - output pointer for state data after single md5 transform
  607  *         operation.
  608  *         The buffer needs to be at least md5 state size long as defined in
  609  *         rfc1321 (16 bytes)
  610  *
  611  * @li Reentrant: yes
  612  * @li IRQ safe:  yes
  613  *
  614  * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL
  615  *
  616  */
  617 CpaStatus qatUtilsHashMD5(uint8_t *in, uint8_t *out);
  618 
  619 /**
  620  * @ingroup QatUtils
  621  *
  622  * @brief  Calculate MD5 transform operation
  623  *
  624  * @param  in - pointer to data to be processed.
  625  *         The buffer needs to be at least md5 block size long as defined in
  626  *         rfc1321 (64 bytes)
  627  *         out - output pointer for state data after single md5 transform
  628  *         operation.
  629  *         The buffer needs to be at least md5 state size long as defined in
  630  *         rfc1321 (16 bytes)
  631  *         len - Length on the input to be processed.
  632  *
  633  * @li Reentrant: yes
  634  * @li IRQ safe:  yes
  635  *
  636  * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL
  637  *
  638  */
  639 CpaStatus qatUtilsHashMD5Full(uint8_t *in, uint8_t *out, uint32_t len);
  640 
  641 /**
  642  * @ingroup QatUtils
  643  *
  644  * @brief  Calculate SHA1 transform operation
  645  *
  646  * @param  in - pointer to data to be processed.
  647  *         The buffer needs to be at least sha1 block size long as defined in
  648  *         rfc3174 (64 bytes)
  649  *         out - output pointer for state data after single sha1 transform
  650  *         operation.
  651  *         The buffer needs to be at least sha1 state size long as defined in
  652  *         rfc3174 (20 bytes)
  653  *
  654  * @li Reentrant: yes
  655  * @li IRQ safe:  yes
  656  *
  657  * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL
  658  *
  659  */
  660 CpaStatus qatUtilsHashSHA1(uint8_t *in, uint8_t *out);
  661 
  662 /**
  663  * @ingroup QatUtils
  664  *
  665  * @brief  Calculate SHA1 transform operation
  666  *
  667  * @param  in - pointer to data to be processed.
  668  *         The buffer needs to be at least sha1 block size long as defined in
  669  *         rfc3174 (64 bytes)
  670  *         out - output pointer for state data after single sha1 transform
  671  *         operation.
  672  *         The buffer needs to be at least sha1 state size long as defined in
  673  *         rfc3174 (20 bytes)
  674  *         len - Length on the input to be processed.
  675  *
  676  * @li Reentrant: yes
  677  * @li IRQ safe:  yes
  678  *
  679  * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL
  680  *
  681  */
  682 CpaStatus qatUtilsHashSHA1Full(uint8_t *in, uint8_t *out, uint32_t len);
  683 
  684 /**
  685  * @ingroup QatUtils
  686  *
  687  * @brief  Calculate SHA224 transform operation
  688  *
  689  * @param  in - pointer to data to be processed.
  690  *         The buffer needs to be at least sha224 block size long as defined in
  691  *         rfc3874 and rfc4868 (64 bytes)
  692  *         out - output pointer for state data after single sha224 transform
  693  *         operation.
  694  *         The buffer needs to be at least sha224 state size long as defined in
  695  *         rfc3874 and rfc4868 (32 bytes)
  696  * @li Reentrant: yes
  697  * @li IRQ safe:  yes
  698  *
  699  * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL
  700  *
  701  */
  702 CpaStatus qatUtilsHashSHA224(uint8_t *in, uint8_t *out);
  703 
  704 /**
  705  * @ingroup QatUtils
  706  *
  707  * @brief  Calculate SHA256 transform operation
  708  *
  709  *
  710  * @param  in - pointer to data to be processed.
  711  *         The buffer needs to be at least sha256 block size long as defined in
  712  *         rfc4868 (64 bytes)
  713  *         out - output pointer for state data after single sha256 transform
  714  *         operation.
  715  *         The buffer needs to be at least sha256 state size long as defined in
  716  *         rfc4868 (32 bytes)
  717  * @li Reentrant: yes
  718  * @li IRQ safe:  yes
  719  *
  720  * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL
  721  *
  722  */
  723 CpaStatus qatUtilsHashSHA256(uint8_t *in, uint8_t *out);
  724 
  725 /**
  726  * @ingroup QatUtils
  727  *
  728  * @brief  Calculate SHA256 transform operation
  729  *
  730  *
  731  * @param  in - pointer to data to be processed.
  732  *         The buffer needs to be at least sha256 block size long as defined in
  733  *         rfc4868 (64 bytes)
  734  *         out - output pointer for state data after single sha256 transform
  735  *         operation.
  736  *         The buffer needs to be at least sha256 state size long as defined in
  737  *         rfc4868 (32 bytes)
  738  *         len - Length on the input to be processed.
  739  * @li Reentrant: yes
  740  * @li IRQ safe:  yes
  741  *
  742  * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL
  743  *
  744  */
  745 CpaStatus qatUtilsHashSHA256Full(uint8_t *in, uint8_t *out, uint32_t len);
  746 
  747 /**
  748  * @ingroup QatUtils
  749  *
  750  * @brief  Calculate SHA384 transform operation
  751  *
  752  * @param  in - pointer to data to be processed.
  753  *         The buffer needs to be at least sha384 block size long as defined in
  754  *         rfc4868 (128 bytes)
  755  *         out - output pointer for state data after single sha384 transform
  756  *         operation.
  757  *         The buffer needs to be at least sha384 state size long as defined in
  758  *         rfc4868 (64 bytes)
  759  * @li Reentrant: yes
  760  * @li IRQ safe:  yes
  761  *
  762  * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL
  763  *
  764  */
  765 CpaStatus qatUtilsHashSHA384(uint8_t *in, uint8_t *out);
  766 
  767 /**
  768  * @ingroup QatUtils
  769  *
  770  * @brief  Calculate SHA384 transform operation
  771  *
  772  * @param  in - pointer to data to be processed.
  773  *         The buffer needs to be at least sha384 block size long as defined in
  774  *         rfc4868 (128 bytes)
  775  *         out - output pointer for state data after single sha384 transform
  776  *         operation.
  777  *         The buffer needs to be at least sha384 state size long as defined in
  778  *         rfc4868 (64 bytes)
  779  *         len - Length on the input to be processed.
  780  * @li Reentrant: yes
  781  * @li IRQ safe:  yes
  782  *
  783  * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL
  784  *
  785  */
  786 CpaStatus qatUtilsHashSHA384Full(uint8_t *in, uint8_t *out, uint32_t len);
  787 
  788 /**
  789  * @ingroup QatUtils
  790  *
  791  * @brief  Calculate SHA512 transform operation
  792  *
  793  * @param  in - pointer to data to be processed.
  794  *         The buffer needs to be at least sha512 block size long as defined in
  795  *         rfc4868 (128 bytes)
  796  *         out - output pointer for state data after single sha512 transform
  797  *         operation.
  798  *         The buffer needs to be at least sha512 state size long as defined in
  799  *         rfc4868 (64 bytes)
  800  * @li Reentrant: yes
  801  * @li IRQ safe:  yes
  802  *
  803  * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL
  804  *
  805  */
  806 CpaStatus qatUtilsHashSHA512(uint8_t *in, uint8_t *out);
  807 
  808 /**
  809  * @ingroup QatUtils
  810  *
  811  * @brief  Calculate SHA512 transform operation
  812  *
  813  * @param  in - pointer to data to be processed.
  814  *         The buffer needs to be at least sha512 block size long as defined in
  815  *         rfc4868 (128 bytes)
  816  *         out - output pointer for state data after single sha512 transform
  817  *         operation.
  818  *         The buffer needs to be at least sha512 state size long as defined in
  819  *         rfc4868 (64 bytes)
  820  *         len - Length on the input to be processed.
  821  * @li Reentrant: yes
  822  * @li IRQ safe:  yes
  823  *
  824  * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL
  825  *
  826  */
  827 CpaStatus qatUtilsHashSHA512Full(uint8_t *in, uint8_t *out, uint32_t len);
  828 
  829 /**
  830  * @ingroup QatUtils
  831  *
  832  * @brief  Single block AES encrypt
  833  *
  834  * @param  key - pointer to symetric key.
  835  *         keyLenInBytes - key length
  836  *         in - pointer to data to encrypt
  837  *         out - pointer to output buffer for encrypted text
  838  *         The in and out buffers need to be at least AES block size long
  839  *         as defined in rfc3686 (16 bytes)
  840  *
  841  * @li Reentrant: yes
  842  * @li IRQ safe:  yes
  843  *
  844  * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL
  845  *
  846  */
  847 CpaStatus qatUtilsAESEncrypt(uint8_t *key,
  848                              uint32_t keyLenInBytes,
  849                              uint8_t *in,
  850                              uint8_t *out);
  851 
  852 /**
  853  * @ingroup QatUtils
  854  *
  855  * @brief  Converts AES forward key to reverse key
  856  *
  857  * @param  key - pointer to symetric key.
  858  *         keyLenInBytes - key length
  859  *         out - pointer to output buffer for reversed key
  860  *         The in and out buffers need to be at least AES block size long
  861  *         as defined in rfc3686 (16 bytes)
  862  *
  863  * @li Reentrant: yes
  864  * @li IRQ safe:  yes
  865  *
  866  * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL
  867  *
  868  */
  869 CpaStatus qatUtilsAESKeyExpansionForward(uint8_t *key,
  870                                          uint32_t keyLenInBytes,
  871                                          uint32_t *out);
  872 #endif

Cache object: a1cf5e29b86e0436d3d10cbe665d92f8


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.