ixgb.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /*******************************************************************************
  2. Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
  3. This program is free software; you can redistribute it and/or modify it
  4. under the terms of the GNU General Public License as published by the Free
  5. Software Foundation; either version 2 of the License, or (at your option)
  6. any later version.
  7. This program is distributed in the hope that it will be useful, but WITHOUT
  8. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  9. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  10. more details.
  11. You should have received a copy of the GNU General Public License along with
  12. this program; if not, write to the Free Software Foundation, Inc., 59
  13. Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. The full GNU General Public License is included in this distribution in the
  15. file called LICENSE.
  16. Contact Information:
  17. Linux NICS <linux.nics@intel.com>
  18. Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  19. *******************************************************************************/
  20. #ifndef _IXGB_H_
  21. #define _IXGB_H_
  22. #include <linux/stddef.h>
  23. #include <linux/config.h>
  24. #include <linux/module.h>
  25. #include <linux/types.h>
  26. #include <asm/byteorder.h>
  27. #include <linux/init.h>
  28. #include <linux/mm.h>
  29. #include <linux/errno.h>
  30. #include <linux/ioport.h>
  31. #include <linux/pci.h>
  32. #include <linux/kernel.h>
  33. #include <linux/netdevice.h>
  34. #include <linux/etherdevice.h>
  35. #include <linux/skbuff.h>
  36. #include <linux/delay.h>
  37. #include <linux/timer.h>
  38. #include <linux/slab.h>
  39. #include <linux/vmalloc.h>
  40. #include <linux/interrupt.h>
  41. #include <linux/string.h>
  42. #include <linux/pagemap.h>
  43. #include <linux/dma-mapping.h>
  44. #include <linux/bitops.h>
  45. #include <asm/io.h>
  46. #include <asm/irq.h>
  47. #include <linux/capability.h>
  48. #include <linux/in.h>
  49. #include <linux/ip.h>
  50. #include <linux/tcp.h>
  51. #include <linux/udp.h>
  52. #include <net/pkt_sched.h>
  53. #include <linux/list.h>
  54. #include <linux/reboot.h>
  55. #ifdef NETIF_F_TSO
  56. #include <net/checksum.h>
  57. #endif
  58. #include <linux/ethtool.h>
  59. #include <linux/if_vlan.h>
  60. #define BAR_0 0
  61. #define BAR_1 1
  62. #define BAR_5 5
  63. struct ixgb_adapter;
  64. #include "ixgb_hw.h"
  65. #include "ixgb_ee.h"
  66. #include "ixgb_ids.h"
  67. #ifdef _DEBUG_DRIVER_
  68. #define IXGB_DBG(args...) printk(KERN_DEBUG "ixgb: " args)
  69. #else
  70. #define IXGB_DBG(args...)
  71. #endif
  72. #define IXGB_ERR(args...) printk(KERN_ERR "ixgb: " args)
  73. /* TX/RX descriptor defines */
  74. #define DEFAULT_TXD 256
  75. #define MAX_TXD 4096
  76. #define MIN_TXD 64
  77. /* hardware cannot reliably support more than 512 descriptors owned by
  78. * hardware descrioptor cache otherwise an unreliable ring under heavy
  79. * recieve load may result */
  80. /* #define DEFAULT_RXD 1024 */
  81. /* #define MAX_RXD 4096 */
  82. #define DEFAULT_RXD 512
  83. #define MAX_RXD 512
  84. #define MIN_RXD 64
  85. /* Supported Rx Buffer Sizes */
  86. #define IXGB_RXBUFFER_2048 2048
  87. #define IXGB_RXBUFFER_4096 4096
  88. #define IXGB_RXBUFFER_8192 8192
  89. #define IXGB_RXBUFFER_16384 16384
  90. /* How many Tx Descriptors do we need to call netif_wake_queue? */
  91. #define IXGB_TX_QUEUE_WAKE 16
  92. /* How many Rx Buffers do we bundle into one write to the hardware ? */
  93. #define IXGB_RX_BUFFER_WRITE 4 /* Must be power of 2 */
  94. /* only works for sizes that are powers of 2 */
  95. #define IXGB_ROUNDUP(i, size) ((i) = (((i) + (size) - 1) & ~((size) - 1)))
  96. /* wrapper around a pointer to a socket buffer,
  97. * so a DMA handle can be stored along with the buffer */
  98. struct ixgb_buffer {
  99. struct sk_buff *skb;
  100. dma_addr_t dma;
  101. unsigned long time_stamp;
  102. uint16_t length;
  103. uint16_t next_to_watch;
  104. };
  105. struct ixgb_desc_ring {
  106. /* pointer to the descriptor ring memory */
  107. void *desc;
  108. /* physical address of the descriptor ring */
  109. dma_addr_t dma;
  110. /* length of descriptor ring in bytes */
  111. unsigned int size;
  112. /* number of descriptors in the ring */
  113. unsigned int count;
  114. /* next descriptor to associate a buffer with */
  115. unsigned int next_to_use;
  116. /* next descriptor to check for DD status bit */
  117. unsigned int next_to_clean;
  118. /* array of buffer information structs */
  119. struct ixgb_buffer *buffer_info;
  120. };
  121. #define IXGB_DESC_UNUSED(R) \
  122. ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
  123. (R)->next_to_clean - (R)->next_to_use - 1)
  124. #define IXGB_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i]))
  125. #define IXGB_RX_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_rx_desc)
  126. #define IXGB_TX_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_tx_desc)
  127. #define IXGB_CONTEXT_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_context_desc)
  128. /* board specific private data structure */
  129. struct ixgb_adapter {
  130. struct timer_list watchdog_timer;
  131. struct vlan_group *vlgrp;
  132. uint32_t bd_number;
  133. uint32_t rx_buffer_len;
  134. uint32_t part_num;
  135. uint16_t link_speed;
  136. uint16_t link_duplex;
  137. spinlock_t tx_lock;
  138. atomic_t irq_sem;
  139. struct work_struct tx_timeout_task;
  140. struct timer_list blink_timer;
  141. unsigned long led_status;
  142. /* TX */
  143. struct ixgb_desc_ring tx_ring;
  144. unsigned long timeo_start;
  145. uint32_t tx_cmd_type;
  146. uint64_t hw_csum_tx_good;
  147. uint64_t hw_csum_tx_error;
  148. uint32_t tx_int_delay;
  149. boolean_t tx_int_delay_enable;
  150. boolean_t detect_tx_hung;
  151. /* RX */
  152. struct ixgb_desc_ring rx_ring;
  153. uint64_t hw_csum_rx_error;
  154. uint64_t hw_csum_rx_good;
  155. uint32_t rx_int_delay;
  156. boolean_t rx_csum;
  157. /* OS defined structs */
  158. struct net_device *netdev;
  159. struct pci_dev *pdev;
  160. struct net_device_stats net_stats;
  161. /* structs defined in ixgb_hw.h */
  162. struct ixgb_hw hw;
  163. struct ixgb_hw_stats stats;
  164. #ifdef CONFIG_PCI_MSI
  165. boolean_t have_msi;
  166. #endif
  167. };
  168. #endif /* _IXGB_H_ */