/**
 * @fn void ixEthAccCodeletRxSinkRxCB()
 * 
 * Recieve callback for Rx sink
 * 
 * @return void
 */
PRIVATE void 
ixEthAccCodeletRxSinkRxCB(UINT32 cbTag, IX_OSAL_MBUF** mBufPtr)
{
    while (NULL != *mBufPtr)
    {
	ixEthAccCodeletStats[cbTag].rxCount++;
	
#ifdef IX_ETHACC_CODELET_TXGENRXSINK_VERIFY
	IX_ETHACC_CODELET_DATA_VERIFY(IX_OSAL_MBUF_MDATA(*mBufPtr), compData);
	
	/* After reading the payload, invalidate it before replenish */
	IX_OSAL_CACHE_INVALIDATE(IX_OSAL_MBUF_MDATA(*mBufPtr), 
				 IX_OSAL_MBUF_MLEN(*mBufPtr));
#endif
	
	ixEthAccCodeletMbufChainSizeSet(*mBufPtr);

	/* Return mBuf to free queue on same port */
	if(ixEthAccPortRxFreeReplenish(cbTag, *mBufPtr) != IX_SUCCESS)
	{
	    ixOsalLog(IX_OSAL_LOG_LVL_ERROR, IX_OSAL_LOG_DEV_STDOUT,
		      "Error replenishing RX free q in TxGen-RxSink\n", 
		      0, 0, 0, 0, 0, 0);
	}
	/* move to next buffer received */
	mBufPtr++;
    }
}
Exemple #2
0
PUBLIC void
ixOsalMbufDataPtrReset (IX_OSAL_MBUF * bufPtr)
{
    IX_OSAL_MBUF_POOL *poolPtr;
    UINT8 *poolDataPtr;

    if (bufPtr == NULL)
    {
        ixOsalLog (IX_OSAL_LOG_LVL_ERROR, IX_OSAL_LOG_DEV_STDOUT,
            "ixOsalBuffPoolBufDataPtrReset"
            ": ERROR - Invalid Parameter\n", 0, 0, 0, 0, 0, 0);
        return;
    }

    poolPtr = (IX_OSAL_MBUF_POOL *) IX_OSAL_MBUF_NET_POOL (bufPtr);
    poolDataPtr = poolPtr->dataMemPtr;

    if (poolPtr->poolAllocType == IX_OSAL_MBUF_POOL_TYPE_SYS_ALLOC)
    {
        if (IX_OSAL_MBUF_GET_SYS_SIGNATURE(bufPtr) != IX_OSAL_MBUF_SYS_SIGNATURE)
        {
            ixOsalLog (IX_OSAL_LOG_LVL_ERROR, IX_OSAL_LOG_DEV_STDOUT,
                "ixOsalBuffPoolBufDataPtrReset"
                ": invalid mbuf, cannot reset mData pointer\n", 0, 0,
                0, 0, 0, 0);
            return;
        }
        IX_OSAL_MBUF_MDATA (bufPtr) = (UINT8*)IX_OSAL_MBUF_ALLOCATED_BUFF_DATA (bufPtr);
    }
    else
    {
        if (poolDataPtr)
        {
            unsigned int bufSize = poolPtr->bufDataSize;
            unsigned int bufDataAddr =
                (unsigned int) IX_OSAL_MBUF_MDATA (bufPtr);
            unsigned int poolDataAddr = (unsigned int) poolDataPtr;

            /*
             * the pointer is still pointing somewhere in the mbuf payload.
             * This operation moves the pointer to the beginning of the 
             * mbuf payload
             */
            bufDataAddr = ((bufDataAddr - poolDataAddr) / bufSize) * bufSize;
            IX_OSAL_MBUF_MDATA (bufPtr) = &poolDataPtr[bufDataAddr];
        }
        else
        {
            ixOsalLog (IX_OSAL_LOG_LVL_WARNING, IX_OSAL_LOG_DEV_STDOUT,
                "ixOsalBuffPoolBufDataPtrReset"
                ": cannot be used if user supplied NULL pointer for pool data area "
                "when pool was created\n", 0, 0, 0, 0, 0, 0);
            return;
        }
    }

}
Exemple #3
0
PRIVATE void
ixOamChildLbCellRx (IxAtmLogicalPort port, IX_OSAL_MBUF *rxMbuf)
{
    UINT32 pti;
    UINT32 vpi;
    UINT32 vci;
    UINT32 oamHdr = 0x0;
    IxOamITU610Cell *rxCell;
    IxOamITU610LbPayload *lbPayload;

    rxCell = (IxOamITU610Cell *)(IX_OSAL_MBUF_MDATA(rxMbuf));

    /* Read the VPI, VCI & Payload Type */
    IX_OAM_HEADER_GET(rxCell, oamHdr);
    vci = IX_OAM_VCI_GET(oamHdr);
    vpi = IX_OAM_VPI_GET(oamHdr);
    pti = IX_OAM_PTI_GET(oamHdr);

    /* Check if the VPI, VCI and Port match */
    if ((vpi == lbVpi) && (vci == lbVci) && (port == (IxAtmLogicalPort)lbPort))
    {
	/* Check if F4 flow (F4 VCI) or PTI matches */
	if ((vci == IX_OAM_ITU610_F4_SEG_VCI) || (vci == IX_OAM_ITU610_F4_ETE_VCI) || (pti == lbPti))
	{
	    /* Setup the data pointers */
	    lbPayload = &(((IxOamITU610Cell *)(IX_OSAL_MBUF_MDATA(rxMbuf)))->payload.lbPayload);
	    
	    /* Source Id correct, all Ones supported only in this codelet */
	    if ( ixOamMemCmp(lbPayload->sourceId, (UCHAR *)allOnesLocId, IX_OAM_ITU610_LOCATION_ID_LEN) == 0 )
	    {
		/* Correlation tag correct? */
		if ( ixOamMemCmp(lbPayload->correlationTag, (UCHAR *)(&lbCorrelationTag), IX_OAM_ITU610_LB_CORRELATION_TAG_LEN) == 0)
		{
		    /* Notify user that a ping has been successful,
		     * N.B. the user is not notified if ping has failed
		     */
		    IX_OAM_CODELET_LOG ("OAM ping reply for VPI:%u VCI:%u PTI:%u on Port:%u\n",
						 lbVpi, lbVci, lbPti, lbPort);

		    /* free the buffer */
		    ixAtmUtilsMbufFree (rxMbuf);
		    childLbCellRxCount[port]++;
		    return;
		}
	    }
	}
    }

    /* free the buffer */
    ixAtmUtilsMbufFree (rxMbuf);
    childLbCellRxErrCount[port]++;
}
Exemple #4
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;
}
Exemple #5
0
PRIVATE void 
ixTimeSyncAccCodeletMbufsFree ()
{
	UINT32 count;
	IX_OSAL_MBUF *mBufPtr;	
	UINT8 *dataPtr;

	/* free mBufs */
	for (count = 0; count < IX_TIMESYNCACC_CODELET_MAX_TS_CHANNELS; count++)
	{
		mBufPtr = ixTimeSyncAccCodeletGlobalMBuf[count];

		if (NULL != mBufPtr)
		{
			dataPtr = (UINT8 *) IX_OSAL_MBUF_MDATA (mBufPtr);	
			if (NULL != dataPtr)
			{
				IX_OSAL_CACHE_DMA_FREE (dataPtr);
			}
			IX_OSAL_CACHE_DMA_FREE (mBufPtr); 

			ixTimeSyncAccCodeletGlobalMBuf[count] = NULL;
		}
	}
	
} /* end of ixTimeSyncAccCodeletMbufsFree function */
Exemple #6
0
/* ---------------------------------------------------
*/
PRIVATE void
ixOamRxInvalidate(IX_OSAL_MBUF * mbufPtr)
{
   while (mbufPtr != NULL)
      {
      IX_OSAL_CACHE_INVALIDATE(IX_OSAL_MBUF_MDATA(mbufPtr), IX_OSAL_MBUF_MLEN(mbufPtr));
      mbufPtr = IX_OSAL_MBUF_NEXT_BUFFER_IN_PKT_PTR(mbufPtr);
       }
    return;
}
Exemple #7
0
/* ---------------------------------------------------
*/
PRIVATE void
ixOamTxFlush(IX_OSAL_MBUF * mbufPtr)
{
    while (mbufPtr != NULL)
    {
      IX_OSAL_CACHE_FLUSH(IX_OSAL_MBUF_MDATA(mbufPtr), IX_OSAL_MBUF_MLEN(mbufPtr));
      mbufPtr = IX_OSAL_MBUF_NEXT_BUFFER_IN_PKT_PTR(mbufPtr);
    }
    return;
}
Exemple #8
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 */
Exemple #9
0
/*
 * Reuse the received parent LB cell
 * and modify some of the fields
 */
