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

📄 dot3ah.h

📁 在freescale 的ne64上开发的源代码
💻 H
📖 第 1 页 / 共 2 页
字号:
#ifndef INCLUDE_DOT3AH_H
#define INCLUDE_DOT3AH_H

#if 0
#pragma MESSAGE DISABLE C1106 /* WARNING C1106: Non-standard bitfield type */
#pragma OPTION ADD V30toV31Compatible "-BfaGapLimitBits4294967295" /*this guarantee correct bitfield positions*/
#endif

#define STATUS UINT8
#ifndef OK
#define OK     TRUE
#endif
#ifndef ERROR
#define ERROR  FALSE
#endif
#define OAM_ENABLE 	 1
#define OAM_DISABLE  0

#define PROTOCOL_SLOW 		0x8809      /*<802.3ah over ethernet>*/

/*OAM global definitions*/
#define OAMPDU_OUI_MSB           0x00   /*24-bit Organizationally Unique Identifier of the vendor*/
#define OAMPDU_OUI_LSB           0x0467
#define OAM_VERSION              0x01   /*OAM version*/
#define OAMPDU_MAX_SIZE          256    /*maxim OAMPDU size*/
#define OAMPDU_COUNT_PER_SECOND  10     /*OAMPDU send count per second*/
#define MAX_OAMPDU_COUNT_PER_SECOND  20 /*maxim OAMPDU send count per second*/
#define OAM_BUFFER               0x4D
#define SPEC_OAM_HEADER_FCS_LEN  26     /*6(DA)+6(SA)+2(TYPE)+1(SubType)+2(Flag)+1(Code)+3(OUI)+1(specCode)+4(FCS)*/
#define LOCAL_LOST_LINK_TIME     5      /*local lost link time value, maxim time of no receive OAM, in second*/
#define MAX_LOCAL_LOST_LINK_TIME 10     /*local lost link time value, maxim time of no receive OAM, in second*/
#define PDU_TIME                 1      /*local at least send one OAM in PDU_TIME period, in second*/
#define MAX_PDU_TIME             2      /*local at least send one OAM in PDU_TIME period, in second*/

/*OAMPDU state*/
#define LOCAL_PDU_LF_INFO        0     /*Only Information OAMPDUs with the Link Fault critical 
                                        link event set andwithout Information TLVs are allowed 
                                        to be transmitted; only Information OAMPDUsare allowed 
                                        to be received.*/
#define LOCAL_PDU_RX_INFO        1     /*No OAMPDUs are allowed to be transmitted; only 
                                        Information OAMPDUsare allowed to be received*/
#define LOCAL_PDU_INFO           2     /*Only Information OAMPDUs are allowed to be transmitted and received*/
#define LOCAL_PDU_ANY            3     /*Any permissible OAMPDU is allowed to be transmitted and received*/

/*discovery state*/
#define DISC_FAULT               0
#define DISC_ACTIVE_SEND_LOCAL   1
#define DISC_PASSIVE_WAIT        2
#define DISC_SEND_LOCAL_RMT      3
#define DISC_SEND_LOCAL_RMT_OK   4
#define DISC_SEND_ANY            5

/*define the slow protocol subType*/
#define	SLOW_SUBTYPE_LACP        0x01  /*Link Aggregation Control Protocol subType*/
#define	SLOW_SUBTYPE_LAMP        0x02  /*Link Aggregation Marker Protocol subType*/
#define	SLOW_SUBTYPE_OAM         0x03  /*802.3ah OAM subType*/

/*define the OAMPDU code field*/
#define OAM_CODE_INFO            0x00  /*Communicates local and remote OAM information*/
#define OAM_CODE_EVENT_NOTIFY    0x01  /*Alerts remote DTE of link event(s), not support*/
#define OAM_CODE_VARIABLE_REQ    0x02  /*Requests one or more specific MIB variables, not support*/
#define OAM_CODE_VARIABLE_RES    0x03  /*Returns one or more specific MIB variables, not support*/
#define OAM_CODE_LOOP_CTRL       0x04  /*Enables/disables OAM remote loopback, not support*/
#define OAM_CODE_ORG_SPEC        0xFE  /*Organization Specific Extensions*/

/*define information TLVs*/
#define TLV_INFO_TYPE_END        0x00  /*End of TLV marker*/
#define TLV_INFO_TYPE_LOCAL      0x01  /*Local Information*/
#define TLV_INFO_TYPE_REMOTE     0x02  /*Remote Information*/
#define TLV_INFO_TYPE_ORG_SPEC   0xFE  /*Organization Specific Information*/
#define TLV_INFO_LEN             0x10  /*The information TLV length in octets, fixed at 16*/

