i40e_client.h 6.8 KB

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