i40evf_client.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _I40E_CLIENT_H_
  3. #define _I40E_CLIENT_H_
  4. #define I40EVF_CLIENT_STR_LENGTH 10
  5. /* Client interface version should be updated anytime there is a change in the
  6. * existing APIs or data structures.
  7. */
  8. #define I40EVF_CLIENT_VERSION_MAJOR 0
  9. #define I40EVF_CLIENT_VERSION_MINOR 01
  10. #define I40EVF_CLIENT_VERSION_BUILD 00
  11. #define I40EVF_CLIENT_VERSION_STR \
  12. __stringify(I40EVF_CLIENT_VERSION_MAJOR) "." \
  13. __stringify(I40EVF_CLIENT_VERSION_MINOR) "." \
  14. __stringify(I40EVF_CLIENT_VERSION_BUILD)
  15. struct i40e_client_version {
  16. u8 major;
  17. u8 minor;
  18. u8 build;
  19. u8 rsvd;
  20. };
  21. enum i40e_client_state {
  22. __I40E_CLIENT_NULL,
  23. __I40E_CLIENT_REGISTERED
  24. };
  25. enum i40e_client_instance_state {
  26. __I40E_CLIENT_INSTANCE_NONE,
  27. __I40E_CLIENT_INSTANCE_OPENED,
  28. };
  29. struct i40e_ops;
  30. struct i40e_client;
  31. /* HW does not define a type value for AEQ; only for RX/TX and CEQ.
  32. * In order for us to keep the interface simple, SW will define a
  33. * unique type value for AEQ.
  34. */
  35. #define I40E_QUEUE_TYPE_PE_AEQ 0x80
  36. #define I40E_QUEUE_INVALID_IDX 0xFFFF
  37. struct i40e_qv_info {
  38. u32 v_idx; /* msix_vector */
  39. u16 ceq_idx;
  40. u16 aeq_idx;
  41. u8 itr_idx;
  42. };
  43. struct i40e_qvlist_info {
  44. u32 num_vectors;
  45. struct i40e_qv_info qv_info[1];
  46. };
  47. #define I40E_CLIENT_MSIX_ALL 0xFFFFFFFF
  48. /* set of LAN parameters useful for clients managed by LAN */
  49. /* Struct to hold per priority info */
  50. struct i40e_prio_qos_params {
  51. u16 qs_handle; /* qs handle for prio */
  52. u8 tc; /* TC mapped to prio */
  53. u8 reserved;
  54. };
  55. #define I40E_CLIENT_MAX_USER_PRIORITY 8
  56. /* Struct to hold Client QoS */
  57. struct i40e_qos_params {
  58. struct i40e_prio_qos_params prio_qos[I40E_CLIENT_MAX_USER_PRIORITY];
  59. };
  60. struct i40e_params {
  61. struct i40e_qos_params qos;
  62. u16 mtu;
  63. u16 link_up; /* boolean */
  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 *vf; /* cast to i40evf_adapter */
  77. /* All L2 params that could change during the life span of the device
  78. * and needs to be communicated to the client when they change
  79. */
  80. struct i40e_params params;
  81. struct i40e_ops *ops;
  82. u16 msix_count; /* number of msix vectors*/
  83. /* Array down below will be dynamically allocated based on msix_count */
  84. struct msix_entry *msix_entries;
  85. u16 itr_index; /* Which ITR index the PE driver is suppose to use */
  86. };
  87. struct i40e_ops {
  88. /* setup_q_vector_list enables queues with a particular vector */
  89. int (*setup_qvlist)(struct i40e_info *ldev, struct i40e_client *client,
  90. struct i40e_qvlist_info *qv_info);
  91. u32 (*virtchnl_send)(struct i40e_info *ldev, struct i40e_client *client,
  92. u8 *msg, u16 len);
  93. /* If the PE Engine is unresponsive, RDMA driver can request a reset.*/
  94. void (*request_reset)(struct i40e_info *ldev,
  95. struct i40e_client *client);
  96. };
  97. struct i40e_client_ops {
  98. /* Should be called from register_client() or whenever the driver is
  99. * ready to create a specific client instance.
  100. */
  101. int (*open)(struct i40e_info *ldev, struct i40e_client *client);
  102. /* Should be closed when netdev is unavailable or when unregister
  103. * call comes in. If the close happens due to a reset, set the reset
  104. * bit to true.
  105. */
  106. void (*close)(struct i40e_info *ldev, struct i40e_client *client,
  107. bool reset);
  108. /* called when some l2 managed parameters changes - mss */
  109. void (*l2_param_change)(struct i40e_info *ldev,
  110. struct i40e_client *client,
  111. struct i40e_params *params);
  112. /* called when a message is received from the PF */
  113. int (*virtchnl_receive)(struct i40e_info *ldev,
  114. struct i40e_client *client,
  115. u8 *msg, u16 len);
  116. };
  117. /* Client device */
  118. struct i40e_client_instance {
  119. struct list_head list;
  120. struct i40e_info lan_info;
  121. struct i40e_client *client;
  122. unsigned long state;
  123. };
  124. struct i40e_client {
  125. struct list_head list; /* list of registered clients */
  126. char name[I40EVF_CLIENT_STR_LENGTH];
  127. struct i40e_client_version version;
  128. unsigned long state; /* client state */
  129. atomic_t ref_cnt; /* Count of all the client devices of this kind */
  130. u32 flags;
  131. #define I40E_CLIENT_FLAGS_LAUNCH_ON_PROBE BIT(0)
  132. #define I40E_TX_FLAGS_NOTIFY_OTHER_EVENTS BIT(2)
  133. u8 type;
  134. #define I40E_CLIENT_IWARP 0
  135. struct i40e_client_ops *ops; /* client ops provided by the client */
  136. };
  137. /* used by clients */
  138. int i40evf_register_client(struct i40e_client *client);
  139. int i40evf_unregister_client(struct i40e_client *client);
  140. #endif /* _I40E_CLIENT_H_ */