PRIVATE IX_STATUS
ixOamChildLbCellTx (IxAtmLogicalPort port, IX_OSAL_MBUF *rxMbuf)
{    
    IxOamITU610Cell *txCell;
    IxOamITU610LbPayload *lbPayload;
    IX_STATUS retval = IX_FAIL;
    UINT32 lockKey;

    /* Setup a pointer to the cell data */
    txCell = (IxOamITU610Cell *) IX_OSAL_MBUF_MDATA(rxMbuf);
        
    /* Setup pointers to Lb fields */
    lbPayload = &(txCell->payload.lbPayload);
    
    /* Change the loopback indication flag */
    IX_OAM_LOOPBACK_INDICATION_SET(lbPayload, IX_OAM_ITU610_LB_INDICATION_CHILD);

    /* Set the LLID to the CPID */
    ixOamMemCpy(lbPayload->llid, oamCpid, IX_OAM_ITU610_LOCATION_ID_LEN);

    /* flush the mbuf from cache */
    ixOamTxFlush( rxMbuf );

    /* Transmit the cell, not reentrant on a VC basis so protect */
    lockKey = ixOsalIrqLock();
    retval =  ixOamTxAndRetry (oamTxConnId[port],
			       rxMbuf,
			       0, /* CLP 0 */
			       1); /* Cells per packet */
    ixOsalIrqUnlock (lockKey);

    if (retval == IX_SUCCESS)
    {
	/* Increment the loopback out counter */
	childLbCellTxCount[port]++;
    }
    else
    {
	/* Release the MBUF */
	ixAtmUtilsMbufFree (rxMbuf);
    }

    return retval;
}
Exemple #10
0
PRIVATE void
ixOamParentLbCellRx (IxAtmLogicalPort port, IX_OSAL_MBUF *rxMbuf)
{     
    /* Loopback location ID correct? */
    if (ixOamRxLlidCheck (((IxOamITU610Cell *)(IX_OSAL_MBUF_MDATA(rxMbuf)))) == IX_SUCCESS)
    {
	parentLbCellRxCount[port]++;

	/* Send loopback child cell back to originator */
	ixOamChildLbCellTx (port, rxMbuf);
    }
    else
    {
	parentLbCellRxErrCount[port]++;

	/* free the buffer */
	ixAtmUtilsMbufFree (rxMbuf);
    }
}
Exemple #11
0
/**
 * @fn ixCryptoQAccessReqDoneQMgrCallback
 * @brief Notification callback registered with QManager. Once the 
 *        threshold of the interrupt source is reached, the notification
 *        callback is triggered and is executed.
 *
 */
