📄 h2flowc.c
字号:
/*
Copyright (c) 2003-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 "h2reg.h"
#include "h2io.h"
#include "main.h"
#include "hwconf.h"
#include "phytsk.h"
#include "hwport.h"
#include "misc2.h"
#include "h2flowc.h"
#include "timer.h"
/* ************************************************************************ **
*
*
* Public data
*
*
*
* ************************************************************************ */
/* ************************************************************************ **
*
*
* Defines
*
*
*
* ************************************************************************ */
/* ************************************************************************ **
*
*
* Typedefs and enums
*
*
*
* ************************************************************************ */
/* ************************************************************************ **
*
*
* Prototypes for local functions
*
*
*
* ************************************************************************ */
/* ************************************************************************ **
*
*
* Local data
*
*
*
* ************************************************************************ */
/* ************************************************************************ */
void h2_setup_flow_control (uchar port_no, uchar link_mode)
/* ------------------------------------------------------------------------ --
* Purpose : Setup flow control according to configuration and link
* partner's advertisement.
* Remarks : Please see main.h for a description of link_mode.
* Restrictions:
* See also :
* Example :
* ************************************************************************ */
{
uchar local;
uchar remote;
uchar bp; /* back pressure */
ushort frame_len;
uchar fc;
uchar giga;
mac_addr_t mac_addr;
uchar use_early_tx_wm = ((h2_read(SYSTEM, 0, SYS_CHIPID) & 0xF0000000) > 0x10000000);
local = TRUE; /* Local has always advertised support of pause frames */
remote = ((link_mode & LINK_MODE_FDX_AND_PAUSE_MASK) ==
LINK_MODE_FDX_AND_PAUSE_MASK);
giga = ((link_mode & LINK_MODE_SPEED_MASK) == LINK_MODE_SPEED_1000);
bp = ((link_mode & LINK_MODE_FDX_MASK) == 0) && local;
fc = (local && remote) || bp;
/* set MAC address */
get_mac_addr(0, mac_addr);
h2_write(PORT, port_no, PORT_FCMACHI,
ushorts2ulong(MK_USHORT(mac_addr[1], mac_addr[2]), mac_addr[0]));
h2_write(PORT, port_no, PORT_FCMACLO,
ushorts2ulong(MK_USHORT(mac_addr[4], mac_addr[5]), mac_addr[3]));
if(use_early_tx_wm) {
h2_write_bit(PORT, port_no, PORT_MISCFIFO, 2, 1);
}
/* Watermarks depend on frame length */
frame_len = h2_read(PORT, port_no, PORT_MAXLEN) & 0xFFFF;
if (fc) {
if (frame_len <= 1536) {
h2_write(PORT, port_no, PORT_Q_MISC_CONF, Q_MISC_CONF_FC);
h2_write(PORT, port_no, PORT_Q_FLOWC_WM, Q_FLOWC_WM_FC);
h2_write(PORT, port_no, PORT_Q_EGRESS_WM, Q_EGRESS_WM_FC);
}
else {
h2_write(PORT, port_no, PORT_Q_MISC_CONF, Q_MISC_CONF_FC_JUMBO);
h2_write(PORT, port_no, PORT_Q_FLOWC_WM, Q_FLOWC_WM_FC_JUMBO);
h2_write(PORT, port_no, PORT_Q_EGRESS_WM, Q_EGRESS_WM_FC_JUMBO);
}
h2_write(PORT, port_no, PORT_FCTXCONF, FCTXCONF_ON);
}
else {
if (frame_len <= 1536) {
h2_write(PORT, port_no, PORT_Q_MISC_CONF, Q_MISC_CONF_DROP);
h2_write(PORT, port_no, PORT_Q_FLOWC_WM, Q_FLOWC_WM_DROP);
h2_write(PORT, port_no, PORT_Q_EGRESS_WM, Q_EGRESS_WM_DROP);
}
else {
/* only enable early_tx if in giga mode */
ulong early_tx_mask = giga ? 0xFFFFFFFF : 0xFFFFFFE1;
if(use_early_tx_wm) {
h2_write(PORT, port_no, PORT_Q_MISC_CONF, Q_MISC_CONF_DROP_JUMBO_EARLY_TX & early_tx_mask);
if(giga) {
h2_write(PORT, port_no, PORT_Q_FLOWC_WM, Q_FLOWC_WM_DROP_JUMBO_EARLY_TX_1G);
} else {
h2_write(PORT, port_no, PORT_Q_FLOWC_WM, Q_FLOWC_WM_DROP_JUMBO_EARLY_TX);
}
h2_write(PORT, port_no, PORT_Q_EGRESS_WM, Q_EGRESS_WM_DROP_JUMBO_EARLY_TX);
} else {
h2_write(PORT, port_no, PORT_Q_MISC_CONF, Q_MISC_CONF_DROP_JUMBO & early_tx_mask);
h2_write(PORT, port_no, PORT_Q_FLOWC_WM, Q_FLOWC_WM_DROP_JUMBO);
h2_write(PORT, port_no, PORT_Q_EGRESS_WM, Q_EGRESS_WM_DROP_JUMBO);
}
}
h2_write(PORT, port_no, PORT_FCTXCONF, FCTXCONF_OFF);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -