i40evf_client.h 4.5 KB

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