void 
ixCryptoQAccessReqDoneQMgrCallback (
    IxQMgrQId queueId, 
    IxQMgrCallbackId callbackId)
{
    UINT32 messageCount = 0;
    IxCryptoQDescriptor *pQDesc = NULL;
    IX_OSAL_MBUF *pSrcMbuf;
    IX_OSAL_MBUF *pDestMbuf;
    UINT32 operationResult;
    UINT32 cryptoCtxId;
    IX_STATUS qStatus;
    IxCryptoAccStatus status;
    UINT32 npeOperation;
    BOOL useDiffBuf = FALSE;
    UINT8 *tempIcvAddr = NULL;
    UINT32 keyId;

    do
    {
        /* Read queue entry from hardware queue */
        qStatus = ixQMgrQRead (queueId, &operationResult);
        
        /* Check if the queue read operation pass */
        if (IX_SUCCESS == qStatus)
        {
            /* Count how many messages got this callback */
            messageCount++;
    
            /* Reset src mbuf and dest mbuf pointers to NULL */
            pSrcMbuf = NULL;
            pDestMbuf = NULL;
            
            pQDesc = (IxCryptoQDescriptor *)
                        (operationResult & IX_CRYPTO_Q_DESC_ADDR_MASK);
    
            /* Convert Q descriptor pointer from physical address to virtual
             * address
             */
            pQDesc = (IxCryptoQDescriptor *) 
                        IX_CRYPTO_PHYSICAL_TO_VIRTUAL_TRANSLATION(
                            (UINT32) pQDesc);
                         
            if (NULL != pQDesc) /* if pQDesc not NULL */
            {       
                /* Invalidate Q descriptor message in cache */
                IX_CRYPTO_DATA_CACHE_INVALIDATE (pQDesc, 
                                  sizeof (IxCryptoQDescriptor));
            
                cryptoCtxId = pQDesc->cryptoCtxId; /* Get Crypto Context ID */
        
                /* Check if the source mbuf is NULL */
                if (NULL != pQDesc->pSrcMbuf)
                {
                    /* Convert mbuf header and its contents from NPE format
                     * to host format
                     */
                    pSrcMbuf = ixCryptoUtilMbufFromNpeFormatConvert (
                                   pQDesc->pSrcMbuf);
                } /* end of if (pQDesc->pSrcMbuf) */
            
                /* Check if the destination mbuf is NULL */ 
                if (NULL != pQDesc->pDestMbuf)
                {
                    /* Convert mbuf header and its contents from NPE 
                     * format to host format
                     */
                    pDestMbuf = ixCryptoUtilMbufFromNpeFormatConvert (
                                    pQDesc->pDestMbuf);
                } /* end of if (pQDesc->pDestMbuf) */

                /* Get NPE operation from Q descriptor */
                npeOperation 
                    = ((pQDesc->npeQDesc.npeOperationMode.npeOperation
                           & (~IX_CRYPTO_NPE_OP_TRANSFER_MODE_MASK)) 
                           & MASK_8_BIT);
                
                if (IX_CRYPTO_NPE_OP_TRANSFER_MODE_IS_IN_PLACE 
                    != (pQDesc->npeQDesc.npeOperationMode.npeOperation
                    & IX_CRYPTO_NPE_OP_TRANSFER_MODE_MASK))
                {
                    /* set to TRUE if non in-place operation */
                    useDiffBuf = TRUE;
                }
            
                /* Switch case based on NPE operation. Tasks need to be 
                 * executed in the callback context depending on the NPE 
                 * operation completed.
                 * 1. Check if the ICV is in the middle of data. If the ICV
                 *    is in the middle of data and the NPE operation is 
                 *    IX_CRYPTO_NPE_OP_HMAC_VER_ICV or 
                 *    IX_CRYPTO_NPE_OP_HMAC_VER_ICV_DECRYPT; copy the original 
                 *    ICV value from queue descriptor and write it back to 
                 *    source and/or destination mbuf (depends on transfer 
                 *    mode) based on the original ICV offset stored in queue 
                 *    descriptor.
                 */                
                switch (npeOperation)
                {
                    /* HMAC verification only, or combined service with
                     * HMAC verification operation. Notes : the code for 
                     * HMAC verification fall thorugh to combined service
                     * IX_CRYPTO_NPE_OP_HMAC_VER_ICV_DECRYPT
                     */
                    case IX_CRYPTO_NPE_OP_HMAC_VER_ICV:
                    case IX_CRYPTO_NPE_OP_HMAC_VER_ICV_DECRYPT:
                        
                        pQDesc->npeQDesc.authStartOffset
                           = IX_CRYPTO_CONVERT_SHORT_TO_HOST_ORDER (
                             pQDesc->npeQDesc.authStartOffset);
  
                        pQDesc->npeQDesc.authLength 
                           = IX_CRYPTO_CONVERT_SHORT_TO_HOST_ORDER (
                             pQDesc->npeQDesc.authLength);

                        /* If ICV in the middle of data */
                        if ((pQDesc->value.originalIcvOffset >= 
                            (UINT32)(pQDesc->npeQDesc.authStartOffset)) &&
                            (pQDesc->value.originalIcvOffset <
                            ((UINT32)pQDesc->npeQDesc.authStartOffset + 
                            (UINT32)pQDesc->npeQDesc.authLength)))
                        {
                            /* Get ICV address from source mbuf */
                            tempIcvAddr = (UINT8 *)
                                ixCryptoUtilMbufOffsetToAddressConvert (
                                pSrcMbuf,
                                pQDesc->value.originalIcvOffset,
                                FALSE);
                                    
                            /* Restore ICV value into source mbuf */        
                            ixOsalMemCopy (
                                tempIcvAddr, 
                                pQDesc->integrityCheckValue,
                                ixCryptoCtx[cryptoCtxId].digestLength);
                        } /* end of if (pQDesc->value.originalIcvOffset) */
                        
                        if (useDiffBuf) /* If non in-place operation */
                        {
                            /* Restore ICV value into destination mbuf */
                            ixOsalMemCopy (
                                (UINT8 *) (IX_OSAL_MBUF_MDATA (pDestMbuf) + 
                                pQDesc->value.originalIcvOffset), 
                                pQDesc->integrityCheckValue,
                                ixCryptoCtx[cryptoCtxId].digestLength);
                        }                        
                        break;
                        
                    /* Convert back the aadAddr */
                    case  IX_CRYPTO_NPE_OP_CCM_GEN_MIC:
                    case  IX_CRYPTO_NPE_OP_CCM_VER_MIC:

                        /* Convert the aadAddr to host byte order*/
                        pQDesc->npeQDesc.aadAddr 
                                = IX_CRYPTO_CONVERT_WORD_TO_HOST_ORDER (
                                       pQDesc->npeQDesc.aadAddr);

                        /* Convert the aadAddr from physical to virtual address */
                        pQDesc->npeQDesc.aadAddr 
                            = (UINT32)IX_CRYPTO_PHYSICAL_TO_VIRTUAL_TRANSLATION (
                                   pQDesc->npeQDesc.aadAddr);   
                        break;

                    /* Encrypt/Decrypt only operation, HMAC generation only, 
                     * or combined service with HMAC generation operation 
                     * - Do nothing
                     */
                    default :
                        break;
                } /* end of switch case (npeOperation) */                    
                        
                /* Check Authentication status */
                if (IX_CRYPTO_NPE_OP_AUTH_FAIL 
                    != (operationResult & IX_CRYPTO_NPE_OP_STATUS_MASK)) /* pass */
                {                
                    /* Increment counter for number of requests completed
                     * successfully without error 
                     */
                    ixCryptoStats.cryptoSuccessCounter++;

                    /* Check NPE operation status flag to determine which
                     * callback function to be called
                     */
                    switch (pQDesc->operStatus)
                    {
                        /* Crypto Perform operation */
                        case IX_CRYPTO_OP_PERFORM:
            
                            /* Crypto Perform operation completed successfully */
                            status =  IX_CRYPTO_ACC_STATUS_SUCCESS;
                                    
                            /* Crypto Perform operation, call the perform 
                             * complete callback function
                             */
                            ixCryptoCtx[cryptoCtxId].performCallbackFn(
                                cryptoCtxId,
                                pSrcMbuf, 
                                pDestMbuf,
                                status);
                                        
                            break;
                
                            /* Crypto Register operation */
                        case IX_CRYPTO_OP_REGISTER:

                            /* If reverse AES key generated, need to copy the
                             * AES key into the crypto param in ixCryptoCtx for
                             * crypto perform service
                             */
                            if (IX_CRYPTO_ACC_REV_AES_KEY_VALID ==
                                (ixCryptoCtx[cryptoCtxId].validAndKeyId &
                                IX_CRYPTO_ACC_REV_AES_KEY_VALID))
                            {
                                /* Invalidate crypto context to get updated primary
                                 * and secondary chaining variables
                                 */
                                IX_CRYPTO_DATA_CACHE_INVALIDATE (
                                    ixCryptoCtx[cryptoCtxId].pNpeCryptoParam,
                                    IX_CRYPTO_NPE_CRYPTO_PARAM_SIZE);

                                keyId = ixCryptoCtx[cryptoCtxId].validAndKeyId & MASK_8_BIT;

                                /* Invalidate key crypto param to get reverse
                                 * AES key
                                 */
                                IX_CRYPTO_DATA_CACHE_INVALIDATE (
                                    ixKeyCryptoParam[keyId].pNpeCryptoParam,
                                    IX_CRYPTO_NPE_CRYPTO_PARAM_SIZE);

                                /* Copy rever AES key from key Crypto Param into
                                 * ixCryptoCtx
                                 */
                                ixOsalMemCopy (
                                    &((ixCryptoCtx[cryptoCtxId].pNpeCryptoParam)
                                    ->npeCryptoInfo[IX_CRYPTO_NPE_CRYPTO_PARAM_CRYPTO_CFG_WORD_LEN]),
                                    &((ixKeyCryptoParam[keyId].pNpeCryptoParam)
                                    ->npeCryptoInfo[IX_CRYPTO_NPE_CRYPTO_PARAM_CRYPTO_CFG_WORD_LEN]),
                                    ixKeyCryptoParam[keyId].keyLength);

                                /* Flush NPE Crypto Param structure from cache
                                 * into SDRAM
                                 */
                                IX_CRYPTO_DATA_CACHE_FLUSH (
                                    ixCryptoCtx[cryptoCtxId].pNpeCryptoParam,
                                    IX_CRYPTO_NPE_CRYPTO_PARAM_SIZE);

                                 /* Release key crypto param */
                                 status = ixCryptoCCDMgmtKeyCryptoParamRelease (
                                            keyId);
                            }

                            /* Crypto Register operation completed successfully */
                            status =  IX_CRYPTO_ACC_STATUS_SUCCESS;

                            /* Mark valid bit in Crypto Context to indicate the
                             * Crypto Context has been registered successfully
                             */
                            ixCryptoCtx[cryptoCtxId].valid = TRUE;

                            /* Crypto Register operation, call the register
                             * complete callback function
                             */
                            ixCryptoCtx[cryptoCtxId].registerCallbackFn(
                                cryptoCtxId,
                                pSrcMbuf,
                                status);
                                    
                            break;
                                 
                            /* Crypto Register Operation */
                        case IX_CRYPTO_OP_WAIT:
                                 
                            /* Crypto Register operation, part of the operation 
                             * completed only, wait for next completion 
                             * indication, and release the buffer
                             */
                            status = IX_CRYPTO_ACC_STATUS_WAIT;
                
                            /* Crypto Register operation, call the register 
                             * complete callback function
                             */
                            ixCryptoCtx[cryptoCtxId].registerCallbackFn(
                                cryptoCtxId,
                                pSrcMbuf,
                                status);

                            break;

                        /* Hash key generation operation */
                        case IX_CRYPTO_OP_HASH_GEN_KEY:

                            /* get keyId from QDesc */
                            keyId = pQDesc->value.keyId;

                            /* Hash key generation operation completed 
                             * successfully 
                             */
                            status =  IX_CRYPTO_ACC_STATUS_SUCCESS;

                            /* Hash key generation operation, call the hash key
                             * generation complete callback function
                             */
                            ixKeyCryptoParam[keyId].hashKeyCallbackFn(
                                keyId,
                                pSrcMbuf,
                                status);

                            /* Release key crypto param */
                            status = ixCryptoCCDMgmtKeyCryptoParamRelease (
                                         keyId);

                            break;

                            /* Default error case, the code should not reach this
                             * default case in normal operation
                             */
                        default:
                            status = IX_CRYPTO_ACC_STATUS_FAIL;

                            /* Log error message in debugging mode */
                            IX_CRYPTO_ACC_LOG(
                                IX_OSAL_LOG_LVL_ERROR,
                                IX_OSAL_LOG_DEV_STDERR,
                                "Wrong NPE Operation status for CryptoCtx %d\n",
                                cryptoCtxId,
                                0, 0, 0, 0, 0);
                                    
                            break;
                                                    
                    } /* end of switch case (pQDesc->OperStatus) */
                }
                else /* Authentication operation failed */
                {
                    status = IX_CRYPTO_ACC_STATUS_AUTH_FAIL;
                        
                    /* Increment counter for number of requests completed 
                     * but operation failed 
                     */
                    ixCryptoStats.cryptoFailCounter++;
                        
                    /* Logging error message in debugging mode */
                    IX_CRYPTO_ACC_LOG(
                        IX_OSAL_LOG_LVL_MESSAGE, 
                        IX_OSAL_LOG_DEV_STDOUT,
                        "Authentication operation failed.\n",
                        0, 0, 0, 0, 0, 0);
                            
                    /* Call client's perform complete callback function,
                     * the callback function is registered during the Crypto 
                     * Context registration process.
                     * Note: Perform compleet callback is always called for the 
                     * case with AuthStatus == Q_DESC_OPERATION_FAIL as only the
                     * crypto perform request with operation authentication will
                     * have this status.
                     */
                    ixCryptoCtx[cryptoCtxId].performCallbackFn(
                        cryptoCtxId,
                        pSrcMbuf, 
                        pDestMbuf,
                        status);
                                  
                } /* end of if-else (AuthStatus) */
                    
                /* Release Q descriptor back to descriptor pool */
                if (IX_CRYPTO_ACC_STATUS_SUCCESS != 
                    ixCryptoDescMgmtQDescriptorRelease (pQDesc))
                {
                    /* Log error message in debugging mode */
                    IX_CRYPTO_ACC_LOG(
                        IX_OSAL_LOG_LVL_ERROR,
                        IX_OSAL_LOG_DEV_STDERR, 
                        "Q descriptor release failed for Crypto Ctx %d.\n",
                        cryptoCtxId,
                        0, 0, 0, 0, 0);
                }
                        
                /* Increment counter in the Crypto Context to keep track the 
                 * number of requests have been completed, log the number even 
                 * if operation failed
                 * Note : Only Increment the counter for crypto register and
                 *        crypto perform request, as hash key generation will
                 *        not have a valid cryptoCtxId
                 */
                if (IX_CRYPTO_OP_HASH_GEN_KEY != pQDesc->operStatus)
                {
                    ixCryptoCtx[cryptoCtxId].reqDoneCount++;
                }
            }
            else /* if pQDesc is NULL */
            {
                /* Increment counter for number of Q descriptor address received
                 * is NULL
                 */
                ixCryptoStats.qDescAddrInvalidCounter++;
                    
                /* Logging error message in debugging mode */
                IX_CRYPTO_ACC_LOG(
                    IX_OSAL_LOG_LVL_ERROR,
                    IX_OSAL_LOG_DEV_STDERR,
                    "Q desc read from Crypto Done Q is NULL\n",
                    0, 0, 0, 0, 0, 0);
            } /* end of if-else (pQDesc) */
        }
        else /* Else for if (qStatus != IX_SUCCESS) */
        {
            if (IX_QMGR_Q_UNDERFLOW == qStatus )
            {
                /* 
                 * Underflow. Only error if this first time in loop
                 * Log with statistics
                 */
                if (0 == messageCount)
                {
                    ixCryptoStats.qUnderflowCounter++;
                }
            }
            else /* queue read failed */
            {
                /* Logging error message in debugging mode */
                IX_CRYPTO_ACC_LOG(
                    IX_OSAL_LOG_LVL_ERROR,
                    IX_OSAL_LOG_DEV_STDERR,
                    "Queue read failed with status %d.\n",
                    qStatus,
                    0, 0, 0, 0, 0);
            }
        } /* End of if (qStatus != IX_SUCCESS) */        
    } while (IX_SUCCESS == qStatus);

} /* end of ixCryptoQAccessReqDoneQMCallback () function */
Exemple #12
0
/**
 * @ingroup IxTimeSyncAccCodelet
 *
 * @fn ixTimeSyncAccCodeletPTPMsgTransmit ()
 *
 * @brief  Transmit Sync message from master port and Delay_Req message
 *	   from slave port every 2 seconds.  
 *
 * @return void
 */
