blob: 73c46d6d5727e4e354124e1516e73c9b0be74c83 [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;
sudarsana.kalluru@cavium.com49632b582017-04-20 22:31:20 -0700147 bool local;
Sudarsana Reddy Kalluru6ad8c632016-06-08 06:22:10 -0400148 u32 err;
149};
150
151struct qed_dcbx_get {
152 struct qed_dcbx_operational_params operational;
153 struct qed_dcbx_lldp_remote lldp_remote;
154 struct qed_dcbx_lldp_local lldp_local;
155 struct qed_dcbx_remote_params remote;
156 struct qed_dcbx_admin_params local;
157};
Sudarsana Reddy Kalluru6ad8c632016-06-08 06:22:10 -0400158
Sudarsana Kalluru91420b82015-11-30 12:25:03 +0200159enum qed_led_mode {
160 QED_LED_MODE_OFF,
161 QED_LED_MODE_ON,
162 QED_LED_MODE_RESTORE
163};
164
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200165#define DIRECT_REG_WR(reg_addr, val) writel((u32)val, \
166 (void __iomem *)(reg_addr))
167
168#define DIRECT_REG_RD(reg_addr) readl((void __iomem *)(reg_addr))
169
170#define QED_COALESCE_MAX 0xFF
Sudarsana Reddy Kalluru0e191822016-10-21 04:43:42 -0400171#define QED_DEFAULT_RX_USECS 12
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200172
173/* forward */
174struct qed_dev;
175
176struct qed_eth_pf_params {
177 /* The following parameters are used during HW-init
178 * and these parameters need to be passed as arguments
179 * to update_pf_params routine invoked before slowpath start
180 */
181 u16 num_cons;
Chopra, Manishd51e4af2017-04-13 04:54:44 -0700182
183 /* To enable arfs, previous to HW-init a positive number needs to be
184 * set [as filters require allocated searcher ILT memory].
185 * This will set the maximal number of configured steering-filters.
186 */
187 u32 num_arfs_filters;
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200188};
189
Arun Easi1e128c82017-02-15 06:28:22 -0800190struct qed_fcoe_pf_params {
191 /* The following parameters are used during protocol-init */
192 u64 glbl_q_params_addr;
193 u64 bdq_pbl_base_addr[2];
194
195 /* The following parameters are used during HW-init
196 * and these parameters need to be passed as arguments
197 * to update_pf_params routine invoked before slowpath start
198 */
199 u16 num_cons;
200 u16 num_tasks;
201
202 /* The following parameters are used during protocol-init */
203 u16 sq_num_pbl_pages;
204
205 u16 cq_num_entries;
206 u16 cmdq_num_entries;
207 u16 rq_buffer_log_size;
208 u16 mtu;
209 u16 dummy_icid;
210 u16 bdq_xoff_threshold[2];
211 u16 bdq_xon_threshold[2];
212 u16 rq_buffer_size;
213 u8 num_cqs; /* num of global CQs */
214 u8 log_page_size;
215 u8 gl_rq_pi;
216 u8 gl_cmd_pi;
217 u8 debug_mode;
218 u8 is_target;
219 u8 bdq_pbl_num_entries[2];
220};
221
Yuval Mintzc5ac9312016-06-03 14:35:34 +0300222/* Most of the the parameters below are described in the FW iSCSI / TCP HSI */
223struct qed_iscsi_pf_params {
224 u64 glbl_q_params_addr;
225 u64 bdq_pbl_base_addr[2];
226 u32 max_cwnd;
227 u16 cq_num_entries;
228 u16 cmdq_num_entries;
Yuval Mintzfc831822016-12-01 00:21:06 -0800229 u32 two_msl_timer;
Yuval Mintzc5ac9312016-06-03 14:35:34 +0300230 u16 dup_ack_threshold;
231 u16 tx_sws_timer;
232 u16 min_rto;
233 u16 min_rto_rt;
234 u16 max_rto;
235
236 /* The following parameters are used during HW-init
237 * and these parameters need to be passed as arguments
238 * to update_pf_params routine invoked before slowpath start
239 */
240 u16 num_cons;
241 u16 num_tasks;
242
243 /* The following parameters are used during protocol-init */
244 u16 half_way_close_timeout;
245 u16 bdq_xoff_threshold[2];
246 u16 bdq_xon_threshold[2];
247 u16 cmdq_xoff_threshold;
248 u16 cmdq_xon_threshold;
249 u16 rq_buffer_size;
250
251 u8 num_sq_pages_in_ring;
252 u8 num_r2tq_pages_in_ring;
253 u8 num_uhq_pages_in_ring;
254 u8 num_queues;
255 u8 log_page_size;
256 u8 rqe_log_size;
257 u8 max_fin_rt;
258 u8 gl_rq_pi;
259 u8 gl_cmd_pi;
260 u8 debug_mode;
261 u8 ll2_ooo_queue_id;
262 u8 ooo_enable;
263
264 u8 is_target;
265 u8 bdq_pbl_num_entries[2];
266};
267
268struct qed_rdma_pf_params {
269 /* Supplied to QED during resource allocation (may affect the ILT and
270 * the doorbell BAR).
271 */
272 u32 min_dpis; /* number of requested DPIs */
Yuval Mintzc5ac9312016-06-03 14:35:34 +0300273 u32 num_qps; /* number of requested Queue Pairs */
274 u32 num_srqs; /* number of requested SRQ */
275 u8 roce_edpm_mode; /* see QED_ROCE_EDPM_MODE_ENABLE */
276 u8 gl_pi; /* protocol index */
277
278 /* Will allocate rate limiters to be used with QPs */
279 u8 enable_dcqcn;
280};
281
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200282struct qed_pf_params {
283 struct qed_eth_pf_params eth_pf_params;
Arun Easi1e128c82017-02-15 06:28:22 -0800284 struct qed_fcoe_pf_params fcoe_pf_params;
Yuval Mintzc5ac9312016-06-03 14:35:34 +0300285 struct qed_iscsi_pf_params iscsi_pf_params;
286 struct qed_rdma_pf_params rdma_pf_params;
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200287};
288
289enum qed_int_mode {
290 QED_INT_MODE_INTA,
291 QED_INT_MODE_MSIX,
292 QED_INT_MODE_MSI,
293 QED_INT_MODE_POLL,
294};
295
296struct qed_sb_info {
297 struct status_block *sb_virt;
298 dma_addr_t sb_phys;
299 u32 sb_ack; /* Last given ack */
300 u16 igu_sb_id;
301 void __iomem *igu_addr;
302 u8 flags;
303#define QED_SB_INFO_INIT 0x1
304#define QED_SB_INFO_SETUP 0x2
305
306 struct qed_dev *cdev;
307};
308
Mintz, Yuval9c79dda2017-03-14 16:23:54 +0200309enum qed_dev_type {
310 QED_DEV_TYPE_BB,
311 QED_DEV_TYPE_AH,
312};
313
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200314struct qed_dev_info {
315 unsigned long pci_mem_start;
316 unsigned long pci_mem_end;
317 unsigned int pci_irq;
318 u8 num_hwfns;
319
320 u8 hw_mac[ETH_ALEN];
Yuval Mintzfc48b7a2016-02-15 13:22:35 -0500321 bool is_mf_default;
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200322
323 /* FW version */
324 u16 fw_major;
325 u16 fw_minor;
326 u16 fw_rev;
327 u16 fw_eng;
328
329 /* MFW version */
330 u32 mfw_rev;
Tomer Tayarae336662017-05-23 09:41:26 +0300331#define QED_MFW_VERSION_0_MASK 0x000000FF
332#define QED_MFW_VERSION_0_OFFSET 0
333#define QED_MFW_VERSION_1_MASK 0x0000FF00
334#define QED_MFW_VERSION_1_OFFSET 8
335#define QED_MFW_VERSION_2_MASK 0x00FF0000
336#define QED_MFW_VERSION_2_OFFSET 16
337#define QED_MFW_VERSION_3_MASK 0xFF000000
338#define QED_MFW_VERSION_3_OFFSET 24
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200339
340 u32 flash_size;
341 u8 mf_mode;
Yuval Mintz831bfb0e2016-05-11 16:36:25 +0300342 bool tx_switching;
Ram Amranicee9fbd2016-10-01 21:59:56 +0300343 bool rdma_supported;
Sudarsana Kalluru0fefbfb2016-10-31 07:14:21 +0200344 u16 mtu;
Mintz, Yuval14d39642016-10-31 07:14:23 +0200345
346 bool wol_support;
Mintz, Yuval9c79dda2017-03-14 16:23:54 +0200347
Tomer Tayarae336662017-05-23 09:41:26 +0300348 /* MBI version */
349 u32 mbi_version;
350#define QED_MBI_VERSION_0_MASK 0x000000FF
351#define QED_MBI_VERSION_0_OFFSET 0
352#define QED_MBI_VERSION_1_MASK 0x0000FF00
353#define QED_MBI_VERSION_1_OFFSET 8
354#define QED_MBI_VERSION_2_MASK 0x00FF0000
355#define QED_MBI_VERSION_2_OFFSET 16
356
Mintz, Yuval9c79dda2017-03-14 16:23:54 +0200357 enum qed_dev_type dev_type;
Chopra, Manish19489c72017-04-24 10:00:45 -0700358
359 /* Output parameters for qede */
360 bool vxlan_enable;
361 bool gre_enable;
362 bool geneve_enable;
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200363};
364
365enum qed_sb_type {
366 QED_SB_TYPE_L2_QUEUE,
Ram Amrani51ff1722016-10-01 21:59:57 +0300367 QED_SB_TYPE_CNQ,
Yuval Mintzfc831822016-12-01 00:21:06 -0800368 QED_SB_TYPE_STORAGE,
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200369};
370
371enum qed_protocol {
372 QED_PROTOCOL_ETH,
Yuval Mintzc5ac9312016-06-03 14:35:34 +0300373 QED_PROTOCOL_ISCSI,
Arun Easi1e128c82017-02-15 06:28:22 -0800374 QED_PROTOCOL_FCOE,
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200375};
376
Sudarsana Reddy Kalluru054c67d2016-08-09 03:51:23 -0400377enum qed_link_mode_bits {
378 QED_LM_FIBRE_BIT = BIT(0),
379 QED_LM_Autoneg_BIT = BIT(1),
380 QED_LM_Asym_Pause_BIT = BIT(2),
381 QED_LM_Pause_BIT = BIT(3),
382 QED_LM_1000baseT_Half_BIT = BIT(4),
383 QED_LM_1000baseT_Full_BIT = BIT(5),
384 QED_LM_10000baseKR_Full_BIT = BIT(6),
385 QED_LM_25000baseKR_Full_BIT = BIT(7),
386 QED_LM_40000baseLR4_Full_BIT = BIT(8),
387 QED_LM_50000baseKR2_Full_BIT = BIT(9),
388 QED_LM_100000baseKR4_Full_BIT = BIT(10),
389 QED_LM_COUNT = 11
390};
391
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200392struct qed_link_params {
393 bool link_up;
394
395#define QED_LINK_OVERRIDE_SPEED_AUTONEG BIT(0)
396#define QED_LINK_OVERRIDE_SPEED_ADV_SPEEDS BIT(1)
397#define QED_LINK_OVERRIDE_SPEED_FORCED_SPEED BIT(2)
398#define QED_LINK_OVERRIDE_PAUSE_CONFIG BIT(3)
Sudarsana Reddy Kalluru03dc76c2016-04-28 20:20:52 -0400399#define QED_LINK_OVERRIDE_LOOPBACK_MODE BIT(4)
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200400 u32 override_flags;
401 bool autoneg;
402 u32 adv_speeds;
403 u32 forced_speed;
404#define QED_LINK_PAUSE_AUTONEG_ENABLE BIT(0)
405#define QED_LINK_PAUSE_RX_ENABLE BIT(1)
406#define QED_LINK_PAUSE_TX_ENABLE BIT(2)
407 u32 pause_config;
Sudarsana Reddy Kalluru03dc76c2016-04-28 20:20:52 -0400408#define QED_LINK_LOOPBACK_NONE BIT(0)
409#define QED_LINK_LOOPBACK_INT_PHY BIT(1)
410#define QED_LINK_LOOPBACK_EXT_PHY BIT(2)
411#define QED_LINK_LOOPBACK_EXT BIT(3)
412#define QED_LINK_LOOPBACK_MAC BIT(4)
413 u32 loopback_mode;
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200414};
415
416struct qed_link_output {
417 bool link_up;
418
Yuval Mintzd194fd22016-08-19 08:34:57 +0300419 /* In QED_LM_* defs */
420 u32 supported_caps;
421 u32 advertised_caps;
422 u32 lp_caps;
423
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200424 u32 speed; /* In Mb/s */
425 u8 duplex; /* In DUPLEX defs */
426 u8 port; /* In PORT defs */
427 bool autoneg;
428 u32 pause_config;
429};
430
Yuval Mintz1408cc1f2016-05-11 16:36:14 +0300431struct qed_probe_params {
432 enum qed_protocol protocol;
433 u32 dp_module;
434 u8 dp_level;
435 bool is_vf;
436};
437
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200438#define QED_DRV_VER_STR_SIZE 12
439struct qed_slowpath_params {
440 u32 int_mode;
441 u8 drv_major;
442 u8 drv_minor;
443 u8 drv_rev;
444 u8 drv_eng;
445 u8 name[QED_DRV_VER_STR_SIZE];
446};
447
448#define ILT_PAGE_SIZE_TCFC 0x8000 /* 32KB */
449
450struct qed_int_info {
451 struct msix_entry *msix;
452 u8 msix_cnt;
453
454 /* This should be updated by the protocol driver */
455 u8 used_cnt;
456};
457
458struct qed_common_cb_ops {
Chopra, Manishd51e4af2017-04-13 04:54:44 -0700459 void (*arfs_filter_op)(void *dev, void *fltr, u8 fw_rc);
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200460 void (*link_update)(void *dev,
461 struct qed_link_output *link);
Arun Easi1e128c82017-02-15 06:28:22 -0800462 void (*dcbx_aen)(void *dev, struct qed_dcbx_get *get, u32 mib_type);
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200463};
464
Sudarsana Reddy Kalluru03dc76c2016-04-28 20:20:52 -0400465struct qed_selftest_ops {
466/**
467 * @brief selftest_interrupt - Perform interrupt test
468 *
469 * @param cdev
470 *
471 * @return 0 on success, error otherwise.
472 */
473 int (*selftest_interrupt)(struct qed_dev *cdev);
474
475/**
476 * @brief selftest_memory - Perform memory test
477 *
478 * @param cdev
479 *
480 * @return 0 on success, error otherwise.
481 */
482 int (*selftest_memory)(struct qed_dev *cdev);
483
484/**
485 * @brief selftest_register - Perform register test
486 *
487 * @param cdev
488 *
489 * @return 0 on success, error otherwise.
490 */
491 int (*selftest_register)(struct qed_dev *cdev);
492
493/**
494 * @brief selftest_clock - Perform clock test
495 *
496 * @param cdev
497 *
498 * @return 0 on success, error otherwise.
499 */
500 int (*selftest_clock)(struct qed_dev *cdev);
Mintz, Yuval7a4b21b2016-10-31 07:14:22 +0200501
502/**
503 * @brief selftest_nvram - Perform nvram test
504 *
505 * @param cdev
506 *
507 * @return 0 on success, error otherwise.
508 */
509 int (*selftest_nvram) (struct qed_dev *cdev);
Sudarsana Reddy Kalluru03dc76c2016-04-28 20:20:52 -0400510};
511
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200512struct qed_common_ops {
Sudarsana Reddy Kalluru03dc76c2016-04-28 20:20:52 -0400513 struct qed_selftest_ops *selftest;
514
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200515 struct qed_dev* (*probe)(struct pci_dev *dev,
Yuval Mintz1408cc1f2016-05-11 16:36:14 +0300516 struct qed_probe_params *params);
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200517
518 void (*remove)(struct qed_dev *cdev);
519
520 int (*set_power_state)(struct qed_dev *cdev,
521 pci_power_t state);
522
Mintz, Yuval712c3cb2017-05-23 09:41:28 +0300523 void (*set_name) (struct qed_dev *cdev, char name[]);
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200524
525 /* Client drivers need to make this call before slowpath_start.
526 * PF params required for the call before slowpath_start is
527 * documented within the qed_pf_params structure definition.
528 */
529 void (*update_pf_params)(struct qed_dev *cdev,
530 struct qed_pf_params *params);
531 int (*slowpath_start)(struct qed_dev *cdev,
532 struct qed_slowpath_params *params);
533
534 int (*slowpath_stop)(struct qed_dev *cdev);
535
536 /* Requests to use `cnt' interrupts for fastpath.
537 * upon success, returns number of interrupts allocated for fastpath.
538 */
539 int (*set_fp_int)(struct qed_dev *cdev,
540 u16 cnt);
541
542 /* Fills `info' with pointers required for utilizing interrupts */
543 int (*get_fp_int)(struct qed_dev *cdev,
544 struct qed_int_info *info);
545
546 u32 (*sb_init)(struct qed_dev *cdev,
547 struct qed_sb_info *sb_info,
548 void *sb_virt_addr,
549 dma_addr_t sb_phy_addr,
550 u16 sb_id,
551 enum qed_sb_type type);
552
553 u32 (*sb_release)(struct qed_dev *cdev,
554 struct qed_sb_info *sb_info,
555 u16 sb_id);
556
557 void (*simd_handler_config)(struct qed_dev *cdev,
558 void *token,
559 int index,
560 void (*handler)(void *));
561
562 void (*simd_handler_clean)(struct qed_dev *cdev,
563 int index);
Arun Easi1e128c82017-02-15 06:28:22 -0800564 int (*dbg_grc)(struct qed_dev *cdev,
565 void *buffer, u32 *num_dumped_bytes);
566
567 int (*dbg_grc_size)(struct qed_dev *cdev);
Yuval Mintzfe7cd2b2016-04-22 08:41:03 +0300568
Tomer Tayare0971c82016-09-07 16:36:25 +0300569 int (*dbg_all_data) (struct qed_dev *cdev, void *buffer);
570
571 int (*dbg_all_data_size) (struct qed_dev *cdev);
572
Yuval Mintzfe7cd2b2016-04-22 08:41:03 +0300573/**
574 * @brief can_link_change - can the instance change the link or not
575 *
576 * @param cdev
577 *
578 * @return true if link-change is allowed, false otherwise.
579 */
580 bool (*can_link_change)(struct qed_dev *cdev);
581
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200582/**
583 * @brief set_link - set links according to params
584 *
585 * @param cdev
586 * @param params - values used to override the default link configuration
587 *
588 * @return 0 on success, error otherwise.
589 */
590 int (*set_link)(struct qed_dev *cdev,
591 struct qed_link_params *params);
592
593/**
594 * @brief get_link - returns the current link state.
595 *
596 * @param cdev
597 * @param if_link - structure to be filled with current link configuration.
598 */
599 void (*get_link)(struct qed_dev *cdev,
600 struct qed_link_output *if_link);
601
602/**
603 * @brief - drains chip in case Tx completions fail to arrive due to pause.
604 *
605 * @param cdev
606 */
607 int (*drain)(struct qed_dev *cdev);
608
609/**
610 * @brief update_msglvl - update module debug level
611 *
612 * @param cdev
613 * @param dp_module
614 * @param dp_level
615 */
616 void (*update_msglvl)(struct qed_dev *cdev,
617 u32 dp_module,
618 u8 dp_level);
619
620 int (*chain_alloc)(struct qed_dev *cdev,
621 enum qed_chain_use_mode intended_use,
622 enum qed_chain_mode mode,
Yuval Mintza91eb522016-06-03 14:35:32 +0300623 enum qed_chain_cnt_type cnt_type,
624 u32 num_elems,
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200625 size_t elem_size,
626 struct qed_chain *p_chain);
627
628 void (*chain_free)(struct qed_dev *cdev,
629 struct qed_chain *p_chain);
Sudarsana Kalluru91420b82015-11-30 12:25:03 +0200630
631/**
Sudarsana Reddy Kalluru722003a2016-06-21 09:36:21 -0400632 * @brief get_coalesce - Get coalesce parameters in usec
633 *
634 * @param cdev
635 * @param rx_coal - Rx coalesce value in usec
636 * @param tx_coal - Tx coalesce value in usec
637 *
638 */
639 void (*get_coalesce)(struct qed_dev *cdev, u16 *rx_coal, u16 *tx_coal);
640
641/**
642 * @brief set_coalesce - Configure Rx coalesce value in usec
643 *
644 * @param cdev
645 * @param rx_coal - Rx coalesce value in usec
646 * @param tx_coal - Tx coalesce value in usec
647 * @param qid - Queue index
648 * @param sb_id - Status Block Id
649 *
650 * @return 0 on success, error otherwise.
651 */
652 int (*set_coalesce)(struct qed_dev *cdev, u16 rx_coal, u16 tx_coal,
sudarsana.kalluru@cavium.comf870a3c2017-05-04 08:15:03 -0700653 u16 qid, u16 sb_id);
Sudarsana Reddy Kalluru722003a2016-06-21 09:36:21 -0400654
655/**
Sudarsana Kalluru91420b82015-11-30 12:25:03 +0200656 * @brief set_led - Configure LED mode
657 *
658 * @param cdev
659 * @param mode - LED mode
660 *
661 * @return 0 on success, error otherwise.
662 */
663 int (*set_led)(struct qed_dev *cdev,
664 enum qed_led_mode mode);
Sudarsana Kalluru0fefbfb2016-10-31 07:14:21 +0200665
666/**
667 * @brief update_drv_state - API to inform the change in the driver state.
668 *
669 * @param cdev
670 * @param active
671 *
672 */
673 int (*update_drv_state)(struct qed_dev *cdev, bool active);
674
675/**
676 * @brief update_mac - API to inform the change in the mac address
677 *
678 * @param cdev
679 * @param mac
680 *
681 */
682 int (*update_mac)(struct qed_dev *cdev, u8 *mac);
683
684/**
685 * @brief update_mtu - API to inform the change in the mtu
686 *
687 * @param cdev
688 * @param mtu
689 *
690 */
691 int (*update_mtu)(struct qed_dev *cdev, u16 mtu);
Mintz, Yuval14d39642016-10-31 07:14:23 +0200692
693/**
694 * @brief update_wol - update of changes in the WoL configuration
695 *
696 * @param cdev
697 * @param enabled - true iff WoL should be enabled.
698 */
699 int (*update_wol) (struct qed_dev *cdev, bool enabled);
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200700};
701
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200702#define MASK_FIELD(_name, _value) \
703 ((_value) &= (_name ## _MASK))
704
705#define FIELD_VALUE(_name, _value) \
706 ((_value & _name ## _MASK) << _name ## _SHIFT)
707
708#define SET_FIELD(value, name, flag) \
709 do { \
710 (value) &= ~(name ## _MASK << name ## _SHIFT); \
711 (value) |= (((u64)flag) << (name ## _SHIFT)); \
712 } while (0)
713
714#define GET_FIELD(value, name) \
715 (((value) >> (name ## _SHIFT)) & name ## _MASK)
716
717/* Debug print definitions */
Mintz, Yuval9d7650c2017-05-23 09:41:19 +0300718#define DP_ERR(cdev, fmt, ...) \
719 do { \
720 pr_err("[%s:%d(%s)]" fmt, \
721 __func__, __LINE__, \
722 DP_NAME(cdev) ? DP_NAME(cdev) : "", \
723 ## __VA_ARGS__); \
724 } while (0)
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200725
726#define DP_NOTICE(cdev, fmt, ...) \
727 do { \
728 if (unlikely((cdev)->dp_level <= QED_LEVEL_NOTICE)) { \
729 pr_notice("[%s:%d(%s)]" fmt, \
730 __func__, __LINE__, \
731 DP_NAME(cdev) ? DP_NAME(cdev) : "", \
732 ## __VA_ARGS__); \
733 \
734 } \
735 } while (0)
736
737#define DP_INFO(cdev, fmt, ...) \
738 do { \
739 if (unlikely((cdev)->dp_level <= QED_LEVEL_INFO)) { \
740 pr_notice("[%s:%d(%s)]" fmt, \
741 __func__, __LINE__, \
742 DP_NAME(cdev) ? DP_NAME(cdev) : "", \
743 ## __VA_ARGS__); \
744 } \
745 } while (0)
746
747#define DP_VERBOSE(cdev, module, fmt, ...) \
748 do { \
749 if (unlikely(((cdev)->dp_level <= QED_LEVEL_VERBOSE) && \
750 ((cdev)->dp_module & module))) { \
751 pr_notice("[%s:%d(%s)]" fmt, \
752 __func__, __LINE__, \
753 DP_NAME(cdev) ? DP_NAME(cdev) : "", \
754 ## __VA_ARGS__); \
755 } \
756 } while (0)
757
758enum DP_LEVEL {
759 QED_LEVEL_VERBOSE = 0x0,
760 QED_LEVEL_INFO = 0x1,
761 QED_LEVEL_NOTICE = 0x2,
762 QED_LEVEL_ERR = 0x3,
763};
764
765#define QED_LOG_LEVEL_SHIFT (30)
766#define QED_LOG_VERBOSE_MASK (0x3fffffff)
767#define QED_LOG_INFO_MASK (0x40000000)
768#define QED_LOG_NOTICE_MASK (0x80000000)
769
770enum DP_MODULE {
771 QED_MSG_SPQ = 0x10000,
772 QED_MSG_STATS = 0x20000,
773 QED_MSG_DCB = 0x40000,
774 QED_MSG_IOV = 0x80000,
775 QED_MSG_SP = 0x100000,
776 QED_MSG_STORAGE = 0x200000,
777 QED_MSG_CXT = 0x800000,
Yuval Mintz0a7fb112016-10-01 21:59:55 +0300778 QED_MSG_LL2 = 0x1000000,
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200779 QED_MSG_ILT = 0x2000000,
Ram Amrani51ff1722016-10-01 21:59:57 +0300780 QED_MSG_RDMA = 0x4000000,
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200781 QED_MSG_DEBUG = 0x8000000,
782 /* to be added...up to 0x8000000 */
783};
784
Yuval Mintzfc48b7a2016-02-15 13:22:35 -0500785enum qed_mf_mode {
786 QED_MF_DEFAULT,
787 QED_MF_OVLAN,
788 QED_MF_NPAR,
789};
790
Mintz, Yuval9c79dda2017-03-14 16:23:54 +0200791struct qed_eth_stats_common {
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200792 u64 no_buff_discards;
793 u64 packet_too_big_discard;
794 u64 ttl0_discard;
795 u64 rx_ucast_bytes;
796 u64 rx_mcast_bytes;
797 u64 rx_bcast_bytes;
798 u64 rx_ucast_pkts;
799 u64 rx_mcast_pkts;
800 u64 rx_bcast_pkts;
801 u64 mftag_filter_discards;
802 u64 mac_filter_discards;
803 u64 tx_ucast_bytes;
804 u64 tx_mcast_bytes;
805 u64 tx_bcast_bytes;
806 u64 tx_ucast_pkts;
807 u64 tx_mcast_pkts;
808 u64 tx_bcast_pkts;
809 u64 tx_err_drop_pkts;
810 u64 tpa_coalesced_pkts;
811 u64 tpa_coalesced_events;
812 u64 tpa_aborts_num;
813 u64 tpa_not_coalesced_pkts;
814 u64 tpa_coalesced_bytes;
815
816 /* port */
817 u64 rx_64_byte_packets;
Yuval Mintzd4967cf2016-04-22 08:41:01 +0300818 u64 rx_65_to_127_byte_packets;
819 u64 rx_128_to_255_byte_packets;
820 u64 rx_256_to_511_byte_packets;
821 u64 rx_512_to_1023_byte_packets;
822 u64 rx_1024_to_1518_byte_packets;
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200823 u64 rx_crc_errors;
824 u64 rx_mac_crtl_frames;
825 u64 rx_pause_frames;
826 u64 rx_pfc_frames;
827 u64 rx_align_errors;
828 u64 rx_carrier_errors;
829 u64 rx_oversize_packets;
830 u64 rx_jabbers;
831 u64 rx_undersize_packets;
832 u64 rx_fragments;
833 u64 tx_64_byte_packets;
834 u64 tx_65_to_127_byte_packets;
835 u64 tx_128_to_255_byte_packets;
836 u64 tx_256_to_511_byte_packets;
837 u64 tx_512_to_1023_byte_packets;
838 u64 tx_1024_to_1518_byte_packets;
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200839 u64 tx_pause_frames;
840 u64 tx_pfc_frames;
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200841 u64 brb_truncates;
842 u64 brb_discards;
843 u64 rx_mac_bytes;
844 u64 rx_mac_uc_packets;
845 u64 rx_mac_mc_packets;
846 u64 rx_mac_bc_packets;
847 u64 rx_mac_frames_ok;
848 u64 tx_mac_bytes;
849 u64 tx_mac_uc_packets;
850 u64 tx_mac_mc_packets;
851 u64 tx_mac_bc_packets;
852 u64 tx_mac_ctrl_frames;
853};
854
Mintz, Yuval9c79dda2017-03-14 16:23:54 +0200855struct qed_eth_stats_bb {
856 u64 rx_1519_to_1522_byte_packets;
857 u64 rx_1519_to_2047_byte_packets;
858 u64 rx_2048_to_4095_byte_packets;
859 u64 rx_4096_to_9216_byte_packets;
860 u64 rx_9217_to_16383_byte_packets;
861 u64 tx_1519_to_2047_byte_packets;
862 u64 tx_2048_to_4095_byte_packets;
863 u64 tx_4096_to_9216_byte_packets;
864 u64 tx_9217_to_16383_byte_packets;
865 u64 tx_lpi_entry_count;
866 u64 tx_total_collisions;
867};
868
869struct qed_eth_stats_ah {
870 u64 rx_1519_to_max_byte_packets;
871 u64 tx_1519_to_max_byte_packets;
872};
873
874struct qed_eth_stats {
875 struct qed_eth_stats_common common;
876
877 union {
878 struct qed_eth_stats_bb bb;
879 struct qed_eth_stats_ah ah;
880 };
881};
882
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200883#define QED_SB_IDX 0x0002
884
885#define RX_PI 0
886#define TX_PI(tc) (RX_PI + 1 + tc)
887
Yuval Mintz4ac801b2016-02-28 12:26:52 +0200888struct qed_sb_cnt_info {
889 int sb_cnt;
890 int sb_iov_cnt;
891 int sb_free_blk;
892};
893
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200894static inline u16 qed_sb_update_sb_idx(struct qed_sb_info *sb_info)
895{
896 u32 prod = 0;
897 u16 rc = 0;
898
899 prod = le32_to_cpu(sb_info->sb_virt->prod_index) &
900 STATUS_BLOCK_PROD_INDEX_MASK;
901 if (sb_info->sb_ack != prod) {
902 sb_info->sb_ack = prod;
903 rc |= QED_SB_IDX;
904 }
905
906 /* Let SB update */
907 mmiowb();
908 return rc;
909}
910
911/**
912 *
913 * @brief This function creates an update command for interrupts that is
914 * written to the IGU.
915 *
916 * @param sb_info - This is the structure allocated and
917 * initialized per status block. Assumption is
918 * that it was initialized using qed_sb_init
919 * @param int_cmd - Enable/Disable/Nop
920 * @param upd_flg - whether igu consumer should be
921 * updated.
922 *
923 * @return inline void
924 */
925static inline void qed_sb_ack(struct qed_sb_info *sb_info,
926 enum igu_int_cmd int_cmd,
927 u8 upd_flg)
928{
929 struct igu_prod_cons_update igu_ack = { 0 };
930
931 igu_ack.sb_id_and_flags =
932 ((sb_info->sb_ack << IGU_PROD_CONS_UPDATE_SB_INDEX_SHIFT) |
933 (upd_flg << IGU_PROD_CONS_UPDATE_UPDATE_FLAG_SHIFT) |
934 (int_cmd << IGU_PROD_CONS_UPDATE_ENABLE_INT_SHIFT) |
935 (IGU_SEG_ACCESS_REG <<
936 IGU_PROD_CONS_UPDATE_SEGMENT_ACCESS_SHIFT));
937
938 DIRECT_REG_WR(sb_info->igu_addr, igu_ack.sb_id_and_flags);
939
940 /* Both segments (interrupts & acks) are written to same place address;
941 * Need to guarantee all commands will be received (in-order) by HW.
942 */
943 mmiowb();
944 barrier();
945}
946
947static inline void __internal_ram_wr(void *p_hwfn,
948 void __iomem *addr,
949 int size,
950 u32 *data)
951
952{
953 unsigned int i;
954
955 for (i = 0; i < size / sizeof(*data); i++)
956 DIRECT_REG_WR(&((u32 __iomem *)addr)[i], data[i]);
957}
958
959static inline void internal_ram_wr(void __iomem *addr,
960 int size,
961 u32 *data)
962{
963 __internal_ram_wr(NULL, addr, size, data);
964}
965
Sudarsana Reddy Kalluru8c5ebd02016-04-10 12:43:00 +0300966enum qed_rss_caps {
967 QED_RSS_IPV4 = 0x1,
968 QED_RSS_IPV6 = 0x2,
969 QED_RSS_IPV4_TCP = 0x4,
970 QED_RSS_IPV6_TCP = 0x8,
971 QED_RSS_IPV4_UDP = 0x10,
972 QED_RSS_IPV6_UDP = 0x20,
973};
974
975#define QED_RSS_IND_TABLE_SIZE 128
976#define QED_RSS_KEY_SIZE 10 /* size in 32b chunks */
Yuval Mintzfe56b9e2015-10-26 11:02:25 +0200977#endif