Browse Source

Added Broadcom 5709 NIC Driver, extend the availabel memory for LSI RAID driver, extend

the total size of memory buffers

Before: Broadcom 5709 NIC can not work.
Now: Broadcom 5709 NIC can work.
Test: In pmon console,  executiving "devls" command, you can find the device name of broadcom 5709
NIC,then Configuring the network, and then checking whether the network can link.

Thanks wanchao@loongson.cn

Targets: 3aserver
master
meiwenbin 13 years ago
committed by wanghongmei
parent
commit
331fbc50cd
  1. 4
      Targets/Bonito3aserver/conf/Bonito.3aserver
  2. 8
      sys/arch/mips/include/param.h
  3. 1158
      sys/dev/mii/brgphy.c
  4. 430
      sys/dev/mii/brgphyreg.h
  5. 4
      sys/dev/mii/files.mii
  6. 10
      sys/dev/mii/mii.c
  7. 65
      sys/dev/mii/mii.h
  8. 513
      sys/dev/mii/mii_physubr.c
  9. 408
      sys/dev/mii/miidevs.h
  10. 73
      sys/dev/mii/miivar.h
  11. 14836
      sys/dev/pci/bnx/bnxfw.h
  12. 2653
      sys/dev/pci/bnx/if_bgereg.h
  13. 6574
      sys/dev/pci/bnx/if_bnx.c
  14. 5143
      sys/dev/pci/bnx/if_bnxreg.h
  15. 8
      sys/dev/pci/files.pci
  16. 14
      sys/dev/pci/pci.c
  17. 123
      sys/dev/pci/pcidevs.h
  18. 7
      sys/dev/pci/pcivar.h
  19. 49
      sys/net/if.h
  20. 11
      sys/net/if_ethersubr.c
  21. 224
      sys/net/if_media.c
  22. 335
      sys/net/if_media.h
  23. 10
      sys/netinet/if_ether.h
  24. 9
      sys/sys/param.h
  25. 103
      sys/sys/timeout.h

4
Targets/Bonito3aserver/conf/Bonito.3aserver

@ -174,9 +174,13 @@ pci* at ppb? bus ?
# fxp normally only used for debugging (enable/disable both)
fxp0 at pci? dev ? function ? # Intel 82559 Device
inphy* at mii? phy ? # Intel 82555 PHYs
brgphy* at mii? phy ? # Broadcom PHYs
rtl* at pci? dev ? function ?
rtk* at pci? dev ? function ?
em* at pci? dev ? function ?
#added by wxy
bnx* at pci? dev ? function ? # BCM5709S
#uhci* at pci? dev ? function ?
ohci0 at pci? dev ? function ?
usb* at usbbus ?

8
sys/arch/mips/include/param.h

@ -55,6 +55,9 @@
#define MACHINE_ARCH "mips"
#define _MACHINE_ARCH mips
//wan+
#define PAGE_SHIFT 12
#define MID_MACHINE 0 /* None but has to be defined */
/*
@ -113,7 +116,7 @@
#define MCLBYTES (1 << MCLSHIFT) /* enough for whole Ethernet packet */
#define MCLOFSET (MCLBYTES - 1)
#ifdef PMON
#define NMBCLUSTERS 256 /* map size, max cluster allocation */
#define NMBCLUSTERS 512 /* map size, max cluster allocation */
#endif
#ifndef NMBCLUSTERS
#ifdef GATEWAY
@ -130,7 +133,8 @@
*/
#ifndef NKMEMCLUSTERS
#ifdef PMON
#define NKMEMCLUSTERS (2048 * 1024 / CLBYTES) /* 0.5Mb */
#define NKMEMCLUSTERS (4 * 2048 * 1024 / CLBYTES) /* wan+ */
//#define NKMEMCLUSTERS (2048 * 1024 / CLBYTES) /* 0.5Mb *//* wan^ */
#else
#define NKMEMCLUSTERS (128 * 1024 * 1024 / CLBYTES)
#endif

1158
sys/dev/mii/brgphy.c

File diff suppressed because it is too large

430
sys/dev/mii/brgphyreg.h

@ -0,0 +1,430 @@
/* $OpenBSD: brgphyreg.h,v 1.15 2010/07/10 07:59:33 sthen Exp $ */
/*
* Copyright (c) 2000
* Bill Paul <wpaul@ee.columbia.edu>. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Bill Paul.
* 4. Neither the name of the author nor the names of any co-contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD: brgphyreg.h,v 1.4 2001/09/27 17:32:49 wpaul Exp $
*/
#ifndef _DEV_MII_BRGPHYREG_H_
#define _DEV_MII_BRGPHYREG_H_
/*
* Broadcom BCM5400 registers
*/
#define BRGPHY_MII_BMCR 0x00
#define BRGPHY_BMCR_RESET 0x8000
#define BRGPHY_BMCR_LOOP 0x4000
#define BRGPHY_BMCR_SPD0 0x2000 /* speed select, lower bit */
#define BRGPHY_BMCR_AUTOEN 0x1000 /* Autoneg enabled */
#define BRGPHY_BMCR_PDOWN 0x0800 /* Power down */
#define BRGPHY_BMCR_ISO 0x0400 /* Isolate */
#define BRGPHY_BMCR_STARTNEG 0x0200 /* Restart autoneg */
#define BRGPHY_BMCR_FDX 0x0100 /* Duplex mode */
#define BRGPHY_BMCR_CTEST 0x0080 /* Collision test enable */
#define BRGPHY_BMCR_SPD1 0x0040 /* Speed select, upper bit */
#define BRGPHY_S1000 BRGPHY_BMCR_SPD1 /* 1000mbps */
#define BRGPHY_S100 BRGPHY_BMCR_SPD0 /* 100mpbs */
#define BRGPHY_S10 0 /* 10mbps */
#define BRGPHY_MII_BMSR 0x01
#define BRGPHY_BMSR_EXTSTS 0x0100 /* Extended status present */
#define BRGPHY_BMSR_PRESUB 0x0040 /* Preamble suppression */
#define BRGPHY_BMSR_ACOMP 0x0020 /* Autoneg complete */
#define BRGPHY_BMSR_RFAULT 0x0010 /* Remote fault condition occurred */
#define BRGPHY_BMSR_ANEG 0x0008 /* Autoneg capable */
#define BRGPHY_BMSR_LINK 0x0004 /* Link status */
#define BRGPHY_BMSR_JABBER 0x0002 /* Jabber detected */
#define BRGPHY_BMSR_EXT 0x0001 /* Extended capability */
#define BRGPHY_MII_ANAR 0x04
#define BRGPHY_ANAR_NP 0x8000 /* Next page */
#define BRGPHY_ANAR_RF 0x2000 /* Remote fault */
#define BRGPHY_ANAR_ASP 0x0800 /* Asymmetric Pause */
#define BRGPHY_ANAR_PC 0x0400 /* Pause capable */
#define BRGPHY_ANAR_SEL 0x001F /* selector field, 00001=Ethernet */
#define BRGPHY_MII_ANLPAR 0x05
#define BRGPHY_ANLPAR_NP 0x8000 /* Next page */
#define BRGPHY_ANLPAR_RF 0x2000 /* Remote fault */
#define BRGPHY_ANLPAR_ASP 0x0800 /* Asymmetric Pause */
#define BRGPHY_ANLPAR_PC 0x0400 /* Pause capable */
#define BRGPHY_ANLPAR_SEL 0x001F /* selector field, 00001=Ethernet */
#define BRGPHY_SEL_TYPE 0x0001 /* ethernet */
#define BRGPHY_MII_ANER 0x06
#define BRGPHY_ANER_PDF 0x0010 /* Parallel detection fault */
#define BRGPHY_ANER_LPNP 0x0008 /* Link partner can next page */
#define BRGPHY_ANER_NP 0x0004 /* Local PHY can next page */
#define BRGPHY_ANER_RX 0x0002 /* Next page received */
#define BRGPHY_ANER_LPAN 0x0001 /* Link partner autoneg capable */
#define BRGPHY_MII_NEXTP 0x07 /* Next page */
#define BRGPHY_MII_NEXTP_LP 0x08 /* Next page of link partner */
#define BRGPHY_MII_1000CTL 0x09 /* 1000baseT control */
#define BRGPHY_1000CTL_TST 0xE000 /* test modes */
#define BRGPHY_1000CTL_MSE 0x1000 /* Master/Slave enable */
#define BRGPHY_1000CTL_MSC 0x0800 /* Master/Slave configuration */
#define BRGPHY_1000CTL_RD 0x0400 /* Repeater/DTE */
#define BRGPHY_1000CTL_AFD 0x0200 /* Advertise full duplex */
#define BRGPHY_1000CTL_AHD 0x0100 /* Advertise half duplex */
#define BRGPHY_MII_1000STS 0x0A /* 1000baseT status */
#define BRGPHY_1000STS_MSF 0x8000 /* Master/slave fault */
#define BRGPHY_1000STS_MSR 0x4000 /* Master/slave result */
#define BRGPHY_1000STS_LRS 0x2000 /* Local receiver status */
#define BRGPHY_1000STS_RRS 0x1000 /* Remote receiver status */
#define BRGPHY_1000STS_LPFD 0x0800 /* Link partner can FD */
#define BRGPHY_1000STS_LPHD 0x0400 /* Link partner can HD */
#define BRGPHY_1000STS_IEC 0x00FF /* Idle error count */
#define BRGPHY_MII_EXTSTS 0x0F /* Extended status */
#define BRGPHY_EXTSTS_X_FD_CAP 0x8000 /* 1000base-X FD capable */
#define BRGPHY_EXTSTS_X_HD_CAP 0x4000 /* 1000base-X HD capable */
#define BRGPHY_EXTSTS_T_FD_CAP 0x2000 /* 1000base-T FD capable */
#define BRGPHY_EXTSTS_T_HD_CAP 0x1000 /* 1000base-T HD capable */
#define BRGPHY_MII_PHY_EXTCTL 0x10 /* PHY extended control */
#define BRGPHY_PHY_EXTCTL_MAC_PHY 0x8000 /* 10BIT/GMI-interface */
#define BRGPHY_PHY_EXTCTL_DIS_CROSS 0x4000 /* Disable MDI crossover */
#define BRGPHY_PHY_EXTCTL_TX_DIS 0x2000 /* Tx output disable d*/
#define BRGPHY_PHY_EXTCTL_INT_DIS 0x1000 /* Interrupts disabled */
#define BRGPHY_PHY_EXTCTL_F_INT 0x0800 /* Force interrupt */
#define BRGPHY_PHY_EXTCTL_BY_45 0x0400 /* Bypass 4B5B-Decoder */
#define BRGPHY_PHY_EXTCTL_BY_SCR 0x0200 /* Bypass scrambler */
#define BRGPHY_PHY_EXTCTL_BY_MLT3 0x0100 /* Bypass MLT3 encoder */
#define BRGPHY_PHY_EXTCTL_BY_RXA 0x0080 /* Bypass RX alignment */
#define BRGPHY_PHY_EXTCTL_RES_SCR 0x0040 /* Reset scrambler */
#define BRGPHY_PHY_EXTCTL_EN_LTR 0x0020 /* Enable LED traffic mode */
#define BRGPHY_PHY_EXTCTL_LED_ON 0x0010 /* Force LEDs on */
#define BRGPHY_PHY_EXTCTL_LED_OFF 0x0008 /* Force LEDs off */
#define BRGPHY_PHY_EXTCTL_EX_IPG 0x0004 /* Extended TX IPG mode */
#define BRGPHY_PHY_EXTCTL_3_LED 0x0002 /* Three link LED mode */
#define BRGPHY_PHY_EXTCTL_HIGH_LA 0x0001 /* GMII Fifo Elasticy (?) */
#define BRGPHY_MII_PHY_EXTSTS 0x11 /* PHY extended status */
#define BRGPHY_PHY_EXTSTS_CROSS_STAT 0x2000 /* MDI crossover status */
#define BRGPHY_PHY_EXTSTS_INT_STAT 0x1000 /* Interrupt status */
#define BRGPHY_PHY_EXTSTS_RRS 0x0800 /* Remote receiver status */
#define BRGPHY_PHY_EXTSTS_LRS 0x0400 /* Local receiver status */
#define BRGPHY_PHY_EXTSTS_LOCKED 0x0200 /* Locked */
#define BRGPHY_PHY_EXTSTS_LS 0x0100 /* Link status */
#define BRGPHY_PHY_EXTSTS_RF 0x0080 /* Remove fault */
#define BRGPHY_PHY_EXTSTS_CE_ER 0x0040 /* Carrier ext error */
#define BRGPHY_PHY_EXTSTS_BAD_SSD 0x0020 /* Bad SSD */
#define BRGPHY_PHY_EXTSTS_BAD_ESD 0x0010 /* Bad ESS */
#define BRGPHY_PHY_EXTSTS_RX_ER 0x0008 /* RX error */
#define BRGPHY_PHY_EXTSTS_TX_ER 0x0004 /* TX error */
#define BRGPHY_PHY_EXTSTS_LOCK_ER 0x0002 /* Lock error */
#define BRGPHY_PHY_EXTSTS_MLT3_ER 0x0001 /* MLT3 code error */
#define BRGPHY_MII_RXERRCNT 0x12 /* RX error counter */
#define BRGPHY_MII_FCERRCNT 0x13 /* false carrier sense counter */
#define BGRPHY_FCERRCNT 0x00FF /* False carrier counter */
#define BRGPHY_MII_RXNOCNT 0x14 /* RX not OK counter */
#define BRGPHY_RXNOCNT_LOCAL 0xFF00 /* Local RX not OK counter */
#define BRGPHY_RXNOCNT_REMOTE 0x00FF /* Local RX not OK counter */
#define BRGPHY_MII_DSP_RW_PORT 0x15 /* DSP coefficient r/w port */
#define BRGPHY_MII_EPHY_PTEST 0x17 /* 5906 PHY register */
#define BRGPHY_MII_DSP_ADDR_REG 0x17 /* DSP coefficient addr register */
#define BRGPHY_DSP_TAP_NUMBER_MASK 0x00
#define BRGPHY_DSP_AGC_A 0x00
#define BRGPHY_DSP_AGC_B 0x01
#define BRGPHY_DSP_MSE_PAIR_STATUS 0x02
#define BRGPHY_DSP_SOFT_DECISION 0x03
#define BRGPHY_DSP_PHASE_REG 0x04
#define BRGPHY_DSP_SKEW 0x05
#define BRGPHY_DSP_POWER_SAVER_UPPER_BOUND 0x06
#define BRGPHY_DSP_POWER_SAVER_LOWER_BOUND 0x07
#define BRGPHY_DSP_LAST_ECHO 0x08
#define BRGPHY_DSP_FREQUENCY 0x09
#define BRGPHY_DSP_PLL_BANDWIDTH 0x0A
#define BRGPHY_DSP_PLL_PHASE_OFFSET 0x0B
#define BRGPHYDSP_FILTER_DCOFFSET 0x0C00
#define BRGPHY_DSP_FILTER_FEXT3 0x0B00
#define BRGPHY_DSP_FILTER_FEXT2 0x0A00
#define BRGPHY_DSP_FILTER_FEXT1 0x0900
#define BRGPHY_DSP_FILTER_FEXT0 0x0800
#define BRGPHY_DSP_FILTER_NEXT3 0x0700
#define BRGPHY_DSP_FILTER_NEXT2 0x0600
#define BRGPHY_DSP_FILTER_NEXT1 0x0500
#define BRGPHY_DSP_FILTER_NEXT0 0x0400
#define BRGPHY_DSP_FILTER_ECHO 0x0300
#define BRGPHY_DSP_FILTER_DFE 0x0200
#define BRGPHY_DSP_FILTER_FFE 0x0100
#define BRGPHY_DSP_CONTROL_ALL_FILTERS 0x1000
#define BRGPHY_DSP_SEL_CH_0 0x0000
#define BRGPHY_DSP_SEL_CH_1 0x2000
#define BRGPHY_DSP_SEL_CH_2 0x4000
#define BRGPHY_DSP_SEL_CH_3 0x6000
#define BRGPHY_MII_AUXCTL 0x18 /* AUX control */
#define BRGPHY_AUXCTL_LOW_SQ 0x8000 /* Low squelch */
#define BRGPHY_AUXCTL_LONG_PKT 0x4000 /* RX long packets */
#define BRGPHY_AUXCTL_ER_CTL 0x3000 /* Edgerate control */
#define BRGPHY_AUXCTL_TX_TST 0x0400 /* TX test, always 1 */
#define BRGPHY_AUXCTL_DIS_PRF 0x0080 /* dis part resp filter */
#define BRGPHY_AUXCTL_DIAG_MODE 0x0004 /* Diagnostic mode */
#define BRGPHY_MII_AUXSTS 0x19 /* AUX status */
#define BRGPHY_AUXSTS_ACOMP 0x8000 /* autoneg complete */
#define BRGPHY_AUXSTS_AN_ACK 0x4000 /* autoneg complete ack */
#define BRGPHY_AUXSTS_AN_ACK_D 0x2000 /* autoneg complete ack detect */
#define BRGPHY_AUXSTS_AN_NPW 0x1000 /* autoneg next page wait */
#define BRGPHY_AUXSTS_AN_RES 0x0700 /* autoneg HCD */
#define BRGPHY_AUXSTS_PDF 0x0080 /* Parallel detect. fault */
#define BRGPHY_AUXSTS_RF 0x0040 /* remote fault */
#define BRGPHY_AUXSTS_ANP_R 0x0020 /* AN page received */
#define BRGPHY_AUXSTS_LP_ANAB 0x0010 /* LP AN ability */
#define BRGPHY_AUXSTS_LP_NPAB 0x0008 /* LP Next page ability */
#define BRGPHY_AUXSTS_LINK 0x0004 /* Link status */
#define BRGPHY_AUXSTS_PRR 0x0002 /* Pause resolution-RX */
#define BRGPHY_AUXSTS_PRT 0x0001 /* Pause resolution-TX */
#define BRGPHY_RES_1000FD 0x0700 /* 1000baseT full duplex */
#define BRGPHY_RES_1000HD 0x0600 /* 1000baseT half duplex */
#define BRGPHY_RES_100FD 0x0500 /* 100baseT full duplex */
#define BRGPHY_RES_100T4 0x0400 /* 100baseT4 */
#define BRGPHY_RES_100HD 0x0300 /* 100baseT half duplex */
#define BRGPHY_RES_10FD 0x0200 /* 10baseT full duplex */
#define BRGPHY_RES_10HD 0x0100 /* 10baseT half duplex */
/* 5906 */
#define BRGPHY_RES_100 0x0008 /* 100baseT */
#define BRGPHY_RES_FULL 0x0001 /* full duplex */
#define BRGPHY_MII_ISR 0x1A /* interrupt status */
#define BRGPHY_ISR_PSERR 0x4000 /* Pair swap error */
#define BRGPHY_ISR_MDXI_SC 0x2000 /* MDIX Status Change */
#define BRGPHY_ISR_HCT 0x1000 /* counter above 32K */
#define BRGPHY_ISR_LCT 0x0800 /* all counter below 128 */
#define BRGPHY_ISR_AN_PR 0x0400 /* Autoneg page received */
#define BRGPHY_ISR_NO_HDCL 0x0200 /* No HCD Link */
#define BRGPHY_ISR_NO_HDC 0x0100 /* No HCD */
#define BRGPHY_ISR_USHDC 0x0080 /* Negotiated Unsupported HCD */
#define BRGPHY_ISR_SCR_S_ERR 0x0040 /* Scrambler sync error */
#define BRGPHY_ISR_RRS_CHG 0x0020 /* Remote RX status change */
#define BRGPHY_ISR_LRS_CHG 0x0010 /* Local RX status change */
#define BRGPHY_ISR_DUP_CHG 0x0008 /* Duplex mode change */
#define BRGPHY_ISR_LSP_CHG 0x0004 /* Link speed changed */
#define BRGPHY_ISR_LNK_CHG 0x0002 /* Link status change */
#define BRGPHY_ISR_CRCERR 0x0001 /* CEC error */
#define BRGPHY_MII_IMR 0x1B /* interrupt mask */
#define BRGPHY_IMR_PSERR 0x4000 /* Pair swap error */
#define BRGPHY_IMR_MDXI_SC 0x2000 /* MDIX Status Change */
#define BRGPHY_IMR_HCT 0x1000 /* counter above 32K */
#define BRGPHY_IMR_LCT 0x0800 /* all counter below 128 */
#define BRGPHY_IMR_AN_PR 0x0400 /* Autoneg page received */
#define BRGPHY_IMR_NO_HDCL 0x0200 /* No HCD Link */
#define BRGPHY_IMR_NO_HDC 0x0100 /* No HCD */
#define BRGPHY_IMR_USHDC 0x0080 /* Negotiated Unsupported HCD */
#define BRGPHY_IMR_SCR_S_ERR 0x0040 /* Scrambler sync error */
#define BRGPHY_IMR_RRS_CHG 0x0020 /* Remote RX status change */
#define BRGPHY_IMR_LRS_CHG 0x0010 /* Local RX status change */
#define BRGPHY_IMR_DUP_CHG 0x0008 /* Duplex mode change */
#define BRGPHY_IMR_LSP_CHG 0x0004 /* Link speed changed */
#define BRGPHY_IMR_LNK_CHG 0x0002 /* Link status change */
#define BRGPHY_IMR_CRCERR 0x0001 /* CEC error */
/*******************************************************/
/* Begin: Shared SerDes PHY register definitions */
/*******************************************************/
/* SerDes autoneg is different from copper */
#define BRGPHY_SERDES_ANAR 0x04
#define BRGPHY_SERDES_ANAR_FDX 0x0020
#define BRGPHY_SERDES_ANAR_HDX 0x0040
#define BRGPHY_SERDES_ANAR_NO_PAUSE (0x0 << 7)
#define BRGPHY_SERDES_ANAR_SYM_PAUSE (0x1 << 7)
#define BRGPHY_SERDES_ANAR_ASYM_PAUSE (0x2 << 7)
#define BRGPHY_SERDES_ANAR_BOTH_PAUSE (0x3 << 7)
#define BRGPHY_SERDES_ANLPAR 0x05
#define BRGPHY_SERDES_ANLPAR_FDX 0x0020
#define BRGPHY_SERDES_ANLPAR_HDX 0x0040
#define BRGPHY_SERDES_ANLPAR_NO_PAUSE (0x0 << 7)
#define BRGPHY_SERDES_ANLPAR_SYM_PAUSE (0x1 << 7)
#define BRGPHY_SERDES_ANLPAR_ASYM_PAUSE (0x2 << 7)
#define BRGPHY_SERDES_ANLPAR_BOTH_PAUSE (0x3 << 7)
/*******************************************************/
/* End: Shared SerDes PHY register definitions */
/*******************************************************/
/*******************************************************/
/* Begin: PHY register values for the 5706 PHY */
/*******************************************************/
/*
* Shadow register 0x1C, bit 15 is write enable,
* bits 14-10 select function (0x00 to 0x1F).
*/
#define BRGPHY_MII_SHADOW_1C 0x1C
#define BRGPHY_SHADOW_1C_WRITE_EN 0x8000
#define BRGPHY_SHADOW_1C_SELECT_MASK 0x7C00
/* Shadow 0x1C Mode Control Register (select value 0x1F) */
#define BRGPHY_SHADOW_1C_MODE_CTRL (0x1F << 10)
/* When set, Regs 0-0x0F are 1000X, else 1000T */
#define BRGPHY_SHADOW_1C_ENA_1000X 0x0001
#define BRGPHY_TEST1 0x1E
#define BRGPHY_TEST1_TRIM_EN 0x0010
#define BRGPHY_TEST1_CRC_EN 0x8000
#define BRGPHY_MII_TEST2 0x1F
/*******************************************************/
/* End: PHY register values for the 5706 PHY */
/*******************************************************/
/*******************************************************/
/* Begin: PHY register values for the 5708S SerDes PHY */
/*******************************************************/
#define BRGPHY_5708S_BMCR_2500 0x20
/* Autoneg Next Page Transmit 1 Regiser */
#define BRGPHY_5708S_ANEG_NXT_PG_XMIT1 0x0B
#define BRGPHY_5708S_ANEG_NXT_PG_XMIT1_25G 0x0001
/* Use the BLOCK_ADDR register to select the page for registers 0x10 to 0x1E */
#define BRGPHY_5708S_BLOCK_ADDR 0x1f
#define BRGPHY_5708S_DIG_PG0 0x0000
#define BRGPHY_5708S_DIG3_PG2 0x0002
#define BRGPHY_5708S_TX_MISC_PG5 0x0005
/* 5708S SerDes "Digital" Registers (page 0) */
#define BRGPHY_5708S_PG0_1000X_CTL1 0x10
#define BRGPHY_5708S_PG0_1000X_CTL1_FIBER_MODE 0x0001
#define BRGPHY_5708S_PG0_1000X_CTL1_AUTODET_EN 0x0010
#define BRGPHY_5708S_PG0_1000X_STAT1 0x14
#define BRGPHY_5708S_PG0_1000X_STAT1_SGMII 0x0001
#define BRGPHY_5708S_PG0_1000X_STAT1_LINK 0x0002
#define BRGPHY_5708S_PG0_1000X_STAT1_FDX 0x0004
#define BRGPHY_5708S_PG0_1000X_STAT1_SPEED_MASK 0x0018
#define BRGPHY_5708S_PG0_1000X_STAT1_SPEED_10 (0x0 << 3)
#define BRGPHY_5708S_PG0_1000X_STAT1_SPEED_100 (0x1 << 3)
#define BRGPHY_5708S_PG0_1000X_STAT1_SPEED_1G (0x2 << 3)
#define BRGPHY_5708S_PG0_1000X_STAT1_SPEED_25G (0x3 << 3)
#define BRGPHY_5708S_PG0_1000X_CTL2 0x11
#define BRGPHY_5708S_PG0_1000X_CTL2_PAR_DET_EN 0x0001
/* 5708S SerDes "Digital 3" Registers (page 2) */
#define BRGPHY_5708S_PG2_DIGCTL_3_0 0x10
#define BRGPHY_5708S_PG2_DIGCTL_3_0_USE_IEEE 0x0001
/* 5708S SerDes "TX Misc" Registers (page 5) */
#define BRGPHY_5708S_PG5_2500STATUS1 0x10
#define BRGPHY_5708S_PG5_TXACTL1 0x15
#define BRGPHY_5708S_PG5_TXACTL1_VCM 0x30
#define BRGPHY_5708S_PG5_TXACTL3 0x17
/*******************************************************/
/* End: PHY register values for the 5708S SerDes PHY */
/*******************************************************/
/*******************************************************/
/* Begin: PHY register values for the 5709S SerDes PHY */
/*******************************************************/
/* 5709S SerDes "General Purpose Status" Registers */
#define BRGPHY_BLOCK_ADDR_GP_STATUS 0x8120
#define BRGPHY_GP_STATUS_TOP_ANEG_STATUS 0x1B
#define BRGPHY_GP_STATUS_TOP_ANEG_SPEED_MASK 0x3F00
#define BRGPHY_GP_STATUS_TOP_ANEG_SPEED_10 0x0000
#define BRGPHY_GP_STATUS_TOP_ANEG_SPEED_100 0x0100
#define BRGPHY_GP_STATUS_TOP_ANEG_SPEED_1G 0x0200
#define BRGPHY_GP_STATUS_TOP_ANEG_SPEED_25G 0x0300
#define BRGPHY_GP_STATUS_TOP_ANEG_SPEED_1GKX 0x0D00
#define BRGPHY_GP_STATUS_TOP_ANEG_FDX 0x0008
#define BRGPHY_GP_STATUS_TOP_ANEG_LINK_UP 0x0004
#define BRGPHY_GP_STATUS_TOP_ANEG_CL73_COMP 0x0001
/* 5709S SerDes "SerDes Digital" Registers */
#define BRGPHY_BLOCK_ADDR_SERDES_DIG 0x8300
#define BRGPHY_SERDES_DIG_1000X_CTL1 0x0010
#define BRGPHY_SD_DIG_1000X_CTL1_AUTODET 0x0010
#define BRGPHY_SD_DIG_1000X_CTL1_FIBER 0x0001
/* 5709S SerDes "Over 1G" Registers */
#define BRGPHY_BLOCK_ADDR_OVER_1G 0x8320
#define BRGPHY_OVER_1G_UNFORMAT_PG1 0x19
/* 5709S SerDes "Multi-Rate Backplane Ethernet" Registers */
#define BRGPHY_BLOCK_ADDR_MRBE 0x8350
#define BRGPHY_MRBE_MSG_PG5_NP 0x10
#define BRGPHY_MRBE_MSG_PG5_NP_MBRE 0x0001
#define BRGPHY_MRBE_MSG_PG5_NP_T2 0x0001
/* 5709S SerDes "IEEE Clause 73 User B0" Registers */
#define BRGPHY_BLOCK_ADDR_CL73_USER_B0 0x8370
#define BRGPHY_CL73_USER_B0_MBRE_CTL1 0x12
#define BRGPHY_CL73_USER_B0_MBRE_CTL1_NP_AFT_BP 0x2000
#define BRGPHY_CL73_USER_B0_MBRE_CTL1_STA_MGR 0x4000
#define BRGPHY_CL73_USER_B0_MBRE_CTL1_ANEG 0x8000
/* 5709S SerDes "IEEE Clause 73 User B0" Registers */
#define BRGPHY_BLOCK_ADDR_ADDR_EXT 0xFFD0
/* 5709S SerDes "Combo IEEE 0" Registers */
#define BRGPHY_BLOCK_ADDR_COMBO_IEEE0 0xFFE0
#define BRGPHY_ADDR_EXT 0x1E
#define BRGPHY_BLOCK_ADDR 0x1F
#define BRGPHY_ADDR_EXT_AN_MMD 0x3800
/*******************************************************/
/* End: PHY register values for the 5709S SerDes PHY */
/*******************************************************/
#define BRGPHY_INTRS \
~(BRGPHY_IMR_LNK_CHG|BRGPHY_IMR_LSP_CHG|BRGPHY_IMR_DUP_CHG)
#endif /* _DEV_BRGPHY_MIIREG_H_ */

