ixgb.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /*******************************************************************************
  2. Copyright(c) 1999 - 2006 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 PFX "ixgb: "
  73. #define DPRINTK(nlevel, klevel, fmt, args...) \
  74. (void)((NETIF_MSG_##nlevel & adapter->msg_enable) && \
  75. printk(KERN_##klevel PFX "%s: %s: " fmt, adapter->netdev->name, \
  76. __FUNCTION__ , ## args))
  77. /* TX/RX descriptor defines */
  78. #define DEFAULT_TXD 256
  79. #define MAX_TXD 4096
  80. #define MIN_TXD 64
  81. /* hardware cannot reliably support more than 512 descriptors owned by
  82. * hardware descrioptor cache otherwise an unreliable ring under heavy
  83. * recieve load may result */
  84. /* #define DEFAULT_RXD 1024 */
  85. /* #define MAX_RXD 4096 */
  86. #define DEFAULT_RXD 512
  87. #define MAX_RXD 512
  88. #define MIN_RXD 64
  89. /* Supported Rx Buffer Sizes */
  90. #define IXGB_RXBUFFER_2048 2048
  91. #define IXGB_RXBUFFER_4096 4096
  92. #define IXGB_RXBUFFER_8192 8192
  93. #define IXGB_RXBUFFER_16384 16384
  94. /* How many Tx Descriptors do we need to call netif_wake_queue? */
  95. #define IXGB_TX_QUEUE_WAKE 16
  96. /* How many Rx Buffers do we bundle into one write to the hardware ? */
  97. #define IXGB_RX_BUFFER_WRITE 4 /* Must be power of 2 */
  98. /* only works for sizes that are powers of 2 */
  99. #define IXGB_ROUNDUP(i, size) ((i) = (((i) + (size) - 1) & ~((size) - 1)))
  100. /* wrapper around a pointer to a socket buffer,
  101. * so a DMA handle can be stored along with the buffer */
  102. struct ixgb_buffer {
  103. struct sk_buff *skb;
  104. dma_addr_t dma;
  105. unsigned long time_stamp;
  106. uint16_t length;
  107. uint16_t next_to_watch;
  108. };
  109. struct ixgb_desc_ring {
  110. /* pointer to the descriptor ring memory */
  111. void *desc;
  112. /* physical address of the descriptor ring */
  113. dma_addr_t dma;
  114. /* length of descriptor ring in bytes */
  115. unsigned int size;
  116. /* number of descriptors in the ring */
  117. unsigned int count;
  118. /* next descriptor to associate a buffer with */
  119. unsigned int next_to_use;
  120. /* next descriptor to check for DD status bit */
  121. unsigned int next_to_clean;
  122. /* array of buffer information structs */
  123. struct ixgb_buffer *buffer_info;
  124. };
  125. #define IXGB_DESC_UNUSED(R) \
  126. ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
  127. (R)->next_to_clean - (R)->next_to_use - 1)
  128. #define IXGB_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i]))
  129. #define IXGB_RX_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_rx_desc)
  130. #define IXGB_TX_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_tx_desc)
  131. #define IXGB_CONTEXT_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_context_desc)
  132. /* board specific private data structure */
  133. struct ixgb_adapter {
  134. struct timer_list watchdog_timer;
  135. struct vlan_group *vlgrp;
  136. uint32_t bd_number;
  137. uint32_t rx_buffer_len;
  138. uint32_t part_num;
  139. uint16_t link_speed;
  140. uint16_t link_duplex;
  141. spinlock_t tx_lock;
  142. atomic_t irq_sem;
  143. struct work_struct tx_timeout_task;
  144. struct timer_list blink_timer;
  145. unsigned long led_status;
  146. /* TX */
  147. struct ixgb_desc_ring tx_ring;
  148. unsigned long timeo_start;
  149. uint32_t tx_cmd_type;
  150. uint64_t hw_csum_tx_good;
  151. uint64_t hw_csum_tx_error;
  152. uint32_t tx_int_delay;
  153. uint32_t tx_timeout_count;
  154. boolean_t tx_int_delay_enable;
  155. boolean_t detect_tx_hung;
  156. /* RX */
  157. struct ixgb_desc_ring rx_ring;
  158. uint64_t hw_csum_rx_error;
  159. uint64_t hw_csum_rx_good;
  160. uint32_t rx_int_delay;
  161. boolean_t rx_csum;
  162. /* OS defined structs */
  163. struct net_device *netdev;
  164. struct pci_dev *pdev;
  165. struct net_device_stats net_stats;
  166. /* structs defined in ixgb_hw.h */
  167. struct ixgb_hw hw;
  168. u16 msg_enable;
  169. struct ixgb_hw_stats stats;
  170. uint32_t alloc_rx_buff_failed;
  171. #ifdef CONFIG_PCI_MSI
  172. boolean_t have_msi;
  173. #endif
  174. };
  175. #endif /* _IXGB_H_ */