/*OAM flag field, 16 bits*/ 
typedef union 
{
	UINT16 flagFieldVal;
	struct
	{
		UINT16 linkFault           :1;   /*link status*/
		UINT16 dyingGasp           :1;   /*unrecoverable local failure condition*/
		UINT16 criticEvent         :1;   /*critical event*/
		UINT16 localStableEval     :2;   /*local stable and evaluating stat*/
		UINT16 rmtStableEval       :2;   /*remote stable and evaluating state*/
		UINT16 resverved           :9;   /*resverved, be zero*/		
	}Bits;
} UNION_OAM_FLAG_FIELD;

#define DTE_UNSATISFIED          0x0   /*Local DTE Unsatisfied, Discovery can not complete*/
#define DISCOVERY_NOT_COMPLETED  0x1   /*Local DTE Discovery process has not completed*/
#define DISCOVERY_COMPLETED      0x2   /*Local DTE Discovery process has completed*/

#define CRITICAL_OCCURRED        1     /*critical event has occurred*/
#define CRITICAL_NOT_OCCURRED    0     /*critical event has not occurred*/

#define FAILURE_OCCURRED         1     /*unrecoverable local failure condition has occurred*/
#define FAILURE_NOT_OCCURRED     0     /*unrecoverable local failure condition has not occurred*/

#define LINK_FAULT_DETECT        1     /*Local device's receive path has detected a fault*/
#define LINK_FAULT_NOT_DETECT    0     /*Local device's receive path has not detected a fault*/

/*information TLV state field, 8 bits*/
typedef union 
{
	UINT8 infoTlvStateVal;
	struct
	{
		UINT8 parAction          :2;    /*parser action*/
		UINT8 muxAction          :1;    /*multiplexer action*/
		UINT8 resverved          :5;    /*resverved, be zero*/		   
	}Bits;
} UNION_OAM_INFO_TLV_STATE;

#define MUX_ACTION_FWD          0      /*Device is forwarding non-OAMPDUs to the lower sublayer*/
#define MUX_ACTION_DISCARD      1      /*Device is discarding non-OAMPDUs*/

#define PAR_ACTION_FWD          0x0    /*Device is forwarding non-OAMPDUs to higher sublayer*/
#define PAR_ACTION_LB           0x1    /*Device is looping back non-OAMPDUs to the lower sublayer*/
#define PAR_ACTION_DISCARD      0x2    /*Device is discarding non-OAMPDUs*/

/*information TLV OAM config field, 8 bits*/
typedef union
{
	UINT8 infoTlvOamCfgVal;
	struct
	{
		UINT8 oamMode            :1;    /*DTE configured in Active or Passive mode*/	
		UINT8 unidirectSupport   :1;    /*DTE is capable of sending OAMPDUs when the receive path is non-operational or not*/
		UINT8 loopSupport        :1;    /*DTE is capable of OAM remote loopback mode or not*/
		UINT8 linkEvents         :1;    /*DTE supports interpreting Link Events or not*/
		UINT8 varRetrieval       :1;    /*DTE supports sending Variable Response OAMPDUs or not*/
		UINT8 resverved          :3;    /*resverved, be zero*/		   
	}Bits;
} UNION_OAM_INFO_TLV_OAM_CFG;

#define DTE_OAM_ACTIVE          1      /*DTE configured in Active mode*/
#define DTE_OAM_PASSIVE         0      /*DTE configured in Passive mode*/

/*information TLV OAMPDU config field, 8 bits*/
typedef union
{
	UINT16 infoTlvOamPduCfgVal;
	struct
	{
		UINT16 maxOamPduSize      :11;   /*the largest OAMPDU, in octets, supported by the DTE*/
		UINT16 resverved          :5;    /*resverved, be zero*/		
	}Bits;
} UNION_OAM_INFO_TLV_OAMPDU_CFG;

/*information TLV OAMPDU config field, 8 bits*/
typedef union
{
	UINT8 hwVerTpLinkVal;
	struct
	{
		UINT8 TpLinkStatus       :1;    /*1-TP port link up, 0-link down*/
		UINT8 firstPwrUpFlg      :1;
		UINT8 vendorHWVer        :6;    /*DTE hardware version*/		
	}Bits;
} UNION_VENDOR_HWVER_TPLNK;


