ixgb.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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/module.h>
  24. #include <linux/types.h>
  25. #include <asm/byteorder.h>
  26. #include <linux/init.h>
  27. #include <linux/mm.h>
  28. #include <linux/errno.h>
  29. #include <linux/ioport.h>
  30. #include <linux/pci.h>
  31. #include <linux/kernel.h>
  32. #include <linux/netdevice.h>
  33. #include <linux/etherdevice.h>
  34. #include <linux/skbuff.h>
  35. #include <linux/delay.h>
  36. #include <linux/timer.h>
  37. #include <linux/slab.h>
  38. #include <linux/vmalloc.h>
  39. #include <linux/interrupt.h>
  40. #include <linux/string.h>
  41. #include <linux/pagemap.h>
  42. #include <linux/dma-mapping.h>
  43. #include <linux/bitops.h>
  44. #include <asm/io.h>
  45. #include <asm/irq.h>
  46. #include <linux/capability.h>
  47. #include <linux/in.h>
  48. #include <linux/ip.h>
  49. #include <linux/tcp.h>
  50. #include <linux/udp.h>
  51. #include <net/pkt_sched.h>
  52. #include <linux/list.h>
  53. #include <linux/reboot.h>
  54. #ifdef NETIF_F_TSO
  55. #include <net/checksum.h>
  56. #endif
  57. #include <linux/ethtool.h>
  58. #include <linux/if_vlan.h>
  59. #define BAR_0 0
  60. #define BAR_1 1
  61. #define BAR_5 5
  62. struct ixgb_adapter;
  63. #include "ixgb_hw.h"
  64. #include "ixgb_ee.h"
  65. #include "ixgb_ids.h"
  66. #ifdef _DEBUG_DRIVER_
  67. #define IXGB_DBG(args...) printk(KERN_DEBUG "ixgb: " args)
  68. #else
  69. #define IXGB_DBG(args...)
  70. #endif
  71. #define PFX "ixgb: "
  72. #define DPRINTK(nlevel, klevel, fmt, args...) \
  73. (void)((NETIF_MSG_##nlevel & adapter->msg_enable) && \
  74. printk(KERN_##klevel PFX "%s: %s: " fmt, adapter->netdev->name, \
  75. __FUNCTION__ , ## args))
  76. /* TX/RX descriptor defines */
  77. #define DEFAULT_TXD 256
  78. #define MAX_TXD 4096
  79. #define MIN_TXD 64
  80. /* hardware cannot reliably support more than 512 descriptors owned by
  81. * hardware descrioptor cache otherwise an unreliable ring under heavy
  82. * recieve load may result */
  83. /* #define DEFAULT_RXD 1024 */
  84. /* #define MAX_RXD 4096 */
  85. #define DEFAULT_RXD 512
  86. #define MAX_RXD 512
  87. #define MIN_RXD 64
  88. /* Supported Rx Buffer Sizes */
  89. #define IXGB_RXBUFFER_2048 2048
  90. #define IXGB_RXBUFFER_4096 4096
  91. #define IXGB_RXBUFFER_8192 8192
  92. #define IXGB_RXBUFFER_16384 16384
  93. /* How many Rx Buffers do we bundle into one write to the hardware ? */
  94. #define IXGB_RX_BUFFER_WRITE 4 /* Must be power of 2 */
  95. /* only works for sizes that are powers of 2 */
  96. #define IXGB_ROUNDUP(i, size) ((i) = (((i) + (size) - 1) & ~((size) - 1)))
  97. /* wrapper around a pointer to a socket buffer,
  98. * so a DMA handle can be stored along with the buffer */
  99. struct ixgb_buffer {
  100. struct sk_buff *skb;
  101. dma_addr_t dma;
  102. unsigned long time_stamp;
  103. uint16_t length;
  104. uint16_t next_to_watch;
  105. };
  106. struct ixgb_desc_ring {
  107. /* pointer to the descriptor ring memory */
  108. void *desc;
  109. /* physical address of the descriptor ring */
  110. dma_addr_t dma;
  111. /* length of descriptor ring in bytes */
  112. unsigned int size;
  113. /* number of descriptors in the ring */
  114. unsigned int count;
  115. /* next descriptor to associate a buffer with */
  116. unsigned int next_to_use;
  117. /* next descriptor to check for DD status bit */
  118. unsigned int next_to_clean;
  119. /* array of buffer information structs */
  120. struct ixgb_buffer *buffer_info;
  121. };
  122. #define IXGB_DESC_UNUSED(R) \
  123. ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
  124. (R)->next_to_clean - (R)->next_to_use - 1)
  125. #define IXGB_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i]))
  126. #define IXGB_RX_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_rx_desc)
  127. #define IXGB_TX_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_tx_desc)
  128. #define IXGB_CONTEXT_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_context_desc)
  129. /* board specific private data structure */
  130. struct ixgb_adapter {
  131. struct timer_list watchdog_timer;
  132. struct vlan_group *vlgrp;
  133. uint32_t bd_number;
  134. uint32_t rx_buffer_len;
  135. uint32_t part_num;
  136. uint16_t link_speed;
  137. uint16_t link_duplex;
  138. spinlock_t tx_lock;
  139. atomic_t irq_sem;
  140. struct work_struct tx_timeout_task;
  141. struct timer_list blink_timer;
  142. unsigned long led_status;
  143. /* TX */
  144. struct ixgb_desc_ring tx_ring ____cacheline_aligned_in_smp;
  145. unsigned long timeo_start;
  146. uint32_t tx_cmd_type;
  147. uint64_t hw_csum_tx_good;
  148. uint64_t hw_csum_tx_error;
  149. uint32_t tx_int_delay;
  150. uint32_t tx_timeout_count;
  151. boolean_t tx_int_delay_enable;
  152. boolean_t detect_tx_hung;
  153. /* RX */
  154. struct ixgb_desc_ring rx_ring;
  155. uint64_t hw_csum_rx_error;
  156. uint64_t hw_csum_rx_good;
  157. uint32_t rx_int_delay;
  158. boolean_t rx_csum;
  159. /* OS defined structs */
  160. struct net_device *netdev;
  161. struct pci_dev *pdev;
  162. struct net_device_stats net_stats;
  163. /* structs defined in ixgb_hw.h */
  164. struct ixgb_hw hw;
  165. u16 msg_enable;
  166. struct ixgb_hw_stats stats;
  167. uint32_t alloc_rx_buff_failed;
  168. #ifdef CONFIG_PCI_MSI
  169. boolean_t have_msi;
  170. #endif
  171. };
  172. #endif /* _IXGB_H_ */