ixgb.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. struct ixgb_adapter;
  42. #include "ixgb_hw.h"
  43. #include "ixgb_ee.h"
  44. #include "ixgb_ids.h"
  45. /* TX/RX descriptor defines */
  46. #define DEFAULT_TXD 256
  47. #define MAX_TXD 4096
  48. #define MIN_TXD 64
  49. /* hardware cannot reliably support more than 512 descriptors owned by
  50. * hardware descriptor cache otherwise an unreliable ring under heavy
  51. * receive load may result */
  52. #define DEFAULT_RXD 512
  53. #define MAX_RXD 512
  54. #define MIN_RXD 64
  55. /* Supported Rx Buffer Sizes */
  56. #define IXGB_RXBUFFER_2048 2048
  57. #define IXGB_RXBUFFER_4096 4096
  58. #define IXGB_RXBUFFER_8192 8192
  59. #define IXGB_RXBUFFER_16384 16384
  60. /* How many Rx Buffers do we bundle into one write to the hardware ? */
  61. #define IXGB_RX_BUFFER_WRITE 8 /* Must be power of 2 */
  62. /* wrapper around a pointer to a socket buffer,
  63. * so a DMA handle can be stored along with the buffer */
  64. struct ixgb_buffer {
  65. struct sk_buff *skb;
  66. dma_addr_t dma;
  67. unsigned long time_stamp;
  68. u16 length;
  69. u16 next_to_watch;
  70. u16 mapped_as_page;
  71. };
  72. struct ixgb_desc_ring {
  73. /* pointer to the descriptor ring memory */
  74. void *desc;
  75. /* physical address of the descriptor ring */
  76. dma_addr_t dma;
  77. /* length of descriptor ring in bytes */
  78. unsigned int size;
  79. /* number of descriptors in the ring */
  80. unsigned int count;
  81. /* next descriptor to associate a buffer with */
  82. unsigned int next_to_use;
  83. /* next descriptor to check for DD status bit */
  84. unsigned int next_to_clean;
  85. /* array of buffer information structs */
  86. struct ixgb_buffer *buffer_info;
  87. };
  88. #define IXGB_DESC_UNUSED(R) \
  89. ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
  90. (R)->next_to_clean - (R)->next_to_use - 1)
  91. #define IXGB_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i]))
  92. #define IXGB_RX_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_rx_desc)
  93. #define IXGB_TX_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_tx_desc)
  94. #define IXGB_CONTEXT_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_context_desc)
  95. /* board specific private data structure */
  96. struct ixgb_adapter {
  97. struct timer_list watchdog_timer;
  98. unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
  99. u32 bd_number;
  100. u32 rx_buffer_len;
  101. u32 part_num;
  102. u16 link_speed;
  103. u16 link_duplex;
  104. struct work_struct tx_timeout_task;
  105. /* TX */
  106. struct ixgb_desc_ring tx_ring ____cacheline_aligned_in_smp;
  107. unsigned int restart_queue;
  108. unsigned long timeo_start;
  109. u32 tx_cmd_type;
  110. u64 hw_csum_tx_good;
  111. u64 hw_csum_tx_error;
  112. u32 tx_int_delay;
  113. u32 tx_timeout_count;
  114. bool tx_int_delay_enable;
  115. bool detect_tx_hung;
  116. /* RX */
  117. struct ixgb_desc_ring rx_ring;
  118. u64 hw_csum_rx_error;
  119. u64 hw_csum_rx_good;
  120. u32 rx_int_delay;
  121. bool rx_csum;
  122. /* OS defined structs */
  123. struct napi_struct napi;
  124. struct net_device *netdev;
  125. struct pci_dev *pdev;
  126. /* structs defined in ixgb_hw.h */
  127. struct ixgb_hw hw;
  128. u16 msg_enable;
  129. struct ixgb_hw_stats stats;
  130. u32 alloc_rx_buff_failed;
  131. bool have_msi;
  132. unsigned long flags;
  133. };
  134. enum ixgb_state_t {
  135. /* TBD
  136. __IXGB_TESTING,
  137. __IXGB_RESETTING,
  138. */
  139. __IXGB_DOWN
  140. };
  141. /* Exported from other modules */
  142. void ixgb_check_options(struct ixgb_adapter *adapter);
  143. void ixgb_set_ethtool_ops(struct net_device *netdev);
  144. extern char ixgb_driver_name[];
  145. void ixgb_set_speed_duplex(struct net_device *netdev);
  146. int ixgb_up(struct ixgb_adapter *adapter);
  147. void ixgb_down(struct ixgb_adapter *adapter, bool kill_watchdog);
  148. void ixgb_reset(struct ixgb_adapter *adapter);
  149. int ixgb_setup_rx_resources(struct ixgb_adapter *adapter);
  150. int ixgb_setup_tx_resources(struct ixgb_adapter *adapter);
  151. void ixgb_free_rx_resources(struct ixgb_adapter *adapter);
  152. void ixgb_free_tx_resources(struct ixgb_adapter *adapter);
  153. void ixgb_update_stats(struct ixgb_adapter *adapter);
  154. #endif /* _IXGB_H_ */