#define   DTE_TYPE_UNKNOWN      0x00   
#define   OL200FR_X4X_V5        0x56        /*OL200 10/100/1000M TP-FX converter*/
#define   OL200FR_GE_V5         0x57        /*OL200 1000M FX-FX converter*/
#define   OL100CR_X4X_V5        0x0B        /*OL100 10/100/1000M TP-FX converter*/
#define   OL100CR_GE_V5         0x0C        /*OL100 1000M FX-FX converter*/
typedef struct 
{
	UINT8     infoType;                         /*Information Type, 1 byte*/
	UINT8     infoLen;                          /*Information Length, 1 byte*/
	UINT8     oamVersion;                       /*OAM Version, 1 byte*/
	UINT16    infoRevision;                     /*Revision, 2 bytes*/
	UNION_OAM_INFO_TLV_STATE      infoState;    /*State, 1 byte*/
	UNION_OAM_INFO_TLV_OAM_CFG    oamConfig;    /*OAM Configuration, 1 byte*/
	UNION_OAM_INFO_TLV_OAMPDU_CFG oampduConfig; /*OAMPDU Configuration, 2 bytes*/
	UINT8     ouiHigh;                          /*OUI, 3 bytes*/
	UINT16    ouiLow;
	UINT8     vendorInfoCode;                   /*Vendor Specific Info code, 
	                                              fixed 0xB3 for gigbit ethernet 
	                                              media converter, 1 bytes*/
	
	UINT8     vendorDTEType;                    /*Vendor device type, 1 bytes*/
	UNION_VENDOR_HWVER_TPLNK hwVerTpLink; /*device hardware version + TP port link*/
	UINT8     vendorSWVer;                      /*device software version*/
} tINFO_TLV;

/*specific OAM definition*/
#define SPEC_TYPE_END               0x00  /*end TLV flag*/
#define SPEC_TYPE_CFG_SET_REQ       0x01  /*remote config request, response type with 0x03*/
#define SPEC_TYPE_STAT_GET_REQ      0x02  /*remote state request, response type with 0x03*/
#define SPEC_TYPE_STAT_GET_RES      0x03  /*remote state response type*/
#define SPEC_TYPE_RATELMT_SET_REQ   0x04  /*remote rate limit set request, response with 0x03 or 0x06*/	
#define SPEC_TYPE_RATELMT_GET_REQ   0x05  /*remote rate limit get request, response with 0x06*/
#define SPEC_TYPE_RATELMT_GET_RES   0x06  /*remote rate limit get response*/
#define SPEC_TYPE_STATISTIC_GET_REQ 0x07  /*remote statistics get request, response with 0x08*/
#define SPEC_TYPE_STATISTIC_GET_RES 0x08  /*remote statistics get response*/
#define SPEC_TYPE_REG_RW_REQ        0x09  /*remote register get request, response with 0x0A*/
#define SPEC_TYPE_REG_RW_RES        0x0A  /*remote register get response*/
#define SPEC_TYPE_FX_INFO_GET_REQ   0x0B  /*remote fx port information get request, response with 0x0C*/
#define SPEC_TYPE_FX_INFO_GET_RES   0x0C  /*remote fx port information get response*/

#define SPEC_CFG_SET_REQ_LEN        6     /*6 bytes, not include type and len field*/
#define SPEC_STAT_GET_REQ_LEN       0     /*get request have no valid data*/	
#define SPEC_STAT_GET_RES_LEN       14    /*6 + 8 bytes*/
#define SPEC_RATELMT_SET_REQ_LEN    9     /*9 bytes */
#define SPEC_RATELMT_GET_REQ_LEN    0     /*get request have no valid data*/	
#define SPEC_RATELMT_GET_RES_LEN    8     /*8 bytes*/
#define SPEC_STATISTIC_GET_REQ_LEN  1     /*1 byte*/
#define SPEC_STATISTIC_GET_RES_LEN  9     /*8 bytes*/
#define SPEC_REG_RW_LEN             7     /*7 byte*/
#define	SPEC_FX_INFO_GET_REQ_LEN    0     /*18 byte*/
#define	SPEC_FX_INFO_GET_RES_LEN    18    /*18 byte*/

typedef struct 
{
	UINT8   ouiHigh;
	UINT16  ouiLow;

	#define OAM_SPEC_CODE               0xB3
	
	UINT8   specCode;                   /*OAM specific code, fixed 0xB3*/
		
	/*specific TLVs, each TLV include type/len/data, more than one TLV will
	  be allowed, the TLVType 0x00 means there are no more specific TLVs*/
	UINT8   specTlvType;		
	UINT8   specTlvDataLen;
	UINT8   *specTlvData;	
}tSPEC_OAM;

