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

📄 ks_config.h

📁 MICREL 网卡驱动 FOR CE 5.0
💻 H
📖 第 1 页 / 共 3 页
字号:
/* ---------------------------------------------------------------------------
          Copyright (c) 2004-2006 Micrel, Inc.  All rights reserved.
   ---------------------------------------------------------------------------

    ks_config.h - KS884X switch configuration functions header.

    Author  Date      Version  Description
    THa     04/03/06           Move STP state definitions from ks_stp.c.
    THa     02/28/06           Do not use HW_WRITE_BYTE because of limitation of
                               some hardware platforms.
    PCD     08/10/05  0.1.7    Fix incorrect register offset in configuration of VLAN.
    THa     10/14/04           Updated with latest specs.
    THa     09/30/04           Updated for PCI version.
    THa     02/13/04           Created file.
   ---------------------------------------------------------------------------
*/


#ifndef __KS_CONFIG_H
#define __KS_CONFIG_H


/* -------------------------------------------------------------------------- */

#ifdef KS_ISA_BUS
ULONG SwapBytes (
    ULONG dwData );

BOOLEAN PortConfigGet_ISA (
    PHARDWARE pHardware,
    UCHAR     bPort,
    UCHAR     bBank,
    UCHAR     bffset,
    UCHAR     bBits );

void PortConfigSet_ISA (
    PHARDWARE pHardware,
    UCHAR     bPort,
    UCHAR     bBank,
    UCHAR     bOffset,

#ifdef SH_16BIT_WRITE
    USHORT    bBits,

#else
    UCHAR     bBits,
#endif
    BOOLEAN   fSet );
#endif

#ifdef KS_PCI_BUS
BOOLEAN PortConfigGetShift (
    PHARDWARE pHardware,
    UCHAR     bPort,
    ULONG     ulOffset,
    UCHAR     bShift );

void PortConfigSetShift (
    PHARDWARE pHardware,
    UCHAR     bPort,
    ULONG     ulOffset,
    UCHAR     bShift,
    BOOLEAN   fSet );
#endif

#ifdef KS_ISA_BUS
void PortConfigReadByte_ISA (
    PHARDWARE pHardware,
    UCHAR     bPort,
    UCHAR     bBank,
    UCHAR     bOffset,
    PUCHAR    pbData );

void PortConfigWriteByte_ISA (
    PHARDWARE pHardware,
    UCHAR     bPort,
    UCHAR     bBank,
    UCHAR     bOffset,
    UCHAR     bData );

void PortConfigReadWord_ISA (
    PHARDWARE pHardware,
    UCHAR     bPort,
    UCHAR     bBank,
    UCHAR     bOffset,
    PUSHORT   pwData );

void PortConfigWriteWord_ISA (
    PHARDWARE pHardware,
    UCHAR     bPort,
    UCHAR     bBank,
    UCHAR     bOffset,
    USHORT    usData );

BOOLEAN SwitchConfigGet_ISA (
    PHARDWARE pHardware,
    int       Offset,
    UCHAR     bBits );

void SwitchConfigSet_ISA (
    PHARDWARE pHardware,
    int       Offset,

#ifdef SH_16BIT_WRITE
    USHORT    bBits,

#else
    UCHAR     bBits,
#endif
    BOOLEAN   fSet );
#endif

#ifdef KS_PCI_BUS
BOOLEAN PortConfigGet_PCI (
    PHARDWARE pHardware,
    UCHAR     bPort,
    UCHAR     bOffset,
    UCHAR     bBits );

void PortConfigSet_PCI (
    PHARDWARE pHardware,
    UCHAR     bPort,
    UCHAR     bOffset,
    UCHAR     bBits,
    BOOLEAN   fSet );

void PortConfigReadByte_PCI (
    PHARDWARE pHardware,
    UCHAR     bPort,
    UCHAR     bOffset,
    PUCHAR    pbData );

void PortConfigWriteByte_PCI (
    PHARDWARE pHardware,
    UCHAR     bPort,
    UCHAR     bOffset,
    UCHAR     bData );

