netxen_nic.h 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522
  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_H_
  31. #define _NETXEN_NIC_H_
  32. #include <linux/module.h>
  33. #include <linux/kernel.h>
  34. #include <linux/types.h>
  35. #include <linux/ioport.h>
  36. #include <linux/pci.h>
  37. #include <linux/netdevice.h>
  38. #include <linux/etherdevice.h>
  39. #include <linux/ip.h>
  40. #include <linux/in.h>
  41. #include <linux/tcp.h>
  42. #include <linux/skbuff.h>
  43. #include <linux/ethtool.h>
  44. #include <linux/mii.h>
  45. #include <linux/timer.h>
  46. #include <linux/vmalloc.h>
  47. #include <asm/io.h>
  48. #include <asm/byteorder.h>
  49. #include "netxen_nic_hw.h"
  50. #define _NETXEN_NIC_LINUX_MAJOR 4
  51. #define _NETXEN_NIC_LINUX_MINOR 0
  52. #define _NETXEN_NIC_LINUX_SUBVERSION 30
  53. #define NETXEN_NIC_LINUX_VERSIONID "4.0.30"
  54. #define NETXEN_VERSION_CODE(a, b, c) (((a) << 16) + ((b) << 8) + (c))
  55. #define NETXEN_NUM_FLASH_SECTORS (64)
  56. #define NETXEN_FLASH_SECTOR_SIZE (64 * 1024)
  57. #define NETXEN_FLASH_TOTAL_SIZE (NETXEN_NUM_FLASH_SECTORS \
  58. * NETXEN_FLASH_SECTOR_SIZE)
  59. #define PHAN_VENDOR_ID 0x4040
  60. #define RCV_DESC_RINGSIZE(rds_ring) \
  61. (sizeof(struct rcv_desc) * (rds_ring)->num_desc)
  62. #define RCV_BUFF_RINGSIZE(rds_ring) \
  63. (sizeof(struct netxen_rx_buffer) * rds_ring->num_desc)
  64. #define STATUS_DESC_RINGSIZE(sds_ring) \
  65. (sizeof(struct status_desc) * (sds_ring)->num_desc)
  66. #define TX_BUFF_RINGSIZE(tx_ring) \
  67. (sizeof(struct netxen_cmd_buffer) * tx_ring->num_desc)
  68. #define TX_DESC_RINGSIZE(tx_ring) \
  69. (sizeof(struct cmd_desc_type0) * tx_ring->num_desc)
  70. #define find_diff_among(a,b,range) ((a)<(b)?((b)-(a)):((b)+(range)-(a)))
  71. #define NETXEN_RCV_PRODUCER_OFFSET 0
  72. #define NETXEN_RCV_PEG_DB_ID 2
  73. #define NETXEN_HOST_DUMMY_DMA_SIZE 1024
  74. #define FLASH_SUCCESS 0
  75. #define ADDR_IN_WINDOW1(off) \
  76. ((off > NETXEN_CRB_PCIX_HOST2) && (off < NETXEN_CRB_MAX)) ? 1 : 0
  77. /*
  78. * normalize a 64MB crb address to 32MB PCI window
  79. * To use NETXEN_CRB_NORMALIZE, window _must_ be set to 1
  80. */
  81. #define NETXEN_CRB_NORMAL(reg) \
  82. ((reg) - NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST)
  83. #define NETXEN_CRB_NORMALIZE(adapter, reg) \
  84. pci_base_offset(adapter, NETXEN_CRB_NORMAL(reg))
  85. #define DB_NORMALIZE(adapter, off) \
  86. (adapter->ahw.db_base + (off))
  87. #define NX_P2_C0 0x24
  88. #define NX_P2_C1 0x25
  89. #define NX_P3_A0 0x30
  90. #define NX_P3_A2 0x30
  91. #define NX_P3_B0 0x40
  92. #define NX_P3_B1 0x41
  93. #define NX_P3_B2 0x42
  94. #define NX_IS_REVISION_P2(REVISION) (REVISION <= NX_P2_C1)
  95. #define NX_IS_REVISION_P3(REVISION) (REVISION >= NX_P3_A0)
  96. #define FIRST_PAGE_GROUP_START 0
  97. #define FIRST_PAGE_GROUP_END 0x100000
  98. #define SECOND_PAGE_GROUP_START 0x6000000
  99. #define SECOND_PAGE_GROUP_END 0x68BC000
  100. #define THIRD_PAGE_GROUP_START 0x70E4000
  101. #define THIRD_PAGE_GROUP_END 0x8000000
  102. #define FIRST_PAGE_GROUP_SIZE FIRST_PAGE_GROUP_END - FIRST_PAGE_GROUP_START
  103. #define SECOND_PAGE_GROUP_SIZE SECOND_PAGE_GROUP_END - SECOND_PAGE_GROUP_START
  104. #define THIRD_PAGE_GROUP_SIZE THIRD_PAGE_GROUP_END - THIRD_PAGE_GROUP_START
  105. #define P2_MAX_MTU (8000)
  106. #define P3_MAX_MTU (9600)
  107. #define NX_ETHERMTU 1500
  108. #define NX_MAX_ETHERHDR 32 /* This contains some padding */
  109. #define NX_RX_NORMAL_BUF_MAX_LEN (NX_MAX_ETHERHDR + NX_ETHERMTU)
  110. #define NX_P2_RX_JUMBO_BUF_MAX_LEN (NX_MAX_ETHERHDR + P2_MAX_MTU)
  111. #define NX_P3_RX_JUMBO_BUF_MAX_LEN (NX_MAX_ETHERHDR + P3_MAX_MTU)
  112. #define NX_CT_DEFAULT_RX_BUF_LEN 2048
  113. #define MAX_RX_BUFFER_LENGTH 1760
  114. #define MAX_RX_JUMBO_BUFFER_LENGTH 8062
  115. #define MAX_RX_LRO_BUFFER_LENGTH (8062)
  116. #define RX_DMA_MAP_LEN (MAX_RX_BUFFER_LENGTH - 2)
  117. #define RX_JUMBO_DMA_MAP_LEN \
  118. (MAX_RX_JUMBO_BUFFER_LENGTH - 2)
  119. #define RX_LRO_DMA_MAP_LEN (MAX_RX_LRO_BUFFER_LENGTH - 2)
  120. /*
  121. * Maximum number of ring contexts
  122. */
  123. #define MAX_RING_CTX 1
  124. /* Opcodes to be used with the commands */
  125. #define TX_ETHER_PKT 0x01
  126. #define TX_TCP_PKT 0x02
  127. #define TX_UDP_PKT 0x03
  128. #define TX_IP_PKT 0x04
  129. #define TX_TCP_LSO 0x05
  130. #define TX_TCP_LSO6 0x06
  131. #define TX_IPSEC 0x07
  132. #define TX_IPSEC_CMD 0x0a
  133. #define TX_TCPV6_PKT 0x0b
  134. #define TX_UDPV6_PKT 0x0c
  135. /* The following opcodes are for internal consumption. */
  136. #define NETXEN_CONTROL_OP 0x10
  137. #define PEGNET_REQUEST 0x11
  138. #define MAX_NUM_CARDS 4
  139. #define MAX_BUFFERS_PER_CMD 32
  140. /*
  141. * Following are the states of the Phantom. Phantom will set them and
  142. * Host will read to check if the fields are correct.
  143. */
  144. #define PHAN_INITIALIZE_START 0xff00
  145. #define PHAN_INITIALIZE_FAILED 0xffff
  146. #define PHAN_INITIALIZE_COMPLETE 0xff01
  147. /* Host writes the following to notify that it has done the init-handshake */
  148. #define PHAN_INITIALIZE_ACK 0xf00f
  149. #define NUM_RCV_DESC_RINGS 3
  150. #define NUM_STS_DESC_RINGS 4
  151. #define RCV_RING_NORMAL 0
  152. #define RCV_RING_JUMBO 1
  153. #define RCV_RING_LRO 2
  154. #define MAX_CMD_DESCRIPTORS 4096
  155. #define MAX_RCV_DESCRIPTORS 16384
  156. #define MAX_CMD_DESCRIPTORS_HOST 1024
  157. #define MAX_RCV_DESCRIPTORS_1G 2048
  158. #define MAX_RCV_DESCRIPTORS_10G 4096
  159. #define MAX_JUMBO_RCV_DESCRIPTORS 1024
  160. #define MAX_LRO_RCV_DESCRIPTORS 8
  161. #define NETXEN_CTX_SIGNATURE 0xdee0
  162. #define NETXEN_RCV_PRODUCER(ringid) (ringid)
  163. #define PHAN_PEG_RCV_INITIALIZED 0xff01
  164. #define PHAN_PEG_RCV_START_INITIALIZE 0xff00
  165. #define get_next_index(index, length) \
  166. (((index) + 1) & ((length) - 1))
  167. #define get_index_range(index,length,count) \
  168. (((index) + (count)) & ((length) - 1))
  169. #define MPORT_SINGLE_FUNCTION_MODE 0x1111
  170. #define MPORT_MULTI_FUNCTION_MODE 0x2222
  171. #include "netxen_nic_phan_reg.h"
  172. /*
  173. * NetXen host-peg signal message structure
  174. *
  175. * Bit 0-1 : peg_id => 0x2 for tx and 01 for rx
  176. * Bit 2 : priv_id => must be 1
  177. * Bit 3-17 : count => for doorbell
  178. * Bit 18-27 : ctx_id => Context id
  179. * Bit 28-31 : opcode
  180. */
  181. typedef u32 netxen_ctx_msg;
  182. #define netxen_set_msg_peg_id(config_word, val) \
  183. ((config_word) &= ~3, (config_word) |= val & 3)
  184. #define netxen_set_msg_privid(config_word) \
  185. ((config_word) |= 1 << 2)
  186. #define netxen_set_msg_count(config_word, val) \
  187. ((config_word) &= ~(0x7fff<<3), (config_word) |= (val & 0x7fff) << 3)
  188. #define netxen_set_msg_ctxid(config_word, val) \
  189. ((config_word) &= ~(0x3ff<<18), (config_word) |= (val & 0x3ff) << 18)
  190. #define netxen_set_msg_opcode(config_word, val) \
  191. ((config_word) &= ~(0xf<<28), (config_word) |= (val & 0xf) << 28)
  192. struct netxen_rcv_context {
  193. __le64 rcv_ring_addr;
  194. __le32 rcv_ring_size;
  195. __le32 rsrvd;
  196. };
  197. struct netxen_ring_ctx {
  198. /* one command ring */
  199. __le64 cmd_consumer_offset;
  200. __le64 cmd_ring_addr;
  201. __le32 cmd_ring_size;
  202. __le32 rsrvd;
  203. /* three receive rings */
  204. struct netxen_rcv_context rcv_ctx[3];
  205. /* one status ring */
  206. __le64 sts_ring_addr;
  207. __le32 sts_ring_size;
  208. __le32 ctx_id;
  209. } __attribute__ ((aligned(64)));
  210. /*
  211. * Following data structures describe the descriptors that will be used.
  212. * Added fileds of tcpHdrSize and ipHdrSize, The driver needs to do it only when
  213. * we are doing LSO (above the 1500 size packet) only.
  214. */
  215. /*
  216. * The size of reference handle been changed to 16 bits to pass the MSS fields
  217. * for the LSO packet
  218. */
  219. #define FLAGS_CHECKSUM_ENABLED 0x01
  220. #define FLAGS_LSO_ENABLED 0x02
  221. #define FLAGS_IPSEC_SA_ADD 0x04
  222. #define FLAGS_IPSEC_SA_DELETE 0x08
  223. #define FLAGS_VLAN_TAGGED 0x10
  224. #define netxen_set_cmd_desc_port(cmd_desc, var) \
  225. ((cmd_desc)->port_ctxid |= ((var) & 0x0F))
  226. #define netxen_set_cmd_desc_ctxid(cmd_desc, var) \
  227. ((cmd_desc)->port_ctxid |= ((var) << 4 & 0xF0))
  228. #define netxen_set_tx_port(_desc, _port) \
  229. (_desc)->port_ctxid = ((_port) & 0xf) | (((_port) << 4) & 0xf0)
  230. #define netxen_set_tx_flags_opcode(_desc, _flags, _opcode) \
  231. (_desc)->flags_opcode = \
  232. cpu_to_le16(((_flags) & 0x7f) | (((_opcode) & 0x3f) << 7))
  233. #define netxen_set_tx_frags_len(_desc, _frags, _len) \
  234. (_desc)->num_of_buffers_total_length = \
  235. cpu_to_le32(((_frags) & 0xff) | (((_len) & 0xffffff) << 8))
  236. struct cmd_desc_type0 {
  237. u8 tcp_hdr_offset; /* For LSO only */
  238. u8 ip_hdr_offset; /* For LSO only */
  239. /* Bit pattern: 0-6 flags, 7-12 opcode, 13-15 unused */
  240. __le16 flags_opcode;
  241. /* Bit pattern: 0-7 total number of segments,
  242. 8-31 Total size of the packet */
  243. __le32 num_of_buffers_total_length;
  244. union {
  245. struct {
  246. __le32 addr_low_part2;
  247. __le32 addr_high_part2;
  248. };
  249. __le64 addr_buffer2;
  250. };
  251. __le16 reference_handle; /* changed to u16 to add mss */
  252. __le16 mss; /* passed by NDIS_PACKET for LSO */
  253. /* Bit pattern 0-3 port, 0-3 ctx id */
  254. u8 port_ctxid;
  255. u8 total_hdr_length; /* LSO only : MAC+IP+TCP Hdr size */
  256. __le16 conn_id; /* IPSec offoad only */
  257. union {
  258. struct {
  259. __le32 addr_low_part3;
  260. __le32 addr_high_part3;
  261. };
  262. __le64 addr_buffer3;
  263. };
  264. union {
  265. struct {
  266. __le32 addr_low_part1;
  267. __le32 addr_high_part1;
  268. };
  269. __le64 addr_buffer1;
  270. };
  271. __le16 buffer_length[4];
  272. union {
  273. struct {
  274. __le32 addr_low_part4;
  275. __le32 addr_high_part4;
  276. };
  277. __le64 addr_buffer4;
  278. };
  279. __le64 unused;
  280. } __attribute__ ((aligned(64)));
  281. /* Note: sizeof(rcv_desc) should always be a mutliple of 2 */
  282. struct rcv_desc {
  283. __le16 reference_handle;
  284. __le16 reserved;
  285. __le32 buffer_length; /* allocated buffer length (usually 2K) */
  286. __le64 addr_buffer;
  287. };
  288. /* opcode field in status_desc */
  289. #define NETXEN_NIC_RXPKT_DESC 0x04
  290. #define NETXEN_OLD_RXPKT_DESC 0x3f
  291. #define NETXEN_NIC_RESPONSE_DESC 0x05
  292. /* for status field in status_desc */
  293. #define STATUS_NEED_CKSUM (1)
  294. #define STATUS_CKSUM_OK (2)
  295. /* owner bits of status_desc */
  296. #define STATUS_OWNER_HOST (0x1ULL << 56)
  297. #define STATUS_OWNER_PHANTOM (0x2ULL << 56)
  298. /* Status descriptor:
  299. 0-3 port, 4-7 status, 8-11 type, 12-27 total_length
  300. 28-43 reference_handle, 44-47 protocol, 48-52 pkt_offset
  301. 53-55 desc_cnt, 56-57 owner, 58-63 opcode
  302. */
  303. #define netxen_get_sts_port(sts_data) \
  304. ((sts_data) & 0x0F)
  305. #define netxen_get_sts_status(sts_data) \
  306. (((sts_data) >> 4) & 0x0F)
  307. #define netxen_get_sts_type(sts_data) \
  308. (((sts_data) >> 8) & 0x0F)
  309. #define netxen_get_sts_totallength(sts_data) \
  310. (((sts_data) >> 12) & 0xFFFF)
  311. #define netxen_get_sts_refhandle(sts_data) \
  312. (((sts_data) >> 28) & 0xFFFF)
  313. #define netxen_get_sts_prot(sts_data) \
  314. (((sts_data) >> 44) & 0x0F)
  315. #define netxen_get_sts_pkt_offset(sts_data) \
  316. (((sts_data) >> 48) & 0x1F)
  317. #define netxen_get_sts_desc_cnt(sts_data) \
  318. (((sts_data) >> 53) & 0x7)
  319. #define netxen_get_sts_opcode(sts_data) \
  320. (((sts_data) >> 58) & 0x03F)
  321. struct status_desc {
  322. __le64 status_desc_data[2];
  323. } __attribute__ ((aligned(16)));
  324. /* The version of the main data structure */
  325. #define NETXEN_BDINFO_VERSION 1
  326. /* Magic number to let user know flash is programmed */
  327. #define NETXEN_BDINFO_MAGIC 0x12345678
  328. /* Max number of Gig ports on a Phantom board */
  329. #define NETXEN_MAX_PORTS 4
  330. #define NETXEN_BRDTYPE_P1_BD 0x0000
  331. #define NETXEN_BRDTYPE_P1_SB 0x0001
  332. #define NETXEN_BRDTYPE_P1_SMAX 0x0002
  333. #define NETXEN_BRDTYPE_P1_SOCK 0x0003
  334. #define NETXEN_BRDTYPE_P2_SOCK_31 0x0008
  335. #define NETXEN_BRDTYPE_P2_SOCK_35 0x0009
  336. #define NETXEN_BRDTYPE_P2_SB35_4G 0x000a
  337. #define NETXEN_BRDTYPE_P2_SB31_10G 0x000b
  338. #define NETXEN_BRDTYPE_P2_SB31_2G 0x000c
  339. #define NETXEN_BRDTYPE_P2_SB31_10G_IMEZ 0x000d
  340. #define NETXEN_BRDTYPE_P2_SB31_10G_HMEZ 0x000e
  341. #define NETXEN_BRDTYPE_P2_SB31_10G_CX4 0x000f
  342. #define NETXEN_BRDTYPE_P3_REF_QG 0x0021
  343. #define NETXEN_BRDTYPE_P3_HMEZ 0x0022
  344. #define NETXEN_BRDTYPE_P3_10G_CX4_LP 0x0023
  345. #define NETXEN_BRDTYPE_P3_4_GB 0x0024
  346. #define NETXEN_BRDTYPE_P3_IMEZ 0x0025
  347. #define NETXEN_BRDTYPE_P3_10G_SFP_PLUS 0x0026
  348. #define NETXEN_BRDTYPE_P3_10000_BASE_T 0x0027
  349. #define NETXEN_BRDTYPE_P3_XG_LOM 0x0028
  350. #define NETXEN_BRDTYPE_P3_4_GB_MM 0x0029
  351. #define NETXEN_BRDTYPE_P3_10G_SFP_CT 0x002a
  352. #define NETXEN_BRDTYPE_P3_10G_SFP_QT 0x002b
  353. #define NETXEN_BRDTYPE_P3_10G_CX4 0x0031
  354. #define NETXEN_BRDTYPE_P3_10G_XFP 0x0032
  355. #define NETXEN_BRDTYPE_P3_10G_TP 0x0080
  356. struct netxen_board_info {
  357. u32 header_version;
  358. u32 board_mfg;
  359. u32 board_type;
  360. u32 board_num;
  361. u32 chip_id;
  362. u32 chip_minor;
  363. u32 chip_major;
  364. u32 chip_pkg;
  365. u32 chip_lot;
  366. u32 port_mask; /* available niu ports */
  367. u32 peg_mask; /* available pegs */
  368. u32 icache_ok; /* can we run with icache? */
  369. u32 dcache_ok; /* can we run with dcache? */
  370. u32 casper_ok;
  371. u32 mac_addr_lo_0;
  372. u32 mac_addr_lo_1;
  373. u32 mac_addr_lo_2;
  374. u32 mac_addr_lo_3;
  375. /* MN-related config */
  376. u32 mn_sync_mode; /* enable/ sync shift cclk/ sync shift mclk */
  377. u32 mn_sync_shift_cclk;
  378. u32 mn_sync_shift_mclk;
  379. u32 mn_wb_en;
  380. u32 mn_crystal_freq; /* in MHz */
  381. u32 mn_speed; /* in MHz */
  382. u32 mn_org;
  383. u32 mn_depth;
  384. u32 mn_ranks_0; /* ranks per slot */
  385. u32 mn_ranks_1; /* ranks per slot */
  386. u32 mn_rd_latency_0;
  387. u32 mn_rd_latency_1;
  388. u32 mn_rd_latency_2;
  389. u32 mn_rd_latency_3;
  390. u32 mn_rd_latency_4;
  391. u32 mn_rd_latency_5;
  392. u32 mn_rd_latency_6;
  393. u32 mn_rd_latency_7;
  394. u32 mn_rd_latency_8;
  395. u32 mn_dll_val[18];
  396. u32 mn_mode_reg; /* MIU DDR Mode Register */
  397. u32 mn_ext_mode_reg; /* MIU DDR Extended Mode Register */
  398. u32 mn_timing_0; /* MIU Memory Control Timing Rgister */
  399. u32 mn_timing_1; /* MIU Extended Memory Ctrl Timing Register */
  400. u32 mn_timing_2; /* MIU Extended Memory Ctrl Timing2 Register */
  401. /* SN-related config */
  402. u32 sn_sync_mode; /* enable/ sync shift cclk / sync shift mclk */
  403. u32 sn_pt_mode; /* pass through mode */
  404. u32 sn_ecc_en;
  405. u32 sn_wb_en;
  406. u32 sn_crystal_freq;
  407. u32 sn_speed;
  408. u32 sn_org;
  409. u32 sn_depth;
  410. u32 sn_dll_tap;
  411. u32 sn_rd_latency;
  412. u32 mac_addr_hi_0;
  413. u32 mac_addr_hi_1;
  414. u32 mac_addr_hi_2;
  415. u32 mac_addr_hi_3;
  416. u32 magic; /* indicates flash has been initialized */
  417. u32 mn_rdimm;
  418. u32 mn_dll_override;
  419. };
  420. #define FLASH_NUM_PORTS (4)
  421. struct netxen_flash_mac_addr {
  422. u32 flash_addr[32];
  423. };
  424. struct netxen_user_old_info {
  425. u8 flash_md5[16];
  426. u8 crbinit_md5[16];
  427. u8 brdcfg_md5[16];
  428. /* bootloader */
  429. u32 bootld_version;
  430. u32 bootld_size;
  431. u8 bootld_md5[16];
  432. /* image */
  433. u32 image_version;
  434. u32 image_size;
  435. u8 image_md5[16];
  436. /* primary image status */
  437. u32 primary_status;
  438. u32 secondary_present;
  439. /* MAC address , 4 ports */
  440. struct netxen_flash_mac_addr mac_addr[FLASH_NUM_PORTS];
  441. };
  442. #define FLASH_NUM_MAC_PER_PORT 32
  443. struct netxen_user_info {
  444. u8 flash_md5[16 * 64];
  445. /* bootloader */
  446. u32 bootld_version;
  447. u32 bootld_size;
  448. /* image */
  449. u32 image_version;
  450. u32 image_size;
  451. /* primary image status */
  452. u32 primary_status;
  453. u32 secondary_present;
  454. /* MAC address , 4 ports, 32 address per port */
  455. u64 mac_addr[FLASH_NUM_PORTS * FLASH_NUM_MAC_PER_PORT];
  456. u32 sub_sys_id;
  457. u8 serial_num[32];
  458. /* Any user defined data */
  459. };
  460. /*
  461. * Flash Layout - new format.
  462. */
  463. struct netxen_new_user_info {
  464. u8 flash_md5[16 * 64];
  465. /* bootloader */
  466. u32 bootld_version;
  467. u32 bootld_size;
  468. /* image */
  469. u32 image_version;
  470. u32 image_size;
  471. /* primary image status */
  472. u32 primary_status;
  473. u32 secondary_present;
  474. /* MAC address , 4 ports, 32 address per port */
  475. u64 mac_addr[FLASH_NUM_PORTS * FLASH_NUM_MAC_PER_PORT];
  476. u32 sub_sys_id;
  477. u8 serial_num[32];
  478. /* Any user defined data */
  479. };
  480. #define SECONDARY_IMAGE_PRESENT 0xb3b4b5b6
  481. #define SECONDARY_IMAGE_ABSENT 0xffffffff
  482. #define PRIMARY_IMAGE_GOOD 0x5a5a5a5a
  483. #define PRIMARY_IMAGE_BAD 0xffffffff
  484. /* Flash memory map */
  485. #define NETXEN_CRBINIT_START 0 /* crbinit section */
  486. #define NETXEN_BRDCFG_START 0x4000 /* board config */
  487. #define NETXEN_INITCODE_START 0x6000 /* pegtune code */
  488. #define NETXEN_BOOTLD_START 0x10000 /* bootld */
  489. #define NETXEN_IMAGE_START 0x43000 /* compressed image */
  490. #define NETXEN_SECONDARY_START 0x200000 /* backup images */
  491. #define NETXEN_PXE_START 0x3E0000 /* PXE boot rom */
  492. #define NETXEN_USER_START 0x3E8000 /* Firmare info */
  493. #define NETXEN_FIXED_START 0x3F0000 /* backup of crbinit */
  494. #define NX_FW_VERSION_OFFSET (NETXEN_USER_START+0x408)
  495. #define NX_FW_SIZE_OFFSET (NETXEN_USER_START+0x40c)
  496. #define NX_BIOS_VERSION_OFFSET (NETXEN_USER_START+0x83c)
  497. #define NX_FW_MAGIC_OFFSET (NETXEN_BRDCFG_START+0x128)
  498. #define NX_FW_MIN_SIZE (0x3fffff)
  499. #define NX_P2_MN_ROMIMAGE 0
  500. #define NX_P3_CT_ROMIMAGE 1
  501. #define NX_P3_MN_ROMIMAGE 2
  502. #define NETXEN_USER_START_OLD NETXEN_PXE_START /* for backward compatibility */
  503. #define NETXEN_FLASH_START (NETXEN_CRBINIT_START)
  504. #define NETXEN_INIT_SECTOR (0)
  505. #define NETXEN_PRIMARY_START (NETXEN_BOOTLD_START)
  506. #define NETXEN_FLASH_CRBINIT_SIZE (0x4000)
  507. #define NETXEN_FLASH_BRDCFG_SIZE (sizeof(struct netxen_board_info))
  508. #define NETXEN_FLASH_USER_SIZE (sizeof(struct netxen_user_info)/sizeof(u32))
  509. #define NETXEN_FLASH_SECONDARY_SIZE (NETXEN_USER_START-NETXEN_SECONDARY_START)
  510. #define NETXEN_NUM_PRIMARY_SECTORS (0x20)
  511. #define NETXEN_NUM_CONFIG_SECTORS (1)
  512. extern char netxen_nic_driver_name[];
  513. /* Number of status descriptors to handle per interrupt */
  514. #define MAX_STATUS_HANDLE (64)
  515. /*
  516. * netxen_skb_frag{} is to contain mapping info for each SG list. This
  517. * has to be freed when DMA is complete. This is part of netxen_tx_buffer{}.
  518. */
  519. struct netxen_skb_frag {
  520. u64 dma;
  521. u64 length;
  522. };
  523. #define _netxen_set_bits(config_word, start, bits, val) {\
  524. unsigned long long __tmask = (((1ULL << (bits)) - 1) << (start));\
  525. unsigned long long __tvalue = (val); \
  526. (config_word) &= ~__tmask; \
  527. (config_word) |= (((__tvalue) << (start)) & __tmask); \
  528. }
  529. #define _netxen_clear_bits(config_word, start, bits) {\
  530. unsigned long long __tmask = (((1ULL << (bits)) - 1) << (start)); \
  531. (config_word) &= ~__tmask; \
  532. }
  533. /* Following defines are for the state of the buffers */
  534. #define NETXEN_BUFFER_FREE 0
  535. #define NETXEN_BUFFER_BUSY 1
  536. /*
  537. * There will be one netxen_buffer per skb packet. These will be
  538. * used to save the dma info for pci_unmap_page()
  539. */
  540. struct netxen_cmd_buffer {
  541. struct sk_buff *skb;
  542. struct netxen_skb_frag frag_array[MAX_BUFFERS_PER_CMD + 1];
  543. u32 frag_count;
  544. };
  545. /* In rx_buffer, we do not need multiple fragments as is a single buffer */
  546. struct netxen_rx_buffer {
  547. struct list_head list;
  548. struct sk_buff *skb;
  549. u64 dma;
  550. u16 ref_handle;
  551. u16 state;
  552. };
  553. /* Board types */
  554. #define NETXEN_NIC_GBE 0x01
  555. #define NETXEN_NIC_XGBE 0x02
  556. /*
  557. * One hardware_context{} per adapter
  558. * contains interrupt info as well shared hardware info.
  559. */
  560. struct netxen_hardware_context {
  561. void __iomem *pci_base0;
  562. void __iomem *pci_base1;
  563. void __iomem *pci_base2;
  564. void __iomem *db_base;
  565. unsigned long db_len;
  566. unsigned long pci_len0;
  567. int qdr_sn_window;
  568. int ddr_mn_window;
  569. unsigned long mn_win_crb;
  570. unsigned long ms_win_crb;
  571. u8 cut_through;
  572. u8 revision_id;
  573. u8 pci_func;
  574. u8 linkup;
  575. u16 port_type;
  576. u16 board_type;
  577. };
  578. #define MINIMUM_ETHERNET_FRAME_SIZE 64 /* With FCS */
  579. #define ETHERNET_FCS_SIZE 4
  580. struct netxen_adapter_stats {
  581. u64 xmitcalled;
  582. u64 xmitfinished;
  583. u64 rxdropped;
  584. u64 txdropped;
  585. u64 csummed;
  586. u64 no_rcv;
  587. u64 rxbytes;
  588. u64 txbytes;
  589. };
  590. /*
  591. * Rcv Descriptor Context. One such per Rcv Descriptor. There may
  592. * be one Rcv Descriptor for normal packets, one for jumbo and may be others.
  593. */
  594. struct nx_host_rds_ring {
  595. u32 producer;
  596. u32 crb_rcv_producer;
  597. u32 num_desc;
  598. u32 dma_size;
  599. u32 skb_size;
  600. u32 flags;
  601. struct rcv_desc *desc_head;
  602. struct netxen_rx_buffer *rx_buf_arr;
  603. struct list_head free_list;
  604. spinlock_t lock;
  605. dma_addr_t phys_addr;
  606. };
  607. struct nx_host_sds_ring {
  608. u32 consumer;
  609. u32 crb_sts_consumer;
  610. u32 crb_intr_mask;
  611. u32 num_desc;
  612. struct status_desc *desc_head;
  613. struct netxen_adapter *adapter;
  614. struct napi_struct napi;
  615. struct list_head free_list[NUM_RCV_DESC_RINGS];
  616. int irq;
  617. dma_addr_t phys_addr;
  618. char name[IFNAMSIZ+4];
  619. };
  620. struct nx_host_tx_ring {
  621. u32 producer;
  622. __le32 *hw_consumer;
  623. u32 sw_consumer;
  624. u32 crb_cmd_producer;
  625. u32 crb_cmd_consumer;
  626. u32 num_desc;
  627. struct netxen_cmd_buffer *cmd_buf_arr;
  628. struct cmd_desc_type0 *desc_head;
  629. dma_addr_t phys_addr;
  630. };
  631. /*
  632. * Receive context. There is one such structure per instance of the
  633. * receive processing. Any state information that is relevant to
  634. * the receive, and is must be in this structure. The global data may be
  635. * present elsewhere.
  636. */
  637. struct netxen_recv_context {
  638. u32 state;
  639. u16 context_id;
  640. u16 virt_port;
  641. struct nx_host_rds_ring rds_rings[NUM_RCV_DESC_RINGS];
  642. struct nx_host_sds_ring *sds_rings;
  643. };
  644. /* New HW context creation */
  645. #define NX_OS_CRB_RETRY_COUNT 4000
  646. #define NX_CDRP_SIGNATURE_MAKE(pcifn, version) \
  647. (((pcifn) & 0xff) | (((version) & 0xff) << 8) | (0xcafe << 16))
  648. #define NX_CDRP_CLEAR 0x00000000
  649. #define NX_CDRP_CMD_BIT 0x80000000
  650. /*
  651. * All responses must have the NX_CDRP_CMD_BIT cleared
  652. * in the crb NX_CDRP_CRB_OFFSET.
  653. */
  654. #define NX_CDRP_FORM_RSP(rsp) (rsp)
  655. #define NX_CDRP_IS_RSP(rsp) (((rsp) & NX_CDRP_CMD_BIT) == 0)
  656. #define NX_CDRP_RSP_OK 0x00000001
  657. #define NX_CDRP_RSP_FAIL 0x00000002
  658. #define NX_CDRP_RSP_TIMEOUT 0x00000003
  659. /*
  660. * All commands must have the NX_CDRP_CMD_BIT set in
  661. * the crb NX_CDRP_CRB_OFFSET.
  662. */
  663. #define NX_CDRP_FORM_CMD(cmd) (NX_CDRP_CMD_BIT | (cmd))
  664. #define NX_CDRP_IS_CMD(cmd) (((cmd) & NX_CDRP_CMD_BIT) != 0)
  665. #define NX_CDRP_CMD_SUBMIT_CAPABILITIES 0x00000001
  666. #define NX_CDRP_CMD_READ_MAX_RDS_PER_CTX 0x00000002
  667. #define NX_CDRP_CMD_READ_MAX_SDS_PER_CTX 0x00000003
  668. #define NX_CDRP_CMD_READ_MAX_RULES_PER_CTX 0x00000004
  669. #define NX_CDRP_CMD_READ_MAX_RX_CTX 0x00000005
  670. #define NX_CDRP_CMD_READ_MAX_TX_CTX 0x00000006
  671. #define NX_CDRP_CMD_CREATE_RX_CTX 0x00000007
  672. #define NX_CDRP_CMD_DESTROY_RX_CTX 0x00000008
  673. #define NX_CDRP_CMD_CREATE_TX_CTX 0x00000009
  674. #define NX_CDRP_CMD_DESTROY_TX_CTX 0x0000000a
  675. #define NX_CDRP_CMD_SETUP_STATISTICS 0x0000000e
  676. #define NX_CDRP_CMD_GET_STATISTICS 0x0000000f
  677. #define NX_CDRP_CMD_DELETE_STATISTICS 0x00000010
  678. #define NX_CDRP_CMD_SET_MTU 0x00000012
  679. #define NX_CDRP_CMD_MAX 0x00000013
  680. #define NX_RCODE_SUCCESS 0
  681. #define NX_RCODE_NO_HOST_MEM 1
  682. #define NX_RCODE_NO_HOST_RESOURCE 2
  683. #define NX_RCODE_NO_CARD_CRB 3
  684. #define NX_RCODE_NO_CARD_MEM 4
  685. #define NX_RCODE_NO_CARD_RESOURCE 5
  686. #define NX_RCODE_INVALID_ARGS 6
  687. #define NX_RCODE_INVALID_ACTION 7
  688. #define NX_RCODE_INVALID_STATE 8
  689. #define NX_RCODE_NOT_SUPPORTED 9
  690. #define NX_RCODE_NOT_PERMITTED 10
  691. #define NX_RCODE_NOT_READY 11
  692. #define NX_RCODE_DOES_NOT_EXIST 12
  693. #define NX_RCODE_ALREADY_EXISTS 13
  694. #define NX_RCODE_BAD_SIGNATURE 14
  695. #define NX_RCODE_CMD_NOT_IMPL 15
  696. #define NX_RCODE_CMD_INVALID 16
  697. #define NX_RCODE_TIMEOUT 17
  698. #define NX_RCODE_CMD_FAILED 18
  699. #define NX_RCODE_MAX_EXCEEDED 19
  700. #define NX_RCODE_MAX 20
  701. #define NX_DESTROY_CTX_RESET 0
  702. #define NX_DESTROY_CTX_D3_RESET 1
  703. #define NX_DESTROY_CTX_MAX 2
  704. /*
  705. * Capabilities
  706. */
  707. #define NX_CAP_BIT(class, bit) (1 << bit)
  708. #define NX_CAP0_LEGACY_CONTEXT NX_CAP_BIT(0, 0)
  709. #define NX_CAP0_MULTI_CONTEXT NX_CAP_BIT(0, 1)
  710. #define NX_CAP0_LEGACY_MN NX_CAP_BIT(0, 2)
  711. #define NX_CAP0_LEGACY_MS NX_CAP_BIT(0, 3)
  712. #define NX_CAP0_CUT_THROUGH NX_CAP_BIT(0, 4)
  713. #define NX_CAP0_LRO NX_CAP_BIT(0, 5)
  714. #define NX_CAP0_LSO NX_CAP_BIT(0, 6)
  715. #define NX_CAP0_JUMBO_CONTIGUOUS NX_CAP_BIT(0, 7)
  716. #define NX_CAP0_LRO_CONTIGUOUS NX_CAP_BIT(0, 8)
  717. /*
  718. * Context state
  719. */
  720. #define NX_HOST_CTX_STATE_FREED 0
  721. #define NX_HOST_CTX_STATE_ALLOCATED 1
  722. #define NX_HOST_CTX_STATE_ACTIVE 2
  723. #define NX_HOST_CTX_STATE_DISABLED 3
  724. #define NX_HOST_CTX_STATE_QUIESCED 4
  725. #define NX_HOST_CTX_STATE_MAX 5
  726. /*
  727. * Rx context
  728. */
  729. typedef struct {
  730. __le64 host_phys_addr; /* Ring base addr */
  731. __le32 ring_size; /* Ring entries */
  732. __le16 msi_index;
  733. __le16 rsvd; /* Padding */
  734. } nx_hostrq_sds_ring_t;
  735. typedef struct {
  736. __le64 host_phys_addr; /* Ring base addr */
  737. __le64 buff_size; /* Packet buffer size */
  738. __le32 ring_size; /* Ring entries */
  739. __le32 ring_kind; /* Class of ring */
  740. } nx_hostrq_rds_ring_t;
  741. typedef struct {
  742. __le64 host_rsp_dma_addr; /* Response dma'd here */
  743. __le32 capabilities[4]; /* Flag bit vector */
  744. __le32 host_int_crb_mode; /* Interrupt crb usage */
  745. __le32 host_rds_crb_mode; /* RDS crb usage */
  746. /* These ring offsets are relative to data[0] below */
  747. __le32 rds_ring_offset; /* Offset to RDS config */
  748. __le32 sds_ring_offset; /* Offset to SDS config */
  749. __le16 num_rds_rings; /* Count of RDS rings */
  750. __le16 num_sds_rings; /* Count of SDS rings */
  751. __le16 rsvd1; /* Padding */
  752. __le16 rsvd2; /* Padding */
  753. u8 reserved[128]; /* reserve space for future expansion*/
  754. /* MUST BE 64-bit aligned.
  755. The following is packed:
  756. - N hostrq_rds_rings
  757. - N hostrq_sds_rings */
  758. char data[0];
  759. } nx_hostrq_rx_ctx_t;
  760. typedef struct {
  761. __le32 host_producer_crb; /* Crb to use */
  762. __le32 rsvd1; /* Padding */
  763. } nx_cardrsp_rds_ring_t;
  764. typedef struct {
  765. __le32 host_consumer_crb; /* Crb to use */
  766. __le32 interrupt_crb; /* Crb to use */
  767. } nx_cardrsp_sds_ring_t;
  768. typedef struct {
  769. /* These ring offsets are relative to data[0] below */
  770. __le32 rds_ring_offset; /* Offset to RDS config */
  771. __le32 sds_ring_offset; /* Offset to SDS config */
  772. __le32 host_ctx_state; /* Starting State */
  773. __le32 num_fn_per_port; /* How many PCI fn share the port */
  774. __le16 num_rds_rings; /* Count of RDS rings */
  775. __le16 num_sds_rings; /* Count of SDS rings */
  776. __le16 context_id; /* Handle for context */
  777. u8 phys_port; /* Physical id of port */
  778. u8 virt_port; /* Virtual/Logical id of port */
  779. u8 reserved[128]; /* save space for future expansion */
  780. /* MUST BE 64-bit aligned.
  781. The following is packed:
  782. - N cardrsp_rds_rings
  783. - N cardrs_sds_rings */
  784. char data[0];
  785. } nx_cardrsp_rx_ctx_t;
  786. #define SIZEOF_HOSTRQ_RX(HOSTRQ_RX, rds_rings, sds_rings) \
  787. (sizeof(HOSTRQ_RX) + \
  788. (rds_rings)*(sizeof(nx_hostrq_rds_ring_t)) + \
  789. (sds_rings)*(sizeof(nx_hostrq_sds_ring_t)))
  790. #define SIZEOF_CARDRSP_RX(CARDRSP_RX, rds_rings, sds_rings) \
  791. (sizeof(CARDRSP_RX) + \
  792. (rds_rings)*(sizeof(nx_cardrsp_rds_ring_t)) + \
  793. (sds_rings)*(sizeof(nx_cardrsp_sds_ring_t)))
  794. /*
  795. * Tx context
  796. */
  797. typedef struct {
  798. __le64 host_phys_addr; /* Ring base addr */
  799. __le32 ring_size; /* Ring entries */
  800. __le32 rsvd; /* Padding */
  801. } nx_hostrq_cds_ring_t;
  802. typedef struct {
  803. __le64 host_rsp_dma_addr; /* Response dma'd here */
  804. __le64 cmd_cons_dma_addr; /* */
  805. __le64 dummy_dma_addr; /* */
  806. __le32 capabilities[4]; /* Flag bit vector */
  807. __le32 host_int_crb_mode; /* Interrupt crb usage */
  808. __le32 rsvd1; /* Padding */
  809. __le16 rsvd2; /* Padding */
  810. __le16 interrupt_ctl;
  811. __le16 msi_index;
  812. __le16 rsvd3; /* Padding */
  813. nx_hostrq_cds_ring_t cds_ring; /* Desc of cds ring */
  814. u8 reserved[128]; /* future expansion */
  815. } nx_hostrq_tx_ctx_t;
  816. typedef struct {
  817. __le32 host_producer_crb; /* Crb to use */
  818. __le32 interrupt_crb; /* Crb to use */
  819. } nx_cardrsp_cds_ring_t;
  820. typedef struct {
  821. __le32 host_ctx_state; /* Starting state */
  822. __le16 context_id; /* Handle for context */
  823. u8 phys_port; /* Physical id of port */
  824. u8 virt_port; /* Virtual/Logical id of port */
  825. nx_cardrsp_cds_ring_t cds_ring; /* Card cds settings */
  826. u8 reserved[128]; /* future expansion */
  827. } nx_cardrsp_tx_ctx_t;
  828. #define SIZEOF_HOSTRQ_TX(HOSTRQ_TX) (sizeof(HOSTRQ_TX))
  829. #define SIZEOF_CARDRSP_TX(CARDRSP_TX) (sizeof(CARDRSP_TX))
  830. /* CRB */
  831. #define NX_HOST_RDS_CRB_MODE_UNIQUE 0
  832. #define NX_HOST_RDS_CRB_MODE_SHARED 1
  833. #define NX_HOST_RDS_CRB_MODE_CUSTOM 2
  834. #define NX_HOST_RDS_CRB_MODE_MAX 3
  835. #define NX_HOST_INT_CRB_MODE_UNIQUE 0
  836. #define NX_HOST_INT_CRB_MODE_SHARED 1
  837. #define NX_HOST_INT_CRB_MODE_NORX 2
  838. #define NX_HOST_INT_CRB_MODE_NOTX 3
  839. #define NX_HOST_INT_CRB_MODE_NORXTX 4
  840. /* MAC */
  841. #define MC_COUNT_P2 16
  842. #define MC_COUNT_P3 38
  843. #define NETXEN_MAC_NOOP 0
  844. #define NETXEN_MAC_ADD 1
  845. #define NETXEN_MAC_DEL 2
  846. typedef struct nx_mac_list_s {
  847. struct nx_mac_list_s *next;
  848. uint8_t mac_addr[MAX_ADDR_LEN];
  849. } nx_mac_list_t;
  850. /*
  851. * Interrupt coalescing defaults. The defaults are for 1500 MTU. It is
  852. * adjusted based on configured MTU.
  853. */
  854. #define NETXEN_DEFAULT_INTR_COALESCE_RX_TIME_US 3
  855. #define NETXEN_DEFAULT_INTR_COALESCE_RX_PACKETS 256
  856. #define NETXEN_DEFAULT_INTR_COALESCE_TX_PACKETS 64
  857. #define NETXEN_DEFAULT_INTR_COALESCE_TX_TIME_US 4
  858. #define NETXEN_NIC_INTR_DEFAULT 0x04
  859. typedef union {
  860. struct {
  861. uint16_t rx_packets;
  862. uint16_t rx_time_us;
  863. uint16_t tx_packets;
  864. uint16_t tx_time_us;
  865. } data;
  866. uint64_t word;
  867. } nx_nic_intr_coalesce_data_t;
  868. typedef struct {
  869. uint16_t stats_time_us;
  870. uint16_t rate_sample_time;
  871. uint16_t flags;
  872. uint16_t rsvd_1;
  873. uint32_t low_threshold;
  874. uint32_t high_threshold;
  875. nx_nic_intr_coalesce_data_t normal;
  876. nx_nic_intr_coalesce_data_t low;
  877. nx_nic_intr_coalesce_data_t high;
  878. nx_nic_intr_coalesce_data_t irq;
  879. } nx_nic_intr_coalesce_t;
  880. #define NX_HOST_REQUEST 0x13
  881. #define NX_NIC_REQUEST 0x14
  882. #define NX_MAC_EVENT 0x1
  883. /*
  884. * Driver --> Firmware
  885. */
  886. #define NX_NIC_H2C_OPCODE_START 0
  887. #define NX_NIC_H2C_OPCODE_CONFIG_RSS 1
  888. #define NX_NIC_H2C_OPCODE_CONFIG_RSS_TBL 2
  889. #define NX_NIC_H2C_OPCODE_CONFIG_INTR_COALESCE 3
  890. #define NX_NIC_H2C_OPCODE_CONFIG_LED 4
  891. #define NX_NIC_H2C_OPCODE_CONFIG_PROMISCUOUS 5
  892. #define NX_NIC_H2C_OPCODE_CONFIG_L2_MAC 6
  893. #define NX_NIC_H2C_OPCODE_LRO_REQUEST 7
  894. #define NX_NIC_H2C_OPCODE_GET_SNMP_STATS 8
  895. #define NX_NIC_H2C_OPCODE_PROXY_START_REQUEST 9
  896. #define NX_NIC_H2C_OPCODE_PROXY_STOP_REQUEST 10
  897. #define NX_NIC_H2C_OPCODE_PROXY_SET_MTU 11
  898. #define NX_NIC_H2C_OPCODE_PROXY_SET_VPORT_MISS_MODE 12
  899. #define NX_NIC_H2C_OPCODE_GET_FINGER_PRINT_REQUEST 13
  900. #define NX_NIC_H2C_OPCODE_INSTALL_LICENSE_REQUEST 14
  901. #define NX_NIC_H2C_OPCODE_GET_LICENSE_CAPABILITY_REQUEST 15
  902. #define NX_NIC_H2C_OPCODE_GET_NET_STATS 16
  903. #define NX_NIC_H2C_OPCODE_PROXY_UPDATE_P2V 17
  904. #define NX_NIC_H2C_OPCODE_CONFIG_IPADDR 18
  905. #define NX_NIC_H2C_OPCODE_CONFIG_LOOPBACK 19
  906. #define NX_NIC_H2C_OPCODE_PROXY_STOP_DONE 20
  907. #define NX_NIC_H2C_OPCODE_GET_LINKEVENT 21
  908. #define NX_NIC_C2C_OPCODE 22
  909. #define NX_NIC_H2C_OPCODE_LAST 23
  910. /*
  911. * Firmware --> Driver
  912. */
  913. #define NX_NIC_C2H_OPCODE_START 128
  914. #define NX_NIC_C2H_OPCODE_CONFIG_RSS_RESPONSE 129
  915. #define NX_NIC_C2H_OPCODE_CONFIG_RSS_TBL_RESPONSE 130
  916. #define NX_NIC_C2H_OPCODE_CONFIG_MAC_RESPONSE 131
  917. #define NX_NIC_C2H_OPCODE_CONFIG_PROMISCUOUS_RESPONSE 132
  918. #define NX_NIC_C2H_OPCODE_CONFIG_L2_MAC_RESPONSE 133
  919. #define NX_NIC_C2H_OPCODE_LRO_DELETE_RESPONSE 134
  920. #define NX_NIC_C2H_OPCODE_LRO_ADD_FAILURE_RESPONSE 135
  921. #define NX_NIC_C2H_OPCODE_GET_SNMP_STATS 136
  922. #define NX_NIC_C2H_OPCODE_GET_FINGER_PRINT_REPLY 137
  923. #define NX_NIC_C2H_OPCODE_INSTALL_LICENSE_REPLY 138
  924. #define NX_NIC_C2H_OPCODE_GET_LICENSE_CAPABILITIES_REPLY 139
  925. #define NX_NIC_C2H_OPCODE_GET_NET_STATS_RESPONSE 140
  926. #define NX_NIC_C2H_OPCODE_GET_LINKEVENT_RESPONSE 141
  927. #define NX_NIC_C2H_OPCODE_LAST 142
  928. #define VPORT_MISS_MODE_DROP 0 /* drop all unmatched */
  929. #define VPORT_MISS_MODE_ACCEPT_ALL 1 /* accept all packets */
  930. #define VPORT_MISS_MODE_ACCEPT_MULTI 2 /* accept unmatched multicast */
  931. #define NX_FW_CAPABILITY_LINK_NOTIFICATION (1 << 5)
  932. #define NX_FW_CAPABILITY_SWITCHING (1 << 6)
  933. /* module types */
  934. #define LINKEVENT_MODULE_NOT_PRESENT 1
  935. #define LINKEVENT_MODULE_OPTICAL_UNKNOWN 2
  936. #define LINKEVENT_MODULE_OPTICAL_SRLR 3
  937. #define LINKEVENT_MODULE_OPTICAL_LRM 4
  938. #define LINKEVENT_MODULE_OPTICAL_SFP_1G 5
  939. #define LINKEVENT_MODULE_TWINAX_UNSUPPORTED_CABLE 6
  940. #define LINKEVENT_MODULE_TWINAX_UNSUPPORTED_CABLELEN 7
  941. #define LINKEVENT_MODULE_TWINAX 8
  942. #define LINKSPEED_10GBPS 10000
  943. #define LINKSPEED_1GBPS 1000
  944. #define LINKSPEED_100MBPS 100
  945. #define LINKSPEED_10MBPS 10
  946. #define LINKSPEED_ENCODED_10MBPS 0
  947. #define LINKSPEED_ENCODED_100MBPS 1
  948. #define LINKSPEED_ENCODED_1GBPS 2
  949. #define LINKEVENT_AUTONEG_DISABLED 0
  950. #define LINKEVENT_AUTONEG_ENABLED 1
  951. #define LINKEVENT_HALF_DUPLEX 0
  952. #define LINKEVENT_FULL_DUPLEX 1
  953. #define LINKEVENT_LINKSPEED_MBPS 0
  954. #define LINKEVENT_LINKSPEED_ENCODED 1
  955. /* firmware response header:
  956. * 63:58 - message type
  957. * 57:56 - owner
  958. * 55:53 - desc count
  959. * 52:48 - reserved
  960. * 47:40 - completion id
  961. * 39:32 - opcode
  962. * 31:16 - error code
  963. * 15:00 - reserved
  964. */
  965. #define netxen_get_nic_msgtype(msg_hdr) \
  966. ((msg_hdr >> 58) & 0x3F)
  967. #define netxen_get_nic_msg_compid(msg_hdr) \
  968. ((msg_hdr >> 40) & 0xFF)
  969. #define netxen_get_nic_msg_opcode(msg_hdr) \
  970. ((msg_hdr >> 32) & 0xFF)
  971. #define netxen_get_nic_msg_errcode(msg_hdr) \
  972. ((msg_hdr >> 16) & 0xFFFF)
  973. typedef struct {
  974. union {
  975. struct {
  976. u64 hdr;
  977. u64 body[7];
  978. };
  979. u64 words[8];
  980. };
  981. } nx_fw_msg_t;
  982. typedef struct {
  983. __le64 qhdr;
  984. __le64 req_hdr;
  985. __le64 words[6];
  986. } nx_nic_req_t;
  987. typedef struct {
  988. u8 op;
  989. u8 tag;
  990. u8 mac_addr[6];
  991. } nx_mac_req_t;
  992. #define MAX_PENDING_DESC_BLOCK_SIZE 64
  993. #define NETXEN_NIC_MSI_ENABLED 0x02
  994. #define NETXEN_NIC_MSIX_ENABLED 0x04
  995. #define NETXEN_IS_MSI_FAMILY(adapter) \
  996. ((adapter)->flags & (NETXEN_NIC_MSI_ENABLED | NETXEN_NIC_MSIX_ENABLED))
  997. #define MSIX_ENTRIES_PER_ADAPTER NUM_STS_DESC_RINGS
  998. #define NETXEN_MSIX_TBL_SPACE 8192
  999. #define NETXEN_PCI_REG_MSIX_TBL 0x44
  1000. #define NETXEN_DB_MAPSIZE_BYTES 0x1000
  1001. #define NETXEN_NETDEV_WEIGHT 128
  1002. #define NETXEN_ADAPTER_UP_MAGIC 777
  1003. #define NETXEN_NIC_PEG_TUNE 0
  1004. struct netxen_dummy_dma {
  1005. void *addr;
  1006. dma_addr_t phys_addr;
  1007. };
  1008. struct netxen_adapter {
  1009. struct netxen_hardware_context ahw;
  1010. struct net_device *netdev;
  1011. struct pci_dev *pdev;
  1012. nx_mac_list_t *mac_list;
  1013. u32 curr_window;
  1014. u32 crb_win;
  1015. rwlock_t adapter_lock;
  1016. spinlock_t tx_clean_lock;
  1017. u16 num_txd;
  1018. u16 num_rxd;
  1019. u16 num_jumbo_rxd;
  1020. u16 num_lro_rxd;
  1021. u8 max_rds_rings;
  1022. u8 max_sds_rings;
  1023. u8 driver_mismatch;
  1024. u8 msix_supported;
  1025. u8 rx_csum;
  1026. u8 pci_using_dac;
  1027. u8 portnum;
  1028. u8 physical_port;
  1029. u8 mc_enabled;
  1030. u8 max_mc_count;
  1031. u16 resv2;
  1032. u32 resv3;
  1033. u8 has_link_events;
  1034. u8 resv1;
  1035. u16 tx_context_id;
  1036. u16 mtu;
  1037. u16 is_up;
  1038. u16 link_speed;
  1039. u16 link_duplex;
  1040. u16 link_autoneg;
  1041. u16 module_type;
  1042. u32 capabilities;
  1043. u32 flags;
  1044. u32 irq;
  1045. u32 temp;
  1046. u32 fw_major;
  1047. u32 fw_version;
  1048. struct netxen_adapter_stats stats;
  1049. struct netxen_recv_context recv_ctx;
  1050. struct nx_host_tx_ring tx_ring;
  1051. /* Context interface shared between card and host */
  1052. struct netxen_ring_ctx *ctx_desc;
  1053. dma_addr_t ctx_desc_phys_addr;
  1054. int (*enable_phy_interrupts) (struct netxen_adapter *);
  1055. int (*disable_phy_interrupts) (struct netxen_adapter *);
  1056. int (*macaddr_set) (struct netxen_adapter *, netxen_ethernet_macaddr_t);
  1057. int (*set_mtu) (struct netxen_adapter *, int);
  1058. int (*set_promisc) (struct netxen_adapter *, u32);
  1059. int (*phy_read) (struct netxen_adapter *, long reg, u32 *);
  1060. int (*phy_write) (struct netxen_adapter *, long reg, u32 val);
  1061. int (*init_port) (struct netxen_adapter *, int);
  1062. int (*stop_port) (struct netxen_adapter *);
  1063. u32 (*hw_read_wx)(struct netxen_adapter *, ulong);
  1064. int (*hw_write_wx)(struct netxen_adapter *, ulong, u32);
  1065. int (*pci_mem_read)(struct netxen_adapter *, u64, void *, int);
  1066. int (*pci_mem_write)(struct netxen_adapter *, u64, void *, int);
  1067. int (*pci_write_immediate)(struct netxen_adapter *, u64, u32);
  1068. u32 (*pci_read_immediate)(struct netxen_adapter *, u64);
  1069. unsigned long (*pci_set_window)(struct netxen_adapter *,
  1070. unsigned long long);
  1071. struct netxen_legacy_intr_set legacy_intr;
  1072. struct msix_entry msix_entries[MSIX_ENTRIES_PER_ADAPTER];
  1073. struct netxen_dummy_dma dummy_dma;
  1074. struct work_struct watchdog_task;
  1075. struct timer_list watchdog_timer;
  1076. struct work_struct tx_timeout_task;
  1077. struct net_device_stats net_stats;
  1078. nx_nic_intr_coalesce_t coal;
  1079. };
  1080. /*
  1081. * NetXen dma watchdog control structure
  1082. *
  1083. * Bit 0 : enabled => R/O: 1 watchdog active, 0 inactive
  1084. * Bit 1 : disable_request => 1 req disable dma watchdog
  1085. * Bit 2 : enable_request => 1 req enable dma watchdog
  1086. * Bit 3-31 : unused
  1087. */
  1088. #define netxen_set_dma_watchdog_disable_req(config_word) \
  1089. _netxen_set_bits(config_word, 1, 1, 1)
  1090. #define netxen_set_dma_watchdog_enable_req(config_word) \
  1091. _netxen_set_bits(config_word, 2, 1, 1)
  1092. #define netxen_get_dma_watchdog_enabled(config_word) \
  1093. ((config_word) & 0x1)
  1094. #define netxen_get_dma_watchdog_disabled(config_word) \
  1095. (((config_word) >> 1) & 0x1)
  1096. int netxen_niu_xgbe_enable_phy_interrupts(struct netxen_adapter *adapter);
  1097. int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter);
  1098. int netxen_niu_xgbe_disable_phy_interrupts(struct netxen_adapter *adapter);
  1099. int netxen_niu_gbe_disable_phy_interrupts(struct netxen_adapter *adapter);
  1100. int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long reg,
  1101. __u32 * readval);
  1102. int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter,
  1103. long reg, __u32 val);
  1104. /* Functions available from netxen_nic_hw.c */
  1105. int netxen_nic_set_mtu_xgb(struct netxen_adapter *adapter, int new_mtu);
  1106. int netxen_nic_set_mtu_gb(struct netxen_adapter *adapter, int new_mtu);
  1107. #define NXRD32(adapter, off) \
  1108. (adapter->hw_read_wx(adapter, off))
  1109. #define NXWR32(adapter, off, val) \
  1110. (adapter->hw_write_wx(adapter, off, val))
  1111. int netxen_nic_get_board_info(struct netxen_adapter *adapter);
  1112. void netxen_nic_get_firmware_info(struct netxen_adapter *adapter);
  1113. int netxen_nic_wol_supported(struct netxen_adapter *adapter);
  1114. u32 netxen_nic_hw_read_wx_128M(struct netxen_adapter *adapter, ulong off);
  1115. int netxen_nic_hw_write_wx_128M(struct netxen_adapter *adapter,
  1116. ulong off, u32 data);
  1117. int netxen_nic_pci_mem_read_128M(struct netxen_adapter *adapter,
  1118. u64 off, void *data, int size);
  1119. int netxen_nic_pci_mem_write_128M(struct netxen_adapter *adapter,
  1120. u64 off, void *data, int size);
  1121. int netxen_nic_pci_write_immediate_128M(struct netxen_adapter *adapter,
  1122. u64 off, u32 data);
  1123. u32 netxen_nic_pci_read_immediate_128M(struct netxen_adapter *adapter, u64 off);
  1124. void netxen_nic_pci_write_normalize_128M(struct netxen_adapter *adapter,
  1125. u64 off, u32 data);
  1126. u32 netxen_nic_pci_read_normalize_128M(struct netxen_adapter *adapter, u64 off);
  1127. unsigned long netxen_nic_pci_set_window_128M(struct netxen_adapter *adapter,
  1128. unsigned long long addr);
  1129. void netxen_nic_pci_change_crbwindow_128M(struct netxen_adapter *adapter,
  1130. u32 wndw);
  1131. u32 netxen_nic_hw_read_wx_2M(struct netxen_adapter *adapter, ulong off);
  1132. int netxen_nic_hw_write_wx_2M(struct netxen_adapter *adapter,
  1133. ulong off, u32 data);
  1134. int netxen_nic_pci_mem_read_2M(struct netxen_adapter *adapter,
  1135. u64 off, void *data, int size);
  1136. int netxen_nic_pci_mem_write_2M(struct netxen_adapter *adapter,
  1137. u64 off, void *data, int size);
  1138. int netxen_nic_pci_write_immediate_2M(struct netxen_adapter *adapter,
  1139. u64 off, u32 data);
  1140. u32 netxen_nic_pci_read_immediate_2M(struct netxen_adapter *adapter, u64 off);
  1141. void netxen_nic_pci_write_normalize_2M(struct netxen_adapter *adapter,
  1142. u64 off, u32 data);
  1143. u32 netxen_nic_pci_read_normalize_2M(struct netxen_adapter *adapter, u64 off);
  1144. unsigned long netxen_nic_pci_set_window_2M(struct netxen_adapter *adapter,
  1145. unsigned long long addr);
  1146. /* Functions from netxen_nic_init.c */
  1147. void netxen_free_adapter_offload(struct netxen_adapter *adapter);
  1148. int netxen_initialize_adapter_offload(struct netxen_adapter *adapter);
  1149. int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val);
  1150. int netxen_load_firmware(struct netxen_adapter *adapter);
  1151. int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose);
  1152. int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp);
  1153. int netxen_rom_fast_read_words(struct netxen_adapter *adapter, int addr,
  1154. u8 *bytes, size_t size);
  1155. int netxen_rom_fast_write_words(struct netxen_adapter *adapter, int addr,
  1156. u8 *bytes, size_t size);
  1157. int netxen_flash_unlock(struct netxen_adapter *adapter);
  1158. int netxen_backup_crbinit(struct netxen_adapter *adapter);
  1159. int netxen_flash_erase_secondary(struct netxen_adapter *adapter);
  1160. int netxen_flash_erase_primary(struct netxen_adapter *adapter);
  1161. void netxen_halt_pegs(struct netxen_adapter *adapter);
  1162. int netxen_rom_se(struct netxen_adapter *adapter, int addr);
  1163. int netxen_alloc_sw_resources(struct netxen_adapter *adapter);
  1164. void netxen_free_sw_resources(struct netxen_adapter *adapter);
  1165. int netxen_alloc_hw_resources(struct netxen_adapter *adapter);
  1166. void netxen_free_hw_resources(struct netxen_adapter *adapter);
  1167. void netxen_release_rx_buffers(struct netxen_adapter *adapter);
  1168. void netxen_release_tx_buffers(struct netxen_adapter *adapter);
  1169. void netxen_initialize_adapter_ops(struct netxen_adapter *adapter);
  1170. int netxen_init_firmware(struct netxen_adapter *adapter);
  1171. void netxen_nic_clear_stats(struct netxen_adapter *adapter);
  1172. void netxen_watchdog_task(struct work_struct *work);
  1173. void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ringid,
  1174. struct nx_host_rds_ring *rds_ring);
  1175. int netxen_process_cmd_ring(struct netxen_adapter *adapter);
  1176. int netxen_process_rcv_ring(struct nx_host_sds_ring *sds_ring, int max);
  1177. void netxen_p2_nic_set_multi(struct net_device *netdev);
  1178. void netxen_p3_nic_set_multi(struct net_device *netdev);
  1179. void netxen_p3_free_mac_list(struct netxen_adapter *adapter);
  1180. int netxen_p3_nic_set_promisc(struct netxen_adapter *adapter, u32);
  1181. int netxen_config_intr_coalesce(struct netxen_adapter *adapter);
  1182. int netxen_config_rss(struct netxen_adapter *adapter, int enable);
  1183. int netxen_linkevent_request(struct netxen_adapter *adapter, int enable);
  1184. void netxen_advert_link_change(struct netxen_adapter *adapter, int linkup);
  1185. int nx_fw_cmd_set_mtu(struct netxen_adapter *adapter, int mtu);
  1186. int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu);
  1187. int netxen_nic_set_mac(struct net_device *netdev, void *p);
  1188. struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev);
  1189. void netxen_nic_update_cmd_producer(struct netxen_adapter *adapter,
  1190. struct nx_host_tx_ring *tx_ring, uint32_t crb_producer);
  1191. /*
  1192. * NetXen Board information
  1193. */
  1194. #define NETXEN_MAX_SHORT_NAME 32
  1195. struct netxen_brdinfo {
  1196. int brdtype; /* type of board */
  1197. long ports; /* max no of physical ports */
  1198. char short_name[NETXEN_MAX_SHORT_NAME];
  1199. };
  1200. static const struct netxen_brdinfo netxen_boards[] = {
  1201. {NETXEN_BRDTYPE_P2_SB31_10G_CX4, 1, "XGb CX4"},
  1202. {NETXEN_BRDTYPE_P2_SB31_10G_HMEZ, 1, "XGb HMEZ"},
  1203. {NETXEN_BRDTYPE_P2_SB31_10G_IMEZ, 2, "XGb IMEZ"},
  1204. {NETXEN_BRDTYPE_P2_SB31_10G, 1, "XGb XFP"},
  1205. {NETXEN_BRDTYPE_P2_SB35_4G, 4, "Quad Gb"},
  1206. {NETXEN_BRDTYPE_P2_SB31_2G, 2, "Dual Gb"},
  1207. {NETXEN_BRDTYPE_P3_REF_QG, 4, "Reference Quad Gig "},
  1208. {NETXEN_BRDTYPE_P3_HMEZ, 2, "Dual XGb HMEZ"},
  1209. {NETXEN_BRDTYPE_P3_10G_CX4_LP, 2, "Dual XGb CX4 LP"},
  1210. {NETXEN_BRDTYPE_P3_4_GB, 4, "Quad Gig LP"},
  1211. {NETXEN_BRDTYPE_P3_IMEZ, 2, "Dual XGb IMEZ"},
  1212. {NETXEN_BRDTYPE_P3_10G_SFP_PLUS, 2, "Dual XGb SFP+ LP"},
  1213. {NETXEN_BRDTYPE_P3_10000_BASE_T, 1, "XGB 10G BaseT LP"},
  1214. {NETXEN_BRDTYPE_P3_XG_LOM, 2, "Dual XGb LOM"},
  1215. {NETXEN_BRDTYPE_P3_4_GB_MM, 4, "NX3031 Gigabit Ethernet"},
  1216. {NETXEN_BRDTYPE_P3_10G_SFP_CT, 2, "NX3031 10 Gigabit Ethernet"},
  1217. {NETXEN_BRDTYPE_P3_10G_SFP_QT, 2, "Quanta Dual XGb SFP+"},
  1218. {NETXEN_BRDTYPE_P3_10G_CX4, 2, "Reference Dual CX4 Option"},
  1219. {NETXEN_BRDTYPE_P3_10G_XFP, 1, "Reference Single XFP Option"}
  1220. };
  1221. #define NUM_SUPPORTED_BOARDS ARRAY_SIZE(netxen_boards)
  1222. static inline void get_brd_name_by_type(u32 type, char *name)
  1223. {
  1224. int i, found = 0;
  1225. for (i = 0; i < NUM_SUPPORTED_BOARDS; ++i) {
  1226. if (netxen_boards[i].brdtype == type) {
  1227. strcpy(name, netxen_boards[i].short_name);
  1228. found = 1;
  1229. break;
  1230. }
  1231. }
  1232. if (!found)
  1233. name = "Unknown";
  1234. }
  1235. static inline int
  1236. dma_watchdog_shutdown_request(struct netxen_adapter *adapter)
  1237. {
  1238. u32 ctrl;
  1239. /* check if already inactive */
  1240. ctrl = adapter->hw_read_wx(adapter,
  1241. NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL));
  1242. if (netxen_get_dma_watchdog_enabled(ctrl) == 0)
  1243. return 1;
  1244. /* Send the disable request */
  1245. netxen_set_dma_watchdog_disable_req(ctrl);
  1246. NXWR32(adapter, NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl);
  1247. return 0;
  1248. }
  1249. static inline int
  1250. dma_watchdog_shutdown_poll_result(struct netxen_adapter *adapter)
  1251. {
  1252. u32 ctrl;
  1253. ctrl = adapter->hw_read_wx(adapter,
  1254. NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL));
  1255. return (netxen_get_dma_watchdog_enabled(ctrl) == 0);
  1256. }
  1257. static inline int
  1258. dma_watchdog_wakeup(struct netxen_adapter *adapter)
  1259. {
  1260. u32 ctrl;
  1261. ctrl = adapter->hw_read_wx(adapter,
  1262. NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL));
  1263. if (netxen_get_dma_watchdog_enabled(ctrl))
  1264. return 1;
  1265. /* send the wakeup request */
  1266. netxen_set_dma_watchdog_enable_req(ctrl);
  1267. NXWR32(adapter, NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl);
  1268. return 0;
  1269. }
  1270. int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, __le64 *mac);
  1271. int netxen_p3_get_mac_addr(struct netxen_adapter *adapter, __le64 *mac);
  1272. extern void netxen_change_ringparam(struct netxen_adapter *adapter);
  1273. extern int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr,
  1274. int *valp);
  1275. extern struct ethtool_ops netxen_nic_ethtool_ops;
  1276. #endif /* __NETXEN_NIC_H_ */