4
sys/dev/mii/files.mii

@ -4,6 +4,10 @@ file sys/dev/mii/mii.c mii
define mii_phy
file sys/dev/mii/mii_physubr.c mii_phy
device brgphy: mii_phy
attach brgphy at mii
file sys/dev/mii/brgphy.c brgphy
device inphy: mii_phy
attach inphy at mii
file sys/dev/mii/inphy.c inphy

10
sys/dev/mii/mii.c

@ -74,7 +74,12 @@ mii_phy_probe(parent, mii, capmask)
struct mii_attach_args ma;
struct mii_softc *child;
LIST_INIT(&mii->mii_phys);
//LIST_INIT(&mii->mii_phys);//wan-
//wan+
if ((mii->mii_flags & MIIF_INITDONE) == 0) {
LIST_INIT(&mii->mii_phys);
mii->mii_flags |= MIIF_INITDONE;
}
for (ma.mii_phyno = 0; ma.mii_phyno < MII_NPHY; ma.mii_phyno++) {
/*
@ -109,6 +114,7 @@ mii_phy_probe(parent, mii, capmask)
ma.mii_data = mii;
ma.mii_capmask = capmask;
ma.mii_flags = (mii->mii_flags & MIIF_INHERIT_MASK);//wan+
if ((child = (struct mii_softc *)config_found_sm(parent, &ma,
mii_print, mii_submatch)) != NULL) {
@ -163,7 +169,7 @@ mii_submatch(parent, match, aux)
cf->cf_loc[MIICF_PHY] != MIICF_PHY_DEFAULT)
return (0);
return ((*cf->cf_attach->ca_match)(parent, cf, aux));
return ((*cf->cf_attach->ca_match)(parent, cf, aux));//wan: valid
}
/*

65
sys/dev/mii/mii.h

@ -73,11 +73,47 @@
#define MII_TPISTATUS 0x1b /* TPI status for 10mbps */
#define MII_NCONFIG 0x1c /* Network interface config */
//wan #if 0
#define BMSR_EXTSTAT 0x0100 /* Extended status in register 15 */
#define BMCR_SPEED0 0x2000 /* speed selection (LSB) */
#define BMCR_SPEED1 0x0040 /* speed selection (MSB) */
#define BMCR_S10 0x0000 /* 10 Mb/s */
#define BMCR_S100 BMCR_SPEED0 /* 100 Mb/s */
#define BMCR_S1000 BMCR_SPEED1 /* 1000 Mb/s */
/* This is also the 1000baseT control register */
#define MII_100T2CR 0x09 /* 100base-T2 control register */
#define GTCR_TEST_MASK 0xe000 /* see 802.3ab ss. 40.6.1.1.2 */
#define GTCR_MAN_MS 0x1000 /* enable manual master/slave control */
#define GTCR_ADV_MS 0x0800 /* 1 = adv. master, 0 = adv. slave */
#define GTCR_PORT_TYPE 0x0400 /* 1 = DCE, 0 = DTE (NIC) */
#define GTCR_ADV_1000TFDX 0x0200 /* adv. 1000baseT FDX */
#define GTCR_ADV_1000THDX 0x0100 /* adv. 1000baseT HDX */
/* This is also the 1000baseT status register */
#define MII_100T2SR 0x0a /* 100base-T2 status register */
#define GTSR_MAN_MS_FLT 0x8000 /* master/slave config fault */
#define GTSR_MS_RES 0x4000 /* result: 1 = master, 0 = slave */
#define GTSR_LRS 0x2000 /* local rx status, 1 = ok */
#define GTSR_RRS 0x1000 /* remove rx status, 1 = ok */
#define GTSR_LP_1000TFDX 0x0800 /* link partner 1000baseT FDX capable */
#define GTSR_LP_1000THDX 0x0400 /* link partner 1000baseT HDX capable */
#define GTSR_LP_ASM_DIR 0x0200 /* link partner asym. pause dir. capable */
#define GTSR_IDLE_ERR 0x00ff /* IDLE error count */
#define MII_EXTSR 0x0f /* Extended status register */
#define EXTSR_1000XFDX 0x8000 /* 1000X full-duplex capable */
#define EXTSR_1000XHDX 0x4000 /* 1000X half-duplex capable */
#define EXTSR_1000TFDX 0x2000 /* 1000T full-duplex capable */
#define EXTSR_1000THDX 0x1000 /* 1000T half-duplex capable */
#define EXTSR_MEDIAMASK (EXTSR_1000XFDX|EXTSR_1000XHDX| \
EXTSR_1000TFDX|EXTSR_1000THDX)
//wan #endif
#define MII_BMCR 0x00 /* Basic mode control register (rw) */
#define BMCR_RESET 0x8000 /* reset */
#define BMCR_LOOP 0x4000 /* loopback */
#define BMCR_S100 0x2000 /* speed (10/100) select */
//wan #define BMCR_S100 0x2000 /* speed (10/100) select */
#define BMCR_AUTOEN 0x1000 /* autonegotiation enable */
#define BMCR_PDOWN 0x0800 /* power down */
#define BMCR_ISO 0x0400 /* isolate */
@ -140,6 +176,27 @@
#define ANLPAR_10 0x0020 /* link partner supports 10bT */
#define ANLPAR_CSMA 0x0001 /* protocol selector CSMA/CD */
//wan #if 0
#define ANLPAR_PAUSE_SYM (1 << 10)
#define ANLPAR_PAUSE_TOWARDS (3 << 10)
#define ANLPAR_PAUSE_NONE (0 << 10)
#define ANLPAR_PAUSE_ASYM (2 << 10)
#define ANAR_FC 0x0400 /* local device supports PAUSE */
#define ANAR_PAUSE_NONE (0 << 10)
#define ANAR_PAUSE_SYM (1 << 10)
#define ANAR_PAUSE_ASYM (2 << 10)
#define ANAR_PAUSE_TOWARDS (3 << 10)
#define ANAR_X_FD 0x0020 /* local device supports 1000BASE-X FD */
#define ANAR_X_HD 0x0040 /* local device supports 1000BASE-X HD */
#define ANAR_X_PAUSE_NONE (0 << 7)
#define ANAR_X_PAUSE_SYM (1 << 7)
#define ANAR_X_PAUSE_ASYM (2 << 7)
#define ANAR_X_PAUSE_TOWARDS (3 << 7)
//wan #endif
#define MII_ANER 0x06 /* Autonegotiation expansion (ro) */
#define ANER_MLF 0x0010 /* multiple link detection fault */
#define ANER_LPNP 0x0008 /* link parter next page-able */
@ -147,6 +204,12 @@
#define ANER_PAGE_RX 0x0002 /* Page received */
#define ANER_LPAN 0x0001 /* link parter autoneg-able */
#define MII_ANNP 0x07 /* Autonegotiation next page */
/* section 28.2.4.1 and 37.2.6.1 */
#define MII_ANLPRNP 0x08 /* Autonegotiation link partner rx next page */
/* section 32.5.1 and 37.2.6.1 */
/* Basic mode control register. */
#define BMCR_RESV 0x003f /* Unused... */
#define BMCR_SPEED1000 0x0040 /* MSB of Speed (1000) */

513
sys/dev/mii/mii_physubr.c

