netxen_nic_hw.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. /*
  2. * Copyright (C) 2003 - 2006 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,
  26. * 3965 Freedom Circle, Fourth floor,
  27. * Santa Clara, CA 95054
  28. *
  29. *
  30. * Structures, enums, and macros for the MAC
  31. *
  32. */
  33. #ifndef __NETXEN_NIC_HW_H_
  34. #define __NETXEN_NIC_HW_H_
  35. #include "netxen_nic_hdr.h"
  36. /* Hardware memory size of 128 meg */
  37. #define NETXEN_MEMADDR_MAX (128 * 1024 * 1024)
  38. #ifndef readq
  39. static inline u64 readq(void __iomem * addr)
  40. {
  41. return readl(addr) | (((u64) readl(addr + 4)) << 32LL);
  42. }
  43. #endif
  44. #ifndef writeq
  45. static inline void writeq(u64 val, void __iomem * addr)
  46. {
  47. writel(((u32) (val)), (addr));
  48. writel(((u32) (val >> 32)), (addr + 4));
  49. }
  50. #endif
  51. static inline void netxen_nic_hw_block_write64(u64 __iomem * data_ptr,
  52. u64 __iomem * addr,
  53. int num_words)
  54. {
  55. int num;
  56. for (num = 0; num < num_words; num++) {
  57. writeq(readq((void __iomem *)data_ptr), addr);
  58. addr++;
  59. data_ptr++;
  60. }
  61. }
  62. static inline void netxen_nic_hw_block_read64(u64 __iomem * data_ptr,
  63. u64 __iomem * addr, int num_words)
  64. {
  65. int num;
  66. for (num = 0; num < num_words; num++) {
  67. writeq(readq((void __iomem *)addr), data_ptr);
  68. addr++;
  69. data_ptr++;
  70. }
  71. }
  72. struct netxen_adapter;
  73. #define NETXEN_PCI_MAPSIZE_BYTES (NETXEN_PCI_MAPSIZE << 20)
  74. #define NETXEN_NIC_LOCKED_READ_REG(X, Y) \
  75. addr = pci_base_offset(adapter, X); \
  76. *(u32 *)Y = readl((void __iomem*) addr);
  77. struct netxen_port;
  78. void netxen_nic_set_link_parameters(struct netxen_adapter *adapter);
  79. void netxen_nic_flash_print(struct netxen_adapter *adapter);
  80. int netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off,
  81. void *data, int len);
  82. void netxen_crb_writelit_adapter(struct netxen_adapter *adapter,
  83. unsigned long off, int data);
  84. int netxen_nic_hw_read_wx(struct netxen_adapter *adapter, u64 off,
  85. void *data, int len);
  86. typedef u8 netxen_ethernet_macaddr_t[6];
  87. /* Nibble or Byte mode for phy interface (GbE mode only) */
  88. typedef enum {
  89. NETXEN_NIU_10_100_MB = 0,
  90. NETXEN_NIU_1000_MB
  91. } netxen_niu_gbe_ifmode_t;
  92. #define _netxen_crb_get_bit(var, bit) ((var >> bit) & 0x1)
  93. /*
  94. * NIU GB MAC Config Register 0 (applies to GB0, GB1, GB2, GB3)
  95. *
  96. * Bit 0 : enable_tx => 1:enable frame xmit, 0:disable
  97. * Bit 1 : tx_synced => R/O: xmit enable synched to xmit stream
  98. * Bit 2 : enable_rx => 1:enable frame recv, 0:disable
  99. * Bit 3 : rx_synced => R/O: recv enable synched to recv stream
  100. * Bit 4 : tx_flowctl => 1:enable pause frame generation, 0:disable
  101. * Bit 5 : rx_flowctl => 1:act on recv'd pause frames, 0:ignore
  102. * Bit 8 : loopback => 1:loop MAC xmits to MAC recvs, 0:normal
  103. * Bit 16: tx_reset_pb => 1:reset frame xmit protocol blk, 0:no-op
  104. * Bit 17: rx_reset_pb => 1:reset frame recv protocol blk, 0:no-op
  105. * Bit 18: tx_reset_mac => 1:reset data/ctl multiplexer blk, 0:no-op
  106. * Bit 19: rx_reset_mac => 1:reset ctl frames & timers blk, 0:no-op
  107. * Bit 31: soft_reset => 1:reset the MAC and the SERDES, 0:no-op
  108. */
  109. #define netxen_gb_enable_tx(config_word) \
  110. ((config_word) |= 1 << 0)
  111. #define netxen_gb_enable_rx(config_word) \
  112. ((config_word) |= 1 << 2)
  113. #define netxen_gb_tx_flowctl(config_word) \
  114. ((config_word) |= 1 << 4)
  115. #define netxen_gb_rx_flowctl(config_word) \
  116. ((config_word) |= 1 << 5)
  117. #define netxen_gb_tx_reset_pb(config_word) \
  118. ((config_word) |= 1 << 16)
  119. #define netxen_gb_rx_reset_pb(config_word) \
  120. ((config_word) |= 1 << 17)
  121. #define netxen_gb_tx_reset_mac(config_word) \
  122. ((config_word) |= 1 << 18)
  123. #define netxen_gb_rx_reset_mac(config_word) \
  124. ((config_word) |= 1 << 19)
  125. #define netxen_gb_soft_reset(config_word) \
  126. ((config_word) |= 1 << 31)
  127. #define netxen_gb_unset_tx_flowctl(config_word) \
  128. ((config_word) &= ~(1 << 4))
  129. #define netxen_gb_unset_rx_flowctl(config_word) \
  130. ((config_word) &= ~(1 << 5))
  131. #define netxen_gb_get_tx_synced(config_word) \
  132. _netxen_crb_get_bit((config_word), 1)
  133. #define netxen_gb_get_rx_synced(config_word) \
  134. _netxen_crb_get_bit((config_word), 3)
  135. #define netxen_gb_get_tx_flowctl(config_word) \
  136. _netxen_crb_get_bit((config_word), 4)
  137. #define netxen_gb_get_rx_flowctl(config_word) \
  138. _netxen_crb_get_bit((config_word), 5)
  139. #define netxen_gb_get_soft_reset(config_word) \
  140. _netxen_crb_get_bit((config_word), 31)
  141. /*
  142. * NIU GB MAC Config Register 1 (applies to GB0, GB1, GB2, GB3)
  143. *
  144. * Bit 0 : duplex => 1:full duplex mode, 0:half duplex
  145. * Bit 1 : crc_enable => 1:append CRC to xmit frames, 0:dont append
  146. * Bit 2 : padshort => 1:pad short frames and add CRC, 0:dont pad
  147. * Bit 4 : checklength => 1:check framelen with actual,0:dont check
  148. * Bit 5 : hugeframes => 1:allow oversize xmit frames, 0:dont allow
  149. * Bits 8-9 : intfmode => 01:nibble (10/100), 10:byte (1000)
  150. * Bits 12-15 : preamblelen => preamble field length in bytes, default 7
  151. */
  152. #define netxen_gb_set_duplex(config_word) \
  153. ((config_word) |= 1 << 0)
  154. #define netxen_gb_set_crc_enable(config_word) \
  155. ((config_word) |= 1 << 1)
  156. #define netxen_gb_set_padshort(config_word) \
  157. ((config_word) |= 1 << 2)
  158. #define netxen_gb_set_checklength(config_word) \
  159. ((config_word) |= 1 << 4)
  160. #define netxen_gb_set_hugeframes(config_word) \
  161. ((config_word) |= 1 << 5)
  162. #define netxen_gb_set_preamblelen(config_word, val) \
  163. ((config_word) |= ((val) << 12) & 0xF000)
  164. #define netxen_gb_set_intfmode(config_word, val) \
  165. ((config_word) |= ((val) << 8) & 0x300)
  166. #define netxen_gb_get_stationaddress_low(config_word) ((config_word) >> 16)
  167. #define netxen_gb_set_mii_mgmt_clockselect(config_word, val) \
  168. ((config_word) |= ((val) & 0x07))
  169. #define netxen_gb_mii_mgmt_reset(config_word) \
  170. ((config_word) |= 1 << 31)
  171. #define netxen_gb_mii_mgmt_unset(config_word) \
  172. ((config_word) &= ~(1 << 31))
  173. /*
  174. * NIU GB MII Mgmt Command Register (applies to GB0, GB1, GB2, GB3)
  175. * Bit 0 : read_cycle => 1:perform single read cycle, 0:no-op
  176. * Bit 1 : scan_cycle => 1:perform continuous read cycles, 0:no-op
  177. */
  178. #define netxen_gb_mii_mgmt_set_read_cycle(config_word) \
  179. ((config_word) |= 1 << 0)
  180. #define netxen_gb_mii_mgmt_reg_addr(config_word, val) \
  181. ((config_word) |= ((val) & 0x1F))
  182. #define netxen_gb_mii_mgmt_phy_addr(config_word, val) \
  183. ((config_word) |= (((val) & 0x1F) << 8))
  184. /*
  185. * NIU GB MII Mgmt Indicators Register (applies to GB0, GB1, GB2, GB3)
  186. * Read-only register.
  187. * Bit 0 : busy => 1:performing an MII mgmt cycle, 0:idle
  188. * Bit 1 : scanning => 1:scan operation in progress, 0:idle
  189. * Bit 2 : notvalid => :mgmt result data not yet valid, 0:idle
  190. */
  191. #define netxen_get_gb_mii_mgmt_busy(config_word) \
  192. _netxen_crb_get_bit(config_word, 0)
  193. #define netxen_get_gb_mii_mgmt_scanning(config_word) \
  194. _netxen_crb_get_bit(config_word, 1)
  195. #define netxen_get_gb_mii_mgmt_notvalid(config_word) \
  196. _netxen_crb_get_bit(config_word, 2)
  197. /*
  198. * NIU XG Pause Ctl Register
  199. *
  200. * Bit 0 : xg0_mask => 1:disable tx pause frames
  201. * Bit 1 : xg0_request => 1:request single pause frame
  202. * Bit 2 : xg0_on_off => 1:request is pause on, 0:off
  203. * Bit 3 : xg1_mask => 1:disable tx pause frames
  204. * Bit 4 : xg1_request => 1:request single pause frame
  205. * Bit 5 : xg1_on_off => 1:request is pause on, 0:off
  206. */
  207. #define netxen_xg_set_xg0_mask(config_word) \
  208. ((config_word) |= 1 << 0)
  209. #define netxen_xg_set_xg1_mask(config_word) \
  210. ((config_word) |= 1 << 3)
  211. #define netxen_xg_get_xg0_mask(config_word) \
  212. _netxen_crb_get_bit((config_word), 0)
  213. #define netxen_xg_get_xg1_mask(config_word) \
  214. _netxen_crb_get_bit((config_word), 3)
  215. #define netxen_xg_unset_xg0_mask(config_word) \
  216. ((config_word) &= ~(1 << 0))
  217. #define netxen_xg_unset_xg1_mask(config_word) \
  218. ((config_word) &= ~(1 << 3))
  219. /*
  220. * NIU XG Pause Ctl Register
  221. *
  222. * Bit 0 : xg0_mask => 1:disable tx pause frames
  223. * Bit 1 : xg0_request => 1:request single pause frame
  224. * Bit 2 : xg0_on_off => 1:request is pause on, 0:off
  225. * Bit 3 : xg1_mask => 1:disable tx pause frames
  226. * Bit 4 : xg1_request => 1:request single pause frame
  227. * Bit 5 : xg1_on_off => 1:request is pause on, 0:off
  228. */
  229. #define netxen_gb_set_gb0_mask(config_word) \
  230. ((config_word) |= 1 << 0)
  231. #define netxen_gb_set_gb1_mask(config_word) \
  232. ((config_word) |= 1 << 2)
  233. #define netxen_gb_set_gb2_mask(config_word) \
  234. ((config_word) |= 1 << 4)
  235. #define netxen_gb_set_gb3_mask(config_word) \
  236. ((config_word) |= 1 << 6)
  237. #define netxen_gb_get_gb0_mask(config_word) \
  238. _netxen_crb_get_bit((config_word), 0)
  239. #define netxen_gb_get_gb1_mask(config_word) \
  240. _netxen_crb_get_bit((config_word), 2)
  241. #define netxen_gb_get_gb2_mask(config_word) \
  242. _netxen_crb_get_bit((config_word), 4)
  243. #define netxen_gb_get_gb3_mask(config_word) \
  244. _netxen_crb_get_bit((config_word), 6)
  245. #define netxen_gb_unset_gb0_mask(config_word) \
  246. ((config_word) &= ~(1 << 0))
  247. #define netxen_gb_unset_gb1_mask(config_word) \
  248. ((config_word) &= ~(1 << 2))
  249. #define netxen_gb_unset_gb2_mask(config_word) \
  250. ((config_word) &= ~(1 << 4))
  251. #define netxen_gb_unset_gb3_mask(config_word) \
  252. ((config_word) &= ~(1 << 6))
  253. /*
  254. * PHY-Specific MII control/status registers.
  255. */
  256. typedef enum {
  257. NETXEN_NIU_GB_MII_MGMT_ADDR_CONTROL = 0,
  258. NETXEN_NIU_GB_MII_MGMT_ADDR_STATUS = 1,
  259. NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_ID_0 = 2,
  260. NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_ID_1 = 3,
  261. NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG = 4,
  262. NETXEN_NIU_GB_MII_MGMT_ADDR_LNKPART = 5,
  263. NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG_MORE = 6,
  264. NETXEN_NIU_GB_MII_MGMT_ADDR_NEXTPAGE_XMIT = 7,
  265. NETXEN_NIU_GB_MII_MGMT_ADDR_LNKPART_NEXTPAGE = 8,
  266. NETXEN_NIU_GB_MII_MGMT_ADDR_1000BT_CONTROL = 9,
  267. NETXEN_NIU_GB_MII_MGMT_ADDR_1000BT_STATUS = 10,
  268. NETXEN_NIU_GB_MII_MGMT_ADDR_EXTENDED_STATUS = 15,
  269. NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_CONTROL = 16,
  270. NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS = 17,
  271. NETXEN_NIU_GB_MII_MGMT_ADDR_INT_ENABLE = 18,
  272. NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS = 19,
  273. NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_CONTROL_MORE = 20,
  274. NETXEN_NIU_GB_MII_MGMT_ADDR_RECV_ERROR_COUNT = 21,
  275. NETXEN_NIU_GB_MII_MGMT_ADDR_LED_CONTROL = 24,
  276. NETXEN_NIU_GB_MII_MGMT_ADDR_LED_OVERRIDE = 25,
  277. NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_CONTROL_MORE_YET = 26,
  278. NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS_MORE = 27
  279. } netxen_niu_phy_register_t;
  280. /*
  281. * PHY-Specific Status Register (reg 17).
  282. *
  283. * Bit 0 : jabber => 1:jabber detected, 0:not
  284. * Bit 1 : polarity => 1:polarity reversed, 0:normal
  285. * Bit 2 : recvpause => 1:receive pause enabled, 0:disabled
  286. * Bit 3 : xmitpause => 1:transmit pause enabled, 0:disabled
  287. * Bit 4 : energydetect => 1:sleep, 0:active
  288. * Bit 5 : downshift => 1:downshift, 0:no downshift
  289. * Bit 6 : crossover => 1:MDIX (crossover), 0:MDI (no crossover)
  290. * Bits 7-9 : cablelen => not valid in 10Mb/s mode
  291. * 0:<50m, 1:50-80m, 2:80-110m, 3:110-140m, 4:>140m
  292. * Bit 10 : link => 1:link up, 0:link down
  293. * Bit 11 : resolved => 1:speed and duplex resolved, 0:not yet
  294. * Bit 12 : pagercvd => 1:page received, 0:page not received
  295. * Bit 13 : duplex => 1:full duplex, 0:half duplex
  296. * Bits 14-15 : speed => 0:10Mb/s, 1:100Mb/s, 2:1000Mb/s, 3:rsvd
  297. */
  298. #define netxen_get_phy_cablelen(config_word) (((config_word) >> 7) & 0x07)
  299. #define netxen_get_phy_speed(config_word) (((config_word) >> 14) & 0x03)
  300. #define netxen_set_phy_speed(config_word, val) \
  301. ((config_word) |= ((val & 0x03) << 14))
  302. #define netxen_set_phy_duplex(config_word) \
  303. ((config_word) |= 1 << 13)
  304. #define netxen_clear_phy_duplex(config_word) \
  305. ((config_word) &= ~(1 << 13))
  306. #define netxen_get_phy_jabber(config_word) \
  307. _netxen_crb_get_bit(config_word, 0)
  308. #define netxen_get_phy_polarity(config_word) \
  309. _netxen_crb_get_bit(config_word, 1)
  310. #define netxen_get_phy_recvpause(config_word) \
  311. _netxen_crb_get_bit(config_word, 2)
  312. #define netxen_get_phy_xmitpause(config_word) \
  313. _netxen_crb_get_bit(config_word, 3)
  314. #define netxen_get_phy_energydetect(config_word) \
  315. _netxen_crb_get_bit(config_word, 4)
  316. #define netxen_get_phy_downshift(config_word) \
  317. _netxen_crb_get_bit(config_word, 5)
  318. #define netxen_get_phy_crossover(config_word) \
  319. _netxen_crb_get_bit(config_word, 6)
  320. #define netxen_get_phy_link(config_word) \
  321. _netxen_crb_get_bit(config_word, 10)
  322. #define netxen_get_phy_resolved(config_word) \
  323. _netxen_crb_get_bit(config_word, 11)
  324. #define netxen_get_phy_pagercvd(config_word) \
  325. _netxen_crb_get_bit(config_word, 12)
  326. #define netxen_get_phy_duplex(config_word) \
  327. _netxen_crb_get_bit(config_word, 13)
  328. /*
  329. * Interrupt Register definition
  330. * This definition applies to registers 18 and 19 (int enable and int status).
  331. * Bit 0 : jabber
  332. * Bit 1 : polarity_changed
  333. * Bit 4 : energy_detect
  334. * Bit 5 : downshift
  335. * Bit 6 : mdi_xover_changed
  336. * Bit 7 : fifo_over_underflow
  337. * Bit 8 : false_carrier
  338. * Bit 9 : symbol_error
  339. * Bit 10: link_status_changed
  340. * Bit 11: autoneg_completed
  341. * Bit 12: page_received
  342. * Bit 13: duplex_changed
  343. * Bit 14: speed_changed
  344. * Bit 15: autoneg_error
  345. */
  346. #define netxen_get_phy_int_jabber(config_word) \
  347. _netxen_crb_get_bit(config_word, 0)
  348. #define netxen_get_phy_int_polarity_changed(config_word) \
  349. _netxen_crb_get_bit(config_word, 1)
  350. #define netxen_get_phy_int_energy_detect(config_word) \
  351. _netxen_crb_get_bit(config_word, 4)
  352. #define netxen_get_phy_int_downshift(config_word) \
  353. _netxen_crb_get_bit(config_word, 5)
  354. #define netxen_get_phy_int_mdi_xover_changed(config_word) \
  355. _netxen_crb_get_bit(config_word, 6)
  356. #define netxen_get_phy_int_fifo_over_underflow(config_word) \
  357. _netxen_crb_get_bit(config_word, 7)
  358. #define netxen_get_phy_int_false_carrier(config_word) \
  359. _netxen_crb_get_bit(config_word, 8)
  360. #define netxen_get_phy_int_symbol_error(config_word) \
  361. _netxen_crb_get_bit(config_word, 9)
  362. #define netxen_get_phy_int_link_status_changed(config_word) \
  363. _netxen_crb_get_bit(config_word, 10)
  364. #define netxen_get_phy_int_autoneg_completed(config_word) \
  365. _netxen_crb_get_bit(config_word, 11)
  366. #define netxen_get_phy_int_page_received(config_word) \
  367. _netxen_crb_get_bit(config_word, 12)
  368. #define netxen_get_phy_int_duplex_changed(config_word) \
  369. _netxen_crb_get_bit(config_word, 13)
  370. #define netxen_get_phy_int_speed_changed(config_word) \
  371. _netxen_crb_get_bit(config_word, 14)
  372. #define netxen_get_phy_int_autoneg_error(config_word) \
  373. _netxen_crb_get_bit(config_word, 15)
  374. #define netxen_set_phy_int_link_status_changed(config_word) \
  375. ((config_word) |= 1 << 10)
  376. #define netxen_set_phy_int_autoneg_completed(config_word) \
  377. ((config_word) |= 1 << 11)
  378. #define netxen_set_phy_int_speed_changed(config_word) \
  379. ((config_word) |= 1 << 14)
  380. /*
  381. * NIU Mode Register.
  382. * Bit 0 : enable FibreChannel
  383. * Bit 1 : enable 10/100/1000 Ethernet
  384. * Bit 2 : enable 10Gb Ethernet
  385. */
  386. #define netxen_get_niu_enable_ge(config_word) \
  387. _netxen_crb_get_bit(config_word, 1)
  388. /* Promiscous mode options (GbE mode only) */
  389. typedef enum {
  390. NETXEN_NIU_PROMISC_MODE = 0,
  391. NETXEN_NIU_NON_PROMISC_MODE
  392. } netxen_niu_prom_mode_t;
  393. /*
  394. * NIU GB Drop CRC Register
  395. *
  396. * Bit 0 : drop_gb0 => 1:drop pkts with bad CRCs, 0:pass them on
  397. * Bit 1 : drop_gb1 => 1:drop pkts with bad CRCs, 0:pass them on
  398. * Bit 2 : drop_gb2 => 1:drop pkts with bad CRCs, 0:pass them on
  399. * Bit 3 : drop_gb3 => 1:drop pkts with bad CRCs, 0:pass them on
  400. */
  401. #define netxen_set_gb_drop_gb0(config_word) \
  402. ((config_word) |= 1 << 0)
  403. #define netxen_set_gb_drop_gb1(config_word) \
  404. ((config_word) |= 1 << 1)
  405. #define netxen_set_gb_drop_gb2(config_word) \
  406. ((config_word) |= 1 << 2)
  407. #define netxen_set_gb_drop_gb3(config_word) \
  408. ((config_word) |= 1 << 3)
  409. #define netxen_clear_gb_drop_gb0(config_word) \
  410. ((config_word) &= ~(1 << 0))
  411. #define netxen_clear_gb_drop_gb1(config_word) \
  412. ((config_word) &= ~(1 << 1))
  413. #define netxen_clear_gb_drop_gb2(config_word) \
  414. ((config_word) &= ~(1 << 2))
  415. #define netxen_clear_gb_drop_gb3(config_word) \
  416. ((config_word) &= ~(1 << 3))
  417. /*
  418. * NIU XG MAC Config Register
  419. *
  420. * Bit 0 : tx_enable => 1:enable frame xmit, 0:disable
  421. * Bit 2 : rx_enable => 1:enable frame recv, 0:disable
  422. * Bit 4 : soft_reset => 1:reset the MAC , 0:no-op
  423. * Bit 27: xaui_framer_reset
  424. * Bit 28: xaui_rx_reset
  425. * Bit 29: xaui_tx_reset
  426. * Bit 30: xg_ingress_afifo_reset
  427. * Bit 31: xg_egress_afifo_reset
  428. */
  429. #define netxen_xg_soft_reset(config_word) \
  430. ((config_word) |= 1 << 4)
  431. /*
  432. * MAC Control Register
  433. *
  434. * Bit 0-1 : id_pool0
  435. * Bit 2 : enable_xtnd0
  436. * Bit 4-5 : id_pool1
  437. * Bit 6 : enable_xtnd1
  438. * Bit 8-9 : id_pool2
  439. * Bit 10 : enable_xtnd2
  440. * Bit 12-13 : id_pool3
  441. * Bit 14 : enable_xtnd3
  442. * Bit 24-25 : mode_select
  443. * Bit 28-31 : enable_pool
  444. */
  445. #define netxen_nic_mcr_set_id_pool0(config, val) \
  446. ((config) |= ((val) &0x03))
  447. #define netxen_nic_mcr_set_enable_xtnd0(config) \
  448. ((config) |= 1 << 3)
  449. #define netxen_nic_mcr_set_id_pool1(config, val) \
  450. ((config) |= (((val) & 0x03) << 4))
  451. #define netxen_nic_mcr_set_enable_xtnd1(config) \
  452. ((config) |= 1 << 6)
  453. #define netxen_nic_mcr_set_id_pool2(config, val) \
  454. ((config) |= (((val) & 0x03) << 8))
  455. #define netxen_nic_mcr_set_enable_xtnd2(config) \
  456. ((config) |= 1 << 10)
  457. #define netxen_nic_mcr_set_id_pool3(config, val) \
  458. ((config) |= (((val) & 0x03) << 12))
  459. #define netxen_nic_mcr_set_enable_xtnd3(config) \
  460. ((config) |= 1 << 14)
  461. #define netxen_nic_mcr_set_mode_select(config, val) \
  462. ((config) |= (((val) & 0x03) << 24))
  463. #define netxen_nic_mcr_set_enable_pool(config, val) \
  464. ((config) |= (((val) & 0x0f) << 28))
  465. /* Set promiscuous mode for a GbE interface */
  466. int netxen_niu_set_promiscuous_mode(struct netxen_adapter *adapter,
  467. netxen_niu_prom_mode_t mode);
  468. int netxen_niu_xg_set_promiscuous_mode(struct netxen_adapter *adapter,
  469. netxen_niu_prom_mode_t mode);
  470. /* get/set the MAC address for a given MAC */
  471. int netxen_niu_macaddr_get(struct netxen_adapter *adapter,
  472. netxen_ethernet_macaddr_t * addr);
  473. int netxen_niu_macaddr_set(struct netxen_adapter *adapter,
  474. netxen_ethernet_macaddr_t addr);
  475. /* XG versons */
  476. int netxen_niu_xg_macaddr_get(struct netxen_adapter *adapter,
  477. netxen_ethernet_macaddr_t * addr);
  478. int netxen_niu_xg_macaddr_set(struct netxen_adapter *adapter,
  479. netxen_ethernet_macaddr_t addr);
  480. /* Generic enable for GbE ports. Will detect the speed of the link. */
  481. int netxen_niu_gbe_init_port(struct netxen_adapter *adapter, int port);
  482. int netxen_niu_xg_init_port(struct netxen_adapter *adapter, int port);
  483. /* Disable a GbE interface */
  484. int netxen_niu_disable_gbe_port(struct netxen_adapter *adapter);
  485. int netxen_niu_disable_xg_port(struct netxen_adapter *adapter);
  486. #endif /* __NETXEN_NIC_HW_H_ */