/*! * This function is called from the SW queue manager in order to complete * a crypto operation. The SW queue manager calls this API when the * "Process" bit "0x2" is set in the SW descriptor header. This function * may be invoked after "DispatchDriverProcess" or "DispatchDriverInit" with any * number of IN/OUT MLLI tables. * * \param pCtx A pointer to the context buffer in SRAM. * \param pDmaInputBuffer A structure which represents the DMA input buffer. * \param pDmaOutputBuffer A structure which represents the DMA output buffer. * * \return int One of DX_SYM_* error codes defined in head of file. */ int SymDriverDispatchFinalize(struct sep_ctx_generic *pCtx, DmaBuffer_s *pDmaInputBuffer, DmaBuffer_s *pDmaOutputBuffer) { int retcode; uint32_t alg; DX_PAL_LOG_INFO("qid=%d pCtx=%p\n", CURR_QUEUE_ID(), pCtx); DX_PAL_LOG_INFO("pDmaInputBuffer: pData=%p DataSize=%d DmaMode=%d nTables=%d\n", (uint32_t *)pDmaInputBuffer->pData, (int)pDmaInputBuffer->size, (int)pDmaInputBuffer->dmaBufType, (int)pDmaInputBuffer->nTables); DX_PAL_LOG_INFO("pDmaOutputBuffer: pData=%p DataSize=%d DmaMode=%d nTables=%d\n", (uint32_t *)pDmaOutputBuffer->pData, (int)pDmaOutputBuffer->size, (int)pDmaOutputBuffer->dmaBufType, (int)pDmaOutputBuffer->nTables); //mdelay(1000); alg = ReadContextWord(&pCtx->alg); if (gFuncDispatchList[alg].finalizeFunc == NULL) { DX_PAL_LOG_ERR("Unsupported alg %d\n", alg); return DX_RET_UNSUPP_ALG; } HW_QUEUE_LOCK(); retcode = (gFuncDispatchList[alg].finalizeFunc)(pCtx, pDmaInputBuffer, pDmaOutputBuffer); HW_QUEUE_UNLOCK(); return retcode; }
/*! * This function allocates IN/OUT MLLI tables in SRAM and appends the * "Last LLI" marker to the end of the IN/OUT tables. Each MLLI table size * is 1K + 8 bytes of the "last LLI" entry. * * \param none * * \return one of the error codes defined in err.h */ void InitMlli() { uint32_t qid; DX_PAL_LOG_INFO("Clear MLLI workspace at adr=0x%08X size=0x%08X\n", (unsigned int)gMlliWorkspace, (unsigned int)(MAX_NUM_HW_QUEUES * MLLI_IN_OUT_BUF_SIZE)); /* clear MLLI tables memory */ _ClearSram((uint32_t*)gMlliWorkspace, MAX_NUM_HW_QUEUES * MLLI_IN_OUT_BUF_SIZE); for (qid = 0; qid < MAX_NUM_HW_QUEUES; qid++) { SetMlliStopEntry(qid); } }
/*! * This function retrieves the pointer to the first LLI entry in the MLLI * table which resides in SRAM. The first LLI will always be located after * the link entry to the next MLLI table. * * \param qid [in] -The queue Id. * \param dir [in] -indicates MLLI_INPUT_TABLE or MLLI_OUTPUT_TABLE * * \return A pointer to the first LLI entry in the MLLI table */ uint32_t *GetFirstLliPtr(int qid, MLLIDirection_t direction) { uint32_t *pBuf; DX_PAL_LOG_INFO("qid=%d\n",(int)qid); pBuf = (void *)(DX_GetMLLIWorkspace() + qid * MLLI_IN_OUT_BUF_SIZE); /* Set offset to input or output table */ pBuf += ( direction == MLLI_INPUT_TABLE ? 0 : MLLI_BUF_SIZE_IN_WORDS ); /* Skip the link entry */ pBuf += SEP_LLI_ENTRY_WORD_SIZE; return pBuf; }
static void SetMlliStopEntry(int qid) { uint32_t *pBuf = (void *)gMlliWorkspace; uint8_t i; /* Buffer points to the begining of the corresponding queue by qid */ pBuf += qid * MLLI_IN_OUT_BUF_SIZE_IN_WORDS; /* Buffer points to last entry in input table */ pBuf += MLLI_BUF_SIZE_IN_WORDS - SEP_LLI_ENTRY_WORD_SIZE; /* Set stop entry in last position of every MLLI table. */ /* We have two tables (IN/OUT) per queue */ for ( i=0; i<2; i++ ) { DX_PAL_LOG_INFO("Set stop entry at adr=0x%08X\n", (unsigned int)pBuf); _WriteWordsToSram((uint32_t*)pBuf ,0x80000000 , 4); /* Set offset to next table */ pBuf += MLLI_BUF_SIZE_IN_WORDS; } }
/*! * This function is called from the SW queue manager which passes the * related context. The function casts the context buffer and diverts * to the specific CRYS Init API according to the cipher algorithm that * associated in the given context. It is also prepare the necessary * firmware private context parameters that are require for the crypto * operation, for example, computation of the AES-MAC k1, k2, k3 values. * The API has no affect on the user data buffers. * * \param pCtx A pointer to the context buffer in SRAM. * * \return int One of DX_SYM_* error codes defined in head of file. */ int SymDriverDispatchInit(struct sep_ctx_generic *pCtx) { int retcode; uint32_t alg; DX_PAL_LOG_INFO("qid=%d pCtx=%p\n", CURR_QUEUE_ID(), pCtx); //mdelay(1000); alg = ReadContextWord(&pCtx->alg); if (gFuncDispatchList[alg].initFunc == NULL) { DX_PAL_LOG_ERR("Unsupported alg %d\n", alg); return DX_RET_UNSUPP_ALG; } HW_QUEUE_LOCK(); retcode = (gFuncDispatchList[alg].initFunc)(pCtx); HW_QUEUE_UNLOCK(); return retcode; }