@ -1,8 +1,8 @@
/* $OpenBSD: mii_physubr.c,v 1.3 1999/12/07 22:01:31 jason Exp $ */
/* $NetBSD: mii_physubr.c,v 1.2.6.1 1999/04/23 15:40:26 perry Exp $ */
/* $OpenBSD: mii_physubr.c,v 1.39 2009/10/13 19:33:16 pirofti Exp $ */
/* $NetBSD: mii_physubr.c,v 1.20 2001/04/13 23:30:09 thorpej Exp $ */
/*-
* Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
* Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -17,13 +17,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
@ -48,34 +41,55 @@
#include <sys/kernel.h>
#include <sys/socket.h>
#include <sys/errno.h>
#include <sys/proc.h>
#include <net/if.h>
#include <net/if_media.h>
#include <dev/mii/mii.h>
#include <dev/mii/miivar.h>
void mii_phy_auto_timeout(void *arg);//wan+
/*
* Media to register setting conversion table. Order matters.
* XXX 802.3 doesn't specify ANAR or ANLPAR bits for 1000base.
*/
const struct mii_media mii_media_table[] = {
{ BMCR_ISO, ANAR_CSMA }, /* None */
{ 0, ANAR_CSMA|ANAR_10 }, /* 10baseT */
{ BMCR_FDX, ANAR_CSMA|ANAR_10_FD }, /* 10baseT-FDX */
{ BMCR_S100, ANAR_CSMA|ANAR_T4 }, /* 100baseT4 */
{ BMCR_S100, ANAR_CSMA|ANAR_TX }, /* 100baseTX */
{ BMCR_S100|BMCR_FDX, ANAR_CSMA|ANAR_TX_FD }, /* 100baseTX-FDX */
/* None */
{ BMCR_ISO, ANAR_CSMA, 0 },
/* 10baseT */
{ BMCR_S10, ANAR_CSMA|ANAR_10, 0 },
/* 10baseT-FDX */
{ BMCR_S10|BMCR_FDX, ANAR_CSMA|ANAR_10_FD, 0 },
/* 100baseT4 */
{ BMCR_S100, ANAR_CSMA|ANAR_T4, 0 },
/* 100baseTX */
{ BMCR_S100, ANAR_CSMA|ANAR_TX, 0 },
/* 100baseTX-FDX */
{ BMCR_S100|BMCR_FDX, ANAR_CSMA|ANAR_TX_FD, 0 },
/* 1000baseX */
{ BMCR_S1000, ANAR_CSMA, 0 },
/* 1000baseX-FDX */
{ BMCR_S1000|BMCR_FDX, ANAR_CSMA, 0 },
/* 1000baseT */
{ BMCR_S1000, ANAR_CSMA, GTCR_ADV_1000THDX },
/* 1000baseT-FDX */
{ BMCR_S1000|BMCR_FDX, ANAR_CSMA, GTCR_ADV_1000TFDX },
};
void mii_phy_auto_timeout __P((void *));
void
mii_phy_setmedia(sc)
struct mii_softc *sc;
mii_phy_setmedia(struct mii_softc *sc)
{
struct mii_data*mii = sc->mii_pdata;
struct mii_data *mii = sc->mii_pdata;
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
int bmcr, anar;
int bmcr, anar, gtcr;
if (IFM_SUBTYPE(ife->ifm_media) == IFM_AUTO) {
if ((PHY_READ(sc, MII_BMCR) & BMCR_AUTOEN) == 0 ||
(sc->mii_flags & MIIF_FORCEANEG))
(void) mii_phy_auto(sc, 1);
return;
}
/*
* Table index is stored in the media entry.
@ -88,37 +102,88 @@ mii_phy_setmedia(sc)
anar = mii_media_table[ife->ifm_data].mm_anar;
bmcr = mii_media_table[ife->ifm_data].mm_bmcr;
gtcr = mii_media_table[ife->ifm_data].mm_gtcr;
if (mii->mii_media.ifm_media & IFM_ETH_MASTER) {
switch (IFM_SUBTYPE(ife->ifm_media)) {
case IFM_1000_T:
gtcr |= GTCR_MAN_MS|GTCR_ADV_MS;
break;
default:
panic("mii_phy_setmedia: MASTER on wrong media");
}
}
if (ife->ifm_media & IFM_LOOP)
bmcr |= BMCR_LOOP;
PHY_WRITE(sc, MII_ANAR, anar);
PHY_WRITE(sc, MII_BMCR, bmcr);
if (sc->mii_flags & MIIF_HAVE_GTCR)
PHY_WRITE(sc, MII_100T2CR, gtcr);
}
int
mii_phy_auto(mii, waitfor)
struct mii_softc *mii;
mii_phy_auto(struct mii_softc *sc, int waitfor)
{
int bmsr, i;
if ((mii->mii_flags & MIIF_DOINGAUTO) == 0) {
PHY_WRITE(mii, MII_ANAR,
BMSR_MEDIA_TO_ANAR(mii->mii_capabilities) | ANAR_CSMA);
PHY_WRITE(mii, MII_BMCR, BMCR_AUTOEN | BMCR_STARTNEG);
if ((sc->mii_flags & MIIF_DOINGAUTO) == 0) {
/*
* Check for 1000BASE-X. Autonegotiation is a bit
* different on such devices.
*/
if (sc->mii_flags & MIIF_IS_1000X) {
uint16_t anar = 0;
if (sc->mii_extcapabilities & EXTSR_1000XFDX)
anar |= ANAR_X_FD;
if (sc->mii_extcapabilities & EXTSR_1000XHDX)
anar |= ANAR_X_HD;
if (sc->mii_flags & MIIF_DOPAUSE &&
sc->mii_extcapabilities & EXTSR_1000XFDX)
anar |= ANAR_X_PAUSE_TOWARDS;
PHY_WRITE(sc, MII_ANAR, anar);
} else {
uint16_t anar;
anar = BMSR_MEDIA_TO_ANAR(sc->mii_capabilities) |
ANAR_CSMA;
/*
* Most 100baseTX PHY's only support symmetric
* PAUSE, so we don't advertise asymmetric
* PAUSE unless we also have 1000baseT capability.
*/
if (sc->mii_flags & MIIF_DOPAUSE) {
if (sc->mii_capabilities & BMSR_100TXFDX)
anar |= ANAR_FC;
if (sc->mii_extcapabilities & EXTSR_1000TFDX)
anar |= ANAR_PAUSE_TOWARDS;
}
PHY_WRITE(sc, MII_ANAR, anar);
if (sc->mii_flags & MIIF_HAVE_GTCR) {
uint16_t gtcr = 0;
if (sc->mii_extcapabilities & EXTSR_1000TFDX)
gtcr |= GTCR_ADV_1000TFDX;
if (sc->mii_extcapabilities & EXTSR_1000THDX)
gtcr |= GTCR_ADV_1000THDX;
PHY_WRITE(sc, MII_100T2CR, gtcr);
}
}
PHY_WRITE(sc, MII_BMCR, BMCR_AUTOEN | BMCR_STARTNEG);
}
if (waitfor) {
/* Wait 500ms for it to complete. */
for (i = 0; i < 500; i++) {
if ((bmsr = PHY_READ(mii, MII_BMSR)) & BMSR_ACOMP)
if ((bmsr = PHY_READ(sc, MII_BMSR)) & BMSR_ACOMP)
return (0);
delay(1000);
#if 0
if ((bmsr & BMSR_ACOMP) == 0)
printf("%s: autonegotiation failed to complete\n",
mii->mii_dev.dv_xname);
#endif
}
/*
@ -134,70 +199,206 @@ mii_phy_auto(mii, waitfor)
* the tick handler driving autonegotiation. Don't want 500ms
* delays all the time while the system is running!
*/
if ((mii->mii_flags & MIIF_DOINGAUTO) == 0) {
mii->mii_flags |= MIIF_DOINGAUTO;
timeout(mii_phy_auto_timeout, mii, hz >> 1);
if (sc->mii_flags & MIIF_AUTOTSLEEP) {
sc->mii_flags |= MIIF_DOINGAUTO;
tsleep(&sc->mii_flags, PZERO, "miiaut", hz >> 1);
mii_phy_auto_timeout(sc);
} else if ((sc->mii_flags & MIIF_DOINGAUTO) == 0) {
sc->mii_flags |= MIIF_DOINGAUTO;
// timeout_set(&sc->mii_phy_timo, mii_phy_auto_timeout, sc);//wan-
// timeout_add_msec(&sc->mii_phy_timo, 500);//wan-
}
return (EJUSTRETURN);
}
void
mii_phy_auto_timeout(arg)
void *arg;
mii_phy_auto_timeout(void *arg)
{
struct mii_softc *mii = arg;
struct mii_softc *sc = arg;
int s, bmsr;
if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0)
return;
s = splnet();
mii->mii_flags &= ~MIIF_DOINGAUTO;
bmsr = PHY_READ(mii, MII_BMSR);
sc->mii_flags &= ~MIIF_DOINGAUTO;
bmsr = PHY_READ(sc, MII_BMSR);
/* Update the media status. */
(void) (*mii->mii_service)(mii, mii->mii_pdata, MII_POLLSTAT);
(void) PHY_SERVICE(sc, sc->mii_pdata, MII_POLLSTAT);
splx(s);
}
int
mii_phy_tick(struct mii_softc *sc)
{
struct mii_data *mii = sc->mii_pdata;
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
int reg;
/* Just bail now if the interface is down. */
if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
return (EJUSTRETURN);
/*
* If we're not doing autonegotiation, we don't need to do
* any extra work here. However, we need to check the link
* status so we can generate an announcement if the status
* changes.
*/
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
return (0);
/* Read the status register twice; BMSR_LINK is latch-low. */
reg = PHY_READ(sc, MII_BMSR) | PHY_READ(sc, MII_BMSR);
if (reg & BMSR_LINK) {
/*
* See above.
*/
return (0);
}
/*
* Only retry autonegotiation every mii_anegticks seconds.
*/
if (!sc->mii_anegticks)
sc->mii_anegticks = MII_ANEGTICKS;
if (++sc->mii_ticks <= sc->mii_anegticks)
return (EJUSTRETURN);
sc->mii_ticks = 0;
PHY_RESET(sc);
if (mii_phy_auto(sc, 0) == EJUSTRETURN)
return (EJUSTRETURN);
/*
* Might need to generate a status message if autonegotiation
* failed.
*/
return (0);
}
void
mii_phy_reset(mii)
struct mii_softc *mii;
mii_phy_reset(struct mii_softc *sc)
{
int reg, i;
if (mii->mii_flags & MIIF_NOISOLATE)
if (sc->mii_flags & MIIF_NOISOLATE)//sc->mii_flags = 6
reg = BMCR_RESET;
else
reg = BMCR_RESET | BMCR_ISO;
PHY_WRITE(mii, MII_BMCR, reg);
PHY_WRITE(sc, MII_BMCR, reg);
/*
* It is best to allow a little time for the reset to settle
* in before we start polling the BMCR again. Notably, the
* DP83840A manual states that there should be a 500us delay
* between asserting software reset and attempting MII serial
* operations. Also, a DP83815 can get into a bad state on
* cable removal and reinsertion if we do not delay here.
*/
delay(500);
/* Wait 100ms for it to complete. */
/* Wait another 100ms for it to complete. */
for (i = 0; i < 100; i++) {
reg = PHY_READ(mii, MII_BMCR);
reg = PHY_READ(sc, MII_BMCR);
if ((reg & BMCR_RESET) == 0)
break;
delay(1000);
}
if (mii->mii_inst != 0 && ((mii->mii_flags & MIIF_NOISOLATE) == 0))
PHY_WRITE(mii, MII_BMCR, reg | BMCR_ISO);
if (sc->mii_inst != 0 && ((sc->mii_flags & MIIF_NOISOLATE) == 0))//wan: invalid
PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
}
void
mii_phy_down(sc)
struct mii_softc *sc;
mii_phy_down(struct mii_softc *sc)
{
if (sc->mii_flags & MIIF_DOINGAUTO) {
sc->mii_flags &= ~MIIF_DOINGAUTO;
untimeout(mii_phy_auto_timeout, sc);
// timeout_del(&sc->mii_phy_timo);//wan-
}
}
void
mii_phy_status(struct mii_softc *sc)
{
PHY_STATUS(sc);
}
void
mii_phy_update(struct mii_softc *sc, int cmd)
{
struct mii_data *mii = sc->mii_pdata;
struct ifnet *ifp = mii->mii_ifp;
int announce, s;
if (sc->mii_media_active != mii->mii_media_active ||
sc->mii_media_status != mii->mii_media_status ||
cmd == MII_MEDIACHG) {
announce = mii_phy_statusmsg(sc);
(*mii->mii_statchg)(sc->mii_dev.dv_parent);
sc->mii_media_active = mii->mii_media_active;
sc->mii_media_status = mii->mii_media_status;
//wan
#if 0
if (announce) {
s = splnet();
if_link_state_change(ifp);
splx(s);
}
#endif
}
}
int
mii_phy_statusmsg(struct mii_softc *sc)
{
struct mii_data *mii = sc->mii_pdata;
struct ifnet *ifp = mii->mii_ifp;
u_int64_t baudrate;
int link_state, announce = 0;
if (mii->mii_media_status & IFM_AVALID) {
if (mii->mii_media_status & IFM_ACTIVE) {
if (mii->mii_media_active & IFM_FDX)
link_state = LINK_STATE_FULL_DUPLEX;
else
link_state = LINK_STATE_HALF_DUPLEX;
} else
link_state = LINK_STATE_DOWN;
} else
link_state = LINK_STATE_UNKNOWN;
baudrate = ifmedia_baudrate(mii->mii_media_active);
if (link_state != ifp->if_link_state) {
ifp->if_link_state = link_state;
/*
* XXX Right here we'd like to notify protocols
* XXX that the link status has changed, so that
* XXX e.g. Duplicate Address Detection can restart.
*/
announce = 1;
}
if (baudrate != ifp->if_baudrate) {
ifp->if_baudrate = baudrate;
announce = 1;
}
return (announce);
}
/*
* Initialize generic PHY media based on BMSR, called when a PHY is
* attached. We expect to be set up to print a comma-separated list
* of media names. Does not print a newline.
* attached.
*/
void
mii_add_media(sc)
struct mii_softc *sc;
mii_phy_add_media(struct mii_softc *sc)
{
struct mii_data *mii = sc->mii_pdata;
@ -210,16 +411,12 @@ mii_add_media(sc)
if (sc->mii_capabilities & BMSR_10THDX) {
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_T, 0, sc->mii_inst),
MII_MEDIA_10_T);
#if 0
if ((sc->mii_flags & MIIF_NOLOOP) == 0)
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_T, IFM_LOOP,
sc->mii_inst), MII_MEDIA_10_T);
#endif
}
if (sc->mii_capabilities & BMSR_10TFDX)
if (sc->mii_capabilities & BMSR_10TFDX) {
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_T, IFM_FDX, sc->mii_inst),
MII_MEDIA_10_T_FDX);
}
if (sc->mii_capabilities & BMSR_100TXHDX) {
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, 0, sc->mii_inst),
MII_MEDIA_100_TX);
@ -229,9 +426,10 @@ mii_add_media(sc)
sc->mii_inst), MII_MEDIA_100_T4);
#endif
}
if (sc->mii_capabilities & BMSR_100TXFDX)
if (sc->mii_capabilities & BMSR_100TXFDX) {
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_FDX, sc->mii_inst),
MII_MEDIA_100_TX_FDX);
}
if (sc->mii_capabilities & BMSR_100T4) {
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_T4, 0, sc->mii_inst),
MII_MEDIA_100_T4);
@ -241,8 +439,191 @@ mii_add_media(sc)
sc->mii_inst), MII_MEDIA_100_T4);
#endif
}
if (sc->mii_capabilities & BMSR_ANEG)
if (sc->mii_extcapabilities & EXTSR_MEDIAMASK) {
/*
* XXX Right now only handle 1000SX and 1000TX. Need
* XXX to handle 1000LX and 1000CX some how.
*/
if (sc->mii_extcapabilities & EXTSR_1000XHDX) {
sc->mii_anegticks = MII_ANEGTICKS_GIGE;
sc->mii_flags |= MIIF_IS_1000X;
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_1000_SX, 0,
sc->mii_inst), MII_MEDIA_1000_X);
}
if (sc->mii_extcapabilities & EXTSR_1000XFDX) {
sc->mii_anegticks = MII_ANEGTICKS_GIGE;
sc->mii_flags |= MIIF_IS_1000X;
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_1000_SX, IFM_FDX,
sc->mii_inst), MII_MEDIA_1000_X_FDX);
}
/*
* 1000baseT media needs to be able to manipulate
* master/slave mode. We set IFM_ETH_MASTER in
* the "don't care mask" and filter it out when
* the media is set.
*
* All 1000baseT PHYs have a 1000baseT control register.
*/
if (sc->mii_extcapabilities & EXTSR_1000THDX) {
sc->mii_anegticks = MII_ANEGTICKS_GIGE;
sc->mii_flags |= MIIF_HAVE_GTCR;
mii->mii_media.ifm_mask |= IFM_ETH_MASTER;
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_1000_T, 0,
sc->mii_inst), MII_MEDIA_1000_T);
}
if (sc->mii_extcapabilities & EXTSR_1000TFDX) {
sc->mii_anegticks = MII_ANEGTICKS_GIGE;
sc->mii_flags |= MIIF_HAVE_GTCR;
mii->mii_media.ifm_mask |= IFM_ETH_MASTER;
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_1000_T, IFM_FDX,
sc->mii_inst), MII_MEDIA_1000_T_FDX);
}
}
if (sc->mii_capabilities & BMSR_ANEG) {
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_AUTO, 0, sc->mii_inst),
MII_NMEDIA); /* intentionally invalid index */
}
#undef ADD
}
//wan+: Just used for compatible with old version
void
mii_add_media(struct mii_softc *sc)
{
mii_phy_add_media(sc);
return;
}
void
mii_phy_delete_media(struct mii_softc *sc)
{
struct mii_data *mii = sc->mii_pdata;
ifmedia_delete_instance(&mii->mii_media, sc->mii_inst);
}
int
mii_phy_activate(struct device *self, int act)
{
int rv = 0;
switch (act) {
case DVACT_ACTIVATE:
break;
case DVACT_DEACTIVATE:
/* Nothing special to do. */
break;
}
return (rv);
}
int
mii_phy_detach(struct device *self, int flags)
{
struct mii_softc *sc = (void *) self;
if (sc->mii_flags & MIIF_DOINGAUTO);
// timeout_del(&sc->mii_phy_timo);//wan-
mii_phy_delete_media(sc);
return (0);
}
const struct mii_phydesc *
mii_phy_match(const struct mii_attach_args *ma, const struct mii_phydesc *mpd)
{
for (; mpd->mpd_name != NULL; mpd++) {
if (MII_OUI(ma->mii_id1, ma->mii_id2) == mpd->mpd_oui &&
MII_MODEL(ma->mii_id2) == mpd->mpd_model)
return (mpd);
}
return (NULL);
}
/*
* Return the flow control status flag from MII_ANAR & MII_ANLPAR.
*/
int
mii_phy_flowstatus(struct mii_softc *sc)
{
int anar, anlpar;
if ((sc->mii_flags & MIIF_DOPAUSE) == 0)
return (0);
anar = PHY_READ(sc, MII_ANAR);
anlpar = PHY_READ(sc, MII_ANLPAR);
/* For 1000baseX, the bits are in a different location. */
if (sc->mii_flags & MIIF_IS_1000X) {
anar <<= 3;
anlpar <<= 3;
}
if ((anar & ANAR_PAUSE_SYM) & (anlpar & ANLPAR_PAUSE_SYM))
return (IFM_FLOW|IFM_ETH_TXPAUSE|IFM_ETH_RXPAUSE);
if ((anar & ANAR_PAUSE_SYM) == 0) {
if ((anar & ANAR_PAUSE_ASYM) &&
((anlpar & ANLPAR_PAUSE_TOWARDS) == ANLPAR_PAUSE_TOWARDS))
return (IFM_FLOW|IFM_ETH_TXPAUSE);
else
return (0);
}
if ((anar & ANAR_PAUSE_ASYM) == 0) {
if (anlpar & ANLPAR_PAUSE_SYM)
return (IFM_FLOW|IFM_ETH_TXPAUSE|IFM_ETH_RXPAUSE);
else
return (0);
}
switch ((anlpar & ANLPAR_PAUSE_TOWARDS)) {
case ANLPAR_PAUSE_NONE:
return (0);
case ANLPAR_PAUSE_ASYM:
return (IFM_FLOW|IFM_ETH_RXPAUSE);
default:
return (IFM_FLOW|IFM_ETH_RXPAUSE|IFM_ETH_TXPAUSE);
}
/* NOTREACHED */
}
/*
* Given an ifmedia word, return the corresponding ANAR value.
*/
int
mii_anar(int media)
{
int rv;
switch (media & (IFM_TMASK|IFM_NMASK|IFM_FDX)) {
case IFM_ETHER|IFM_10_T:
rv = ANAR_10|ANAR_CSMA;
break;
case IFM_ETHER|IFM_10_T|IFM_FDX:
rv = ANAR_10_FD|ANAR_CSMA;
break;
case IFM_ETHER|IFM_100_TX:
rv = ANAR_TX|ANAR_CSMA;
break;
case IFM_ETHER|IFM_100_TX|IFM_FDX:
rv = ANAR_TX_FD|ANAR_CSMA;
break;
case IFM_ETHER|IFM_100_T4:
rv = ANAR_T4|ANAR_CSMA;
break;
default:
rv = 0;
break;
}
return (rv);
}

408
sys/dev/mii/miidevs.h

