i40e_client.h 5.3 KB

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