i40e_client.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. enum i40e_client_type {
  54. I40E_CLIENT_IWARP,
  55. I40E_CLIENT_VMDQ2
  56. };
  57. struct i40e_ops;
  58. struct i40e_client;
  59. /* HW does not define a type value for AEQ; only for RX/TX and CEQ.
  60. * In order for us to keep the interface simple, SW will define a
  61. * unique type value for AEQ.
  62. */
  63. #define I40E_QUEUE_TYPE_PE_AEQ 0x80
  64. #define I40E_QUEUE_INVALID_IDX 0xFFFF
  65. struct i40e_qv_info {
  66. u32 v_idx; /* msix_vector */
  67. u16 ceq_idx;
  68. u16 aeq_idx;
  69. u8 itr_idx;
  70. };
  71. struct i40e_qvlist_info {
  72. u32 num_vectors;
  73. struct i40e_qv_info qv_info[1];
  74. };
  75. #define I40E_CLIENT_MSIX_ALL 0xFFFFFFFF
  76. /* set of LAN parameters useful for clients managed by LAN */
  77. /* Struct to hold per priority info */
  78. struct i40e_prio_qos_params {
  79. u16 qs_handle; /* qs handle for prio */
  80. u8 tc; /* TC mapped to prio */
  81. u8 reserved;
  82. };
  83. #define I40E_CLIENT_MAX_USER_PRIORITY 8
  84. /* Struct to hold Client QoS */
  85. struct i40e_qos_params {
  86. struct i40e_prio_qos_params prio_qos[I40E_CLIENT_MAX_USER_PRIORITY];
  87. };
  88. struct i40e_params {
  89. struct i40e_qos_params qos;
  90. u16 mtu;
  91. };
  92. /* Structure to hold Lan device info for a client device */
  93. struct i40e_info {
  94. struct i40e_client_version version;
  95. u8 lanmac[6];
  96. struct net_device *netdev;
  97. struct pci_dev *pcidev;
  98. u8 __iomem *hw_addr;
  99. u8 fid; /* function id, PF id or VF id */
  100. #define I40E_CLIENT_FTYPE_PF 0
  101. #define I40E_CLIENT_FTYPE_VF 1
  102. u8 ftype; /* function type, PF or VF */
  103. void *pf;
  104. /* All L2 params that could change during the life span of the PF
  105. * and needs to be communicated to the client when they change
  106. */
  107. struct i40e_qvlist_info *qvlist_info;
  108. struct i40e_params params;
  109. struct i40e_ops *ops;
  110. u16 msix_count; /* number of msix vectors*/
  111. /* Array down below will be dynamically allocated based on msix_count */
  112. struct msix_entry *msix_entries;
  113. u16 itr_index; /* Which ITR index the PE driver is suppose to use */
  114. u16 fw_maj_ver; /* firmware major version */
  115. u16 fw_min_ver; /* firmware minor version */
  116. u32 fw_build; /* firmware build number */
  117. };
  118. #define I40E_CLIENT_RESET_LEVEL_PF 1
  119. #define I40E_CLIENT_RESET_LEVEL_CORE 2
  120. #define I40E_CLIENT_VSI_FLAG_TCP_PACKET_ENABLE BIT(1)
  121. struct i40e_ops {
  122. /* setup_q_vector_list enables queues with a particular vector */
  123. int (*setup_qvlist)(struct i40e_info *ldev, struct i40e_client *client,
  124. struct i40e_qvlist_info *qv_info);
  125. int (*virtchnl_send)(struct i40e_info *ldev, struct i40e_client *client,
  126. u32 vf_id, u8 *msg, u16 len);
  127. /* If the PE Engine is unresponsive, RDMA driver can request a reset.
  128. * The level helps determine the level of reset being requested.
  129. */
  130. void (*request_reset)(struct i40e_info *ldev,
  131. struct i40e_client *client, u32 level);
  132. /* API for the RDMA driver to set certain VSI flags that control
  133. * PE Engine.
  134. */
  135. int (*update_vsi_ctxt)(struct i40e_info *ldev,
  136. struct i40e_client *client,
  137. bool is_vf, u32 vf_id,
  138. u32 flag, u32 valid_flag);
  139. };
  140. struct i40e_client_ops {
  141. /* Should be called from register_client() or whenever PF is ready
  142. * to create a specific client instance.
  143. */
  144. int (*open)(struct i40e_info *ldev, struct i40e_client *client);
  145. /* Should be called when netdev is unavailable or when unregister
  146. * call comes in. If the close is happenening due to a reset being
  147. * triggered set the reset bit to true.
  148. */
  149. void (*close)(struct i40e_info *ldev, struct i40e_client *client,
  150. bool reset);
  151. /* called when some l2 managed parameters changes - mtu */
  152. void (*l2_param_change)(struct i40e_info *ldev,
  153. struct i40e_client *client,
  154. struct i40e_params *params);
  155. int (*virtchnl_receive)(struct i40e_info *ldev,
  156. struct i40e_client *client, u32 vf_id,
  157. u8 *msg, u16 len);
  158. /* called when a VF is reset by the PF */
  159. void (*vf_reset)(struct i40e_info *ldev,
  160. struct i40e_client *client, u32 vf_id);
  161. /* called when the number of VFs changes */
  162. void (*vf_enable)(struct i40e_info *ldev,
  163. struct i40e_client *client, u32 num_vfs);
  164. /* returns true if VF is capable of specified offload */
  165. int (*vf_capable)(struct i40e_info *ldev,
  166. struct i40e_client *client, u32 vf_id);
  167. };
  168. /* Client device */
  169. struct i40e_client_instance {
  170. struct list_head list;
  171. struct i40e_info lan_info;
  172. struct i40e_client *client;
  173. unsigned long state;
  174. /* A count of all the in-progress calls to the client */
  175. atomic_t ref_cnt;
  176. };
  177. struct i40e_client {
  178. struct list_head list; /* list of registered clients */
  179. char name[I40E_CLIENT_STR_LENGTH];
  180. struct i40e_client_version version;
  181. unsigned long state; /* client state */
  182. atomic_t ref_cnt; /* Count of all the client devices of this kind */
  183. u32 flags;
  184. #define I40E_CLIENT_FLAGS_LAUNCH_ON_PROBE BIT(0)
  185. #define I40E_TX_FLAGS_NOTIFY_OTHER_EVENTS BIT(2)
  186. enum i40e_client_type type;
  187. const struct i40e_client_ops *ops; /* client ops provided by the client */
  188. };
  189. static inline bool i40e_client_is_registered(struct i40e_client *client)
  190. {
  191. return test_bit(__I40E_CLIENT_REGISTERED, &client->state);
  192. }
  193. /* used by clients */
  194. int i40e_register_client(struct i40e_client *client);
  195. int i40e_unregister_client(struct i40e_client *client);
  196. #endif /* _I40E_CLIENT_H_ */