diff options
author | raghavendra.koushik@neterion.com <raghavendra.koushik@neterion.com> | 2005-08-03 15:24:33 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-08-11 00:10:44 -0400 |
commit | 20346722ec474245446bcbf460594a935a5c0512 (patch) | |
tree | ab907a8c754fce58a97a0da9b4f19424c64eefde /drivers/net/s2io.h | |
parent | cd04b947bc674f8fc9cac38ec30497bae5d664ad (diff) |
[PATCH] S2io: Code cleanup
Hi,
We are submitting a series of 13 patches to support our Xframe I and
Xframe II line of products. The patches can be categorized as follows:
Patches 1-8 : Changes applicable to both Xframe I and II
Patches 9-11: Xframe II specific features
Patch 12: Addresses issues found during testing cycle.
Patch 13: Incorpoates mostly the review comments from community
and some last moment bug fixes.
Please review the patches and let us know your comments.
Starting with patch 1 below.
This patch involves cosmetic changes(tabs and indentation,
regrouping of transmit and receive data structures, typecasting,
code cleanup).
Signed-off-by: Ravinandan Arakali <ravinandan.arakali@neterion.com>
Signed-off-by: Raghavendra Koushik <raghavendra.koushik@neterion.com>
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
Diffstat (limited to 'drivers/net/s2io.h')
-rw-r--r-- | drivers/net/s2io.h | 286 |
1 files changed, 171 insertions, 115 deletions
diff --git a/drivers/net/s2io.h b/drivers/net/s2io.h index 1711c8c3dc99..4d2fc7a40434 100644 --- a/drivers/net/s2io.h +++ b/drivers/net/s2io.h | |||
@@ -31,6 +31,9 @@ | |||
31 | #define SUCCESS 0 | 31 | #define SUCCESS 0 |
32 | #define FAILURE -1 | 32 | #define FAILURE -1 |
33 | 33 | ||
34 | /* Maximum time to flicker LED when asked to identify NIC using ethtool */ | ||
35 | #define MAX_FLICKER_TIME 60000 /* 60 Secs */ | ||
36 | |||
34 | /* Maximum outstanding splits to be configured into xena. */ | 37 | /* Maximum outstanding splits to be configured into xena. */ |
35 | typedef enum xena_max_outstanding_splits { | 38 | typedef enum xena_max_outstanding_splits { |
36 | XENA_ONE_SPLIT_TRANSACTION = 0, | 39 | XENA_ONE_SPLIT_TRANSACTION = 0, |
@@ -45,10 +48,10 @@ typedef enum xena_max_outstanding_splits { | |||
45 | #define XENA_MAX_OUTSTANDING_SPLITS(n) (n << 4) | 48 | #define XENA_MAX_OUTSTANDING_SPLITS(n) (n << 4) |
46 | 49 | ||
47 | /* OS concerned variables and constants */ | 50 | /* OS concerned variables and constants */ |
48 | #define WATCH_DOG_TIMEOUT 5*HZ | 51 | #define WATCH_DOG_TIMEOUT 15*HZ |
49 | #define EFILL 0x1234 | 52 | #define EFILL 0x1234 |
50 | #define ALIGN_SIZE 127 | 53 | #define ALIGN_SIZE 127 |
51 | #define PCIX_COMMAND_REGISTER 0x62 | 54 | #define PCIX_COMMAND_REGISTER 0x62 |
52 | 55 | ||
53 | /* | 56 | /* |
54 | * Debug related variables. | 57 | * Debug related variables. |
@@ -61,7 +64,7 @@ typedef enum xena_max_outstanding_splits { | |||
61 | #define INTR_DBG 4 | 64 | #define INTR_DBG 4 |
62 | 65 | ||
63 | /* Global variable that defines the present debug level of the driver. */ | 66 | /* Global variable that defines the present debug level of the driver. */ |
64 | static int debug_level = ERR_DBG; /* Default level. */ | 67 | int debug_level = ERR_DBG; /* Default level. */ |
65 | 68 | ||
66 | /* DEBUG message print. */ | 69 | /* DEBUG message print. */ |
67 | #define DBG_PRINT(dbg_level, args...) if(!(debug_level<dbg_level)) printk(args) | 70 | #define DBG_PRINT(dbg_level, args...) if(!(debug_level<dbg_level)) printk(args) |
@@ -71,6 +74,12 @@ static int debug_level = ERR_DBG; /* Default level. */ | |||
71 | #define L4_CKSUM_OK 0xFFFF | 74 | #define L4_CKSUM_OK 0xFFFF |
72 | #define S2IO_JUMBO_SIZE 9600 | 75 | #define S2IO_JUMBO_SIZE 9600 |
73 | 76 | ||
77 | /* Driver statistics maintained by driver */ | ||
78 | typedef struct { | ||
79 | unsigned long long single_ecc_errs; | ||
80 | unsigned long long double_ecc_errs; | ||
81 | } swStat_t; | ||
82 | |||
74 | /* The statistics block of Xena */ | 83 | /* The statistics block of Xena */ |
75 | typedef struct stat_block { | 84 | typedef struct stat_block { |
76 | /* Tx MAC statistics counters. */ | 85 | /* Tx MAC statistics counters. */ |
@@ -188,10 +197,26 @@ typedef struct stat_block { | |||
188 | u32 txf_rd_cnt; | 197 | u32 txf_rd_cnt; |
189 | } StatInfo_t; | 198 | } StatInfo_t; |
190 | 199 | ||
191 | /* Structures representing different init time configuration | 200 | /* |
201 | * Structures representing different init time configuration | ||
192 | * parameters of the NIC. | 202 | * parameters of the NIC. |
193 | */ | 203 | */ |
194 | 204 | ||
205 | #define MAX_TX_FIFOS 8 | ||
206 | #define MAX_RX_RINGS 8 | ||
207 | |||
208 | /* FIFO mappings for all possible number of fifos configured */ | ||
209 | int fifo_map[][MAX_TX_FIFOS] = { | ||
210 | {0, 0, 0, 0, 0, 0, 0, 0}, | ||
211 | {0, 0, 0, 0, 1, 1, 1, 1}, | ||
212 | {0, 0, 0, 1, 1, 1, 2, 2}, | ||
213 | {0, 0, 1, 1, 2, 2, 3, 3}, | ||
214 | {0, 0, 1, 1, 2, 2, 3, 4}, | ||
215 | {0, 0, 1, 1, 2, 3, 4, 5}, | ||
216 | {0, 0, 1, 2, 3, 4, 5, 6}, | ||
217 | {0, 1, 2, 3, 4, 5, 6, 7}, | ||
218 | }; | ||
219 | |||
195 | /* Maintains Per FIFO related information. */ | 220 | /* Maintains Per FIFO related information. */ |
196 | typedef struct tx_fifo_config { | 221 | typedef struct tx_fifo_config { |
197 | #define MAX_AVAILABLE_TXDS 8192 | 222 | #define MAX_AVAILABLE_TXDS 8192 |
@@ -237,14 +262,14 @@ typedef struct rx_ring_config { | |||
237 | #define NO_SNOOP_RXD_BUFFER 0x02 | 262 | #define NO_SNOOP_RXD_BUFFER 0x02 |
238 | } rx_ring_config_t; | 263 | } rx_ring_config_t; |
239 | 264 | ||
240 | /* This structure provides contains values of the tunable parameters | 265 | /* This structure provides contains values of the tunable parameters |
241 | * of the H/W | 266 | * of the H/W |
242 | */ | 267 | */ |
243 | struct config_param { | 268 | struct config_param { |
244 | /* Tx Side */ | 269 | /* Tx Side */ |
245 | u32 tx_fifo_num; /*Number of Tx FIFOs */ | 270 | u32 tx_fifo_num; /*Number of Tx FIFOs */ |
246 | #define MAX_TX_FIFOS 8 | ||
247 | 271 | ||
272 | u8 fifo_mapping[MAX_TX_FIFOS]; | ||
248 | tx_fifo_config_t tx_cfg[MAX_TX_FIFOS]; /*Per-Tx FIFO config */ | 273 | tx_fifo_config_t tx_cfg[MAX_TX_FIFOS]; /*Per-Tx FIFO config */ |
249 | u32 max_txds; /*Max no. of Tx buffer descriptor per TxDL */ | 274 | u32 max_txds; /*Max no. of Tx buffer descriptor per TxDL */ |
250 | u64 tx_intr_type; | 275 | u64 tx_intr_type; |
@@ -252,7 +277,6 @@ struct config_param { | |||
252 | 277 | ||
253 | /* Rx Side */ | 278 | /* Rx Side */ |
254 | u32 rx_ring_num; /*Number of receive rings */ | 279 | u32 rx_ring_num; /*Number of receive rings */ |
255 | #define MAX_RX_RINGS 8 | ||
256 | #define MAX_RX_BLOCKS_PER_RING 150 | 280 | #define MAX_RX_BLOCKS_PER_RING 150 |
257 | 281 | ||
258 | rx_ring_config_t rx_cfg[MAX_RX_RINGS]; /*Per-Rx Ring config */ | 282 | rx_ring_config_t rx_cfg[MAX_RX_RINGS]; /*Per-Rx Ring config */ |
@@ -269,6 +293,7 @@ struct config_param { | |||
269 | #define MAX_PYLD_JUMBO 9600 | 293 | #define MAX_PYLD_JUMBO 9600 |
270 | #define MAX_MTU_JUMBO (MAX_PYLD_JUMBO+18) | 294 | #define MAX_MTU_JUMBO (MAX_PYLD_JUMBO+18) |
271 | #define MAX_MTU_JUMBO_VLAN (MAX_PYLD_JUMBO+22) | 295 | #define MAX_MTU_JUMBO_VLAN (MAX_PYLD_JUMBO+22) |
296 | u16 bus_speed; | ||
272 | }; | 297 | }; |
273 | 298 | ||
274 | /* Structure representing MAC Addrs */ | 299 | /* Structure representing MAC Addrs */ |
@@ -277,7 +302,7 @@ typedef struct mac_addr { | |||
277 | } macaddr_t; | 302 | } macaddr_t; |
278 | 303 | ||
279 | /* Structure that represent every FIFO element in the BAR1 | 304 | /* Structure that represent every FIFO element in the BAR1 |
280 | * Address location. | 305 | * Address location. |
281 | */ | 306 | */ |
282 | typedef struct _TxFIFO_element { | 307 | typedef struct _TxFIFO_element { |
283 | u64 TxDL_Pointer; | 308 | u64 TxDL_Pointer; |
@@ -339,6 +364,7 @@ typedef struct _RxD_t { | |||
339 | #define RXD_FRAME_PROTO vBIT(0xFFFF,24,8) | 364 | #define RXD_FRAME_PROTO vBIT(0xFFFF,24,8) |
340 | #define RXD_FRAME_PROTO_IPV4 BIT(27) | 365 | #define RXD_FRAME_PROTO_IPV4 BIT(27) |
341 | #define RXD_FRAME_PROTO_IPV6 BIT(28) | 366 | #define RXD_FRAME_PROTO_IPV6 BIT(28) |
367 | #define RXD_FRAME_IP_FRAG BIT(29) | ||
342 | #define RXD_FRAME_PROTO_TCP BIT(30) | 368 | #define RXD_FRAME_PROTO_TCP BIT(30) |
343 | #define RXD_FRAME_PROTO_UDP BIT(31) | 369 | #define RXD_FRAME_PROTO_UDP BIT(31) |
344 | #define TCP_OR_UDP_FRAME (RXD_FRAME_PROTO_TCP | RXD_FRAME_PROTO_UDP) | 370 | #define TCP_OR_UDP_FRAME (RXD_FRAME_PROTO_TCP | RXD_FRAME_PROTO_UDP) |
@@ -347,10 +373,10 @@ typedef struct _RxD_t { | |||
347 | 373 | ||
348 | u64 Control_2; | 374 | u64 Control_2; |
349 | #ifndef CONFIG_2BUFF_MODE | 375 | #ifndef CONFIG_2BUFF_MODE |
350 | #define MASK_BUFFER0_SIZE vBIT(0xFFFF,0,16) | 376 | #define MASK_BUFFER0_SIZE vBIT(0x3FFF,2,14) |
351 | #define SET_BUFFER0_SIZE(val) vBIT(val,0,16) | 377 | #define SET_BUFFER0_SIZE(val) vBIT(val,2,14) |
352 | #else | 378 | #else |
353 | #define MASK_BUFFER0_SIZE vBIT(0xFF,0,16) | 379 | #define MASK_BUFFER0_SIZE vBIT(0xFF,2,14) |
354 | #define MASK_BUFFER1_SIZE vBIT(0xFFFF,16,16) | 380 | #define MASK_BUFFER1_SIZE vBIT(0xFFFF,16,16) |
355 | #define MASK_BUFFER2_SIZE vBIT(0xFFFF,32,16) | 381 | #define MASK_BUFFER2_SIZE vBIT(0xFFFF,32,16) |
356 | #define SET_BUFFER0_SIZE(val) vBIT(val,8,8) | 382 | #define SET_BUFFER0_SIZE(val) vBIT(val,8,8) |
@@ -363,7 +389,7 @@ typedef struct _RxD_t { | |||
363 | #define SET_NUM_TAG(val) vBIT(val,16,32) | 389 | #define SET_NUM_TAG(val) vBIT(val,16,32) |
364 | 390 | ||
365 | #ifndef CONFIG_2BUFF_MODE | 391 | #ifndef CONFIG_2BUFF_MODE |
366 | #define RXD_GET_BUFFER0_SIZE(Control_2) (u64)((Control_2 & vBIT(0xFFFF,0,16))) | 392 | #define RXD_GET_BUFFER0_SIZE(Control_2) (u64)((Control_2 & vBIT(0x3FFF,2,14))) |
367 | #else | 393 | #else |
368 | #define RXD_GET_BUFFER0_SIZE(Control_2) (u8)((Control_2 & MASK_BUFFER0_SIZE) \ | 394 | #define RXD_GET_BUFFER0_SIZE(Control_2) (u8)((Control_2 & MASK_BUFFER0_SIZE) \ |
369 | >> 48) | 395 | >> 48) |
@@ -382,7 +408,7 @@ typedef struct _RxD_t { | |||
382 | #endif | 408 | #endif |
383 | } RxD_t; | 409 | } RxD_t; |
384 | 410 | ||
385 | /* Structure that represents the Rx descriptor block which contains | 411 | /* Structure that represents the Rx descriptor block which contains |
386 | * 128 Rx descriptors. | 412 | * 128 Rx descriptors. |
387 | */ | 413 | */ |
388 | #ifndef CONFIG_2BUFF_MODE | 414 | #ifndef CONFIG_2BUFF_MODE |
@@ -392,11 +418,11 @@ typedef struct _RxD_block { | |||
392 | 418 | ||
393 | u64 reserved_0; | 419 | u64 reserved_0; |
394 | #define END_OF_BLOCK 0xFEFFFFFFFFFFFFFFULL | 420 | #define END_OF_BLOCK 0xFEFFFFFFFFFFFFFFULL |
395 | u64 reserved_1; /* 0xFEFFFFFFFFFFFFFF to mark last | 421 | u64 reserved_1; /* 0xFEFFFFFFFFFFFFFF to mark last |
396 | * Rxd in this blk */ | 422 | * Rxd in this blk */ |
397 | u64 reserved_2_pNext_RxD_block; /* Logical ptr to next */ | 423 | u64 reserved_2_pNext_RxD_block; /* Logical ptr to next */ |
398 | u64 pNext_RxD_Blk_physical; /* Buff0_ptr.In a 32 bit arch | 424 | u64 pNext_RxD_Blk_physical; /* Buff0_ptr.In a 32 bit arch |
399 | * the upper 32 bits should | 425 | * the upper 32 bits should |
400 | * be 0 */ | 426 | * be 0 */ |
401 | } RxD_block_t; | 427 | } RxD_block_t; |
402 | #else | 428 | #else |
@@ -405,13 +431,13 @@ typedef struct _RxD_block { | |||
405 | RxD_t rxd[MAX_RXDS_PER_BLOCK]; | 431 | RxD_t rxd[MAX_RXDS_PER_BLOCK]; |
406 | 432 | ||
407 | #define END_OF_BLOCK 0xFEFFFFFFFFFFFFFFULL | 433 | #define END_OF_BLOCK 0xFEFFFFFFFFFFFFFFULL |
408 | u64 reserved_1; /* 0xFEFFFFFFFFFFFFFF to mark last Rxd | 434 | u64 reserved_1; /* 0xFEFFFFFFFFFFFFFF to mark last Rxd |
409 | * in this blk */ | 435 | * in this blk */ |
410 | u64 pNext_RxD_Blk_physical; /* Phy ponter to next blk. */ | 436 | u64 pNext_RxD_Blk_physical; /* Phy ponter to next blk. */ |
411 | } RxD_block_t; | 437 | } RxD_block_t; |
412 | #define SIZE_OF_BLOCK 4096 | 438 | #define SIZE_OF_BLOCK 4096 |
413 | 439 | ||
414 | /* Structure to hold virtual addresses of Buf0 and Buf1 in | 440 | /* Structure to hold virtual addresses of Buf0 and Buf1 in |
415 | * 2buf mode. */ | 441 | * 2buf mode. */ |
416 | typedef struct bufAdd { | 442 | typedef struct bufAdd { |
417 | void *ba_0_org; | 443 | void *ba_0_org; |
@@ -423,8 +449,8 @@ typedef struct bufAdd { | |||
423 | 449 | ||
424 | /* Structure which stores all the MAC control parameters */ | 450 | /* Structure which stores all the MAC control parameters */ |
425 | 451 | ||
426 | /* This structure stores the offset of the RxD in the ring | 452 | /* This structure stores the offset of the RxD in the ring |
427 | * from which the Rx Interrupt processor can start picking | 453 | * from which the Rx Interrupt processor can start picking |
428 | * up the RxDs for processing. | 454 | * up the RxDs for processing. |
429 | */ | 455 | */ |
430 | typedef struct _rx_curr_get_info_t { | 456 | typedef struct _rx_curr_get_info_t { |
@@ -436,7 +462,7 @@ typedef struct _rx_curr_get_info_t { | |||
436 | typedef rx_curr_get_info_t rx_curr_put_info_t; | 462 | typedef rx_curr_get_info_t rx_curr_put_info_t; |
437 | 463 | ||
438 | /* This structure stores the offset of the TxDl in the FIFO | 464 | /* This structure stores the offset of the TxDl in the FIFO |
439 | * from which the Tx Interrupt processor can start picking | 465 | * from which the Tx Interrupt processor can start picking |
440 | * up the TxDLs for send complete interrupt processing. | 466 | * up the TxDLs for send complete interrupt processing. |
441 | */ | 467 | */ |
442 | typedef struct { | 468 | typedef struct { |
@@ -446,32 +472,96 @@ typedef struct { | |||
446 | 472 | ||
447 | typedef tx_curr_get_info_t tx_curr_put_info_t; | 473 | typedef tx_curr_get_info_t tx_curr_put_info_t; |
448 | 474 | ||
449 | /* Infomation related to the Tx and Rx FIFOs and Rings of Xena | 475 | /* Structure that holds the Phy and virt addresses of the Blocks */ |
450 | * is maintained in this structure. | 476 | typedef struct rx_block_info { |
451 | */ | 477 | RxD_t *block_virt_addr; |
452 | typedef struct mac_info { | 478 | dma_addr_t block_dma_addr; |
453 | /* rx side stuff */ | 479 | } rx_block_info_t; |
454 | /* Put pointer info which indictes which RxD has to be replenished | 480 | |
481 | /* pre declaration of the nic structure */ | ||
482 | typedef struct s2io_nic nic_t; | ||
483 | |||
484 | /* Ring specific structure */ | ||
485 | typedef struct ring_info { | ||
486 | /* The ring number */ | ||
487 | int ring_no; | ||
488 | |||
489 | /* | ||
490 | * Place holders for the virtual and physical addresses of | ||
491 | * all the Rx Blocks | ||
492 | */ | ||
493 | rx_block_info_t rx_blocks[MAX_RX_BLOCKS_PER_RING]; | ||
494 | int block_count; | ||
495 | int pkt_cnt; | ||
496 | |||
497 | /* | ||
498 | * Put pointer info which indictes which RxD has to be replenished | ||
455 | * with a new buffer. | 499 | * with a new buffer. |
456 | */ | 500 | */ |
457 | rx_curr_put_info_t rx_curr_put_info[MAX_RX_RINGS]; | 501 | rx_curr_put_info_t rx_curr_put_info; |
458 | 502 | ||
459 | /* Get pointer info which indictes which is the last RxD that was | 503 | /* |
504 | * Get pointer info which indictes which is the last RxD that was | ||
460 | * processed by the driver. | 505 | * processed by the driver. |
461 | */ | 506 | */ |
462 | rx_curr_get_info_t rx_curr_get_info[MAX_RX_RINGS]; | 507 | rx_curr_get_info_t rx_curr_get_info; |
463 | 508 | ||
464 | u16 rmac_pause_time; | 509 | #ifndef CONFIG_S2IO_NAPI |
465 | u16 mc_pause_threshold_q0q3; | 510 | /* Index to the absolute position of the put pointer of Rx ring */ |
466 | u16 mc_pause_threshold_q4q7; | 511 | int put_pos; |
512 | #endif | ||
513 | |||
514 | #ifdef CONFIG_2BUFF_MODE | ||
515 | /* Buffer Address store. */ | ||
516 | buffAdd_t **ba; | ||
517 | #endif | ||
518 | nic_t *nic; | ||
519 | } ring_info_t; | ||
467 | 520 | ||
521 | /* Fifo specific structure */ | ||
522 | typedef struct fifo_info { | ||
523 | /* FIFO number */ | ||
524 | int fifo_no; | ||
525 | |||
526 | /* Maximum TxDs per TxDL */ | ||
527 | int max_txds; | ||
528 | |||
529 | /* Place holder of all the TX List's Phy and Virt addresses. */ | ||
530 | list_info_hold_t *list_info; | ||
531 | |||
532 | /* | ||
533 | * Current offset within the tx FIFO where driver would write | ||
534 | * new Tx frame | ||
535 | */ | ||
536 | tx_curr_put_info_t tx_curr_put_info; | ||
537 | |||
538 | /* | ||
539 | * Current offset within tx FIFO from where the driver would start freeing | ||
540 | * the buffers | ||
541 | */ | ||
542 | tx_curr_get_info_t tx_curr_get_info; | ||
543 | |||
544 | nic_t *nic; | ||
545 | }fifo_info_t; | ||
546 | |||
547 | /* Infomation related to the Tx and Rx FIFOs and Rings of Xena | ||
548 | * is maintained in this structure. | ||
549 | */ | ||
550 | typedef struct mac_info { | ||
468 | /* tx side stuff */ | 551 | /* tx side stuff */ |
469 | /* logical pointer of start of each Tx FIFO */ | 552 | /* logical pointer of start of each Tx FIFO */ |
470 | TxFIFO_element_t __iomem *tx_FIFO_start[MAX_TX_FIFOS]; | 553 | TxFIFO_element_t __iomem *tx_FIFO_start[MAX_TX_FIFOS]; |
471 | 554 | ||
472 | /* Current offset within tx_FIFO_start, where driver would write new Tx frame*/ | 555 | /* Fifo specific structure */ |
473 | tx_curr_put_info_t tx_curr_put_info[MAX_TX_FIFOS]; | 556 | fifo_info_t fifos[MAX_TX_FIFOS]; |
474 | tx_curr_get_info_t tx_curr_get_info[MAX_TX_FIFOS]; | 557 | |
558 | /* rx side stuff */ | ||
559 | /* Ring specific structure */ | ||
560 | ring_info_t rings[MAX_RX_RINGS]; | ||
561 | |||
562 | u16 rmac_pause_time; | ||
563 | u16 mc_pause_threshold_q0q3; | ||
564 | u16 mc_pause_threshold_q4q7; | ||
475 | 565 | ||
476 | void *stats_mem; /* orignal pointer to allocated mem */ | 566 | void *stats_mem; /* orignal pointer to allocated mem */ |
477 | dma_addr_t stats_mem_phy; /* Physical address of the stat block */ | 567 | dma_addr_t stats_mem_phy; /* Physical address of the stat block */ |
@@ -485,12 +575,6 @@ typedef struct { | |||
485 | int usage_cnt; | 575 | int usage_cnt; |
486 | } usr_addr_t; | 576 | } usr_addr_t; |
487 | 577 | ||
488 | /* Structure that holds the Phy and virt addresses of the Blocks */ | ||
489 | typedef struct rx_block_info { | ||
490 | RxD_t *block_virt_addr; | ||
491 | dma_addr_t block_dma_addr; | ||
492 | } rx_block_info_t; | ||
493 | |||
494 | /* Default Tunable parameters of the NIC. */ | 578 | /* Default Tunable parameters of the NIC. */ |
495 | #define DEFAULT_FIFO_LEN 4096 | 579 | #define DEFAULT_FIFO_LEN 4096 |
496 | #define SMALL_RXD_CNT 30 * (MAX_RXDS_PER_BLOCK+1) | 580 | #define SMALL_RXD_CNT 30 * (MAX_RXDS_PER_BLOCK+1) |
@@ -499,7 +583,20 @@ typedef struct rx_block_info { | |||
499 | #define LARGE_BLK_CNT 100 | 583 | #define LARGE_BLK_CNT 100 |
500 | 584 | ||
501 | /* Structure representing one instance of the NIC */ | 585 | /* Structure representing one instance of the NIC */ |
502 | typedef struct s2io_nic { | 586 | struct s2io_nic { |
587 | #ifdef CONFIG_S2IO_NAPI | ||
588 | /* | ||
589 | * Count of packets to be processed in a given iteration, it will be indicated | ||
590 | * by the quota field of the device structure when NAPI is enabled. | ||
591 | */ | ||
592 | int pkts_to_process; | ||
593 | #endif | ||
594 | struct net_device *dev; | ||
595 | mac_info_t mac_control; | ||
596 | struct config_param config; | ||
597 | struct pci_dev *pdev; | ||
598 | void __iomem *bar0; | ||
599 | void __iomem *bar1; | ||
503 | #define MAX_MAC_SUPPORTED 16 | 600 | #define MAX_MAC_SUPPORTED 16 |
504 | #define MAX_SUPPORTED_MULTICASTS MAX_MAC_SUPPORTED | 601 | #define MAX_SUPPORTED_MULTICASTS MAX_MAC_SUPPORTED |
505 | 602 | ||
@@ -507,33 +604,17 @@ typedef struct s2io_nic { | |||
507 | macaddr_t pre_mac_addr[MAX_MAC_SUPPORTED]; | 604 | macaddr_t pre_mac_addr[MAX_MAC_SUPPORTED]; |
508 | 605 | ||
509 | struct net_device_stats stats; | 606 | struct net_device_stats stats; |
510 | void __iomem *bar0; | ||
511 | void __iomem *bar1; | ||
512 | struct config_param config; | ||
513 | mac_info_t mac_control; | ||
514 | int high_dma_flag; | 607 | int high_dma_flag; |
515 | int device_close_flag; | 608 | int device_close_flag; |
516 | int device_enabled_once; | 609 | int device_enabled_once; |
517 | 610 | ||
518 | char name[32]; | 611 | char name[50]; |
519 | struct tasklet_struct task; | 612 | struct tasklet_struct task; |
520 | volatile unsigned long tasklet_status; | 613 | volatile unsigned long tasklet_status; |
521 | struct timer_list timer; | ||
522 | struct net_device *dev; | ||
523 | struct pci_dev *pdev; | ||
524 | 614 | ||
525 | u16 vendor_id; | 615 | /* Space to back up the PCI config space */ |
526 | u16 device_id; | 616 | u32 config_space[256 / sizeof(u32)]; |
527 | u16 ccmd; | 617 | |
528 | u32 cbar0_1; | ||
529 | u32 cbar0_2; | ||
530 | u32 cbar1_1; | ||
531 | u32 cbar1_2; | ||
532 | u32 cirq; | ||
533 | u8 cache_line; | ||
534 | u32 rom_expansion; | ||
535 | u16 pcix_cmd; | ||
536 | u32 irq; | ||
537 | atomic_t rx_bufs_left[MAX_RX_RINGS]; | 618 | atomic_t rx_bufs_left[MAX_RX_RINGS]; |
538 | 619 | ||
539 | spinlock_t tx_lock; | 620 | spinlock_t tx_lock; |
@@ -558,27 +639,11 @@ typedef struct s2io_nic { | |||
558 | u16 tx_err_count; | 639 | u16 tx_err_count; |
559 | u16 rx_err_count; | 640 | u16 rx_err_count; |
560 | 641 | ||
561 | #ifndef CONFIG_S2IO_NAPI | ||
562 | /* Index to the absolute position of the put pointer of Rx ring. */ | ||
563 | int put_pos[MAX_RX_RINGS]; | ||
564 | #endif | ||
565 | |||
566 | /* | ||
567 | * Place holders for the virtual and physical addresses of | ||
568 | * all the Rx Blocks | ||
569 | */ | ||
570 | rx_block_info_t rx_blocks[MAX_RX_RINGS][MAX_RX_BLOCKS_PER_RING]; | ||
571 | int block_count[MAX_RX_RINGS]; | ||
572 | int pkt_cnt[MAX_RX_RINGS]; | ||
573 | |||
574 | /* Place holder of all the TX List's Phy and Virt addresses. */ | ||
575 | list_info_hold_t *list_info[MAX_TX_FIFOS]; | ||
576 | |||
577 | /* Id timer, used to blink NIC to physically identify NIC. */ | 642 | /* Id timer, used to blink NIC to physically identify NIC. */ |
578 | struct timer_list id_timer; | 643 | struct timer_list id_timer; |
579 | 644 | ||
580 | /* Restart timer, used to restart NIC if the device is stuck and | 645 | /* Restart timer, used to restart NIC if the device is stuck and |
581 | * a schedule task that will set the correct Link state once the | 646 | * a schedule task that will set the correct Link state once the |
582 | * NIC's PHY has stabilized after a state change. | 647 | * NIC's PHY has stabilized after a state change. |
583 | */ | 648 | */ |
584 | #ifdef INIT_TQUEUE | 649 | #ifdef INIT_TQUEUE |
@@ -589,12 +654,12 @@ typedef struct s2io_nic { | |||
589 | struct work_struct set_link_task; | 654 | struct work_struct set_link_task; |
590 | #endif | 655 | #endif |
591 | 656 | ||
592 | /* Flag that can be used to turn on or turn off the Rx checksum | 657 | /* Flag that can be used to turn on or turn off the Rx checksum |
593 | * offload feature. | 658 | * offload feature. |
594 | */ | 659 | */ |
595 | int rx_csum; | 660 | int rx_csum; |
596 | 661 | ||
597 | /* after blink, the adapter must be restored with original | 662 | /* after blink, the adapter must be restored with original |
598 | * values. | 663 | * values. |
599 | */ | 664 | */ |
600 | u64 adapt_ctrl_org; | 665 | u64 adapt_ctrl_org; |
@@ -604,16 +669,12 @@ typedef struct s2io_nic { | |||
604 | #define LINK_DOWN 1 | 669 | #define LINK_DOWN 1 |
605 | #define LINK_UP 2 | 670 | #define LINK_UP 2 |
606 | 671 | ||
607 | #ifdef CONFIG_2BUFF_MODE | ||
608 | /* Buffer Address store. */ | ||
609 | buffAdd_t **ba[MAX_RX_RINGS]; | ||
610 | #endif | ||
611 | int task_flag; | 672 | int task_flag; |
612 | #define CARD_DOWN 1 | 673 | #define CARD_DOWN 1 |
613 | #define CARD_UP 2 | 674 | #define CARD_UP 2 |
614 | atomic_t card_state; | 675 | atomic_t card_state; |
615 | volatile unsigned long link_state; | 676 | volatile unsigned long link_state; |
616 | } nic_t; | 677 | }; |
617 | 678 | ||
618 | #define RESET_ERROR 1; | 679 | #define RESET_ERROR 1; |
619 | #define CMD_ERROR 2; | 680 | #define CMD_ERROR 2; |
@@ -622,9 +683,10 @@ typedef struct s2io_nic { | |||
622 | #ifndef readq | 683 | #ifndef readq |
623 | static inline u64 readq(void __iomem *addr) | 684 | static inline u64 readq(void __iomem *addr) |
624 | { | 685 | { |
625 | u64 ret = readl(addr + 4); | 686 | u64 ret = 0; |
626 | ret <<= 32; | 687 | ret = readl(addr + 4); |
627 | ret |= readl(addr); | 688 | (u64) ret <<= 32; |
689 | (u64) ret |= readl(addr); | ||
628 | 690 | ||
629 | return ret; | 691 | return ret; |
630 | } | 692 | } |
@@ -637,10 +699,10 @@ static inline void writeq(u64 val, void __iomem *addr) | |||
637 | writel((u32) (val >> 32), (addr + 4)); | 699 | writel((u32) (val >> 32), (addr + 4)); |
638 | } | 700 | } |
639 | 701 | ||
640 | /* In 32 bit modes, some registers have to be written in a | 702 | /* In 32 bit modes, some registers have to be written in a |
641 | * particular order to expect correct hardware operation. The | 703 | * particular order to expect correct hardware operation. The |
642 | * macro SPECIAL_REG_WRITE is used to perform such ordered | 704 | * macro SPECIAL_REG_WRITE is used to perform such ordered |
643 | * writes. Defines UF (Upper First) and LF (Lower First) will | 705 | * writes. Defines UF (Upper First) and LF (Lower First) will |
644 | * be used to specify the required write order. | 706 | * be used to specify the required write order. |
645 | */ | 707 | */ |
646 | #define UF 1 | 708 | #define UF 1 |
@@ -716,6 +778,7 @@ static inline void SPECIAL_REG_WRITE(u64 val, void __iomem *addr, int order) | |||
716 | #define PCC_FB_ECC_ERR vBIT(0xff, 16, 8) /* Interrupt to indicate | 778 | #define PCC_FB_ECC_ERR vBIT(0xff, 16, 8) /* Interrupt to indicate |
717 | PCC_FB_ECC Error. */ | 779 | PCC_FB_ECC Error. */ |
718 | 780 | ||
781 | #define RXD_GET_VLAN_TAG(Control_2) (u16)(Control_2 & MASK_VLAN_TAG) | ||
719 | /* | 782 | /* |
720 | * Prototype declaration. | 783 | * Prototype declaration. |
721 | */ | 784 | */ |
@@ -725,36 +788,29 @@ static void __devexit s2io_rem_nic(struct pci_dev *pdev); | |||
725 | static int init_shared_mem(struct s2io_nic *sp); | 788 | static int init_shared_mem(struct s2io_nic *sp); |
726 | static void free_shared_mem(struct s2io_nic *sp); | 789 | static void free_shared_mem(struct s2io_nic *sp); |
727 | static int init_nic(struct s2io_nic *nic); | 790 | static int init_nic(struct s2io_nic *nic); |
728 | #ifndef CONFIG_S2IO_NAPI | 791 | static void rx_intr_handler(ring_info_t *ring_data); |
729 | static void rx_intr_handler(struct s2io_nic *sp); | 792 | static void tx_intr_handler(fifo_info_t *fifo_data); |
730 | #endif | ||
731 | static void tx_intr_handler(struct s2io_nic *sp); | ||
732 | static void alarm_intr_handler(struct s2io_nic *sp); | 793 | static void alarm_intr_handler(struct s2io_nic *sp); |
733 | 794 | ||
734 | static int s2io_starter(void); | 795 | static int s2io_starter(void); |
735 | static void s2io_closer(void); | 796 | void s2io_closer(void); |
736 | static void s2io_tx_watchdog(struct net_device *dev); | 797 | static void s2io_tx_watchdog(struct net_device *dev); |
737 | static void s2io_tasklet(unsigned long dev_addr); | 798 | static void s2io_tasklet(unsigned long dev_addr); |
738 | static void s2io_set_multicast(struct net_device *dev); | 799 | static void s2io_set_multicast(struct net_device *dev); |
739 | #ifndef CONFIG_2BUFF_MODE | 800 | static int rx_osm_handler(ring_info_t *ring_data, RxD_t * rxdp); |
740 | static int rx_osm_handler(nic_t * sp, u16 len, RxD_t * rxdp, int ring_no); | 801 | void s2io_link(nic_t * sp, int link); |
741 | #else | 802 | void s2io_reset(nic_t * sp); |
742 | static int rx_osm_handler(nic_t * sp, RxD_t * rxdp, int ring_no, | 803 | #if defined(CONFIG_S2IO_NAPI) |
743 | buffAdd_t * ba); | ||
744 | #endif | ||
745 | static void s2io_link(nic_t * sp, int link); | ||
746 | static void s2io_reset(nic_t * sp); | ||
747 | #ifdef CONFIG_S2IO_NAPI | ||
748 | static int s2io_poll(struct net_device *dev, int *budget); | 804 | static int s2io_poll(struct net_device *dev, int *budget); |
749 | #endif | 805 | #endif |
750 | static void s2io_init_pci(nic_t * sp); | 806 | static void s2io_init_pci(nic_t * sp); |
751 | static int s2io_set_mac_addr(struct net_device *dev, u8 * addr); | 807 | int s2io_set_mac_addr(struct net_device *dev, u8 * addr); |
752 | static irqreturn_t s2io_isr(int irq, void *dev_id, struct pt_regs *regs); | 808 | static irqreturn_t s2io_isr(int irq, void *dev_id, struct pt_regs *regs); |
753 | static int verify_xena_quiescence(u64 val64, int flag); | 809 | static int verify_xena_quiescence(nic_t *sp, u64 val64, int flag); |
754 | static struct ethtool_ops netdev_ethtool_ops; | 810 | static struct ethtool_ops netdev_ethtool_ops; |
755 | static void s2io_set_link(unsigned long data); | 811 | static void s2io_set_link(unsigned long data); |
756 | static int s2io_set_swapper(nic_t * sp); | 812 | int s2io_set_swapper(nic_t * sp); |
757 | static void s2io_card_down(nic_t * nic); | 813 | static void s2io_card_down(nic_t *nic); |
758 | static int s2io_card_up(nic_t * nic); | 814 | static int s2io_card_up(nic_t *nic); |
759 | 815 | int get_xena_rev_id(struct pci_dev *pdev); | |
760 | #endif /* _S2IO_H */ | 816 | #endif /* _S2IO_H */ |