1 /************************************************
2 * FILE: netapi_init.c
3 * Global, local initialization of NETAPI
4 *
5 * DESCRIPTION: Functions to initialize framework resources for running NETAPI
6 *
7 * REVISION HISTORY:
8 *
9 * Copyright (c) Texas Instruments Incorporated 2010-2011
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 *
15 * Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 *
18 * Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the
21 * distribution.
22 *
23 * Neither the name of Texas Instruments Incorporated nor the names of
24 * its contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 *
39 ***********************************************/
40 #include <stdint.h>
41 #include <stdio.h>
42 #include <string.h>
43 #include <sys/types.h>
44 #include <sys/stat.h>
45 #include <fcntl.h>
46 #include <sys/mman.h>
47 #include <errno.h>
48 #include <unistd.h>
50 #include <ti/drv/nwal/nwal.h>
51 #include "netapi.h"
52 #include "netapi_loc.h"
53 #include "ti/drv/nwal/nwal.h"
55 /* CSL RL includes */
56 #include <ti/csl/cslr_device.h>
57 #include <ti/csl/cslr_qm_config.h>
58 #include <ti/csl/cslr_qm_descriptor_region_config.h>
59 #include <ti/csl/cslr_qm_queue_management.h>
60 #include <ti/csl/cslr_qm_queue_status_config.h>
61 #include <ti/csl/cslr_qm_intd.h>
62 #include <ti/csl/cslr_pdsp.h>
63 #include <ti/csl/csl_qm_queue.h>
64 #include <ti/csl/cslr_cppidma_global_config.h>
65 #include <ti/csl/cslr_cppidma_rx_channel_config.h>
66 #include <ti/csl/cslr_cppidma_rx_flow_config.h>
67 #include <ti/csl/cslr_cppidma_tx_channel_config.h>
68 #include <ti/csl/cslr_cppidma_tx_scheduler_config.h>
69 #include <ti/csl/csl_cppi.h>
70 #include <ti/csl/csl_pscAux.h>
71 #include <ti/csl/csl_semAux.h>
72 #include <ti/csl/csl_cacheAux.h>
73 #include <ti/csl/csl_xmcAux.h>
74 #include <ti/drv/qmss/qmss_qm.h>
76 /* TODO verify: */
77 #define CACHE_LINESZ 64
79 #define System_printf printf
80 #define ALIGN(x) __attribute__((aligned (x)))
82 /*****************************************************************************
83 * Global Resources shared by all Cores
84 *****************************************************************************/
85 uint8_t *QMemGlobDescRam = 0;
86 uint8_t *cppiMemPaSaLinkBuf = 0;
87 uint8_t *cppiMemSaPaLinkBuf = 0;
89 /*****************************************************************************
90 * Local Resource allocated at each Core
91 *****************************************************************************/
92 /* Descriptors in global shared */
93 uint8_t *QMemLocDescRam = NULL;
94 uint8_t *cppiMemRxPktLinkBuf = NULL;
95 uint8_t *cppiMemTxPktLinkBuf = NULL;
96 uint8_t *cppiMemRxCtlLinkBuf = NULL;
97 uint8_t *cppiMemTxCtlLinkBuf = NULL;
100 //****************************************************
101 // Set up QM memory region (per SOC)
102 //***************************************************
103 int netapi_qm_setup_mem_region(
104 uint32_t numDesc,
105 uint32_t descSize,
106 uint32_t* pDescMemBase,
107 Qmss_MemRegion memRegion)
108 {
109 Qmss_MemRegInfo memInfo;
110 Int32 result;
111 Int n;
112 static int netapi_qm_region_index=0;
114 memset(&memInfo,0,sizeof(Qmss_MemRegInfo));
115 memInfo.descBase = pDescMemBase;
116 memInfo.descSize = descSize;
117 memInfo.descNum = numDesc;
118 memInfo.manageDescFlag = Qmss_ManageDesc_MANAGE_DESCRIPTOR;
119 memInfo.memRegion = memRegion;
121 if(memRegion == NETAPI_GLOBAL_REGION)
122 {
123 memInfo.startIndex = TUNE_NETAPI_QM_START_INDEX; //was 0
124 netapi_qm_region_index += numDesc;
125 }else if(memRegion ==NETAPI_LOCAL_REGION)
126 {
127 /* 2nd region for descriptors (perhaps private?) */
128 memInfo.startIndex = netapi_qm_region_index;
129 }
130 else
131 {
132 return -1 ;
133 }
135 memset (pDescMemBase, 0, (descSize * numDesc));
137 result = Qmss_insertMemoryRegion (&memInfo);
138 if (result < QMSS_SOK)
139 {
140 printf (">function setup_qm_region: Qmss_insertMemoryRegion returned error code %d\n", result);
141 return (-1);
142 }
144 return 1;
146 }
148 //****************************************************
149 // Start QM (per thread)
150 //***************************************************
151 int netapi_start_qm(void)
152 {
153 int32_t result;
154 result = Qmss_start();
155 if (result != QMSS_SOK)
156 {
157 System_printf (">start_qm: Qmss_start failed with error code %d\n", result);
158 return (-1);
159 }
160 return 1;
161 }
163 //*************************************************
164 //initialize NWAL (one per soc)
165 //*************************************************
166 /*** NWAL Memory Buffer Configuration ***/
167 #define NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_HANDLE 3400
168 uint8_t nwalInstMem[NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_HANDLE]ALIGN(CACHE_LINESZ);
170 #define NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_PER_MAC 128
171 #define NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_IPSEC_HANDLE_PER_CHAN 256
172 #define NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_PER_IP 128
173 #define NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_PER_PORT 128
174 #define NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_PER_L2L3_HDR 128
175 #define NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_PER_LOC_CONTEXT 384
176 #define NWAL_CHAN_HANDLE_SIZE ((NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_PER_MAC * TUNE_NETAPI_MAX_NUM_MAC) + \
177 (NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_IPSEC_HANDLE_PER_CHAN * TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS*2) + \
178 (NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_PER_IP * TUNE_NETAPI_MAX_NUM_IP) + \
179 (NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_PER_PORT * TUNE_NETAPI_MAX_NUM_PORTS)+ \
180 (NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_PER_LOC_CONTEXT * TUNE_NETAPI_NUM_CORES) + \
181 (NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_PER_L2L3_HDR * TUNE_NETAPI_MAX_NUM_L2_L3_HDRS))
183 uint8_t nwalHandleMem[NWAL_CHAN_HANDLE_SIZE]ALIGN(CACHE_LINESZ);
185 /* todo: Check if below size information can be made available from pa interface file */
186 #define NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF0 128
187 /* PA instance */
188 /* Memory used for the PA Instance. Needs to be assigned global uncached memory for chip */
189 uint8_t paBuf0[NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF0]ALIGN(CACHE_LINESZ);
191 /* Memory used for PA handles */
192 #define NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF1 128
193 uint8_t paBuf1[NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF1]ALIGN(CACHE_LINESZ);
195 //#define NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF2 768
196 #define NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF2 6144
197 uint8_t paBuf2[NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF2]ALIGN(CACHE_LINESZ);
199 /* Memory used for SA LLD global Handle */
200 #define NETAPI_NWAL_CONFIG_BUFSIZE_SA_LLD_HANDLE 384
201 uint8_t salldHandle[NETAPI_NWAL_CONFIG_BUFSIZE_SA_LLD_HANDLE]ALIGN(CACHE_LINESZ);
203 #if 0 //need to alloc this since we need phy addr also
204 /* Memory used for SA contet Handle */
205 #define NETAPI_NWAL_CONFIG_BUFSIZE_SA_CONTEXT_PER_CHAN 384
206 uint8_t saContext[NETAPI_NWAL_CONFIG_BUFSIZE_SA_CONTEXT_PER_CHAN * TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS]ALIGN(CACHE_LINESZ);
207 #endif
209 /* Memory used by SA LLD per Channel */
210 #define NETAPI_NWAL_CONFIG_BUFSIZE_SA_LLD_HANDLE_PER_CHAN 512
211 uint8_t salldChanHandle[NETAPI_NWAL_CONFIG_BUFSIZE_SA_LLD_HANDLE_PER_CHAN * TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS*2]ALIGN(CACHE_LINESZ);
214 /*******************************************
215 * Initialize the nwal subsystem for NETAPI use
216 ***********************************************/
217 int netapi_init_nwal(
218 int region2use,
219 Pktlib_HeapIfTable * p_table,
220 NETAPI_NWAL_GLOBAL_CONTEXT_T * p_nwal_context,
221 NETAPI_CFG_T*p_cfg )
222 {
223 nwalSizeInfo_t nwalSizeInfo;
224 nwal_RetValue nwalRetVal;
225 nwalGlobCfg_t nwalGlobCfg;
226 uint8_t count;
227 int sizes[nwal_N_BUFS];
228 int aligns[nwal_N_BUFS];
229 void* bases[nwal_N_BUFS];
230 Pktlib_HeapCfg heapCfg;
231 int32_t errCode;
233 memset(p_nwal_context,0,sizeof( NETAPI_NWAL_GLOBAL_CONTEXT_T) );
234 memset(&nwalGlobCfg,0,sizeof(nwalGlobCfg_t ) );
237 /* Initialize Buffer Pool for NetCP PA to SA packets */
238 nwalGlobCfg.pa2SaBufPool.numBufPools = 1;
239 nwalGlobCfg.pa2SaBufPool.bufPool[0].descSize = TUNE_NETAPI_DESC_SIZE;
240 nwalGlobCfg.pa2SaBufPool.bufPool[0].bufSize = p_cfg->def_heap_buf_size;
242 /* Initialize the heap configuration. */
243 memset ((void *)&heapCfg, 0, sizeof(Pktlib_HeapCfg));
244 /* Populate the heap configuration */
245 heapCfg.name = "nwal PA2SA";
246 heapCfg.memRegion = region2use;
247 heapCfg.sharedHeap = 0;
248 heapCfg.useStarvationQueue = 0;
249 heapCfg.dataBufferSize = p_cfg->def_heap_buf_size;
250 heapCfg.numPkts = TUNE_NETAPI_CONFIG_MAX_PA_TO_SA_DESC;
251 heapCfg.numZeroBufferPackets= 0;
252 heapCfg.heapInterfaceTable.data_malloc = p_table->data_malloc;
253 heapCfg.heapInterfaceTable.data_free = p_table->data_free;
254 heapCfg.dataBufferPktThreshold = 0;
255 heapCfg.zeroBufferPktThreshold = 0;
258 nwalGlobCfg.pa2SaBufPool.bufPool[0].heapHandle = p_nwal_context->pa2sa_heap=
259 Pktlib_createHeap(&heapCfg, &errCode);
260 if(nwalGlobCfg.pa2SaBufPool.bufPool[0].heapHandle == NULL)
261 {
262 printf (">Pktlib_createHeap:Heap Creation Failed for PA to SA Buffer Pool , Error Code: %d\n",errCode);
263 netapi_err_teardown();
264 return -1;
265 }
267 /* Initialize Buffer Pool for NetCP SA to PA packets */
268 nwalGlobCfg.sa2PaBufPool.numBufPools = 1;
269 nwalGlobCfg.sa2PaBufPool.bufPool[0].descSize = TUNE_NETAPI_DESC_SIZE;
270 nwalGlobCfg.sa2PaBufPool.bufPool[0].bufSize = p_cfg->def_heap_buf_size;
272 /* Populate the heap configuration */
273 heapCfg.name = "nwal SA2PA";
274 heapCfg.numPkts = TUNE_NETAPI_CONFIG_MAX_SA_TO_PA_DESC;
276 nwalGlobCfg.sa2PaBufPool.bufPool[0].heapHandle = p_nwal_context->sa2pa_heap=
277 Pktlib_createHeap(&heapCfg, &errCode);
278 if(nwalGlobCfg.sa2PaBufPool.bufPool[0].heapHandle == NULL)
279 {
280 printf (">Pktlib_createHeap:Heap Creation Failed for SA to PA Buffer Pool , Error Code: %d\n",errCode);
281 netapi_err_teardown();
282 return -1;
283 }
285 nwalGlobCfg.hopLimit = 5;/* Default TTL / Hop Limit */
286 nwalGlobCfg.paPowerOn = nwal_TRUE;
287 nwalGlobCfg.saPowerOn = nwal_TRUE;
288 nwalGlobCfg.paFwActive = nwal_TRUE;
289 nwalGlobCfg.saFwActive = nwal_FALSE;
291 /* Pick Default Physical Address */
292 nwalGlobCfg.paVirtBaseAddr = (uint32_t) netapi_VM_VirtAddr->passCfgVaddr;
293 nwalGlobCfg.saVirtBaseAddr = (uint32_t) netapi_VM_VirtAddr->passCfgVaddr +
294 ((uint32_t)CSL_PA_SS_CFG_CP_ACE_CFG_REGS - (uint32_t)CSL_PA_SS_CFG_REGS) ;
295 nwalGlobCfg.rxDefPktQ = QMSS_PARAM_NOT_SPECIFIED;
297 /* Get the Buffer Requirement from NWAL */
298 memset(&nwalSizeInfo,0,sizeof(nwalSizeInfo));
299 nwalSizeInfo.nMaxMacAddress = TUNE_NETAPI_MAX_NUM_MAC;
300 nwalSizeInfo.nMaxIpAddress = TUNE_NETAPI_MAX_NUM_IP;
301 nwalSizeInfo.nMaxL4Ports = TUNE_NETAPI_MAX_NUM_PORTS;
302 nwalSizeInfo.nMaxIpSecChannels = TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS;//we allocate 2 per channel
303 nwalSizeInfo.nMaxDmSecChannels = TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS;//we allocate 2 per channel
304 nwalSizeInfo.nMaxL2L3Hdr = TUNE_NETAPI_MAX_NUM_L2_L3_HDRS;
305 nwalSizeInfo.nProc = TUNE_NETAPI_NUM_CORES;
306 nwalRetVal = nwal_getBufferReq(&nwalSizeInfo,
307 sizes,
308 aligns);
309 if(nwalRetVal != nwal_OK)
310 {
311 printf (">netapi: init_nwal - nwal_getBufferReq Failed %d\n", nwalRetVal);
312 return nwal_FALSE;
313 }
315 /* Check for memory size requirement and update the base */
316 count = 0;
317 bases[nwal_BUF_INDEX_INST] = (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)nwalInstMem);
318 if(NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_HANDLE < sizes[nwal_BUF_INDEX_INST])
319 {
320 /* Resize Memory */
321 while(1);
322 }
323 count++;
325 bases[nwal_BUF_INDEX_INT_HANDLES] = (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)nwalHandleMem);
326 if(NWAL_CHAN_HANDLE_SIZE < sizes[nwal_BUF_INDEX_INT_HANDLES])
327 {
328 /* Resize Memory */
329 while(1);
330 }
331 count++;
332 bases[nwal_BUF_INDEX_PA_LLD_BUF0] = (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)paBuf0);
333 if((NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF0) < sizes[nwal_BUF_INDEX_PA_LLD_BUF0])
334 {
335 /* Resize Memory */
336 while(1);
337 }
338 count++;
340 bases[nwal_BUF_INDEX_PA_LLD_BUF1] = (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)paBuf1);
341 if((NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF1) < sizes[nwal_BUF_INDEX_PA_LLD_BUF1])
342 {
343 /* Resize Memory */
344 while(1);
345 }
346 count++;
348 bases[nwal_BUF_INDEX_PA_LLD_BUF2] = (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)paBuf2);
349 if((NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF2) < sizes[nwal_BUF_INDEX_PA_LLD_BUF2])
350 {
351 /* Resize Memory */
352 while(1);
353 }
354 count++;
355 #ifdef NETAPI_ENABLE_SECURITY
356 bases[nwal_BUF_INDEX_SA_LLD_HANDLE] = (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)salldHandle);
357 if((NETAPI_NWAL_CONFIG_BUFSIZE_SA_LLD_HANDLE) < sizes[nwal_BUF_INDEX_SA_LLD_HANDLE])
358 {
359 /* Resize Memory */
360 while(1);
361 }
362 count++;
364 bases[nwal_BUF_INDEX_SA_CONTEXT] = (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)netapi_VM_SaContextVaddr);
365 count++;
367 bases[nwal_BUF_INDEX_SA_LLD_CHAN_HANDLE] = (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)salldChanHandle);
368 if((NETAPI_NWAL_CONFIG_BUFSIZE_SA_LLD_HANDLE_PER_CHAN * TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS*2) <
369 sizes[nwal_BUF_INDEX_SA_LLD_CHAN_HANDLE])
370 {
371 /* Resize Memory */
372 while(1);
373 }
374 count++;
375 #else
376 bases[nwal_BUF_INDEX_SA_LLD_HANDLE] = 0;
377 bases[nwal_BUF_INDEX_SA_CONTEXT] = 0;
378 bases[nwal_BUF_INDEX_SA_LLD_CHAN_HANDLE] = 0;
379 count = count+3;
380 #endif
381 if(count != nwal_N_BUFS)
382 {
383 while(1);
384 }
386 /* Initialize NWAL module */
387 nwalRetVal = nwal_create(&nwalGlobCfg,
388 &nwalSizeInfo,
389 sizes,
390 bases,
391 &p_nwal_context->nwalInstHandle);
392 if(nwalRetVal != nwal_OK)
393 {
394 printf (">netapi: init_nwal- nwal_create Failed %d\n",nwalRetVal);
395 while(1);
396 }
398 printf(">netapi: init_nwal - Global and Local Network initialization Successful \n");
399 return 1;
400 }
402 //*************************************************
403 //* Local (per thread/core) nwal initialization0
404 //**************************************************
405 int netapi_start_nwal(Pktlib_HeapHandle pkt_heap,
406 Pktlib_HeapHandle cmd_rx_heap,
407 Pktlib_HeapHandle cmd_tx_heap,
408 NETAPI_NWAL_LOCAL_CONTEXT_T *p,
409 NETAPI_CFG_T *p_cfg,
410 NETAPI_NWAL_GLOBAL_CONTEXT_T * p_nwal_glob_context )
411 {
412 nwalLocCfg_t nwalLocCfg;
413 int count;
414 nwal_RetValue nwalRetVal;
416 memset(&nwalLocCfg,0,sizeof(nwalLocCfg));
418 /* Common Initialization for all cores */
419 while(count < TUNE_NETAPI_MAX_NUM_TRANS)
420 {
421 p_nwal_glob_context->transInfos[count].transId = count;
422 count++;
423 }
425 /* Update the Start of Packet Offset for the default flows created
426 * by NWAL
427 */
428 nwalLocCfg.rxSopPktOffset = p_cfg->def_flow_pkt_rx_offset;
429 nwalLocCfg.rxPktTailRoomSz = p_cfg->def_heap_tailroom_size;
431 /* Call back registration for the core */
432 nwalLocCfg.pRxPktCallBack = netapi_NWALRxPktCallback;
433 nwalLocCfg.pCmdCallBack = netapi_NWALCmdCallBack;
434 nwalLocCfg.pPaStatsCallBack = netapi_NWALCmdPaStatsReply;
435 nwalLocCfg.pRxDmCallBack= netapi_NWALSBPktCallback; //sideband mode callback
437 /* Initialize Buffer Pool for Control packets from NetCP to Host */
438 nwalLocCfg.rxCtlPool.numBufPools = 1;
439 nwalLocCfg.rxCtlPool.bufPool[0].descSize = TUNE_NETAPI_DESC_SIZE;
440 nwalLocCfg.rxCtlPool.bufPool[0].bufSize = TUNE_NETAPI_CONFIG_MAX_CTL_RXTX_BUF_SIZE;
441 nwalLocCfg.rxCtlPool.bufPool[0].heapHandle = cmd_rx_heap;
443 /* Initialize Buffer Pool for Control packets from Host to NetCP */
444 nwalLocCfg.txCtlPool.numBufPools = 1;
445 nwalLocCfg.txCtlPool.bufPool[0].descSize = TUNE_NETAPI_DESC_SIZE;
446 nwalLocCfg.txCtlPool.bufPool[0].bufSize = TUNE_NETAPI_CONFIG_MAX_CTL_RXTX_BUF_SIZE;
447 nwalLocCfg.txCtlPool.bufPool[0].heapHandle = cmd_tx_heap;
449 /* Initialize Buffer Pool for Packets from NetCP to Host */
450 nwalLocCfg.rxPktPool.numBufPools = 1;
451 nwalLocCfg.rxPktPool.bufPool[0].descSize = TUNE_NETAPI_DESC_SIZE;
452 nwalLocCfg.rxPktPool.bufPool[0].bufSize = p_cfg->def_heap_buf_size;
453 nwalLocCfg.rxPktPool.bufPool[0].heapHandle = pkt_heap;
455 /* Initialize Buffer Pool for Packets from Host to NetCP */
456 nwalLocCfg.txPktPool.numBufPools = 1;
457 nwalLocCfg.txPktPool.bufPool[0].descSize = TUNE_NETAPI_DESC_SIZE;
458 nwalLocCfg.txPktPool.bufPool[0].bufSize = p_cfg->def_heap_buf_size;
459 nwalLocCfg.txPktPool.bufPool[0].heapHandle = pkt_heap;
461 memcpy(&p->nwalLocCfg,&nwalLocCfg,sizeof(nwalLocCfg_t));
462 while(1)
463 {
464 nwalRetVal = nwal_start(p_nwal_glob_context->nwalInstHandle,&nwalLocCfg);
465 if(nwalRetVal == nwal_ERR_INVALID_STATE)
466 {
467 continue;
468 }
469 break;
470 }
472 if(nwalRetVal != nwal_OK)
473 {
474 printf (">nwal_start:Failed ->err %d !!!\n", nwalRetVal);
475 return -1;
476 }
477 p->state = NETAPI_NW_CXT_LOC_ACTIVE;
478 return 1;
481 }
482 //***************************************************
483 // intialize timer
484 //***************************************************
485 int netapi_init_timer(void)
486 {
487 return t64_start();
488 }