PRIVATE void
ixTimeSyncAccCodeletPTPMsgTransmit ()
{
	IX_OSAL_MBUF *mBufPtr;
	IxEthAccPortId portId = 0; 
	IxTimeSyncAcc1588PTPPort tsChannel;
	IxTimeSyncAcc1588PTPMsgType txMsgType;
	IxTimeSyncAcc1588PTPPortMode tsChannelMode;

	/* clear PTP message transmission halt flag */
	ixTimeSyncAccCodeletTxHalt = FALSE;

	for (tsChannel = IX_TIMESYNCACC_NPE_A_1588PTP_PORT; 
	     tsChannel < IX_TIMESYNCACC_CODELET_MAX_TS_CHANNELS; 
	     tsChannel++)
	{
		
		portId = ixTimeSyncAccCodeletPortIdList[tsChannel];
		tsChannelMode = ixTimeSyncAccCodeletConfigPtr->tsChannelMode[tsChannel];
		txMsgType = ixTimeSyncAccCodeletPTPMsgTypeList[tsChannelMode]; 
	
		/* build PTP message */
		ixTimeSyncAccCodeletPTPMsgBuild (txMsgType);

		if (IX_SUCCESS != ixTimeSyncAccCodeletPortConfigure (portId))
		{
			ixOsalLog (IX_OSAL_LOG_LVL_ERROR, IX_OSAL_LOG_DEV_STDERR, "ixTimeSyncAccCodeletPTPMsgTransmit: failed to configure port %d\n", 
				portId, 0, 0, 0, 0, 0);

			/* terminate time sync codelet execution */
			ixTimeSyncAccCodeletUninit ();

			return;
		}
   
		if (IX_ETH_ACC_SUCCESS != ixEthAccPortEnable (portId))
		{
			ixOsalLog (IX_OSAL_LOG_LVL_ERROR, IX_OSAL_LOG_DEV_STDERR, "ixTimeSyncAccCodeletPTPMsgTransmit: failed to enable port %d\n", 
				portId, 0, 0, 0, 0, 0);
			
			/* terminate time sync codelet execution */
			ixTimeSyncAccCodeletUninit ();

			return;
		} 

		mBufPtr = ixTimeSyncAccCodeletGlobalMBuf[portId];

		if (NULL == mBufPtr)
		{
	  		ixOsalLog (IX_OSAL_LOG_LVL_ERROR, IX_OSAL_LOG_DEV_STDERR, "ixTimeSyncAccCodeletPTPMsgTransmit: NULL mBuf pointer, port Id %d\n", 
				portId, 0, 0, 0, 0, 0);

			/* terminate time sync codelet execution */
			ixTimeSyncAccCodeletUninit ();

			return;
		}
		
		/* copy PTP message data to mBuf's data buffer */	
		ixOsalMemCopy (IX_OSAL_MBUF_MDATA(mBufPtr), 
			ixTimeSyncAccCodeletPtpMsgData, 
			IX_TIMESYNCACC_CODELET_UDP_FRAME_LEN);

	} /* end of for loop */

	if (IX_SUCCESS != ixOsalSemaphoreInit (&ixTimeSyncAccCodeletSemId, IX_TIMESYNCACC_CODELET_MAX_TS_CHANNELS))
	{
		ixOsalLog (IX_OSAL_LOG_LVL_ERROR, IX_OSAL_LOG_DEV_STDERR, "ixTimeSyncAccCodeletPTPMsgTransmit: failed to create semaphore\n",
			0, 0, 0, 0, 0, 0);
		
		/* terminate time sync codelet execution */
		ixTimeSyncAccCodeletUninit ();

		return;
	}
	
	do 
	{
		/* halt PTP message transmission */
		if (TRUE == ixTimeSyncAccCodeletTxHalt)
		{
			ixOsalLog (IX_OSAL_LOG_LVL_USER, IX_OSAL_LOG_DEV_STDOUT, "ixTimeSyncAccCodeletPTPMsgTransmit: PTP message transmission was halted\n",
				0, 0, 0, 0, 0, 0);

			return;
		}

		/* sleep and wait for interval time to elapse before transmitting next PTP message */
		ixOsalSleep (IX_TIMESYNCACC_CODELET_PTP_MSG_XMIT_INTERVAL);

		for (portId = IX_ETH_PORT_1; portId <= IX_ETH_PORT_3; portId++)
		{
			if (IX_SUCCESS != ixOsalSemaphoreWait (&ixTimeSyncAccCodeletSemId, IX_TIMESYNCACC_CODELET_PTP_MSG_XMIT_INTERVAL))
			{
				ixOsalLog (IX_OSAL_LOG_LVL_ERROR, IX_OSAL_LOG_DEV_STDERR, "ixTimeSyncAccCodeletPTPMsgTransmit: PTP message transmission error at port %d\n",
					portId, 0, 0, 0, 0, 0);
				
				/* terminate time sync codelet execution */
				ixTimeSyncAccCodeletUninit ();

				return;
	
			}

			if (IX_ETH_ACC_SUCCESS != ixEthAccPortTxFrameSubmit (portId, 
									ixTimeSyncAccCodeletGlobalMBuf[portId], 
									IX_ETH_ACC_TX_DEFAULT_PRIORITY))
			{
				ixOsalLog (IX_OSAL_LOG_LVL_ERROR, IX_OSAL_LOG_DEV_STDERR, "ixTimeSyncAccCodeletPTPMsgTransmit: failed to transmit PTP message from port %d\n", 
					portId, 0, 0, 0, 0, 0);

				
				/* terminate time sync codelet execution */
				ixTimeSyncAccCodeletUninit ();

				return;
			}
		} /* end of for loop */
				
	} while (TRUE);

} /* end of ixTimeSyncAccCodeletPTPMsgTransmit function */
Exemple #13
0
/*
 *
 * Transmit loopback parent cell
 */
