示例#1
0
PRIVATE IX_OSAL_MBUF *
ixOsalBuffPoolMbufInit (UINT32 mbufSizeAligned,
                      UINT32 dataSizeAligned,
                      IX_OSAL_MBUF_POOL *poolPtr)
{
    UINT8 *dataPtr;
    IX_OSAL_MBUF *realMbufPtr;
    /* Allocate cache-aligned memory for mbuf header */
    realMbufPtr = (IX_OSAL_MBUF *) IX_OSAL_CACHE_DMA_MALLOC (mbufSizeAligned);
    IX_OSAL_ASSERT (realMbufPtr != NULL);
    memset (realMbufPtr, 0, mbufSizeAligned);

    /* Allocate cache-aligned memory for mbuf data */
    dataPtr = (UINT8 *) IX_OSAL_CACHE_DMA_MALLOC (dataSizeAligned);
    IX_OSAL_ASSERT (dataPtr != NULL);
    memset (dataPtr, 0, dataSizeAligned);

    /* Fill in mbuf header fields */
    IX_OSAL_MBUF_MDATA (realMbufPtr) = dataPtr;
    IX_OSAL_MBUF_ALLOCATED_BUFF_DATA (realMbufPtr) = (UINT32)dataPtr;

    IX_OSAL_MBUF_MLEN (realMbufPtr) = dataSizeAligned;
    IX_OSAL_MBUF_ALLOCATED_BUFF_LEN (realMbufPtr) = dataSizeAligned;

    IX_OSAL_MBUF_NET_POOL (realMbufPtr) = (IX_OSAL_MBUF_POOL *) poolPtr;

    IX_OSAL_MBUF_SYS_SIGNATURE_INIT(realMbufPtr);

    /* update some statistical information */
    poolPtr->mbufMemSize += mbufSizeAligned;
    poolPtr->dataMemSize += dataSizeAligned;

    return realMbufPtr;
}
示例#2
0
/**
 * @ingroup IxTimeSyncAccCodelet
 *
 * @fn ixTimeSyncAccCodeletMbufAllocate ()
 *
 * @brief  Allocate memory for mBuf and its associated data buffer
 *
 * @return 
 * 	@li IX_OSAL_MBUF * - successfully allocated memory for mBuf
 *	@li NULL - fail
 */
PRIVATE IX_OSAL_MBUF  
*ixTimeSyncAccCodeletMbufAllocate ()
{
	IX_OSAL_MBUF *mBufPtr;	
	UINT8 *dataPtr;

	/* Allocate cache-aligned memory for mbuf header */
	mBufPtr = (IX_OSAL_MBUF *) IX_OSAL_CACHE_DMA_MALLOC (sizeof (IX_OSAL_MBUF));

	if (NULL == mBufPtr)
	{
		ixOsalLog (IX_OSAL_LOG_LVL_ERROR, IX_OSAL_LOG_DEV_STDERR, "ixTimeSyncAccCodeletMbufAllocate: failed to allocate memory for mBuf\n",
			0, 0, 0, 0, 0, 0);

		return NULL;
	}

	/* initialize mBuf */
	ixOsalMemSet (mBufPtr, 0, sizeof (IX_OSAL_MBUF));

	/* Allocate cache-aligned memory for mbuf data */
	dataPtr = (UINT8 *) IX_OSAL_CACHE_DMA_MALLOC (IX_TIMESYNCACC_CODELET_UDP_FRAME_LEN);

	if (NULL == dataPtr)
	{
		ixOsalLog (IX_OSAL_LOG_LVL_ERROR, IX_OSAL_LOG_DEV_STDERR, "ixTimeSyncAccCodeletMbufAllocate: failed to allocate memory for mBuf's data buffer\n",
			0, 0, 0, 0, 0, 0);

		return NULL;
	}

	/* initialize mBuf's data buffer */
	ixOsalMemSet (dataPtr, 0, IX_TIMESYNCACC_CODELET_UDP_FRAME_LEN);

	/* Fill in mbuf header fields */
	IX_OSAL_MBUF_MDATA (mBufPtr) = dataPtr;
	IX_OSAL_MBUF_ALLOCATED_BUFF_DATA (mBufPtr) = (UINT32)dataPtr;

	IX_OSAL_MBUF_MLEN (mBufPtr) = IX_TIMESYNCACC_CODELET_UDP_FRAME_LEN;
	IX_OSAL_MBUF_ALLOCATED_BUFF_LEN (mBufPtr) = IX_TIMESYNCACC_CODELET_UDP_FRAME_LEN;
	IX_OSAL_MBUF_PKT_LEN (mBufPtr) = IX_TIMESYNCACC_CODELET_UDP_FRAME_LEN;

	return mBufPtr;

} /* end of ixTimeSyncAccCodeletMbufAllocate function */
示例#3
0
/**
 * @brief allocates non-cached or contiguous NPE tree update areas for all the ports
 *
 * This function is called only once at initialization time from
 * @ref ixEthDBInit().
 *
 * @warning do not call manually
 *
 * @see ixEthDBInit()
 *
 * @internal
 */