void PortConfigReadWord_PCI (
    PHARDWARE pHardware,
    UCHAR     bPort,
    UCHAR     bOffset,
    PUSHORT   pwData );

void PortConfigWriteWord_PCI (
    PHARDWARE pHardware,
    UCHAR     bPort,
    UCHAR     bOffset,
    USHORT    usData );

BOOLEAN SwitchConfigGet_PCI (
    PHARDWARE pHardware,
    int       Offset,
    UCHAR     bBits );

void SwitchConfigSet_PCI (
    PHARDWARE pHardware,
    int       Offset,
    UCHAR     bBits,
    BOOLEAN   fSet );
#endif

#ifdef KS_PCI_BUS
#define SwitchConfigReadByte( phwi, offset, data )                          \
    HW_READ_BYTE( phwi, offset, data )

#define SwitchConfigWriteByte( phwi, offset, data )                         \
    HW_WRITE_BYTE( phwi, offset, data )

#define PortConfigGet  PortConfigGet_PCI
#define PortConfigSet  PortConfigSet_PCI
#define PortConfigReadByte  PortConfigReadByte_PCI
#define PortConfigWriteByte  PortConfigWriteByte_PCI
#define PortConfigReadWord  PortConfigReadWord_PCI
#define PortConfigWriteWord  PortConfigWriteWord_PCI
#define SwitchConfigGet  SwitchConfigGet_PCI
#define SwitchConfigSet  SwitchConfigSet_PCI

#else
#define SwitchConfigReadByte( phwi, offset, data )                          \
    HardwareReadRegByte( phwi, REG_SWITCH_CTRL_BANK, offset, data )

#define SwitchConfigWriteByte( phwi, offset, data )                         \
    HardwareWriteRegByte( phwi, REG_SWITCH_CTRL_BANK, offset, data )

#define PortConfigGet PortConfigGet_ISA
#define PortConfigSet  PortConfigSet_ISA
#define PortConfigReadByte  PortConfigReadByte_ISA
#define PortConfigWriteByte  PortConfigWriteByte_ISA
#define PortConfigReadWord  PortConfigReadWord_ISA
#define PortConfigWriteWord  PortConfigWriteWord_ISA
#define SwitchConfigGet  SwitchConfigGet_ISA
#define SwitchConfigSet  SwitchConfigSet_ISA
#endif

/* -------------------------------------------------------------------------- */

/* Bandwidth */

#ifdef KS_PCI_BUS
#define PortConfigBroadcastStorm( phwi, port, enable )                      \
    PortConfigSet_PCI( phwi, port,                                          \
        REG_PORT_CTRL_1_OFFSET, PORT_BROADCAST_STORM, enable )

#define PortGetBroadcastStorm( phwi, port )                                 \
    PortConfigGet_PCI( phwi, port,                                          \
        REG_PORT_CTRL_1_OFFSET, PORT_BROADCAST_STORM )

#else
#define PortConfigBroadcastStorm( phwi, port, enable )                      \
    PortConfigSet_ISA( phwi, port, REG_PORT_CTRL_BANK,                      \
        REG_PORT_CTRL_1_OFFSET, PORT_BROADCAST_STORM, enable )

#define PortGetBroadcastStorm( phwi, port )                                 \
    PortConfigGet_ISA( phwi, port, REG_PORT_CTRL_BANK,                      \
        REG_PORT_CTRL_1_OFFSET, PORT_BROADCAST_STORM )
#endif


/* Communication */

#ifdef KS_PCI_BUS
#define PortConfigBackPressure( phwi, port, enable )                        \
    PortConfigSet_PCI( phwi, port,                                          \
        REG_PORT_CTRL_2_HI_OFFSET, PORT_BACK_PRESSURE, enable )

#define PortConfigForceFlowCtrl( phwi, port, enable )                       \
    PortConfigSet_PCI( phwi, port,                                          \
        REG_PORT_CTRL_2_HI_OFFSET, PORT_FORCE_FLOW_CTRL, enable )

