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