IX_ETH_DB_PUBLIC
void ixEthDBNPEUpdateAreasInit(void)
{
    UINT32 portIndex;
    PortUpdateMethod *update;

    for (portIndex = 0 ; portIndex < IX_ETH_DB_NUMBER_OF_PORTS ; portIndex++)
    {
        update = &ixEthDBPortInfo[portIndex].updateMethod;

        if (ixEthDBPortDefinitions[portIndex].type == IX_ETH_NPE)
        {
            update->npeUpdateZone   = IX_OSAL_CACHE_DMA_MALLOC(FULL_ELT_BYTE_SIZE);
            update->npeGwUpdateZone = IX_OSAL_CACHE_DMA_MALLOC(FULL_GW_BYTE_SIZE);
            update->vlanUpdateZone  = IX_OSAL_CACHE_DMA_MALLOC(FULL_VLAN_BYTE_SIZE);

            if (update->npeUpdateZone == NULL
                || update->npeGwUpdateZone == NULL
                || update->vlanUpdateZone == NULL)
            {
                ERROR_LOG("Fatal error: IX_ACC_DRV_DMA_MALLOC() returned NULL, no NPE update zones available\n");
            }
            else
            {
                memset(update->npeUpdateZone, 0, FULL_ELT_BYTE_SIZE);
                memset(update->npeGwUpdateZone, 0, FULL_GW_BYTE_SIZE);
                memset(update->vlanUpdateZone, 0, FULL_VLAN_BYTE_SIZE);
            }
        }
        else
        {
            /* unused */
            update->npeUpdateZone   = NULL;
            update->npeGwUpdateZone = NULL;
            update->vlanUpdateZone  = NULL;
        }
    }
}
示例#4
0
void
ixHssAccCodeletChannelisedServiceConfigure (
    IxHssAccHssPort hssPortId)
{
    IX_STATUS status;
    unsigned bytesPerTSTrigger;
    UINT8 *rxCircular;
    unsigned numRxBytesPerTS;
    UINT32 *txPtrList;
    unsigned numTxPtrLists;
    unsigned numTxBytesPerBlk;
    IxHssAccChanRxCallback rxCallback;
    unsigned channelIndex;
    unsigned i;
    ClientInfo *pClientInfo = &clientInfo[hssPortId];
    ChannelInfo *pChannelInfo;
    IxOsalThreadAttr ixHssAccCodeletChanThreadAttr;

    /* initialise client infor structure for this client */
    pClientInfo->hssPortId = hssPortId;
    pClientInfo->lastTxOffset = -1;
    pClientInfo->nextRxOffset = 0;        /* 1st rxOffset we receive to */
    pClientInfo->lastRxOffset = -1;       /* initially invalid */ 
    pClientInfo->readyToLoopback = FALSE; /* no samples Rx'ed yet */

    for (channelIndex = 0;
         channelIndex < IX_HSSACC_CODELET_CHAN_NUM_CHANS;
         channelIndex++)
    {
        pChannelInfo = &pClientInfo->channelInfo[channelIndex];

        /* not receiving non-idle data yet */
        pChannelInfo->receivingNonIdleData = FALSE;

        /* initialise the tx/rx sample data values (to channel number) */
        pChannelInfo->txSampleData = channelIndex + 1;
        pChannelInfo->rxSampleData = channelIndex + 1;
    }

    /****************/
    /* START THREAD */
    /****************/

    /* initialise message queue to empty */
    pClientInfo->qHead = 0;
    pClientInfo->qTail = 0;

    /* initialise the rx semaphore */
    (void) ixOsalSemaphoreInit (
        &pClientInfo->messageSem, IX_HSSACC_CODELET_SEM_UNAVAILABLE);

    /* create the thread for processing callbacks */
    /* when running both packetised and channelised services, the */
    /* channelised service needs to be serviced in a higher priority */
    /* thread (high) than the packetised service (low) */
    ixHssAccCodeletChanThreadAttr.name = "HSS Codelet Chan CB";
    ixHssAccCodeletChanThreadAttr.stackSize = 10240;
    ixHssAccCodeletChanThreadAttr.priority = IX_HSSACC_CODELET_THREAD_PRI_HIGH;
    (void) ixOsalThreadCreate (
	&pClientInfo->threadId,                             /* threadId */
	&ixHssAccCodeletChanThreadAttr,                     /* threadAttr */
	(IxOsalVoidFnVoidPtr)ixHssAccCodeletChanThreadMain, /* startRoutine */
	pClientInfo);                                       /* arg */ 

    /* start the thread for processing callbacks */
    (void) ixOsalThreadStart (
	&pClientInfo->threadId);    /* threadId */		

    /********************/
    /* ALLOCATE BUFFERS */
    /********************/

    /* allocate channelised RX buffers */
    if (pClientInfo->rxBuffers == 0)
    {
        pClientInfo->rxBuffers = IX_OSAL_CACHE_DMA_MALLOC(
            sizeof (*pClientInfo->rxBuffers));

        if (pClientInfo->rxBuffers == 0)
        {
	    printf("Failed to allocated Rx buffers\n");
            return;
        }
    }

    /* to allow for caching, we request a cache flush after memset */
    MEMSET_AND_FLUSH (pClientInfo->rxBuffers, 0x00,
                      sizeof (*pClientInfo->rxBuffers));

    /* allocate channelised TX buffers */
    if (pClientInfo->txBuffers == 0)
    {
        pClientInfo->txBuffers = IX_OSAL_CACHE_DMA_MALLOC(
            sizeof (*pClientInfo->txBuffers));

        if (pClientInfo->txBuffers == 0)
        {
	    printf("Failed to allocated Tx buffers\n");
	    return;
        }
    }

    /* to allow for caching, we request a cache flush after memset */
    MEMSET_AND_FLUSH (pClientInfo->txBuffers, 0x00,
                      sizeof (*pClientInfo->txBuffers));

    /* allocate channelised TX pointer lists */
    if (pClientInfo->txPointers == 0)
    {
        pClientInfo->txPointers = IX_OSAL_CACHE_DMA_MALLOC(
            sizeof (*pClientInfo->txPointers));

        if (pClientInfo->txPointers == 0)
        {
	    printf("Failed to allocated Tx pointers\n");
            return;
        }
    }

    /* to allow for caching, we request a cache flush after memset */
    MEMSET_AND_FLUSH (pClientInfo->txPointers, 0x00,
                      sizeof (*pClientInfo->txPointers));

    /**********************/
    /* CONNECT TO SERVICE */
    /**********************/

    /* Bytes per timeslot trigger = 8 */
    bytesPerTSTrigger = IX_HSSACC_CODELET_CHAN_BYTES_PER_TS_TRIG;

    /* RX circular buffer = RX buffer */
    rxCircular = (UINT8 *)(*pClientInfo->rxBuffers);

    /* Number of RX bytes per timeslot = 176 (RX buf size per channel) */
    numRxBytesPerTS = IX_HSSACC_CODELET_CHAN_RX_BUFSIZE_PERCHAN;

    /* TX pointer list = TX pointer array */
    txPtrList = (UINT32 *)(*pClientInfo->txPointers);

    /* Number of TX pointer lists = 8 (latency factor) */
    numTxPtrLists = IX_HSSACC_CODELET_CHAN_TX_LATENCY_FACTOR;

    /* Number of TX bytes per block = 44 (bytes per sample) */
    numTxBytesPerBlk = IX_HSSACC_CODELET_CHAN_BYTES_PER_SAMPLE;

    /* Receive callback */
    rxCallback = ixHssAccCodeletChanRxCallback;

    /* connect this client to the Channelised Service */
    status = ixHssAccChanConnect (
        hssPortId,         /* hssPortId */
        bytesPerTSTrigger, /* bytesPerTSTrigger */
        rxCircular,        /* rxCircular */
        numRxBytesPerTS,   /* numRxBytesPerTS */
        txPtrList,         /* txPtrList */
        numTxPtrLists,     /* numTxPtrLists */
        numTxBytesPerBlk,  /* numTxBytesPerBlk */
        rxCallback);       /* rxCallback */

    /* if there was any problem then update stats */
    if (status != IX_SUCCESS)
    {
        stats[hssPortId].chan.connectFails++;
        return;
    }

    /*******************/
    /* PREPARE TX DATA */
    /*******************/

    /* prepare data for transmit */
    for (i = 1; i <= IX_HSSACC_CODELET_CHAN_TX_LATENCY_FACTOR; i++)
    {
        /* by passing in txOffsets from 1 to the tx latency factor, we */
        /* can reuse our transmit function to initially fill up the tx */
        /* buffer with data */
        ixHssAccCodeletChannelisedDataTransmit (hssPortId, i);
    }
}
示例#5
0
/*
 * Function definition: ixDmaAccCodeletInit()
 * See header file for documentation.
 */
