netxen_nic_hw.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  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. #include "netxen_nic_hdr.h"
  33. /* Hardware memory size of 128 meg */
  34. #define NETXEN_MEMADDR_MAX (128 * 1024 * 1024)
  35. struct netxen_adapter;
  36. #define NETXEN_PCI_MAPSIZE_BYTES (NETXEN_PCI_MAPSIZE << 20)
  37. void netxen_nic_set_link_parameters(struct netxen_adapter *adapter);
  38. /* Nibble or Byte mode for phy interface (GbE mode only) */
  39. #define _netxen_crb_get_bit(var, bit) ((var >> bit) & 0x1)
  40. /*
  41. * NIU GB MAC Config Register 0 (applies to GB0, GB1, GB2, GB3)
  42. *
  43. * Bit 0 : enable_tx => 1:enable frame xmit, 0:disable
  44. * Bit 1 : tx_synced => R/O: xmit enable synched to xmit stream
  45. * Bit 2 : enable_rx => 1:enable frame recv, 0:disable
  46. * Bit 3 : rx_synced => R/O: recv enable synched to recv stream
  47. * Bit 4 : tx_flowctl => 1:enable pause frame generation, 0:disable
  48. * Bit 5 : rx_flowctl => 1:act on recv'd pause frames, 0:ignore
  49. * Bit 8 : loopback => 1:loop MAC xmits to MAC recvs, 0:normal
  50. * Bit 16: tx_reset_pb => 1:reset frame xmit protocol blk, 0:no-op
  51. * Bit 17: rx_reset_pb => 1:reset frame recv protocol blk, 0:no-op
  52. * Bit 18: tx_reset_mac => 1:reset data/ctl multiplexer blk, 0:no-op
  53. * Bit 19: rx_reset_mac => 1:reset ctl frames & timers blk, 0:no-op
  54. * Bit 31: soft_reset => 1:reset the MAC and the SERDES, 0:no-op
  55. */
  56. #define netxen_gb_enable_tx(config_word) \
  57. ((config_word) |= 1 << 0)
  58. #define netxen_gb_enable_rx(config_word) \
  59. ((config_word) |= 1 << 2)
  60. #define netxen_gb_tx_flowctl(config_word) \
  61. ((config_word) |= 1 << 4)
  62. #define netxen_gb_rx_flowctl(config_word) \
  63. ((config_word) |= 1 << 5)
  64. #define netxen_gb_tx_reset_pb(config_word) \
  65. ((config_word) |= 1 << 16)
  66. #define netxen_gb_rx_reset_pb(config_word) \
  67. ((config_word) |= 1 << 17)
  68. #define netxen_gb_tx_reset_mac(config_word) \
  69. ((config_word) |= 1 << 18)
  70. #define netxen_gb_rx_reset_mac(config_word) \
  71. ((config_word) |= 1 << 19)
  72. #define netxen_gb_soft_reset(config_word) \
  73. ((config_word) |= 1 << 31)
  74. #define netxen_gb_unset_tx_flowctl(config_word) \
  75. ((config_word) &= ~(1 << 4))
  76. #define netxen_gb_unset_rx_flowctl(config_word) \
  77. ((config_word) &= ~(1 << 5))
  78. #define netxen_gb_get_tx_synced(config_word) \
  79. _netxen_crb_get_bit((config_word), 1)
  80. #define netxen_gb_get_rx_synced(config_word) \
  81. _netxen_crb_get_bit((config_word), 3)
  82. #define netxen_gb_get_tx_flowctl(config_word) \
  83. _netxen_crb_get_bit((config_word), 4)
  84. #define netxen_gb_get_rx_flowctl(config_word) \
  85. _netxen_crb_get_bit((config_word), 5)
  86. #define netxen_gb_get_soft_reset(config_word) \
  87. _netxen_crb_get_bit((config_word), 31)
  88. #define netxen_gb_get_stationaddress_low(config_word) ((config_word) >> 16)
  89. #define netxen_gb_set_mii_mgmt_clockselect(config_word, val) \
  90. ((config_word) |= ((val) & 0x07))
  91. #define netxen_gb_mii_mgmt_reset(config_word) \
  92. ((config_word) |= 1 << 31)
  93. #define netxen_gb_mii_mgmt_unset(config_word) \
  94. ((config_word) &= ~(1 << 31))
  95. /*
  96. * NIU GB MII Mgmt Command Register (applies to GB0, GB1, GB2, GB3)
  97. * Bit 0 : read_cycle => 1:perform single read cycle, 0:no-op
  98. * Bit 1 : scan_cycle => 1:perform continuous read cycles, 0:no-op
  99. */
  100. #define netxen_gb_mii_mgmt_set_read_cycle(config_word) \
  101. ((config_word) |= 1 << 0)
  102. #define netxen_gb_mii_mgmt_reg_addr(config_word, val) \
  103. ((config_word) |= ((val) & 0x1F))
  104. #define netxen_gb_mii_mgmt_phy_addr(config_word, val) \
  105. ((config_word) |= (((val) & 0x1F) << 8))
  106. /*
  107. * NIU GB MII Mgmt Indicators Register (applies to GB0, GB1, GB2, GB3)
  108. * Read-only register.
  109. * Bit 0 : busy => 1:performing an MII mgmt cycle, 0:idle
  110. * Bit 1 : scanning => 1:scan operation in progress, 0:idle
  111. * Bit 2 : notvalid => :mgmt result data not yet valid, 0:idle
  112. */
  113. #define netxen_get_gb_mii_mgmt_busy(config_word) \
  114. _netxen_crb_get_bit(config_word, 0)
  115. #define netxen_get_gb_mii_mgmt_scanning(config_word) \
  116. _netxen_crb_get_bit(config_word, 1)
  117. #define netxen_get_gb_mii_mgmt_notvalid(config_word) \
  118. _netxen_crb_get_bit(config_word, 2)
  119. /*
  120. * NIU XG Pause Ctl Register
  121. *
  122. * Bit 0 : xg0_mask => 1:disable tx pause frames
  123. * Bit 1 : xg0_request => 1:request single pause frame
  124. * Bit 2 : xg0_on_off => 1:request is pause on, 0:off
  125. * Bit 3 : xg1_mask => 1:disable tx pause frames
  126. * Bit 4 : xg1_request => 1:request single pause frame
  127. * Bit 5 : xg1_on_off => 1:request is pause on, 0:off
  128. */
  129. #define netxen_xg_set_xg0_mask(config_word) \
  130. ((config_word) |= 1 << 0)
  131. #define netxen_xg_set_xg1_mask(config_word) \
  132. ((config_word) |= 1 << 3)
  133. #define netxen_xg_get_xg0_mask(config_word) \
  134. _netxen_crb_get_bit((config_word), 0)
  135. #define netxen_xg_get_xg1_mask(config_word) \
  136. _netxen_crb_get_bit((config_word), 3)
  137. #define netxen_xg_unset_xg0_mask(config_word) \
  138. ((config_word) &= ~(1 << 0))
  139. #define netxen_xg_unset_xg1_mask(config_word) \
  140. ((config_word) &= ~(1 << 3))
  141. /*
  142. * NIU XG Pause Ctl Register
  143. *
  144. * Bit 0 : xg0_mask => 1:disable tx pause frames
  145. * Bit 1 : xg0_request => 1:request single pause frame
  146. * Bit 2 : xg0_on_off => 1:request is pause on, 0:off
  147. * Bit 3 : xg1_mask => 1:disable tx pause frames
  148. * Bit 4 : xg1_request => 1:request single pause frame
  149. * Bit 5 : xg1_on_off => 1:request is pause on, 0:off
  150. */
  151. #define netxen_gb_set_gb0_mask(config_word) \
  152. ((config_word) |= 1 << 0)
  153. #define netxen_gb_set_gb1_mask(config_word) \
  154. ((config_word) |= 1 << 2)
  155. #define netxen_gb_set_gb2_mask(config_word) \
  156. ((config_word) |= 1 << 4)
  157. #define netxen_gb_set_gb3_mask(config_word) \
  158. ((config_word) |= 1 << 6)
  159. #define netxen_gb_get_gb0_mask(config_word) \
  160. _netxen_crb_get_bit((config_word), 0)
  161. #define netxen_gb_get_gb1_mask(config_word) \
  162. _netxen_crb_get_bit((config_word), 2)
  163. #define netxen_gb_get_gb2_mask(config_word) \
  164. _netxen_crb_get_bit((config_word), 4)
  165. #define netxen_gb_get_gb3_mask(config_word) \
  166. _netxen_crb_get_bit((config_word), 6)
  167. #define netxen_gb_unset_gb0_mask(config_word) \
  168. ((config_word) &= ~(1 << 0))
  169. #define netxen_gb_unset_gb1_mask(config_word) \
  170. ((config_word) &= ~(1 << 2))
  171. #define netxen_gb_unset_gb2_mask(config_word) \
  172. ((config_word) &= ~(1 << 4))
  173. #define netxen_gb_unset_gb3_mask(config_word) \
  174. ((config_word) &= ~(1 << 6))
  175. /*
  176. * PHY-Specific MII control/status registers.
  177. */
  178. #define NETXEN_NIU_GB_MII_MGMT_ADDR_CONTROL 0
  179. #define NETXEN_NIU_GB_MII_MGMT_ADDR_STATUS 1
  180. #define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_ID_0 2
  181. #define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_ID_1 3
  182. #define NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG 4
  183. #define NETXEN_NIU_GB_MII_MGMT_ADDR_LNKPART 5
  184. #define NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG_MORE 6
  185. #define NETXEN_NIU_GB_MII_MGMT_ADDR_NEXTPAGE_XMIT 7
  186. #define NETXEN_NIU_GB_MII_MGMT_ADDR_LNKPART_NEXTPAGE 8
  187. #define NETXEN_NIU_GB_MII_MGMT_ADDR_1000BT_CONTROL 9
  188. #define NETXEN_NIU_GB_MII_MGMT_ADDR_1000BT_STATUS 10
  189. #define NETXEN_NIU_GB_MII_MGMT_ADDR_EXTENDED_STATUS 15
  190. #define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_CONTROL 16
  191. #define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS 17
  192. #define NETXEN_NIU_GB_MII_MGMT_ADDR_INT_ENABLE 18
  193. #define NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS 19
  194. #define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_CONTROL_MORE 20
  195. #define NETXEN_NIU_GB_MII_MGMT_ADDR_RECV_ERROR_COUNT 21
  196. #define NETXEN_NIU_GB_MII_MGMT_ADDR_LED_CONTROL 24
  197. #define NETXEN_NIU_GB_MII_MGMT_ADDR_LED_OVERRIDE 25
  198. #define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_CONTROL_MORE_YET 26
  199. #define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS_MORE 27
  200. /*
  201. * PHY-Specific Status Register (reg 17).
  202. *
  203. * Bit 0 : jabber => 1:jabber detected, 0:not
  204. * Bit 1 : polarity => 1:polarity reversed, 0:normal
  205. * Bit 2 : recvpause => 1:receive pause enabled, 0:disabled
  206. * Bit 3 : xmitpause => 1:transmit pause enabled, 0:disabled
  207. * Bit 4 : energydetect => 1:sleep, 0:active
  208. * Bit 5 : downshift => 1:downshift, 0:no downshift
  209. * Bit 6 : crossover => 1:MDIX (crossover), 0:MDI (no crossover)
  210. * Bits 7-9 : cablelen => not valid in 10Mb/s mode
  211. * 0:<50m, 1:50-80m, 2:80-110m, 3:110-140m, 4:>140m
  212. * Bit 10 : link => 1:link up, 0:link down
  213. * Bit 11 : resolved => 1:speed and duplex resolved, 0:not yet
  214. * Bit 12 : pagercvd => 1:page received, 0:page not received
  215. * Bit 13 : duplex => 1:full duplex, 0:half duplex
  216. * Bits 14-15 : speed => 0:10Mb/s, 1:100Mb/s, 2:1000Mb/s, 3:rsvd
  217. */
  218. #define netxen_get_phy_cablelen(config_word) (((config_word) >> 7) & 0x07)
  219. #define netxen_get_phy_speed(config_word) (((config_word) >> 14) & 0x03)
  220. #define netxen_set_phy_speed(config_word, val) \
  221. ((config_word) |= ((val & 0x03) << 14))
  222. #define netxen_set_phy_duplex(config_word) \
  223. ((config_word) |= 1 << 13)
  224. #define netxen_clear_phy_duplex(config_word) \
  225. ((config_word) &= ~(1 << 13))
  226. #define netxen_get_phy_jabber(config_word) \
  227. _netxen_crb_get_bit(config_word, 0)
  228. #define netxen_get_phy_polarity(config_word) \
  229. _netxen_crb_get_bit(config_word, 1)
  230. #define netxen_get_phy_recvpause(config_word) \
  231. _netxen_crb_get_bit(config_word, 2)
  232. #define netxen_get_phy_xmitpause(config_word) \
  233. _netxen_crb_get_bit(config_word, 3)
  234. #define netxen_get_phy_energydetect(config_word) \
  235. _netxen_crb_get_bit(config_word, 4)
  236. #define netxen_get_phy_downshift(config_word) \
  237. _netxen_crb_get_bit(config_word, 5)
  238. #define netxen_get_phy_crossover(config_word) \
  239. _netxen_crb_get_bit(config_word, 6)
  240. #define netxen_get_phy_link(config_word) \
  241. _netxen_crb_get_bit(config_word, 10)
  242. #define netxen_get_phy_resolved(config_word) \
  243. _netxen_crb_get_bit(config_word, 11)
  244. #define netxen_get_phy_pagercvd(config_word) \
  245. _netxen_crb_get_bit(config_word, 12)
  246. #define netxen_get_phy_duplex(config_word) \
  247. _netxen_crb_get_bit(config_word, 13)
  248. /*
  249. * Interrupt Register definition
  250. * This definition applies to registers 18 and 19 (int enable and int status).
  251. * Bit 0 : jabber
  252. * Bit 1 : polarity_changed
  253. * Bit 4 : energy_detect
  254. * Bit 5 : downshift
  255. * Bit 6 : mdi_xover_changed
  256. * Bit 7 : fifo_over_underflow
  257. * Bit 8 : false_carrier
  258. * Bit 9 : symbol_error
  259. * Bit 10: link_status_changed
  260. * Bit 11: autoneg_completed
  261. * Bit 12: page_received
  262. * Bit 13: duplex_changed
  263. * Bit 14: speed_changed
  264. * Bit 15: autoneg_error
  265. */
  266. #define netxen_get_phy_int_jabber(config_word) \
  267. _netxen_crb_get_bit(config_word, 0)
  268. #define netxen_get_phy_int_polarity_changed(config_word) \
  269. _netxen_crb_get_bit(config_word, 1)
  270. #define netxen_get_phy_int_energy_detect(config_word) \
  271. _netxen_crb_get_bit(config_word, 4)
  272. #define netxen_get_phy_int_downshift(config_word) \
  273. _netxen_crb_get_bit(config_word, 5)
  274. #define netxen_get_phy_int_mdi_xover_changed(config_word) \
  275. _netxen_crb_get_bit(config_word, 6)
  276. #define netxen_get_phy_int_fifo_over_underflow(config_word) \
  277. _netxen_crb_get_bit(config_word, 7)
  278. #define netxen_get_phy_int_false_carrier(config_word) \
  279. _netxen_crb_get_bit(config_word, 8)
  280. #define netxen_get_phy_int_symbol_error(config_word) \
  281. _netxen_crb_get_bit(config_word, 9)
  282. #define netxen_get_phy_int_link_status_changed(config_word) \
  283. _netxen_crb_get_bit(config_word, 10)
  284. #define netxen_get_phy_int_autoneg_completed(config_word) \
  285. _netxen_crb_get_bit(config_word, 11)
  286. #define netxen_get_phy_int_page_received(config_word) \
  287. _netxen_crb_get_bit(config_word, 12)
  288. #define netxen_get_phy_int_duplex_changed(config_word) \
  289. _netxen_crb_get_bit(config_word, 13)
  290. #define netxen_get_phy_int_speed_changed(config_word) \
  291. _netxen_crb_get_bit(config_word, 14)
  292. #define netxen_get_phy_int_autoneg_error(config_word) \
  293. _netxen_crb_get_bit(config_word, 15)
  294. #define netxen_set_phy_int_link_status_changed(config_word) \
  295. ((config_word) |= 1 << 10)
  296. #define netxen_set_phy_int_autoneg_completed(config_word) \
  297. ((config_word) |= 1 << 11)
  298. #define netxen_set_phy_int_speed_changed(config_word) \
  299. ((config_word) |= 1 << 14)
  300. /*
  301. * NIU Mode Register.
  302. * Bit 0 : enable FibreChannel
  303. * Bit 1 : enable 10/100/1000 Ethernet
  304. * Bit 2 : enable 10Gb Ethernet
  305. */
  306. #define netxen_get_niu_enable_ge(config_word) \
  307. _netxen_crb_get_bit(config_word, 1)
  308. #define NETXEN_NIU_NON_PROMISC_MODE 0
  309. #define NETXEN_NIU_PROMISC_MODE 1
  310. #define NETXEN_NIU_ALLMULTI_MODE 2
  311. /*
  312. * NIU GB Drop CRC Register
  313. *
  314. * Bit 0 : drop_gb0 => 1:drop pkts with bad CRCs, 0:pass them on
  315. * Bit 1 : drop_gb1 => 1:drop pkts with bad CRCs, 0:pass them on
  316. * Bit 2 : drop_gb2 => 1:drop pkts with bad CRCs, 0:pass them on
  317. * Bit 3 : drop_gb3 => 1:drop pkts with bad CRCs, 0:pass them on
  318. */
  319. #define netxen_set_gb_drop_gb0(config_word) \
  320. ((config_word) |= 1 << 0)
  321. #define netxen_set_gb_drop_gb1(config_word) \
  322. ((config_word) |= 1 << 1)
  323. #define netxen_set_gb_drop_gb2(config_word) \
  324. ((config_word) |= 1 << 2)
  325. #define netxen_set_gb_drop_gb3(config_word) \
  326. ((config_word) |= 1 << 3)
  327. #define netxen_clear_gb_drop_gb0(config_word) \
  328. ((config_word) &= ~(1 << 0))
  329. #define netxen_clear_gb_drop_gb1(config_word) \
  330. ((config_word) &= ~(1 << 1))
  331. #define netxen_clear_gb_drop_gb2(config_word) \
  332. ((config_word) &= ~(1 << 2))
  333. #define netxen_clear_gb_drop_gb3(config_word) \
  334. ((config_word) &= ~(1 << 3))
  335. /*
  336. * NIU XG MAC Config Register
  337. *
  338. * Bit 0 : tx_enable => 1:enable frame xmit, 0:disable
  339. * Bit 2 : rx_enable => 1:enable frame recv, 0:disable
  340. * Bit 4 : soft_reset => 1:reset the MAC , 0:no-op
  341. * Bit 27: xaui_framer_reset
  342. * Bit 28: xaui_rx_reset
  343. * Bit 29: xaui_tx_reset
  344. * Bit 30: xg_ingress_afifo_reset
  345. * Bit 31: xg_egress_afifo_reset
  346. */
  347. #define netxen_xg_soft_reset(config_word) \
  348. ((config_word) |= 1 << 4)
  349. /* Set promiscuous mode for a GbE interface */
  350. int netxen_niu_set_promiscuous_mode(struct netxen_adapter *adapter,
  351. u32 mode);
  352. int netxen_niu_xg_set_promiscuous_mode(struct netxen_adapter *adapter,
  353. u32 mode);
  354. /* Generic enable for GbE ports. Will detect the speed of the link. */
  355. int netxen_niu_gbe_init_port(struct netxen_adapter *adapter, int port);
  356. int netxen_niu_xg_init_port(struct netxen_adapter *adapter, int port);
  357. /* Disable a GbE interface */
  358. int netxen_niu_disable_gbe_port(struct netxen_adapter *adapter);
  359. int netxen_niu_disable_xg_port(struct netxen_adapter *adapter);
  360. typedef struct {
  361. unsigned valid;
  362. unsigned start_128M;
  363. unsigned end_128M;
  364. unsigned start_2M;
  365. } crb_128M_2M_sub_block_map_t;
  366. typedef struct {
  367. crb_128M_2M_sub_block_map_t sub_block[16];
  368. } crb_128M_2M_block_map_t;
  369. #endif /* __NETXEN_NIC_HW_H_ */