i40e_client.h 5.7 KB

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