xref: /linux/include/linux/qed/qed_if.h (revision bd628c1bed7902ec1f24ba0fe70758949146abbe)
1 /* QLogic qed NIC Driver
2  * Copyright (c) 2015-2017  QLogic Corporation
3  *
4  * This software is available to you under a choice of one of two
5  * licenses.  You may choose to be licensed under the terms of the GNU
6  * General Public License (GPL) Version 2, available from the file
7  * COPYING in the main directory of this source tree, or the
8  * OpenIB.org BSD license below:
9  *
10  *     Redistribution and use in source and binary forms, with or
11  *     without modification, are permitted provided that the following
12  *     conditions are met:
13  *
14  *      - Redistributions of source code must retain the above
15  *        copyright notice, this list of conditions and the following
16  *        disclaimer.
17  *
18  *      - Redistributions in binary form must reproduce the above
19  *        copyright notice, this list of conditions and the following
20  *        disclaimer in the documentation and /or other materials
21  *        provided with the distribution.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30  * SOFTWARE.
31  */
32 
33 #ifndef _QED_IF_H
34 #define _QED_IF_H
35 
36 #include <linux/types.h>
37 #include <linux/interrupt.h>
38 #include <linux/netdevice.h>
39 #include <linux/pci.h>
40 #include <linux/skbuff.h>
41 #include <linux/types.h>
42 #include <asm/byteorder.h>
43 #include <linux/io.h>
44 #include <linux/compiler.h>
45 #include <linux/kernel.h>
46 #include <linux/list.h>
47 #include <linux/slab.h>
48 #include <linux/qed/common_hsi.h>
49 #include <linux/qed/qed_chain.h>
50 #include <linux/io-64-nonatomic-lo-hi.h>
51 
52 enum dcbx_protocol_type {
53 	DCBX_PROTOCOL_ISCSI,
54 	DCBX_PROTOCOL_FCOE,
55 	DCBX_PROTOCOL_ROCE,
56 	DCBX_PROTOCOL_ROCE_V2,
57 	DCBX_PROTOCOL_ETH,
58 	DCBX_MAX_PROTOCOL_TYPE
59 };
60 
61 #define QED_ROCE_PROTOCOL_INDEX (3)
62 
63 #define QED_LLDP_CHASSIS_ID_STAT_LEN 4
64 #define QED_LLDP_PORT_ID_STAT_LEN 4
65 #define QED_DCBX_MAX_APP_PROTOCOL 32
66 #define QED_MAX_PFC_PRIORITIES 8
67 #define QED_DCBX_DSCP_SIZE 64
68 
69 struct qed_dcbx_lldp_remote {
70 	u32 peer_chassis_id[QED_LLDP_CHASSIS_ID_STAT_LEN];
71 	u32 peer_port_id[QED_LLDP_PORT_ID_STAT_LEN];
72 	bool enable_rx;
73 	bool enable_tx;
74 	u32 tx_interval;
75 	u32 max_credit;
76 };
77 
78 struct qed_dcbx_lldp_local {
79 	u32 local_chassis_id[QED_LLDP_CHASSIS_ID_STAT_LEN];
80 	u32 local_port_id[QED_LLDP_PORT_ID_STAT_LEN];
81 };
82 
83 struct qed_dcbx_app_prio {
84 	u8 roce;
85 	u8 roce_v2;
86 	u8 fcoe;
87 	u8 iscsi;
88 	u8 eth;
89 };
90 
91 struct qed_dbcx_pfc_params {
92 	bool willing;
93 	bool enabled;
94 	u8 prio[QED_MAX_PFC_PRIORITIES];
95 	u8 max_tc;
96 };
97 
98 enum qed_dcbx_sf_ieee_type {
99 	QED_DCBX_SF_IEEE_ETHTYPE,
100 	QED_DCBX_SF_IEEE_TCP_PORT,
101 	QED_DCBX_SF_IEEE_UDP_PORT,
102 	QED_DCBX_SF_IEEE_TCP_UDP_PORT
103 };
104 
105 struct qed_app_entry {
106 	bool ethtype;
107 	enum qed_dcbx_sf_ieee_type sf_ieee;
108 	bool enabled;
109 	u8 prio;
110 	u16 proto_id;
111 	enum dcbx_protocol_type proto_type;
112 };
113 
114 struct qed_dcbx_params {
115 	struct qed_app_entry app_entry[QED_DCBX_MAX_APP_PROTOCOL];
116 	u16 num_app_entries;
117 	bool app_willing;
118 	bool app_valid;
119 	bool app_error;
120 	bool ets_willing;
121 	bool ets_enabled;
122 	bool ets_cbs;
123 	bool valid;
124 	u8 ets_pri_tc_tbl[QED_MAX_PFC_PRIORITIES];
125 	u8 ets_tc_bw_tbl[QED_MAX_PFC_PRIORITIES];
126 	u8 ets_tc_tsa_tbl[QED_MAX_PFC_PRIORITIES];
127 	struct qed_dbcx_pfc_params pfc;
128 	u8 max_ets_tc;
129 };
130 
131 struct qed_dcbx_admin_params {
132 	struct qed_dcbx_params params;
133 	bool valid;
134 };
135 
136 struct qed_dcbx_remote_params {
137 	struct qed_dcbx_params params;
138 	bool valid;
139 };
140 
141 struct qed_dcbx_operational_params {
142 	struct qed_dcbx_app_prio app_prio;
143 	struct qed_dcbx_params params;
144 	bool valid;
145 	bool enabled;
146 	bool ieee;
147 	bool cee;
148 	bool local;
149 	u32 err;
150 };
151 
152 struct qed_dcbx_get {
153 	struct qed_dcbx_operational_params operational;
154 	struct qed_dcbx_lldp_remote lldp_remote;
155 	struct qed_dcbx_lldp_local lldp_local;
156 	struct qed_dcbx_remote_params remote;
157 	struct qed_dcbx_admin_params local;
158 };
159 
160 enum qed_nvm_images {
161 	QED_NVM_IMAGE_ISCSI_CFG,
162 	QED_NVM_IMAGE_FCOE_CFG,
163 	QED_NVM_IMAGE_NVM_CFG1,
164 	QED_NVM_IMAGE_DEFAULT_CFG,
165 	QED_NVM_IMAGE_NVM_META,
166 };
167 
168 struct qed_link_eee_params {
169 	u32 tx_lpi_timer;
170 #define QED_EEE_1G_ADV		BIT(0)
171 #define QED_EEE_10G_ADV		BIT(1)
172 
173 	/* Capabilities are represented using QED_EEE_*_ADV values */
174 	u8 adv_caps;
175 	u8 lp_adv_caps;
176 	bool enable;
177 	bool tx_lpi_enable;
178 };
179 
180 enum qed_led_mode {
181 	QED_LED_MODE_OFF,
182 	QED_LED_MODE_ON,
183 	QED_LED_MODE_RESTORE
184 };
185 
186 struct qed_mfw_tlv_eth {
187 	u16 lso_maxoff_size;
188 	bool lso_maxoff_size_set;
189 	u16 lso_minseg_size;
190 	bool lso_minseg_size_set;
191 	u8 prom_mode;
192 	bool prom_mode_set;
193 	u16 tx_descr_size;
194 	bool tx_descr_size_set;
195 	u16 rx_descr_size;
196 	bool rx_descr_size_set;
197 	u16 netq_count;
198 	bool netq_count_set;
199 	u32 tcp4_offloads;
200 	bool tcp4_offloads_set;
201 	u32 tcp6_offloads;
202 	bool tcp6_offloads_set;
203 	u16 tx_descr_qdepth;
204 	bool tx_descr_qdepth_set;
205 	u16 rx_descr_qdepth;
206 	bool rx_descr_qdepth_set;
207 	u8 iov_offload;
208 #define QED_MFW_TLV_IOV_OFFLOAD_NONE            (0)
209 #define QED_MFW_TLV_IOV_OFFLOAD_MULTIQUEUE      (1)
210 #define QED_MFW_TLV_IOV_OFFLOAD_VEB             (2)
211 #define QED_MFW_TLV_IOV_OFFLOAD_VEPA            (3)
212 	bool iov_offload_set;
213 	u8 txqs_empty;
214 	bool txqs_empty_set;
215 	u8 rxqs_empty;
216 	bool rxqs_empty_set;
217 	u8 num_txqs_full;
218 	bool num_txqs_full_set;
219 	u8 num_rxqs_full;
220 	bool num_rxqs_full_set;
221 };
222 
223 #define QED_MFW_TLV_TIME_SIZE	14
224 struct qed_mfw_tlv_time {
225 	bool b_set;
226 	u8 month;
227 	u8 day;
228 	u8 hour;
229 	u8 min;
230 	u16 msec;
231 	u16 usec;
232 };
233 
234 struct qed_mfw_tlv_fcoe {
235 	u8 scsi_timeout;
236 	bool scsi_timeout_set;
237 	u32 rt_tov;
238 	bool rt_tov_set;
239 	u32 ra_tov;
240 	bool ra_tov_set;
241 	u32 ed_tov;
242 	bool ed_tov_set;
243 	u32 cr_tov;
244 	bool cr_tov_set;
245 	u8 boot_type;
246 	bool boot_type_set;
247 	u8 npiv_state;
248 	bool npiv_state_set;
249 	u32 num_npiv_ids;
250 	bool num_npiv_ids_set;
251 	u8 switch_name[8];
252 	bool switch_name_set;
253 	u16 switch_portnum;
254 	bool switch_portnum_set;
255 	u8 switch_portid[3];
256 	bool switch_portid_set;
257 	u8 vendor_name[8];
258 	bool vendor_name_set;
259 	u8 switch_model[8];
260 	bool switch_model_set;
261 	u8 switch_fw_version[8];
262 	bool switch_fw_version_set;
263 	u8 qos_pri;
264 	bool qos_pri_set;
265 	u8 port_alias[3];
266 	bool port_alias_set;
267 	u8 port_state;
268 #define QED_MFW_TLV_PORT_STATE_OFFLINE  (0)
269 #define QED_MFW_TLV_PORT_STATE_LOOP             (1)
270 #define QED_MFW_TLV_PORT_STATE_P2P              (2)
271 #define QED_MFW_TLV_PORT_STATE_FABRIC           (3)
272 	bool port_state_set;
273 	u16 fip_tx_descr_size;
274 	bool fip_tx_descr_size_set;
275 	u16 fip_rx_descr_size;
276 	bool fip_rx_descr_size_set;
277 	u16 link_failures;
278 	bool link_failures_set;
279 	u8 fcoe_boot_progress;
280 	bool fcoe_boot_progress_set;
281 	u64 rx_bcast;
282 	bool rx_bcast_set;
283 	u64 tx_bcast;
284 	bool tx_bcast_set;
285 	u16 fcoe_txq_depth;
286 	bool fcoe_txq_depth_set;
287 	u16 fcoe_rxq_depth;
288 	bool fcoe_rxq_depth_set;
289 	u64 fcoe_rx_frames;
290 	bool fcoe_rx_frames_set;
291 	u64 fcoe_rx_bytes;
292 	bool fcoe_rx_bytes_set;
293 	u64 fcoe_tx_frames;
294 	bool fcoe_tx_frames_set;
295 	u64 fcoe_tx_bytes;
296 	bool fcoe_tx_bytes_set;
297 	u16 crc_count;
298 	bool crc_count_set;
299 	u32 crc_err_src_fcid[5];
300 	bool crc_err_src_fcid_set[5];
301 	struct qed_mfw_tlv_time crc_err[5];
302 	u16 losync_err;
303 	bool losync_err_set;
304 	u16 losig_err;
305 	bool losig_err_set;
306 	u16 primtive_err;
307 	bool primtive_err_set;
308 	u16 disparity_err;
309 	bool disparity_err_set;
310 	u16 code_violation_err;
311 	bool code_violation_err_set;
312 	u32 flogi_param[4];
313 	bool flogi_param_set[4];
314 	struct qed_mfw_tlv_time flogi_tstamp;
315 	u32 flogi_acc_param[4];
316 	bool flogi_acc_param_set[4];
317 	struct qed_mfw_tlv_time flogi_acc_tstamp;
318 	u32 flogi_rjt;
319 	bool flogi_rjt_set;
320 	struct qed_mfw_tlv_time flogi_rjt_tstamp;
321 	u32 fdiscs;
322 	bool fdiscs_set;
323 	u8 fdisc_acc;
324 	bool fdisc_acc_set;
325 	u8 fdisc_rjt;
326 	bool fdisc_rjt_set;
327 	u8 plogi;
328 	bool plogi_set;
329 	u8 plogi_acc;
330 	bool plogi_acc_set;
331 	u8 plogi_rjt;
332 	bool plogi_rjt_set;
333 	u32 plogi_dst_fcid[5];
334 	bool plogi_dst_fcid_set[5];
335 	struct qed_mfw_tlv_time plogi_tstamp[5];
336 	u32 plogi_acc_src_fcid[5];
337 	bool plogi_acc_src_fcid_set[5];
338 	struct qed_mfw_tlv_time plogi_acc_tstamp[5];
339 	u8 tx_plogos;
340 	bool tx_plogos_set;
341 	u8 plogo_acc;
342 	bool plogo_acc_set;
343 	u8 plogo_rjt;
344 	bool plogo_rjt_set;
345 	u32 plogo_src_fcid[5];
346 	bool plogo_src_fcid_set[5];
347 	struct qed_mfw_tlv_time plogo_tstamp[5];
348 	u8 rx_logos;
349 	bool rx_logos_set;
350 	u8 tx_accs;
351 	bool tx_accs_set;
352 	u8 tx_prlis;
353 	bool tx_prlis_set;
354 	u8 rx_accs;
355 	bool rx_accs_set;
356 	u8 tx_abts;
357 	bool tx_abts_set;
358 	u8 rx_abts_acc;
359 	bool rx_abts_acc_set;
360 	u8 rx_abts_rjt;
361 	bool rx_abts_rjt_set;
362 	u32 abts_dst_fcid[5];
363 	bool abts_dst_fcid_set[5];
364 	struct qed_mfw_tlv_time abts_tstamp[5];
365 	u8 rx_rscn;
366 	bool rx_rscn_set;
367 	u32 rx_rscn_nport[4];
368 	bool rx_rscn_nport_set[4];
369 	u8 tx_lun_rst;
370 	bool tx_lun_rst_set;
371 	u8 abort_task_sets;
372 	bool abort_task_sets_set;
373 	u8 tx_tprlos;
374 	bool tx_tprlos_set;
375 	u8 tx_nos;
376 	bool tx_nos_set;
377 	u8 rx_nos;
378 	bool rx_nos_set;
379 	u8 ols;
380 	bool ols_set;
381 	u8 lr;
382 	bool lr_set;
383 	u8 lrr;
384 	bool lrr_set;
385 	u8 tx_lip;
386 	bool tx_lip_set;
387 	u8 rx_lip;
388 	bool rx_lip_set;
389 	u8 eofa;
390 	bool eofa_set;
391 	u8 eofni;
392 	bool eofni_set;
393 	u8 scsi_chks;
394 	bool scsi_chks_set;
395 	u8 scsi_cond_met;
396 	bool scsi_cond_met_set;
397 	u8 scsi_busy;
398 	bool scsi_busy_set;
399 	u8 scsi_inter;
400 	bool scsi_inter_set;
401 	u8 scsi_inter_cond_met;
402 	bool scsi_inter_cond_met_set;
403 	u8 scsi_rsv_conflicts;
404 	bool scsi_rsv_conflicts_set;
405 	u8 scsi_tsk_full;
406 	bool scsi_tsk_full_set;
407 	u8 scsi_aca_active;
408 	bool scsi_aca_active_set;
409 	u8 scsi_tsk_abort;
410 	bool scsi_tsk_abort_set;
411 	u32 scsi_rx_chk[5];
412 	bool scsi_rx_chk_set[5];
413 	struct qed_mfw_tlv_time scsi_chk_tstamp[5];
414 };
415 
416 struct qed_mfw_tlv_iscsi {
417 	u8 target_llmnr;
418 	bool target_llmnr_set;
419 	u8 header_digest;
420 	bool header_digest_set;
421 	u8 data_digest;
422 	bool data_digest_set;
423 	u8 auth_method;
424 #define QED_MFW_TLV_AUTH_METHOD_NONE            (1)
425 #define QED_MFW_TLV_AUTH_METHOD_CHAP            (2)
426 #define QED_MFW_TLV_AUTH_METHOD_MUTUAL_CHAP     (3)
427 	bool auth_method_set;
428 	u16 boot_taget_portal;
429 	bool boot_taget_portal_set;
430 	u16 frame_size;
431 	bool frame_size_set;
432 	u16 tx_desc_size;
433 	bool tx_desc_size_set;
434 	u16 rx_desc_size;
435 	bool rx_desc_size_set;
436 	u8 boot_progress;
437 	bool boot_progress_set;
438 	u16 tx_desc_qdepth;
439 	bool tx_desc_qdepth_set;
440 	u16 rx_desc_qdepth;
441 	bool rx_desc_qdepth_set;
442 	u64 rx_frames;
443 	bool rx_frames_set;
444 	u64 rx_bytes;
445 	bool rx_bytes_set;
446 	u64 tx_frames;
447 	bool tx_frames_set;
448 	u64 tx_bytes;
449 	bool tx_bytes_set;
450 };
451 
452 enum qed_db_rec_width {
453 	DB_REC_WIDTH_32B,
454 	DB_REC_WIDTH_64B,
455 };
456 
457 enum qed_db_rec_space {
458 	DB_REC_KERNEL,
459 	DB_REC_USER,
460 };
461 
462 #define DIRECT_REG_WR(reg_addr, val) writel((u32)val, \
463 					    (void __iomem *)(reg_addr))
464 
465 #define DIRECT_REG_RD(reg_addr) readl((void __iomem *)(reg_addr))
466 
467 #define DIRECT_REG_WR64(reg_addr, val) writeq((u32)val,	\
468 					      (void __iomem *)(reg_addr))
469 
470 #define QED_COALESCE_MAX 0x1FF
471 #define QED_DEFAULT_RX_USECS 12
472 #define QED_DEFAULT_TX_USECS 48
473 
474 /* forward */
475 struct qed_dev;
476 
477 struct qed_eth_pf_params {
478 	/* The following parameters are used during HW-init
479 	 * and these parameters need to be passed as arguments
480 	 * to update_pf_params routine invoked before slowpath start
481 	 */
482 	u16 num_cons;
483 
484 	/* per-VF number of CIDs */
485 	u8 num_vf_cons;
486 #define ETH_PF_PARAMS_VF_CONS_DEFAULT	(32)
487 
488 	/* To enable arfs, previous to HW-init a positive number needs to be
489 	 * set [as filters require allocated searcher ILT memory].
490 	 * This will set the maximal number of configured steering-filters.
491 	 */
492 	u32 num_arfs_filters;
493 };
494 
495 struct qed_fcoe_pf_params {
496 	/* The following parameters are used during protocol-init */
497 	u64 glbl_q_params_addr;
498 	u64 bdq_pbl_base_addr[2];
499 
500 	/* The following parameters are used during HW-init
501 	 * and these parameters need to be passed as arguments
502 	 * to update_pf_params routine invoked before slowpath start
503 	 */
504 	u16 num_cons;
505 	u16 num_tasks;
506 
507 	/* The following parameters are used during protocol-init */
508 	u16 sq_num_pbl_pages;
509 
510 	u16 cq_num_entries;
511 	u16 cmdq_num_entries;
512 	u16 rq_buffer_log_size;
513 	u16 mtu;
514 	u16 dummy_icid;
515 	u16 bdq_xoff_threshold[2];
516 	u16 bdq_xon_threshold[2];
517 	u16 rq_buffer_size;
518 	u8 num_cqs;		/* num of global CQs */
519 	u8 log_page_size;
520 	u8 gl_rq_pi;
521 	u8 gl_cmd_pi;
522 	u8 debug_mode;
523 	u8 is_target;
524 	u8 bdq_pbl_num_entries[2];
525 };
526 
527 /* Most of the the parameters below are described in the FW iSCSI / TCP HSI */
528 struct qed_iscsi_pf_params {
529 	u64 glbl_q_params_addr;
530 	u64 bdq_pbl_base_addr[3];
531 	u16 cq_num_entries;
532 	u16 cmdq_num_entries;
533 	u32 two_msl_timer;
534 	u16 tx_sws_timer;
535 
536 	/* The following parameters are used during HW-init
537 	 * and these parameters need to be passed as arguments
538 	 * to update_pf_params routine invoked before slowpath start
539 	 */
540 	u16 num_cons;
541 	u16 num_tasks;
542 
543 	/* The following parameters are used during protocol-init */
544 	u16 half_way_close_timeout;
545 	u16 bdq_xoff_threshold[3];
546 	u16 bdq_xon_threshold[3];
547 	u16 cmdq_xoff_threshold;
548 	u16 cmdq_xon_threshold;
549 	u16 rq_buffer_size;
550 
551 	u8 num_sq_pages_in_ring;
552 	u8 num_r2tq_pages_in_ring;
553 	u8 num_uhq_pages_in_ring;
554 	u8 num_queues;
555 	u8 log_page_size;
556 	u8 rqe_log_size;
557 	u8 max_fin_rt;
558 	u8 gl_rq_pi;
559 	u8 gl_cmd_pi;
560 	u8 debug_mode;
561 	u8 ll2_ooo_queue_id;
562 
563 	u8 is_target;
564 	u8 is_soc_en;
565 	u8 soc_num_of_blocks_log;
566 	u8 bdq_pbl_num_entries[3];
567 };
568 
569 struct qed_rdma_pf_params {
570 	/* Supplied to QED during resource allocation (may affect the ILT and
571 	 * the doorbell BAR).
572 	 */
573 	u32 min_dpis;		/* number of requested DPIs */
574 	u32 num_qps;		/* number of requested Queue Pairs */
575 	u32 num_srqs;		/* number of requested SRQ */
576 	u8 roce_edpm_mode;	/* see QED_ROCE_EDPM_MODE_ENABLE */
577 	u8 gl_pi;		/* protocol index */
578 
579 	/* Will allocate rate limiters to be used with QPs */
580 	u8 enable_dcqcn;
581 };
582 
583 struct qed_pf_params {
584 	struct qed_eth_pf_params eth_pf_params;
585 	struct qed_fcoe_pf_params fcoe_pf_params;
586 	struct qed_iscsi_pf_params iscsi_pf_params;
587 	struct qed_rdma_pf_params rdma_pf_params;
588 };
589 
590 enum qed_int_mode {
591 	QED_INT_MODE_INTA,
592 	QED_INT_MODE_MSIX,
593 	QED_INT_MODE_MSI,
594 	QED_INT_MODE_POLL,
595 };
596 
597 struct qed_sb_info {
598 	struct status_block_e4 *sb_virt;
599 	dma_addr_t sb_phys;
600 	u32 sb_ack; /* Last given ack */
601 	u16 igu_sb_id;
602 	void __iomem *igu_addr;
603 	u8 flags;
604 #define QED_SB_INFO_INIT	0x1
605 #define QED_SB_INFO_SETUP	0x2
606 
607 	struct qed_dev *cdev;
608 };
609 
610 enum qed_dev_type {
611 	QED_DEV_TYPE_BB,
612 	QED_DEV_TYPE_AH,
613 };
614 
615 struct qed_dev_info {
616 	unsigned long	pci_mem_start;
617 	unsigned long	pci_mem_end;
618 	unsigned int	pci_irq;
619 	u8		num_hwfns;
620 
621 	u8		hw_mac[ETH_ALEN];
622 
623 	/* FW version */
624 	u16		fw_major;
625 	u16		fw_minor;
626 	u16		fw_rev;
627 	u16		fw_eng;
628 
629 	/* MFW version */
630 	u32		mfw_rev;
631 #define QED_MFW_VERSION_0_MASK		0x000000FF
632 #define QED_MFW_VERSION_0_OFFSET	0
633 #define QED_MFW_VERSION_1_MASK		0x0000FF00
634 #define QED_MFW_VERSION_1_OFFSET	8
635 #define QED_MFW_VERSION_2_MASK		0x00FF0000
636 #define QED_MFW_VERSION_2_OFFSET	16
637 #define QED_MFW_VERSION_3_MASK		0xFF000000
638 #define QED_MFW_VERSION_3_OFFSET	24
639 
640 	u32		flash_size;
641 	bool		b_inter_pf_switch;
642 	bool		tx_switching;
643 	bool		rdma_supported;
644 	u16		mtu;
645 
646 	bool wol_support;
647 
648 	/* MBI version */
649 	u32 mbi_version;
650 #define QED_MBI_VERSION_0_MASK		0x000000FF
651 #define QED_MBI_VERSION_0_OFFSET	0
652 #define QED_MBI_VERSION_1_MASK		0x0000FF00
653 #define QED_MBI_VERSION_1_OFFSET	8
654 #define QED_MBI_VERSION_2_MASK		0x00FF0000
655 #define QED_MBI_VERSION_2_OFFSET	16
656 
657 	enum qed_dev_type dev_type;
658 
659 	/* Output parameters for qede */
660 	bool		vxlan_enable;
661 	bool		gre_enable;
662 	bool		geneve_enable;
663 
664 	u8		abs_pf_id;
665 };
666 
667 enum qed_sb_type {
668 	QED_SB_TYPE_L2_QUEUE,
669 	QED_SB_TYPE_CNQ,
670 	QED_SB_TYPE_STORAGE,
671 };
672 
673 enum qed_protocol {
674 	QED_PROTOCOL_ETH,
675 	QED_PROTOCOL_ISCSI,
676 	QED_PROTOCOL_FCOE,
677 };
678 
679 enum qed_link_mode_bits {
680 	QED_LM_FIBRE_BIT = BIT(0),
681 	QED_LM_Autoneg_BIT = BIT(1),
682 	QED_LM_Asym_Pause_BIT = BIT(2),
683 	QED_LM_Pause_BIT = BIT(3),
684 	QED_LM_1000baseT_Full_BIT = BIT(4),
685 	QED_LM_10000baseT_Full_BIT = BIT(5),
686 	QED_LM_10000baseKR_Full_BIT = BIT(6),
687 	QED_LM_20000baseKR2_Full_BIT = BIT(7),
688 	QED_LM_25000baseKR_Full_BIT = BIT(8),
689 	QED_LM_40000baseLR4_Full_BIT = BIT(9),
690 	QED_LM_50000baseKR2_Full_BIT = BIT(10),
691 	QED_LM_100000baseKR4_Full_BIT = BIT(11),
692 	QED_LM_2500baseX_Full_BIT = BIT(12),
693 	QED_LM_Backplane_BIT = BIT(13),
694 	QED_LM_1000baseKX_Full_BIT = BIT(14),
695 	QED_LM_10000baseKX4_Full_BIT = BIT(15),
696 	QED_LM_10000baseR_FEC_BIT = BIT(16),
697 	QED_LM_40000baseKR4_Full_BIT = BIT(17),
698 	QED_LM_40000baseCR4_Full_BIT = BIT(18),
699 	QED_LM_40000baseSR4_Full_BIT = BIT(19),
700 	QED_LM_25000baseCR_Full_BIT = BIT(20),
701 	QED_LM_25000baseSR_Full_BIT = BIT(21),
702 	QED_LM_50000baseCR2_Full_BIT = BIT(22),
703 	QED_LM_100000baseSR4_Full_BIT = BIT(23),
704 	QED_LM_100000baseCR4_Full_BIT = BIT(24),
705 	QED_LM_100000baseLR4_ER4_Full_BIT = BIT(25),
706 	QED_LM_50000baseSR2_Full_BIT = BIT(26),
707 	QED_LM_1000baseX_Full_BIT = BIT(27),
708 	QED_LM_10000baseCR_Full_BIT = BIT(28),
709 	QED_LM_10000baseSR_Full_BIT = BIT(29),
710 	QED_LM_10000baseLR_Full_BIT = BIT(30),
711 	QED_LM_10000baseLRM_Full_BIT = BIT(31),
712 	QED_LM_COUNT = 32
713 };
714 
715 struct qed_link_params {
716 	bool	link_up;
717 
718 #define QED_LINK_OVERRIDE_SPEED_AUTONEG         BIT(0)
719 #define QED_LINK_OVERRIDE_SPEED_ADV_SPEEDS      BIT(1)
720 #define QED_LINK_OVERRIDE_SPEED_FORCED_SPEED    BIT(2)
721 #define QED_LINK_OVERRIDE_PAUSE_CONFIG          BIT(3)
722 #define QED_LINK_OVERRIDE_LOOPBACK_MODE         BIT(4)
723 #define QED_LINK_OVERRIDE_EEE_CONFIG            BIT(5)
724 	u32	override_flags;
725 	bool	autoneg;
726 	u32	adv_speeds;
727 	u32	forced_speed;
728 #define QED_LINK_PAUSE_AUTONEG_ENABLE           BIT(0)
729 #define QED_LINK_PAUSE_RX_ENABLE                BIT(1)
730 #define QED_LINK_PAUSE_TX_ENABLE                BIT(2)
731 	u32	pause_config;
732 #define QED_LINK_LOOPBACK_NONE                  BIT(0)
733 #define QED_LINK_LOOPBACK_INT_PHY               BIT(1)
734 #define QED_LINK_LOOPBACK_EXT_PHY               BIT(2)
735 #define QED_LINK_LOOPBACK_EXT                   BIT(3)
736 #define QED_LINK_LOOPBACK_MAC                   BIT(4)
737 	u32	loopback_mode;
738 	struct qed_link_eee_params eee;
739 };
740 
741 struct qed_link_output {
742 	bool	link_up;
743 
744 	/* In QED_LM_* defs */
745 	u32	supported_caps;
746 	u32	advertised_caps;
747 	u32	lp_caps;
748 
749 	u32	speed;                  /* In Mb/s */
750 	u8	duplex;                 /* In DUPLEX defs */
751 	u8	port;                   /* In PORT defs */
752 	bool	autoneg;
753 	u32	pause_config;
754 
755 	/* EEE - capability & param */
756 	bool eee_supported;
757 	bool eee_active;
758 	u8 sup_caps;
759 	struct qed_link_eee_params eee;
760 };
761 
762 struct qed_probe_params {
763 	enum qed_protocol protocol;
764 	u32 dp_module;
765 	u8 dp_level;
766 	bool is_vf;
767 };
768 
769 #define QED_DRV_VER_STR_SIZE 12
770 struct qed_slowpath_params {
771 	u32	int_mode;
772 	u8	drv_major;
773 	u8	drv_minor;
774 	u8	drv_rev;
775 	u8	drv_eng;
776 	u8	name[QED_DRV_VER_STR_SIZE];
777 };
778 
779 #define ILT_PAGE_SIZE_TCFC 0x8000 /* 32KB */
780 
781 struct qed_int_info {
782 	struct msix_entry	*msix;
783 	u8			msix_cnt;
784 
785 	/* This should be updated by the protocol driver */
786 	u8			used_cnt;
787 };
788 
789 struct qed_generic_tlvs {
790 #define QED_TLV_IP_CSUM         BIT(0)
791 #define QED_TLV_LSO             BIT(1)
792 	u16 feat_flags;
793 #define QED_TLV_MAC_COUNT	3
794 	u8 mac[QED_TLV_MAC_COUNT][ETH_ALEN];
795 };
796 
797 #define QED_I2C_DEV_ADDR_A0 0xA0
798 #define QED_I2C_DEV_ADDR_A2 0xA2
799 
800 #define QED_NVM_SIGNATURE 0x12435687
801 
802 enum qed_nvm_flash_cmd {
803 	QED_NVM_FLASH_CMD_FILE_DATA = 0x2,
804 	QED_NVM_FLASH_CMD_FILE_START = 0x3,
805 	QED_NVM_FLASH_CMD_NVM_CHANGE = 0x4,
806 	QED_NVM_FLASH_CMD_NVM_MAX,
807 };
808 
809 struct qed_common_cb_ops {
810 	void (*arfs_filter_op)(void *dev, void *fltr, u8 fw_rc);
811 	void	(*link_update)(void			*dev,
812 			       struct qed_link_output	*link);
813 	void	(*dcbx_aen)(void *dev, struct qed_dcbx_get *get, u32 mib_type);
814 	void (*get_generic_tlv_data)(void *dev, struct qed_generic_tlvs *data);
815 	void (*get_protocol_tlv_data)(void *dev, void *data);
816 };
817 
818 struct qed_selftest_ops {
819 /**
820  * @brief selftest_interrupt - Perform interrupt test
821  *
822  * @param cdev
823  *
824  * @return 0 on success, error otherwise.
825  */
826 	int (*selftest_interrupt)(struct qed_dev *cdev);
827 
828 /**
829  * @brief selftest_memory - Perform memory test
830  *
831  * @param cdev
832  *
833  * @return 0 on success, error otherwise.
834  */
835 	int (*selftest_memory)(struct qed_dev *cdev);
836 
837 /**
838  * @brief selftest_register - Perform register test
839  *
840  * @param cdev
841  *
842  * @return 0 on success, error otherwise.
843  */
844 	int (*selftest_register)(struct qed_dev *cdev);
845 
846 /**
847  * @brief selftest_clock - Perform clock test
848  *
849  * @param cdev
850  *
851  * @return 0 on success, error otherwise.
852  */
853 	int (*selftest_clock)(struct qed_dev *cdev);
854 
855 /**
856  * @brief selftest_nvram - Perform nvram test
857  *
858  * @param cdev
859  *
860  * @return 0 on success, error otherwise.
861  */
862 	int (*selftest_nvram) (struct qed_dev *cdev);
863 };
864 
865 struct qed_common_ops {
866 	struct qed_selftest_ops *selftest;
867 
868 	struct qed_dev*	(*probe)(struct pci_dev *dev,
869 				 struct qed_probe_params *params);
870 
871 	void		(*remove)(struct qed_dev *cdev);
872 
873 	int		(*set_power_state)(struct qed_dev *cdev,
874 					   pci_power_t state);
875 
876 	void (*set_name) (struct qed_dev *cdev, char name[]);
877 
878 	/* Client drivers need to make this call before slowpath_start.
879 	 * PF params required for the call before slowpath_start is
880 	 * documented within the qed_pf_params structure definition.
881 	 */
882 	void		(*update_pf_params)(struct qed_dev *cdev,
883 					    struct qed_pf_params *params);
884 	int		(*slowpath_start)(struct qed_dev *cdev,
885 					  struct qed_slowpath_params *params);
886 
887 	int		(*slowpath_stop)(struct qed_dev *cdev);
888 
889 	/* Requests to use `cnt' interrupts for fastpath.
890 	 * upon success, returns number of interrupts allocated for fastpath.
891 	 */
892 	int		(*set_fp_int)(struct qed_dev *cdev,
893 				      u16 cnt);
894 
895 	/* Fills `info' with pointers required for utilizing interrupts */
896 	int		(*get_fp_int)(struct qed_dev *cdev,
897 				      struct qed_int_info *info);
898 
899 	u32		(*sb_init)(struct qed_dev *cdev,
900 				   struct qed_sb_info *sb_info,
901 				   void *sb_virt_addr,
902 				   dma_addr_t sb_phy_addr,
903 				   u16 sb_id,
904 				   enum qed_sb_type type);
905 
906 	u32		(*sb_release)(struct qed_dev *cdev,
907 				      struct qed_sb_info *sb_info,
908 				      u16 sb_id);
909 
910 	void		(*simd_handler_config)(struct qed_dev *cdev,
911 					       void *token,
912 					       int index,
913 					       void (*handler)(void *));
914 
915 	void		(*simd_handler_clean)(struct qed_dev *cdev,
916 					      int index);
917 	int (*dbg_grc)(struct qed_dev *cdev,
918 		       void *buffer, u32 *num_dumped_bytes);
919 
920 	int (*dbg_grc_size)(struct qed_dev *cdev);
921 
922 	int (*dbg_all_data) (struct qed_dev *cdev, void *buffer);
923 
924 	int (*dbg_all_data_size) (struct qed_dev *cdev);
925 
926 /**
927  * @brief can_link_change - can the instance change the link or not
928  *
929  * @param cdev
930  *
931  * @return true if link-change is allowed, false otherwise.
932  */
933 	bool (*can_link_change)(struct qed_dev *cdev);
934 
935 /**
936  * @brief set_link - set links according to params
937  *
938  * @param cdev
939  * @param params - values used to override the default link configuration
940  *
941  * @return 0 on success, error otherwise.
942  */
943 	int		(*set_link)(struct qed_dev *cdev,
944 				    struct qed_link_params *params);
945 
946 /**
947  * @brief get_link - returns the current link state.
948  *
949  * @param cdev
950  * @param if_link - structure to be filled with current link configuration.
951  */
952 	void		(*get_link)(struct qed_dev *cdev,
953 				    struct qed_link_output *if_link);
954 
955 /**
956  * @brief - drains chip in case Tx completions fail to arrive due to pause.
957  *
958  * @param cdev
959  */
960 	int		(*drain)(struct qed_dev *cdev);
961 
962 /**
963  * @brief update_msglvl - update module debug level
964  *
965  * @param cdev
966  * @param dp_module
967  * @param dp_level
968  */
969 	void		(*update_msglvl)(struct qed_dev *cdev,
970 					 u32 dp_module,
971 					 u8 dp_level);
972 
973 	int		(*chain_alloc)(struct qed_dev *cdev,
974 				       enum qed_chain_use_mode intended_use,
975 				       enum qed_chain_mode mode,
976 				       enum qed_chain_cnt_type cnt_type,
977 				       u32 num_elems,
978 				       size_t elem_size,
979 				       struct qed_chain *p_chain,
980 				       struct qed_chain_ext_pbl *ext_pbl);
981 
982 	void		(*chain_free)(struct qed_dev *cdev,
983 				      struct qed_chain *p_chain);
984 
985 /**
986  * @brief nvm_flash - Flash nvm data.
987  *
988  * @param cdev
989  * @param name - file containing the data
990  *
991  * @return 0 on success, error otherwise.
992  */
993 	int (*nvm_flash)(struct qed_dev *cdev, const char *name);
994 
995 /**
996  * @brief nvm_get_image - reads an entire image from nvram
997  *
998  * @param cdev
999  * @param type - type of the request nvram image
1000  * @param buf - preallocated buffer to fill with the image
1001  * @param len - length of the allocated buffer
1002  *
1003  * @return 0 on success, error otherwise
1004  */
1005 	int (*nvm_get_image)(struct qed_dev *cdev,
1006 			     enum qed_nvm_images type, u8 *buf, u16 len);
1007 
1008 /**
1009  * @brief set_coalesce - Configure Rx coalesce value in usec
1010  *
1011  * @param cdev
1012  * @param rx_coal - Rx coalesce value in usec
1013  * @param tx_coal - Tx coalesce value in usec
1014  * @param qid - Queue index
1015  * @param sb_id - Status Block Id
1016  *
1017  * @return 0 on success, error otherwise.
1018  */
1019 	int (*set_coalesce)(struct qed_dev *cdev,
1020 			    u16 rx_coal, u16 tx_coal, void *handle);
1021 
1022 /**
1023  * @brief set_led - Configure LED mode
1024  *
1025  * @param cdev
1026  * @param mode - LED mode
1027  *
1028  * @return 0 on success, error otherwise.
1029  */
1030 	int (*set_led)(struct qed_dev *cdev,
1031 		       enum qed_led_mode mode);
1032 /**
1033  * @brief db_recovery_add - add doorbell information to the doorbell
1034  * recovery mechanism.
1035  *
1036  * @param cdev
1037  * @param db_addr - doorbell address
1038  * @param db_data - address of where db_data is stored
1039  * @param db_is_32b - doorbell is 32b pr 64b
1040  * @param db_is_user - doorbell recovery addresses are user or kernel space
1041  */
1042 	int (*db_recovery_add)(struct qed_dev *cdev,
1043 			       void __iomem *db_addr,
1044 			       void *db_data,
1045 			       enum qed_db_rec_width db_width,
1046 			       enum qed_db_rec_space db_space);
1047 
1048 /**
1049  * @brief db_recovery_del - remove doorbell information from the doorbell
1050  * recovery mechanism. db_data serves as key (db_addr is not unique).
1051  *
1052  * @param cdev
1053  * @param db_addr - doorbell address
1054  * @param db_data - address where db_data is stored. Serves as key for the
1055  *		    entry to delete.
1056  */
1057 	int (*db_recovery_del)(struct qed_dev *cdev,
1058 			       void __iomem *db_addr, void *db_data);
1059 
1060 /**
1061  * @brief update_drv_state - API to inform the change in the driver state.
1062  *
1063  * @param cdev
1064  * @param active
1065  *
1066  */
1067 	int (*update_drv_state)(struct qed_dev *cdev, bool active);
1068 
1069 /**
1070  * @brief update_mac - API to inform the change in the mac address
1071  *
1072  * @param cdev
1073  * @param mac
1074  *
1075  */
1076 	int (*update_mac)(struct qed_dev *cdev, u8 *mac);
1077 
1078 /**
1079  * @brief update_mtu - API to inform the change in the mtu
1080  *
1081  * @param cdev
1082  * @param mtu
1083  *
1084  */
1085 	int (*update_mtu)(struct qed_dev *cdev, u16 mtu);
1086 
1087 /**
1088  * @brief update_wol - update of changes in the WoL configuration
1089  *
1090  * @param cdev
1091  * @param enabled - true iff WoL should be enabled.
1092  */
1093 	int (*update_wol) (struct qed_dev *cdev, bool enabled);
1094 
1095 /**
1096  * @brief read_module_eeprom
1097  *
1098  * @param cdev
1099  * @param buf - buffer
1100  * @param dev_addr - PHY device memory region
1101  * @param offset - offset into eeprom contents to be read
1102  * @param len - buffer length, i.e., max bytes to be read
1103  */
1104 	int (*read_module_eeprom)(struct qed_dev *cdev,
1105 				  char *buf, u8 dev_addr, u32 offset, u32 len);
1106 };
1107 
1108 #define MASK_FIELD(_name, _value) \
1109 	((_value) &= (_name ## _MASK))
1110 
1111 #define FIELD_VALUE(_name, _value) \
1112 	((_value & _name ## _MASK) << _name ## _SHIFT)
1113 
1114 #define SET_FIELD(value, name, flag)			       \
1115 	do {						       \
1116 		(value) &= ~(name ## _MASK << name ## _SHIFT); \
1117 		(value) |= (((u64)flag) << (name ## _SHIFT));  \
1118 	} while (0)
1119 
1120 #define GET_FIELD(value, name) \
1121 	(((value) >> (name ## _SHIFT)) & name ## _MASK)
1122 
1123 /* Debug print definitions */
1124 #define DP_ERR(cdev, fmt, ...)					\
1125 	do {							\
1126 		pr_err("[%s:%d(%s)]" fmt,			\
1127 		       __func__, __LINE__,			\
1128 		       DP_NAME(cdev) ? DP_NAME(cdev) : "",	\
1129 		       ## __VA_ARGS__);				\
1130 	} while (0)
1131 
1132 #define DP_NOTICE(cdev, fmt, ...)				      \
1133 	do {							      \
1134 		if (unlikely((cdev)->dp_level <= QED_LEVEL_NOTICE)) { \
1135 			pr_notice("[%s:%d(%s)]" fmt,		      \
1136 				  __func__, __LINE__,		      \
1137 				  DP_NAME(cdev) ? DP_NAME(cdev) : "", \
1138 				  ## __VA_ARGS__);		      \
1139 								      \
1140 		}						      \
1141 	} while (0)
1142 
1143 #define DP_INFO(cdev, fmt, ...)					      \
1144 	do {							      \
1145 		if (unlikely((cdev)->dp_level <= QED_LEVEL_INFO)) {   \
1146 			pr_notice("[%s:%d(%s)]" fmt,		      \
1147 				  __func__, __LINE__,		      \
1148 				  DP_NAME(cdev) ? DP_NAME(cdev) : "", \
1149 				  ## __VA_ARGS__);		      \
1150 		}						      \
1151 	} while (0)
1152 
1153 #define DP_VERBOSE(cdev, module, fmt, ...)				\
1154 	do {								\
1155 		if (unlikely(((cdev)->dp_level <= QED_LEVEL_VERBOSE) &&	\
1156 			     ((cdev)->dp_module & module))) {		\
1157 			pr_notice("[%s:%d(%s)]" fmt,			\
1158 				  __func__, __LINE__,			\
1159 				  DP_NAME(cdev) ? DP_NAME(cdev) : "",	\
1160 				  ## __VA_ARGS__);			\
1161 		}							\
1162 	} while (0)
1163 
1164 enum DP_LEVEL {
1165 	QED_LEVEL_VERBOSE	= 0x0,
1166 	QED_LEVEL_INFO		= 0x1,
1167 	QED_LEVEL_NOTICE	= 0x2,
1168 	QED_LEVEL_ERR		= 0x3,
1169 };
1170 
1171 #define QED_LOG_LEVEL_SHIFT     (30)
1172 #define QED_LOG_VERBOSE_MASK    (0x3fffffff)
1173 #define QED_LOG_INFO_MASK       (0x40000000)
1174 #define QED_LOG_NOTICE_MASK     (0x80000000)
1175 
1176 enum DP_MODULE {
1177 	QED_MSG_SPQ	= 0x10000,
1178 	QED_MSG_STATS	= 0x20000,
1179 	QED_MSG_DCB	= 0x40000,
1180 	QED_MSG_IOV	= 0x80000,
1181 	QED_MSG_SP	= 0x100000,
1182 	QED_MSG_STORAGE = 0x200000,
1183 	QED_MSG_CXT	= 0x800000,
1184 	QED_MSG_LL2	= 0x1000000,
1185 	QED_MSG_ILT	= 0x2000000,
1186 	QED_MSG_RDMA	= 0x4000000,
1187 	QED_MSG_DEBUG	= 0x8000000,
1188 	/* to be added...up to 0x8000000 */
1189 };
1190 
1191 enum qed_mf_mode {
1192 	QED_MF_DEFAULT,
1193 	QED_MF_OVLAN,
1194 	QED_MF_NPAR,
1195 };
1196 
1197 struct qed_eth_stats_common {
1198 	u64	no_buff_discards;
1199 	u64	packet_too_big_discard;
1200 	u64	ttl0_discard;
1201 	u64	rx_ucast_bytes;
1202 	u64	rx_mcast_bytes;
1203 	u64	rx_bcast_bytes;
1204 	u64	rx_ucast_pkts;
1205 	u64	rx_mcast_pkts;
1206 	u64	rx_bcast_pkts;
1207 	u64	mftag_filter_discards;
1208 	u64	mac_filter_discards;
1209 	u64	gft_filter_drop;
1210 	u64	tx_ucast_bytes;
1211 	u64	tx_mcast_bytes;
1212 	u64	tx_bcast_bytes;
1213 	u64	tx_ucast_pkts;
1214 	u64	tx_mcast_pkts;
1215 	u64	tx_bcast_pkts;
1216 	u64	tx_err_drop_pkts;
1217 	u64	tpa_coalesced_pkts;
1218 	u64	tpa_coalesced_events;
1219 	u64	tpa_aborts_num;
1220 	u64	tpa_not_coalesced_pkts;
1221 	u64	tpa_coalesced_bytes;
1222 
1223 	/* port */
1224 	u64	rx_64_byte_packets;
1225 	u64	rx_65_to_127_byte_packets;
1226 	u64	rx_128_to_255_byte_packets;
1227 	u64	rx_256_to_511_byte_packets;
1228 	u64	rx_512_to_1023_byte_packets;
1229 	u64	rx_1024_to_1518_byte_packets;
1230 	u64	rx_crc_errors;
1231 	u64	rx_mac_crtl_frames;
1232 	u64	rx_pause_frames;
1233 	u64	rx_pfc_frames;
1234 	u64	rx_align_errors;
1235 	u64	rx_carrier_errors;
1236 	u64	rx_oversize_packets;
1237 	u64	rx_jabbers;
1238 	u64	rx_undersize_packets;
1239 	u64	rx_fragments;
1240 	u64	tx_64_byte_packets;
1241 	u64	tx_65_to_127_byte_packets;
1242 	u64	tx_128_to_255_byte_packets;
1243 	u64	tx_256_to_511_byte_packets;
1244 	u64	tx_512_to_1023_byte_packets;
1245 	u64	tx_1024_to_1518_byte_packets;
1246 	u64	tx_pause_frames;
1247 	u64	tx_pfc_frames;
1248 	u64	brb_truncates;
1249 	u64	brb_discards;
1250 	u64	rx_mac_bytes;
1251 	u64	rx_mac_uc_packets;
1252 	u64	rx_mac_mc_packets;
1253 	u64	rx_mac_bc_packets;
1254 	u64	rx_mac_frames_ok;
1255 	u64	tx_mac_bytes;
1256 	u64	tx_mac_uc_packets;
1257 	u64	tx_mac_mc_packets;
1258 	u64	tx_mac_bc_packets;
1259 	u64	tx_mac_ctrl_frames;
1260 	u64	link_change_count;
1261 };
1262 
1263 struct qed_eth_stats_bb {
1264 	u64 rx_1519_to_1522_byte_packets;
1265 	u64 rx_1519_to_2047_byte_packets;
1266 	u64 rx_2048_to_4095_byte_packets;
1267 	u64 rx_4096_to_9216_byte_packets;
1268 	u64 rx_9217_to_16383_byte_packets;
1269 	u64 tx_1519_to_2047_byte_packets;
1270 	u64 tx_2048_to_4095_byte_packets;
1271 	u64 tx_4096_to_9216_byte_packets;
1272 	u64 tx_9217_to_16383_byte_packets;
1273 	u64 tx_lpi_entry_count;
1274 	u64 tx_total_collisions;
1275 };
1276 
1277 struct qed_eth_stats_ah {
1278 	u64 rx_1519_to_max_byte_packets;
1279 	u64 tx_1519_to_max_byte_packets;
1280 };
1281 
1282 struct qed_eth_stats {
1283 	struct qed_eth_stats_common common;
1284 
1285 	union {
1286 		struct qed_eth_stats_bb bb;
1287 		struct qed_eth_stats_ah ah;
1288 	};
1289 };
1290 
1291 #define QED_SB_IDX              0x0002
1292 
1293 #define RX_PI           0
1294 #define TX_PI(tc)       (RX_PI + 1 + tc)
1295 
1296 struct qed_sb_cnt_info {
1297 	/* Original, current, and free SBs for PF */
1298 	int orig;
1299 	int cnt;
1300 	int free_cnt;
1301 
1302 	/* Original, current and free SBS for child VFs */
1303 	int iov_orig;
1304 	int iov_cnt;
1305 	int free_cnt_iov;
1306 };
1307 
1308 static inline u16 qed_sb_update_sb_idx(struct qed_sb_info *sb_info)
1309 {
1310 	u32 prod = 0;
1311 	u16 rc = 0;
1312 
1313 	prod = le32_to_cpu(sb_info->sb_virt->prod_index) &
1314 	       STATUS_BLOCK_E4_PROD_INDEX_MASK;
1315 	if (sb_info->sb_ack != prod) {
1316 		sb_info->sb_ack = prod;
1317 		rc |= QED_SB_IDX;
1318 	}
1319 
1320 	/* Let SB update */
1321 	mmiowb();
1322 	return rc;
1323 }
1324 
1325 /**
1326  *
1327  * @brief This function creates an update command for interrupts that is
1328  *        written to the IGU.
1329  *
1330  * @param sb_info       - This is the structure allocated and
1331  *                 initialized per status block. Assumption is
1332  *                 that it was initialized using qed_sb_init
1333  * @param int_cmd       - Enable/Disable/Nop
1334  * @param upd_flg       - whether igu consumer should be
1335  *                 updated.
1336  *
1337  * @return inline void
1338  */
1339 static inline void qed_sb_ack(struct qed_sb_info *sb_info,
1340 			      enum igu_int_cmd int_cmd,
1341 			      u8 upd_flg)
1342 {
1343 	struct igu_prod_cons_update igu_ack = { 0 };
1344 
1345 	igu_ack.sb_id_and_flags =
1346 		((sb_info->sb_ack << IGU_PROD_CONS_UPDATE_SB_INDEX_SHIFT) |
1347 		 (upd_flg << IGU_PROD_CONS_UPDATE_UPDATE_FLAG_SHIFT) |
1348 		 (int_cmd << IGU_PROD_CONS_UPDATE_ENABLE_INT_SHIFT) |
1349 		 (IGU_SEG_ACCESS_REG <<
1350 		  IGU_PROD_CONS_UPDATE_SEGMENT_ACCESS_SHIFT));
1351 
1352 	DIRECT_REG_WR(sb_info->igu_addr, igu_ack.sb_id_and_flags);
1353 
1354 	/* Both segments (interrupts & acks) are written to same place address;
1355 	 * Need to guarantee all commands will be received (in-order) by HW.
1356 	 */
1357 	mmiowb();
1358 	barrier();
1359 }
1360 
1361 static inline void __internal_ram_wr(void *p_hwfn,
1362 				     void __iomem *addr,
1363 				     int size,
1364 				     u32 *data)
1365 
1366 {
1367 	unsigned int i;
1368 
1369 	for (i = 0; i < size / sizeof(*data); i++)
1370 		DIRECT_REG_WR(&((u32 __iomem *)addr)[i], data[i]);
1371 }
1372 
1373 static inline void internal_ram_wr(void __iomem *addr,
1374 				   int size,
1375 				   u32 *data)
1376 {
1377 	__internal_ram_wr(NULL, addr, size, data);
1378 }
1379 
1380 enum qed_rss_caps {
1381 	QED_RSS_IPV4		= 0x1,
1382 	QED_RSS_IPV6		= 0x2,
1383 	QED_RSS_IPV4_TCP	= 0x4,
1384 	QED_RSS_IPV6_TCP	= 0x8,
1385 	QED_RSS_IPV4_UDP	= 0x10,
1386 	QED_RSS_IPV6_UDP	= 0x20,
1387 };
1388 
1389 #define QED_RSS_IND_TABLE_SIZE 128
1390 #define QED_RSS_KEY_SIZE 10 /* size in 32b chunks */
1391 #endif
1392