#define PortGetBackPressure( phwi, port )                                   \
    PortConfigGet_PCI( phwi, port,                                          \
        REG_PORT_CTRL_2_HI_OFFSET, PORT_BACK_PRESSURE )

#define PortGetForceFlowCtrl( phwi, port )                                  \
    PortConfigGet_PCI( phwi, port,                                          \
        REG_PORT_CTRL_2_HI_OFFSET, PORT_FORCE_FLOW_CTRL )

#else
#define PortConfigBackPressure( phwi, port, enable )                        \
    PortConfigSet_ISA( phwi, port, REG_PORT_CTRL_BANK,                      \
        REG_PORT_CTRL_2_HI_OFFSET, PORT_BACK_PRESSURE, enable )

#define PortConfigForceFlowCtrl( phwi, port, enable )                       \
    PortConfigSet_ISA( phwi, port, REG_PORT_CTRL_BANK,                      \
        REG_PORT_CTRL_2_HI_OFFSET, PORT_FORCE_FLOW_CTRL, enable )

#define PortGetBackPressure( phwi, port )                                   \
    PortConfigGet_ISA( phwi, port, REG_PORT_CTRL_BANK,                      \
        REG_PORT_CTRL_2_HI_OFFSET, PORT_BACK_PRESSURE )

#define PortGetForceFlowCtrl( phwi, port )                                  \
    PortConfigGet_ISA( phwi, port, REG_PORT_CTRL_BANK,                      \
        REG_PORT_CTRL_2_HI_OFFSET, PORT_FORCE_FLOW_CTRL )
#endif


/* Spanning Tree */

#ifdef KS_PCI_BUS
#define PortConfigDisableLearning( phwi, port, enable )                     \
    PortConfigSet_PCI( phwi, port,                                          \
        REG_PORT_CTRL_2_HI_OFFSET, PORT_LEARN_DISABLE, enable )

#define PortConfigEnableReceive( phwi, port, enable )                       \
    PortConfigSet_PCI( phwi, port,                                          \
        REG_PORT_CTRL_2_HI_OFFSET, PORT_RX_ENABLE, enable )

#define PortConfigEnableTransmit( phwi, port, enable )                      \
    PortConfigSet_PCI( phwi, port,                                          \
        REG_PORT_CTRL_2_HI_OFFSET, PORT_TX_ENABLE, enable )

#else
#define PortConfigDisableLearning( phwi, port, enable )                     \
    PortConfigSet_ISA( phwi, port, REG_PORT_CTRL_BANK,                      \
        REG_PORT_CTRL_2_HI_OFFSET, PORT_LEARN_DISABLE, enable )

#define PortConfigEnableReceive( phwi, port, enable )                       \
    PortConfigSet_ISA( phwi, port, REG_PORT_CTRL_BANK,                      \
        REG_PORT_CTRL_2_HI_OFFSET, PORT_RX_ENABLE, enable )

#define PortConfigEnableTransmit( phwi, port, enable )                      \
    PortConfigSet_ISA( phwi, port, REG_PORT_CTRL_BANK,                      \
        REG_PORT_CTRL_2_HI_OFFSET, PORT_TX_ENABLE, enable )
#endif


/* VLAN */

#ifdef KS_PCI_BUS
#define PortConfigDiscardNonVID( phwi, port, enable )                       \
    PortConfigSet_PCI( phwi, port,                                          \
        REG_PORT_CTRL_2_HI_OFFSET, PORT_DISCARD_NON_VID, enable )

#define PortConfigDoubleTag( phwi, port, enable )                           \
    PortConfigSet_PCI( phwi, port,                                          \
        REG_PORT_CTRL_2_OFFSET, PORT_DOUBLE_TAG, enable )

#define PortConfigIngressFiltering( phwi, port, enable )                    \
    PortConfigSet_PCI( phwi, port,                                          \
        REG_PORT_CTRL_2_HI_OFFSET, PORT_INGRESS_FILTER, enable )

#define PortConfigInsertTag( phwi, port, insert )                           \
    PortConfigSet_PCI( phwi, port,                                          \
        REG_PORT_CTRL_1_OFFSET, PORT_INSERT_TAG, insert )