/***************************************
Remote specific configration and status 
definitions
****************************************/
typedef union
{
	UINT16 rmtTpCfgVal;
	struct
	{
		UINT16 tpAutoEn       :1;     /*1-TP port auto enable, 0-ignore*/
		UINT16 tpAutoDis      :1;     /*1-TP port auto disable, 0-ignore*/
		UINT16 tpFull         :1;     /*1-TP port full duplex enable, 0-ignore*/ 
		UINT16 tpHalf         :1;     /*1-TP port half duplex enable, 0-ignore*/
		UINT16 tp10M          :1;     /*1-TP port 10M enable, 0-ignore*/
		UINT16 tp100M         :1;     /*1-TP port 100M enable, 0-ignore*/
		UINT16 tp1000M        :1;     /*1-TP port 1000M enable, 0-ignore*/
		UINT16 tpFlowCtrlEn   :1;     /*1-TP port flow control enable, 0-ignore*/
		UINT16 tpFlowCtrlDis  :1;     /*1-TP port flow control disable, 0-ignore*/
		UINT16 tpLoopChkEn    :1;     /*1-TP port loopback check enable, 0-ignore*/
		UINT16 tpLoopChkDis   :1;     /*1-TP port loopback check disable, 0-ignore*/	  
		UINT16 resverved      :5;     /*reserved, should be set to 0*/
	}Bits;
} UNION_RMT_TP_CFG;

typedef union
{
	UINT16 rmtFxCfgVal;
	struct
	{
		UINT16 fxAutoEn       :1;     /*1-FX port auto enable, 0-ignore*/
		UINT16 fxAutoDis      :1;     /*1-FX port auto disable, 0-ignore*/
		UINT16 fxFEFEn        :1;     /*1-FX port FEF enable, 0-ignore*/ 
		UINT16 fxFEFDis       :1;     /*1-FX port FEF disable, 0-ignore*/
		UINT16 fxFlowCtrlEn   :1;     /*1-FX port flow control enable, 0-ignore*/
		UINT16 fxFlowCtrlDis  :1;     /*1-FX port flow control disable, 0-ignore*/
		UINT16 fxLoopChkEn    :1;     /*1-FX port loopback check enable, 0-ignore*/
		UINT16 fxLoopChkDis   :1;     /*1-FX port loopback check disable, 0-ignore*/	
		UINT16 resverved      :8;     /*reserved, should be set to 0*/
	}Bits;
} UNION_RMT_FX_CFG;

typedef union
{
	UINT16 rmtGlbCfgVal;
	struct
	{
		UINT16 rmtCloseEn     :1;     /*1-remote close enable, 0-ignore*/
		UINT16 rmtCloseDis    :1;     /*1-remote close disable, 0-ignore*/
		UINT16 rmtReset       :1;     /*1-remote reset, 0-ignore*/
		UINT16 rmtCOSEn       :1;     /*1-remote COS enable, 0-ignore*/
		UINT16 rmtCOSDis      :1;     /*1-remote COS disable, 0-ignore*/
		UINT16 rmtLFPEn       :1;     /*1-remote LFP enable, 0-ignore*/
		UINT16 rmtLFPDis      :1;     /*1-remote LFP disable, 0-ignore*/
		UINT16 rmtPwrUpFlgRst :1;     /*1-reset remote power up flag, 0-ignore*/
		UINT16 rmtLoopEn      :1;     /*1-remote loop enable, 0-ignore*/
		UINT16 rmtLoopDis     :1;     /*1-remote loop disable, 0-ignore*/
		UINT16 resverved      :6;    /*reserved, should be set to 0*/
	}Bits;
} UNION_RMT_GLB_CFG;

typedef union
{
	UINT16 rmtTpStatVal;
	struct
	{
		UINT16 tpCfgAuto      :1;     /*1-TP port auto enable, 0-disable*/
		UINT16 tpCfgDuplex    :1;     /*1-TP port full duplex enable, 0-disable*/ 
		UINT16 tpCfgSpeed     :2;     /*00-TP port config 10M
		                              01-TP port config 100M
		                              10-TP port config 1000M
		                              11-invalid*/	
		UINT16 tpCfgFlowCtrl  :1;     /*1-TP port flow control enable, 0-disable*/	
		UINT16 tpCfgLoopChk   :1;     /*1-TP port loopback check enable, 0-disable*/

⌨️ 快捷键说明

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