ixgb.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright(c) 1999 - 2008 Intel Corporation. */
  3. #ifndef _IXGB_H_
  4. #define _IXGB_H_
  5. #include <linux/stddef.h>
  6. #include <linux/module.h>
  7. #include <linux/types.h>
  8. #include <asm/byteorder.h>
  9. #include <linux/mm.h>
  10. #include <linux/errno.h>
  11. #include <linux/ioport.h>
  12. #include <linux/pci.h>
  13. #include <linux/kernel.h>
  14. #include <linux/netdevice.h>
  15. #include <linux/etherdevice.h>
  16. #include <linux/skbuff.h>
  17. #include <linux/delay.h>
  18. #include <linux/timer.h>
  19. #include <linux/slab.h>
  20. #include <linux/vmalloc.h>
  21. #include <linux/interrupt.h>
  22. #include <linux/string.h>
  23. #include <linux/pagemap.h>
  24. #include <linux/dma-mapping.h>
  25. #include <linux/bitops.h>
  26. #include <asm/io.h>
  27. #include <asm/irq.h>
  28. #include <linux/capability.h>
  29. #include <linux/in.h>
  30. #include <linux/ip.h>
  31. #include <linux/tcp.h>
  32. #include <linux/udp.h>
  33. #include <net/pkt_sched.h>
  34. #include <linux/list.h>
  35. #include <linux/reboot.h>
  36. #include <net/checksum.h>
  37. #include <linux/ethtool.h>
  38. #include <linux/if_vlan.h>
  39. #define BAR_0 0
  40. #define BAR_1 1
  41. #define BAR_5 5
  42. struct ixgb_adapter;
  43. #include "ixgb_hw.h"
  44. #include "ixgb_ee.h"
  45. #include "ixgb_ids.h"
  46. /* TX/RX descriptor defines */
  47. #define DEFAULT_TXD 256
  48. #define MAX_TXD 4096
  49. #define MIN_TXD 64
  50. /* hardware cannot reliably support more than 512 descriptors owned by
  51. * hardware descriptor cache otherwise an unreliable ring under heavy
  52. * receive load may result */
  53. #define DEFAULT_RXD 512
  54. #define MAX_RXD 512
  55. #define MIN_RXD 64
  56. /* Supported Rx Buffer Sizes */
  57. #define IXGB_RXBUFFER_2048 2048
  58. #define IXGB_RXBUFFER_4096 4096
  59. #define IXGB_RXBUFFER_8192 8192
  60. #define IXGB_RXBUFFER_16384 16384
  61. /* How many Rx Buffers do we bundle into one write to the hardware ? */
  62. #define IXGB_RX_BUFFER_WRITE 8 /* Must be power of 2 */
  63. /* wrapper around a pointer to a socket buffer,
  64. * so a DMA handle can be stored along with the buffer */
  65. struct ixgb_buffer {
  66. struct sk_buff *skb;
  67. dma_addr_t dma;
  68. unsigned long time_stamp;
  69. u16 length;
  70. u16 next_to_watch;
  71. u16 mapped_as_page;
  72. };
  73. struct ixgb_desc_ring {
  74. /* pointer to the descriptor ring memory */
  75. void *desc;
  76. /* physical address of the descriptor ring */
  77. dma_addr_t dma;
  78. /* length of descriptor ring in bytes */
  79. unsigned int size;
  80. /* number of descriptors in the ring */
  81. unsigned int count;
  82. /* next descriptor to associate a buffer with */
  83. unsigned int next_to_use;
  84. /* next descriptor to check for DD status bit */
  85. unsigned int next_to_clean;
  86. /* array of buffer information structs */
  87. struct ixgb_buffer *buffer_info;
  88. };
  89. #define IXGB_DESC_UNUSED(R) \
  90. ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
  91. (R)->next_to_clean - (R)->next_to_use - 1)
  92. #define IXGB_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i]))
  93. #define IXGB_RX_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_rx_desc)
  94. #define IXGB_TX_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_tx_desc)
  95. #define IXGB_CONTEXT_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_context_desc)
  96. /* board specific private data structure */
  97. struct ixgb_adapter {
  98. struct timer_list watchdog_timer;
  99. unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
  100. u32 bd_number;
  101. u32 rx_buffer_len;
  102. u32 part_num;
  103. u16 link_speed;
  104. u16 link_duplex;
  105. struct work_struct tx_timeout_task;
  106. /* TX */
  107. struct ixgb_desc_ring tx_ring ____cacheline_aligned_in_smp;
  108. unsigned int restart_queue;
  109. unsigned long timeo_start;
  110. u32 tx_cmd_type;
  111. u64 hw_csum_tx_good;
  112. u64 hw_csum_tx_error;
  113. u32 tx_int_delay;
  114. u32 tx_timeout_count;
  115. bool tx_int_delay_enable;
  116. bool detect_tx_hung;
  117. /* RX */
  118. struct ixgb_desc_ring rx_ring;
  119. u64 hw_csum_rx_error;
  120. u64 hw_csum_rx_good;
  121. u32 rx_int_delay;
  122. bool rx_csum;
  123. /* OS defined structs */
  124. struct napi_struct napi;
  125. struct net_device *netdev;
  126. struct pci_dev *pdev;
  127. /* structs defined in ixgb_hw.h */
  128. struct ixgb_hw hw;
  129. u16 msg_enable;
  130. struct ixgb_hw_stats stats;
  131. u32 alloc_rx_buff_failed;
  132. bool have_msi;
  133. unsigned long flags;
  134. };
  135. enum ixgb_state_t {
  136. /* TBD
  137. __IXGB_TESTING,
  138. __IXGB_RESETTING,
  139. */
  140. __IXGB_DOWN
  141. };
  142. /* Exported from other modules */
  143. void ixgb_check_options(struct ixgb_adapter *adapter);
  144. void ixgb_set_ethtool_ops(struct net_device *netdev);
  145. extern char ixgb_driver_name[];
  146. extern const char ixgb_driver_version[];
  147. void ixgb_set_speed_duplex(struct net_device *netdev);
  148. int ixgb_up(struct ixgb_adapter *adapter);
  149. void ixgb_down(struct ixgb_adapter *adapter, bool kill_watchdog);
  150. void ixgb_reset(struct ixgb_adapter *adapter);
  151. int ixgb_setup_rx_resources(struct ixgb_adapter *adapter);
  152. int ixgb_setup_tx_resources(struct ixgb_adapter *adapter);
  153. void ixgb_free_rx_resources(struct ixgb_adapter *adapter);
  154. void ixgb_free_tx_resources(struct ixgb_adapter *adapter);
  155. void ixgb_update_stats(struct ixgb_adapter *adapter);
  156. #endif /* _IXGB_H_ */