⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ixhssaccpdm.c

📁 有关ARM开发板上的IXP400网络驱动程序的源码以。
💻 C
📖 第 1 页 / 共 2 页
字号:
     */    if (!(poolInfo->descPool[poolInfo->freeIndex]->descInUse))    {	/*	 * Descriptor pools are statically allocated for each client. 	 * The hssPortId, the hdlcPortId and the poolType are used to 	 * index into the array of pools.	 */	*desc = poolInfo->descPool[poolInfo->freeIndex];	(*desc)->descInUse = TRUE;	poolInfo->stats.gets++;	descsInUse = poolInfo->stats.gets - poolInfo->stats.frees;	/* Update the Max value if maxInUse has been broken*/	if (poolInfo->stats.maxInUse < descsInUse)	{	    poolInfo->stats.maxInUse = descsInUse;	}       /*	* Is the freeIndex at the end of the array? 	* if not, just increment it, if it is, 	* move freeIndex to start of the array 	* Do this by calculating the base address of the 	* array to the current pointer 	* and comparing it to the total num of descriptors in the pool.	*/	poolInfo->freeIndex = ++(poolInfo->freeIndex) % 	    IX_HSSACC_PKT_NUM_DESCS_PER_POOL;    }    else    {	poolInfo->stats.errs++;	IX_HSSACC_DEBUG_OFF (	    IX_HSSACC_REPORT_ERROR_WITH_ARG ("ixHssAccPDMDescGet: freeIndex desc in use - "					     "Hdlc[%d] - Out of descriptors\n",					     hdlcPortId,					     0, 0, 0, 0, 0));	return IX_HSSACC_RESOURCE_ERR;    }        IX_HSSACC_DEBUG_OFF (IX_HSSACC_TRACE0 (IX_HSSACC_FN_ENTRY_EXIT, "Exiting "					   "ixHssAccPDMDescGet\n"));    return status;}/** * Function definition: ixHssAccPDMDescFree  */void ixHssAccPDMDescFree (IxHssAccPDMDescriptor *desc, 		     IxHssAccPDMPoolType poolType){    /* This function may be called from within an ISR */    unsigned int index1;    unsigned poolIndex = (desc->hssPortId * IX_HSSACC_PKT_NUM_POOLS_PER_HSS) +	(desc->hdlcPortId * IX_HSSACC_PKT_NUM_POOLS_PER_CLIENT) + poolType;    IxHssAccPDMPoolInfo *poolInfo = &ixHssAccPDMPoolInfo[poolIndex];           /* Freeing of descriptors:       When freeing descriptors it is important to consider that one        descriptor received contains a chain of mbufs, and these mbufs        will have come from a single descriptor each.  So rather than        freeing just a single descriptor it is necessary to free the        following 'chaincount' descriptors also. This done as follows:       Go from the first desc index forward the num of mbuf that was        on the first desc as follows...        Start at the first desc pulled off the Q, the index of this in        the array is firstDescIndex and go forward the number of mbufs       chained to that descriptor, marking free that number of descriptors,       because that is the number of descriptors used by this packet.       The mod in the array index is to enable wrap around */    for (index1 = desc->descIndex;	 index1 <= (desc->descIndex + (desc->npeDesc.chainCount)); index1++)    {	if (poolInfo->descPool[index1 % IX_HSSACC_PKT_NUM_DESCS_PER_POOL]->descInUse)	{	    poolInfo->descPool[index1 % IX_HSSACC_PKT_NUM_DESCS_PER_POOL]->descInUse = 		FALSE;	    poolInfo->stats.frees++;	}	else	{	    poolInfo->stats.errs++;	}    }    }/** * Function definition: ixHssAccPDMNumDescInUse */unsigned ixHssAccPDMNumDescInUse (IxHssAccHssPort hssPortId, 			 IxHssAccHdlcPort hdlcPortId){    /* This function may be called from within an ISR */    unsigned index1 = 0;    unsigned descsInUse = 0;    unsigned poolIndex = (hssPortId * IX_HSSACC_PKT_NUM_POOLS_PER_HSS) +	(hdlcPortId * IX_HSSACC_PKT_NUM_POOLS_PER_CLIENT);    IxHssAccPDMPoolInfo *poolInfo = &ixHssAccPDMPoolInfo[poolIndex];    IX_HSSACC_DEBUG_OFF (IX_HSSACC_TRACE0 (IX_HSSACC_FN_ENTRY_EXIT, "Entering"					   " ixHssAccPDMNumDescInUse\n"));            /* While we havent gone past the max number of desc in the array AND       * the desc at this index isnt in use, AND the desc at the same index      * in the next pool arent in use increment the index by 1.       * The 2 adjacent pools belong to the same client, one for Tx and 1 for Rx.     * So eventually we will either find an in use descriptor or we will      * reach the array end. */    while (index1 < IX_HSSACC_PKT_NUM_DESCS_PER_POOL)    {	/* check tx pool */	if (poolInfo->descPool[index1]->descInUse)	{	    descsInUse++;	}	/* check rx pool */	if ((poolInfo + 1)->descPool[index1]->descInUse)	{	    descsInUse++;	}	index1++;    }        IX_HSSACC_DEBUG_OFF (IX_HSSACC_TRACE0 (IX_HSSACC_FN_ENTRY_EXIT, "Exiting "					   "ixHssAccPDMNumDescInUse\n"));    return descsInUse;}IX_OSAL_MBUF *ixHssAccPDMMbufToNpeFormatConvert (IX_OSAL_MBUF *mbufPtr){    IX_OSAL_MBUF *mbufChainPtr;    IX_OSAL_MBUF *mbufTemp;    int iterationCount;    mbufChainPtr = mbufPtr;    /* convert the pointer to the first mbuf */    mbufPtr = (IX_OSAL_MBUF *) IX_HSSACC_PKT_MMU_VIRT_TO_PHY (mbufPtr);    /* iterate through the mbuf chain */    iterationCount = 0;    while (mbufChainPtr)    {        iterationCount++;        /* check about possible mbuf infinite chain or loop */        /* save the next pointer */        mbufTemp = IX_OSAL_MBUF_NEXT_BUFFER_IN_PKT_PTR(mbufChainPtr);        /* convert the current mbuf header */        IX_OSAL_MBUF_NEXT_BUFFER_IN_PKT_PTR(mbufChainPtr) = (IX_OSAL_MBUF *)            IX_HSSACC_PKT_MMU_VIRT_TO_PHY (	        IX_OSAL_MBUF_NEXT_BUFFER_IN_PKT_PTR(mbufChainPtr));	        IX_OSAL_MBUF_MDATA(mbufChainPtr) = (UINT8 *)            IX_HSSACC_PKT_MMU_VIRT_TO_PHY (IX_OSAL_MBUF_MDATA(mbufChainPtr));        /* endian conversion for the mbuf header */	IX_HSSACC_ENDIAN_MBUF_SWAP(mbufChainPtr);        /* force data to be stored in physical memory */        IX_HSSACC_PKT_DATA_CACHE_FLUSH(mbufChainPtr, sizeof(*mbufChainPtr));        /* next element */        mbufChainPtr = mbufTemp;    }    return (mbufPtr);}IX_OSAL_MBUF *ixHssAccPDMMbufFromNpeFormatConvert (IX_OSAL_MBUF *mbufPtr,                                     BOOL invalidateCache){    IX_OSAL_MBUF *mbufChainPtr;    int iterationCount;    /* convert the pointer to the first mbuf */    mbufPtr = (IX_OSAL_MBUF *) IX_HSSACC_PKT_MMU_PHY_TO_VIRT (mbufPtr);    mbufChainPtr = mbufPtr;    /* iterate through the mbuf chain */    iterationCount = 0;    while (mbufChainPtr)    {        iterationCount++;        /* check about possible mbuf infinite chain or loop */        if (invalidateCache)        {            /* force data to be read from physical memory */            IX_HSSACC_PKT_DATA_CACHE_INVALIDATE(mbufChainPtr,                                                 sizeof(*mbufChainPtr));        }        /* endian conversion for the mbuf header */	IX_HSSACC_ENDIAN_MBUF_SWAP(mbufChainPtr);        /* convert the current mbuf header */        IX_OSAL_MBUF_NEXT_BUFFER_IN_PKT_PTR(mbufChainPtr) =	    (IX_OSAL_MBUF *) IX_HSSACC_PKT_MMU_PHY_TO_VIRT (	        IX_OSAL_MBUF_NEXT_BUFFER_IN_PKT_PTR(mbufChainPtr));        IX_OSAL_MBUF_MDATA(mbufChainPtr) = 	    (UINT8 *) IX_HSSACC_PKT_MMU_PHY_TO_VIRT (IX_OSAL_MBUF_MDATA(mbufChainPtr));	        /* next element */        mbufChainPtr = IX_OSAL_MBUF_NEXT_BUFFER_IN_PKT_PTR(mbufChainPtr);    }    return (mbufPtr);}/** * Function definition: ixHssAccPDMShow */void ixHssAccPDMShow (void){    IxHssAccHssPort hssPortId;    IxHssAccHdlcPort hdlcPortId;    IxHssAccPDMPoolType poolType;    unsigned poolIndex;    unsigned availIndex;    unsigned avail = 0;    IxHssAccPDMPoolInfo *poolInfo = &ixHssAccPDMPoolInfo[0];    /* check that the pools have been setup */    if (poolInfo->descPool[0] == NULL)    {	return;    }    printf ("\nixHssAccPDMShow:\n");    printf ("     Pool           Total  Avail BlkSize  Freelist    Gets    Frees   MaxOut     Errs\n");    printf ("=====================================================================================\n");    for (poolIndex = 0; poolIndex < maxNumPools;	poolIndex++, avail = 0)    {	hssPortId = (IxHssAccHssPort) (poolIndex / IX_HSSACC_PKT_NUM_POOLS_PER_HSS);	hdlcPortId = (IxHssAccHdlcPort) ((poolIndex / IX_HSSACC_PKT_NUM_POOLS_PER_CLIENT) %                                          IX_HSSACC_HDLC_PORT_MAX);	poolType = (IxHssAccPDMPoolType) (poolIndex % IX_HSSACC_PKT_NUM_POOLS_PER_CLIENT);	for (availIndex = 0; availIndex < IX_HSSACC_PKT_NUM_DESCS_PER_POOL;	     availIndex++)	{	    if (poolInfo->descPool[availIndex]->descInUse == FALSE)	    {		avail++;	    }	}	printf (" HSS[%d] HDLC[%d] %s %5d %5d",		hssPortId,		hdlcPortId,		poolType == IX_HSSACC_PDM_TX_POOL ? "TX" : "RX",		IX_HSSACC_PKT_NUM_DESCS_PER_POOL,		avail);	printf (" %7d    %p %8d %8d %8d %8d\n",		(int) sizeof (IxHssAccPDMDescriptor),#if (CPU!=SIMSPARCSOLARIS)		poolInfo->descPool[poolInfo->freeIndex],#else		(UINT32 *) 0x0, /* don't want to see the addr on UT */#endif		poolInfo->stats.gets,		poolInfo->stats.frees,		poolInfo->stats.maxInUse,		poolInfo->stats.errs);	poolInfo++;    }}/** * Function definition: ixHssAccPDMStatsInit */void ixHssAccPDMStatsInit (IxHssAccHssPort hssPortId, 		      IxHssAccHdlcPort hdlcPortId){    unsigned i;    unsigned poolIndex = (hssPortId * IX_HSSACC_PKT_NUM_POOLS_PER_HSS) + 	(hdlcPortId * IX_HSSACC_PKT_NUM_POOLS_PER_CLIENT);    for (i = 0; i < IX_HSSACC_PKT_NUM_POOLS_PER_CLIENT; i++)    {	/* initialise all pools for this client */	ixHssAccPDMPoolStatsInit (poolIndex + i);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -