netxen_nic_hw.h 10 KB

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