#define PortConfigRemoveTag( phwi, port, remove )                           \
    PortConfigSet_PCI( phwi, port,                                          \
        REG_PORT_CTRL_1_OFFSET, PORT_REMOVE_TAG, remove )

#define PortGetDiscardNonVID( phwi, port )                                  \
    PortConfigGet_PCI( phwi, port,                                          \
        REG_PORT_CTRL_2_HI_OFFSET, PORT_DISCARD_NON_VID )

#define PortGetDoubleTag( phwi, port )                                      \
    PortConfigGet_PCI( phwi, port,                                          \
        REG_PORT_CTRL_2_OFFSET, PORT_DOUBLE_TAG )

#define PortGetIngressFiltering( phwi, port )                               \
    PortConfigGet_PCI( phwi, port,                                          \
        REG_PORT_CTRL_2_HI_OFFSET, PORT_INGRESS_FILTER )

#define PortGetInsertTag( phwi, port )                                      \
    PortConfigGet_PCI( phwi, port,                                          \
        REG_PORT_CTRL_1_OFFSET, PORT_INSERT_TAG )

#define PortGetRemoveTag( phwi, port )                                      \
    PortConfigGet_PCI( phwi, port,                                          \
        REG_PORT_CTRL_1_OFFSET, PORT_REMOVE_TAG )

#else
#define PortConfigDiscardNonVID( phwi, port, enable )                       \
    PortConfigSet_ISA( phwi, port, REG_PORT_CTRL_BANK,                      \
        REG_PORT_CTRL_2_HI_OFFSET, PORT_DISCARD_NON_VID, enable )

#define PortConfigDoubleTag( phwi, port, enable )                           \
    PortConfigSet_ISA( phwi, port, REG_PORT_CTRL_BANK,                      \
        REG_PORT_CTRL_2_OFFSET, PORT_DOUBLE_TAG, enable )

#define PortConfigIngressFiltering( phwi, port, enable )                    \
    PortConfigSet_ISA( phwi, port, REG_PORT_CTRL_BANK,                      \
        REG_PORT_CTRL_2_HI_OFFSET, PORT_INGRESS_FILTER, enable )

#define PortConfigInsertTag( phwi, port, insert )                           \
    PortConfigSet_ISA( phwi, port, REG_PORT_CTRL_BANK,                      \
        REG_PORT_CTRL_1_OFFSET, PORT_INSERT_TAG, insert )

#define PortConfigRemoveTag( phwi, port, remove )                           \
    PortConfigSet_ISA( phwi, port, REG_PORT_CTRL_BANK,                      \
        REG_PORT_CTRL_1_OFFSET, PORT_REMOVE_TAG, remove )

#define PortGetDiscardNonVID( phwi, port )                                  \
    PortConfigGet_ISA( phwi, port, REG_PORT_CTRL_BANK,                      \
        REG_PORT_CTRL_2_HI_OFFSET, PORT_DISCARD_NON_VID )

#define PortGetDoubleTag( phwi, port )                                      \
    PortConfigGet_ISA( phwi, port, REG_PORT_CTRL_BANK,                      \
        REG_PORT_CTRL_2_OFFSET, PORT_DOUBLE_TAG )

#define PortGetIngressFiltering( phwi, port )                               \
    PortConfigGet_ISA( phwi, port, REG_PORT_CTRL_BANK,                      \
        REG_PORT_CTRL_2_HI_OFFSET, PORT_INGRESS_FILTER )

#define PortGetInsertTag( phwi, port )                                      \
    PortConfigGet_ISA( phwi, port, REG_PORT_CTRL_BANK,                      \
        REG_PORT_CTRL_1_OFFSET, PORT_INSERT_TAG )

#define PortGetRemoveTag( phwi, port )                                      \
    PortConfigGet_ISA( phwi, port, REG_PORT_CTRL_BANK,                      \
        REG_PORT_CTRL_1_OFFSET, PORT_REMOVE_TAG )
#endif

⌨️ 快捷键说明

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