Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Copyright (C) 2003 - 2009 NetXen, Inc.
0004  * Copyright (C) 2009 - QLogic Corporation.
0005  * All rights reserved.
0006  */
0007 
0008 #ifndef __NETXEN_NIC_HW_H_
0009 #define __NETXEN_NIC_HW_H_
0010 
0011 /* Hardware memory size of 128 meg */
0012 #define NETXEN_MEMADDR_MAX (128 * 1024 * 1024)
0013 
0014 struct netxen_adapter;
0015 
0016 #define NETXEN_PCI_MAPSIZE_BYTES  (NETXEN_PCI_MAPSIZE << 20)
0017 
0018 void netxen_nic_set_link_parameters(struct netxen_adapter *adapter);
0019 
0020 /* Nibble or Byte mode for phy interface (GbE mode only) */
0021 
0022 #define _netxen_crb_get_bit(var, bit)  ((var >> bit) & 0x1)
0023 
0024 /*
0025  * NIU GB MAC Config Register 0 (applies to GB0, GB1, GB2, GB3)
0026  *
0027  *  Bit 0 : enable_tx => 1:enable frame xmit, 0:disable
0028  *  Bit 1 : tx_synced => R/O: xmit enable synched to xmit stream
0029  *  Bit 2 : enable_rx => 1:enable frame recv, 0:disable
0030  *  Bit 3 : rx_synced => R/O: recv enable synched to recv stream
0031  *  Bit 4 : tx_flowctl => 1:enable pause frame generation, 0:disable
0032  *  Bit 5 : rx_flowctl => 1:act on recv'd pause frames, 0:ignore
0033  *  Bit 8 : loopback => 1:loop MAC xmits to MAC recvs, 0:normal
0034  *  Bit 16: tx_reset_pb => 1:reset frame xmit protocol blk, 0:no-op
0035  *  Bit 17: rx_reset_pb => 1:reset frame recv protocol blk, 0:no-op
0036  *  Bit 18: tx_reset_mac => 1:reset data/ctl multiplexer blk, 0:no-op
0037  *  Bit 19: rx_reset_mac => 1:reset ctl frames & timers blk, 0:no-op
0038  *  Bit 31: soft_reset => 1:reset the MAC and the SERDES, 0:no-op
0039  */
0040 
0041 #define netxen_gb_tx_flowctl(config_word)   \
0042     ((config_word) |= 1 << 4)
0043 #define netxen_gb_rx_flowctl(config_word)   \
0044     ((config_word) |= 1 << 5)
0045 #define netxen_gb_tx_reset_pb(config_word)  \
0046     ((config_word) |= 1 << 16)
0047 #define netxen_gb_rx_reset_pb(config_word)  \
0048     ((config_word) |= 1 << 17)
0049 #define netxen_gb_tx_reset_mac(config_word) \
0050     ((config_word) |= 1 << 18)
0051 #define netxen_gb_rx_reset_mac(config_word) \
0052     ((config_word) |= 1 << 19)
0053 
0054 #define netxen_gb_unset_tx_flowctl(config_word) \
0055     ((config_word) &= ~(1 << 4))
0056 #define netxen_gb_unset_rx_flowctl(config_word) \
0057     ((config_word) &= ~(1 << 5))
0058 
0059 #define netxen_gb_get_tx_synced(config_word)    \
0060         _netxen_crb_get_bit((config_word), 1)
0061 #define netxen_gb_get_rx_synced(config_word)    \
0062         _netxen_crb_get_bit((config_word), 3)
0063 #define netxen_gb_get_tx_flowctl(config_word)   \
0064         _netxen_crb_get_bit((config_word), 4)
0065 #define netxen_gb_get_rx_flowctl(config_word)   \
0066         _netxen_crb_get_bit((config_word), 5)
0067 #define netxen_gb_get_soft_reset(config_word)   \
0068         _netxen_crb_get_bit((config_word), 31)
0069 
0070 #define netxen_gb_get_stationaddress_low(config_word) ((config_word) >> 16)
0071 
0072 #define netxen_gb_set_mii_mgmt_clockselect(config_word, val)    \
0073         ((config_word) |= ((val) & 0x07))
0074 #define netxen_gb_mii_mgmt_reset(config_word)   \
0075         ((config_word) |= 1 << 31)
0076 #define netxen_gb_mii_mgmt_unset(config_word)   \
0077         ((config_word) &= ~(1 << 31))
0078 
0079 /*
0080  * NIU GB MII Mgmt Command Register (applies to GB0, GB1, GB2, GB3)
0081  * Bit 0 : read_cycle => 1:perform single read cycle, 0:no-op
0082  * Bit 1 : scan_cycle => 1:perform continuous read cycles, 0:no-op
0083  */
0084 
0085 #define netxen_gb_mii_mgmt_set_read_cycle(config_word)  \
0086         ((config_word) |= 1 << 0)
0087 #define netxen_gb_mii_mgmt_reg_addr(config_word, val)   \
0088         ((config_word) |= ((val) & 0x1F))
0089 #define netxen_gb_mii_mgmt_phy_addr(config_word, val)   \
0090         ((config_word) |= (((val) & 0x1F) << 8))
0091 
0092 /*
0093  * NIU GB MII Mgmt Indicators Register (applies to GB0, GB1, GB2, GB3)
0094  * Read-only register.
0095  * Bit 0 : busy => 1:performing an MII mgmt cycle, 0:idle
0096  * Bit 1 : scanning => 1:scan operation in progress, 0:idle
0097  * Bit 2 : notvalid => :mgmt result data not yet valid, 0:idle
0098  */
0099 #define netxen_get_gb_mii_mgmt_busy(config_word)    \
0100         _netxen_crb_get_bit(config_word, 0)
0101 #define netxen_get_gb_mii_mgmt_scanning(config_word)    \
0102         _netxen_crb_get_bit(config_word, 1)
0103 #define netxen_get_gb_mii_mgmt_notvalid(config_word)    \
0104         _netxen_crb_get_bit(config_word, 2)
0105 /*
0106  * NIU XG Pause Ctl Register
0107  *
0108  *      Bit 0       : xg0_mask => 1:disable tx pause frames
0109  *      Bit 1       : xg0_request => 1:request single pause frame
0110  *      Bit 2       : xg0_on_off => 1:request is pause on, 0:off
0111  *      Bit 3       : xg1_mask => 1:disable tx pause frames
0112  *      Bit 4       : xg1_request => 1:request single pause frame
0113  *      Bit 5       : xg1_on_off => 1:request is pause on, 0:off
0114  */
0115 
0116 #define netxen_xg_set_xg0_mask(config_word)    \
0117     ((config_word) |= 1 << 0)
0118 #define netxen_xg_set_xg1_mask(config_word)    \
0119     ((config_word) |= 1 << 3)
0120 
0121 #define netxen_xg_get_xg0_mask(config_word)    \
0122     _netxen_crb_get_bit((config_word), 0)
0123 #define netxen_xg_get_xg1_mask(config_word)    \
0124     _netxen_crb_get_bit((config_word), 3)
0125 
0126 #define netxen_xg_unset_xg0_mask(config_word)  \
0127     ((config_word) &= ~(1 << 0))
0128 #define netxen_xg_unset_xg1_mask(config_word)  \
0129     ((config_word) &= ~(1 << 3))
0130 
0131 /*
0132  * NIU XG Pause Ctl Register
0133  *
0134  *      Bit 0       : xg0_mask => 1:disable tx pause frames
0135  *      Bit 1       : xg0_request => 1:request single pause frame
0136  *      Bit 2       : xg0_on_off => 1:request is pause on, 0:off
0137  *      Bit 3       : xg1_mask => 1:disable tx pause frames
0138  *      Bit 4       : xg1_request => 1:request single pause frame
0139  *      Bit 5       : xg1_on_off => 1:request is pause on, 0:off
0140  */
0141 #define netxen_gb_set_gb0_mask(config_word)    \
0142     ((config_word) |= 1 << 0)
0143 #define netxen_gb_set_gb1_mask(config_word)    \
0144     ((config_word) |= 1 << 2)
0145 #define netxen_gb_set_gb2_mask(config_word)    \
0146     ((config_word) |= 1 << 4)
0147 #define netxen_gb_set_gb3_mask(config_word)    \
0148     ((config_word) |= 1 << 6)
0149 
0150 #define netxen_gb_get_gb0_mask(config_word)    \
0151     _netxen_crb_get_bit((config_word), 0)
0152 #define netxen_gb_get_gb1_mask(config_word)    \
0153     _netxen_crb_get_bit((config_word), 2)
0154 #define netxen_gb_get_gb2_mask(config_word)    \
0155     _netxen_crb_get_bit((config_word), 4)
0156 #define netxen_gb_get_gb3_mask(config_word)    \
0157     _netxen_crb_get_bit((config_word), 6)
0158 
0159 #define netxen_gb_unset_gb0_mask(config_word)  \
0160     ((config_word) &= ~(1 << 0))
0161 #define netxen_gb_unset_gb1_mask(config_word)  \
0162     ((config_word) &= ~(1 << 2))
0163 #define netxen_gb_unset_gb2_mask(config_word)  \
0164     ((config_word) &= ~(1 << 4))
0165 #define netxen_gb_unset_gb3_mask(config_word)  \
0166     ((config_word) &= ~(1 << 6))
0167 
0168 
0169 /*
0170  * PHY-Specific MII control/status registers.
0171  */
0172 #define NETXEN_NIU_GB_MII_MGMT_ADDR_CONTROL     0
0173 #define NETXEN_NIU_GB_MII_MGMT_ADDR_STATUS      1
0174 #define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_ID_0        2
0175 #define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_ID_1        3
0176 #define NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG     4
0177 #define NETXEN_NIU_GB_MII_MGMT_ADDR_LNKPART     5
0178 #define NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG_MORE    6
0179 #define NETXEN_NIU_GB_MII_MGMT_ADDR_NEXTPAGE_XMIT   7
0180 #define NETXEN_NIU_GB_MII_MGMT_ADDR_LNKPART_NEXTPAGE    8
0181 #define NETXEN_NIU_GB_MII_MGMT_ADDR_1000BT_CONTROL  9
0182 #define NETXEN_NIU_GB_MII_MGMT_ADDR_1000BT_STATUS   10
0183 #define NETXEN_NIU_GB_MII_MGMT_ADDR_EXTENDED_STATUS 15
0184 #define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_CONTROL     16
0185 #define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS      17
0186 #define NETXEN_NIU_GB_MII_MGMT_ADDR_INT_ENABLE      18
0187 #define NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS      19
0188 #define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_CONTROL_MORE    20
0189 #define NETXEN_NIU_GB_MII_MGMT_ADDR_RECV_ERROR_COUNT    21
0190 #define NETXEN_NIU_GB_MII_MGMT_ADDR_LED_CONTROL     24
0191 #define NETXEN_NIU_GB_MII_MGMT_ADDR_LED_OVERRIDE    25
0192 #define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_CONTROL_MORE_YET    26
0193 #define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS_MORE 27
0194 
0195 /*
0196  * PHY-Specific Status Register (reg 17).
0197  *
0198  * Bit 0      : jabber => 1:jabber detected, 0:not
0199  * Bit 1      : polarity => 1:polarity reversed, 0:normal
0200  * Bit 2      : recvpause => 1:receive pause enabled, 0:disabled
0201  * Bit 3      : xmitpause => 1:transmit pause enabled, 0:disabled
0202  * Bit 4      : energydetect => 1:sleep, 0:active
0203  * Bit 5      : downshift => 1:downshift, 0:no downshift
0204  * Bit 6      : crossover => 1:MDIX (crossover), 0:MDI (no crossover)
0205  * Bits 7-9   : cablelen => not valid in 10Mb/s mode
0206  *          0:<50m, 1:50-80m, 2:80-110m, 3:110-140m, 4:>140m
0207  * Bit 10     : link => 1:link up, 0:link down
0208  * Bit 11     : resolved => 1:speed and duplex resolved, 0:not yet
0209  * Bit 12     : pagercvd => 1:page received, 0:page not received
0210  * Bit 13     : duplex => 1:full duplex, 0:half duplex
0211  * Bits 14-15 : speed => 0:10Mb/s, 1:100Mb/s, 2:1000Mb/s, 3:rsvd
0212  */
0213 
0214 #define netxen_get_phy_speed(config_word) (((config_word) >> 14) & 0x03)
0215 
0216 #define netxen_set_phy_speed(config_word, val)  \
0217         ((config_word) |= ((val & 0x03) << 14))
0218 #define netxen_set_phy_duplex(config_word)  \
0219         ((config_word) |= 1 << 13)
0220 #define netxen_clear_phy_duplex(config_word)    \
0221         ((config_word) &= ~(1 << 13))
0222 
0223 #define netxen_get_phy_link(config_word)    \
0224         _netxen_crb_get_bit(config_word, 10)
0225 #define netxen_get_phy_duplex(config_word)  \
0226         _netxen_crb_get_bit(config_word, 13)
0227 
0228 /*
0229  * NIU Mode Register.
0230  * Bit 0 : enable FibreChannel
0231  * Bit 1 : enable 10/100/1000 Ethernet
0232  * Bit 2 : enable 10Gb Ethernet
0233  */
0234 
0235 #define netxen_get_niu_enable_ge(config_word)   \
0236         _netxen_crb_get_bit(config_word, 1)
0237 
0238 #define NETXEN_NIU_NON_PROMISC_MODE 0
0239 #define NETXEN_NIU_PROMISC_MODE     1
0240 #define NETXEN_NIU_ALLMULTI_MODE    2
0241 
0242 /*
0243  * NIU XG MAC Config Register
0244  *
0245  * Bit 0 : tx_enable => 1:enable frame xmit, 0:disable
0246  * Bit 2 : rx_enable => 1:enable frame recv, 0:disable
0247  * Bit 4 : soft_reset => 1:reset the MAC , 0:no-op
0248  * Bit 27: xaui_framer_reset
0249  * Bit 28: xaui_rx_reset
0250  * Bit 29: xaui_tx_reset
0251  * Bit 30: xg_ingress_afifo_reset
0252  * Bit 31: xg_egress_afifo_reset
0253  */
0254 
0255 #define netxen_xg_soft_reset(config_word)   \
0256         ((config_word) |= 1 << 4)
0257 
0258 typedef struct {
0259     unsigned valid;
0260     unsigned start_128M;
0261     unsigned end_128M;
0262     unsigned start_2M;
0263 } crb_128M_2M_sub_block_map_t;
0264 
0265 typedef struct {
0266     crb_128M_2M_sub_block_map_t sub_block[16];
0267 } crb_128M_2M_block_map_t;
0268 
0269 #endif              /* __NETXEN_NIC_HW_H_ */