@ -1,10 +1,9 @@
/* $OpenBSD: miidevs.h,v 1.29 2001/12/15 02:41:38 deraadt Exp $ */
/* $OpenBSD: miidevs.h,v 1.119 2011/01/21 09:47:03 kevlo Exp $ */
/*
* THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.
*
* generated from:
* OpenBSD: miidevs,v 1.26 2001/12/15 02:41:33 deraadt Exp
* OpenBSD: miidevs,v 1.116 2011/01/21 09:46:13 kevlo Exp
*/
/* $NetBSD: miidevs,v 1.3 1998/11/05 03:43:43 thorpej Exp $ */
@ -24,13 +23,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
@ -49,39 +41,58 @@
* List of known MII OUIs
*/
#define MII_OUI_AMD 0x00001a /* AMD */
#define MII_OUI_REALTEK 0x000020 /* Realtek */
#define MII_OUI_VITESSE 0x0001c1 /* Vitesse */
#define MII_OUI_CICADA 0x0003f1 /* Cicada */
#define MII_OUI_CENIX 0x000749 /* CENiX */
#define MII_OUI_BROADCOM2 0x000af7 /* Broadcom */
#define MII_OUI_RDC 0x000bb4 /* RDC Semi. */
#define MII_OUI_ASIX 0x000ec6 /* ASIX */
#define MII_OUI_BROADCOM 0x001018 /* Broadcom */
#define MII_OUI_3COM 0x00105a /* 3com */
#define MII_OUI_ALTIMA 0x0010a9 /* Altima Communications */
#define MII_OUI_AMD 0x00001a /* Advanced Micro Devices */
#define MII_OUI_BROADCOM 0x001018 /* Broadcom Corporation */
#define MII_OUI_ENABLESEMI 0x0010dd /* Enable Semiconductor */
#define MII_OUI_DAVICOM 0x00606e /* Davicom Semiconductor */
#define MII_OUI_MARVELL 0x005043 /* Marvell Semiconductor */
#define MII_OUI_ICS 0x00a0be /* Integrated Circuit Systems */
#define MII_OUI_INTEL 0x00aa00 /* Intel */
#define MII_OUI_ALTIMA 0x0010a9 /* Altima */
#define MII_OUI_ENABLESEMI 0x0010dd /* Enable Semi. */
#define MII_OUI_ATHEROS 0x001374 /* Atheros */
#define MII_OUI_JMICRON 0x001b8c /* JMicron */
#define MII_OUI_LEVEL1 0x00207b /* Level 1 */
#define MII_OUI_MYSON 0x00c0b4 /* Myson Technology */
#define MII_OUI_NATSEMI 0x080017 /* National Semiconductor */
#define MII_OUI_QUALSEMI 0x006051 /* Quality Semiconductor */
#define MII_OUI_VIA 0x004063 /* VIA Networking */
#define MII_OUI_MARVELL 0x005043 /* Marvell */
#define MII_OUI_LUCENT 0x00601d /* Lucent */
#define MII_OUI_QUALITYSEMI 0x006051 /* Quality Semi. */
#define MII_OUI_DAVICOM 0x00606e /* Davicom */
#define MII_OUI_SMSC 0x00800f /* Standard Microsystems */
#define MII_OUI_ICPLUS 0x0090c3 /* IC Plus */
#define MII_OUI_TOPICSEMI 0x0090c3 /* Topic Semi. */
#define MII_OUI_AGERE 0x00a0bc /* Agere */
#define MII_OUI_ICS 0x00a0be /* Integrated Circuit Systems */
#define MII_OUI_SEEQ 0x00a07d /* Seeq */
#define MII_OUI_INTEL 0x00aa00 /* Intel */
#define MII_OUI_TDK 0x00c039 /* TDK */
#define MII_OUI_MYSON 0x00c0b4 /* Myson */
#define MII_OUI_PMCSIERRA 0x00e004 /* PMC-Sierra */
#define MII_OUI_SIS 0x00e006 /* Silicon Integrated Systems */
#define MII_OUI_REALTEK2 0x00e04c /* Realtek */
#define MII_OUI_JATO 0x00e083 /* Jato Technologies */
#define MII_OUI_XAQTI 0x00e0ae /* XaQti */
#define MII_OUI_PLESSEYSEMI 0x046b40 /* Plessey Semi. */
#define MII_OUI_NATSEMI 0x080017 /* National Semi. */
#define MII_OUI_TI 0x080028 /* Texas Instruments */
#define MII_OUI_TSC 0x00c039 /* TDK Semiconductor */
#define MII_OUI_XAQTI 0x00e0ae /* XaQti Corp. */
/* in the 79c873, AMD uses another OUI (which matches Davicom!) */
#define MII_OUI_xxALTIMA 0x000895 /* Altima Communications */
#define MII_OUI_xxAMD 0x00606e /* Advanced Micro Devices */
#define MII_OUI_xxALTIMA 0x000895 /* Altima */
#define MII_OUI_xxAMD 0x00606e /* AMD */
#define MII_OUI_xxCICADA 0x00c08f /* Cicada (alt) */
#define MII_OUI_xxINTEL 0x00f800 /* Intel (alt) */
/* some vendors have the bits swapped within bytes
(ie, ordered as on the wire) */
#define MII_OUI_xxBROADCOM 0x000818 /* Broadcom Corporation */
#define MII_OUI_xxICS 0x00057d /* Integrated Circuit Systems */
#define MII_OUI_xxSEEQ 0x0005be /* Seeq */
#define MII_OUI_xxSIS 0x000760 /* Silicon Integrated Systems */
#define MII_OUI_xxBROADCOM 0x000818 /* Broadcom */
#define MII_OUI_xxTI 0x100014 /* Texas Instruments */
#define MII_OUI_xxXAQTI 0x350700 /* XaQti Corp. */
#define MII_OUI_xxXAQTI 0x350700 /* XaQti */
/* Level 1 is completely different - from right to left.
(Two bits get lost in the third OUI byte.) */
@ -89,133 +100,356 @@
#define MII_OUI_xxLEVEL1a 0x0004de /* Level 1 */
/* Don't know what's going on here. */
#define MII_OUI_xxDAVICOM 0x006040 /* Davicom Semiconductor */
#define MII_OUI_xxBROADCOM2 0x0050ef /* Broadcom */
#define MII_OUI_xxBROADCOM3 0x00d897 /* Broadcom */
#define MII_OUI_xxDAVICOM 0x006040 /* Davicom */
/* This is the OUI of the gigE PHY in the RealTek 8169S/8110S chips */
#define MII_OUI_xxREALTEK 0x000732 /* Realtek */
/* Contrived vendor for dcphy */
#define MII_OUI_xxDEC 0x040440 /* Digital Clone */
#define MII_OUI_xxMARVELL 0x000ac2 /* Marvell */
/*
* List of known models. Grouped by oui.
*/
/* Advanced Micro Devices PHYs */
/* AMD PHYs */
#define MII_MODEL_xxAMD_79C873 0x0000
#define MII_STR_xxAMD_79C873 "Am79C873 10/100 media interface"
#define MII_STR_xxAMD_79C873 "Am79C873 10/100 PHY"
#define MII_MODEL_AMD_79C875phy 0x0014
#define MII_STR_AMD_79C875phy "Am79C875 quad PHY"
#define MII_MODEL_AMD_79C873phy 0x0036
#define MII_STR_AMD_79C873phy "Am79C873 internal PHY"
/* Altima Communications PHYs */
/* Agere PHYs */
#define MII_MODEL_AGERE_ET1011 0x0004
#define MII_STR_AGERE_ET1011 "ET1011 10/100/1000baseT PHY"
/* Atheros PHYs */
#define MII_MODEL_ATHEROS_F1 0x0001
#define MII_STR_ATHEROS_F1 "F1 10/100/1000 PHY"
#define MII_MODEL_ATHEROS_F2 0x0002
#define MII_STR_ATHEROS_F2 "F2 10/100 PHY"
#define MII_MODEL_ATHEROS_F1_7 0x0007
#define MII_STR_ATHEROS_F1_7 "F1 10/100/1000 PHY"
/* Altima PHYs */
#define MII_MODEL_xxALTIMA_AC_UNKNOWN 0x0001
#define MII_STR_xxALTIMA_AC_UNKNOWN "AC_UNKNOWN 10/100 PHY"
#define MII_MODEL_xxALTIMA_AC101L 0x0012
#define MII_STR_xxALTIMA_AC101L "AC101L 10/100 PHY"
#define MII_MODEL_xxALTIMA_AC101 0x0021
#define MII_STR_xxALTIMA_AC101 "AC101 10/100 media interface"
#define MII_STR_xxALTIMA_AC101 "AC101 10/100 PHY"
/* Broadcom Corp. PHYs */
/* Broadcom PHYs */
#define MII_MODEL_xxBROADCOM_BCM5400 0x0004
#define MII_STR_xxBROADCOM_BCM5400 "BCM5400 1000baseTX PHY"
#define MII_STR_xxBROADCOM_BCM5400 "BCM5400 1000baseT PHY"
#define MII_MODEL_xxBROADCOM_BCM5401 0x0005
#define MII_STR_xxBROADCOM_BCM5401 "BCM5401 10/100/1000baseTX PHY"
#define MII_STR_xxBROADCOM_BCM5401 "BCM5401 10/100/1000baseT PHY"
#define MII_MODEL_xxBROADCOM_BCM5411 0x0007
#define MII_STR_xxBROADCOM_BCM5411 "BCM5411 10/100/1000baseTX PHY"
#define MII_STR_xxBROADCOM_BCM5411 "BCM5411 10/100/1000baseT PHY"
#define MII_MODEL_xxBROADCOM_BCM5464 0x000b
#define MII_STR_xxBROADCOM_BCM5464 "BCM5464 10/100/1000baseT PHY"
#define MII_MODEL_xxBROADCOM_BCM5461 0x000c
#define MII_STR_xxBROADCOM_BCM5461 "BCM5461 10/100/1000baseT PHY"
#define MII_MODEL_xxBROADCOM_BCM5462 0x000d
#define MII_STR_xxBROADCOM_BCM5462 "BCM5462 10/100/1000baseT PHY"
#define MII_MODEL_xxBROADCOM_BCM5421 0x000e
#define MII_STR_xxBROADCOM_BCM5421 "BCM5421 10/100/1000baseT PHY"
#define MII_MODEL_xxBROADCOM_BCM5752 0x0010
#define MII_STR_xxBROADCOM_BCM5752 "BCM5752 10/100/1000baseT PHY"
#define MII_MODEL_xxBROADCOM_BCM5701 0x0011
#define MII_STR_xxBROADCOM_BCM5701 "BCM5701 10/100/1000baseT PHY"
#define MII_MODEL_xxBROADCOM_BCM5706 0x0015
#define MII_STR_xxBROADCOM_BCM5706 "BCM5706 10/100/1000baseT/SX PHY"
#define MII_MODEL_xxBROADCOM_BCM5703 0x0016
#define MII_STR_xxBROADCOM_BCM5703 "BCM5703 10/100/1000baseT PHY"
#define MII_MODEL_xxBROADCOM_BCM5750 0x0018
#define MII_STR_xxBROADCOM_BCM5750 "BCM5750 10/100/1000baseT PHY"
#define MII_MODEL_xxBROADCOM_BCM5704 0x0019
#define MII_STR_xxBROADCOM_BCM5704 "BCM5704 10/100/1000baseT PHY"
#define MII_MODEL_xxBROADCOM_BCM5705 0x001a
#define MII_STR_xxBROADCOM_BCM5705 "BCM5705 10/100/1000baseT PHY"
#define MII_MODEL_xxBROADCOM_BCM54K2 0x002e
#define MII_STR_xxBROADCOM_BCM54K2 "BCM54K2 10/100/1000baseT PHY"
#define MII_MODEL_xxBROADCOM_BCM5714 0x0034
#define MII_STR_xxBROADCOM_BCM5714 "BCM5714 10/100/1000baseT/SX PHY"
#define MII_MODEL_xxBROADCOM_BCM5780 0x0035
#define MII_STR_xxBROADCOM_BCM5780 "BCM5780 10/100/1000baseT/SX PHY"
#define MII_MODEL_xxBROADCOM_BCM5708C 0x0036
#define MII_STR_xxBROADCOM_BCM5708C "BCM5708C 10/100/1000baseT PHY"
#define MII_MODEL_xxBROADCOM2_BCM54XX 0x0007
#define MII_STR_xxBROADCOM2_BCM54XX "BCM54XX 10/100/1000baseT PHY"
#define MII_MODEL_xxBROADCOM2_BCM5481 0x000a
#define MII_STR_xxBROADCOM2_BCM5481 "BCM5481 10/100/1000baseT PHY"
#define MII_MODEL_xxBROADCOM2_BCM5482 0x000b
#define MII_STR_xxBROADCOM2_BCM5482 "BCM5482 10/100/1000baseT PHY"
#define MII_MODEL_xxBROADCOM2_BCM5755 0x000c
#define MII_STR_xxBROADCOM2_BCM5755 "BCM5755 10/100/1000baseT PHY"
#define MII_MODEL_xxBROADCOM2_BCM5787 0x000e
#define MII_STR_xxBROADCOM2_BCM5787 "BCM5787 10/100/1000baseT PHY"
#define MII_MODEL_xxBROADCOM2_BCM5708S 0x0015
#define MII_STR_xxBROADCOM2_BCM5708S "BCM5708S 1000/2500baseSX PHY"
#define MII_MODEL_xxBROADCOM2_BCM5709CAX 0x002c
#define MII_STR_xxBROADCOM2_BCM5709CAX "BCM5709CAX 10/100/1000baseT PHY"
#define MII_MODEL_xxBROADCOM2_BCM5722 0x002d
#define MII_STR_xxBROADCOM2_BCM5722 "BCM5722 10/100/1000baseT PHY"
#define MII_MODEL_xxBROADCOM2_BCM5784 0x003a
#define MII_STR_xxBROADCOM2_BCM5784 "BCM5784 10/100/1000baseT PHY"
#define MII_MODEL_xxBROADCOM2_BCM5709C 0x003c
#define MII_STR_xxBROADCOM2_BCM5709C "BCM5709 10/100/1000baseT PHY"
#define MII_MODEL_xxBROADCOM2_BCM5761 0x003d
#define MII_STR_xxBROADCOM2_BCM5761 "BCM5761 10/100/1000baseT PHY"
#define MII_MODEL_xxBROADCOM2_BCM5709S 0x003f
#define MII_STR_xxBROADCOM2_BCM5709S "BCM5709S 1000/2500baseSX PHY"
#define MII_MODEL_xxBROADCOM3_BCM57780 0x0019
#define MII_STR_xxBROADCOM3_BCM57780 "BCM57780 10/100/1000baseT PHY"
#define MII_MODEL_BROADCOM_BCM5400 0x0004
#define MII_STR_BROADCOM_BCM5400 "BCM5400 1000baseTX PHY"
#define MII_STR_BROADCOM_BCM5400 "BCM5400 1000baseT PHY"
#define MII_MODEL_BROADCOM_BCM5401 0x0005
#define MII_STR_BROADCOM_BCM5401 "BCM5401 1000baseTX PHY"
#define MII_STR_BROADCOM_BCM5401 "BCM5401 1000baseT PHY"
#define MII_MODEL_BROADCOM_BCM5411 0x0007
#define MII_STR_BROADCOM_BCM5411 "BCM5411 1000baseTX PHY"
#define MII_STR_BROADCOM_BCM5411 "BCM5411 1000baseT PHY"
#define MII_MODEL_BROADCOM_3C905B 0x0012
#define MII_STR_BROADCOM_3C905B "3C905B internal PHY"
#define MII_MODEL_BROADCOM_3C905C 0x0017
#define MII_STR_BROADCOM_3C905C "Broadcom 3C905C internal PHY"
#define MII_STR_BROADCOM_3C905C "3C905C internal PHY"
#define MII_MODEL_BROADCOM_BCM5221 0x001e
#define MII_STR_BROADCOM_BCM5221 "BCM5221 100baseTX PHY"
#define MII_MODEL_BROADCOM_BCM5201 0x0021
#define MII_STR_BROADCOM_BCM5201 "BCM5201 10/100 media interface"
/* Davicom Semiconductor PHYs */
#define MII_MODEL_DAVICOM_DM9102 0x0004
#define MII_STR_DAVICOM_DM9102 "DM9102 10/100 media interface"
#define MII_MODEL_xxDAVICOM_DM9101 0x0000
#define MII_STR_xxDAVICOM_DM9101 "DM9101 10/100 media interface"
#define MII_STR_BROADCOM_BCM5201 "BCM5201 10/100 PHY"
#define MII_MODEL_BROADCOM_BCM5214 0x0028
#define MII_STR_BROADCOM_BCM5214 "BCM5214 Quad 10/100 PHY"
#define MII_MODEL_BROADCOM_BCM5222 0x0032
#define MII_STR_BROADCOM_BCM5222 "BCM5222 Dual 10/100 PHY"
#define MII_MODEL_BROADCOM_BCM5220 0x0033
#define MII_STR_BROADCOM_BCM5220 "BCM5220 10/100 PHY"
#define MII_MODEL_BROADCOM_BCM4401 0x0036
#define MII_STR_BROADCOM_BCM4401 "BCM4401 10/100baseTX PHY"
#define MII_MODEL_BROADCOM2_BCM5906 0x0004
#define MII_STR_BROADCOM2_BCM5906 "BCM5906 10/100baseTX PHY"
/* Enable Semiconductor PHYs */
#define MII_MODEL_ENABLESEMI_88E1000 0x0005
#define MII_STR_ENABLESEMI_88E1000 "Enable 88E1000"
#define MII_MODEL_ENABLESEMI_88E1000S 0x0004
#define MII_STR_ENABLESEMI_88E1000S "Enable 88E1000S"
/* Cicada PHYs (now owned by Vitesse) */
#define MII_MODEL_xxCICADA_CS8201B 0x0021
#define MII_STR_xxCICADA_CS8201B "CS8201 10/100/1000TX PHY"
#define MII_MODEL_CICADA_CS8201 0x0001
#define MII_STR_CICADA_CS8201 "CS8201 10/100/1000TX PHY"
#define MII_MODEL_CICADA_CS8204 0x0004
#define MII_STR_CICADA_CS8204 "CS8204 10/100/1000TX PHY"
#define MII_MODEL_CICADA_VSC8211 0x000b
#define MII_STR_CICADA_VSC8211 "VSC8211 10/100/1000 PHY"
#define MII_MODEL_CICADA_CS8201A 0x0020
#define MII_STR_CICADA_CS8201A "CS8201 10/100/1000TX PHY"
#define MII_MODEL_CICADA_CS8201B 0x0021
#define MII_STR_CICADA_CS8201B "CS8201 10/100/1000TX PHY"
#define MII_MODEL_CICADA_CS8244 0x002c
#define MII_STR_CICADA_CS8244 "CS8244 10/100/1000TX PHY"
/* Marvell Semiconductor PHYs */
#define MII_MODEL_MARVELL_E1000 0x0000
#define MII_STR_MARVELL_E1000 "Marvell Semiconductor 88E1000* Gigabit"
/* Davicom PHYs */
#define MII_MODEL_xxDAVICOM_DM9101 0x0000
#define MII_STR_xxDAVICOM_DM9101 "DM9101 10/100 PHY"
#define MII_MODEL_DAVICOM_DM9102 0x0004
#define MII_STR_DAVICOM_DM9102 "DM9102 10/100 PHY"
#define MII_MODEL_DAVICOM_DM9601 0x000c
#define MII_STR_DAVICOM_DM9601 "DM9601 10/100 PHY"
/* Contrived vendor/model for dcphy */
#define MII_MODEL_xxDEC_xxDC 0x0001
#define MII_STR_xxDEC_xxDC "DC"
/* Enable Semi. PHYs (Agere) */
#define MII_MODEL_ENABLESEMI_LU3X31FT 0x0001
#define MII_STR_ENABLESEMI_LU3X31FT "LU3X31FT"
#define MII_MODEL_ENABLESEMI_LU3X31T2 0x0002
#define MII_STR_ENABLESEMI_LU3X31T2 "LU3X31T2"
#define MII_MODEL_ENABLESEMI_88E1000S 0x0004
#define MII_STR_ENABLESEMI_88E1000S "88E1000S"
#define MII_MODEL_ENABLESEMI_88E1000 0x0005
#define MII_STR_ENABLESEMI_88E1000 "88E1000"
/* IC Plus PHYs */
#define MII_MODEL_ICPLUS_IP100 0x0004
#define MII_STR_ICPLUS_IP100 "IP100 10/100 PHY"
#define MII_MODEL_ICPLUS_IP101 0x0005
#define MII_STR_ICPLUS_IP101 "IP101 10/100 PHY"
#define MII_MODEL_ICPLUS_IP1000A 0x0008
#define MII_STR_ICPLUS_IP1000A "IP1000A 10/100/1000 PHY"
#define MII_MODEL_ICPLUS_IP1001 0x0019
#define MII_STR_ICPLUS_IP1001 "IP1001 10/100/1000 PHY"
/* Integrated Circuit Systems PHYs */
#define MII_MODEL_xxICS_1890 0x0002
#define MII_STR_xxICS_1890 "ICS1890 10/100 media interface"
#define MII_STR_xxICS_1890 "ICS1890 10/100 PHY"
#define MII_MODEL_xxICS_1892 0x0003
#define MII_STR_xxICS_1892 "ICS1892 10/100 media interface"
#define MII_STR_xxICS_1892 "ICS1892 10/100 PHY"
#define MII_MODEL_xxICS_1893 0x0004
#define MII_STR_xxICS_1893 "ICS1893 10/100 PHY"
/* Intel PHYs */
#define MII_MODEL_xxINTEL_I82553 0x0000
#define MII_STR_xxINTEL_I82553 "i82553 10/100 media interface"
#define MII_STR_xxINTEL_I82553 "i82553 10/100 PHY"
#define MII_MODEL_INTEL_I82555 0x0015
#define MII_STR_INTEL_I82555 "i82555 10/100 media interface"
#define MII_STR_INTEL_I82555 "i82555 10/100 PHY"
#define MII_MODEL_INTEL_I82562G 0x0031
#define MII_STR_INTEL_I82562G "i82562G 10/100 PHY"
#define MII_MODEL_INTEL_I82562EM 0x0032
#define MII_STR_INTEL_I82562EM "i82562EM 10/100 media interface"
#define MII_STR_INTEL_I82562EM "i82562EM 10/100 PHY"
#define MII_MODEL_INTEL_I82562ET 0x0033
#define MII_STR_INTEL_I82562ET "i82562ET 10/100 media interface"
#define MII_STR_INTEL_I82562ET "i82562ET 10/100 PHY"
#define MII_MODEL_INTEL_I82553 0x0035
#define MII_STR_INTEL_I82553 "i82553 10/100 media interface"
#define MII_STR_INTEL_I82553 "i82553 10/100 PHY"
/* Jato Technologies PHYs */
#define MII_MODEL_JATO_BASEX 0x0000
#define MII_STR_JATO_BASEX "Jato 1000baseX PHY"
/* JMicron PHYs */
#define MII_MODEL_JMICRON_JMP211 0x0021
#define MII_STR_JMICRON_JMP211 "JMP211 10/100/1000 PHY"
#define MII_MODEL_JMICRON_JMP202 0x0022
#define MII_STR_JMICRON_JMP202 "JMP202 10/100 PHY"
/* Level 1 PHYs */
#define MII_MODEL_xxLEVEL1_LXT970 0x0000
#define MII_STR_xxLEVEL1_LXT970 "LXT970 10/100 media interface"
#define MII_STR_xxLEVEL1_LXT970 "LXT970 10/100 PHY"
#define MII_MODEL_xxLEVEL1a_LXT971 0x000e
#define MII_STR_xxLEVEL1a_LXT971 "LXT971 10/100 media interface"
#define MII_STR_xxLEVEL1a_LXT971 "LXT971 10/100 PHY"
#define MII_MODEL_LEVEL1_LXT1000_OLD 0x0003
#define MII_STR_LEVEL1_LXT1000_OLD "LXT1000 10/100/1000 PHY"
#define MII_MODEL_LEVEL1_LXT1000 0x000c
#define MII_STR_LEVEL1_LXT1000 "LXT1000 10/100/1000 PHY"
/* Lucent PHYs */
#define MII_MODEL_LUCENT_LU6612 0x000c
#define MII_STR_LUCENT_LU6612 "LU6612 10/100 PHY"
#define MII_MODEL_LUCENT_LU3X51FT 0x0033
#define MII_STR_LUCENT_LU3X51FT "LU3X51FT 10/100 PHY"
#define MII_MODEL_LUCENT_LU3X54FT 0x0036
#define MII_STR_LUCENT_LU3X54FT "LU3X54FT 10/100 PHY"
/* Marvell PHYs */
#define MII_MODEL_xxMARVELL_E1000_5 0x0002
#define MII_STR_xxMARVELL_E1000_5 "88E1000 5 Gigabit PHY"
#define MII_MODEL_xxMARVELL_E1000_6 0x0003
#define MII_STR_xxMARVELL_E1000_6 "88E1000 6 Gigabit PHY"
#define MII_MODEL_xxMARVELL_E1000_7 0x0005
#define MII_STR_xxMARVELL_E1000_7 "88E1000 7 Gigabit PHY"
#define MII_MODEL_xxMARVELL_E1111 0x000c
#define MII_STR_xxMARVELL_E1111 "88E1111 Gigabit PHY"
#define MII_MODEL_MARVELL_E1000_1 0x0000
#define MII_STR_MARVELL_E1000_1 "88E1000 1 Gigabit PHY"
#define MII_MODEL_MARVELL_E1011 0x0002
#define MII_STR_MARVELL_E1011 "88E1011 Gigabit PHY"
#define MII_MODEL_MARVELL_E1000_2 0x0003
#define MII_STR_MARVELL_E1000_2 "88E1000 2 Gigabit PHY"
#define MII_MODEL_MARVELL_E1000S 0x0004
#define MII_STR_MARVELL_E1000S "88E1000S Gigabit PHY"
#define MII_MODEL_MARVELL_E1000_3 0x0005
#define MII_STR_MARVELL_E1000_3 "88E1000 3 Gigabit PHY"
#define MII_MODEL_MARVELL_E1000_4 0x0006
#define MII_STR_MARVELL_E1000_4 "88E1000 4 Gigabit PHY"
#define MII_MODEL_MARVELL_E3082 0x0008
#define MII_STR_MARVELL_E3082 "88E3082 10/100 PHY"
#define MII_MODEL_MARVELL_E1112 0x0009
#define MII_STR_MARVELL_E1112 "88E1112 Gigabit PHY"
#define MII_MODEL_MARVELL_E1149 0x000b
#define MII_STR_MARVELL_E1149 "88E1149 Gigabit PHY"
#define MII_MODEL_MARVELL_E1111 0x000c
#define MII_STR_MARVELL_E1111 "88E1111 Gigabit PHY"
#define MII_MODEL_MARVELL_E1116 0x0021
#define MII_STR_MARVELL_E1116 "88E1116 Gigabit PHY"
#define MII_MODEL_MARVELL_E1118 0x0022
#define MII_STR_MARVELL_E1118 "88E1118 Gigabit PHY"
#define MII_MODEL_MARVELL_E1116R 0x0024
#define MII_STR_MARVELL_E1116R "88E1116R Gigabit PHY"
#define MII_MODEL_MARVELL_E3016 0x0026
#define MII_STR_MARVELL_E3016 "88E3016 10/100 PHY"
#define MII_MODEL_MARVELL_PHYG65G 0x0027
#define MII_STR_MARVELL_PHYG65G "PHYG65G Gigabit PHY"
/* Myson PHYs */
/* Myson Technology PHYs */
#define MII_MODEL_MYSON_MTD972 0x0000
#define MII_STR_MYSON_MTD972 "MTD972 10/100 media interface"
#define MII_STR_MYSON_MTD972 "MTD972 10/100 PHY"
/* National Semiconductor PHYs */
/* National Semi. PHYs */
#define MII_MODEL_NATSEMI_DP83840 0x0000
#define MII_STR_NATSEMI_DP83840 "DP83840 10/100 media interface"
#define MII_MODEL_NATSEMI_DP83843 0x0001
#define MII_STR_NATSEMI_DP83843 "DP83843 10/100 media interface"
#define MII_MODEL_NATSEMI_DP83815 0x0002
#define MII_STR_NATSEMI_DP83815 "DP83815 10/100 integrated"
#define MII_STR_NATSEMI_DP83815 "DP83815 10/100 PHY"
#define MII_MODEL_NATSEMI_DP83847 0x0003
#define MII_STR_NATSEMI_DP83847 "DP83847 10/100 PHY"
#define MII_MODEL_NATSEMI_DP83891 0x0005
#define MII_STR_NATSEMI_DP83891 "DP83891 10/100/1000 media interface"
#define MII_STR_NATSEMI_DP83891 "DP83891 10/100/1000 PHY"
#define MII_MODEL_NATSEMI_DP83861 0x0006
#define MII_STR_NATSEMI_DP83861 "DP83861 10/100/1000 media interface"
#define MII_STR_NATSEMI_DP83861 "DP83861 10/100/1000 PHY"
#define MII_MODEL_NATSEMI_DP83865 0x0007
#define MII_STR_NATSEMI_DP83865 "DP83865 10/100/1000 PHY"
/* Plessey Semi. PHYs */
#define MII_MODEL_PLESSEY_NWK914 0x0000
#define MII_STR_PLESSEY_NWK914 "NWK914 10/100 PHY"
/* Quality Semiconductor PHYs */
#define MII_MODEL_QUALSEMI_QS6612 0x0000
#define MII_STR_QUALSEMI_QS6612 "QS6612 10/100 media interface"
/* Quality Semi. PHYs */
#define MII_MODEL_QUALITYSEMI_QS6612 0x0000
#define MII_STR_QUALITYSEMI_QS6612 "QS6612 10/100 PHY"
/* RDC Semi. PHYs */
#define MII_MODEL_RDC_R6040 0x0003
#define MII_STR_RDC_R6040 "R6040 10/100 PHY"
/* Realtek PHYs */
#define MII_MODEL_xxREALTEK_RTL8169S 0x0011
#define MII_STR_xxREALTEK_RTL8169S "RTL8169S/8110S PHY"
#define MII_MODEL_REALTEK_RTL8201L 0x0020
#define MII_STR_REALTEK_RTL8201L "RTL8201L 10/100 PHY"
/* Seeq PHYs */
#define MII_MODEL_xxSEEQ_80220 0x0003
#define MII_STR_xxSEEQ_80220 "Seeq 80220 10/100 media interface"
#define MII_STR_xxSEEQ_80220 "80220 10/100 PHY"
#define MII_MODEL_xxSEEQ_84220 0x0004
#define MII_STR_xxSEEQ_84220 "Seeq 84220 10/100 media interface"
#define MII_STR_xxSEEQ_84220 "84220 10/100 PHY"
#define MII_MODEL_xxSEEQ_80225 0x0008
#define MII_STR_xxSEEQ_80225 "80225 10/100 PHY"
/* Silicon Integrated Systems PHYs */
#define MII_MODEL_xxSIS_900 0x0000
#define MII_STR_xxSIS_900 "SiS 900 10/100 media interface"
#define MII_STR_xxSIS_900 "900 10/100 PHY"
/* Standard Microsystems PHYs */
#define MII_MODEL_SMSC_LAN83C185 0x000a
#define MII_STR_SMSC_LAN83C185 "LAN83C185 10/100 PHY"
/* Texas Instruments PHYs */
#define MII_MODEL_xxTI_TLAN10T 0x0001
#define MII_STR_xxTI_TLAN10T "ThunderLAN 10baseT media interface"
#define MII_STR_xxTI_TLAN10T "ThunderLAN 10baseT PHY"
#define MII_MODEL_xxTI_100VGPMI 0x0002
#define MII_STR_xxTI_100VGPMI "ThunderLAN 100VG-AnyLan media interface"
#define MII_STR_xxTI_100VGPMI "ThunderLAN 100VG-AnyLan PHY"
#define MII_MODEL_xxTI_TNETE2101 0x0003
#define MII_STR_xxTI_TNETE2101 "TNETE2101 media interface"
#define MII_STR_xxTI_TNETE2101 "TNETE2101 PHY"
/* TDK PHYs */
#define MII_MODEL_TDK_78Q2120 0x0014
#define MII_STR_TDK_78Q2120 "78Q2120 10/100 PHY"
#define MII_MODEL_TDK_78Q2121 0x0015
#define MII_STR_TDK_78Q2121 "78Q2121 100baseTX PHY"
/* VIA Networking PHYs */
#define MII_MODEL_VIA_VT6103 0x0032
#define MII_STR_VIA_VT6103 "VT6103 10/100 PHY"
#define MII_MODEL_VIA_VT6103_2 0x0034
#define MII_STR_VIA_VT6103_2 "VT6103 10/100 PHY"
/* TDK Semiconductor PHYs */
#define MII_MODEL_TSC_78Q2120 0x0014
#define MII_STR_TSC_78Q2120 "78Q2120 10/100 media interface"
#define MII_MODEL_TSC_78Q2121 0x0015
#define MII_STR_TSC_78Q2121 "78Q2121 100baseTX media interface"
/* Vitesse PHYs */
#define MII_MODEL_VITESSE_VSC8601 0x0002
#define MII_STR_VITESSE_VSC8601 "VSC8601 10/100/1000 PHY"
/* XaQti Corp. PHYs */
/* XaQti PHYs */
#define MII_MODEL_XAQTI_XMACII 0x0000
#define MII_STR_XAQTI_XMACII "XaQti Corp. XMAC II gigabit interface"
#define MII_STR_XAQTI_XMACII "XMAC II Gigabit PHY"

