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

📄 h2mactab.c

📁 Vitesse 24port gigabit Switch Source Code
💻 C
字号:
/*

    Copyright (c) 2002-2005 Vitesse Semiconductor Corporation "Vitesse".  
    All Rights Reserved.  Unpublished rights reserved under the copyright laws
    of the United States of America, other countries and international treaties.
    The software is provided without a fee. Permission to use, copy, store and 
    modify, the software and its source code is granted. Permission to integrate
    into other products, disclose, transmit and distribute the software in an
    absolute machine readable format (e.g. HEX file) is also granted. 

    The source code of the software may not be disclosed, transmitted or
    distributed without the written permission of Vitesse. The software and its
    source code may only be used in products utilizing a Vitesse VSC73xx product.
 
    This copyright notice must appear in any copy, modification, disclosure,
    transmission or distribution of the software. Vitesse retains all ownership,
    copyright, trade secret and proprietary rights in the software.  

    THIS SOFTWARE HAS BEEN PROVIDED "AS IS," WITHOUT EXPRESS OR IMPLIED WARRANTY
    INCLUDING, WITHOUT LIMITATION, IMPLIED WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR USE AND NON-INFRINGEMENT.

*/
#include "common.h"
#include "hwconf.h"
#include "h2mactab.h"
#include "h2reg.h"
#include "h2io.h"
#include "h2.h"
#include "timer.h"
#include "main.h"

/* ************************************************************************ **
 *
 *
 * Defines
 *
 *
 *
 * ************************************************************************ */


/* MAC table commands */
#define MAC_TAB_IDLE   0
#define MAC_TAB_LEARN  1
#define MAC_TAB_FORGET 2
#define MAC_TAB_AGE    3
#define MAC_TAB_FLUSH  4
#define MAC_TAB_CLEAR  5
#define MAC_TAB_READ   6
#define MAC_TAB_WRITE  7

/* ************************************************************************ **
 *
 *
 * Typedefs and enums
 *
 *
 *
 * ************************************************************************ */


/* ************************************************************************ **
 *
 *
 * Prototypes for local functions
 *
 *
 *
 * ************************************************************************ */

static void   do_mactab_cmd (ushort mac_access_reg_val);


/* ************************************************************************ **
 *
 *
 * Local data
 *
 *
 *
 * ************************************************************************ */



/* ************************************************************************ */
void h2_mactab_age (void)
/* ------------------------------------------------------------------------ --
 * Purpose     : Perform ageing operation on MAC address table.
 * Remarks     :
 * Restrictions:
 * See also    :
 * Example     :
 * ************************************************************************ */
{
    do_mactab_cmd(MAC_TAB_AGE);
}

/* ************************************************************************ */
void h2_mactab_clear (void)
/* ------------------------------------------------------------------------ --
 * Purpose     : Perform clear operation on MAC address table.
 * Remarks     :
 * Restrictions:
 * See also    :
 * Example     :
 * ************************************************************************ */
{
    do_mactab_cmd(MAC_TAB_CLEAR);
}

/* ************************************************************************ */
void h2_mactab_filter (void)
/* ------------------------------------------------------------------------ --
 * Purpose     : Use MAC table to filter out certain addresses
 * Remarks     :
 * Restrictions:
 * See also    :
 * Example     :
 * ************************************************************************ */
{
    uchar j;

    for (j = 1; j <= 0x0f; j++) {
        h2_write(ANALYZER, 0, ANA_MACHDATA, 0x00000180);
        h2_write(ANALYZER, 0, ANA_MACLDATA, 0xc2000000 + j);
        do_mactab_cmd(0X2600 | MAC_TAB_LEARN);
    }
}

/* ************************************************************************ **
 *
 *
 * Support functions
 *
 *
 *
 * ************************************************************************ */

static void do_mactab_cmd (ushort mac_access_reg_val)
{
    h2_write(ANALYZER, 0, ANA_MACACCES, mac_access_reg_val);
    start_timer(MSEC_100);
    while (((uchar) h2_read(ANALYZER, 0, ANA_MACACCES) & 0x07) != 0) {
        if (timeout()) {
            set_fatal_error(MACTAB_FAILURE);
            return;
        }
    }
}


⌨️ 快捷键说明

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