IX_STATUS ixDmaAccCodeletInit(IxNpeDlNpeId npeId)
{
    UINT32 counter;

    /* Block reinitialisation if already done so */
    if(ixDmaAccCodeletInitialised)
    {
        printf("\nDma codelet already initialised");
	    return(IX_FAIL);
    }

    /* get the memory for source area */
    ixDmaAccCodeletSrcBlock = (UINT8*) IX_OSAL_CACHE_DMA_MALLOC(IX_DMA_CODELET_TEST_MAXLENGTH);

    /* get the memory for destination area */
    ixDmaAccCodeletDestBlock = (UINT8*) IX_OSAL_CACHE_DMA_MALLOC(IX_DMA_CODELET_TEST_MAXLENGTH);

    /* Initialise Queue Manager */
    printf("\nInitialising Queue Manager...");
    if (ixQMgrInit() != IX_SUCCESS)
    {
	    printf("\nError initialising queue manager!");
	    return (IX_FAIL);
    }
    /* Start the Queue Manager dispatcher loop :
       Parameter is TRUE for Interrupt mode else poll mode */
#ifdef __linux
    if(ixDmaAccCodeletDispatcherStart(TRUE) != IX_SUCCESS)
#else
    if(ixDmaAccCodeletDispatcherStart(FALSE) != IX_SUCCESS)
#endif
    {
	    printf("\nError starting queue manager dispatch loop!");
	    return (IX_FAIL);
    }
    /* Initialise NPE and download Image */
    printf("\nInitialising NPE %d...", npeId);
    if(ixDmaAccCodeletNpeInit(npeId) != IX_SUCCESS)
    {
	    printf("\nError initialising NPE %d!", npeId);
	    return (IX_FAIL);
    }

    /***********************************************************************
     * System initialisation done. Now initialise Dma Access component.
     ***********************************************************************/
    if (ixDmaAccInit(npeId) != IX_SUCCESS)
    {
	    printf("\nError initialising Dma access driver!");
	    return (IX_FAIL);
    }

    /* initialize the start and stop time array */
    for (counter = 0; counter < PERFORMANCE_LOOP_NUM; counter++)
    {
	ixDmaAccCodeletTimeStore.startTime[counter] = 0;
	ixDmaAccCodeletTimeStore.stopTime[counter] = 0;
    }

    ixDmaAccCodeletInitialised = TRUE;
    return (IX_SUCCESS);
}
示例#6
0
/* ----------------------------------------------------
* Initialisation
*/
IX_STATUS
ixAtmdAccDescMgmtInit (void)
{
    IX_STATUS returnStatus = IX_FAIL;
    IxAtmdAccNpeDescriptor* npeDescriptorPtr = NULL;
    void *physicalAddress;
    unsigned int descSize = 0;
    unsigned char *descPtr = NULL;
    unsigned char *descPtrAlign = NULL;

    if (!initDone)
    {
        returnStatus = ixOsalMutexInit (&descMgmtLock);
        if (returnStatus != IX_SUCCESS)
        {
            returnStatus = IX_FAIL;
        }
        else
        {
            ixAtmdAccDescMgmtStatsReset ();
            
            /* compute the size of each element and ensure descriptors are 64-byte aligned */
            /* NPE_ADDR_ALIGN is multiple of IX_OSAL_CACHE_LINE_SIZE which is 64 */
            descSize = (((sizeof (IxAtmdAccNpeDescriptor)) + (NPE_ADDR_ALIGN - 1))
                / NPE_ADDR_ALIGN)
                * NPE_ADDR_ALIGN;

            /* allocate a big buffer containing all elements */
            descPtr = IX_OSAL_CACHE_DMA_MALLOC((IX_ATMDACC_MAX_NPE_DESCRIPTORS * descSize)
                + (NPE_ADDR_ALIGN - 1));
 
	    descPtr += (NPE_ADDR_ALIGN - 1);  
	
		descPointer	=	descPtr;
        /* mask descriptor pointer with 0xffffffc0 to ensure lower 6 bits are 0*/   
         descPtrAlign = (unsigned char *)(((UINT32)descPtr) & NPE_DESCRIPTOR_MASK);


		IxAtmdDmaDescPointer = descPtrAlign;

  
            if (descPtrAlign == NULL)
            {
                returnStatus = IX_FAIL;
            }
            else
            {
                for (npeDescCount = 0;
                    (npeDescCount < IX_ATMDACC_MAX_NPE_DESCRIPTORS);
                    npeDescCount++)
                {
                    
                    /* allocate a NPE descriptor from the big buffer */
                    npeDescriptorPtr = (IxAtmdAccNpeDescriptor *)descPtrAlign;
                    descPtrAlign += descSize;

                    /* initialise the array of descriptors */
                    npeDescriptorArray[npeDescCount] = npeDescriptorPtr;
                    physicalAddress = npeDescriptorPtr;
                    IX_ATMDACC_CONVERT_TO_PHYSICAL_ADDRESS (physicalAddress);
                    npeDescriptorPtr->atmd.physicalAddress = (unsigned int)physicalAddress;
#ifndef NDEBUG
                    npeDescriptorPtr->atmd.signature = IX_ATMDACC_DESCRIPTOR_SIGNATURE;
#endif
                } /* end of for(npeDescCount) */
                if (returnStatus == IX_SUCCESS)
                {
                    initDone = TRUE;
                }
            }
        } /* end of if-else(returnStatus) */
    } /* end of if(initDone) */

    return returnStatus;
}
示例#7
0
void ixEthAccCodeletShow(void)
{
    static IxEthEthObjStats *portStats = NULL;
    UINT32 portNo;

    if (!ixEthAccCodeletInitialised)
    {
	printf("CodeletMain: Codelet is not initialized!\n");
	return;
    }

    if(portStats == NULL)
    {
	/*
	 * The statistics are gathered by the NPE therefore we use DMA_MALLOC
	 * to make it cache safe for us to read.
	 */
	if((portStats = IX_OSAL_CACHE_DMA_MALLOC(sizeof(IxEthEthObjStats))) == NULL)
	{
	    printf("CodeletMain: Unable to create port stats!\n");
	    return;
	}
    }

    for(portNo=0; portNo<IX_ETHACC_CODELET_MAX_PORT; portNo++)
    {
	if (ixEthAccCodeletHardwareExists[portNo])
	{
	    memset(portStats, 0, sizeof(IxEthEthObjStats));
	    
	    printf("\nStatistics for port %d:\n", portNo);
	    if(ixEthAccMibIIStatsGetClear(portNo, portStats) != IX_ETH_ACC_SUCCESS)
	    {
		printf("Unable to retrieve statistics for port %d!\n", portNo);
	    }
	    else
	    {
                printf (" dot3portStatsAlignmentErrors:           %u\n",
                    (unsigned) portStats->dot3StatsAlignmentErrors);
                printf (" dot3portStatsFCSErrors:                 %u\n",
                    (unsigned) portStats->dot3StatsFCSErrors);
                printf (" dot3portStatsInternalMacReceiveErrors:  %u\n",
                    (unsigned) portStats->dot3StatsInternalMacReceiveErrors);        
                printf (" RxOverrunDiscards:                      %u\n",
                    (unsigned) portStats->RxOverrunDiscards);
                printf (" RxLearnedEntryDiscards:                 %u\n",
                    (unsigned) portStats->RxLearnedEntryDiscards);
                printf (" RxLargeFramesDiscards:                  %u\n",
                    (unsigned) portStats->RxLargeFramesDiscards);
                printf (" RxSTPBlockedDiscards:                   %u\n",
                    (unsigned) portStats->RxSTPBlockedDiscards);    
                printf (" RxVLANTypeFilterDiscards:               %u\n",
                    (unsigned) portStats->RxVLANTypeFilterDiscards);
                printf (" RxVLANIdFilterDiscards:                 %u\n",
                    (unsigned) portStats->RxVLANIdFilterDiscards);
                printf (" RxInvalidSourceDiscards:                %u\n",
                    (unsigned) portStats->RxInvalidSourceDiscards);
                printf (" RxWhiteListDiscards:                    %u\n",
                    (unsigned) portStats->RxWhiteListDiscards);
                printf (" RxBlackListDiscards:                    %u\n",
                    (unsigned) portStats->RxBlackListDiscards);
                printf (" RxUnderflowEntryDiscards:               %u\n",
                    (unsigned) portStats->RxUnderflowEntryDiscards);
                printf (" dot3portStatsSingleCollisionFrames:     %u\n",
                    (unsigned) portStats->dot3StatsSingleCollisionFrames);
                printf (" dot3portStatsMultipleCollisionFrames:   %u\n",
                    (unsigned) portStats->dot3StatsMultipleCollisionFrames);
                printf (" dot3portStatsDeferredTransmissions:     %u\n",
                    (unsigned) portStats->dot3StatsDeferredTransmissions);
                printf (" dot3portStatsLateCollisions:            %u\n",
                    (unsigned) portStats->dot3StatsLateCollisions);
                printf (" dot3portStatsExcessiveCollsions:        %u\n",
                    (unsigned) portStats->dot3StatsExcessiveCollsions);
                printf (" dot3portStatsInternalMacTransmitErrors: %u\n",
                    (unsigned) portStats->dot3StatsInternalMacTransmitErrors);
                printf (" dot3portStatsCarrierSenseErrors:        %u\n",
                    (unsigned) portStats->dot3StatsCarrierSenseErrors);
                printf (" TxLargeFrameDiscards:                   %u\n",
                    (unsigned) portStats->TxLargeFrameDiscards);
                printf (" TxVLANIdFilterDiscards:                 %u\n",
                    (unsigned) portStats->TxVLANIdFilterDiscards);
                printf (" RxValidFramesTotalOctets:               %u\n",
                    (unsigned) portStats->RxValidFramesTotalOctets);
                printf (" RxUcastPkts:                            %u\n",
                    (unsigned) portStats->RxUcastPkts);
                printf (" RxBcastPkts:                            %u\n",
                    (unsigned) portStats->RxBcastPkts);
                printf (" RxMcastPkts:                            %u\n",
                    (unsigned) portStats->RxMcastPkts);
                printf (" RxPkts64Octets:                         %u\n",
                    (unsigned) portStats->RxPkts64Octets);
                printf (" RxPkts65to127Octets:                    %u\n",
                    (unsigned) portStats->RxPkts65to127Octets);
                printf (" RxPkts128to255Octets:                   %u\n",
                    (unsigned) portStats->RxPkts128to255Octets);
                printf (" RxPkts256to511Octets:                   %u\n",
                    (unsigned) portStats->RxPkts256to511Octets);
                printf (" RxPkts512to1023Octets:                  %u\n",
                    (unsigned) portStats->RxPkts512to1023Octets);
                printf (" RxPkts1024to1518Octets:                 %u\n",
                    (unsigned) portStats->RxPkts1024to1518Octets);
                printf (" RxInternalNPEReceiveErrors:             %u\n",
                    (unsigned) portStats->RxInternalNPEReceiveErrors);
                printf (" TxInternalNPETransmitErrors:            %u\n",
                    (unsigned) portStats->TxInternalNPETransmitErrors);
		printf("\n");
	    }
	}
    }
}