90 lines
2.4 KiB
C
90 lines
2.4 KiB
C
#ifndef _MIRROR_DRV_H_
|
|
#define _MIRROR_DRV_H_
|
|
|
|
#define MAX_SWITCH_PORT (14)
|
|
|
|
/**
|
|
* @var typedef __MIRROR_ERROR_CODE__ MIRROR_ERROR_CODE
|
|
* @brief
|
|
*/
|
|
/**
|
|
* @enum __MIRROR_ERROR_CODE__
|
|
* @brief
|
|
*/
|
|
typedef enum __MIRROR_ERROR_CODE__
|
|
{
|
|
ERR_NO_ERROR = 0, ///< 无错误
|
|
ERR_INPUT_PARAMS, ///< 参数错误
|
|
ERR_DEV_UNVALID, ///< 设备无效或设备不存在
|
|
ERR_MALLOC_MEMORY, ///< 分配内存失败
|
|
ERR_CONVERT_STR, ///< 字符串转换失败
|
|
|
|
ERR_UNSUPPORT_PORT = 10,
|
|
|
|
ERR_SPI_TRANSFER = 100, ///< I2C 设备传输失败
|
|
ERR_SPI_UNINIT, ///< I2C 设备未初始化
|
|
ERR_SPI_DEVICE, ///< 未知 I2C 设备
|
|
|
|
ERR_UNSUPPORT_BOARD = 200, ///< 不支持的板卡
|
|
ERR_IOC_UNKNOWNCMD, ///< 未知控制命令
|
|
} MIRROR_ERROR_CODE;
|
|
|
|
typedef enum __BCM_PORT_NAME__
|
|
{
|
|
BCM_PORT_UNKNOWN = -1,
|
|
FE0_BOARD_SLOT1 = 0,
|
|
FE1_BOARD_SLOT2,
|
|
FE2_BOARD_SLOT3,
|
|
FE3_BOARD_SLOT4,
|
|
FE4_BOARD_SLOT5,
|
|
FE5_BOARD_FSLOT1,
|
|
FE6_MSB_ETH0,
|
|
FE7_SG_ETH0,
|
|
FE8_MSB_FE1,
|
|
FE9_MSB_FE2,
|
|
FE10_MSB_FE3,
|
|
FE11_DM_TC,
|
|
GE0_MSB_GE = 25,
|
|
GE1_BOARD_FSLOT2 = 26,
|
|
} BCM_PORT_NAME;
|
|
|
|
typedef enum __MIRROR_MASK__
|
|
{
|
|
MIRROR_MASK_DISABLE = 0,
|
|
MIRROR_MASK_ENABLE = (1 << 7),
|
|
MIRROR_MASK_OUT_ENABLE = (1 << 0),
|
|
MIRROR_MASK_IN_ENABLE = (1 << 1),
|
|
} MIRROR_MASK;
|
|
|
|
typedef struct __BCM_PORT__
|
|
{
|
|
const BCM_PORT_NAME portName; ///< 端口名称
|
|
BCM_PORT_NAME mirrorPort; ///< 端口的镜像端口名称
|
|
MIRROR_MASK mirrorMask; ///< 端口镜像功能掩码
|
|
// const char* pPortDesc; ///< 端口显示名称
|
|
} BCM_PORT, *PBCM_PORT;
|
|
|
|
#if 0
|
|
typedef struct __SWITCH_PORT__
|
|
{
|
|
//int mirrorEnable;
|
|
//char portPos[32];
|
|
|
|
BCM_PORT bcmPortInfo;
|
|
} SWITCH_PORT, *PSWITCH_PORT;
|
|
#endif
|
|
|
|
typedef struct __MIRROR_HAL_DEV__
|
|
{
|
|
struct class* pDevClass; ///< 设备注册信息
|
|
struct spi_master* pSPIMaster; ///< SPI 设备指针
|
|
struct spi_device* pSPIDevice; ///< SPI 驱动设备
|
|
int bEnabled; ///< 是否开启端口镜像功能
|
|
// BCM_PORT bcmPortInfo[MAX_SWITCH_PORT]; ///< 交换机端口信息
|
|
} MIRROR_HAL_DEV, *PMIRROR_HAL_DEV;
|
|
|
|
PMIRROR_HAL_DEV DRV_GetDrvDetail(void);
|
|
|
|
const char* GetBCMPortName(BCM_PORT_NAME bcmPort);
|
|
#endif
|