PRIVATE IX_STATUS
ixOamParentLbCellTx (IxAtmLogicalPort port, UINT32 vpi, UINT32 vci, UINT32 pti)
{    
    IxOamITU610Cell *txCell;
    IxOamITU610LbPayload *lbPayload;
    IX_OSAL_MBUF *txMbuf;
    IX_STATUS retval = IX_FAIL;
    UINT32 lockKey;
    UINT32 oamHdr = 0x0;

    /* Get a Tx mbuf */
    ixAtmUtilsMbufGet(IX_ATM_OAM_CELL_SIZE_NO_HEC, &txMbuf);
    if (txMbuf != NULL)
    {		
	/* set the packet header len */
	IX_OSAL_MBUF_PKT_LEN(txMbuf) = IX_OSAL_MBUF_MLEN(txMbuf);

	txCell = (IxOamITU610Cell *)(IX_OSAL_MBUF_MDATA(txMbuf));

	/* Setup shortcut pointers */
	lbPayload = &(txCell->payload.lbPayload);
	
	/* Set the OAM function type to LB */
	IX_OAM_TYPE_AND_FUNC_SET(lbPayload, IX_OAM_ITU610_TYPE_FAULT_MAN_LB);
	
	/* Setup the loopback indication */
	IX_OAM_LOOPBACK_INDICATION_SET(lbPayload, IX_OAM_ITU610_LB_INDICATION_PARENT);
	
	/* Increment the correlation tag and write this into the cell */
 	lbCorrelationTag++;
	ixOamMemCpy(lbPayload->correlationTag, (UCHAR *)(&lbCorrelationTag), IX_OAM_ITU610_LB_CORRELATION_TAG_LEN);
	
	/* Set Loopback Location Id */
	ixOamMemCpy(lbPayload->llid, allOnesLocId, IX_OAM_ITU610_LOCATION_ID_LEN);
	
	/* Store the source Id as the CPID */
	ixOamMemCpy(lbPayload->sourceId, oamCpid, IX_OAM_ITU610_LOCATION_ID_LEN);
	
	/* Set the reserved fields to 0x6a */
	ixOamMemSet(lbPayload->reserved, 
		    IX_OAM_ITU610_RESERVED_BYTE_VALUE, 
		    IX_OAM_ITU610_LB_RESERVED_BYTES_LEN);
	
	/* Set the transmit VPI */
	IX_OAM_VPI_SET(oamHdr, vpi);

	/* Set the transmit VCI TX Vci */
	IX_OAM_VCI_SET(oamHdr, vci);
	
	/* Set the PTI */
	IX_OAM_PTI_SET(oamHdr, pti);

	/* Set the header in buffer */
	IX_OAM_HEADER_SET(txCell, oamHdr);

        /* flush the mbuf frm cache */
        ixOamTxFlush( txMbuf );

	/* Transmit the cell, not reentrant on a VC basis so protect */
	lockKey = ixOsalIrqLock();
	retval = ixOamTxAndRetry (oamTxConnId[port],
			          txMbuf,
			          0,  /* CLP 0 */
			          1); /* Cells per packet */
	ixOsalIrqUnlock (lockKey);

	if (retval == IX_SUCCESS)
	{
	    /* Increment the loopback out counter */
	    parentLbCellTxCount[port]++;
	}
	else
	{
	    /* Release the MBUF */
	    ixAtmUtilsMbufFree (txMbuf);
	}
    }
    else
    {
	IX_OAM_CODELET_IRQ_SAFE_LOG_ERROR("ixOamParentLbCellTx: Failed to get a buffer for transmit");
    }

    return retval;
}
Exemple #14
0
PUBLIC IX_OSAL_MBUF_POOL *
ixOsalNoAllocPoolInit (void *poolBufPtr,
    void *poolDataPtr, UINT32 count, UINT32 size, const char *name)
{
    UINT32 i,  mbufSizeAligned, sizeAligned;
    IX_OSAL_MBUF *currentMbufPtr = NULL;
    IX_OSAL_MBUF *nextMbufPtr = NULL;
    IX_OSAL_MBUF_POOL *poolPtr = NULL;

    /*
     * check parameters 
     */
    if (poolBufPtr == NULL)
    {
        ixOsalLog (IX_OSAL_LOG_LVL_ERROR,
            IX_OSAL_LOG_DEV_STDOUT,
            "ixOsalNoAllocPoolInit(): "
            "ERROR - NULL poolBufPtr \n", 0, 0, 0, 0, 0, 0);
        return NULL;
    }

    if (count <= 0)
    {
        ixOsalLog (IX_OSAL_LOG_LVL_ERROR,
            IX_OSAL_LOG_DEV_STDOUT,
            "ixOsalNoAllocPoolInit(): "
            "ERROR - count must > 0   \n", 0, 0, 0, 0, 0, 0);
        return NULL;
    }

    if (name == NULL)
    {
        ixOsalLog (IX_OSAL_LOG_LVL_ERROR,
            IX_OSAL_LOG_DEV_STDOUT,
            "ixOsalNoAllocPoolInit(): "
            "ERROR - NULL name ptr  \n", 0, 0, 0, 0, 0, 0);
        return NULL;
    }

    if (strlen (name) > IX_OSAL_MBUF_POOL_NAME_LEN)
    {
        ixOsalLog (IX_OSAL_LOG_LVL_ERROR,
            IX_OSAL_LOG_DEV_STDOUT,
            "ixOsalNoAllocPoolInit(): "
            "ERROR - name length should be no greater than %d  \n",
            IX_OSAL_MBUF_POOL_NAME_LEN, 0, 0, 0, 0, 0);
        return NULL;
    }

    poolPtr = ixOsalPoolAlloc ();

    if (poolPtr == NULL)
    {
        return NULL;
    }

    /*
     * Adjust sizes to ensure alignment on cache line boundaries 
     */
    mbufSizeAligned =
        IX_OSAL_MBUF_POOL_SIZE_ALIGN (sizeof (IX_OSAL_MBUF));
    /*
     * clear the mbuf memory area 
     */
    memset (poolBufPtr, 0, mbufSizeAligned * count);

    if (poolDataPtr != NULL)
    {
        /*
         * Adjust sizes to ensure alignment on cache line boundaries 
         */
        sizeAligned = IX_OSAL_MBUF_POOL_SIZE_ALIGN (size);
        /*
         * clear the data memory area 
         */
        memset (poolDataPtr, 0, sizeAligned * count);
    }
    else
    {
        sizeAligned = 0;
    }

    /*
     * initialise pool fields 
     */
    strcpy ((poolPtr)->name, name);

    poolPtr->dataMemPtr = poolDataPtr;
    poolPtr->mbufMemPtr = poolBufPtr;
    poolPtr->bufDataSize = sizeAligned;
    poolPtr->totalBufsInPool = count;
    poolPtr->mbufMemSize = mbufSizeAligned * count;
    poolPtr->dataMemSize = sizeAligned * count;

    currentMbufPtr = (IX_OSAL_MBUF *) poolBufPtr;

    poolPtr->nextFreeBuf = currentMbufPtr;

    for (i = 0; i < count; i++)
    {
        if (i < (count - 1))
        {
            nextMbufPtr =
                (IX_OSAL_MBUF *) ((unsigned) currentMbufPtr +
                mbufSizeAligned);
        }
        else
        {                       /* last mbuf in chain */
            nextMbufPtr = NULL;
        }
        IX_OSAL_MBUF_NEXT_BUFFER_IN_PKT_PTR (currentMbufPtr) = nextMbufPtr;
        IX_OSAL_MBUF_NET_POOL (currentMbufPtr) = poolPtr;

        IX_OSAL_MBUF_SYS_SIGNATURE_INIT(currentMbufPtr);

        if (poolDataPtr != NULL)
        {
            IX_OSAL_MBUF_MDATA (currentMbufPtr) = poolDataPtr;
            IX_OSAL_MBUF_ALLOCATED_BUFF_DATA(currentMbufPtr) = (UINT32) poolDataPtr;

            IX_OSAL_MBUF_MLEN (currentMbufPtr) = sizeAligned;
            IX_OSAL_MBUF_ALLOCATED_BUFF_LEN(currentMbufPtr) = sizeAligned;

            poolDataPtr = (void *) ((unsigned) poolDataPtr + sizeAligned);
        }

        currentMbufPtr = nextMbufPtr;
    }

    /*
     * update the number of free buffers in the pool 
     */
    poolPtr->freeBufsInPool = count;

    poolPtr->poolAllocType = IX_OSAL_MBUF_POOL_TYPE_USER_ALLOC;

    return poolPtr;
}
Exemple #15
0
PRIVATE void 
ixOamCellRxTask( void )
{
    IxOamITU610Cell *rxCell;
    UINT32 pti;
    UINT32 vci;
    UINT32 vpi;
    UINT32 oamRxHdr=0x0;

    IX_OSAL_MBUF *rxMbuf;

    int port;

    while(1)
    {
        for( port=0; port<ixOamCodeletNumPorts; port++ )
        {
            if(!ixOamQueueEmptyQuery(&ixOamSwQueue[port]))
            {
                rxMbuf = ixOamMBufQueueGet(&ixOamSwQueue[port]);
                IX_OSAL_ASSERT( rxMbuf != NULL );
    
                /* invalidate cache */
                ixOamRxInvalidate( rxMbuf );
                
                rxCell = (IxOamITU610Cell *)(IX_OSAL_MBUF_MDATA(rxMbuf));
                
                /* Read the VCI & Payload Type */
		IX_OAM_HEADER_GET(rxCell, oamRxHdr);
		vci = IX_OAM_VCI_GET(oamRxHdr);
		vpi = IX_OAM_VPI_GET(oamRxHdr);
		pti = IX_OAM_PTI_GET(oamRxHdr);
                
                /* Ensure access layer delivered a correct OAM cell */
                IX_OSAL_ASSERT ((vci == IX_OAM_ITU610_F4_SEG_VCI) || (vci == IX_OAM_ITU610_F4_ETE_VCI) || 
                           (pti == IX_OAM_ITU610_F5_ETE_PTI) || (pti == IX_OAM_ITU610_F5_SEG_PTI));                
                
                /* Is it an Loopback cell ? */
                if ( (IX_OAM_TYPE_AND_FUNC_GET(rxCell)) == IX_OAM_ITU610_TYPE_FAULT_MAN_LB )
                {
                    /* Is Parent Loopback Indication field in cell set? */
                    if ( (IX_OAM_LOOPBACK_INDICATION_GET(rxCell)) == IX_OAM_ITU610_LB_INDICATION_PARENT )
                    {
                        ixOamParentLbCellRx (port, rxMbuf);
                    }
                    /* Otherwise child cell, i.e. response to loopback cell sent earlier */
                    else 
                    {
                        ixOamChildLbCellRx(port, rxMbuf);
                    }
                }
                else
                {
                    unsupportedOamRxCount[port]++;
                    /* free the buffer */
                    ixAtmUtilsMbufFree (rxMbuf);
                }
            }
        }
    
	/* share the CPU */
        ixOsalSleep(IX_OAM_RX_QUEUE_POLL_INTERVAL);
    }
}
PRIVATE IX_STATUS 
ixEthAccCodeletTxGenRxSinkStart(IxEthAccPortId portId)
{
    IX_OSAL_MBUF *mBufPtr;
    UINT32 numBufs;
    IxEthDBStatus status;

    /* port transmits as fast as possible and drops rx traffic */
    if (ixEthAccCodeletPortConfigure(portId,
				     NULL,
				     ixEthAccCodeletRxSinkRxCB, 
				     ixEthAccCodeletTxGenTxCB,
				     portId)
	!= IX_ETH_ACC_SUCCESS)
    {
	printf("Loopbacks: Failed to start the Tx-Gen Rx-Sink Operation port %u\n",
	       (UINT32)portId);
	return IX_FAIL;
    }

    /* Disable MAC learning and filtering at the port that sinks the frame. 
       With learning enabled at both ports, TxGenRxSink will report buffer underrun and overruns 
       as this mode generates a heavy load of MAC address migrations in the learning/filtering 
       database. 
     */
    status = ixEthDBFeatureEnable (portId, IX_ETH_DB_FILTERING, FALSE);
    if (IX_ETH_DB_SUCCESS == status)
    {
        status = ixEthDBFeatureEnable (portId, IX_ETH_DB_LEARNING, FALSE); 
    }

    if (IX_ETH_DB_SUCCESS == status)
    {
        printf("\nMAC learning & filtering are disabled at port %d\n", portId);
        printf("This is to prohibit the MAC address from being migrated back and forth\n");
        printf("between two connected ports in the learning/filtering database.\n\n");
    }
    else
    {
        printf("\nFailed to disable MAC learning & filtering at port %d.\n", portId);
        printf("TxGenRxSink will report buffer underrun and overruns as this mode generates \n");
        printf("a heavy load of MAC address migrations in the learning/filtering database. \n");
        printf("With learning enabled at both ports, buffer underrun and overruns are expected.\n");
    }

    /* Generate our random data for the payload */
    IX_ETHACC_CODELET_DATAGEN(compData);
	
    /* Now start the loopback by transmitting the first few frames */
    for (numBufs=0; numBufs<IX_ETHACC_CODELET_TXGEN_PCKS; numBufs++)
    {
	IX_ETHACC_CODELET_REMOVE_MBUF_FROM_Q_HEAD(ixEthAccCodeletFreeBufQ,
						  mBufPtr);
	
	if (mBufPtr == NULL)
	{
	    printf("Loopbacks: Buffer queue empty. Not enough free buffers to transmit in TxGen-RxSink Loopback!\n");
	    return (IX_FAIL);
	}
	
	IX_OSAL_MBUF_MLEN(mBufPtr) = IX_ETHACC_CODELET_TXGEN_PCK_LEN;
	IX_OSAL_MBUF_PKT_LEN(mBufPtr) = IX_ETHACC_CODELET_TXGEN_PCK_LEN;
	
	memcpy(IX_OSAL_MBUF_MDATA(mBufPtr), 
	       &compData[0], 
	       IX_ETHACC_CODELET_TXGEN_PCK_LEN);
	
	IX_OSAL_CACHE_FLUSH(IX_OSAL_MBUF_MDATA(mBufPtr), 
				IX_OSAL_MBUF_MLEN(mBufPtr));
	
	if(ixEthAccPortTxFrameSubmit(portId, 
				     mBufPtr,
				     IX_ETH_ACC_TX_DEFAULT_PRIORITY)
	   != IX_ETH_ACC_SUCCESS)
	{
	    printf("Loopbacks: Error Submitting frame for transmission on port %u\n",
		   portId);
	    return (IX_FAIL);
	}
    }
    printf("Port %d Tx pool has %d buffers\n", portId, numBufs);

    /* enable traffic */
    if(ixEthAccPortEnable(portId) 
       != IX_ETH_ACC_SUCCESS)
    {
	printf("Loopbacks: Error Enabling port %u\n",
	       (UINT32)portId);
	return (IX_FAIL);
    }

    return (IX_SUCCESS);
}
Exemple #17
0
/*
 *Function :ixHssAccPktRxFreeReplenish
 */
