?? zl5011xptx.c
字號:
/*******************************************************************************
*
* File name: zl5011xPtx.c
*
* Version: 16
*
* Author: MRC
*
* Date created: 11/04/2002
*
* Copyright 2002, 2003, 2004, 2005, Zarlink Semiconductor Limited.
* All rights reserved.
*
* Module Description:
*
* This file contains all the functions that will initialise and control
* the Ptx block. The Ptx can manage the headers for all of the contexts
* plus a further 16 for host flows.
* For context data flows, the PTX adds a header, which is nominally the
* ethernet and IP headers (provides features to control the length and
* checksum).
* A further 16 MPID's are required for host to Lan packet transmission
* (one for each port / queue combination), and the header is not
* attached for these.
*
* Revision History:
*
* Rev: Date: Author: Comments:
* 1 11/04/2002 MRC Creation
* 2 22/04/2002 MRC The table base address register needed the value
* in 64 bit fields, that is divided by 8.
* 3 22/04/2002 MRC Fixed address problem in loop in set header fn
* 4 22/04/2002 MRC Initialised the host table entries
* 5 24/04/2002 MRC the number of context headers and the size of
* headers are now parameters to configure.
* 6 26/04/2002 MRC Changed some data names in response to comments
* from Thomas, regarding the MIB interface.
* 7 29/04/2002 MRC Changes following code review.
* 8 07/05/2002 MRC Changed enum to use uppercase
* P(acketTxHeaderModeE).
* 9 19/06/2002 MRC Updated following block change
* 10 20/06/2002 MRC Updated
* 11 31/07/2002 MRC Changed the return code for header size error in
* set header fn
* 12 31/10/2002 MRC Added variants + minor fixes
* 13 03/04/2003 MRC When a header is disabled, the length field is
* also cleared out.
* 14 09/06/2003 DJA Performed pre-audit actions
* 15 04/05/2005 APL Clear header descriptors on initialisation.
* Added zl5011xPtxEnableSrcMacOverwrite function.
* 16 06/05/2005 APL Minor fix to initialisation in zl5011xPtxConfigure
*
*******************************************************************************/
/***************** INCLUDE FILES *****************************/
#include "zl5011x.h"
#include "zl5011xPtx.h"
#include "zl5011xPtxMap.h"
#include "zl5011xUtilLib.h"
/***************** EXPORTED GLOBAL VARIABLES *****************************/
/***************** STATIC GLOBAL VARIABLES *****************************/
/*******************************************************************************
Function:
zl5011xPtxInit
Description:
This function initialises the Ptx block and data structure.
Inputs:
zl5011xParams Pointer to the structure for this device instance
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xPtxInit(zl5011xParamsS *zl5011xParams)
{
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_PTX_FN_ID, "zl5011xPtxInit:", 0, 0, 0, 0, 0, 0);
/* The PTX block itself needs no initialisation */
return(status);
}
/*******************************************************************************
Function:
zl5011xPtxConfigure
Description:
This function initialises the header descriptors. This disables header
attachment and source MAC overwrite for all normal and host contexts
Inputs:
zl5011xParams Pointer to the structure for this device instance
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xPtxConfigure(zl5011xParamsS *zl5011xParams)
{
zlStatusE status = ZL5011X_OK;
Uint32T ptxCtrlAddress;
Uint32T *ptxCtrlPtr;
Uint32T loop;
ZL5011X_TRACE(ZL5011X_PTX_FN_ID,
"zl5011xPtxConfigure:",
0, 0, 0, 0, 0, 0);
/* Get the address of the first header descriptor */
status = zl5011xPtxGetTableAddress(zl5011xParams, 0, &ptxCtrlAddress);
ptxCtrlPtr = (Uint32T*)ptxCtrlAddress;
for (loop = 0; loop < (ZL5011X_PKT_TX_NUM_CONTEXT_HEADERS + ZL5011X_PKT_TX_NUM_HOST_HEADERS) &&
(status == ZL5011X_OK); loop++)
{
/* Zero the memory using 32-bit writes.
Each descriptor is 8 bytes long so two writes required */
if (status == ZL5011X_OK)
{
status = zl5011xWrite(zl5011xParams, (Uint32T)ptxCtrlPtr, 0x00);
ptxCtrlPtr++;
}
if (status == ZL5011X_OK)
{
status = zl5011xWrite(zl5011xParams, (Uint32T)ptxCtrlPtr, 0x00);
ptxCtrlPtr++;
}
}
return(status);
}
/*******************************************************************************
Function:
zl5011xPtxEnableHeaderInsertion
Description:
Controls whether the PTX attaches a header to the data or not.
Inputs:
zl5011xParams Pointer to the structure for this device instance
tableEntry entry in the table to disable header insertion for
enable ZL5011X_TRUE to allow the PTX to add the header
ZL5011X_FALSE to pass the data through without adding a header
Outputs:
None
Returns:
zlStatusE
Remarks:
This function will not normally be used as header insertion is controlled
using zl5011xPtxSetHeader function but is retained for backward compatibility
*******************************************************************************/
zlStatusE zl5011xPtxEnableHeaderInsertion(zl5011xParamsS *zl5011xParams,
Uint32T tableEntry, zl5011xBooleanE enable)
{
zlStatusE status = ZL5011X_OK;
Uint32T tableAddr, bits, bitMask;
ZL5011X_TRACE(ZL5011X_PTX_FN_ID,
"zl5011xPtxEnableHeaderInsertion: entry %3d, enable %d",
tableEntry, enable, 0, 0, 0, 0);
/* check that the table entry is a valid number. Note host contexts do not support header insertion */
if (tableEntry >= ZL5011X_PKT_TX_NUM_CONTEXT_HEADERS)
{
status = ZL5011X_PARAMETER_INVALID;
}
if (status == ZL5011X_OK)
{
status = zl5011xPtxGetTableAddress(zl5011xParams, tableEntry, &tableAddr);
}
if (status == ZL5011X_OK)
{
/* set the bit to enable the header to be attached */
if (enable == ZL5011X_TRUE)
{
bitMask = ZL5011X_1BIT_MASK << ZL5011X_PTX_ENABLE_HEADER_BIT;
bits = bitMask;
}
else
{
/* must also clear out the length field to allow packet to be sent
without a header attached */
bits = 0;
bitMask = (ZL5011X_1BIT_MASK << ZL5011X_PTX_ENABLE_HEADER_BIT) |
(ZL5011X_PTX_HEADER_LENGTH_MASK << ZL5011X_PTX_HEADER_LENGTH_BITS);
}
status = zl5011xReadModWrite(zl5011xParams, tableAddr, bits, bitMask);
}
return(status);
}
/*******************************************************************************
Function:
zl5011xPtxEnableSrcMacOverwrite
Description:
Controls whether the PTX overwrites the outgoing packet source MAC address
with the device MAC address.
Inputs:
zl5011xParams Pointer to the structure for this device instance
context Context number for the header to control
enable ZL5011X_TRUE to make the PTX overwrite the source MAC
ZL5011X_FALSE to pass the data through with the source MAC
unchanged
Outputs:
None
Returns:
zlStatusE
Remarks:
Will normally be used only for host contexts as normal contexts are controlled
using zl5011xPtxSetHeader function
*******************************************************************************/
zlStatusE zl5011xPtxEnableSrcMacOverwrite(zl5011xParamsS *zl5011xParams,
Uint32T context, zl5011xBooleanE enable)
{
zlStatusE status = ZL5011X_OK;
Uint32T descriptorAddr, bits, bitMask;
ZL5011X_TRACE(ZL5011X_PTX_FN_ID,
"zl5011xPtxEnableSrcMacOverwrite: context %3d, enable %d",
context, enable, 0, 0, 0, 0);
/* check that the context is a valid normal or host context number */
if (context >= (ZL5011X_PKT_TX_NUM_CONTEXT_HEADERS + ZL5011X_PKT_TX_NUM_HOST_HEADERS))
{
status = ZL5011X_PARAMETER_INVALID;
}
if (status == ZL5011X_OK)
{
status = zl5011xPtxGetTableAddress(zl5011xParams, context, &descriptorAddr);
}
if (status == ZL5011X_OK)
{
bitMask = ZL5011X_1BIT_MASK << ZL5011X_PTX_SRC_ADDR_FROM_MAC_BIT;
if (enable == ZL5011X_TRUE)
{ /* set the bit to enable the MAC address to be overwritten */
bits = bitMask;
}
else
{ /* clear the bit */
bits = 0;
}
status = zl5011xReadModWrite(zl5011xParams, descriptorAddr, bits, bitMask);
}
return(status);
}
/*******************************************************************************
Function:
zl5011xPtxGetTableAddress
Description:
Returns the base address of the control header for the required context.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -