i40e_client.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /*******************************************************************************
  2. *
  3. * Intel Ethernet Controller XL710 Family Linux Driver
  4. * Copyright(c) 2013 - 2015 Intel Corporation.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms and conditions of the GNU General Public License,
  8. * version 2, as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. * The full GNU General Public License is included in this distribution in
  19. * the file called "COPYING".
  20. *
  21. * Contact Information:
  22. * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
  23. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  24. *
  25. ******************************************************************************/
  26. #ifndef _I40E_CLIENT_H_
  27. #define _I40E_CLIENT_H_
  28. #define I40E_CLIENT_STR_LENGTH 10
  29. /* Client interface version should be updated anytime there is a change in the
  30. * existing APIs or data structures.
  31. */
  32. #define I40E_CLIENT_VERSION_MAJOR 0
  33. #define I40E_CLIENT_VERSION_MINOR 01
  34. #define I40E_CLIENT_VERSION_BUILD 00
  35. #define I40E_CLIENT_VERSION_STR \
  36. __stringify(I40E_CLIENT_VERSION_MAJOR) "." \
  37. __stringify(I40E_CLIENT_VERSION_MINOR) "." \
  38. __stringify(I40E_CLIENT_VERSION_BUILD)
  39. struct i40e_client_version {
  40. u8 major;
  41. u8 minor;
  42. u8 build;
  43. u8 rsvd;
  44. };
  45. enum i40e_client_state {
  46. __I40E_CLIENT_NULL,
  47. __I40E_CLIENT_REGISTERED
  48. };
  49. enum i40e_client_instance_state {
  50. __I40E_CLIENT_INSTANCE_NONE,
  51. __I40E_CLIENT_INSTANCE_OPENED,
  52. };
  53. struct i40e_ops;
  54. struct i40e_client;
  55. /* HW does not define a type value for AEQ; only for RX/TX and CEQ.
  56. * In order for us to keep the interface simple, SW will define a
  57. * unique type value for AEQ.
  58. */
  59. #define I40E_QUEUE_TYPE_PE_AEQ 0x80
  60. #define I40E_QUEUE_INVALID_IDX 0xFFFF
  61. struct i40e_qv_info {
  62. u32 v_idx; /* msix_vector */
  63. u16 ceq_idx;
  64. u16 aeq_idx;
  65. u8 itr_idx;
  66. };
  67. struct i40e_qvlist_info {
  68. u32 num_vectors;
  69. struct i40e_qv_info qv_info[1];
  70. };
  71. #define I40E_CLIENT_MSIX_ALL 0xFFFFFFFF
  72. /* set of LAN parameters useful for clients managed by LAN */
  73. /* Struct to hold per priority info */
  74. struct i40e_prio_qos_params {
  75. u16 qs_handle; /* qs handle for prio */
  76. u8 tc; /* TC mapped to prio */
  77. u8 reserved;
  78. };
  79. #define I40E_CLIENT_MAX_USER_PRIORITY 8
  80. /* Struct to hold Client QoS */
  81. struct i40e_qos_params {
  82. struct i40e_prio_qos_params prio_qos[I40E_CLIENT_MAX_USER_PRIORITY];
  83. };
  84. struct i40e_params {
  85. struct i40e_qos_params qos;
  86. u16 mtu;
  87. };
  88. /* Structure to hold Lan device info for a client device */
  89. struct i40e_info {
  90. struct i40e_client_version version;
  91. u8 lanmac[6];
  92. struct net_device *netdev;
  93. struct pci_dev *pcidev;
  94. u8 __iomem *hw_addr;
  95. u8 fid; /* function id, PF id or VF id */
  96. #define I40E_CLIENT_FTYPE_PF 0
  97. #define I40E_CLIENT_FTYPE_VF 1
  98. u8 ftype; /* function type, PF or VF */
  99. void *pf;
  100. /* All L2 params that could change during the life span of the PF
  101. * and needs to be communicated to the client when they change
  102. */
  103. struct i40e_qvlist_info *qvlist_info;
  104. struct i40e_params params;
  105. struct i40e_ops *ops;
  106. u16 msix_count; /* number of msix vectors*/
  107. /* Array down below will be dynamically allocated based on msix_count */
  108. struct msix_entry *msix_entries;
  109. u16 itr_index; /* Which ITR index the PE driver is suppose to use */
  110. u16 fw_maj_ver; /* firmware major version */
  111. u16 fw_min_ver; /* firmware minor version */
  112. u32 fw_build; /* firmware build number */
  113. };
  114. #define I40E_CLIENT_RESET_LEVEL_PF 1
  115. #define I40E_CLIENT_RESET_LEVEL_CORE 2
  116. #define I40E_CLIENT_VSI_FLAG_TCP_PACKET_ENABLE BIT(1)
  117. struct i40e_ops {
  118. /* setup_q_vector_list enables queues with a particular vector */
  119. int (*setup_qvlist)(struct i40e_info *ldev, struct i40e_client *client,
  120. struct i40e_qvlist_info *qv_info);
  121. int (*virtchnl_send)(struct i40e_info *ldev, struct i40e_client *client,
  122. u32 vf_id, u8 *msg, u16 len);
  123. /* If the PE Engine is unresponsive, RDMA driver can request a reset.
  124. * The level helps determine the level of reset being requested.
  125. */
  126. void (*request_reset)(struct i40e_info *ldev,
  127. struct i40e_client *client, u32 level);
  128. /* API for the RDMA driver to set certain VSI flags that control
  129. * PE Engine.
  130. */
  131. int (*update_vsi_ctxt)(struct i40e_info *ldev,
  132. struct i40e_client *client,
  133. bool is_vf, u32 vf_id,
  134. u32 flag, u32 valid_flag);
  135. };
  136. struct i40e_client_ops {
  137. /* Should be called from register_client() or whenever PF is ready
  138. * to create a specific client instance.
  139. */
  140. int (*open)(struct i40e_info *ldev, struct i40e_client *client);
  141. /* Should be called when netdev is unavailable or when unregister
  142. * call comes in. If the close is happenening due to a reset being
  143. * triggered set the reset bit to true.
  144. */
  145. void (*close)(struct i40e_info *ldev, struct i40e_client *client,
  146. bool reset);
  147. /* called when some l2 managed parameters changes - mtu */
  148. void (*l2_param_change)(struct i40e_info *ldev,
  149. struct i40e_client *client,
  150. struct i40e_params *params);
  151. int (*virtchnl_receive)(struct i40e_info *ldev,
  152. struct i40e_client *client, u32 vf_id,
  153. u8 *msg, u16 len);
  154. /* called when a VF is reset by the PF */
  155. void (*vf_reset)(struct i40e_info *ldev,
  156. struct i40e_client *client, u32 vf_id);
  157. /* called when the number of VFs changes */
  158. void (*vf_enable)(struct i40e_info *ldev,
  159. struct i40e_client *client, u32 num_vfs);
  160. /* returns true if VF is capable of specified offload */
  161. int (*vf_capable)(struct i40e_info *ldev,
  162. struct i40e_client *client, u32 vf_id);
  163. };
  164. /* Client device */
  165. struct i40e_client_instance {
  166. struct list_head list;
  167. struct i40e_info lan_info;
  168. struct i40e_client *client;
  169. unsigned long state;
  170. };
  171. struct i40e_client {
  172. struct list_head list; /* list of registered clients */
  173. char name[I40E_CLIENT_STR_LENGTH];
  174. struct i40e_client_version version;
  175. unsigned long state; /* client state */
  176. atomic_t ref_cnt; /* Count of all the client devices of this kind */
  177. u32 flags;
  178. #define I40E_CLIENT_FLAGS_LAUNCH_ON_PROBE BIT(0)
  179. #define I40E_TX_FLAGS_NOTIFY_OTHER_EVENTS BIT(2)
  180. u8 type;
  181. #define I40E_CLIENT_IWARP 0
  182. const struct i40e_client_ops *ops; /* client ops provided by the client */
  183. };
  184. static inline bool i40e_client_is_registered(struct i40e_client *client)
  185. {
  186. return test_bit(__I40E_CLIENT_REGISTERED, &client->state);
  187. }
  188. /* used by clients */
  189. int i40e_register_client(struct i40e_client *client);
  190. int i40e_unregister_client(struct i40e_client *client);
  191. #endif /* _I40E_CLIENT_H_ */