blob: d44933a058ee6d71846beca649843152a6f87180 [file] [log] [blame]
Yuval Mintzfe56b9e2015-10-26 11:02:25 +02001/* QLogic qed NIC Driver
Mintz, Yuvale8f1cb52017-01-01 13:57:00 +02002 * Copyright (c) 2015-2017 QLogic Corporation
Yuval Mintzfe56b9e2015-10-26 11:02:25 +02003 *
Mintz, Yuvale8f1cb52017-01-01 13:57:00 +02004 * 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:
Yuval Mintzfe56b9e2015-10-26 11:02:25 +02009 *
Mintz, Yuvale8f1cb52017-01-01 13:57:00 +020010 * 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.
Yuval Mintzfe56b9e2015-10-26 11:02:25 +020031 */
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
Sudarsana Reddy Kalluru39651ab2016-05-17 06:44:26 -040051enum dcbx_protocol_type {
52 DCBX_PROTOCOL_ISCSI,
53 DCBX_PROTOCOL_FCOE,
54 DCBX_PROTOCOL_ROCE,
55 DCBX_PROTOCOL_ROCE_V2,
56 DCBX_PROTOCOL_ETH,
57 DCBX_MAX_PROTOCOL_TYPE
58};
59
Ram Amrani51ff1722016-10-01 21:59:57 +030060#define QED_ROCE_PROTOCOL_INDEX (3)
61
Sudarsana Reddy Kalluru6ad8c632016-06-08 06:22:10 -040062#define QED_LLDP_CHASSIS_ID_STAT_LEN 4
63#define QED_LLDP_PORT_ID_STAT_LEN 4
64#define QED_DCBX_MAX_APP_PROTOCOL 32
65#define QED_MAX_PFC_PRIORITIES 8
66#define QED_DCBX_DSCP_SIZE 64
67
68struct qed_dcbx_lldp_remote {
69 u32 peer_chassis_id[QED_LLDP_CHASSIS_ID_STAT_LEN];
70 u32 peer_port_id[QED_LLDP_PORT_ID_STAT_LEN];
71 bool enable_rx;
72 bool enable_tx;
73 u32 tx_interval;
74 u32 max_credit;
75};
76
77struct qed_dcbx_lldp_local {
78 u32 local_chassis_id[QED_LLDP_CHASSIS_ID_STAT_LEN];
79 u32 local_port_id[QED_LLDP_PORT_ID_STAT_LEN];
80};
81
82struct qed_dcbx_app_prio {
83 u8 roce;
84 u8 roce_v2;
85 u8 fcoe;
86 u8 iscsi;
87 u8 eth;
88};
89
90struct qed_dbcx_pfc_params {
91 bool willing;
92 bool enabled;
93 u8 prio[QED_MAX_PFC_PRIORITIES];
94 u8 max_tc;
95};
96
Sudarsana Reddy Kalluru59bcb792016-08-08 21:57:42 -040097enum qed_dcbx_sf_ieee_type {
98 QED_DCBX_SF_IEEE_ETHTYPE,
99 QED_DCBX_SF_IEEE_TCP_PORT,
100 QED_DCBX_SF_IEEE_UDP_PORT,
101 QED_DCBX_SF_IEEE_TCP_UDP_PORT
102};
103
Sudarsana Reddy Kalluru6ad8c632016-06-08 06:22:10 -0400104struct qed_app_entry {
105 bool ethtype;
Sudarsana Reddy Kalluru59bcb792016-08-08 21:57:42 -0400106 enum qed_dcbx_sf_ieee_type sf_ieee;
Sudarsana Reddy Kalluru6ad8c632016-06-08 06:22:10 -0400107 bool enabled;
108 u8 prio;
109 u16 proto_id;
110 enum dcbx_protocol_type proto_type;
111};
112
113struct qed_dcbx_params {
114 struct qed_app_entry app_entry[QED_DCBX_MAX_APP_PROTOCOL];
115 u16 num_app_entries;
116 bool app_willing;
117 bool app_valid;
118 bool app_error;
119 bool ets_willing;
120 bool ets_enabled;
121 bool ets_cbs;
122 bool valid;
123 u8 ets_pri_tc_tbl[QED_MAX_PFC_PRIORITIES];
124 u8 ets_tc_bw_tbl[QED_MAX_PFC_PRIORITIES];
125 u8 ets_tc_tsa_tbl[QED_MAX_PFC_PRIORITIES];
126 struct qed_dbcx_pfc_params pfc;
127 u8 max_ets_tc;
128};
129
130struct qed_dcbx_admin_params {
131 struct qed_dcbx_params params;
132 bool valid;
133};
134
135struct qed_dcbx_remote_params {
136 struct qed_dcbx_params params;
137 bool valid;
138};
139
140struct qed_dcbx_operational_params {
141 struct qed_dcbx_app_prio app_prio;
142 struct qed_dcbx_params params;
143 bool valid;
144 bool enabled;
145 bool ieee;
146 bool cee;
147 u32 err;
148};
149
150struct qed_dcbx_get {
151 struct qed_dcbx_operational_params operational;
152 struct qed_dcbx_lldp_remote lldp_remote;
153 struct qed_dcbx_lldp_local lldp_local;
154 struct qed_dcbx_remote_params remote;
155 struct qed_dcbx_admin_params local;
156};
Sudarsana Reddy Kalluru6ad8c632016-06-08 06:22:10 -0400157
Sudarsana Kalluru91420b82015-11-30 12:25:03 +0200158enum qed_led_mode {
159 QED_LED_MODE_OFF,
160 QED_LED_MODE_ON,
161 QED_LED_MODE_RESTORE
162};
163
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200164#define DIRECT_REG_WR(reg_addr, val) writel((u32)val, \
165 (void __iomem *)(reg_addr))
166
167#define DIRECT_REG_RD(reg_addr) readl((void __iomem *)(reg_addr))
168
169#define QED_COALESCE_MAX 0xFF
Sudarsana Reddy Kalluru0e191822016-10-21 04:43:42 -0400170#define QED_DEFAULT_RX_USECS 12
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200171
172/* forward */
173struct qed_dev;
174
175struct qed_eth_pf_params {
176 /* The following parameters are used during HW-init
177 * and these parameters need to be passed as arguments
178 * to update_pf_params routine invoked before slowpath start
179 */
180 u16 num_cons;
Chopra, Manishd51e4af2017-04-13 04:54:44 -0700181
182 /* To enable arfs, previous to HW-init a positive number needs to be
183 * set [as filters require allocated searcher ILT memory].
184 * This will set the maximal number of configured steering-filters.
185 */
186 u32 num_arfs_filters;
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200187};
188
Arun Easi1e128c82017-02-15 06:28:22 -0800189struct qed_fcoe_pf_params {
190 /* The following parameters are used during protocol-init */
191 u64 glbl_q_params_addr;
192 u64 bdq_pbl_base_addr[2];
193
194 /* The following parameters are used during HW-init
195 * and these parameters need to be passed as arguments
196 * to update_pf_params routine invoked before slowpath start
197 */
198 u16 num_cons;
199 u16 num_tasks;
200
201 /* The following parameters are used during protocol-init */
202 u16 sq_num_pbl_pages;
203
204 u16 cq_num_entries;
205 u16 cmdq_num_entries;
206 u16 rq_buffer_log_size;
207 u16 mtu;
208 u16 dummy_icid;
209 u16 bdq_xoff_threshold[2];
210 u16 bdq_xon_threshold[2];
211 u16 rq_buffer_size;
212 u8 num_cqs; /* num of global CQs */
213 u8 log_page_size;
214 u8 gl_rq_pi;
215 u8 gl_cmd_pi;
216 u8 debug_mode;
217 u8 is_target;
218 u8 bdq_pbl_num_entries[2];
219};
220
Yuval Mintzc5ac9312016-06-03 14:35:34 +0300221/* Most of the the parameters below are described in the FW iSCSI / TCP HSI */
222struct qed_iscsi_pf_params {
223 u64 glbl_q_params_addr;
224 u64 bdq_pbl_base_addr[2];
225 u32 max_cwnd;
226 u16 cq_num_entries;
227 u16 cmdq_num_entries;
Yuval Mintzfc831822016-12-01 00:21:06 -0800228 u32 two_msl_timer;
Yuval Mintzc5ac9312016-06-03 14:35:34 +0300229 u16 dup_ack_threshold;
230 u16 tx_sws_timer;
231 u16 min_rto;
232 u16 min_rto_rt;
233 u16 max_rto;
234
235 /* The following parameters are used during HW-init
236 * and these parameters need to be passed as arguments
237 * to update_pf_params routine invoked before slowpath start
238 */
239 u16 num_cons;
240 u16 num_tasks;
241
242 /* The following parameters are used during protocol-init */
243 u16 half_way_close_timeout;
244 u16 bdq_xoff_threshold[2];
245 u16 bdq_xon_threshold[2];
246 u16 cmdq_xoff_threshold;
247 u16 cmdq_xon_threshold;
248 u16 rq_buffer_size;
249
250 u8 num_sq_pages_in_ring;
251 u8 num_r2tq_pages_in_ring;
252 u8 num_uhq_pages_in_ring;
253 u8 num_queues;
254 u8 log_page_size;
255 u8 rqe_log_size;
256 u8 max_fin_rt;
257 u8 gl_rq_pi;
258 u8 gl_cmd_pi;
259 u8 debug_mode;
260 u8 ll2_ooo_queue_id;
261 u8 ooo_enable;
262
263 u8 is_target;
264 u8 bdq_pbl_num_entries[2];
265};
266
267struct qed_rdma_pf_params {
268 /* Supplied to QED during resource allocation (may affect the ILT and
269 * the doorbell BAR).
270 */
271 u32 min_dpis; /* number of requested DPIs */
Yuval Mintzc5ac9312016-06-03 14:35:34 +0300272 u32 num_qps; /* number of requested Queue Pairs */
273 u32 num_srqs; /* number of requested SRQ */
274 u8 roce_edpm_mode; /* see QED_ROCE_EDPM_MODE_ENABLE */
275 u8 gl_pi; /* protocol index */
276
277 /* Will allocate rate limiters to be used with QPs */
278 u8 enable_dcqcn;
279};
280
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200281struct qed_pf_params {
282 struct qed_eth_pf_params eth_pf_params;
Arun Easi1e128c82017-02-15 06:28:22 -0800283 struct qed_fcoe_pf_params fcoe_pf_params;
Yuval Mintzc5ac9312016-06-03 14:35:34 +0300284 struct qed_iscsi_pf_params iscsi_pf_params;
285 struct qed_rdma_pf_params rdma_pf_params;
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200286};
287
288enum qed_int_mode {
289 QED_INT_MODE_INTA,
290 QED_INT_MODE_MSIX,
291 QED_INT_MODE_MSI,
292 QED_INT_MODE_POLL,
293};
294
295struct qed_sb_info {
296 struct status_block *sb_virt;
297 dma_addr_t sb_phys;
298 u32 sb_ack; /* Last given ack */
299 u16 igu_sb_id;
300 void __iomem *igu_addr;
301 u8 flags;
302#define QED_SB_INFO_INIT 0x1
303#define QED_SB_INFO_SETUP 0x2
304
305 struct qed_dev *cdev;
306};
307
Mintz, Yuval9c79dda2017-03-14 16:23:54 +0200308enum qed_dev_type {
309 QED_DEV_TYPE_BB,
310 QED_DEV_TYPE_AH,
311};
312
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200313struct qed_dev_info {
314 unsigned long pci_mem_start;
315 unsigned long pci_mem_end;
316 unsigned int pci_irq;
317 u8 num_hwfns;
318
319 u8 hw_mac[ETH_ALEN];
Yuval Mintzfc48b7a2016-02-15 13:22:35 -0500320 bool is_mf_default;
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200321
322 /* FW version */
323 u16 fw_major;
324 u16 fw_minor;
325 u16 fw_rev;
326 u16 fw_eng;
327
328 /* MFW version */
329 u32 mfw_rev;
330
331 u32 flash_size;
332 u8 mf_mode;
Yuval Mintz831bfb0e2016-05-11 16:36:25 +0300333 bool tx_switching;
Ram Amranicee9fbd2016-10-01 21:59:56 +0300334 bool rdma_supported;
Sudarsana Kalluru0fefbfb2016-10-31 07:14:21 +0200335 u16 mtu;
Mintz, Yuval14d39642016-10-31 07:14:23 +0200336
337 bool wol_support;
Mintz, Yuval9c79dda2017-03-14 16:23:54 +0200338
339 enum qed_dev_type dev_type;
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200340};
341
342enum qed_sb_type {
343 QED_SB_TYPE_L2_QUEUE,
Ram Amrani51ff1722016-10-01 21:59:57 +0300344 QED_SB_TYPE_CNQ,
Yuval Mintzfc831822016-12-01 00:21:06 -0800345 QED_SB_TYPE_STORAGE,
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200346};
347
348enum qed_protocol {
349 QED_PROTOCOL_ETH,
Yuval Mintzc5ac9312016-06-03 14:35:34 +0300350 QED_PROTOCOL_ISCSI,
Arun Easi1e128c82017-02-15 06:28:22 -0800351 QED_PROTOCOL_FCOE,
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200352};
353
Sudarsana Reddy Kalluru054c67d2016-08-09 03:51:23 -0400354enum qed_link_mode_bits {
355 QED_LM_FIBRE_BIT = BIT(0),
356 QED_LM_Autoneg_BIT = BIT(1),
357 QED_LM_Asym_Pause_BIT = BIT(2),
358 QED_LM_Pause_BIT = BIT(3),
359 QED_LM_1000baseT_Half_BIT = BIT(4),
360 QED_LM_1000baseT_Full_BIT = BIT(5),
361 QED_LM_10000baseKR_Full_BIT = BIT(6),
362 QED_LM_25000baseKR_Full_BIT = BIT(7),
363 QED_LM_40000baseLR4_Full_BIT = BIT(8),
364 QED_LM_50000baseKR2_Full_BIT = BIT(9),
365 QED_LM_100000baseKR4_Full_BIT = BIT(10),
366 QED_LM_COUNT = 11
367};
368
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200369struct qed_link_params {
370 bool link_up;
371
372#define QED_LINK_OVERRIDE_SPEED_AUTONEG BIT(0)
373#define QED_LINK_OVERRIDE_SPEED_ADV_SPEEDS BIT(1)
374#define QED_LINK_OVERRIDE_SPEED_FORCED_SPEED BIT(2)
375#define QED_LINK_OVERRIDE_PAUSE_CONFIG BIT(3)
Sudarsana Reddy Kalluru03dc76c2016-04-28 20:20:52 -0400376#define QED_LINK_OVERRIDE_LOOPBACK_MODE BIT(4)
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200377 u32 override_flags;
378 bool autoneg;
379 u32 adv_speeds;
380 u32 forced_speed;
381#define QED_LINK_PAUSE_AUTONEG_ENABLE BIT(0)
382#define QED_LINK_PAUSE_RX_ENABLE BIT(1)
383#define QED_LINK_PAUSE_TX_ENABLE BIT(2)
384 u32 pause_config;
Sudarsana Reddy Kalluru03dc76c2016-04-28 20:20:52 -0400385#define QED_LINK_LOOPBACK_NONE BIT(0)
386#define QED_LINK_LOOPBACK_INT_PHY BIT(1)
387#define QED_LINK_LOOPBACK_EXT_PHY BIT(2)
388#define QED_LINK_LOOPBACK_EXT BIT(3)
389#define QED_LINK_LOOPBACK_MAC BIT(4)
390 u32 loopback_mode;
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200391};
392
393struct qed_link_output {
394 bool link_up;
395
Yuval Mintzd194fd22016-08-19 08:34:57 +0300396 /* In QED_LM_* defs */
397 u32 supported_caps;
398 u32 advertised_caps;
399 u32 lp_caps;
400
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200401 u32 speed; /* In Mb/s */
402 u8 duplex; /* In DUPLEX defs */
403 u8 port; /* In PORT defs */
404 bool autoneg;
405 u32 pause_config;
406};
407
Yuval Mintz1408cc1f2016-05-11 16:36:14 +0300408struct qed_probe_params {
409 enum qed_protocol protocol;
410 u32 dp_module;
411 u8 dp_level;
412 bool is_vf;
413};
414
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200415#define QED_DRV_VER_STR_SIZE 12
416struct qed_slowpath_params {
417 u32 int_mode;
418 u8 drv_major;
419 u8 drv_minor;
420 u8 drv_rev;
421 u8 drv_eng;
422 u8 name[QED_DRV_VER_STR_SIZE];
423};
424
425#define ILT_PAGE_SIZE_TCFC 0x8000 /* 32KB */
426
427struct qed_int_info {
428 struct msix_entry *msix;
429 u8 msix_cnt;
430
431 /* This should be updated by the protocol driver */
432 u8 used_cnt;
433};
434
435struct qed_common_cb_ops {
Chopra, Manishd51e4af2017-04-13 04:54:44 -0700436 void (*arfs_filter_op)(void *dev, void *fltr, u8 fw_rc);
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200437 void (*link_update)(void *dev,
438 struct qed_link_output *link);
Arun Easi1e128c82017-02-15 06:28:22 -0800439 void (*dcbx_aen)(void *dev, struct qed_dcbx_get *get, u32 mib_type);
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200440};
441
Sudarsana Reddy Kalluru03dc76c2016-04-28 20:20:52 -0400442struct qed_selftest_ops {
443/**
444 * @brief selftest_interrupt - Perform interrupt test
445 *
446 * @param cdev
447 *
448 * @return 0 on success, error otherwise.
449 */
450 int (*selftest_interrupt)(struct qed_dev *cdev);
451
452/**
453 * @brief selftest_memory - Perform memory test
454 *
455 * @param cdev
456 *
457 * @return 0 on success, error otherwise.
458 */
459 int (*selftest_memory)(struct qed_dev *cdev);
460
461/**
462 * @brief selftest_register - Perform register test
463 *
464 * @param cdev
465 *
466 * @return 0 on success, error otherwise.
467 */
468 int (*selftest_register)(struct qed_dev *cdev);
469
470/**
471 * @brief selftest_clock - Perform clock test
472 *
473 * @param cdev
474 *
475 * @return 0 on success, error otherwise.
476 */
477 int (*selftest_clock)(struct qed_dev *cdev);
Mintz, Yuval7a4b21b2016-10-31 07:14:22 +0200478
479/**
480 * @brief selftest_nvram - Perform nvram test
481 *
482 * @param cdev
483 *
484 * @return 0 on success, error otherwise.
485 */
486 int (*selftest_nvram) (struct qed_dev *cdev);
Sudarsana Reddy Kalluru03dc76c2016-04-28 20:20:52 -0400487};
488
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200489struct qed_common_ops {
Sudarsana Reddy Kalluru03dc76c2016-04-28 20:20:52 -0400490 struct qed_selftest_ops *selftest;
491
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200492 struct qed_dev* (*probe)(struct pci_dev *dev,
Yuval Mintz1408cc1f2016-05-11 16:36:14 +0300493 struct qed_probe_params *params);
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200494
495 void (*remove)(struct qed_dev *cdev);
496
497 int (*set_power_state)(struct qed_dev *cdev,
498 pci_power_t state);
499
500 void (*set_id)(struct qed_dev *cdev,
501 char name[],
502 char ver_str[]);
503
504 /* Client drivers need to make this call before slowpath_start.
505 * PF params required for the call before slowpath_start is
506 * documented within the qed_pf_params structure definition.
507 */
508 void (*update_pf_params)(struct qed_dev *cdev,
509 struct qed_pf_params *params);
510 int (*slowpath_start)(struct qed_dev *cdev,
511 struct qed_slowpath_params *params);
512
513 int (*slowpath_stop)(struct qed_dev *cdev);
514
515 /* Requests to use `cnt' interrupts for fastpath.
516 * upon success, returns number of interrupts allocated for fastpath.
517 */
518 int (*set_fp_int)(struct qed_dev *cdev,
519 u16 cnt);
520
521 /* Fills `info' with pointers required for utilizing interrupts */
522 int (*get_fp_int)(struct qed_dev *cdev,
523 struct qed_int_info *info);
524
525 u32 (*sb_init)(struct qed_dev *cdev,
526 struct qed_sb_info *sb_info,
527 void *sb_virt_addr,
528 dma_addr_t sb_phy_addr,
529 u16 sb_id,
530 enum qed_sb_type type);
531
532 u32 (*sb_release)(struct qed_dev *cdev,
533 struct qed_sb_info *sb_info,
534 u16 sb_id);
535
536 void (*simd_handler_config)(struct qed_dev *cdev,
537 void *token,
538 int index,
539 void (*handler)(void *));
540
541 void (*simd_handler_clean)(struct qed_dev *cdev,
542 int index);
Arun Easi1e128c82017-02-15 06:28:22 -0800543 int (*dbg_grc)(struct qed_dev *cdev,
544 void *buffer, u32 *num_dumped_bytes);
545
546 int (*dbg_grc_size)(struct qed_dev *cdev);
Yuval Mintzfe7cd2b2016-04-22 08:41:03 +0300547
Tomer Tayare0971c82016-09-07 16:36:25 +0300548 int (*dbg_all_data) (struct qed_dev *cdev, void *buffer);
549
550 int (*dbg_all_data_size) (struct qed_dev *cdev);
551
Yuval Mintzfe7cd2b2016-04-22 08:41:03 +0300552/**
553 * @brief can_link_change - can the instance change the link or not
554 *
555 * @param cdev
556 *
557 * @return true if link-change is allowed, false otherwise.
558 */
559 bool (*can_link_change)(struct qed_dev *cdev);
560
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200561/**
562 * @brief set_link - set links according to params
563 *
564 * @param cdev
565 * @param params - values used to override the default link configuration
566 *
567 * @return 0 on success, error otherwise.
568 */
569 int (*set_link)(struct qed_dev *cdev,
570 struct qed_link_params *params);
571
572/**
573 * @brief get_link - returns the current link state.
574 *
575 * @param cdev
576 * @param if_link - structure to be filled with current link configuration.
577 */
578 void (*get_link)(struct qed_dev *cdev,
579 struct qed_link_output *if_link);
580
581/**
582 * @brief - drains chip in case Tx completions fail to arrive due to pause.
583 *
584 * @param cdev
585 */
586 int (*drain)(struct qed_dev *cdev);
587
588/**
589 * @brief update_msglvl - update module debug level
590 *
591 * @param cdev
592 * @param dp_module
593 * @param dp_level
594 */
595 void (*update_msglvl)(struct qed_dev *cdev,
596 u32 dp_module,
597 u8 dp_level);
598
599 int (*chain_alloc)(struct qed_dev *cdev,
600 enum qed_chain_use_mode intended_use,
601 enum qed_chain_mode mode,
Yuval Mintza91eb522016-06-03 14:35:32 +0300602 enum qed_chain_cnt_type cnt_type,
603 u32 num_elems,
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200604 size_t elem_size,
605 struct qed_chain *p_chain);
606
607 void (*chain_free)(struct qed_dev *cdev,
608 struct qed_chain *p_chain);
Sudarsana Kalluru91420b82015-11-30 12:25:03 +0200609
610/**
Sudarsana Reddy Kalluru722003a2016-06-21 09:36:21 -0400611 * @brief get_coalesce - Get coalesce parameters in usec
612 *
613 * @param cdev
614 * @param rx_coal - Rx coalesce value in usec
615 * @param tx_coal - Tx coalesce value in usec
616 *
617 */
618 void (*get_coalesce)(struct qed_dev *cdev, u16 *rx_coal, u16 *tx_coal);
619
620/**
621 * @brief set_coalesce - Configure Rx coalesce value in usec
622 *
623 * @param cdev
624 * @param rx_coal - Rx coalesce value in usec
625 * @param tx_coal - Tx coalesce value in usec
626 * @param qid - Queue index
627 * @param sb_id - Status Block Id
628 *
629 * @return 0 on success, error otherwise.
630 */
631 int (*set_coalesce)(struct qed_dev *cdev, u16 rx_coal, u16 tx_coal,
632 u8 qid, u16 sb_id);
633
634/**
Sudarsana Kalluru91420b82015-11-30 12:25:03 +0200635 * @brief set_led - Configure LED mode
636 *
637 * @param cdev
638 * @param mode - LED mode
639 *
640 * @return 0 on success, error otherwise.
641 */
642 int (*set_led)(struct qed_dev *cdev,
643 enum qed_led_mode mode);
Sudarsana Kalluru0fefbfb2016-10-31 07:14:21 +0200644
645/**
646 * @brief update_drv_state - API to inform the change in the driver state.
647 *
648 * @param cdev
649 * @param active
650 *
651 */
652 int (*update_drv_state)(struct qed_dev *cdev, bool active);
653
654/**
655 * @brief update_mac - API to inform the change in the mac address
656 *
657 * @param cdev
658 * @param mac
659 *
660 */
661 int (*update_mac)(struct qed_dev *cdev, u8 *mac);
662
663/**
664 * @brief update_mtu - API to inform the change in the mtu
665 *
666 * @param cdev
667 * @param mtu
668 *
669 */
670 int (*update_mtu)(struct qed_dev *cdev, u16 mtu);
Mintz, Yuval14d39642016-10-31 07:14:23 +0200671
672/**
673 * @brief update_wol - update of changes in the WoL configuration
674 *
675 * @param cdev
676 * @param enabled - true iff WoL should be enabled.
677 */
678 int (*update_wol) (struct qed_dev *cdev, bool enabled);
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200679};
680
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200681#define MASK_FIELD(_name, _value) \
682 ((_value) &= (_name ## _MASK))
683
684#define FIELD_VALUE(_name, _value) \
685 ((_value & _name ## _MASK) << _name ## _SHIFT)
686
687#define SET_FIELD(value, name, flag) \
688 do { \
689 (value) &= ~(name ## _MASK << name ## _SHIFT); \
690 (value) |= (((u64)flag) << (name ## _SHIFT)); \
691 } while (0)
692
693#define GET_FIELD(value, name) \
694 (((value) >> (name ## _SHIFT)) & name ## _MASK)
695
696/* Debug print definitions */
697#define DP_ERR(cdev, fmt, ...) \
698 pr_err("[%s:%d(%s)]" fmt, \
699 __func__, __LINE__, \
700 DP_NAME(cdev) ? DP_NAME(cdev) : "", \
701 ## __VA_ARGS__) \
702
703#define DP_NOTICE(cdev, fmt, ...) \
704 do { \
705 if (unlikely((cdev)->dp_level <= QED_LEVEL_NOTICE)) { \
706 pr_notice("[%s:%d(%s)]" fmt, \
707 __func__, __LINE__, \
708 DP_NAME(cdev) ? DP_NAME(cdev) : "", \
709 ## __VA_ARGS__); \
710 \
711 } \
712 } while (0)
713
714#define DP_INFO(cdev, fmt, ...) \
715 do { \
716 if (unlikely((cdev)->dp_level <= QED_LEVEL_INFO)) { \
717 pr_notice("[%s:%d(%s)]" fmt, \
718 __func__, __LINE__, \
719 DP_NAME(cdev) ? DP_NAME(cdev) : "", \
720 ## __VA_ARGS__); \
721 } \
722 } while (0)
723
724#define DP_VERBOSE(cdev, module, fmt, ...) \
725 do { \
726 if (unlikely(((cdev)->dp_level <= QED_LEVEL_VERBOSE) && \
727 ((cdev)->dp_module & module))) { \
728 pr_notice("[%s:%d(%s)]" fmt, \
729 __func__, __LINE__, \
730 DP_NAME(cdev) ? DP_NAME(cdev) : "", \
731 ## __VA_ARGS__); \
732 } \
733 } while (0)
734
735enum DP_LEVEL {
736 QED_LEVEL_VERBOSE = 0x0,
737 QED_LEVEL_INFO = 0x1,
738 QED_LEVEL_NOTICE = 0x2,
739 QED_LEVEL_ERR = 0x3,
740};
741
742#define QED_LOG_LEVEL_SHIFT (30)
743#define QED_LOG_VERBOSE_MASK (0x3fffffff)
744#define QED_LOG_INFO_MASK (0x40000000)
745#define QED_LOG_NOTICE_MASK (0x80000000)
746
747enum DP_MODULE {
748 QED_MSG_SPQ = 0x10000,
749 QED_MSG_STATS = 0x20000,
750 QED_MSG_DCB = 0x40000,
751 QED_MSG_IOV = 0x80000,
752 QED_MSG_SP = 0x100000,
753 QED_MSG_STORAGE = 0x200000,
754 QED_MSG_CXT = 0x800000,
Yuval Mintz0a7fb112016-10-01 21:59:55 +0300755 QED_MSG_LL2 = 0x1000000,
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200756 QED_MSG_ILT = 0x2000000,
Ram Amrani51ff1722016-10-01 21:59:57 +0300757 QED_MSG_RDMA = 0x4000000,
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200758 QED_MSG_DEBUG = 0x8000000,
759 /* to be added...up to 0x8000000 */
760};
761
Yuval Mintzfc48b7a2016-02-15 13:22:35 -0500762enum qed_mf_mode {
763 QED_MF_DEFAULT,
764 QED_MF_OVLAN,
765 QED_MF_NPAR,
766};
767
Mintz, Yuval9c79dda2017-03-14 16:23:54 +0200768struct qed_eth_stats_common {
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200769 u64 no_buff_discards;
770 u64 packet_too_big_discard;
771 u64 ttl0_discard;
772 u64 rx_ucast_bytes;
773 u64 rx_mcast_bytes;
774 u64 rx_bcast_bytes;
775 u64 rx_ucast_pkts;
776 u64 rx_mcast_pkts;
777 u64 rx_bcast_pkts;
778 u64 mftag_filter_discards;
779 u64 mac_filter_discards;
780 u64 tx_ucast_bytes;
781 u64 tx_mcast_bytes;
782 u64 tx_bcast_bytes;
783 u64 tx_ucast_pkts;
784 u64 tx_mcast_pkts;
785 u64 tx_bcast_pkts;
786 u64 tx_err_drop_pkts;
787 u64 tpa_coalesced_pkts;
788 u64 tpa_coalesced_events;
789 u64 tpa_aborts_num;
790 u64 tpa_not_coalesced_pkts;
791 u64 tpa_coalesced_bytes;
792
793 /* port */
794 u64 rx_64_byte_packets;
Yuval Mintzd4967cf2016-04-22 08:41:01 +0300795 u64 rx_65_to_127_byte_packets;
796 u64 rx_128_to_255_byte_packets;
797 u64 rx_256_to_511_byte_packets;
798 u64 rx_512_to_1023_byte_packets;
799 u64 rx_1024_to_1518_byte_packets;
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200800 u64 rx_crc_errors;
801 u64 rx_mac_crtl_frames;
802 u64 rx_pause_frames;
803 u64 rx_pfc_frames;
804 u64 rx_align_errors;
805 u64 rx_carrier_errors;
806 u64 rx_oversize_packets;
807 u64 rx_jabbers;
808 u64 rx_undersize_packets;
809 u64 rx_fragments;
810 u64 tx_64_byte_packets;
811 u64 tx_65_to_127_byte_packets;
812 u64 tx_128_to_255_byte_packets;
813 u64 tx_256_to_511_byte_packets;
814 u64 tx_512_to_1023_byte_packets;
815 u64 tx_1024_to_1518_byte_packets;
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200816 u64 tx_pause_frames;
817 u64 tx_pfc_frames;
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200818 u64 brb_truncates;
819 u64 brb_discards;
820 u64 rx_mac_bytes;
821 u64 rx_mac_uc_packets;
822 u64 rx_mac_mc_packets;
823 u64 rx_mac_bc_packets;
824 u64 rx_mac_frames_ok;
825 u64 tx_mac_bytes;
826 u64 tx_mac_uc_packets;
827 u64 tx_mac_mc_packets;
828 u64 tx_mac_bc_packets;
829 u64 tx_mac_ctrl_frames;
830};
831
Mintz, Yuval9c79dda2017-03-14 16:23:54 +0200832struct qed_eth_stats_bb {
833 u64 rx_1519_to_1522_byte_packets;
834 u64 rx_1519_to_2047_byte_packets;
835 u64 rx_2048_to_4095_byte_packets;
836 u64 rx_4096_to_9216_byte_packets;
837 u64 rx_9217_to_16383_byte_packets;
838 u64 tx_1519_to_2047_byte_packets;
839 u64 tx_2048_to_4095_byte_packets;
840 u64 tx_4096_to_9216_byte_packets;
841 u64 tx_9217_to_16383_byte_packets;
842 u64 tx_lpi_entry_count;
843 u64 tx_total_collisions;
844};
845
846struct qed_eth_stats_ah {
847 u64 rx_1519_to_max_byte_packets;
848 u64 tx_1519_to_max_byte_packets;
849};
850
851struct qed_eth_stats {
852 struct qed_eth_stats_common common;
853
854 union {
855 struct qed_eth_stats_bb bb;
856 struct qed_eth_stats_ah ah;
857 };
858};
859
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200860#define QED_SB_IDX 0x0002
861
862#define RX_PI 0
863#define TX_PI(tc) (RX_PI + 1 + tc)
864
Yuval Mintz4ac801b2016-02-28 12:26:52 +0200865struct qed_sb_cnt_info {
866 int sb_cnt;
867 int sb_iov_cnt;
868 int sb_free_blk;
869};
870
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200871static inline u16 qed_sb_update_sb_idx(struct qed_sb_info *sb_info)
872{
873 u32 prod = 0;
874 u16 rc = 0;
875
876 prod = le32_to_cpu(sb_info->sb_virt->prod_index) &
877 STATUS_BLOCK_PROD_INDEX_MASK;
878 if (sb_info->sb_ack != prod) {
879 sb_info->sb_ack = prod;
880 rc |= QED_SB_IDX;
881 }
882
883 /* Let SB update */
884 mmiowb();
885 return rc;
886}
887
888/**
889 *
890 * @brief This function creates an update command for interrupts that is
891 * written to the IGU.
892 *
893 * @param sb_info - This is the structure allocated and
894 * initialized per status block. Assumption is
895 * that it was initialized using qed_sb_init
896 * @param int_cmd - Enable/Disable/Nop
897 * @param upd_flg - whether igu consumer should be
898 * updated.
899 *
900 * @return inline void
901 */
902static inline void qed_sb_ack(struct qed_sb_info *sb_info,
903 enum igu_int_cmd int_cmd,
904 u8 upd_flg)
905{
906 struct igu_prod_cons_update igu_ack = { 0 };
907
908 igu_ack.sb_id_and_flags =
909 ((sb_info->sb_ack << IGU_PROD_CONS_UPDATE_SB_INDEX_SHIFT) |
910 (upd_flg << IGU_PROD_CONS_UPDATE_UPDATE_FLAG_SHIFT) |
911 (int_cmd << IGU_PROD_CONS_UPDATE_ENABLE_INT_SHIFT) |
912 (IGU_SEG_ACCESS_REG <<
913 IGU_PROD_CONS_UPDATE_SEGMENT_ACCESS_SHIFT));
914
915 DIRECT_REG_WR(sb_info->igu_addr, igu_ack.sb_id_and_flags);
916
917 /* Both segments (interrupts & acks) are written to same place address;
918 * Need to guarantee all commands will be received (in-order) by HW.
919 */
920 mmiowb();
921 barrier();
922}
923
924static inline void __internal_ram_wr(void *p_hwfn,
925 void __iomem *addr,
926 int size,
927 u32 *data)
928
929{
930 unsigned int i;
931
932 for (i = 0; i < size / sizeof(*data); i++)
933 DIRECT_REG_WR(&((u32 __iomem *)addr)[i], data[i]);
934}
935
936static inline void internal_ram_wr(void __iomem *addr,
937 int size,
938 u32 *data)
939{
940 __internal_ram_wr(NULL, addr, size, data);
941}
942
Sudarsana Reddy Kalluru8c5ebd02016-04-10 12:43:00 +0300943enum qed_rss_caps {
944 QED_RSS_IPV4 = 0x1,
945 QED_RSS_IPV6 = 0x2,
946 QED_RSS_IPV4_TCP = 0x4,
947 QED_RSS_IPV6_TCP = 0x8,
948 QED_RSS_IPV4_UDP = 0x10,
949 QED_RSS_IPV6_UDP = 0x20,
950};
951
952#define QED_RSS_IND_TABLE_SIZE 128
953#define QED_RSS_KEY_SIZE 10 /* size in 32b chunks */
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200954#endif