netxen_nic_hw.h 9.5 KB

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