diff options
Diffstat (limited to 'drivers/net/netxen/netxen_nic.h')
-rw-r--r-- | drivers/net/netxen/netxen_nic.h | 331 |
1 files changed, 241 insertions, 90 deletions
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h index 9c588af8ab74..b5410bee5f21 100644 --- a/drivers/net/netxen/netxen_nic.h +++ b/drivers/net/netxen/netxen_nic.h | |||
@@ -1,25 +1,25 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2003 - 2006 NetXen, Inc. | 2 | * Copyright (C) 2003 - 2006 NetXen, Inc. |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or | 5 | * This program is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU General Public License | 6 | * modify it under the terms of the GNU General Public License |
7 | * as published by the Free Software Foundation; either version 2 | 7 | * as published by the Free Software Foundation; either version 2 |
8 | * of the License, or (at your option) any later version. | 8 | * of the License, or (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, but | 10 | * This program is distributed in the hope that it will be useful, but |
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 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 | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, | 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
18 | * MA 02111-1307, USA. | 18 | * MA 02111-1307, USA. |
19 | * | 19 | * |
20 | * The full GNU General Public License is included in this distribution | 20 | * The full GNU General Public License is included in this distribution |
21 | * in the file called LICENSE. | 21 | * in the file called LICENSE. |
22 | * | 22 | * |
23 | * Contact Information: | 23 | * Contact Information: |
24 | * info@netxen.com | 24 | * info@netxen.com |
25 | * NetXen, | 25 | * NetXen, |
@@ -63,40 +63,68 @@ | |||
63 | 63 | ||
64 | #include "netxen_nic_hw.h" | 64 | #include "netxen_nic_hw.h" |
65 | 65 | ||
66 | #define NETXEN_NIC_BUILD_NO "5" | 66 | #define NETXEN_NIC_BUILD_NO "1" |
67 | #define _NETXEN_NIC_LINUX_MAJOR 2 | 67 | #define _NETXEN_NIC_LINUX_MAJOR 3 |
68 | #define _NETXEN_NIC_LINUX_MINOR 3 | 68 | #define _NETXEN_NIC_LINUX_MINOR 3 |
69 | #define _NETXEN_NIC_LINUX_SUBVERSION 59 | 69 | #define _NETXEN_NIC_LINUX_SUBVERSION 2 |
70 | #define NETXEN_NIC_LINUX_VERSIONID "2.3.59" "-" NETXEN_NIC_BUILD_NO | 70 | #define NETXEN_NIC_LINUX_VERSIONID "3.3.2" "-" NETXEN_NIC_BUILD_NO |
71 | #define NETXEN_NIC_FW_VERSIONID "2.3.59" | 71 | #define NETXEN_NIC_FW_VERSIONID "3.3.2" |
72 | 72 | ||
73 | #define RCV_DESC_RINGSIZE \ | 73 | #define RCV_DESC_RINGSIZE \ |
74 | (sizeof(struct rcv_desc) * adapter->max_rx_desc_count) | 74 | (sizeof(struct rcv_desc) * adapter->max_rx_desc_count) |
75 | #define STATUS_DESC_RINGSIZE \ | 75 | #define STATUS_DESC_RINGSIZE \ |
76 | (sizeof(struct status_desc)* adapter->max_rx_desc_count) | 76 | (sizeof(struct status_desc)* adapter->max_rx_desc_count) |
77 | #define LRO_DESC_RINGSIZE \ | ||
78 | (sizeof(rcvDesc_t) * adapter->max_lro_rx_desc_count) | ||
77 | #define TX_RINGSIZE \ | 79 | #define TX_RINGSIZE \ |
78 | (sizeof(struct netxen_cmd_buffer) * adapter->max_tx_desc_count) | 80 | (sizeof(struct netxen_cmd_buffer) * adapter->max_tx_desc_count) |
79 | #define RCV_BUFFSIZE \ | 81 | #define RCV_BUFFSIZE \ |
80 | (sizeof(struct netxen_rx_buffer) * rcv_desc->max_rx_desc_count) | 82 | (sizeof(struct netxen_rx_buffer) * rcv_desc->max_rx_desc_count) |
81 | #define find_diff_among(a,b,range) ((a)<(b)?((b)-(a)):((b)+(range)-(a))) | 83 | #define find_diff_among(a,b,range) ((a)<(b)?((b)-(a)):((b)+(range)-(a))) |
82 | 84 | ||
83 | #define NETXEN_NETDEV_STATUS 0x1 | 85 | #define NETXEN_NETDEV_STATUS 0x1 |
86 | #define NETXEN_RCV_PRODUCER_OFFSET 0 | ||
87 | #define NETXEN_RCV_PEG_DB_ID 2 | ||
88 | #define NETXEN_HOST_DUMMY_DMA_SIZE 1024 | ||
84 | 89 | ||
85 | #define ADDR_IN_WINDOW1(off) \ | 90 | #define ADDR_IN_WINDOW1(off) \ |
86 | ((off > NETXEN_CRB_PCIX_HOST2) && (off < NETXEN_CRB_MAX)) ? 1 : 0 | 91 | ((off > NETXEN_CRB_PCIX_HOST2) && (off < NETXEN_CRB_MAX)) ? 1 : 0 |
92 | /* | ||
93 | * In netxen_nic_down(), we must wait for any pending callback requests into | ||
94 | * netxen_watchdog_task() to complete; eg otherwise the watchdog_timer could be | ||
95 | * reenabled right after it is deleted in netxen_nic_down(). FLUSH_SCHEDULED_WORK() | ||
96 | * does this synchronization. | ||
97 | * | ||
98 | * Normally, schedule_work()/flush_scheduled_work() could have worked, but | ||
99 | * netxen_nic_close() is invoked with kernel rtnl lock held. netif_carrier_off() | ||
100 | * call in netxen_nic_close() triggers a schedule_work(&linkwatch_work), and a | ||
101 | * subsequent call to flush_scheduled_work() in netxen_nic_down() would cause | ||
102 | * linkwatch_event() to be executed which also attempts to acquire the rtnl | ||
103 | * lock thus causing a deadlock. | ||
104 | */ | ||
105 | |||
106 | #define SCHEDULE_WORK(tp) queue_work(netxen_workq, tp) | ||
107 | #define FLUSH_SCHEDULED_WORK() flush_workqueue(netxen_workq) | ||
108 | extern struct workqueue_struct *netxen_workq; | ||
87 | 109 | ||
88 | /* | 110 | /* |
89 | * normalize a 64MB crb address to 32MB PCI window | 111 | * normalize a 64MB crb address to 32MB PCI window |
90 | * To use NETXEN_CRB_NORMALIZE, window _must_ be set to 1 | 112 | * To use NETXEN_CRB_NORMALIZE, window _must_ be set to 1 |
91 | */ | 113 | */ |
92 | #define NETXEN_CRB_NORMAL(reg) \ | 114 | #define NETXEN_CRB_NORMAL(reg) \ |
93 | (reg) - NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST | 115 | ((reg) - NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST) |
94 | 116 | ||
95 | #define NETXEN_CRB_NORMALIZE(adapter, reg) \ | 117 | #define NETXEN_CRB_NORMALIZE(adapter, reg) \ |
96 | pci_base_offset(adapter, NETXEN_CRB_NORMAL(reg)) | 118 | pci_base_offset(adapter, NETXEN_CRB_NORMAL(reg)) |
97 | 119 | ||
120 | #define DB_NORMALIZE(adapter, off) \ | ||
121 | (adapter->ahw.db_base + (off)) | ||
122 | |||
123 | #define NX_P2_C0 0x24 | ||
124 | #define NX_P2_C1 0x25 | ||
125 | |||
98 | #define FIRST_PAGE_GROUP_START 0 | 126 | #define FIRST_PAGE_GROUP_START 0 |
99 | #define FIRST_PAGE_GROUP_END 0x400000 | 127 | #define FIRST_PAGE_GROUP_END 0x100000 |
100 | 128 | ||
101 | #define SECOND_PAGE_GROUP_START 0x4000000 | 129 | #define SECOND_PAGE_GROUP_START 0x4000000 |
102 | #define SECOND_PAGE_GROUP_END 0x66BC000 | 130 | #define SECOND_PAGE_GROUP_END 0x66BC000 |
@@ -108,11 +136,13 @@ | |||
108 | #define SECOND_PAGE_GROUP_SIZE SECOND_PAGE_GROUP_END - SECOND_PAGE_GROUP_START | 136 | #define SECOND_PAGE_GROUP_SIZE SECOND_PAGE_GROUP_END - SECOND_PAGE_GROUP_START |
109 | #define THIRD_PAGE_GROUP_SIZE THIRD_PAGE_GROUP_END - THIRD_PAGE_GROUP_START | 137 | #define THIRD_PAGE_GROUP_SIZE THIRD_PAGE_GROUP_END - THIRD_PAGE_GROUP_START |
110 | 138 | ||
111 | #define MAX_RX_BUFFER_LENGTH 2000 | 139 | #define MAX_RX_BUFFER_LENGTH 1760 |
112 | #define MAX_RX_JUMBO_BUFFER_LENGTH 9046 | 140 | #define MAX_RX_JUMBO_BUFFER_LENGTH 9046 |
113 | #define RX_DMA_MAP_LEN (MAX_RX_BUFFER_LENGTH - NET_IP_ALIGN) | 141 | #define MAX_RX_LRO_BUFFER_LENGTH ((48*1024)-512) |
142 | #define RX_DMA_MAP_LEN (MAX_RX_BUFFER_LENGTH - 2) | ||
114 | #define RX_JUMBO_DMA_MAP_LEN \ | 143 | #define RX_JUMBO_DMA_MAP_LEN \ |
115 | (MAX_RX_JUMBO_BUFFER_LENGTH - NET_IP_ALIGN) | 144 | (MAX_RX_JUMBO_BUFFER_LENGTH - 2) |
145 | #define RX_LRO_DMA_MAP_LEN (MAX_RX_LRO_BUFFER_LENGTH - 2) | ||
116 | #define NETXEN_ROM_ROUNDUP 0x80000000ULL | 146 | #define NETXEN_ROM_ROUNDUP 0x80000000ULL |
117 | 147 | ||
118 | /* | 148 | /* |
@@ -151,30 +181,38 @@ enum { | |||
151 | /* Host writes the following to notify that it has done the init-handshake */ | 181 | /* Host writes the following to notify that it has done the init-handshake */ |
152 | #define PHAN_INITIALIZE_ACK 0xf00f | 182 | #define PHAN_INITIALIZE_ACK 0xf00f |
153 | 183 | ||
154 | #define NUM_RCV_DESC_RINGS 2 /* No of Rcv Descriptor contexts */ | 184 | #define NUM_RCV_DESC_RINGS 3 /* No of Rcv Descriptor contexts */ |
155 | 185 | ||
156 | /* descriptor types */ | 186 | /* descriptor types */ |
157 | #define RCV_DESC_NORMAL 0x01 | 187 | #define RCV_DESC_NORMAL 0x01 |
158 | #define RCV_DESC_JUMBO 0x02 | 188 | #define RCV_DESC_JUMBO 0x02 |
189 | #define RCV_DESC_LRO 0x04 | ||
159 | #define RCV_DESC_NORMAL_CTXID 0 | 190 | #define RCV_DESC_NORMAL_CTXID 0 |
160 | #define RCV_DESC_JUMBO_CTXID 1 | 191 | #define RCV_DESC_JUMBO_CTXID 1 |
192 | #define RCV_DESC_LRO_CTXID 2 | ||
161 | 193 | ||
162 | #define RCV_DESC_TYPE(ID) \ | 194 | #define RCV_DESC_TYPE(ID) \ |
163 | ((ID == RCV_DESC_JUMBO_CTXID) ? RCV_DESC_JUMBO : RCV_DESC_NORMAL) | 195 | ((ID == RCV_DESC_JUMBO_CTXID) \ |
196 | ? RCV_DESC_JUMBO \ | ||
197 | : ((ID == RCV_DESC_LRO_CTXID) \ | ||
198 | ? RCV_DESC_LRO : \ | ||
199 | (RCV_DESC_NORMAL))) | ||
164 | 200 | ||
165 | #define MAX_CMD_DESCRIPTORS 1024 | 201 | #define MAX_CMD_DESCRIPTORS 1024 |
166 | #define MAX_RCV_DESCRIPTORS 32768 | 202 | #define MAX_RCV_DESCRIPTORS 32768 |
167 | #define MAX_JUMBO_RCV_DESCRIPTORS 1024 | 203 | #define MAX_JUMBO_RCV_DESCRIPTORS 4096 |
204 | #define MAX_LRO_RCV_DESCRIPTORS 2048 | ||
168 | #define MAX_RCVSTATUS_DESCRIPTORS MAX_RCV_DESCRIPTORS | 205 | #define MAX_RCVSTATUS_DESCRIPTORS MAX_RCV_DESCRIPTORS |
169 | #define MAX_JUMBO_RCV_DESC MAX_JUMBO_RCV_DESCRIPTORS | 206 | #define MAX_JUMBO_RCV_DESC MAX_JUMBO_RCV_DESCRIPTORS |
170 | #define MAX_RCV_DESC MAX_RCV_DESCRIPTORS | 207 | #define MAX_RCV_DESC MAX_RCV_DESCRIPTORS |
171 | #define MAX_RCVSTATUS_DESC MAX_RCV_DESCRIPTORS | 208 | #define MAX_RCVSTATUS_DESC MAX_RCV_DESCRIPTORS |
172 | #define NUM_RCV_DESC (MAX_RCV_DESC + MAX_JUMBO_RCV_DESCRIPTORS) | ||
173 | #define MAX_EPG_DESCRIPTORS (MAX_CMD_DESCRIPTORS * 8) | 209 | #define MAX_EPG_DESCRIPTORS (MAX_CMD_DESCRIPTORS * 8) |
174 | 210 | #define NUM_RCV_DESC (MAX_RCV_DESC + MAX_JUMBO_RCV_DESCRIPTORS + \ | |
211 | MAX_LRO_RCV_DESCRIPTORS) | ||
175 | #define MIN_TX_COUNT 4096 | 212 | #define MIN_TX_COUNT 4096 |
176 | #define MIN_RX_COUNT 4096 | 213 | #define MIN_RX_COUNT 4096 |
177 | 214 | #define NETXEN_CTX_SIGNATURE 0xdee0 | |
215 | #define NETXEN_RCV_PRODUCER(ringid) (ringid) | ||
178 | #define MAX_FRAME_SIZE 0x10000 /* 64K MAX size for LSO */ | 216 | #define MAX_FRAME_SIZE 0x10000 /* 64K MAX size for LSO */ |
179 | 217 | ||
180 | #define PHAN_PEG_RCV_INITIALIZED 0xff01 | 218 | #define PHAN_PEG_RCV_INITIALIZED 0xff01 |
@@ -186,6 +224,67 @@ enum { | |||
186 | #define get_index_range(index,length,count) \ | 224 | #define get_index_range(index,length,count) \ |
187 | (((index) + (count)) & ((length) - 1)) | 225 | (((index) + (count)) & ((length) - 1)) |
188 | 226 | ||
227 | #define MPORT_SINGLE_FUNCTION_MODE 0x1111 | ||
228 | |||
229 | extern unsigned long long netxen_dma_mask; | ||
230 | |||
231 | /* | ||
232 | * NetXen host-peg signal message structure | ||
233 | * | ||
234 | * Bit 0-1 : peg_id => 0x2 for tx and 01 for rx | ||
235 | * Bit 2 : priv_id => must be 1 | ||
236 | * Bit 3-17 : count => for doorbell | ||
237 | * Bit 18-27 : ctx_id => Context id | ||
238 | * Bit 28-31 : opcode | ||
239 | */ | ||
240 | |||
241 | typedef u32 netxen_ctx_msg; | ||
242 | |||
243 | #define _netxen_set_bits(config_word, start, bits, val) {\ | ||
244 | unsigned long long mask = (((1ULL << (bits)) - 1) << (start)); \ | ||
245 | unsigned long long value = (val); \ | ||
246 | (config_word) &= ~mask; \ | ||
247 | (config_word) |= (((value) << (start)) & mask); \ | ||
248 | } | ||
249 | |||
250 | #define netxen_set_msg_peg_id(config_word, val) \ | ||
251 | _netxen_set_bits(config_word, 0, 2, val) | ||
252 | #define netxen_set_msg_privid(config_word) \ | ||
253 | set_bit(2, (unsigned long*)&config_word) | ||
254 | #define netxen_set_msg_count(config_word, val) \ | ||
255 | _netxen_set_bits(config_word, 3, 15, val) | ||
256 | #define netxen_set_msg_ctxid(config_word, val) \ | ||
257 | _netxen_set_bits(config_word, 18, 10, val) | ||
258 | #define netxen_set_msg_opcode(config_word, val) \ | ||
259 | _netxen_set_bits(config_word, 28, 4, val) | ||
260 | |||
261 | struct netxen_rcv_context { | ||
262 | u32 rcv_ring_addr_lo; | ||
263 | u32 rcv_ring_addr_hi; | ||
264 | u32 rcv_ring_size; | ||
265 | u32 rsrvd; | ||
266 | }; | ||
267 | |||
268 | struct netxen_ring_ctx { | ||
269 | |||
270 | /* one command ring */ | ||
271 | u64 cmd_consumer_offset; | ||
272 | u32 cmd_ring_addr_lo; | ||
273 | u32 cmd_ring_addr_hi; | ||
274 | u32 cmd_ring_size; | ||
275 | u32 rsrvd; | ||
276 | |||
277 | /* three receive rings */ | ||
278 | struct netxen_rcv_context rcv_ctx[3]; | ||
279 | |||
280 | /* one status ring */ | ||
281 | u32 sts_ring_addr_lo; | ||
282 | u32 sts_ring_addr_hi; | ||
283 | u32 sts_ring_size; | ||
284 | |||
285 | u32 ctx_id; | ||
286 | } __attribute__ ((aligned(64))); | ||
287 | |||
189 | /* | 288 | /* |
190 | * Following data structures describe the descriptors that will be used. | 289 | * Following data structures describe the descriptors that will be used. |
191 | * Added fileds of tcpHdrSize and ipHdrSize, The driver needs to do it only when | 290 | * Added fileds of tcpHdrSize and ipHdrSize, The driver needs to do it only when |
@@ -203,22 +302,32 @@ enum { | |||
203 | #define FLAGS_IPSEC_SA_DELETE 0x08 | 302 | #define FLAGS_IPSEC_SA_DELETE 0x08 |
204 | #define FLAGS_VLAN_TAGGED 0x10 | 303 | #define FLAGS_VLAN_TAGGED 0x10 |
205 | 304 | ||
206 | #define CMD_DESC_TOTAL_LENGTH(cmd_desc) \ | 305 | #define netxen_set_cmd_desc_port(cmd_desc, var) \ |
207 | ((cmd_desc)->length_tcp_hdr & 0x00FFFFFF) | 306 | ((cmd_desc)->port_ctxid |= ((var) & 0x0F)) |
208 | #define CMD_DESC_TCP_HDR_OFFSET(cmd_desc) \ | ||
209 | (((cmd_desc)->length_tcp_hdr >> 24) & 0x0FF) | ||
210 | #define CMD_DESC_PORT(cmd_desc) ((cmd_desc)->port_ctxid & 0x0F) | ||
211 | #define CMD_DESC_CTX_ID(cmd_desc) (((cmd_desc)->port_ctxid >> 4) & 0x0F) | ||
212 | 307 | ||
213 | #define CMD_DESC_TOTAL_LENGTH_WRT(cmd_desc, var) \ | 308 | #define netxen_set_cmd_desc_flags(cmd_desc, val) \ |
214 | ((cmd_desc)->length_tcp_hdr |= ((var) & 0x00FFFFFF)) | 309 | _netxen_set_bits((cmd_desc)->flags_opcode, 0, 7, val) |
215 | #define CMD_DESC_TCP_HDR_OFFSET_WRT(cmd_desc, var) \ | 310 | #define netxen_set_cmd_desc_opcode(cmd_desc, val) \ |
216 | ((cmd_desc)->length_tcp_hdr |= (((var) << 24) & 0xFF000000)) | 311 | _netxen_set_bits((cmd_desc)->flags_opcode, 7, 6, val) |
217 | #define CMD_DESC_PORT_WRT(cmd_desc, var) \ | 312 | |
218 | ((cmd_desc)->port_ctxid |= ((var) & 0x0F)) | 313 | #define netxen_set_cmd_desc_num_of_buff(cmd_desc, val) \ |
314 | _netxen_set_bits((cmd_desc)->num_of_buffers_total_length, 0, 8, val); | ||
315 | #define netxen_set_cmd_desc_totallength(cmd_desc, val) \ | ||
316 | _netxen_set_bits((cmd_desc)->num_of_buffers_total_length, 8, 24, val); | ||
317 | |||
318 | #define netxen_get_cmd_desc_opcode(cmd_desc) \ | ||
319 | (((cmd_desc)->flags_opcode >> 7) & 0x003F) | ||
320 | #define netxen_get_cmd_desc_totallength(cmd_desc) \ | ||
321 | (((cmd_desc)->num_of_buffers_total_length >> 8) & 0x0FFFFFF) | ||
219 | 322 | ||
220 | struct cmd_desc_type0 { | 323 | struct cmd_desc_type0 { |
221 | u64 netxen_next; /* for fragments handled by Phantom */ | 324 | u8 tcp_hdr_offset; /* For LSO only */ |
325 | u8 ip_hdr_offset; /* For LSO only */ | ||
326 | /* Bit pattern: 0-6 flags, 7-12 opcode, 13-15 unused */ | ||
327 | u16 flags_opcode; | ||
328 | /* Bit pattern: 0-7 total number of segments, | ||
329 | 8-31 Total size of the packet */ | ||
330 | u32 num_of_buffers_total_length; | ||
222 | union { | 331 | union { |
223 | struct { | 332 | struct { |
224 | u32 addr_low_part2; | 333 | u32 addr_low_part2; |
@@ -227,13 +336,6 @@ struct cmd_desc_type0 { | |||
227 | u64 addr_buffer2; | 336 | u64 addr_buffer2; |
228 | }; | 337 | }; |
229 | 338 | ||
230 | /* Bit pattern: 0-23 total length, 24-32 tcp header offset */ | ||
231 | u32 length_tcp_hdr; | ||
232 | u8 ip_hdr_offset; /* For LSO only */ | ||
233 | u8 num_of_buffers; /* total number of segments */ | ||
234 | u8 flags; /* as defined above */ | ||
235 | u8 opcode; | ||
236 | |||
237 | u16 reference_handle; /* changed to u16 to add mss */ | 339 | u16 reference_handle; /* changed to u16 to add mss */ |
238 | u16 mss; /* passed by NDIS_PACKET for LSO */ | 340 | u16 mss; /* passed by NDIS_PACKET for LSO */ |
239 | /* Bit pattern 0-3 port, 0-3 ctx id */ | 341 | /* Bit pattern 0-3 port, 0-3 ctx id */ |
@@ -248,7 +350,6 @@ struct cmd_desc_type0 { | |||
248 | }; | 350 | }; |
249 | u64 addr_buffer3; | 351 | u64 addr_buffer3; |
250 | }; | 352 | }; |
251 | |||
252 | union { | 353 | union { |
253 | struct { | 354 | struct { |
254 | u32 addr_low_part1; | 355 | u32 addr_low_part1; |
@@ -270,6 +371,8 @@ struct cmd_desc_type0 { | |||
270 | u64 addr_buffer4; | 371 | u64 addr_buffer4; |
271 | }; | 372 | }; |
272 | 373 | ||
374 | u64 unused; | ||
375 | |||
273 | } __attribute__ ((aligned(64))); | 376 | } __attribute__ ((aligned(64))); |
274 | 377 | ||
275 | /* Note: sizeof(rcv_desc) should always be a mutliple of 2 */ | 378 | /* Note: sizeof(rcv_desc) should always be a mutliple of 2 */ |
@@ -296,22 +399,49 @@ struct rcv_desc { | |||
296 | #define NETXEN_PROT_UNKNOWN (0) | 399 | #define NETXEN_PROT_UNKNOWN (0) |
297 | 400 | ||
298 | /* Note: sizeof(status_desc) should always be a mutliple of 2 */ | 401 | /* Note: sizeof(status_desc) should always be a mutliple of 2 */ |
299 | #define STATUS_DESC_PORT(status_desc) \ | 402 | |
300 | ((status_desc)->port_status_type_op & 0x0F) | 403 | #define netxen_get_sts_desc_lro_cnt(status_desc) \ |
301 | #define STATUS_DESC_STATUS(status_desc) \ | 404 | ((status_desc)->lro & 0x7F) |
302 | (((status_desc)->port_status_type_op >> 4) & 0x0F) | 405 | #define netxen_get_sts_desc_lro_last_frag(status_desc) \ |
303 | #define STATUS_DESC_TYPE(status_desc) \ | 406 | (((status_desc)->lro & 0x80) >> 7) |
304 | (((status_desc)->port_status_type_op >> 8) & 0x0F) | 407 | |
305 | #define STATUS_DESC_OPCODE(status_desc) \ | 408 | #define netxen_get_sts_port(status_desc) \ |
306 | (((status_desc)->port_status_type_op >> 12) & 0x0F) | 409 | ((status_desc)->status_desc_data & 0x0F) |
410 | #define netxen_get_sts_status(status_desc) \ | ||
411 | (((status_desc)->status_desc_data >> 4) & 0x0F) | ||
412 | #define netxen_get_sts_type(status_desc) \ | ||
413 | (((status_desc)->status_desc_data >> 8) & 0x0F) | ||
414 | #define netxen_get_sts_totallength(status_desc) \ | ||
415 | (((status_desc)->status_desc_data >> 12) & 0xFFFF) | ||
416 | #define netxen_get_sts_refhandle(status_desc) \ | ||
417 | (((status_desc)->status_desc_data >> 28) & 0xFFFF) | ||
418 | #define netxen_get_sts_prot(status_desc) \ | ||
419 | (((status_desc)->status_desc_data >> 44) & 0x0F) | ||
420 | #define netxen_get_sts_owner(status_desc) \ | ||
421 | (((status_desc)->status_desc_data >> 56) & 0x03) | ||
422 | #define netxen_get_sts_opcode(status_desc) \ | ||
423 | (((status_desc)->status_desc_data >> 58) & 0x03F) | ||
424 | |||
425 | #define netxen_clear_sts_owner(status_desc) \ | ||
426 | ((status_desc)->status_desc_data &= \ | ||
427 | ~(((unsigned long long)3) << 56 )) | ||
428 | #define netxen_set_sts_owner(status_desc, val) \ | ||
429 | ((status_desc)->status_desc_data |= \ | ||
430 | (((unsigned long long)((val) & 0x3)) << 56 )) | ||
307 | 431 | ||
308 | struct status_desc { | 432 | struct status_desc { |
309 | /* Bit pattern: 0-3 port, 4-7 status, 8-11 type, 12-15 opcode */ | 433 | /* Bit pattern: 0-3 port, 4-7 status, 8-11 type, 12-27 total_length |
310 | u16 port_status_type_op; | 434 | 28-43 reference_handle, 44-47 protocol, 48-52 unused |
311 | u16 total_length; /* NIC mode */ | 435 | 53-55 desc_cnt, 56-57 owner, 58-63 opcode |
312 | u16 reference_handle; /* handle for the associated packet */ | 436 | */ |
313 | /* Bit pattern: 0-1 owner, 2-5 protocol */ | 437 | u64 status_desc_data; |
314 | u16 owner; /* Owner of the descriptor */ | 438 | u32 hash_value; |
439 | u8 hash_type; | ||
440 | u8 msg_type; | ||
441 | u8 unused; | ||
442 | /* Bit pattern: 0-6 lro_count indicates frag sequence, | ||
443 | 7 last_frag indicates last frag */ | ||
444 | u8 lro; | ||
315 | } __attribute__ ((aligned(8))); | 445 | } __attribute__ ((aligned(8))); |
316 | 446 | ||
317 | enum { | 447 | enum { |
@@ -559,11 +689,12 @@ typedef enum { | |||
559 | #define PRIMARY_START (BOOTLD_START) | 689 | #define PRIMARY_START (BOOTLD_START) |
560 | #define FLASH_CRBINIT_SIZE (0x4000) | 690 | #define FLASH_CRBINIT_SIZE (0x4000) |
561 | #define FLASH_BRDCFG_SIZE (sizeof(struct netxen_board_info)) | 691 | #define FLASH_BRDCFG_SIZE (sizeof(struct netxen_board_info)) |
562 | #define FLASH_USER_SIZE (sizeof(netxen_user_info)/sizeof(u32)) | 692 | #define FLASH_USER_SIZE (sizeof(struct netxen_user_info)/sizeof(u32)) |
563 | #define FLASH_SECONDARY_SIZE (USER_START-SECONDARY_START) | 693 | #define FLASH_SECONDARY_SIZE (USER_START-SECONDARY_START) |
564 | #define NUM_PRIMARY_SECTORS (0x20) | 694 | #define NUM_PRIMARY_SECTORS (0x20) |
565 | #define NUM_CONFIG_SECTORS (1) | 695 | #define NUM_CONFIG_SECTORS (1) |
566 | #define PFX "netxen: " | 696 | #define PFX "NetXen: " |
697 | extern char netxen_nic_driver_name[]; | ||
567 | 698 | ||
568 | /* Note: Make sure to not call this before adapter->port is valid */ | 699 | /* Note: Make sure to not call this before adapter->port is valid */ |
569 | #if !defined(NETXEN_DEBUG) | 700 | #if !defined(NETXEN_DEBUG) |
@@ -572,7 +703,7 @@ typedef enum { | |||
572 | #else | 703 | #else |
573 | #define DPRINTK(klevel, fmt, args...) do { \ | 704 | #define DPRINTK(klevel, fmt, args...) do { \ |
574 | printk(KERN_##klevel PFX "%s: %s: " fmt, __FUNCTION__,\ | 705 | printk(KERN_##klevel PFX "%s: %s: " fmt, __FUNCTION__,\ |
575 | (adapter != NULL && adapter->port != NULL && \ | 706 | (adapter != NULL && \ |
576 | adapter->port[0] != NULL && \ | 707 | adapter->port[0] != NULL && \ |
577 | adapter->port[0]->netdev != NULL) ? \ | 708 | adapter->port[0]->netdev != NULL) ? \ |
578 | adapter->port[0]->netdev->name : NULL, \ | 709 | adapter->port[0]->netdev->name : NULL, \ |
@@ -609,7 +740,6 @@ struct netxen_cmd_buffer { | |||
609 | u8 frag_count; | 740 | u8 frag_count; |
610 | unsigned long time_stamp; | 741 | unsigned long time_stamp; |
611 | u32 state; | 742 | u32 state; |
612 | u32 no_of_descriptors; | ||
613 | }; | 743 | }; |
614 | 744 | ||
615 | /* In rx_buffer, we do not need multiple fragments as is a single buffer */ | 745 | /* In rx_buffer, we do not need multiple fragments as is a single buffer */ |
@@ -618,6 +748,9 @@ struct netxen_rx_buffer { | |||
618 | u64 dma; | 748 | u64 dma; |
619 | u16 ref_handle; | 749 | u16 ref_handle; |
620 | u16 state; | 750 | u16 state; |
751 | u32 lro_expected_frags; | ||
752 | u32 lro_current_frags; | ||
753 | u32 lro_length; | ||
621 | }; | 754 | }; |
622 | 755 | ||
623 | /* Board types */ | 756 | /* Board types */ |
@@ -633,6 +766,8 @@ struct netxen_hardware_context { | |||
633 | void __iomem *pci_base0; | 766 | void __iomem *pci_base0; |
634 | void __iomem *pci_base1; | 767 | void __iomem *pci_base1; |
635 | void __iomem *pci_base2; | 768 | void __iomem *pci_base2; |
769 | void __iomem *db_base; | ||
770 | unsigned long db_len; | ||
636 | 771 | ||
637 | u8 revision_id; | 772 | u8 revision_id; |
638 | u16 board_type; | 773 | u16 board_type; |
@@ -642,14 +777,13 @@ struct netxen_hardware_context { | |||
642 | u32 qg_linksup; | 777 | u32 qg_linksup; |
643 | /* Address of cmd ring in Phantom */ | 778 | /* Address of cmd ring in Phantom */ |
644 | struct cmd_desc_type0 *cmd_desc_head; | 779 | struct cmd_desc_type0 *cmd_desc_head; |
645 | char *pauseaddr; | ||
646 | struct pci_dev *cmd_desc_pdev; | 780 | struct pci_dev *cmd_desc_pdev; |
647 | dma_addr_t cmd_desc_phys_addr; | 781 | dma_addr_t cmd_desc_phys_addr; |
648 | dma_addr_t pause_physaddr; | ||
649 | struct pci_dev *pause_pdev; | ||
650 | struct netxen_adapter *adapter; | 782 | struct netxen_adapter *adapter; |
651 | }; | 783 | }; |
652 | 784 | ||
785 | #define RCV_RING_LRO RCV_DESC_LRO | ||
786 | |||
653 | #define MINIMUM_ETHERNET_FRAME_SIZE 64 /* With FCS */ | 787 | #define MINIMUM_ETHERNET_FRAME_SIZE 64 /* With FCS */ |
654 | #define ETHERNET_FCS_SIZE 4 | 788 | #define ETHERNET_FCS_SIZE 4 |
655 | 789 | ||
@@ -702,8 +836,13 @@ struct netxen_recv_context { | |||
702 | }; | 836 | }; |
703 | 837 | ||
704 | #define NETXEN_NIC_MSI_ENABLED 0x02 | 838 | #define NETXEN_NIC_MSI_ENABLED 0x02 |
839 | #define NETXEN_DMA_MASK 0xfffffffe | ||
840 | #define NETXEN_DB_MAPSIZE_BYTES 0x1000 | ||
705 | 841 | ||
706 | struct netxen_drvops; | 842 | struct netxen_dummy_dma { |
843 | void *addr; | ||
844 | dma_addr_t phys_addr; | ||
845 | }; | ||
707 | 846 | ||
708 | struct netxen_adapter { | 847 | struct netxen_adapter { |
709 | struct netxen_hardware_context ahw; | 848 | struct netxen_hardware_context ahw; |
@@ -720,12 +859,13 @@ struct netxen_adapter { | |||
720 | u32 curr_window; | 859 | u32 curr_window; |
721 | 860 | ||
722 | u32 cmd_producer; | 861 | u32 cmd_producer; |
723 | u32 cmd_consumer; | 862 | u32 *cmd_consumer; |
724 | 863 | ||
725 | u32 last_cmd_consumer; | 864 | u32 last_cmd_consumer; |
726 | u32 max_tx_desc_count; | 865 | u32 max_tx_desc_count; |
727 | u32 max_rx_desc_count; | 866 | u32 max_rx_desc_count; |
728 | u32 max_jumbo_rx_desc_count; | 867 | u32 max_jumbo_rx_desc_count; |
868 | u32 max_lro_rx_desc_count; | ||
729 | /* Num of instances active on cmd buffer ring */ | 869 | /* Num of instances active on cmd buffer ring */ |
730 | u32 proc_cmd_buf_counter; | 870 | u32 proc_cmd_buf_counter; |
731 | 871 | ||
@@ -747,8 +887,27 @@ struct netxen_adapter { | |||
747 | struct netxen_recv_context recv_ctx[MAX_RCV_CTX]; | 887 | struct netxen_recv_context recv_ctx[MAX_RCV_CTX]; |
748 | 888 | ||
749 | int is_up; | 889 | int is_up; |
750 | int work_done; | 890 | int number; |
751 | struct netxen_drvops *ops; | 891 | struct netxen_dummy_dma dummy_dma; |
892 | |||
893 | /* Context interface shared between card and host */ | ||
894 | struct netxen_ring_ctx *ctx_desc; | ||
895 | struct pci_dev *ctx_desc_pdev; | ||
896 | dma_addr_t ctx_desc_phys_addr; | ||
897 | int (*enable_phy_interrupts) (struct netxen_adapter *, int); | ||
898 | int (*disable_phy_interrupts) (struct netxen_adapter *, int); | ||
899 | void (*handle_phy_intr) (struct netxen_adapter *); | ||
900 | int (*macaddr_set) (struct netxen_port *, netxen_ethernet_macaddr_t); | ||
901 | int (*set_mtu) (struct netxen_port *, int); | ||
902 | int (*set_promisc) (struct netxen_adapter *, int, | ||
903 | netxen_niu_prom_mode_t); | ||
904 | int (*unset_promisc) (struct netxen_adapter *, int, | ||
905 | netxen_niu_prom_mode_t); | ||
906 | int (*phy_read) (struct netxen_adapter *, long phy, long reg, u32 *); | ||
907 | int (*phy_write) (struct netxen_adapter *, long phy, long reg, u32 val); | ||
908 | int (*init_port) (struct netxen_adapter *, int); | ||
909 | void (*init_niu) (struct netxen_adapter *); | ||
910 | int (*stop_port) (struct netxen_adapter *, int); | ||
752 | }; /* netxen_adapter structure */ | 911 | }; /* netxen_adapter structure */ |
753 | 912 | ||
754 | /* Max number of xmit producer threads that can run simultaneously */ | 913 | /* Max number of xmit producer threads that can run simultaneously */ |
@@ -830,25 +989,6 @@ static inline void __iomem *pci_base(struct netxen_adapter *adapter, | |||
830 | return NULL; | 989 | return NULL; |
831 | } | 990 | } |
832 | 991 | ||
833 | struct netxen_drvops { | ||
834 | int (*enable_phy_interrupts) (struct netxen_adapter *, int); | ||
835 | int (*disable_phy_interrupts) (struct netxen_adapter *, int); | ||
836 | void (*handle_phy_intr) (struct netxen_adapter *); | ||
837 | int (*macaddr_set) (struct netxen_port *, netxen_ethernet_macaddr_t); | ||
838 | int (*set_mtu) (struct netxen_port *, int); | ||
839 | int (*set_promisc) (struct netxen_adapter *, int, | ||
840 | netxen_niu_prom_mode_t); | ||
841 | int (*unset_promisc) (struct netxen_adapter *, int, | ||
842 | netxen_niu_prom_mode_t); | ||
843 | int (*phy_read) (struct netxen_adapter *, long phy, long reg, u32 *); | ||
844 | int (*phy_write) (struct netxen_adapter *, long phy, long reg, u32 val); | ||
845 | int (*init_port) (struct netxen_adapter *, int); | ||
846 | void (*init_niu) (struct netxen_adapter *); | ||
847 | int (*stop_port) (struct netxen_adapter *, int); | ||
848 | }; | ||
849 | |||
850 | extern char netxen_nic_driver_name[]; | ||
851 | |||
852 | int netxen_niu_xgbe_enable_phy_interrupts(struct netxen_adapter *adapter, | 992 | int netxen_niu_xgbe_enable_phy_interrupts(struct netxen_adapter *adapter, |
853 | int port); | 993 | int port); |
854 | int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter, | 994 | int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter, |
@@ -887,10 +1027,20 @@ int netxen_nic_hw_read_wx(struct netxen_adapter *adapter, u64 off, void *data, | |||
887 | int len); | 1027 | int len); |
888 | int netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off, void *data, | 1028 | int netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off, void *data, |
889 | int len); | 1029 | int len); |
1030 | int netxen_nic_hw_read_ioctl(struct netxen_adapter *adapter, u64 off, | ||
1031 | void *data, int len); | ||
1032 | int netxen_nic_hw_write_ioctl(struct netxen_adapter *adapter, u64 off, | ||
1033 | void *data, int len); | ||
1034 | int netxen_nic_pci_mem_write_ioctl(struct netxen_adapter *adapter, | ||
1035 | u64 off, void *data, int size); | ||
1036 | int netxen_nic_pci_mem_read_ioctl(struct netxen_adapter *adapter, | ||
1037 | u64 off, void *data, int size); | ||
890 | void netxen_crb_writelit_adapter(struct netxen_adapter *adapter, | 1038 | void netxen_crb_writelit_adapter(struct netxen_adapter *adapter, |
891 | unsigned long off, int data); | 1039 | unsigned long off, int data); |
892 | 1040 | ||
893 | /* Functions from netxen_nic_init.c */ | 1041 | /* Functions from netxen_nic_init.c */ |
1042 | void netxen_free_adapter_offload(struct netxen_adapter *adapter); | ||
1043 | int netxen_initialize_adapter_offload(struct netxen_adapter *adapter); | ||
894 | void netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val); | 1044 | void netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val); |
895 | void netxen_load_firmware(struct netxen_adapter *adapter); | 1045 | void netxen_load_firmware(struct netxen_adapter *adapter); |
896 | int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose); | 1046 | int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose); |
@@ -925,7 +1075,9 @@ int netxen_nic_tx_has_work(struct netxen_adapter *adapter); | |||
925 | void netxen_watchdog_task(struct work_struct *work); | 1075 | void netxen_watchdog_task(struct work_struct *work); |
926 | void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, | 1076 | void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, |
927 | u32 ringid); | 1077 | u32 ringid); |
928 | void netxen_process_cmd_ring(unsigned long data); | 1078 | void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, u32 ctx, |
1079 | u32 ringid); | ||
1080 | int netxen_process_cmd_ring(unsigned long data); | ||
929 | u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctx, int max); | 1081 | u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctx, int max); |
930 | void netxen_nic_set_multi(struct net_device *netdev); | 1082 | void netxen_nic_set_multi(struct net_device *netdev); |
931 | int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu); | 1083 | int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu); |
@@ -1019,7 +1171,6 @@ static inline void get_brd_name_by_type(u32 type, char *name) | |||
1019 | 1171 | ||
1020 | int netxen_is_flash_supported(struct netxen_adapter *adapter); | 1172 | int netxen_is_flash_supported(struct netxen_adapter *adapter); |
1021 | int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, u64 mac[]); | 1173 | int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, u64 mac[]); |
1022 | |||
1023 | extern void netxen_change_ringparam(struct netxen_adapter *adapter); | 1174 | extern void netxen_change_ringparam(struct netxen_adapter *adapter); |
1024 | extern int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr, | 1175 | extern int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr, |
1025 | int *valp); | 1176 | int *valp); |