vf.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright(c) 2009 - 2018 Intel Corporation. */
  3. #ifndef _E1000_VF_H_
  4. #define _E1000_VF_H_
  5. #include <linux/pci.h>
  6. #include <linux/delay.h>
  7. #include <linux/interrupt.h>
  8. #include <linux/if_ether.h>
  9. #include "regs.h"
  10. #include "defines.h"
  11. struct e1000_hw;
  12. #define E1000_DEV_ID_82576_VF 0x10CA
  13. #define E1000_DEV_ID_I350_VF 0x1520
  14. #define E1000_REVISION_0 0
  15. #define E1000_REVISION_1 1
  16. #define E1000_REVISION_2 2
  17. #define E1000_REVISION_3 3
  18. #define E1000_REVISION_4 4
  19. #define E1000_FUNC_0 0
  20. #define E1000_FUNC_1 1
  21. /* Receive Address Register Count
  22. * Number of high/low register pairs in the RAR. The RAR (Receive Address
  23. * Registers) holds the directed and multicast addresses that we monitor.
  24. * These entries are also used for MAC-based filtering.
  25. */
  26. #define E1000_RAR_ENTRIES_VF 1
  27. /* Receive Descriptor - Advanced */
  28. union e1000_adv_rx_desc {
  29. struct {
  30. u64 pkt_addr; /* Packet buffer address */
  31. u64 hdr_addr; /* Header buffer address */
  32. } read;
  33. struct {
  34. struct {
  35. union {
  36. u32 data;
  37. struct {
  38. u16 pkt_info; /* RSS/Packet type */
  39. /* Split Header, hdr buffer length */
  40. u16 hdr_info;
  41. } hs_rss;
  42. } lo_dword;
  43. union {
  44. u32 rss; /* RSS Hash */
  45. struct {
  46. u16 ip_id; /* IP id */
  47. u16 csum; /* Packet Checksum */
  48. } csum_ip;
  49. } hi_dword;
  50. } lower;
  51. struct {
  52. u32 status_error; /* ext status/error */
  53. u16 length; /* Packet length */
  54. u16 vlan; /* VLAN tag */
  55. } upper;
  56. } wb; /* writeback */
  57. };
  58. #define E1000_RXDADV_HDRBUFLEN_MASK 0x7FE0
  59. #define E1000_RXDADV_HDRBUFLEN_SHIFT 5
  60. /* Transmit Descriptor - Advanced */
  61. union e1000_adv_tx_desc {
  62. struct {
  63. u64 buffer_addr; /* Address of descriptor's data buf */
  64. u32 cmd_type_len;
  65. u32 olinfo_status;
  66. } read;
  67. struct {
  68. u64 rsvd; /* Reserved */
  69. u32 nxtseq_seed;
  70. u32 status;
  71. } wb;
  72. };
  73. /* Adv Transmit Descriptor Config Masks */
  74. #define E1000_ADVTXD_DTYP_CTXT 0x00200000 /* Advanced Context Descriptor */
  75. #define E1000_ADVTXD_DTYP_DATA 0x00300000 /* Advanced Data Descriptor */
  76. #define E1000_ADVTXD_DCMD_EOP 0x01000000 /* End of Packet */
  77. #define E1000_ADVTXD_DCMD_IFCS 0x02000000 /* Insert FCS (Ethernet CRC) */
  78. #define E1000_ADVTXD_DCMD_RS 0x08000000 /* Report Status */
  79. #define E1000_ADVTXD_DCMD_DEXT 0x20000000 /* Descriptor extension (1=Adv) */
  80. #define E1000_ADVTXD_DCMD_VLE 0x40000000 /* VLAN pkt enable */
  81. #define E1000_ADVTXD_DCMD_TSE 0x80000000 /* TCP Seg enable */
  82. #define E1000_ADVTXD_PAYLEN_SHIFT 14 /* Adv desc PAYLEN shift */
  83. /* Context descriptors */
  84. struct e1000_adv_tx_context_desc {
  85. u32 vlan_macip_lens;
  86. u32 seqnum_seed;
  87. u32 type_tucmd_mlhl;
  88. u32 mss_l4len_idx;
  89. };
  90. #define E1000_ADVTXD_MACLEN_SHIFT 9 /* Adv ctxt desc mac len shift */
  91. #define E1000_ADVTXD_TUCMD_IPV4 0x00000400 /* IP Packet Type: 1=IPv4 */
  92. #define E1000_ADVTXD_TUCMD_L4T_TCP 0x00000800 /* L4 Packet TYPE of TCP */
  93. #define E1000_ADVTXD_TUCMD_L4T_SCTP 0x00001000 /* L4 packet TYPE of SCTP */
  94. #define E1000_ADVTXD_L4LEN_SHIFT 8 /* Adv ctxt L4LEN shift */
  95. #define E1000_ADVTXD_MSS_SHIFT 16 /* Adv ctxt MSS shift */
  96. enum e1000_mac_type {
  97. e1000_undefined = 0,
  98. e1000_vfadapt,
  99. e1000_vfadapt_i350,
  100. e1000_num_macs /* List is 1-based, so subtract 1 for true count. */
  101. };
  102. struct e1000_vf_stats {
  103. u64 base_gprc;
  104. u64 base_gptc;
  105. u64 base_gorc;
  106. u64 base_gotc;
  107. u64 base_mprc;
  108. u64 base_gotlbc;
  109. u64 base_gptlbc;
  110. u64 base_gorlbc;
  111. u64 base_gprlbc;
  112. u32 last_gprc;
  113. u32 last_gptc;
  114. u32 last_gorc;
  115. u32 last_gotc;
  116. u32 last_mprc;
  117. u32 last_gotlbc;
  118. u32 last_gptlbc;
  119. u32 last_gorlbc;
  120. u32 last_gprlbc;
  121. u64 gprc;
  122. u64 gptc;
  123. u64 gorc;
  124. u64 gotc;
  125. u64 mprc;
  126. u64 gotlbc;
  127. u64 gptlbc;
  128. u64 gorlbc;
  129. u64 gprlbc;
  130. };
  131. #include "mbx.h"
  132. struct e1000_mac_operations {
  133. /* Function pointers for the MAC. */
  134. s32 (*init_params)(struct e1000_hw *);
  135. s32 (*check_for_link)(struct e1000_hw *);
  136. void (*clear_vfta)(struct e1000_hw *);
  137. s32 (*get_bus_info)(struct e1000_hw *);
  138. s32 (*get_link_up_info)(struct e1000_hw *, u16 *, u16 *);
  139. void (*update_mc_addr_list)(struct e1000_hw *, u8 *, u32, u32, u32);
  140. s32 (*set_uc_addr)(struct e1000_hw *, u32, u8 *);
  141. s32 (*reset_hw)(struct e1000_hw *);
  142. s32 (*init_hw)(struct e1000_hw *);
  143. s32 (*setup_link)(struct e1000_hw *);
  144. void (*write_vfta)(struct e1000_hw *, u32, u32);
  145. void (*mta_set)(struct e1000_hw *, u32);
  146. void (*rar_set)(struct e1000_hw *, u8*, u32);
  147. s32 (*read_mac_addr)(struct e1000_hw *);
  148. s32 (*set_vfta)(struct e1000_hw *, u16, bool);
  149. };
  150. struct e1000_mac_info {
  151. struct e1000_mac_operations ops;
  152. u8 addr[6];
  153. u8 perm_addr[6];
  154. enum e1000_mac_type type;
  155. u16 mta_reg_count;
  156. u16 rar_entry_count;
  157. bool get_link_status;
  158. };
  159. struct e1000_mbx_operations {
  160. s32 (*init_params)(struct e1000_hw *hw);
  161. s32 (*read)(struct e1000_hw *, u32 *, u16);
  162. s32 (*write)(struct e1000_hw *, u32 *, u16);
  163. s32 (*read_posted)(struct e1000_hw *, u32 *, u16);
  164. s32 (*write_posted)(struct e1000_hw *, u32 *, u16);
  165. s32 (*check_for_msg)(struct e1000_hw *);
  166. s32 (*check_for_ack)(struct e1000_hw *);
  167. s32 (*check_for_rst)(struct e1000_hw *);
  168. };
  169. struct e1000_mbx_stats {
  170. u32 msgs_tx;
  171. u32 msgs_rx;
  172. u32 acks;
  173. u32 reqs;
  174. u32 rsts;
  175. };
  176. struct e1000_mbx_info {
  177. struct e1000_mbx_operations ops;
  178. struct e1000_mbx_stats stats;
  179. u32 timeout;
  180. u32 usec_delay;
  181. u16 size;
  182. };
  183. struct e1000_dev_spec_vf {
  184. u32 vf_number;
  185. u32 v2p_mailbox;
  186. };
  187. struct e1000_hw {
  188. void *back;
  189. u8 __iomem *hw_addr;
  190. u8 __iomem *flash_address;
  191. unsigned long io_base;
  192. struct e1000_mac_info mac;
  193. struct e1000_mbx_info mbx;
  194. spinlock_t mbx_lock; /* serializes mailbox ops */
  195. union {
  196. struct e1000_dev_spec_vf vf;
  197. } dev_spec;
  198. u16 device_id;
  199. u16 subsystem_vendor_id;
  200. u16 subsystem_device_id;
  201. u16 vendor_id;
  202. u8 revision_id;
  203. };
  204. /* These functions must be implemented by drivers */
  205. void e1000_rlpml_set_vf(struct e1000_hw *, u16);
  206. void e1000_init_function_pointers_vf(struct e1000_hw *hw);
  207. #endif /* _E1000_VF_H_ */