73
sys/dev/mii/miivar.h

@ -42,6 +42,7 @@
#define _DEV_MII_MIIVAR_H_
#include <sys/queue.h>
#include <sys/timeout.h>
/*
* Media Independent Interface autoconfiguration defintions.
@ -68,6 +69,9 @@ struct mii_data {
struct ifmedia mii_media; /* media information */
struct ifnet *mii_ifp; /* pointer back to network interface */
//wan+
int mii_flags; /* misc. flags; see below */
/*
* For network interfaces with multiple PHYs, a list of all
* PHYs is required so they can all be notified when a media
@ -91,6 +95,12 @@ struct mii_data {
};
typedef struct mii_data mii_data_t;
struct mii_phy_funcs {
int (*pf_service)(struct mii_softc *, struct mii_data *, int);
void (*pf_status)(struct mii_softc *);
void (*pf_reset)(struct mii_softc *);
};
/*
* This call is used by the MII layer to call into the PHY driver
* to perform a `service request'.
@ -118,23 +128,53 @@ struct mii_softc {
int mii_phy; /* our MII address */
int mii_inst; /* instance for ifmedia */
/* Our PHY functions. */
const struct mii_phy_funcs *mii_funcs;
mii_downcall_t mii_service; /* our downcall */
struct mii_data *mii_pdata; /* pointer to parent's mii_data */
int mii_flags; /* misc. flags; see below */
int mii_flags; /* misc. flags; see below */
int mii_capabilities; /* capabilities from BMSR */
//wan #if 0
int mii_model; /* MII_MODEL(ma->mii_id2) */
int mii_rev; /* MII_REV(ma->mii_id2) */
struct timeout mii_phy_timo; /* timeout handle */
int mii_extcapabilities; /* extended capabilities */
int mii_anegticks; /* ticks before retrying aneg */
int mii_media_active; /* last active media */
int mii_media_status; /* last active status */
//wan #endif
int mii_ticks; /* MII_TICK counter */
int mii_active; /* last active media */
};
typedef struct mii_softc mii_softc_t;
//wan
/* Default mii_anegticks values. */
#define MII_ANEGTICKS 5
#define MII_ANEGTICKS_GIGE 10
/* mii_flags */
#define MIIF_INITDONE 0x0001 /* has been initialized (mii_data) */
#define MIIF_NOISOLATE 0x0002 /* do not isolate the PHY */
#define MIIF_NOLOOP 0x0004 /* no loopback capability */
#define MIIF_DOINGAUTO 0x0008 /* doing autonegotiation (mii_softc) */
#define MIIF_AUTOTSLEEP 0x0010 /* use tsleep(), not timeout() */
#define MIIF_HAVEFIBER 0x0020 /* from parent: has fiber interface */
#define MIIF_HAVE_GTCR 0x0040 /* has 100base-T2/1000base-T CR */
#define MIIF_IS_1000X 0x0080 /* is a 1000BASE-X device */
#define MIIF_DOPAUSE 0x0100 /* advertise PAUSE capability */
#define MIIF_IS_HPNA 0x0200 /* is a HomePNA device */
#define MIIF_FORCEANEG 0x0400 /* force autonegotiation */
#define MIIF_INHERIT_MASK (MIIF_NOISOLATE|MIIF_NOLOOP)
#define MII_OFFSET_ANY -1
#define MII_PHY_ANY -1
/*
* Used to attach a PHY to a parent.
@ -145,15 +185,29 @@ struct mii_attach_args {
int mii_id1; /* PHY ID register 1 */
int mii_id2; /* PHY ID register 2 */
int mii_capmask; /* capability mask from BMSR */
int mii_flags; /* flags from parent */
};
typedef struct mii_attach_args mii_attach_args_t;
/*
* Used to match a PHY.
*/
struct mii_phydesc {
u_int32_t mpd_oui; /* the PHY's OUI */
u_int32_t mpd_model; /* the PHY's model */
const char *mpd_name; /* the PHY's name */
};
/*
* An array of these structures map MII media types to BMCR/ANAR settings.
*/
struct mii_media {
int mm_bmcr; /* BMCR settings for this media */
int mm_anar; /* ANAR settings for this media */
//wxy
#if 1
int mm_gtcr; /* 100base-T2 or 1000base-T CR */
#endif
};
#define MII_MEDIA_NONE 0
@ -164,6 +218,22 @@ struct mii_media {
#define MII_MEDIA_100_TX_FDX 5
#define MII_NMEDIA 6
//wan #if 0
#define MII_MEDIA_1000_X 6
#define MII_MEDIA_1000_X_FDX 7
#define MII_MEDIA_1000_T 8
#define MII_MEDIA_1000_T_FDX 9
#define PHY_SERVICE(p, d, o) \
(*(p)->mii_funcs->pf_service)((p), (d), (o))
#define PHY_STATUS(p) \
(*(p)->mii_funcs->pf_status)((p))
#define PHY_RESET(p) \
(*(p)->mii_funcs->pf_reset)((p))
//wan #endif
#ifdef _KERNEL
#define PHY_READ(p, r) \
@ -181,6 +251,7 @@ void mii_down __P((struct mii_data *));
void mii_phy_probe __P((struct device *, struct mii_data *, int));
int mii_detach __P((struct mii_softc *, int));
void mii_add_media __P((struct mii_softc *));
void mii_phy_add_media __P((struct mii_softc *));//wan+
void mii_phy_setmedia __P((struct mii_softc *));
int mii_phy_auto __P((struct mii_softc *, int));

14836
sys/dev/pci/bnx/bnxfw.h

File diff suppressed because it is too large

2653
sys/dev/pci/bnx/if_bgereg.h

File diff suppressed because it is too large

6574
sys/dev/pci/bnx/if_bnx.c

File diff suppressed because it is too large

5143
sys/dev/pci/bnx/if_bnxreg.h

File diff suppressed because it is too large

8
sys/dev/pci/files.pci

@ -102,6 +102,14 @@ device rtk: ether, ifnet
attach rtk at pci
file sys/dev/pci/rtl8169.c rtk
#added by wxy
# Broadcom BCM5709S gigabit ethernet
#device bnx: ether, ifnet, mii, ifmedia, mii_phy
device bnx: ether, ifnet, mii, ifmedia, mii_phy
attach bnx at pci
#file sys/dev/pci/if_bnx.c bnx
file sys/dev/pci/bnx/if_bnx.c bnx
device ste: ether, ifnet
attach ste at pci
file sys/dev/pci/sundance.c ste

14
sys/dev/pci/pci.c

@ -283,6 +283,20 @@ pcisubmatch(parent, match, aux)
return (success);
}
int
pci_matchbyid(struct pci_attach_args *pa, const struct pci_matchid *ids,
int nent)
{
const struct pci_matchid *pm;
int i;
for (i = 0, pm = ids; i < nent; i++, pm++)
if (PCI_VENDOR(pa->pa_id) == pm->pm_vid &&
PCI_PRODUCT(pa->pa_id) == pm->pm_pid)
return (1);
return (0);
}
void
set_pci_isa_bridge_callback(fn, arg)
void (*fn) __P((void *));

123
sys/dev/pci/pcidevs.h

