Files
2026-07-30 11:19:44 +05:30

656 lines
25 KiB
C

/*
******************************************************************************
* SOURCE FILE
*
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: sec4_init.c,v $ $Revision: 1.7 $
* $Source: /home/interpeak/CVSRoot/ipfreescale/sec4/sec4_init.c,v $
* $Author: dhessing $
* $State: Exp $ $Locker: $
*
* INTERPEAK_COPYRIGHT_STRING
******************************************************************************
*/
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
*/
/****************************************************************************
* sec4_init.c -- The Initialization code for SEC4 Driver
* Based on sec2_init.c for SEC2 Driver
****************************************************************************
* Copyright (c) Certicom Corp. 1996-2002. All rights reserved
* Copyright (c) 2003-2005 Freescale Semiconductor
* All Rights Reserved. Proprietary and Confidential.
*
* NOTICE: The information contained in this file is proprietary
* to Freescale Semiconductor, and is being made available to
* Freescale's customers under strict license agreements.
* Use or disclosure of this information is permissible only
* under the terms of the existing license agreement.
***************************************************************************/
/* Revision History:
* 1.0 Mar 11,2011 - Based on sec2_init.c v1.2
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#include <taskLib.h>
#include <stdio.h>
#include "Sec4Driver.h"
#include <sec_dcl_ext.h>
#include <sec_jq_ext.h>
#ifdef SEC4_USE_QI
#include <sec_qi_ext.h>
t_Error sec4_qi_init(void);
#endif
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
/* Define module for errors reported from this file (as used in Netcomm SEC4 driver) */
#define __ERR_MODULE__ MODULE_SEC
#ifdef DEBUG
/*unsigned long SEC4DebugLevel = (DBGTXT_ERROR | DBGTXT_SETRQ | DBGTXT_SVCRQ | DBGTXT_INITDEV | DBGTXT_DESCSHOW | DBGTXT_INFO);*/
unsigned long SEC4DebugLevel = (DBGTXT_INFO | DBGTXT_ERROR);
/*unsigned long SEC4DebugLevel = (DBGTXT_INFO | DBGTXT_INITDEV | DBGTXT_ERROR);*/
/*unsigned long SEC4DebugLevel = (DBGTXT_ERROR | DBGTXT_SETRQ | DBGTXT_SVCRQ | DBGTXT_INITDEV | DBGTXT_INFO);*/
#else
unsigned long SEC4DebugLevel = 0x0;
#endif
#ifdef _WRS_CONFIG_WRHV_GUEST
/* The packets shared memory area is retrieved and depends on the Hypervisor configuration
* This name must match the name in that configuration */
#define SEC4_WRHV_SHMEM_PACKETS_NAME "packets"
/* The shared memory area for shared descriptors is retrieved and depends on the Hypervisor configuration
* This name must match the name in that configuration */
#define SEC4_WRHV_SHMEM_SHDESC_NAME "numa1"
#endif
#ifdef SEC4_PREALLOC_DESC_BUF
/* Settings for pre-allocated memory buffers for descriptors and descriptor buffers */
#define SEC_DCL_DESC_MEM_BUFSIZE (32)
#define SEC_DCL_DESCBUF_MEM_BUFSIZE (128)
#endif /* #ifdef SEC4_PREALLOC_DESC_BUF */
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
/*
****************************************************************************
* 6 EXTERN PROTOTYPES
****************************************************************************
*/
/*
****************************************************************************
* 7 LOCAL PROTOTYPES
****************************************************************************
*/
t_Error sec4_jq_init(t_Handle *p_SecJobQueue, uint32_t jqId, uint8_t jqIrqCoalCnt,
uint16_t jqIrqCoalTime, uint16_t jqIRSize, uint16_t jqORSize);
#ifdef SEC4_USE_QI
t_Error sec4_qi_init(void);
t_Error sec4_fq_map_init(uint32_t coreIx);
t_Error sec4_shm_init(uint32_t coreIx);
#endif
/*
****************************************************************************
* 8 DATA
****************************************************************************
*/
/* Global handles */
t_Handle h_Sec4;
t_Handle h_SecDcl;
t_Handle h_SecJobQueue;
uint32_t sec4CoreId; /* Current core SEC4 ID */
#ifdef SEC4_USE_QI
t_Handle h_SecDclQi;
t_Handle h_SecQi;
t_Handle h_sec4Shm; /* Handle to start of shared memory for objects needed during init */
t_Handle h_sec4IpsecSaCache; /* IPsec SA cache handle*/
t_Handle *p_sec4IpsecCacheHandle; /* pointer to IPsec SA cache handle */
uint32_t sec4IpsecSaCacheNoofEntries = SEC4_IPSEC_NOOF_SA_CACHE_ENTRIES_DEFAULT;
uint32_t **sec4IpsecSaFqMap; /* IPsec SA to frame queue per core map */
uint32_t **p_sec4IpsecSaFqMap;
#endif
#ifdef SEC4_USE_SHARED_JOB_QUEUE
t_Handle **p_sec4JobQueueHandle = NULL; /* Pointer to shared job queue handle */
t_sec4IpcMsg *sec4IpcVector = NULL; /* Used for master core to guest core messaging of job status */
t_sec4IpcMsg **p_sec4IpcVector = NULL; /* For every core to find sec4IpcVector during init */
#endif
#ifdef _WRS_CONFIG_WRHV_GUEST
/* If we are on top of a Hypervisor we need to map physical to virtual addresses */
/* The offset is retrieved during SEC4DriverInit() */
physAddress_t sec4VirtualOffset = 0;
/* Memory area for packets may have another offset.*/
physAddress_t sec4VirtualOffsetPackets = 0;
physAddress_t sec4PacketsBase = 0; /* Used to differentiate when to use sec4VirtualOffset vs sec4VirtualOffsetPackets */
/* Memory area for shared descriptors may have another offset.*/
physAddress_t sec4VirtualOffsetShDesc = 0;
physAddress_t sec4ShDescBase = 0; /* Used to differentiate when to use sec4VirtualOffsetShDesc vs sec4VirtualOffsetPackets */
#endif
static uint64_t sec4DeviceBaseAddr;
/*
****************************************************************************
* 9 LOCAL FUNCTIONS
****************************************************************************
*/
#ifdef SEC4_USE_QI
/*************************************************************************
* Function Name: sec4_qi_init
* Purpose: Configures and initializes the SEC4 queue interface.
*
* Return: E_OK if everything passed, otherwise the error code
*************************************************************************/
t_Error sec4_qi_init(void)
{
t_SecQiParam secQiParam;
t_SecQiCmdParam secQiCmdParam;
t_Error status;
/* Config SEC4 QI (Queue Interface) */
secQiParam.baseAddr = sec4DeviceBaseAddr + ((uint64_t) SEC4X_QI_BASE_OFFSET);
secQiParam.h_Sec = h_Sec4;
secQiParam.nonSeqLiodnBase = 0;
secQiParam.nonSeqLiodnMask = 0;
secQiParam.seqLiodnBase = 0;
h_SecQi = SEC_QI_Config(&secQiParam);
if(h_SecQi == NULL)
{
return ERROR_CODE(E_NO_MEMORY);
}
/* Configure SEC4 QI Commands */
secQiCmdParam.deqByteCountThr = 0xffff; /* Don't limit no. of bytes to dequeue */
secQiCmdParam.deqFrameCount = e_SEC_QI_FRAME_COUNT_MAXIMUM_3;
secQiCmdParam.deqScheduling = e_SEC_QI_SCHEDULING_PRI_WITH_IC;
secQiCmdParam.deqSpfCountThr = 0x7; /* Don't limit no. of frames for each sub-portal */
secQiCmdParam.enqFrameColor = e_SEC_QI_FRAME_COLOR_OVERRIDE;
status = SEC_QI_ConfigCommands(h_SecQi, &secQiCmdParam);
if(E_OK != status)
return status;
status = SEC_QI_Init(h_SecQi);
if(E_OK != status)
return status;
return SEC4_SUCCESS;
}
/*************************************************************************
* Function Name: sec4_shm_init
* Purpose: Configures and initializes the SEC4 shared memory.
* IPsec SA frame queue to core map, IPsec SA cache,
* shared job queue handle.
*
* Return: E_OK if everything passed, otherwise the error code
*************************************************************************/
t_Error sec4_shm_init(uint32_t coreIx)
{
int i;
/* Pointers to handles in dedicated place in shared memory*/
p_sec4IpsecCacheHandle = (t_Handle *) h_sec4Shm;
p_sec4IpsecSaFqMap = (uint32_t **) ((uint32_t)h_sec4Shm + sizeof(h_sec4Shm));
#ifdef SEC4_USE_SHARED_JOB_QUEUE
p_sec4JobQueueHandle = (t_Handle **) ((uint32_t)p_sec4IpsecSaFqMap + sizeof(p_sec4IpsecSaFqMap));
p_sec4IpcVector = (t_sec4IpcMsg **) ((uint32_t)p_sec4JobQueueHandle + sizeof(p_sec4JobQueueHandle));
#endif
if(coreIx == NCSW_MASTER_ID)
{
/* IPsec SA cache */
h_sec4IpsecSaCache = (t_Handle) XX_MallocSmart(sec4IpsecSaCacheNoofEntries * sizeof(t_sec4IpsecSa), 1, 1);
if(h_sec4IpsecSaCache == NULL)
{
return ERROR_CODE(E_NO_MEMORY);
}
memset(h_sec4IpsecSaCache, 0, sec4IpsecSaCacheNoofEntries * sizeof(t_sec4IpsecSa));
*p_sec4IpsecCacheHandle = h_sec4IpsecSaCache;
#ifdef SEC4_USE_SHARED_JOB_QUEUE
/* Initiate core to core message communication vector */
sec4IpcVector = (t_sec4IpcMsg *) XX_MallocSmart(SEC4_MAXNOOF_CORES * sizeof(t_sec4IpcMsg), 1, 1);
if(sec4IpcVector == NULL)
{
return ERROR_CODE(E_NO_MEMORY);
}
for(i=0; i < SEC4_MAXNOOF_CORES; i++)
{
sec4IpcVector[i].state = SEC4_IPC_STATE_IDLE;
sec4IpcVector[i].req = NULL;
}
*p_sec4IpcVector = sec4IpcVector;
SEC4Dump(DBGTXT_INITDEV, ("SEC4 : sec4IpcVector initiated at 0x%x\n", sec4IpcVector));
#endif
}
else
{
/**/
h_sec4IpsecSaCache = *p_sec4IpsecCacheHandle;
SEC4Dump(DBGTXT_INITDEV, ("SEC4 : sec4IpsecSaCache is at 0x%x\n", h_sec4IpsecSaCache));
#ifdef SEC4_USE_SHARED_JOB_QUEUE
sec4IpcVector = *p_sec4IpcVector;
SEC4Dump(DBGTXT_INITDEV, ("SEC4 : sec4IpcVector is at is at 0x%x\n", sec4IpcVector));
#endif
}
SEC4Dump(DBGTXT_INITDEV, ("SEC4 : IPsec SA cache is at 0x%x for %d entries\n",\
h_sec4IpsecSaCache, sec4IpsecSaCacheNoofEntries));
return E_OK;
}
/*************************************************************************
* Function Name: sec4_fq_map_init
* Purpose: Configures and initializes the SEC4 IPsec SA frame queue to
* core map.
*
* Return: E_OK if everything passed, otherwise the error code
*************************************************************************/
t_Error sec4_fq_map_init(uint32_t coreIx)
{
int i;
if(coreIx == NCSW_MASTER_ID)
{
/* Allocate core local map of SA->FQ ID */
if((sec4IpsecSaFqMap = XX_MallocSmart(sec4IpsecSaCacheNoofEntries * sizeof(uint32_t *), 1, 1)) == NULL)
{
SEC4Dump(DBGTXT_ERROR,("SEC4_populate_sa() :: Could not allocate memory for SA-> FQID map\n"));
return ERROR_CODE(E_NO_MEMORY);
}
else
{
/* Set global shared MAP */
*p_sec4IpsecSaFqMap = sec4IpsecSaFqMap;
for(i = 0; i < sec4IpsecSaCacheNoofEntries; i++)
{
if((sec4IpsecSaFqMap[i] = XX_MallocSmart(SEC4_MAXNOOF_CORES * sizeof(uint32_t), 1, 1)) == NULL)
{
SEC4Dump(DBGTXT_ERROR,("SEC4_populate_sa() :: Could not allocate memory for SA-> FQID map core array\n"));
return ERROR_CODE(E_NO_MEMORY);
}
/* Clear map */
memset(sec4IpsecSaFqMap[i], 0, SEC4_MAXNOOF_CORES * sizeof(uint32_t));
}
SEC4Dump(DBGTXT_INITDEV, ("SEC4 : IPsec SA to FQID map initiated at 0x%x\n", sec4IpsecSaFqMap));
}
}
else
{
/* Set global shared MAP has been set and alloocated by master core */
sec4IpsecSaFqMap = *p_sec4IpsecSaFqMap;
SEC4Dump(DBGTXT_INITDEV, ("SEC4 : IPsec SA to FQID map at 0x%x\n", sec4IpsecSaFqMap));
}
return E_OK;
}
#endif
/*************************************************************************
* Function Name: sec4_jq_config
* Purpose: Configure and init a SEC4 job queue handle.
*
* Return: E_OK if everything passed, otherwise the error code
*************************************************************************/
t_Error sec4_jq_init(t_Handle *p_SecJobQueue, uint32_t jqId, uint8_t jqIrqCoalCnt,
uint16_t jqIrqCoalTime, uint16_t jqIRSize, uint16_t jqORSize)
{
t_SecJqParam jQParam;
t_SecJqRingParam jQRingParam;
t_SecJqIntrParam jQIntrParam;
t_Error status;
#ifdef SEC4_USE_SHARED_JOB_QUEUE
/* Only set up job queue 0 (needs to be done first!)
* Everyone will share the same job queue */
if(jqId != 0)
{
/* Assign shared handle */
*p_SecJobQueue = *p_sec4JobQueueHandle;
SEC4Dump(DBGTXT_INITDEV, ("sec4_jq_init() :: Using shared job queue at 0x%x\n", *p_SecJobQueue));
return E_OK;
}
#endif
/* Configure job queue parameters */
jQParam.h_Sec = h_Sec4;
jQParam.baseAddr = sec4DeviceBaseAddr + ((uint64_t) (SEC4X_JQ0_BASE_OFFSET + (jqId * SEC4X_JQ_BASE_SIZE)));
jQParam.jobQueueId = jqId;
jQParam.seqLiodnVal = 0;
jQParam.nonSeqLiodnVal = 0;
jQParam.f_Cbr = &InterruptServiceRoutine;
jQParam.h_App = NULL; /* Not used */
#ifdef SEC4_POLLED_MODE
jQParam.irq = NO_IRQ;
#else
jQParam.irq = INUM_SEC4_BASE + jqId;
#endif
#ifdef SEC4_USE_SHARED_JOB_QUEUE
jQParam.memId = 1;
#else
jQParam.memId = 0;
#endif
SEC4Dump(DBGTXT_INFO, ("sec4_jq_init() :: Using SEC4 job queue %d\n", jQParam.jobQueueId));
/* Configure and init SEC4 job queue */
*p_SecJobQueue = SEC_JQ_Config(&jQParam);
if(NULL == *p_SecJobQueue)
{
SEC4Dump(DBGTXT_INITDEV, ("sec4_jq_init() :: SEC_JQ_Config() failed\n"));
return ERROR_CODE(E_NO_MEMORY);
}
SEC4Dump(DBGTXT_INITDEV, ("sec4_jq_init() :: *p_SecJobQueue=0x%x\n", *p_SecJobQueue));
/* Input ring configuration */
jQRingParam.len = jqIRSize;
#ifdef SEC4_USE_SHARED_JOB_QUEUE
/* Job queue rings in shared memory */
jQRingParam.memId = 1;
#else
/* Job queue rings in private memory */
jQRingParam.memId = 0;
#endif
status = SEC_JQ_ConfigInputRing(*p_SecJobQueue, &jQRingParam);
if(E_OK != status)
{
return status;
}
SEC4Dump(DBGTXT_INITDEV, ("sec4_jq_init() :: Job queue input ring size=%d\n", jQRingParam.len));
/* Output ring configuration */
jQRingParam.len = jqORSize;
status = SEC_JQ_ConfigOutputRing(*p_SecJobQueue, &jQRingParam);
if(E_OK != status)
{
return status;
}
SEC4Dump(DBGTXT_INITDEV, ("sec4_jq_init() :: Job queue output ring size=%d\n", jQRingParam.len));
/* Interrupt coalescing configuration */
jQIntrParam.jobCountThr = jqIrqCoalCnt;
jQIntrParam.ticCountThr = jqIrqCoalTime;
status = SEC_JQ_ConfigInterrupts(*p_SecJobQueue, &jQIntrParam);
if(E_OK != status)
{
return status;
}
/* Init SEC4 job queue Interface */
status = SEC_JQ_Init(*p_SecJobQueue);
if(E_OK != status)
{
return status;
}
#ifdef SEC4_USE_SHARED_JOB_QUEUE
*p_sec4JobQueueHandle = *p_SecJobQueue;
#endif
SEC4Dump(DBGTXT_INITDEV, ("sec4_jq_init() :: Job queue irq coalescing: num=%d, time=%d SEC4 clock cycles\n", jQIntrParam.jobCountThr, jQIntrParam.ticCountThr * SEC_JQ_INTR_TIC_COUNT_THR_UNITS));
return E_OK;
}
/*
****************************************************************************
* 10 PUBLIC FUNCTIONS
****************************************************************************
*/
/*************************************************************************
* Function Name: SEC4DriverInit
* Purpose: Configures and initializes the SEC4 driver and the SEC4 engine.
*
* Input: cpuId - Selects SEC4 job queue to use. Should be 0-3 (if not using shared job queue).
* cpuId should be 0 for the core that should own the SEC4 and perform basic initialization
* (corresponding to NCSW_MASTER_ID). For a single core system cpuId should always be 0.
*
* Return: SEC4_SUCCESS if everything passed, otherwise the error code
*************************************************************************/
int SEC4DriverInit(uint32_t cpuId, uint8_t jqIrqCoalCnt, uint16_t jqIrqCoalTime,
uint16_t jqIRSize, uint16_t jqORSize)
{
t_SecParam sec4Param;
t_SecDclParam secDclParam;
t_SecDclParam secDclQiParam;
t_Error status;
#ifdef _WRS_CONFIG_WRHV_GUEST
/* For physical to virtual address translation when running on top of a hypervisor */
void *vbPhys;
uint32_t attr;
uint32_t length;
vbiStatus_t ret;
vbiPhysAddr_t paddr;
#endif
/* Check prior initialization, and initialize driver per OS convention */
if (taskIdVerify (taskNameToId (SEC4_PC_TASKNAME)) == OK) {
SEC4Dump(DBGTXT_INFO, ("Security Processor already initialized\n"));
return SEC4_SUCCESS;
}
/* Init SEC4 parameters */
/* Set guestId. Only one core may "own" the SEC4 for init etc. */
#ifndef SEC4_USE_SHARED_JOB_QUEUE
if(cpuId > (SEC4X_NOOF_JOB_QUEUES - 1))
{
SEC4Dump(DBGTXT_ERROR, ("SEC4DriverInit() :: No job queue available for cpuId=%d\n", cpuId));
return SEC4_JQ_NOT_AVAIL;
}
#endif
if(cpuId == NCSW_MASTER_ID)
SEC4Dump(DBGTXT_INFO, ("SEC4DriverInit() :: This core is master of the SEC4\n"));
else
{
SEC4Dump(DBGTXT_INFO, ("SEC4DriverInit() :: This core has SEC4 guestId %d\n", cpuId));
}
sec4CoreId = cpuId;
#ifdef _WRS_CONFIG_WRHV_GUEST
/* If we are on top of a Hypervisor we need to map virtual to physical addresses */
/* Get virtual to physical address offset */
vbPhys = (void *) 1; /* Use any address here as VxWorks has the same offset for any address */
ret = vbiGuestDmaAddrGet((vbiGuestPhysAddr_t)vbPhys, &paddr);
sec4VirtualOffset = (uint32_t)((uint64_t)paddr - (uint64_t)vbPhys);
SEC4Dump(DBGTXT_INFO, ("SEC4DriverInit() :: Using 0x%x offset for virtual to physical address translation\n",((uint32_t)sec4VirtualOffset)));
/* Another offset is needed for packets TODO: Improve this solution!*/
char *name = SEC4_WRHV_SHMEM_PACKETS_NAME;
vbiShmemRegionFind((int8_t *)name, &vbPhys, &length, &attr);
sec4PacketsBase = (physAddress_t) vbPhys;
SEC4Dump(DBGTXT_INFO, ("SEC4DriverInit() :: Base address for packets is 0x%x\n",((uint32_t)sec4PacketsBase)));
ret = vbiGuestDmaAddrGet((vbiGuestPhysAddr_t)vbPhys, &paddr);
sec4VirtualOffsetPackets = (physAddress_t)((uint64_t)vbPhys - (uint64_t)paddr);
SEC4Dump(DBGTXT_INFO, ("SEC4DriverInit() :: Using 0x%x offset for virtual to physical address translation for packets\n",((uint32_t)sec4VirtualOffsetPackets)));
/* Another offset is needed for shared descriptors TODO: Improve this solution!*/
char name2[] = SEC4_WRHV_SHMEM_SHDESC_NAME;
vbiShmemRegionFind((int8_t *)name2, &vbPhys, &length, &attr);
sec4ShDescBase = (physAddress_t) vbPhys;
SEC4Dump(DBGTXT_INFO, ("SEC4DriverInit() :: Base address for shared descriptors is 0x%x\n",((uint32_t)sec4ShDescBase)));
ret = vbiGuestDmaAddrGet((vbiGuestPhysAddr_t)vbPhys, &paddr);
sec4VirtualOffsetShDesc = (physAddress_t)((uint64_t)vbPhys - (uint64_t)paddr);
SEC4Dump(DBGTXT_INFO, ("SEC4DriverInit() :: Using 0x%x offset for virtual to physical address translation for shared descriptors\n",((uint32_t)sec4VirtualOffsetShDesc)));
/* We need to get the address for accessing the Pheripheral IO devices as we are on top of a hypervisor*/
sec4DeviceBaseAddr = ((uint64_t) PERIPHERAL_BASE) + ((uint64_t)SEC4X_BASE_OFFSET);
#else
/* sysGetPeripheralBase() gets the CCSBAR from the OS */
sec4DeviceBaseAddr = ((uint64_t) sysGetPeripheralBase()) + ((uint64_t)SEC4X_BASE_OFFSET);
#endif
sec4Param.guestId = sec4CoreId;
sec4Param.baseAddr = sec4DeviceBaseAddr;
SEC4Dump(DBGTXT_INITDEV, ("SEC4DriverInit() :: SEC4 Base Address=0x%08lx\n", (uint32_t) sec4Param.baseAddr));
h_Sec4 = SEC_Config(&sec4Param);
if (NULL == h_Sec4)
{
SEC4Dump(DBGTXT_INITDEV, ("SEC4DriverInit() :: Error. SEC_Config() failed\n"));
return ERROR_CODE(E_NO_MEMORY);
}
status = SEC_Init(h_Sec4);
if (E_OK != status)
{
return status;
}
if(sec4Param.guestId != NCSW_MASTER_ID)
{
/* Wait for Master to initialize SEC4 before proceeding */
while (SEC_GetPtrSize(h_Sec4) != sizeof(uint64_t)); /* TODO Better way for this!! */
}
#if defined(SEC4_USE_QI) || defined (SEC4_USE_SHARED_JOB_QUEUE)
/* Initialize shared memory */
if((status = sec4_shm_init(sec4Param.guestId)) != E_OK)
{
return status;
}
#endif
/* Config and init DCL for jobs for job queue */
secDclParam.alignment = 4;
secDclParam.h_Sec = h_Sec4;
#ifdef SEC4_USE_SHARED_JOB_QUEUE
/* All descriptors must be accessible from master core as well (during job dequeue from SEC4) */
secDclParam.memId = 1;
#else
secDclParam.memId = 0;
#endif
secDclParam.postfixSize = 0; /* No additional data after the actual descriptor */
secDclParam.prefixSize = sizeof(t_Handle); /* Needed For h_Sec4 Handle (driver internal sec_jq.c) */
#ifdef SEC4_PREALLOC_DESC_BUF
secDclParam.descSize = SEC_DCL_DESC_MEM_BUFSIZE;
secDclParam.descBufSize = SEC_DCL_DESCBUF_MEM_BUFSIZE;
secDclParam.noofBuf = 16 + (jqIRSize + jqORSize); /* Total queue capabillities and some additional */
#endif
h_SecDcl = SEC_DCL_Config(&secDclParam);
status = SEC_DCL_Init(h_SecDcl);
if (E_OK != status)
{
SEC4Dump(DBGTXT_INITDEV, ("SEC4DriverInit() :: SEC_DCL_Init() failed\n"));
return status;
}
SEC4Dump(DBGTXT_INFO, ("SEC 4.x Security Processor Core\n"));
SEC4Dump(DBGTXT_INFO, ("SEC 4.x Driver Version %s %s %s\n", VERSION, __DATE__,__TIME__));
SEC4Dump(DBGTXT_INFO, ("SEC 4 version: %d.%d\n", SEC_GetMajRevNum(h_Sec4), SEC_GetMinRevNum(h_Sec4)));
SEC4DbgDo(DBGTXT_INITDEV, SEC_DumpRegisters(h_Sec4));
/* Initialize job queue */
status = sec4_jq_init(&h_SecJobQueue, sec4Param.guestId, jqIrqCoalCnt, jqIrqCoalTime, jqIRSize, jqORSize);
if(E_OK != status)
{
return status;
}
SEC4Dump(DBGTXT_INITDEV, ("SEC4DriverInit() :: h_SecJobQueue=0x%x\n", h_SecJobQueue));
SEC4DbgDo(DBGTXT_INITDEV, SEC_JQ_DumpRegisters(h_SecJobQueue));
#ifdef SEC4_USE_QI
/* Setup IPsec SA frame queue to core map */
if((status = sec4_fq_map_init(sec4Param.guestId)) != E_OK)
{
return status;
}
/* Config and init DCL to be used for QI related descriptors */
secDclQiParam.alignment = 4;
secDclQiParam.h_Sec = h_Sec4;
secDclQiParam.memId = 1; /* Use shared memory for shared descriptors */
secDclQiParam.postfixSize = 0; /* No additional data after the actual descriptor */
secDclQiParam.prefixSize = sizeof(t_SecPreHeader); /* Needed For pre-header, before shared descriptor */
#ifdef SEC4_PREALLOC_DESC_BUF
secDclQiParam.descSize = SEC_DCL_DESC_MEM_BUFSIZE;
secDclQiParam.descBufSize = SEC_DCL_DESCBUF_MEM_BUFSIZE;
secDclQiParam.noofBuf = sec4IpsecSaCacheNoofEntries + 8;
#endif
h_SecDclQi = SEC_DCL_Config(&secDclQiParam);
status = SEC_DCL_Init(h_SecDclQi);
if (E_OK != status)
{
return status;
}
/* Configure SEC Queue manager interface */
if(sec4Param.guestId == NCSW_MASTER_ID)
{
status = sec4_qi_init();
if(E_OK != status)
{
return status;
}
SEC4Dump(DBGTXT_INFO, ("SEC4DriverInit() :: SEC4 Queue Interface initiated\n"));
SEC4DbgDo(DBGTXT_INITDEV, SEC_QI_DumpRegisters(h_SecQi));
/* Enable SEC Queue Interface */
status = SEC_QI_Enable(h_SecQi);
if(E_OK != status)
{
return status;
}
SEC4Dump(DBGTXT_INFO, ("SEC4DriverInit() :: SEC_QI_Enabled\n"));
}
#endif
/* Init semaphores */
IOInitSemaphores();
/* Msg queue for completed jobs */
if ((status = IOInitQs(jqIRSize + jqORSize)) != SEC4_SUCCESS)
return status;
if ((status = IORegisterDriver()) != SEC4_SUCCESS)
return status;
SEC4Dump(DBGTXT_INITDEV, ("SEC4DriverInit() return SEC4_SUCCESS!\n"));
return SEC4_SUCCESS;
} /* end of DriverInit */
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/