IX_STATUS 
ixHssAccPktRxFreeReplenish (IxHssAccHssPort hssPortId, 
                IxHssAccHdlcPort hdlcPortId, 
                IX_OSAL_MBUF *buffer)
{
    /* This function may be called from within an ISR */
    IX_STATUS status = IX_SUCCESS;
 
    UINT32 qEntry = 0; 

    IX_HSSACC_TRACE0 (IX_HSSACC_FN_ENTRY_EXIT, "Entering "
                      "ixHssAccPktRxFreeReplenish \n");

    /* Check that the client is connected */
    if (ixHssAccPCMCheckReplenishOk (hssPortId, hdlcPortId))
    {

        /* Set up the NPE shared region of the IX_OSAL_BUF buffer */
        IX_HSSACC_IX_NE_SHARED_STATUS(buffer) = (UINT8) IX_HSSACC_PKT_OK;
        IX_HSSACC_IX_NE_SHARED_PKT_LEN(buffer) = (UINT16) 0;
        IX_HSSACC_IX_NE_SHARED_DATA(buffer) = (UINT8 *)IX_HSSACC_PKT_MMU_VIRT_TO_PHY(IX_OSAL_MBUF_MDATA(buffer));
        IX_HSSACC_IX_NE_SHARED_LEN(buffer) = (UINT16) IX_OSAL_MBUF_MLEN(buffer);
        IX_HSSACC_IX_NE_SHARED_NEXT(buffer) = (UINT32 *) NULL;
        IX_HSSACC_IX_NE_SHARED_ERR_CNT(buffer) = (UINT8) 0;

        /* Endian conversion is performed on the NPE shared region of the buffer */
        IX_HSSACC_IX_NE_ENDIAN_SWAP(buffer);
        
        /* The cache is flushed for the NPE shared region of the buffer */
        IX_HSSACC_IX_NE_SHARED_CACHE_FLUSH(buffer);

        /* Form the Q entry and Write it to the appropriate RxFree Q*/
        qEntry = (UINT32) IX_HSSACC_PKT_MMU_VIRT_TO_PHY (IX_HSSACC_IX_NE_SHARED(buffer));
        qEntry |= (hdlcPortId & IX_HSSACC_QM_Q_CHAN_NUM_MASK);
        status = ixQMgrQWrite (ixHssAccPCMRxFreeQIdGet (hssPortId, hdlcPortId),
                               &qEntry);

        if (status != IX_SUCCESS)
        {
            if (status == IX_FAIL)
            {
                IX_HSSACC_REPORT_ERROR ("ixHssAccPktRxFreeReplenish:"
                            "Writing a queue entry to the RXFREE"
                            " Queue failed\n");
                ixHssAccPktRxStats.rxFreeQWriteFails++;
            }
            else if (status == IX_QMGR_Q_OVERFLOW)
            {
                ixHssAccPktRxStats.rxQWriteOverflows++;
      		status = IX_HSSACC_Q_WRITE_OVERFLOW;
            }
            return status;
        } /* end of if (status != IX_SUCCESS)*/

        /* Increment the number of buffers in use count for the client by one*/
        ixHssAccPCMnoBuffersInUseCountInc (hssPortId, hdlcPortId, 1); 

    ixHssAccPktRxStats.rxFreeReplenishs++;
    }
    else
    {
    IX_HSSACC_REPORT_ERROR ("ixHssAccPktRxFreeReplenish:"
                "Called ixHssAccPktRxInternalFreeBufReplenish "
                "on a port that is not connected\n");
    return IX_FAIL;
    }
   
    IX_HSSACC_TRACE0 (IX_HSSACC_FN_ENTRY_EXIT, "Exiting "
              "ixHssAccPktRxFreeReplenish \n");
    return status;
}