i40evf_client.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright(c) 2013 - 2018 Intel Corporation. */
  3. #ifndef _I40EVF_CLIENT_H_
  4. #define _I40EVF_CLIENT_H_
  5. #define I40EVF_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 I40EVF_CLIENT_VERSION_MAJOR 0
  10. #define I40EVF_CLIENT_VERSION_MINOR 01
  11. #define I40EVF_CLIENT_VERSION_BUILD 00
  12. #define I40EVF_CLIENT_VERSION_STR \
  13. __stringify(I40EVF_CLIENT_VERSION_MAJOR) "." \
  14. __stringify(I40EVF_CLIENT_VERSION_MINOR) "." \
  15. __stringify(I40EVF_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. u16 link_up; /* boolean */
  65. };
  66. /* Structure to hold LAN device info for a client device */
  67. struct i40e_info {
  68. struct i40e_client_version version;
  69. u8 lanmac[6];
  70. struct net_device *netdev;
  71. struct pci_dev *pcidev;
  72. u8 __iomem *hw_addr;
  73. u8 fid; /* function id, PF id or VF id */
  74. #define I40E_CLIENT_FTYPE_PF 0
  75. #define I40E_CLIENT_FTYPE_VF 1
  76. u8 ftype; /* function type, PF or VF */
  77. void *vf; /* cast to i40evf_adapter */
  78. /* All L2 params that could change during the life span of the device
  79. * and needs to be communicated to the client when they change
  80. */
  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. };
  88. struct i40e_ops {
  89. /* setup_q_vector_list enables queues with a particular vector */
  90. int (*setup_qvlist)(struct i40e_info *ldev, struct i40e_client *client,
  91. struct i40e_qvlist_info *qv_info);
  92. u32 (*virtchnl_send)(struct i40e_info *ldev, struct i40e_client *client,
  93. u8 *msg, u16 len);
  94. /* If the PE Engine is unresponsive, RDMA driver can request a reset.*/
  95. void (*request_reset)(struct i40e_info *ldev,
  96. struct i40e_client *client);
  97. };
  98. struct i40e_client_ops {
  99. /* Should be called from register_client() or whenever the driver is
  100. * ready to create a specific client instance.
  101. */
  102. int (*open)(struct i40e_info *ldev, struct i40e_client *client);
  103. /* Should be closed when netdev is unavailable or when unregister
  104. * call comes in. If the close happens due to a reset, set the reset
  105. * bit to true.
  106. */
  107. void (*close)(struct i40e_info *ldev, struct i40e_client *client,
  108. bool reset);
  109. /* called when some l2 managed parameters changes - mss */
  110. void (*l2_param_change)(struct i40e_info *ldev,
  111. struct i40e_client *client,
  112. struct i40e_params *params);
  113. /* called when a message is received from the PF */
  114. int (*virtchnl_receive)(struct i40e_info *ldev,
  115. struct i40e_client *client,
  116. u8 *msg, u16 len);
  117. };
  118. /* Client device */
  119. struct i40e_client_instance {
  120. struct list_head list;
  121. struct i40e_info lan_info;
  122. struct i40e_client *client;
  123. unsigned long state;
  124. };
  125. struct i40e_client {
  126. struct list_head list; /* list of registered clients */
  127. char name[I40EVF_CLIENT_STR_LENGTH];
  128. struct i40e_client_version version;
  129. unsigned long state; /* client state */
  130. atomic_t ref_cnt; /* Count of all the client devices of this kind */
  131. u32 flags;
  132. #define I40E_CLIENT_FLAGS_LAUNCH_ON_PROBE BIT(0)
  133. #define I40E_TX_FLAGS_NOTIFY_OTHER_EVENTS BIT(2)
  134. u8 type;
  135. #define I40E_CLIENT_IWARP 0
  136. struct i40e_client_ops *ops; /* client ops provided by the client */
  137. };
  138. /* used by clients */
  139. int i40evf_register_client(struct i40e_client *client);
  140. int i40evf_unregister_client(struct i40e_client *client);
  141. #endif /* _I40EVF_CLIENT_H_ */