@ -738,9 +738,132 @@
#define PCI_PRODUCT_ATI_MACH64_VV 0x5656 /* Mach64 VV */
/* Broadcom */
#define PCI_PRODUCT_BROADCOM_BCM5752 0x1600 /* BCM5752 */
#define PCI_PRODUCT_BROADCOM_BCM5752M 0x1601 /* BCM5752M */
#define PCI_PRODUCT_BROADCOM_BCM5709 0x1639 /* BCM5709 */
#define PCI_PRODUCT_BROADCOM_BCM5709S 0x163a /* BCM5709S */
#define PCI_PRODUCT_BROADCOM_BCM5716 0x163b /* BCM5716 */
#define PCI_PRODUCT_BROADCOM_BCM5716S 0x163c /* BCM5716S */
#define PCI_PRODUCT_BROADCOM_BCM5700 0x1644 /* BCM5700 */
#define PCI_PRODUCT_BROADCOM_BCM5701 0x1645 /* BCM5701 */
#define PCI_PRODUCT_BROADCOM_BCM5702 0x1646 /* BCM5702 */
#define PCI_PRODUCT_BROADCOM_BCM5703 0x1647 /* BCM5703 */
#define PCI_PRODUCT_BROADCOM_BCM5704C 0x1648 /* BCM5704C */
#define PCI_PRODUCT_BROADCOM_BCM5704S_ALT 0x1649 /* BCM5704S Alt */
#define PCI_PRODUCT_BROADCOM_BCM5706 0x164a /* BCM5706 */
#define PCI_PRODUCT_BROADCOM_BCM5708 0x164c /* BCM5708 */
#define PCI_PRODUCT_BROADCOM_BCM5702FE 0x164d /* BCM5702FE */
#define PCI_PRODUCT_BROADCOM_BCM57710 0x164e /* BCM57710 */
#define PCI_PRODUCT_BROADCOM_BCM57711 0x164f /* BCM57711 */
#define PCI_PRODUCT_BROADCOM_BCM57711E 0x1650 /* BCM57711E */
#define PCI_PRODUCT_BROADCOM_BCM5705 0x1653 /* BCM5705 */
#define PCI_PRODUCT_BROADCOM_BCM5705K 0x1654 /* BCM5705K */
#define PCI_PRODUCT_BROADCOM_BCM5717 0x1655 /* BCM5717 */
#define PCI_PRODUCT_BROADCOM_BCM5718 0x1656 /* BCM5718 */
#define PCI_PRODUCT_BROADCOM_BCM5719 0x1657 /* BCM5719 */
#define PCI_PRODUCT_BROADCOM_BCM5720 0x1658 /* BCM5720 */
#define PCI_PRODUCT_BROADCOM_BCM5721 0x1659 /* BCM5721 */
#define PCI_PRODUCT_BROADCOM_BCM5722 0x165a /* BCM5722 */
#define PCI_PRODUCT_BROADCOM_BCM5723 0x165b /* BCM5723 */
#define PCI_PRODUCT_BROADCOM_BCM5724 0x165c /* BCM5724 */
#define PCI_PRODUCT_BROADCOM_BCM5705M 0x165d /* BCM5705M */
#define PCI_PRODUCT_BROADCOM_BCM5705M_ALT 0x165e /* BCM5705M Alt */
#define PCI_PRODUCT_BROADCOM_BCM57712 0x1662 /* BCM57712 */
#define PCI_PRODUCT_BROADCOM_BCM57712E 0x1663 /* BCM57712E */
#define PCI_PRODUCT_BROADCOM_BCM5714 0x1668 /* BCM5714 */
#define PCI_PRODUCT_BROADCOM_BCM5714S 0x1669 /* BCM5714S */
#define PCI_PRODUCT_BROADCOM_BCM5780 0x166a /* BCM5780 */
#define PCI_PRODUCT_BROADCOM_BCM5780S 0x166b /* BCM5780S */
#define PCI_PRODUCT_BROADCOM_BCM5705F 0x166e /* BCM5705F */
#define PCI_PRODUCT_BROADCOM_BCM5754M 0x1672 /* BCM5754M */
#define PCI_PRODUCT_BROADCOM_BCM5755M 0x1673 /* BCM5755M */
#define PCI_PRODUCT_BROADCOM_BCM5756 0x1674 /* BCM5756 */
#define PCI_PRODUCT_BROADCOM_BCM5750 0x1676 /* BCM5750 */
#define PCI_PRODUCT_BROADCOM_BCM5751 0x1677 /* BCM5751 */
#define PCI_PRODUCT_BROADCOM_BCM5715 0x1678 /* BCM5715 */
#define PCI_PRODUCT_BROADCOM_BCM5715S 0x1679 /* BCM5715S */
#define PCI_PRODUCT_BROADCOM_BCM5754 0x167a /* BCM5754 */
#define PCI_PRODUCT_BROADCOM_BCM5755 0x167b /* BCM5755 */
#define PCI_PRODUCT_BROADCOM_BCM5750M 0x167c /* BCM5750M */
#define PCI_PRODUCT_BROADCOM_BCM5751M 0x167d /* BCM5751M */
#define PCI_PRODUCT_BROADCOM_BCM5751F 0x167e /* BCM5751F */
#define PCI_PRODUCT_BROADCOM_BCM5787F 0x167f /* BCM5787F */
#define PCI_PRODUCT_BROADCOM_BCM5761E 0x1680 /* BCM5761E */
#define PCI_PRODUCT_BROADCOM_BCM5761 0x1681 /* BCM5761 */
#define PCI_PRODUCT_BROADCOM_BCM5764 0x1684 /* BCM5764 */
#define PCI_PRODUCT_BROADCOM_BCM5761S 0x1688 /* BCM5761S */
#define PCI_PRODUCT_BROADCOM_BCM5761SE 0x1689 /* BCM5761SE */
#define PCI_PRODUCT_BROADCOM_BCM57760 0x1690 /* BCM57760 */
#define PCI_PRODUCT_BROADCOM_BCM57788 0x1691 /* BCM57788 */
#define PCI_PRODUCT_BROADCOM_BCM57780 0x1692 /* BCM57780 */
#define PCI_PRODUCT_BROADCOM_BCM5787M 0x1693 /* BCM5787M */
#define PCI_PRODUCT_BROADCOM_BCM57790 0x1694 /* BCM57790 */
#define PCI_PRODUCT_BROADCOM_BCM5782 0x1696 /* BCM5782 */
#define PCI_PRODUCT_BROADCOM_BCM5784 0x1698 /* BCM5784 */
#define PCI_PRODUCT_BROADCOM_BCM5785G 0x1699 /* BCM5785G */
#define PCI_PRODUCT_BROADCOM_BCM5786 0x169a /* BCM5786 */
#define PCI_PRODUCT_BROADCOM_BCM5787 0x169b /* BCM5787 */
#define PCI_PRODUCT_BROADCOM_BCM5788 0x169c /* BCM5788 */
#define PCI_PRODUCT_BROADCOM_BCM5789 0x169d /* BCM5789 */
#define PCI_PRODUCT_BROADCOM_BCM5785F 0x16a0 /* BCM5785F */
#define PCI_PRODUCT_BROADCOM_BCM5702X 0x16a6 /* BCM5702X */
#define PCI_PRODUCT_BROADCOM_BCM5703X 0x16a7 /* BCM5703X */
#define PCI_PRODUCT_BROADCOM_BCM5704S 0x16a8 /* BCM5704S */
#define PCI_PRODUCT_BROADCOM_BCM5706S 0x16aa /* BCM5706S */
#define PCI_PRODUCT_BROADCOM_BCM5708S 0x16ac /* BCM5708S */
#define PCI_PRODUCT_BROADCOM_BCM57761 0x16b0 /* BCM57761 */
#define PCI_PRODUCT_BROADCOM_BCM57781 0x16b1 /* BCM57781 */
#define PCI_PRODUCT_BROADCOM_BCM57791 0x16b2 /* BCM57791 */
#define PCI_PRODUCT_BROADCOM_BCM57765 0x16b4 /* BCM57765 */
#define PCI_PRODUCT_BROADCOM_BCM57785 0x16b5 /* BCM57785 */
#define PCI_PRODUCT_BROADCOM_BCM57795 0x16b6 /* BCM57795 */
#define PCI_PRODUCT_BROADCOM_SD 0x16bc /* SD Host Controller */
#define PCI_PRODUCT_BROADCOM_BCM5702_ALT 0x16c6 /* BCM5702 Alt */
#define PCI_PRODUCT_BROADCOM_BCM5703_ALT 0x16c7 /* BCM5703 Alt */
#define PCI_PRODUCT_BROADCOM_BCM5781 0x16dd /* BCM5781 */
#define PCI_PRODUCT_BROADCOM_BCM5753 0x16f7 /* BCM5753 */
#define PCI_PRODUCT_BROADCOM_BCM5753M 0x16fd /* BCM5753M */
#define PCI_PRODUCT_BROADCOM_BCM5753F 0x16fe /* BCM5753F */
#define PCI_PRODUCT_BROADCOM_BCM5903M 0x16ff /* BCM5903M */
#define PCI_PRODUCT_BROADCOM_BCM4401B1 0x170c /* BCM4401B1 */
#define PCI_PRODUCT_BROADCOM_BCM5901 0x170d /* BCM5901 */
#define PCI_PRODUCT_BROADCOM_BCM5901A2 0x170e /* BCM5901A2 */
#define PCI_PRODUCT_BROADCOM_BCM5903F 0x170f /* BCM5903F */
#define PCI_PRODUCT_BROADCOM_BCM5906 0x1712 /* BCM5906 */
#define PCI_PRODUCT_BROADCOM_BCM5906M 0x1713 /* BCM5906M */
#define PCI_PRODUCT_BROADCOM_BCM4303 0x4301 /* BCM4303 */
#define PCI_PRODUCT_BROADCOM_BCM4307 0x4307 /* BCM4307 */
#define PCI_PRODUCT_BROADCOM_BCM4311 0x4311 /* BCM4311 */
#define PCI_PRODUCT_BROADCOM_BCM4312 0x4312 /* BCM4312 */
#define PCI_PRODUCT_BROADCOM_BCM4315 0x4315 /* BCM4315 */
#define PCI_PRODUCT_BROADCOM_BCM4318 0x4318 /* BCM4318 */
#define PCI_PRODUCT_BROADCOM_BCM4319 0x4319 /* BCM4319 */
#define PCI_PRODUCT_BROADCOM_BCM4306 0x4320 /* BCM4306 */
#define PCI_PRODUCT_BROADCOM_BCM4306_2 0x4321 /* BCM4306 */
#define PCI_PRODUCT_BROADCOM_SERIAL_2 0x4322 /* Serial */
#define PCI_PRODUCT_BROADCOM_BCM4309 0x4324 /* BCM4309 */
#define PCI_PRODUCT_BROADCOM_BCM43XG 0x4325 /* BCM43XG */
#define PCI_PRODUCT_BROADCOM_BCM4321 0x4328 /* BCM4321 */
#define PCI_PRODUCT_BROADCOM_BCM4321_2 0x4329 /* BCM4321 */
#define PCI_PRODUCT_BROADCOM_BCM4322 0x432b /* BCM4322 */
#define PCI_PRODUCT_BROADCOM_SERIAL 0x4333 /* Serial */
#define PCI_PRODUCT_BROADCOM_SERIAL_GC 0x4344 /* Serial */
#define PCI_PRODUCT_BROADCOM_BCM43224 0x4353 /* BCM43224 */
#define PCI_PRODUCT_BROADCOM_BCM43225 0x4357 /* BCM43225 */
#define PCI_PRODUCT_BROADCOM_BCM4401 0x4401 /* BCM4401 */
#define PCI_PRODUCT_BROADCOM_BCM4401B0 0x4402 /* BCM4401B0 */
#define PCI_PRODUCT_BROADCOM_BCM4313 0x4727 /* BCM4313 */
#define PCI_PRODUCT_BROADCOM_5801 0x5801 /* 5801 */
#define PCI_PRODUCT_BROADCOM_5802 0x5802 /* 5802 */
#define PCI_PRODUCT_BROADCOM_5805 0x5805 /* 5805 */
#define PCI_PRODUCT_BROADCOM_5820 0x5820 /* 5820 */
#define PCI_PRODUCT_BROADCOM_5821 0x5821 /* 5821 */
#define PCI_PRODUCT_BROADCOM_5822 0x5822 /* 5822 */
#define PCI_PRODUCT_BROADCOM_5823 0x5823 /* 5823 */
#define PCI_PRODUCT_BROADCOM_5825 0x5825 /* 5825 */
#define PCI_PRODUCT_BROADCOM_5860 0x5860 /* 5860 */
#define PCI_PRODUCT_BROADCOM_5861 0x5861 /* 5861 */
#define PCI_PRODUCT_BROADCOM_5862 0x5862 /* 5862 */
/* Brooktree products */
#define PCI_PRODUCT_BROOKTREE_BT848 0x0350 /* BT848 */

7
sys/dev/pci/pcivar.h

