xref: /illumos-gate/usr/src/uts/common/io/bnxe/577xx/drivers/common/lm/vf/common/lm_vf_common.h (revision d14abf155341d55053c76eeec58b787a456b753b)
1 #ifndef _LM_VF_COMMON_H
2 #define _LM_VF_COMMON_H
3 
4 #include "lm_defs.h"
5 #define ELEM_OF_RES_ARRAY_SIZE_IN_BYTES     (sizeof(u32_t))
6 #define ELEM_OF_RES_ARRAY_SIZE_IN_BITS      (ELEM_OF_RES_ARRAY_SIZE_IN_BYTES*8)
7 
8 /* VF functions*/
9 
10 /* Description:
11 */
12 u8_t lm_vf_is_function_after_flr(struct _lm_device_t * pdev);
13 
14 lm_status_t lm_vf_setup_alloc_resc(struct _lm_device_t *pdev, u8_t b_is_alloc);
15 
16 lm_status_t lm_vf_allocate_resc_in_pf(struct _lm_device_t *pdev);
17 
18 lm_status_t
19 lm_vf_init_dev_info(struct _lm_device_t *pdev);
20 
21 lm_status_t
22 lm_vf_chip_init(struct _lm_device_t *pdev);
23 
24 lm_status_t
25 lm_vf_chip_reset(struct _lm_device_t *pdev, lm_reason_t reason);
26 
27 lm_status_t
28 lm_vf_recycle_resc_in_pf(struct _lm_device_t *pdev);
29 
30 lm_status_t
31 lm_vf_get_intr_blk_info(struct _lm_device_t *pdev);
32 
33 lm_status_t
34 lm_vf_get_bar_offset(struct _lm_device_t *pdev, u8_t bar_num, lm_address_t * bar_addr);
35 
36 lm_status_t
37 lm_vf_get_vf_id(struct _lm_device_t * pdev);
38 
39 lm_status_t
40 lm_vf_en(struct _lm_device_t * pf_dev, u16_t vf_num);
41 
42 lm_status_t
43 lm_vf_dis(struct _lm_device_t * pf_dev);
44 
45 lm_status_t
46 lm_vf_prep(struct _lm_device_t * pf_dev, struct _lm_device_t * vf_dev);
47 
48 
49 lm_status_t
50 lm_vf_get_pcicfg_info(struct _lm_device_t * pdev);
51 
52 lm_status_t
53 lm_vf_enable_vf(struct _lm_device_t *pdev);
54 
55 lm_status_t
56 lm_vf_enable_igu_int(struct _lm_device_t * pdev);
57 
58 lm_status_t
59 lm_vf_disable_igu_int(struct _lm_device_t * pdev);
60 
61 void lm_pf_fl_vf_reset_set_inprogress(struct _lm_device_t * pdev, u8_t abs_vf_id);
62 void lm_pf_fl_vf_reset_clear_inprogress(struct _lm_device_t *pdev, u8_t abs_vf_id);
63 u8_t lm_pf_fl_vf_reset_is_inprogress(struct _lm_device_t *pdev, u8_t abs_vf_id);
64 
65 /*=================================CHANNEL_VF===========================================*/
66 #define LM_FW_VF_SB_ID(_vf_info, _sb_id) ((_vf_info)->vf_chains[(_sb_id)].fw_ndsb)
67 #define LM_SW_VF_SB_ID(_vf_info, _sb_id) ((_vf_info)->vf_chains[(_sb_id)].sw_ndsb)
68 
69 #define LM_FW_VF_QZONE_ID(_vf_info, _q_zone_id) ((_vf_info)->vf_chains[(_q_zone_id)].fw_qzone_id)
70 #define LM_FW_VF_DHC_QZONE_ID(_vf_info, _q_zone_id)  ((_vf_info)->vf_chains[(_q_zone_id)].fw_qzone_id)
71 
72 #define LM_VF_IGU_SB_ID(_vf_info, _igu_sb_id) ((_vf_info)->vf_chains[(_igu_sb_id)].igu_sb_id)
73 
74 #define LM_FW_VF_STATS_CNT_ID(_vf_info) ((_vf_info)->base_fw_stats_id)
75 
76 #define LM_FW_VF_CLI_ID(_vf_info, _q_id)  ((_vf_info)->vf_chains[(_q_id)].fw_client_id)
77 #define LM_SW_VF_CLI_ID(_vf_info, _q_id)  ((_vf_info)->vf_chains[(_q_id)].sw_client_id)
78 
79 #define LM_VF_Q_ID_TO_PF_CID(_pdev,_vf_info, _q_id) ((((1 << LM_VF_MAX_RVFID_SIZE) | (_vf_info)->abs_vf_id) <<  LM_VF_CID_WND_SIZE(_pdev)) | (_q_id))
80 
81 typedef struct _lm_pf_vf_response_t
82 {
83     u32_t           state;
84 #define PF_VF_RESPONSE_FLAG_OFFSET     16
85     u16_t           recent_opcode;
86     u16_t           req_resp_state;
87 #define VF_PF_UNKNOWN_STATE                     0
88 #define VF_PF_WAIT_FOR_START_REQUEST            1
89 #define VF_PF_WAIT_FOR_NEXT_CHUNK_OF_REQUEST    2
90 #define VF_PF_REQUEST_IN_PROCESSING             3
91 #define VF_PF_RESPONSE_READY                    4
92 
93     u32_t           request_size;
94     u32_t           request_offset;
95     void *          request_virt_addr;
96     lm_address_t    request_phys_addr;
97     u32_t           response_size;
98     u32_t           response_offset;
99     void *          response_virt_addr;
100     lm_address_t    response_phys_addr;
101     lm_address_t    vf_pf_message_addr;
102 }
103     lm_pf_vf_response_t;
104 
105 typedef struct _lm_vf_location_t
106 {
107     u16_t   pci_segment_num;
108     u8_t    pci_bus_num;
109     u8_t    pci_device_num;
110     u8_t    pci_function_num;
111     u8_t    pad[3];
112 }
113     lm_vf_location_t;
114 
115 typedef struct _lm_vf_stats_t
116 {
117     struct per_queue_stats *pf_fw_stats_virt_data;
118     lm_address_t	        pf_fw_stats_phys_data;
119     lm_address_t	        vf_fw_stats_phys_data;
120     void   *mirror_stats_fw;
121 
122     u32_t                   vf_stats_state;
123 #define VF_STATS_NONE               0
124 #define VF_STATS_REQ_SUBMITTED      1
125 #define VF_STATS_REQ_IN_PROCESSING  2
126 #define VF_STATS_REQ_READY          3
127 
128     u8_t                    vf_stats_flag;
129 #define VF_STATS_COLLECT_FW_STATS_FOR_PF   0x01
130 #define VF_STATS_COLLECT_FW_STATS_FOR_VF   0x02
131 
132     u8_t                    stop_collect_stats;
133     u8_t                    do_not_collect_pf_stats;
134     u8_t                    pad;
135     u32_t                   vf_stats_cnt;
136     u32_t                   vf_exracted_stats_cnt;
137 }
138     lm_vf_stats_t;
139 
140 
141 typedef struct _lm_vf_slowpath_data_t
142 {
143     struct eth_rss_update_ramrod_data * rss_rdata;
144     lm_address_t rss_rdata_phys;
145 }
146 lm_vf_slowpath_data_t ;
147 
148 typedef struct _lm_vf_slowpath_info_t {
149     lm_vf_slowpath_data_t slowpath_data;
150 
151     #define LM_VF_SLOWPATH(vf_info, var)		(vf_info->vf_slowpath_info.slowpath_data.var)
152     #define LM_VF_SLOWPATH_PHYS(vf_info, var) (vf_info->vf_slowpath_info.slowpath_data.var##_phys)
153 
154     struct ecore_rss_config_obj rss_conf_obj;
155     volatile u32_t  sp_rss_state;
156     struct ecore_config_rss_params rss_params;
157 } lm_vf_slowpath_info_t;
158 
159 
160 typedef struct _lm_vf_chain_info_t
161 {
162     u8_t    sw_client_id;
163     u8_t    fw_client_id;
164     u8_t    fw_qzone_id;
165     u8_t    sw_ndsb;
166     u8_t    fw_ndsb;
167     u8_t    igu_sb_id;
168     u16_t   mtu;
169     u64     sge_addr;
170     struct tpa_update_ramrod_data*
171             tpa_ramrod_data_virt;
172     lm_address_t
173             tpa_ramrod_data_phys;
174 }
175     lm_vf_chain_info_t;
176 
177 typedef struct _lm_vf_tpa_info_t
178 {
179     volatile u32_t  ramrod_recv_cnt;    // Number of ramrods received.Decrement by using Interlockeddecrement.
180     u8_t            ipvx_enabled_required;
181     u8_t            ipvx_enabled_current;
182 }
183     lm_vf_tpa_info_t ;
184 
185 typedef struct _lm_vf_info_t
186 {
187     u8_t    relative_vf_id;
188     u8_t    abs_vf_id;
189     u8_t    vport_state;
190 #define VF_VPORT_STATE_DELETED              0
191 #define VF_VPORT_STATE_CREATED              1
192 #define VF_VPORT_STATE_RESET                2
193 #define VF_VPORT_STATE_REJECTED             3
194 
195     u8_t    vf_si_state;
196 #define PF_SI_WAIT_FOR_ACQUIRING_REQUEST    0
197 #define PF_SI_ACQUIRED                      1
198 #define PF_SI_VF_INITIALIZED                2
199 
200     u8_t    base_fw_stats_id;
201     u8_t    vport_instance;
202     u8_t    num_rxqs;
203     u8_t    num_txqs;
204 
205     u8_t    num_vport_chains_requested;     /* Requested via Hyper-V manager, VMNetworkAdapter setting*/
206     u8_t    num_vf_chains_requested;        /* Requested via VF/PF channel, VF acquiring */
207     u8_t    num_igu_sb_available;
208     u8_t    num_allocated_chains;
209 
210     u8_t    num_sbs;
211 
212     u8_t    num_mac_filters;
213     u8_t    num_vlan_filters;
214     u8_t    num_mc_filters;
215 
216     u8_t    is_mac_set;
217     u8_t    was_flred;
218     u8_t    was_malicious;
219 
220     u8_t    is_promiscuous_mode_restricted;
221 
222     u16_t    current_interrupr_moderation;
223 #define VPORT_INT_MOD_UNDEFINED     0
224 #define VPORT_INT_MOD_ADAPTIVE      1
225 #define VPORT_INT_MOD_OFF           2
226 #define VPORT_INT_MOD_LOW           100
227 #define VPORT_INT_MOD_MEDIUM        200
228 #define VPORT_INT_MOD_HIGH          300
229 
230     u8_t    malicious_cnt;
231     u8_t    fp_hsi_ver;
232 
233     u32_t   vf_si_num_of_active_q;
234     u32_t   base_cam_offset;
235 
236     lm_vf_chain_info_t      vf_chains[16];
237     lm_vf_location_t        vf_location;
238     lm_pf_vf_response_t     pf_vf_response;
239     lm_vf_stats_t           vf_stats;
240     lm_vf_slowpath_info_t   vf_slowpath_info;
241     lm_vf_tpa_info_t        vf_tpa_info;
242     void *  um_ctx;
243 }
244     lm_vf_info_t;
245 
246 typedef struct _lm_vfs_set_t
247 {
248     lm_vf_info_t  * vfs_array;
249     u16_t           number_of_enabled_vfs;
250     u8_t            vf_sb_cnt;
251     u8_t            pad;
252 
253     void *          req_resp_virt_addr;
254     lm_address_t    req_resp_phys_addr;
255     u32_t           req_resp_size;
256 
257     void *          pf_fw_stats_set_virt_data;
258     lm_address_t	pf_fw_stats_set_phys_data;
259     u32_t			pf_fw_stats_set_data_sz;
260 
261     u8_t *          mirror_stats_fw_set;
262 
263     void *          rss_update_virt_addr;
264     lm_address_t    rss_update_phys_addr;
265     u32_t           rss_update_size;
266 }
267     lm_vfs_set_t;
268 
269 u16_t lm_vf_pf_get_sb_running_index(struct _lm_device_t *pdev, u8_t sb_id, u8_t sm_idx);
270 u16_t lm_vf_pf_get_sb_index(struct _lm_device_t *pdev, u8_t sb_id, u8_t idx);
271 u16_t lm_vf_get_doorbell_size(struct _lm_device_t *pdev);
272 
273 #define RX_Q_VALIDATE   0x01
274 #define TX_Q_VALIDATE   0x02
275 
276 typedef enum {
277     Q_FILTER_MAC,
278     Q_FILTER_VLAN,
279     Q_FILTER_MC,
280     Q_FILTER_RX_MASK
281 } q_filter_type;
282 
283 typedef enum {
284     PFVF_BB_CHANNEL_IS_NOT_ACTIVE,
285     PFVF_BB_CHANNEL_CRC_ERR,
286     PFVF_BB_NO_UPDATE,
287     PFVF_BB_VALID_MAC,
288 } pfvf_bb_event_type;
289 
290 
291 u8_t lm_vf_is_lamac_restricted(struct _lm_device_t *pdev);
292 lm_status_t lm_pf_process_standard_request(struct _lm_device_t *pdev, lm_vf_info_t *vf_info);
293 lm_status_t lm_pf_notify_standard_request_ready(struct _lm_device_t *pdev, lm_vf_info_t *vf_info, u8_t * set_done);
294 
295 lm_status_t lm_vf_pf_acquire_msg(struct _lm_device_t * pdev);
296 lm_status_t lm_vf_pf_init_vf(struct _lm_device_t * pdev);
297 lm_status_t lm_vf_pf_setup_q(struct _lm_device_t * pdev, u8 vf_qid, u8_t validation_flag);
298 lm_status_t lm_vf_pf_tear_q_down(struct _lm_device_t * pdev, u8 vf_qid);
299 lm_status_t lm_vf_pf_set_q_filters(struct _lm_device_t * pdev, u8 vf_qid, void * cookie,
300                                    q_filter_type filter_type, u8_t * pbuf, u32_t buf_len,
301                                    u16_t vlan_tag, u8_t set_mac);
302 lm_status_t lm_vf_pf_set_q_filters_list(struct _lm_device_t * pdev, u8 vf_qid, void * cookie,
303                                         q_filter_type filter_type, d_list_t * pbuf,
304                                         u16_t vlan_tag, u8_t set_mac);
305 lm_status_t lm_vf_pf_close_vf(struct _lm_device_t * pdev);
306 lm_status_t lm_vf_pf_release_vf(struct _lm_device_t * pdev);
307 lm_status_t lm_vf_pf_update_rss(struct _lm_device_t *pdev, void * cookie, u32_t rss_flags, u8_t rss_result_mask, u8_t * ind_table, u32_t * rss_key);
308 lm_status_t lm_vf_pf_update_rsc(struct _lm_device_t *pdev);
309 
310 lm_status_t lm_vf_pf_wait_no_messages_pending(struct _lm_device_t * pdev);
311 
312 lm_status_t lm_vf_queue_init(struct _lm_device_t *pdev, u8_t cid);
313 lm_status_t lm_vf_queue_close(struct _lm_device_t *pdev, u8_t cid);
314 pfvf_bb_event_type lm_vf_check_hw_back_channel(struct _lm_device_t * pdev);
315 
316 void lm_pf_init_vf_client(struct _lm_device_t *pdev, lm_vf_info_t *vf_info, u8_t q_id);
317 void lm_pf_init_vf_slow_path(struct _lm_device_t *pdev, lm_vf_info_t *vf_info);
318 
319 lm_status_t lm_pf_init_vf_client_init_data(struct _lm_device_t *pf_dev, lm_vf_info_t *vf_info, u8_t q_id,
320                                            struct sw_vf_pf_rxq_params * rxq_params,
321                                            struct sw_vf_pf_txq_params * txq_params);
322 lm_status_t lm_pf_init_vf_non_def_sb(struct _lm_device_t *pdev, lm_vf_info_t *vf_info, u8_t sb_idx, u64 sb_addr);
323 lm_status_t lm_pf_enable_vf_igu_int(struct _lm_device_t * pdev, u8_t abs_vf_id);
324 
325 lm_status_t lm_pf_disable_vf_igu_int(struct _lm_device_t * pdev,  u8_t abs_vf_id);
326 
327 lm_status_t lm_pf_enable_vf(struct _lm_device_t *pdev,   u8_t abs_vf_id);
328 lm_status_t lm_pf_vf_wait_for_stats_ready(struct _lm_device_t *pdev, lm_vf_info_t *vf_info);
329 //struct _lm_vf_pf_message_t * lm_vf_pf_channel_get_message_to_send(struct _lm_device_t * pdev, u8  opcode);
330 //lm_status_t lm_vf_pf_channel_send(struct _lm_device_t * pdev, struct _lm_vf_pf_message_t * mess);
331 //lm_status_t lm_vf_pf_channel_wait_response(struct _lm_device_t * pdev, struct _lm_vf_pf_message_t * mess);
332 
333 /*
334 static __inline void * lm_vf_pf_channel_get_message(struct _lm_device_t * pdev)
335 {
336     return pdev->vars.vf_pf_mess.message_virt_addr;
337 }
338 */
339 
340 u8_t lm_vf_get_free_resource(u32_t * resource, u8_t min_num, u8_t max_num, u8_t num);
341 void lm_vf_acquire_resource(u32_t * presource, u8_t base_value, u8_t num);
342 u8_t lm_vf_get_resource_value(u32_t * presource, u8_t base_value);
343 void lm_vf_release_resource(u32_t * presource, u8_t base_value, u8_t num);
344 lm_status_t lm_wait_vf_config_rss_done(struct _lm_device_t *pdev, lm_vf_info_t *vf_info);
345 
346 
347 lm_status_t lm_pf_create_vf(struct _lm_device_t *pdev, u16_t rel_vf_id, void* ctx);
348 lm_status_t lm_pf_remove_vf(struct _lm_device_t *pdev, u16_t rel_vf_id);
349 lm_status_t lm_pf_cleanup_vf_after_flr(struct _lm_device_t *pdev, lm_vf_info_t *vf_info);
350 lm_status_t lm_pf_finally_release_vf(struct _lm_device_t *pdev, lm_vf_info_t *vf_info);
351 lm_status_t lm_pf_tpa_send_vf_ramrod(struct _lm_device_t *pdev, lm_vf_info_t *vf_info, u32_t q_idx, u8_t update_ipv4, u8_t update_ipv6);
352 
353 u8_t lm_is_vf_rsc_supported(struct _lm_device_t *pdev);
354 
355 void lm_pf_init_vf_filters(struct _lm_device_t *pdev, lm_vf_info_t *vf_info);
356 void lm_pf_allow_vf_promiscuous_mode(lm_vf_info_t *vf_info, u8_t is_allowed);
357 void lm_pf_int_vf_igu_sb_cleanup(struct _lm_device_t *pdev, lm_vf_info_t *vf_info, u8_t vf_chain_id);
358 #endif
359 /* */
360