netxen_nic_hw.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. /*
  2. * Copyright (C) 2003 - 2009 NetXen, Inc.
  3. * All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
  18. * MA 02111-1307, USA.
  19. *
  20. * The full GNU General Public License is included in this distribution
  21. * in the file called LICENSE.
  22. *
  23. * Contact Information:
  24. * info@netxen.com
  25. * NetXen Inc,
  26. * 18922 Forge Drive
  27. * Cupertino, CA 95014-0701
  28. *
  29. */
  30. #ifndef __NETXEN_NIC_HW_H_
  31. #define __NETXEN_NIC_HW_H_
  32. /* Hardware memory size of 128 meg */
  33. #define NETXEN_MEMADDR_MAX (128 * 1024 * 1024)
  34. struct netxen_adapter;
  35. #define NETXEN_PCI_MAPSIZE_BYTES (NETXEN_PCI_MAPSIZE << 20)
  36. void netxen_nic_set_link_parameters(struct netxen_adapter *adapter);
  37. /* Nibble or Byte mode for phy interface (GbE mode only) */
  38. #define _netxen_crb_get_bit(var, bit) ((var >> bit) & 0x1)
  39. /*
  40. * NIU GB MAC Config Register 0 (applies to GB0, GB1, GB2, GB3)
  41. *
  42. * Bit 0 : enable_tx => 1:enable frame xmit, 0:disable
  43. * Bit 1 : tx_synced => R/O: xmit enable synched to xmit stream
  44. * Bit 2 : enable_rx => 1:enable frame recv, 0:disable
  45. * Bit 3 : rx_synced => R/O: recv enable synched to recv stream
  46. * Bit 4 : tx_flowctl => 1:enable pause frame generation, 0:disable
  47. * Bit 5 : rx_flowctl => 1:act on recv'd pause frames, 0:ignore
  48. * Bit 8 : loopback => 1:loop MAC xmits to MAC recvs, 0:normal
  49. * Bit 16: tx_reset_pb => 1:reset frame xmit protocol blk, 0:no-op
  50. * Bit 17: rx_reset_pb => 1:reset frame recv protocol blk, 0:no-op
  51. * Bit 18: tx_reset_mac => 1:reset data/ctl multiplexer blk, 0:no-op
  52. * Bit 19: rx_reset_mac => 1:reset ctl frames & timers blk, 0:no-op
  53. * Bit 31: soft_reset => 1:reset the MAC and the SERDES, 0:no-op
  54. */
  55. #define netxen_gb_tx_flowctl(config_word) \
  56. ((config_word) |= 1 << 4)
  57. #define netxen_gb_rx_flowctl(config_word) \
  58. ((config_word) |= 1 << 5)
  59. #define netxen_gb_tx_reset_pb(config_word) \
  60. ((config_word) |= 1 << 16)
  61. #define netxen_gb_rx_reset_pb(config_word) \
  62. ((config_word) |= 1 << 17)
  63. #define netxen_gb_tx_reset_mac(config_word) \
  64. ((config_word) |= 1 << 18)
  65. #define netxen_gb_rx_reset_mac(config_word) \
  66. ((config_word) |= 1 << 19)
  67. #define netxen_gb_unset_tx_flowctl(config_word) \
  68. ((config_word) &= ~(1 << 4))
  69. #define netxen_gb_unset_rx_flowctl(config_word) \
  70. ((config_word) &= ~(1 << 5))
  71. #define netxen_gb_get_tx_synced(config_word) \
  72. _netxen_crb_get_bit((config_word), 1)
  73. #define netxen_gb_get_rx_synced(config_word) \
  74. _netxen_crb_get_bit((config_word), 3)
  75. #define netxen_gb_get_tx_flowctl(config_word) \
  76. _netxen_crb_get_bit((config_word), 4)
  77. #define netxen_gb_get_rx_flowctl(config_word) \
  78. _netxen_crb_get_bit((config_word), 5)
  79. #define netxen_gb_get_soft_reset(config_word) \
  80. _netxen_crb_get_bit((config_word), 31)
  81. #define netxen_gb_get_stationaddress_low(config_word) ((config_word) >> 16)
  82. #define netxen_gb_set_mii_mgmt_clockselect(config_word, val) \
  83. ((config_word) |= ((val) & 0x07))
  84. #define netxen_gb_mii_mgmt_reset(config_word) \
  85. ((config_word) |= 1 << 31)
  86. #define netxen_gb_mii_mgmt_unset(config_word) \
  87. ((config_word) &= ~(1 << 31))
  88. /*
  89. * NIU GB MII Mgmt Command Register (applies to GB0, GB1, GB2, GB3)
  90. * Bit 0 : read_cycle => 1:perform single read cycle, 0:no-op
  91. * Bit 1 : scan_cycle => 1:perform continuous read cycles, 0:no-op
  92. */
  93. #define netxen_gb_mii_mgmt_set_read_cycle(config_word) \
  94. ((config_word) |= 1 << 0)
  95. #define netxen_gb_mii_mgmt_reg_addr(config_word, val) \
  96. ((config_word) |= ((val) & 0x1F))
  97. #define netxen_gb_mii_mgmt_phy_addr(config_word, val) \
  98. ((config_word) |= (((val) & 0x1F) << 8))
  99. /*
  100. * NIU GB MII Mgmt Indicators Register (applies to GB0, GB1, GB2, GB3)
  101. * Read-only register.
  102. * Bit 0 : busy => 1:performing an MII mgmt cycle, 0:idle
  103. * Bit 1 : scanning => 1:scan operation in progress, 0:idle
  104. * Bit 2 : notvalid => :mgmt result data not yet valid, 0:idle
  105. */
  106. #define netxen_get_gb_mii_mgmt_busy(config_word) \
  107. _netxen_crb_get_bit(config_word, 0)
  108. #define netxen_get_gb_mii_mgmt_scanning(config_word) \
  109. _netxen_crb_get_bit(config_word, 1)
  110. #define netxen_get_gb_mii_mgmt_notvalid(config_word) \
  111. _netxen_crb_get_bit(config_word, 2)
  112. /*
  113. * NIU XG Pause Ctl Register
  114. *
  115. * Bit 0 : xg0_mask => 1:disable tx pause frames
  116. * Bit 1 : xg0_request => 1:request single pause frame
  117. * Bit 2 : xg0_on_off => 1:request is pause on, 0:off
  118. * Bit 3 : xg1_mask => 1:disable tx pause frames
  119. * Bit 4 : xg1_request => 1:request single pause frame
  120. * Bit 5 : xg1_on_off => 1:request is pause on, 0:off
  121. */
  122. #define netxen_xg_set_xg0_mask(config_word) \
  123. ((config_word) |= 1 << 0)
  124. #define netxen_xg_set_xg1_mask(config_word) \
  125. ((config_word) |= 1 << 3)
  126. #define netxen_xg_get_xg0_mask(config_word) \
  127. _netxen_crb_get_bit((config_word), 0)
  128. #define netxen_xg_get_xg1_mask(config_word) \
  129. _netxen_crb_get_bit((config_word), 3)
  130. #define netxen_xg_unset_xg0_mask(config_word) \
  131. ((config_word) &= ~(1 << 0))
  132. #define netxen_xg_unset_xg1_mask(config_word) \
  133. ((config_word) &= ~(1 << 3))
  134. /*
  135. * NIU XG Pause Ctl Register
  136. *
  137. * Bit 0 : xg0_mask => 1:disable tx pause frames
  138. * Bit 1 : xg0_request => 1:request single pause frame
  139. * Bit 2 : xg0_on_off => 1:request is pause on, 0:off
  140. * Bit 3 : xg1_mask => 1:disable tx pause frames
  141. * Bit 4 : xg1_request => 1:request single pause frame
  142. * Bit 5 : xg1_on_off => 1:request is pause on, 0:off
  143. */
  144. #define netxen_gb_set_gb0_mask(config_word) \
  145. ((config_word) |= 1 << 0)
  146. #define netxen_gb_set_gb1_mask(config_word) \
  147. ((config_word) |= 1 << 2)
  148. #define netxen_gb_set_gb2_mask(config_word) \
  149. ((config_word) |= 1 << 4)
  150. #define netxen_gb_set_gb3_mask(config_word) \
  151. ((config_word) |= 1 << 6)
  152. #define netxen_gb_get_gb0_mask(config_word) \
  153. _netxen_crb_get_bit((config_word), 0)
  154. #define netxen_gb_get_gb1_mask(config_word) \
  155. _netxen_crb_get_bit((config_word), 2)
  156. #define netxen_gb_get_gb2_mask(config_word) \
  157. _netxen_crb_get_bit((config_word), 4)
  158. #define netxen_gb_get_gb3_mask(config_word) \
  159. _netxen_crb_get_bit((config_word), 6)
  160. #define netxen_gb_unset_gb0_mask(config_word) \
  161. ((config_word) &= ~(1 << 0))
  162. #define netxen_gb_unset_gb1_mask(config_word) \
  163. ((config_word) &= ~(1 << 2))
  164. #define netxen_gb_unset_gb2_mask(config_word) \
  165. ((config_word) &= ~(1 << 4))
  166. #define netxen_gb_unset_gb3_mask(config_word) \
  167. ((config_word) &= ~(1 << 6))
  168. /*
  169. * PHY-Specific MII control/status registers.
  170. */
  171. #define NETXEN_NIU_GB_MII_MGMT_ADDR_CONTROL 0
  172. #define NETXEN_NIU_GB_MII_MGMT_ADDR_STATUS 1
  173. #define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_ID_0 2
  174. #define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_ID_1 3
  175. #define NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG 4
  176. #define NETXEN_NIU_GB_MII_MGMT_ADDR_LNKPART 5
  177. #define NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG_MORE 6
  178. #define NETXEN_NIU_GB_MII_MGMT_ADDR_NEXTPAGE_XMIT 7
  179. #define NETXEN_NIU_GB_MII_MGMT_ADDR_LNKPART_NEXTPAGE 8
  180. #define NETXEN_NIU_GB_MII_MGMT_ADDR_1000BT_CONTROL 9
  181. #define NETXEN_NIU_GB_MII_MGMT_ADDR_1000BT_STATUS 10
  182. #define NETXEN_NIU_GB_MII_MGMT_ADDR_EXTENDED_STATUS 15
  183. #define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_CONTROL 16
  184. #define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS 17
  185. #define NETXEN_NIU_GB_MII_MGMT_ADDR_INT_ENABLE 18
  186. #define NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS 19
  187. #define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_CONTROL_MORE 20
  188. #define NETXEN_NIU_GB_MII_MGMT_ADDR_RECV_ERROR_COUNT 21
  189. #define NETXEN_NIU_GB_MII_MGMT_ADDR_LED_CONTROL 24
  190. #define NETXEN_NIU_GB_MII_MGMT_ADDR_LED_OVERRIDE 25
  191. #define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_CONTROL_MORE_YET 26
  192. #define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS_MORE 27
  193. /*
  194. * PHY-Specific Status Register (reg 17).
  195. *
  196. * Bit 0 : jabber => 1:jabber detected, 0:not
  197. * Bit 1 : polarity => 1:polarity reversed, 0:normal
  198. * Bit 2 : recvpause => 1:receive pause enabled, 0:disabled
  199. * Bit 3 : xmitpause => 1:transmit pause enabled, 0:disabled
  200. * Bit 4 : energydetect => 1:sleep, 0:active
  201. * Bit 5 : downshift => 1:downshift, 0:no downshift
  202. * Bit 6 : crossover => 1:MDIX (crossover), 0:MDI (no crossover)
  203. * Bits 7-9 : cablelen => not valid in 10Mb/s mode
  204. * 0:<50m, 1:50-80m, 2:80-110m, 3:110-140m, 4:>140m
  205. * Bit 10 : link => 1:link up, 0:link down
  206. * Bit 11 : resolved => 1:speed and duplex resolved, 0:not yet
  207. * Bit 12 : pagercvd => 1:page received, 0:page not received
  208. * Bit 13 : duplex => 1:full duplex, 0:half duplex
  209. * Bits 14-15 : speed => 0:10Mb/s, 1:100Mb/s, 2:1000Mb/s, 3:rsvd
  210. */
  211. #define netxen_get_phy_speed(config_word) (((config_word) >> 14) & 0x03)
  212. #define netxen_set_phy_speed(config_word, val) \
  213. ((config_word) |= ((val & 0x03) << 14))
  214. #define netxen_set_phy_duplex(config_word) \
  215. ((config_word) |= 1 << 13)
  216. #define netxen_clear_phy_duplex(config_word) \
  217. ((config_word) &= ~(1 << 13))
  218. #define netxen_get_phy_link(config_word) \
  219. _netxen_crb_get_bit(config_word, 10)
  220. #define netxen_get_phy_duplex(config_word) \
  221. _netxen_crb_get_bit(config_word, 13)
  222. /*
  223. * NIU Mode Register.
  224. * Bit 0 : enable FibreChannel
  225. * Bit 1 : enable 10/100/1000 Ethernet
  226. * Bit 2 : enable 10Gb Ethernet
  227. */
  228. #define netxen_get_niu_enable_ge(config_word) \
  229. _netxen_crb_get_bit(config_word, 1)
  230. #define NETXEN_NIU_NON_PROMISC_MODE 0
  231. #define NETXEN_NIU_PROMISC_MODE 1
  232. #define NETXEN_NIU_ALLMULTI_MODE 2
  233. /*
  234. * NIU XG MAC Config Register
  235. *
  236. * Bit 0 : tx_enable => 1:enable frame xmit, 0:disable
  237. * Bit 2 : rx_enable => 1:enable frame recv, 0:disable
  238. * Bit 4 : soft_reset => 1:reset the MAC , 0:no-op
  239. * Bit 27: xaui_framer_reset
  240. * Bit 28: xaui_rx_reset
  241. * Bit 29: xaui_tx_reset
  242. * Bit 30: xg_ingress_afifo_reset
  243. * Bit 31: xg_egress_afifo_reset
  244. */
  245. #define netxen_xg_soft_reset(config_word) \
  246. ((config_word) |= 1 << 4)
  247. typedef struct {
  248. unsigned valid;
  249. unsigned start_128M;
  250. unsigned end_128M;
  251. unsigned start_2M;
  252. } crb_128M_2M_sub_block_map_t;
  253. typedef struct {
  254. crb_128M_2M_sub_block_map_t sub_block[16];
  255. } crb_128M_2M_block_map_t;
  256. #endif /* __NETXEN_NIC_HW_H_ */