@ -159,6 +159,13 @@ int pci_mem_find __P((pci_chipset_tag_t, pcitag_t, int, bus_addr_t *,
int pci_get_capability __P((pci_chipset_tag_t, pcitag_t, int,
int *, pcireg_t *));
struct pci_matchid {
pci_vendor_id_t pm_vid;
pci_product_id_t pm_pid;
};
int pci_matchbyid(struct pci_attach_args *, const struct pci_matchid *, int);
/*
* Helper functions for autoconfiguration.
*/

49
sys/net/if.h

@ -36,6 +36,8 @@
* @(#)if.h 8.1 (Berkeley) 6/10/93
*/
#ifndef _NET_IN_IF_H_
#define _NET_IN_IF_H_
#include <sys/queue.h>
/*
@ -81,6 +83,9 @@ struct if_data {
u_char ifi_type; /* ethernet, tokenring, etc. */
u_char ifi_addrlen; /* media address length */
u_char ifi_hdrlen; /* media header length */
//wan
u_char ifi_link_state; /* current link state */
u_long ifi_mtu; /* maximum transmission unit */
u_long ifi_metric; /* routing metric (external only) */
u_long ifi_baudrate; /* linespeed */
@ -144,6 +149,24 @@ struct ifnet { /* and the entries */
int ifq_drops;
} if_snd; /* output queue */
};
//wan #if 0
/*
* Values for if_link_state.
*/
#define LINK_STATE_UNKNOWN 0 /* link unknown */
#define LINK_STATE_INVALID 1 /* link invalid */
#define LINK_STATE_DOWN 2 /* link is down */
#define LINK_STATE_KALIVE_DOWN 3 _/* keepalive reports down */
#define LINK_STATE_UP 4 /* link is up */
#define LINK_STATE_HALF_DUPLEX 5 /* link is up and half duplex */
#define LINK_STATE_FULL_DUPLEX 6 /* link is up and full duplex */
#define LINK_STATE_IS_UP(_s) ((_s) >= LINK_STATE_UP)
#define if_link_state if_data.ifi_link_state
//wan #endif
#define if_mtu if_data.ifi_mtu
#define if_type if_data.ifi_type
#define if_addrlen if_data.ifi_addrlen
@ -185,12 +208,28 @@ struct ifnet { /* and the entries */
(IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\
IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI)
//wan
/*
* Some convenience macros used for setting ifi_baudrate.
*/
#define IF_Kbps(x) ((x) * 1000ULL) /* kilobits/sec. */
#define IF_Mbps(x) (IF_Kbps((x) * 1000ULL)) /* megabits/sec. */
#define IF_Gbps(x) (IF_Mbps((x) * 1000ULL)) /* gigabits/sec. */
/*
* Output queues (ifp->if_snd) and internetwork datagram level (pup level 1)
* input routines have queues of messages stored on ifqueue structures
* (defined above). Entries are added to and deleted from these structures
* by these macros, which should be called with ipl raised to splimp().
*/
#define IF_POLL(ifq, m) \
do { \
do { \
(m) = (ifq)->ifq_head; \
} while (!(m) && --((ifq)->ifq_len) >= 0); \
} while (/* CONSTCOND */0)
#define IF_QFULL(ifq) ((ifq)->ifq_len >= (ifq)->ifq_maxlen)
#define IF_DROP(ifq) ((ifq)->ifq_drops++)
#define IF_ENQUEUE(ifq, m) { \
@ -222,6 +261,13 @@ struct ifnet { /* and the entries */
#define IFQ_MAXLEN 50
#define IFNET_SLOWHZ 1 /* granularity is 1 second */
#define IFQ_LEN(ifq) IF_LEN(ifq)
#define IFQ_IS_EMPTY(ifq) ((ifq)->ifq_len == 0)
#define IFQ_INC_LEN(ifq) ((ifq)->ifq_len++)
#define IFQ_DEC_LEN(ifq) (--(ifq)->ifq_len)
#define IFQ_INC_DROPS(ifq) ((ifq)->ifq_drops++)
#define IFQ_SET_MAXLEN(ifq, len) ((ifq)->ifq_maxlen = (len))
/*
* The ifaddr structure contains information about one address
* of an interface. They are maintained by the different address families,
@ -355,6 +401,8 @@ struct if_nameindex *if_nameindex __P((void));
struct ifnet_head ifnet;
struct ifnet *lo0ifp;
#define ether_input_mbuf(ifp, m) ether_input((ifp), NULL, (m))
void ether_ifattach __P((struct ifnet *));
void ether_ifdetach __P((struct ifnet *));
int ether_ioctl __P((struct ifnet *, struct arpcom *, u_long, caddr_t));
@ -393,3 +441,4 @@ int looutput __P((struct ifnet *,
struct mbuf *, struct sockaddr *, struct rtentry *));
void lortrequest __P((int, struct rtentry *, struct sockaddr *));
#endif /* _KERNEL */
#endif

11
sys/net/if_ethersubr.c

@ -481,7 +481,7 @@ ether_output(ifp, m0, dst, rt0)
senderr(ENOBUFS);
}
ifp->if_obytes += m->m_pkthdr.len;
IF_ENQUEUE(&ifp->if_snd, m);
IF_ENQUEUE(&ifp->if_snd, m);//wan: add mbuf m to ifp->if_snd
if (m->m_flags & M_MCAST)
ifp->if_omcasts++;
if ((ifp->if_flags & IFF_OACTIVE) == 0)
@ -516,6 +516,13 @@ ether_input(ifp, eh, m)
m_freem(m);
return;
}
//wan+
if (eh == NULL) {
eh = mtod(m, struct ether_header *);
m_adj(m, ETHER_HDR_LEN);
}
#include "raw_ether.h"
#if NRAW_ETHER
{
@ -805,7 +812,7 @@ ether_ifattach(ifp)
ifp->if_addrlen = 6;
ifp->if_hdrlen = 14;
ifp->if_mtu = ETHERMTU;
ifp->if_output = ether_output;
ifp->if_output = ether_output;//wan: implete ifp->if_output in ping -> ... -> udp_output()
for (ifa = ifp->if_addrlist.tqh_first; ifa != 0;
ifa = ifa->ifa_list.tqe_next)
if ((sdl = (struct sockaddr_dl *)ifa->ifa_addr) &&

224
sys/net/if_media.c

@ -1,6 +1,5 @@
/* $OpenBSD: if_media.c,v 1.1 1998/09/03 06:24:20 jason Exp $ */
/* $NetBSD: if_media.c,v 1.3 1998/08/30 07:39:39 enami Exp $ */
/* $OpenBSD: if_media.c,v 1.20 2008/06/26 05:42:20 ray Exp $ */
/* $NetBSD: if_media.c,v 1.10 2000/03/13 23:52:39 soren Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
* All rights reserved.
@ -17,13 +16,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
@ -101,26 +93,22 @@
* Useful for debugging newly-ported drivers.
*/
struct ifmedia_entry *ifmedia_match __P((struct ifmedia *ifm,
int flags, int mask));
#ifdef IFMEDIA_DEBUG
int ifmedia_debug = 0;
static void ifmedia_printword __P((int));
static void ifmedia_printword(int);
#endif
/*
* Initialize if_media struct for a specific interface instance.
*/
void
ifmedia_init(ifm, dontcare_mask, change_callback, status_callback)
struct ifmedia *ifm;
int dontcare_mask;
ifm_change_cb_t change_callback;
ifm_stat_cb_t status_callback;
ifmedia_init(struct ifmedia *ifm, int dontcare_mask,
ifm_change_cb_t change_callback, ifm_stat_cb_t status_callback)
{
LIST_INIT(&ifm->ifm_list);
TAILQ_INIT(&ifm->ifm_list);
ifm->ifm_cur = NULL;
ifm->ifm_media = 0;
ifm->ifm_mask = dontcare_mask; /* IF don't-care bits */
@ -133,13 +121,9 @@ ifmedia_init(ifm, dontcare_mask, change_callback, status_callback)
* for a specific interface instance.
*/
void
ifmedia_add(ifm, mword, data, aux)
struct ifmedia *ifm;
int mword;
int data;
void *aux;
ifmedia_add(struct ifmedia *ifm, int mword, int data, void *aux)
{
register struct ifmedia_entry *entry;
struct ifmedia_entry *entry;
#ifdef IFMEDIA_DEBUG
if (ifmedia_debug) {
@ -160,7 +144,7 @@ ifmedia_add(ifm, mword, data, aux)
entry->ifm_data = data;
entry->ifm_aux = aux;
LIST_INSERT_HEAD(&ifm->ifm_list, entry, ifm_list);
TAILQ_INSERT_TAIL(&ifm->ifm_list, entry, ifm_list);
}
/*
@ -168,10 +152,7 @@ ifmedia_add(ifm, mword, data, aux)
* supported media for a specific interface instance.
*/
void
ifmedia_list_add(ifm, lp, count)
struct ifmedia *ifm;
struct ifmedia_entry *lp;
int count;
ifmedia_list_add(struct ifmedia *ifm, struct ifmedia_entry *lp, int count)
{
int i;
@ -188,19 +169,38 @@ ifmedia_list_add(ifm, lp, count)
* media-change callback.
*/
void
ifmedia_set(ifm, target)
struct ifmedia *ifm;
int target;
ifmedia_set(struct ifmedia *ifm, int target)
{
struct ifmedia_entry *match;
match = ifmedia_match(ifm, target, ifm->ifm_mask);
match = ifmedia_match(ifm, target, ifm->ifm_mask);//wan: return ifm entry. (added in brgphy_attach-->ifmedia_add)
/*
* If we didn't find the requested media, then we try to fall
* back to target-type (IFM_ETHER, e.g.) | IFM_NONE. If that's
* not on the list, then we add it and set the media to it.
*
* Since ifmedia_set is almost always called with IFM_AUTO or
* with a known-good media, this really should only occur if we:
*
* a) didn't find any PHYs, or
* b) didn't find an autoselect option on the PHY when the
* parent ethernet driver expected to.
*
* In either case, it makes sense to select no media.
*/
if (match == NULL) {
printf("ifmedia_set: no match for 0x%x/0x%x\n",
target, ~ifm->ifm_mask);
panic("ifmedia_set");
target = (target & IFM_NMASK) | IFM_NONE;
match = ifmedia_match(ifm, target, ifm->ifm_mask);
if (match == NULL) {
ifmedia_add(ifm, target, 0, NULL);
match = ifmedia_match(ifm, target, ifm->ifm_mask);
if (match == NULL)
panic("ifmedia_set failed");
}
}
ifm->ifm_cur = match;
@ -218,18 +218,15 @@ ifmedia_set(ifm, target)
* Device-independent media ioctl support function.
*/
int
ifmedia_ioctl(ifp, ifr, ifm, cmd)
struct ifnet *ifp;
struct ifreq *ifr;
struct ifmedia *ifm;
u_long cmd;
ifmedia_ioctl(struct ifnet *ifp, struct ifreq *ifr, struct ifmedia *ifm,
u_long cmd)
{
struct ifmedia_entry *match;
struct ifmediareq *ifmr = (struct ifmediareq *) ifr;
int error = 0, sticky;
int error = 0;
if (ifp == NULL || ifr == NULL || ifm == NULL)
return(EINVAL);
return (EINVAL);
switch (cmd) {
@ -239,31 +236,30 @@ ifmedia_ioctl(ifp, ifr, ifm, cmd)
case SIOCSIFMEDIA:
{
struct ifmedia_entry *oldentry;
int oldmedia;
int newmedia = ifr->ifr_media;
u_int oldmedia;
u_int newmedia = ifr->ifr_media;
match = ifmedia_match(ifm, newmedia, ifm->ifm_mask);
if (match == NULL) {
#ifdef IFMEDIA_DEBUG
if (ifmedia_debug) {
printf(
"ifmedia_ioctl: no media found for 0x%x\n",
printf("ifmedia_ioctl: no media found for 0x%x\n",
newmedia);
}
#endif
return (ENXIO);
return (EINVAL);
}
/*
* If no change, we're done.
* XXX Automedia may invole software intervention.
* Keep going in case the the connected media changed.
* XXX Automedia may involve software intervention.
* Keep going in case the connected media changed.
* Similarly, if best match changed (kernel debugger?).
*/
if ((IFM_SUBTYPE(newmedia) != IFM_AUTO) &&
(newmedia == ifm->ifm_media) &&
(match == ifm->ifm_cur))
return 0;
return (0);
/*
* We found a match, now make the driver switch to it.
@ -295,9 +291,10 @@ ifmedia_ioctl(ifp, ifr, ifm, cmd)
case SIOCGIFMEDIA:
{
struct ifmedia_entry *ep;
int *kptr, count;
size_t nwords;
kptr = NULL; /* XXX gcc */
if(ifmr->ifm_count < 0)
return (EINVAL);
ifmr->ifm_active = ifmr->ifm_current = ifm->ifm_cur ?
ifm->ifm_cur->ifm_media : IFM_NONE;
@ -305,58 +302,42 @@ ifmedia_ioctl(ifp, ifr, ifm, cmd)
ifmr->ifm_status = 0;
(*ifm->ifm_status)(ifp, ifmr);
count = 0;
ep = ifm->ifm_list.lh_first;
/*
* Count them so we know a-priori how much is the max we'll
* need.
*/
ep = TAILQ_FIRST(&ifm->ifm_list);
for (nwords = 0; ep != NULL; ep = TAILQ_NEXT(ep, ifm_list))
nwords++;
if (ifmr->ifm_count != 0) {
kptr = (int *)malloc(ifmr->ifm_count * sizeof(int),
M_TEMP, M_WAITOK);
size_t count;
size_t minwords = nwords > (size_t)ifmr->ifm_count
? (size_t)ifmr->ifm_count : nwords;
int *kptr = (int *)malloc(minwords * sizeof(int),
M_TEMP, M_WAITOK);
/*
* Get the media words from the interface's list.
*/
for (; ep != NULL && count < ifmr->ifm_count;
ep = ep->ifm_list.le_next, count++)
ep = TAILQ_FIRST(&ifm->ifm_list);
for (count = 0; ep != NULL && count < minwords;
ep = TAILQ_NEXT(ep, ifm_list), count++)
kptr[count] = ep->ifm_media;
if (ep != NULL)
error = copyout(kptr, ifmr->ifm_ulist,
minwords * sizeof(int));
if (error == 0 && ep != NULL)
error = E2BIG; /* oops! */
}
/*
* If there are more interfaces on the list, count
* them. This allows the caller to set ifmr->ifm_count
* to 0 on the first call to know how much space to
* callocate.
*/
for (; ep != NULL; ep = ep->ifm_list.le_next)
count++;
/*
* We do the copyout on E2BIG, because that's
* just our way of telling userland that there
* are more. This is the behavior I've observed
* under BSD/OS 3.0
*/
sticky = error;
if ((error == 0 || error == E2BIG) && ifmr->ifm_count != 0) {
error = copyout((caddr_t)kptr,
(caddr_t)ifmr->ifm_ulist,
ifmr->ifm_count * sizeof(int));
}
if (error == 0)
error = sticky;
if (ifmr->ifm_count != 0)
free(kptr, M_TEMP);
ifmr->ifm_count = count;
}
ifmr->ifm_count = nwords;
break;
}
default:
return (EINVAL);
return (ENOTTY);
}
return (error);
@ -367,30 +348,70 @@ ifmedia_ioctl(ifp, ifr, ifm, cmd)
*
*/
struct ifmedia_entry *
ifmedia_match(ifm, target, mask)
struct ifmedia *ifm;
int target;
int mask;
ifmedia_match(struct ifmedia *ifm, u_int target, u_int mask)
{
struct ifmedia_entry *match, *next;
match = NULL;
mask = ~mask;
for (next = ifm->ifm_list.lh_first; next != NULL;
next = next->ifm_list.le_next) {
for (next = TAILQ_FIRST(&ifm->ifm_list); next != NULL;
next = TAILQ_NEXT(next, ifm_list)) {
if ((next->ifm_media & mask) == (target & mask)) {
#if defined(IFMEDIA_DEBUG) || defined(DIAGNOSTIC)
if (match) {
#if defined(IFMEDIA_DEBUG) || defined(DIAGNOSTIC)
printf("ifmedia_match: multiple match for "
"0x%x/0x%x\n", target, mask);
}
"0x%x/0x%x, selected instance %d\n",
target, mask, IFM_INST(match->ifm_media));
#endif
break;
}
match = next;
}
}
return (match);
}
/*
* Delete all media for a given instance.
*/
void
ifmedia_delete_instance(struct ifmedia *ifm, u_int inst)
{
struct ifmedia_entry *ife, *nife;
for (ife = TAILQ_FIRST(&ifm->ifm_list); ife != NULL;
ife = nife) {
nife = TAILQ_NEXT(ife, ifm_list);
if (inst == IFM_INST_ANY ||
inst == IFM_INST(ife->ifm_media)) {
TAILQ_REMOVE(&ifm->ifm_list, ife, ifm_list);
free(ife, M_IFADDR);
}
}
}
/*
* Compute the interface `baudrate' from the media, for the interface
* metrics (used by routing daemons).
*/
struct ifmedia_baudrate ifmedia_baudrate_descriptions[] =
IFM_BAUDRATE_DESCRIPTIONS;
u_int64_t
ifmedia_baudrate(int mword)
{
int i;
for (i = 0; ifmedia_baudrate_descriptions[i].ifmb_word != 0; i++) {
if ((mword & (IFM_NMASK|IFM_TMASK)) ==
ifmedia_baudrate_descriptions[i].ifmb_word)
return (ifmedia_baudrate_descriptions[i].ifmb_baudrate);
}
/* Not known. */
return (0);
return match;
}
#ifdef IFMEDIA_DEBUG
@ -408,8 +429,7 @@ struct ifmedia_description ifm_option_descriptions[] =
* print a media word.
*/
static void
ifmedia_printword(ifmw)
int ifmw;
ifmedia_printword(int ifmw)
{
struct ifmedia_description *desc;
int seen_option = 0;

335
sys/net/if_media.h

@ -1,8 +1,7 @@
/* $OpenBSD: if_media.h,v 1.6 2000/03/21 23:18:13 mickey Exp $ */
/* $NetBSD: if_media.h,v 1.11 1998/08/12 23:23:29 thorpej Exp $ */
/* $OpenBSD: if_media.h,v 1.31 2010/02/09 13:18:04 claudio Exp $ */
/* $NetBSD: if_media.h,v 1.22 2000/02/17 21:53:16 sommerfeld Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -17,13 +16,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
@ -94,16 +86,16 @@
/*
* Driver callbacks for media status and change requests.
*/
typedef int (*ifm_change_cb_t) __P((struct ifnet *ifp));
typedef void (*ifm_stat_cb_t) __P((struct ifnet *ifp, struct ifmediareq *req));
typedef int (*ifm_change_cb_t)(struct ifnet *);
typedef void (*ifm_stat_cb_t)(struct ifnet *, struct ifmediareq *);
/*
* In-kernel representation of a single supported media type.
*/
struct ifmedia_entry {
LIST_ENTRY(ifmedia_entry) ifm_list;
int ifm_media; /* description of this media attachment */
int ifm_data; /* for driver-specific use */
TAILQ_ENTRY(ifmedia_entry) ifm_list;
u_int ifm_media; /* description of this media attachment */
u_int ifm_data; /* for driver-specific use */
void *ifm_aux; /* for driver-specific use */
};
@ -112,38 +104,41 @@ struct ifmedia_entry {
* It is used to keep general media state.
*/
struct ifmedia {
int ifm_mask; /* mask of changes we don't care about */
int ifm_media; /* current user-set media word */
u_int ifm_mask; /* mask of changes we don't care about */
u_int ifm_media; /* current user-set media word */
struct ifmedia_entry *ifm_cur; /* currently selected media */
LIST_HEAD(, ifmedia_entry) ifm_list; /* list of all supported media */
TAILQ_HEAD(, ifmedia_entry) ifm_list; /* list of all supported media */
ifm_change_cb_t ifm_change; /* media change driver callback */
ifm_stat_cb_t ifm_status; /* media status driver callback */
};
/* Initialize an interface's struct if_media field. */
void ifmedia_init __P((struct ifmedia *ifm, int dontcare_mask,
ifm_change_cb_t change_callback, ifm_stat_cb_t status_callback));
void ifmedia_init(struct ifmedia *, int, ifm_change_cb_t,
ifm_stat_cb_t);
/* Add one supported medium to a struct ifmedia. */
void ifmedia_add __P((struct ifmedia *ifm, int mword, int data, void *aux));
void ifmedia_add(struct ifmedia *, int, int, void *);
/* Add an array (of ifmedia_entry) media to a struct ifmedia. */
void ifmedia_list_add(struct ifmedia *mp, struct ifmedia_entry *lp,
int count);
void ifmedia_list_add(struct ifmedia *, struct ifmedia_entry *,
int);
/* Set default media type on initialization. */
void ifmedia_set __P((struct ifmedia *ifm, int mword));
void ifmedia_set(struct ifmedia *, int);
/* Common ioctl function for getting/setting media, called by driver. */
int ifmedia_ioctl __P((struct ifnet *ifp, struct ifreq *ifr,
struct ifmedia *ifm, u_long cmd));
int ifmedia_ioctl(struct ifnet *, struct ifreq *, struct ifmedia *,
u_long);
/* Locate a media entry */
struct ifmedia_entry *ifmedia_match __P((struct ifmedia *ifm,
int flags, int mask));
struct ifmedia_entry *ifmedia_match(struct ifmedia *, u_int, u_int);
/* Delete all media for a given media instance */
void ifmedia_delete_instance __P((struct ifmedia *, int));
void ifmedia_delete_instance(struct ifmedia *, u_int);
/* Compute baudrate for a given media. */
u_int64_t ifmedia_baudrate(int);
#endif /*_KERNEL */
@ -151,7 +146,7 @@ void ifmedia_delete_instance __P((struct ifmedia *, int));
* if_media Options word:
* Bits Use
* ---- -------
* 0-4 Media variant MAX SUBTYPE == 31!
* 0-4 Media subtype MAX SUBTYPE == 31!
* 5-7 Media type
* 8-15 Type specific options
* 16-19 RFU
@ -171,26 +166,24 @@ void ifmedia_delete_instance __P((struct ifmedia *, int));
#define IFM_100_T4 8 /* 100BaseT4 - 4 pair cat 3 */
#define IFM_100_VG 9 /* 100VG-AnyLAN */
#define IFM_100_T2 10 /* 100BaseT2 */
#define IFM_1000_FX 11 /* 1000BaseFX - gigabit over fiber */
#define IFM_1000_SX 11 /* 1000BaseSX - multi-mode fiber */
#define IFM_10_STP 12 /* 10BaseT over shielded TP */
#define IFM_10_FL 13 /* 10BaseFL - Fiber */
#define IFM_1000_SX 14 /* 1000baseSX Multi-mode Fiber */
#define IFM_1000_LX 15 /* 1000baseLX Single-mode Fiber */
#define IFM_1000_CX 16 /* 1000baseCX 150ohm STP */
#define IFM_1000_TX 17 /* 1000baseTX 4 pair cat 5 */
#define IFM_HPNA_1 18 /* HomePNA 1.0 (1Mb/s) */
/*
* Token ring
*/
#define IFM_TOKEN 0x00000040
#define IFM_TOK_STP4 3 /* Shielded twisted pair 4m - DB9 */
#define IFM_TOK_STP16 4 /* Shielded twisted pair 16m - DB9 */
#define IFM_TOK_UTP4 5 /* Unshielded twisted pair 4m - RJ45 */
#define IFM_TOK_UTP16 6 /* Unshielded twisted pair 16m - RJ45 */
#define IFM_TOK_ETR 0x00000200 /* Early token release */
#define IFM_TOK_SRCRT 0x00000400 /* Enable source routing features */
#define IFM_TOK_ALLR 0x00000800 /* All routes / Single route bcast */
#define IFM_1000_LX 14 /* 1000baseLX - single-mode fiber */
#define IFM_1000_CX 15 /* 1000baseCX - 150ohm STP */
#define IFM_1000_T 16 /* 1000baseT - 4 pair cat 5 */
#define IFM_1000_TX IFM_1000_T /* for backwards compatibility */
#define IFM_HPNA_1 17 /* HomePNA 1.0 (1Mb/s) */
#define IFM_10G_LR 18 /* 10GBase-LR - single-mode fiber */
#define IFM_10G_SR 19 /* 10GBase-SR - multi-mode fiber */
#define IFM_10G_CX4 20 /* 10GBase-CX4 - copper */
#define IFM_2500_SX 21 /* 2500baseSX - multi-mode fiber */
#define IFM_10G_T 22 /* 10GbaseT cat 6 */
#define IFM_10G_SFP_CU 23 /* 10G SFP+ direct attached cable */
#define IFM_ETH_MASTER 0x00000100 /* master mode (1000baseT) */
#define IFM_ETH_RXPAUSE 0x00000200 /* receive PAUSE frames */
#define IFM_ETH_TXPAUSE 0x00000400 /* transmit PAUSE frames */
/*
* FDDI
@ -211,7 +204,64 @@ void ifmedia_delete_instance __P((struct ifmedia *, int));
#define IFM_IEEE80211_DS5 6 /* Direct Sequence 5Mbps*/
#define IFM_IEEE80211_DS11 7 /* Direct Sequence 11Mbps*/
#define IFM_IEEE80211_DS1 8 /* Direct Sequence 1Mbps*/
#define IFM_IEEE80211_DS22 9 /* Direct Sequence 22Mbps */
#define IFM_IEEE80211_OFDM6 10 /* OFDM 6Mbps */
#define IFM_IEEE80211_OFDM9 11 /* OFDM 9Mbps */
#define IFM_IEEE80211_OFDM12 12 /* OFDM 12Mbps */
#define IFM_IEEE80211_OFDM18 13 /* OFDM 18Mbps */
#define IFM_IEEE80211_OFDM24 14 /* OFDM 24Mbps */
#define IFM_IEEE80211_OFDM36 15 /* OFDM 36Mbps */
#define IFM_IEEE80211_OFDM48 16 /* OFDM 48Mbps */
#define IFM_IEEE80211_OFDM54 17 /* OFDM 54Mbps */
#define IFM_IEEE80211_OFDM72 18 /* OFDM 72Mbps */
#define IFM_IEEE80211_ADHOC 0x100 /* Operate in Adhoc mode */
#define IFM_IEEE80211_HOSTAP 0x200 /* Operate in Host AP mode */
#define IFM_IEEE80211_IBSS 0x400 /* Operate in IBSS mode */
#define IFM_IEEE80211_IBSSMASTER 0x800 /* Operate as an IBSS master */
#define IFM_IEEE80211_MONITOR 0x1000 /* Operate in Monitor mode */
#define IFM_IEEE80211_TURBO 0x2000 /* Operate in Turbo mode */
/* operating mode for multi-mode devices */
#define IFM_IEEE80211_11A 0x00010000 /* 5GHz, OFDM mode */
#define IFM_IEEE80211_11B 0x00020000 /* Direct Sequence mode */
#define IFM_IEEE80211_11G 0x00030000 /* 2GHz, CCK mode */
#define IFM_IEEE80211_FH 0x00040000 /* 2GHz, GFSK mode */
/*
* Digitally multiplexed "Carrier" Serial Interfaces
*/
#define IFM_TDM 0x000000a0
#define IFM_TDM_T1 3 /* T1 B8ZS+ESF 24 ts */
#define IFM_TDM_T1_AMI 4 /* T1 AMI+SF 24 ts */
#define IFM_TDM_E1 5 /* E1 HDB3+G.703 clearchannel 32 ts */
#define IFM_TDM_E1_G704 6 /* E1 HDB3+G.703+G.704 channelized 31 ts */
#define IFM_TDM_E1_AMI 7 /* E1 AMI+G.703 32 ts */
#define IFM_TDM_E1_AMI_G704 8 /* E1 AMI+G.703+G.704 31 ts */
#define IFM_TDM_T3 9 /* T3 B3ZS+C-bit 672 ts */
#define IFM_TDM_T3_M13 10 /* T3 B3ZS+M13 672 ts */
#define IFM_TDM_E3 11 /* E3 HDB3+G.751 512? ts */
#define IFM_TDM_E3_G751 12 /* E3 G.751 512 ts */
#define IFM_TDM_E3_G832 13 /* E3 G.832 512 ts */
#define IFM_TDM_E1_G704_CRC4 14 /* E1 HDB3+G.703+G.704 31 ts + CRC4 */
/*
* 6 major ways that networks talk: Drivers enforce independent selection,
* meaning, a driver will ensure that only one of these is set at a time.
* Default is cisco hdlc mode with 32 bit CRC.
*/
#define IFM_TDM_HDLC_CRC16 0x0100 /* Use 16-bit CRC for HDLC instead */
#define IFM_TDM_PPP 0x0200 /* SPPP (dumb) */
#define IFM_TDM_FR_ANSI 0x0400 /* Frame Relay + LMI ANSI "Annex D" */
#define IFM_TDM_FR_CISCO 0x0800 /* Frame Relay + LMI Cisco */
#define IFM_TDM_FR_ITU 0x1000 /* Frame Relay + LMI ITU "Q933A" */
/* operating mode */
#define IFM_TDM_MASTER 0x00010000 /* aka clock source internal */
/*
* Common Access Redundancy Protocol
*/
#define IFM_CARP 0x000000c0
/*
* Shared media sub-types
@ -239,8 +289,14 @@ void ifmedia_delete_instance __P((struct ifmedia *, int));
#define IFM_IMASK 0xf0000000 /* Instance */
#define IFM_ISHIFT 28 /* Instance shift */
#define IFM_OMASK 0x0000ff00 /* Type specific options */
#define IFM_MMASK 0x00070000 /* Mode */
#define IFM_MSHIFT 16 /* Mode shift */
#define IFM_GMASK 0x0ff00000 /* Global options */
/* Ethernet flow control mask */
#define IFM_ETH_FMASK (IFM_FLOW|IFM_ETH_RXPAUSE|IFM_ETH_TXPAUSE)
#define IFM_NMIN IFM_ETHER /* lowest Network type */
#define IFM_NMAX IFM_NMASK /* highest Network type */
@ -266,16 +322,18 @@ void ifmedia_delete_instance __P((struct ifmedia *, int));
#define IFM_SUBTYPE(x) ((x) & IFM_TMASK)
#define IFM_INST(x) (((x) & IFM_IMASK) >> IFM_ISHIFT)
#define IFM_OPTIONS(x) ((x) & (IFM_OMASK|IFM_GMASK))
#define IFM_MODE(x) ((x) & IFM_MMASK)
#define IFM_INST_MAX IFM_INST(IFM_IMASK)
#define IFM_INST_ANY (-1)
#define IFM_INST_ANY ((u_int) -1)
/*
* Macro to create a media word.
*/
#define IFM_MAKEWORD(type, subtype, options, instance) \
((type) | (subtype) | (options) | ((instance) << IFM_ISHIFT))
((type) | (subtype) | (options) | ((instance) << IFM_ISHIFT))
#define IFM_MAKEMODE(mode) \
(((mode) << IFM_MSHIFT) & IFM_MMASK)
/*
* NetBSD extension not defined in the BSDI API. This is used in various
* places to get the canonical description for a given type/subtype.
@ -297,10 +355,10 @@ struct ifmedia_description {
#define IFM_TYPE_DESCRIPTIONS { \
{ IFM_ETHER, "Ethernet" }, \
{ IFM_ETHER, "ether" }, \
{ IFM_TOKEN, "TokenRing" }, \
{ IFM_TOKEN, "token" }, \
{ IFM_FDDI, "FDDI" }, \
{ IFM_IEEE80211, "IEEE802.11" }, \
{ IFM_TDM, "TDM" }, \
{ IFM_CARP, "CARP" }, \
{ 0, NULL }, \
}
@ -335,29 +393,40 @@ struct ifmedia_description {
{ IFM_ETHER|IFM_100_VG, "100VG" }, \
{ IFM_ETHER|IFM_100_T2, "100baseT2" }, \
{ IFM_ETHER|IFM_100_T2, "100T2" }, \
{ IFM_ETHER|IFM_1000_FX, "1000baseFX" }, \
{ IFM_ETHER|IFM_1000_FX, "1000FX" }, \
{ IFM_ETHER|IFM_1000_SX, "1000baseSX" }, \
{ IFM_ETHER|IFM_1000_SX, "1000SX" }, \
{ IFM_ETHER|IFM_10_STP, "10baseSTP" }, \
{ IFM_ETHER|IFM_10_STP, "STP" }, \
{ IFM_ETHER|IFM_10_STP, "10STP" }, \
{ IFM_ETHER|IFM_10_FL, "10baseFL" }, \
{ IFM_ETHER|IFM_10_FL, "FL" }, \
{ IFM_ETHER|IFM_10_FL, "10FL" }, \
{ IFM_ETHER|IFM_1000_SX, "1000baseSX" }, \
{ IFM_ETHER|IFM_1000_LX, "1000baseLX" }, \
{ IFM_ETHER|IFM_1000_LX, "1000LX" }, \
{ IFM_ETHER|IFM_1000_CX, "1000baseCX" }, \
{ IFM_ETHER|IFM_1000_TX, "1000baseTX" }, \
{ IFM_ETHER|IFM_1000_CX, "1000CX" }, \
{ IFM_ETHER|IFM_1000_T, "1000baseT" }, \
{ IFM_ETHER|IFM_1000_T, "1000T" }, \
{ IFM_ETHER|IFM_1000_T, "1000baseTX" }, \
{ IFM_ETHER|IFM_1000_T, "1000TX" }, \
{ IFM_ETHER|IFM_HPNA_1, "HomePNA1" }, \
{ IFM_ETHER|IFM_HPNA_1, "HPNA1" }, \
\
{ IFM_TOKEN|IFM_TOK_STP4, "DB9/4Mbit" }, \
{ IFM_TOKEN|IFM_TOK_STP4, "4STP" }, \
{ IFM_TOKEN|IFM_TOK_STP16, "DB9/16Mbit" }, \
{ IFM_TOKEN|IFM_TOK_STP16, "16STP" }, \
{ IFM_TOKEN|IFM_TOK_UTP4, "UTP/4Mbit" }, \
{ IFM_TOKEN|IFM_TOK_UTP4, "4UTP" }, \
{ IFM_TOKEN|IFM_TOK_UTP16, "UTP/16Mbit" }, \
{ IFM_TOKEN|IFM_TOK_UTP16, "16UTP" }, \
{ IFM_ETHER|IFM_10G_LR, "10GbaseLR" }, \
{ IFM_ETHER|IFM_10G_LR, "10GLR" }, \
{ IFM_ETHER|IFM_10G_LR, "10GBASE-LR" }, \
{ IFM_ETHER|IFM_10G_SR, "10GbaseSR" }, \
{ IFM_ETHER|IFM_10G_SR, "10GSR" }, \
{ IFM_ETHER|IFM_10G_SR, "10GBASE-SR" }, \
{ IFM_ETHER|IFM_10G_CX4, "10GbaseCX4" }, \
{ IFM_ETHER|IFM_10G_CX4, "10GCX4" }, \
{ IFM_ETHER|IFM_10G_CX4, "10GBASE-CX4" }, \
{ IFM_ETHER|IFM_2500_SX, "2500baseSX" }, \
{ IFM_ETHER|IFM_2500_SX, "2500SX" }, \
{ IFM_ETHER|IFM_10G_T, "10GbaseT" }, \
{ IFM_ETHER|IFM_10G_T, "10GT" }, \
{ IFM_ETHER|IFM_10G_T, "10GBASE-T" }, \
{ IFM_ETHER|IFM_10G_SFP_CU, "10GSFP+Cu" }, \
{ IFM_ETHER|IFM_10G_SFP_CU, "10GCu" }, \
\
{ IFM_FDDI|IFM_FDDI_SMF, "Single-mode" }, \
{ IFM_FDDI|IFM_FDDI_SMF, "SMF" }, \
@ -368,14 +437,49 @@ struct ifmedia_description {
\
{ IFM_IEEE80211|IFM_IEEE80211_FH1, "FH1" }, \
{ IFM_IEEE80211|IFM_IEEE80211_FH2, "FH2" }, \
{ IFM_IEEE80211|IFM_IEEE80211_DS1, "DS1" }, \
{ IFM_IEEE80211|IFM_IEEE80211_DS2, "DS2" }, \
{ IFM_IEEE80211|IFM_IEEE80211_DS5, "DS5" }, \
{ IFM_IEEE80211|IFM_IEEE80211_DS11, "DS11" }, \
{ IFM_IEEE80211|IFM_IEEE80211_DS1, "DS1" }, \
{ IFM_IEEE80211|IFM_IEEE80211_DS22, "DS22" }, \
{ IFM_IEEE80211|IFM_IEEE80211_OFDM6, "OFDM6" }, \
{ IFM_IEEE80211|IFM_IEEE80211_OFDM9, "OFDM9" }, \
{ IFM_IEEE80211|IFM_IEEE80211_OFDM12, "OFDM12" }, \
{ IFM_IEEE80211|IFM_IEEE80211_OFDM18, "OFDM18" }, \
{ IFM_IEEE80211|IFM_IEEE80211_OFDM24, "OFDM24" }, \
{ IFM_IEEE80211|IFM_IEEE80211_OFDM36, "OFDM36" }, \
{ IFM_IEEE80211|IFM_IEEE80211_OFDM48, "OFDM48" }, \
{ IFM_IEEE80211|IFM_IEEE80211_OFDM54, "OFDM54" }, \
{ IFM_IEEE80211|IFM_IEEE80211_OFDM72, "OFDM72" }, \
\
{ IFM_TDM|IFM_TDM_T1, "t1" }, \
{ IFM_TDM|IFM_TDM_T1_AMI, "t1-ami" }, \
{ IFM_TDM|IFM_TDM_E1, "e1" }, \
{ IFM_TDM|IFM_TDM_E1_G704, "e1-g.704" }, \
{ IFM_TDM|IFM_TDM_E1_AMI, "e1-ami" }, \
{ IFM_TDM|IFM_TDM_E1_AMI_G704, "e1-ami-g.704" }, \
{ IFM_TDM|IFM_TDM_T3, "t3" }, \
{ IFM_TDM|IFM_TDM_T3_M13, "t3-m13" }, \
{ IFM_TDM|IFM_TDM_E3, "e3" }, \
{ IFM_TDM|IFM_TDM_E3_G751, "e3-g.751" }, \
{ IFM_TDM|IFM_TDM_E3_G832, "e3-g.832" }, \
{ IFM_TDM|IFM_TDM_E1_G704_CRC4, "e1-g.704-crc4" }, \
\
{ 0, NULL }, \
}
#define IFM_MODE_DESCRIPTIONS { \
{ IFM_AUTO, "autoselect" }, \
{ IFM_AUTO, "auto" }, \
{ IFM_IEEE80211|IFM_IEEE80211_11A, "11a" }, \
{ IFM_IEEE80211|IFM_IEEE80211_11B, "11b" }, \
{ IFM_IEEE80211|IFM_IEEE80211_11G, "11g" }, \
{ IFM_IEEE80211|IFM_IEEE80211_FH, "fh" }, \
{ IFM_TDM|IFM_TDM_MASTER, "master" }, \
{ 0, NULL }, \
}
#define IFM_OPTION_DESCRIPTIONS { \
{ IFM_FDX, "full-duplex" }, \
{ IFM_FDX, "fdx" }, \
@ -388,22 +492,99 @@ struct ifmedia_description {
{ IFM_LOOP, "hw-loopback"}, \
{ IFM_LOOP, "loop" }, \
\
{ IFM_TOKEN|IFM_TOK_ETR, "EarlyTokenRelease" }, \
{ IFM_TOKEN|IFM_TOK_ETR, "ETR" }, \
{ IFM_TOKEN|IFM_TOK_SRCRT, "SourceRouting" }, \
{ IFM_TOKEN|IFM_TOK_SRCRT, "SRCRT" }, \
{ IFM_TOKEN|IFM_TOK_ALLR, "AllRoutes" }, \
{ IFM_TOKEN|IFM_TOK_ALLR, "ALLR" }, \
{ IFM_ETHER|IFM_ETH_MASTER, "master" }, \
{ IFM_ETHER|IFM_ETH_RXPAUSE, "rxpause" }, \
{ IFM_ETHER|IFM_ETH_TXPAUSE, "txpause" }, \
\
{ IFM_FDDI|IFM_FDDI_DA, "dual-attach" }, \
{ IFM_FDDI|IFM_FDDI_DA, "das" }, \
\
{ IFM_IEEE80211|IFM_IEEE80211_ADHOC, "adhoc" }, \
{ IFM_IEEE80211|IFM_IEEE80211_HOSTAP, "hostap" }, \
{ IFM_IEEE80211|IFM_IEEE80211_IBSS, "ibss" }, \
{ IFM_IEEE80211|IFM_IEEE80211_IBSSMASTER, "ibss-master" }, \
{ IFM_IEEE80211|IFM_IEEE80211_MONITOR, "monitor" }, \
{ IFM_IEEE80211|IFM_IEEE80211_TURBO, "turbo" }, \
\
{ IFM_TDM|IFM_TDM_HDLC_CRC16, "hdlc-crc16" }, \
{ IFM_TDM|IFM_TDM_PPP, "ppp" }, \
{ IFM_TDM|IFM_TDM_FR_ANSI, "framerelay-ansi" }, \
{ IFM_TDM|IFM_TDM_FR_CISCO, "framerelay-cisco" }, \
{ IFM_TDM|IFM_TDM_FR_ANSI, "framerelay-itu" }, \
\
{ 0, NULL }, \
}
/*
* Baudrate descriptions for the various media types.
*/
struct ifmedia_baudrate {
int ifmb_word; /* media word */
u_int64_t ifmb_baudrate; /* corresponding baudrate */
};
#define IFM_BAUDRATE_DESCRIPTIONS { \
{ IFM_ETHER|IFM_10_T, IF_Mbps(10) }, \
{ IFM_ETHER|IFM_10_2, IF_Mbps(10) }, \
{ IFM_ETHER|IFM_10_5, IF_Mbps(10) }, \
{ IFM_ETHER|IFM_100_TX, IF_Mbps(100) }, \
{ IFM_ETHER|IFM_100_FX, IF_Mbps(100) }, \
{ IFM_ETHER|IFM_100_T4, IF_Mbps(100) }, \
{ IFM_ETHER|IFM_100_VG, IF_Mbps(100) }, \
{ IFM_ETHER|IFM_100_T2, IF_Mbps(100) }, \
{ IFM_ETHER|IFM_1000_SX, IF_Mbps(1000) }, \
{ IFM_ETHER|IFM_10_STP, IF_Mbps(10) }, \
{ IFM_ETHER|IFM_10_FL, IF_Mbps(10) }, \
{ IFM_ETHER|IFM_1000_LX, IF_Mbps(1000) }, \
{ IFM_ETHER|IFM_1000_CX, IF_Mbps(1000) }, \
{ IFM_ETHER|IFM_1000_T, IF_Mbps(1000) }, \
{ IFM_ETHER|IFM_HPNA_1, IF_Mbps(1) }, \
{ IFM_ETHER|IFM_10G_LR, IF_Gbps(10) }, \
{ IFM_ETHER|IFM_10G_SR, IF_Gbps(10) }, \
{ IFM_ETHER|IFM_10G_CX4, IF_Gbps(10) }, \
{ IFM_ETHER|IFM_2500_SX, IF_Mbps(2500) }, \
{ IFM_ETHER|IFM_10G_T, IF_Gbps(10) }, \
{ IFM_ETHER|IFM_10G_SFP_CU, IF_Gbps(10) }, \
\
{ IFM_FDDI|IFM_FDDI_SMF, IF_Mbps(100) }, \
{ IFM_FDDI|IFM_FDDI_MMF, IF_Mbps(100) }, \
{ IFM_FDDI|IFM_FDDI_UTP, IF_Mbps(100) }, \
\
{ IFM_IEEE80211|IFM_IEEE80211_FH1, IF_Mbps(1) }, \
{ IFM_IEEE80211|IFM_IEEE80211_FH2, IF_Mbps(2) }, \
{ IFM_IEEE80211|IFM_IEEE80211_DS1, IF_Mbps(1) }, \
{ IFM_IEEE80211|IFM_IEEE80211_DS2, IF_Mbps(2) }, \
{ IFM_IEEE80211|IFM_IEEE80211_DS5, IF_Mbps(5) }, \
{ IFM_IEEE80211|IFM_IEEE80211_DS11, IF_Mbps(11) }, \
{ IFM_IEEE80211|IFM_IEEE80211_DS22, IF_Mbps(22) }, \
{ IFM_IEEE80211|IFM_IEEE80211_OFDM6, IF_Mbps(6) }, \
{ IFM_IEEE80211|IFM_IEEE80211_OFDM9, IF_Mbps(9) }, \
{ IFM_IEEE80211|IFM_IEEE80211_OFDM12, IF_Mbps(12) }, \
{ IFM_IEEE80211|IFM_IEEE80211_OFDM18, IF_Mbps(18) }, \
{ IFM_IEEE80211|IFM_IEEE80211_OFDM24, IF_Mbps(24) }, \
{ IFM_IEEE80211|IFM_IEEE80211_OFDM36, IF_Mbps(36) }, \
{ IFM_IEEE80211|IFM_IEEE80211_OFDM48, IF_Mbps(48) }, \
{ IFM_IEEE80211|IFM_IEEE80211_OFDM54, IF_Mbps(54) }, \
{ IFM_IEEE80211|IFM_IEEE80211_OFDM72, IF_Mbps(72) }, \
\
{ IFM_TDM|IFM_TDM_T1, IF_Kbps(1536) }, \
{ IFM_TDM|IFM_TDM_T1_AMI, IF_Kbps(1536) }, \
{ IFM_TDM|IFM_TDM_E1, IF_Kbps(2048) }, \
{ IFM_TDM|IFM_TDM_E1_G704, IF_Kbps(2048) }, \
{ IFM_TDM|IFM_TDM_E1_AMI, IF_Kbps(2048) }, \
{ IFM_TDM|IFM_TDM_E1_AMI_G704, IF_Kbps(2048) }, \
{ IFM_TDM|IFM_TDM_T3, IF_Kbps(44736) }, \
{ IFM_TDM|IFM_TDM_T3_M13, IF_Kbps(44736) }, \
{ IFM_TDM|IFM_TDM_E3, IF_Kbps(34368) }, \
{ IFM_TDM|IFM_TDM_E3_G751, IF_Kbps(34368) }, \
{ IFM_TDM|IFM_TDM_E3_G832, IF_Kbps(34368) }, \
{ IFM_TDM|IFM_TDM_E1_G704_CRC4, IF_Kbps(2048) }, \
\
{ 0, 0 }, \
}
/*
* Status bit descriptions for the various media types.
*/
struct ifmedia_status_description {
@ -421,10 +602,12 @@ struct ifmedia_status_description {
{ "no carrier", "active" } }, \
{ IFM_FDDI, IFM_AVALID, IFM_ACTIVE, \
{ "no ring", "inserted" } }, \
{ IFM_TOKEN, IFM_AVALID, IFM_ACTIVE, \
{ "no ring", "inserted" } }, \
{ IFM_IEEE80211, IFM_AVALID, IFM_ACTIVE, \
{ "no network", "active" } }, \
{ IFM_TDM, IFM_AVALID, IFM_ACTIVE, \
{ "no carrier", "active" } }, \
{ IFM_CARP, IFM_AVALID, IFM_ACTIVE, \
{ "backup", "master" } }, \
{ 0, 0, 0, \
{ NULL, NULL } } \
}

10
sys/netinet/if_ether.h

@ -35,7 +35,8 @@
*
* @(#)if_ether.h 8.1 (Berkeley) 6/10/93
*/
#ifndef _NETINET_IN_IF_ETHER_H
#define _NETINET_IN_IF_ETHER_H
/*
* Ethernet address - 6 octets
* this is only used by the ethers(3) functions.
@ -49,6 +50,12 @@ struct ether_addr {
*/
#define ETHER_ADDR_LEN 6
#define ETHER_CRC_LEN 4 /* Ethernet CRC length */
#define ETHER_ALIGN 2 /* driver adjust for IP hdr alignment */
//wan+
#define ETHER_TYPE_LEN 2 /* Ethernet type field length_______*/
#define ETHER_HDR_LEN ((ETHER_ADDR_LEN * 2) + ETHER_TYPE_LEN)
struct ether_header {
u_int8_t ether_dhost[ETHER_ADDR_LEN];
u_int8_t ether_shost[ETHER_ADDR_LEN];
@ -265,3 +272,4 @@ int ether_hostton __P((char *, struct ether_addr *));
int ether_line __P((char *, struct ether_addr *, char *));
#endif
#endif

9
sys/sys/param.h

@ -181,6 +181,13 @@
#define MAXPATHLEN PATH_MAX
#define MAXSYMLINKS 32
/* Macros to set/clear/test flags. */
#ifdef _KERNEL
#define SET(t, f) ((t) |= (f))
#define CLR(t, f) ((t) &= ~(f))
#define ISSET(t, f) ((t) & (f))
#endif
/* Bit map related macros. */
#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
@ -199,7 +206,7 @@
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
#endif
#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
/*
* Constants for setting the parameters of the kernel memory allocator.
*

103
sys/sys/timeout.h

@ -0,0 +1,103 @@
/* $OpenBSD: timeout.h,v 1.21 2011/05/10 00:58:42 dlg Exp $ */
/*
* Copyright (c) 2000-2001 Artur Grabowski <art@openbsd.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _SYS_TIMEOUT_H_
#define _SYS_TIMEOUT_H_
/*
* Interface for handling time driven events in the kernel.
*
* The basic component of this API is the struct timeout. The user should not
* touch the internals of this structure, but it's the users responsibility
* to allocate and deallocate timeouts.
*
* The functions used to manipulate timeouts are:
* - timeout_set(timeout, function, argument)
* Initializes a timeout struct to call the function with the argument.
* A timeout only needs to be initialized once.
* - timeout_add(timeout, ticks)
* Schedule this timeout to run in "ticks" ticks (there are hz ticks in
* one second). You may not touch the timeout with timeout_set once the
* timeout is scheduled. A second call to timeout_add with an already
* scheduled timeout will cause the old timeout to be canceled and the
* new will be scheduled.
* - timeout_del(timeout)
* Remove the timeout from the timeout queue. It's legal to remove
* a timeout that has already happened.
*
* These functions may be called in interrupt context (anything below splhigh).
*/
struct circq {
struct circq *next; /* next element */
struct circq *prev; /* previous element */
};
struct timeout {
struct circq to_list; /* timeout queue, don't move */
void (*to_func)(void *); /* function to call */
void *to_arg; /* function argument */
int to_time; /* ticks on event */
int to_flags; /* misc flags */
};
/*
* flags in the to_flags field.
*/
#define TIMEOUT_ONQUEUE 2 /* timeout is on the todo queue */
#define TIMEOUT_INITIALIZED 4 /* timeout is initialized */
#define TIMEOUT_TRIGGERED 8 /* timeout is running or ran */
#ifdef _KERNEL
/*
* special macros
*
* timeout_pending(to) - is this timeout already scheduled to run?
* timeout_initialized(to) - is this timeout initialized?
*/
#define timeout_pending(to) ((to)->to_flags & TIMEOUT_ONQUEUE)
#define timeout_initialized(to) ((to)->to_flags & TIMEOUT_INITIALIZED)
#define timeout_triggered(to) ((to)->to_flags & TIMEOUT_TRIGGERED)
void timeout_set(struct timeout *, void (*)(void *), void *);
void timeout_add(struct timeout *, int);
void timeout_add_tv(struct timeout *, const struct timeval *);
void timeout_add_ts(struct timeout *, const struct timespec *);
void timeout_add_bt(struct timeout *, const struct bintime *);
void timeout_add_sec(struct timeout *, int);
void timeout_add_msec(struct timeout *, int);
void timeout_add_usec(struct timeout *, int);
void timeout_add_nsec(struct timeout *, int);
int timeout_del(struct timeout *);
void timeout_startup(void);
/*
* called once every hardclock. returns non-zero if we need to schedule a
* softclock.
*/
int timeout_hardclock_update(void);
#endif /* _KERNEL */
#endif /* _SYS_TIMEOUT_H_ */
Loading…
Cancel
Save