Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1 | /* QLogic qed NIC Driver |
| 2 | * |
| 3 | * Copyright (c) 2015 QLogic Corporation |
| 4 | * |
| 5 | * This software is available under the terms of the GNU General Public License |
| 6 | * (GPL) Version 2, available from the file COPYING in the main directory of |
| 7 | * this source tree. |
| 8 | */ |
| 9 | |
| 10 | #ifndef _QED_IF_H |
| 11 | #define _QED_IF_H |
| 12 | |
| 13 | #include <linux/types.h> |
| 14 | #include <linux/interrupt.h> |
| 15 | #include <linux/netdevice.h> |
| 16 | #include <linux/pci.h> |
| 17 | #include <linux/skbuff.h> |
| 18 | #include <linux/types.h> |
| 19 | #include <asm/byteorder.h> |
| 20 | #include <linux/io.h> |
| 21 | #include <linux/compiler.h> |
| 22 | #include <linux/kernel.h> |
| 23 | #include <linux/list.h> |
| 24 | #include <linux/slab.h> |
| 25 | #include <linux/qed/common_hsi.h> |
| 26 | #include <linux/qed/qed_chain.h> |
| 27 | |
Sudarsana Reddy Kalluru | 39651ab | 2016-05-17 06:44:26 -0400 | [diff] [blame] | 28 | enum dcbx_protocol_type { |
| 29 | DCBX_PROTOCOL_ISCSI, |
| 30 | DCBX_PROTOCOL_FCOE, |
| 31 | DCBX_PROTOCOL_ROCE, |
| 32 | DCBX_PROTOCOL_ROCE_V2, |
| 33 | DCBX_PROTOCOL_ETH, |
| 34 | DCBX_MAX_PROTOCOL_TYPE |
| 35 | }; |
| 36 | |
Ram Amrani | 51ff172 | 2016-10-01 21:59:57 +0300 | [diff] [blame] | 37 | #define QED_ROCE_PROTOCOL_INDEX (3) |
| 38 | |
Sudarsana Reddy Kalluru | 6ad8c63 | 2016-06-08 06:22:10 -0400 | [diff] [blame] | 39 | #ifdef CONFIG_DCB |
| 40 | #define QED_LLDP_CHASSIS_ID_STAT_LEN 4 |
| 41 | #define QED_LLDP_PORT_ID_STAT_LEN 4 |
| 42 | #define QED_DCBX_MAX_APP_PROTOCOL 32 |
| 43 | #define QED_MAX_PFC_PRIORITIES 8 |
| 44 | #define QED_DCBX_DSCP_SIZE 64 |
| 45 | |
| 46 | struct qed_dcbx_lldp_remote { |
| 47 | u32 peer_chassis_id[QED_LLDP_CHASSIS_ID_STAT_LEN]; |
| 48 | u32 peer_port_id[QED_LLDP_PORT_ID_STAT_LEN]; |
| 49 | bool enable_rx; |
| 50 | bool enable_tx; |
| 51 | u32 tx_interval; |
| 52 | u32 max_credit; |
| 53 | }; |
| 54 | |
| 55 | struct qed_dcbx_lldp_local { |
| 56 | u32 local_chassis_id[QED_LLDP_CHASSIS_ID_STAT_LEN]; |
| 57 | u32 local_port_id[QED_LLDP_PORT_ID_STAT_LEN]; |
| 58 | }; |
| 59 | |
| 60 | struct qed_dcbx_app_prio { |
| 61 | u8 roce; |
| 62 | u8 roce_v2; |
| 63 | u8 fcoe; |
| 64 | u8 iscsi; |
| 65 | u8 eth; |
| 66 | }; |
| 67 | |
| 68 | struct qed_dbcx_pfc_params { |
| 69 | bool willing; |
| 70 | bool enabled; |
| 71 | u8 prio[QED_MAX_PFC_PRIORITIES]; |
| 72 | u8 max_tc; |
| 73 | }; |
| 74 | |
Sudarsana Reddy Kalluru | 59bcb79 | 2016-08-08 21:57:42 -0400 | [diff] [blame] | 75 | enum qed_dcbx_sf_ieee_type { |
| 76 | QED_DCBX_SF_IEEE_ETHTYPE, |
| 77 | QED_DCBX_SF_IEEE_TCP_PORT, |
| 78 | QED_DCBX_SF_IEEE_UDP_PORT, |
| 79 | QED_DCBX_SF_IEEE_TCP_UDP_PORT |
| 80 | }; |
| 81 | |
Sudarsana Reddy Kalluru | 6ad8c63 | 2016-06-08 06:22:10 -0400 | [diff] [blame] | 82 | struct qed_app_entry { |
| 83 | bool ethtype; |
Sudarsana Reddy Kalluru | 59bcb79 | 2016-08-08 21:57:42 -0400 | [diff] [blame] | 84 | enum qed_dcbx_sf_ieee_type sf_ieee; |
Sudarsana Reddy Kalluru | 6ad8c63 | 2016-06-08 06:22:10 -0400 | [diff] [blame] | 85 | bool enabled; |
| 86 | u8 prio; |
| 87 | u16 proto_id; |
| 88 | enum dcbx_protocol_type proto_type; |
| 89 | }; |
| 90 | |
| 91 | struct qed_dcbx_params { |
| 92 | struct qed_app_entry app_entry[QED_DCBX_MAX_APP_PROTOCOL]; |
| 93 | u16 num_app_entries; |
| 94 | bool app_willing; |
| 95 | bool app_valid; |
| 96 | bool app_error; |
| 97 | bool ets_willing; |
| 98 | bool ets_enabled; |
| 99 | bool ets_cbs; |
| 100 | bool valid; |
| 101 | u8 ets_pri_tc_tbl[QED_MAX_PFC_PRIORITIES]; |
| 102 | u8 ets_tc_bw_tbl[QED_MAX_PFC_PRIORITIES]; |
| 103 | u8 ets_tc_tsa_tbl[QED_MAX_PFC_PRIORITIES]; |
| 104 | struct qed_dbcx_pfc_params pfc; |
| 105 | u8 max_ets_tc; |
| 106 | }; |
| 107 | |
| 108 | struct qed_dcbx_admin_params { |
| 109 | struct qed_dcbx_params params; |
| 110 | bool valid; |
| 111 | }; |
| 112 | |
| 113 | struct qed_dcbx_remote_params { |
| 114 | struct qed_dcbx_params params; |
| 115 | bool valid; |
| 116 | }; |
| 117 | |
| 118 | struct qed_dcbx_operational_params { |
| 119 | struct qed_dcbx_app_prio app_prio; |
| 120 | struct qed_dcbx_params params; |
| 121 | bool valid; |
| 122 | bool enabled; |
| 123 | bool ieee; |
| 124 | bool cee; |
| 125 | u32 err; |
| 126 | }; |
| 127 | |
| 128 | struct qed_dcbx_get { |
| 129 | struct qed_dcbx_operational_params operational; |
| 130 | struct qed_dcbx_lldp_remote lldp_remote; |
| 131 | struct qed_dcbx_lldp_local lldp_local; |
| 132 | struct qed_dcbx_remote_params remote; |
| 133 | struct qed_dcbx_admin_params local; |
| 134 | }; |
| 135 | #endif |
| 136 | |
Sudarsana Kalluru | 91420b8 | 2015-11-30 12:25:03 +0200 | [diff] [blame] | 137 | enum qed_led_mode { |
| 138 | QED_LED_MODE_OFF, |
| 139 | QED_LED_MODE_ON, |
| 140 | QED_LED_MODE_RESTORE |
| 141 | }; |
| 142 | |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 143 | #define DIRECT_REG_WR(reg_addr, val) writel((u32)val, \ |
| 144 | (void __iomem *)(reg_addr)) |
| 145 | |
| 146 | #define DIRECT_REG_RD(reg_addr) readl((void __iomem *)(reg_addr)) |
| 147 | |
| 148 | #define QED_COALESCE_MAX 0xFF |
Sudarsana Reddy Kalluru | 0e19182 | 2016-10-21 04:43:42 -0400 | [diff] [blame] | 149 | #define QED_DEFAULT_RX_USECS 12 |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 150 | |
| 151 | /* forward */ |
| 152 | struct qed_dev; |
| 153 | |
| 154 | struct qed_eth_pf_params { |
| 155 | /* The following parameters are used during HW-init |
| 156 | * and these parameters need to be passed as arguments |
| 157 | * to update_pf_params routine invoked before slowpath start |
| 158 | */ |
| 159 | u16 num_cons; |
| 160 | }; |
| 161 | |
Yuval Mintz | c5ac931 | 2016-06-03 14:35:34 +0300 | [diff] [blame] | 162 | /* Most of the the parameters below are described in the FW iSCSI / TCP HSI */ |
| 163 | struct qed_iscsi_pf_params { |
| 164 | u64 glbl_q_params_addr; |
| 165 | u64 bdq_pbl_base_addr[2]; |
| 166 | u32 max_cwnd; |
| 167 | u16 cq_num_entries; |
| 168 | u16 cmdq_num_entries; |
Yuval Mintz | fc83182 | 2016-12-01 00:21:06 -0800 | [diff] [blame] | 169 | u32 two_msl_timer; |
Yuval Mintz | c5ac931 | 2016-06-03 14:35:34 +0300 | [diff] [blame] | 170 | u16 dup_ack_threshold; |
| 171 | u16 tx_sws_timer; |
| 172 | u16 min_rto; |
| 173 | u16 min_rto_rt; |
| 174 | u16 max_rto; |
| 175 | |
| 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; |
| 181 | u16 num_tasks; |
| 182 | |
| 183 | /* The following parameters are used during protocol-init */ |
| 184 | u16 half_way_close_timeout; |
| 185 | u16 bdq_xoff_threshold[2]; |
| 186 | u16 bdq_xon_threshold[2]; |
| 187 | u16 cmdq_xoff_threshold; |
| 188 | u16 cmdq_xon_threshold; |
| 189 | u16 rq_buffer_size; |
| 190 | |
| 191 | u8 num_sq_pages_in_ring; |
| 192 | u8 num_r2tq_pages_in_ring; |
| 193 | u8 num_uhq_pages_in_ring; |
| 194 | u8 num_queues; |
| 195 | u8 log_page_size; |
| 196 | u8 rqe_log_size; |
| 197 | u8 max_fin_rt; |
| 198 | u8 gl_rq_pi; |
| 199 | u8 gl_cmd_pi; |
| 200 | u8 debug_mode; |
| 201 | u8 ll2_ooo_queue_id; |
| 202 | u8 ooo_enable; |
| 203 | |
| 204 | u8 is_target; |
| 205 | u8 bdq_pbl_num_entries[2]; |
| 206 | }; |
| 207 | |
| 208 | struct qed_rdma_pf_params { |
| 209 | /* Supplied to QED during resource allocation (may affect the ILT and |
| 210 | * the doorbell BAR). |
| 211 | */ |
| 212 | u32 min_dpis; /* number of requested DPIs */ |
| 213 | u32 num_mrs; /* number of requested memory regions */ |
| 214 | u32 num_qps; /* number of requested Queue Pairs */ |
| 215 | u32 num_srqs; /* number of requested SRQ */ |
| 216 | u8 roce_edpm_mode; /* see QED_ROCE_EDPM_MODE_ENABLE */ |
| 217 | u8 gl_pi; /* protocol index */ |
| 218 | |
| 219 | /* Will allocate rate limiters to be used with QPs */ |
| 220 | u8 enable_dcqcn; |
| 221 | }; |
| 222 | |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 223 | struct qed_pf_params { |
| 224 | struct qed_eth_pf_params eth_pf_params; |
Yuval Mintz | c5ac931 | 2016-06-03 14:35:34 +0300 | [diff] [blame] | 225 | struct qed_iscsi_pf_params iscsi_pf_params; |
| 226 | struct qed_rdma_pf_params rdma_pf_params; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 227 | }; |
| 228 | |
| 229 | enum qed_int_mode { |
| 230 | QED_INT_MODE_INTA, |
| 231 | QED_INT_MODE_MSIX, |
| 232 | QED_INT_MODE_MSI, |
| 233 | QED_INT_MODE_POLL, |
| 234 | }; |
| 235 | |
| 236 | struct qed_sb_info { |
| 237 | struct status_block *sb_virt; |
| 238 | dma_addr_t sb_phys; |
| 239 | u32 sb_ack; /* Last given ack */ |
| 240 | u16 igu_sb_id; |
| 241 | void __iomem *igu_addr; |
| 242 | u8 flags; |
| 243 | #define QED_SB_INFO_INIT 0x1 |
| 244 | #define QED_SB_INFO_SETUP 0x2 |
| 245 | |
| 246 | struct qed_dev *cdev; |
| 247 | }; |
| 248 | |
| 249 | struct qed_dev_info { |
| 250 | unsigned long pci_mem_start; |
| 251 | unsigned long pci_mem_end; |
| 252 | unsigned int pci_irq; |
| 253 | u8 num_hwfns; |
| 254 | |
| 255 | u8 hw_mac[ETH_ALEN]; |
Yuval Mintz | fc48b7a | 2016-02-15 13:22:35 -0500 | [diff] [blame] | 256 | bool is_mf_default; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 257 | |
| 258 | /* FW version */ |
| 259 | u16 fw_major; |
| 260 | u16 fw_minor; |
| 261 | u16 fw_rev; |
| 262 | u16 fw_eng; |
| 263 | |
| 264 | /* MFW version */ |
| 265 | u32 mfw_rev; |
| 266 | |
| 267 | u32 flash_size; |
| 268 | u8 mf_mode; |
Yuval Mintz | 831bfb0e | 2016-05-11 16:36:25 +0300 | [diff] [blame] | 269 | bool tx_switching; |
Ram Amrani | cee9fbd | 2016-10-01 21:59:56 +0300 | [diff] [blame] | 270 | bool rdma_supported; |
Sudarsana Kalluru | 0fefbfb | 2016-10-31 07:14:21 +0200 | [diff] [blame] | 271 | u16 mtu; |
Mintz, Yuval | 14d3964 | 2016-10-31 07:14:23 +0200 | [diff] [blame] | 272 | |
| 273 | bool wol_support; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 274 | }; |
| 275 | |
| 276 | enum qed_sb_type { |
| 277 | QED_SB_TYPE_L2_QUEUE, |
Ram Amrani | 51ff172 | 2016-10-01 21:59:57 +0300 | [diff] [blame] | 278 | QED_SB_TYPE_CNQ, |
Yuval Mintz | fc83182 | 2016-12-01 00:21:06 -0800 | [diff] [blame] | 279 | QED_SB_TYPE_STORAGE, |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 280 | }; |
| 281 | |
| 282 | enum qed_protocol { |
| 283 | QED_PROTOCOL_ETH, |
Yuval Mintz | c5ac931 | 2016-06-03 14:35:34 +0300 | [diff] [blame] | 284 | QED_PROTOCOL_ISCSI, |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 285 | }; |
| 286 | |
Sudarsana Reddy Kalluru | 054c67d | 2016-08-09 03:51:23 -0400 | [diff] [blame] | 287 | enum qed_link_mode_bits { |
| 288 | QED_LM_FIBRE_BIT = BIT(0), |
| 289 | QED_LM_Autoneg_BIT = BIT(1), |
| 290 | QED_LM_Asym_Pause_BIT = BIT(2), |
| 291 | QED_LM_Pause_BIT = BIT(3), |
| 292 | QED_LM_1000baseT_Half_BIT = BIT(4), |
| 293 | QED_LM_1000baseT_Full_BIT = BIT(5), |
| 294 | QED_LM_10000baseKR_Full_BIT = BIT(6), |
| 295 | QED_LM_25000baseKR_Full_BIT = BIT(7), |
| 296 | QED_LM_40000baseLR4_Full_BIT = BIT(8), |
| 297 | QED_LM_50000baseKR2_Full_BIT = BIT(9), |
| 298 | QED_LM_100000baseKR4_Full_BIT = BIT(10), |
| 299 | QED_LM_COUNT = 11 |
| 300 | }; |
| 301 | |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 302 | struct qed_link_params { |
| 303 | bool link_up; |
| 304 | |
| 305 | #define QED_LINK_OVERRIDE_SPEED_AUTONEG BIT(0) |
| 306 | #define QED_LINK_OVERRIDE_SPEED_ADV_SPEEDS BIT(1) |
| 307 | #define QED_LINK_OVERRIDE_SPEED_FORCED_SPEED BIT(2) |
| 308 | #define QED_LINK_OVERRIDE_PAUSE_CONFIG BIT(3) |
Sudarsana Reddy Kalluru | 03dc76c | 2016-04-28 20:20:52 -0400 | [diff] [blame] | 309 | #define QED_LINK_OVERRIDE_LOOPBACK_MODE BIT(4) |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 310 | u32 override_flags; |
| 311 | bool autoneg; |
| 312 | u32 adv_speeds; |
| 313 | u32 forced_speed; |
| 314 | #define QED_LINK_PAUSE_AUTONEG_ENABLE BIT(0) |
| 315 | #define QED_LINK_PAUSE_RX_ENABLE BIT(1) |
| 316 | #define QED_LINK_PAUSE_TX_ENABLE BIT(2) |
| 317 | u32 pause_config; |
Sudarsana Reddy Kalluru | 03dc76c | 2016-04-28 20:20:52 -0400 | [diff] [blame] | 318 | #define QED_LINK_LOOPBACK_NONE BIT(0) |
| 319 | #define QED_LINK_LOOPBACK_INT_PHY BIT(1) |
| 320 | #define QED_LINK_LOOPBACK_EXT_PHY BIT(2) |
| 321 | #define QED_LINK_LOOPBACK_EXT BIT(3) |
| 322 | #define QED_LINK_LOOPBACK_MAC BIT(4) |
| 323 | u32 loopback_mode; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 324 | }; |
| 325 | |
| 326 | struct qed_link_output { |
| 327 | bool link_up; |
| 328 | |
Yuval Mintz | d194fd2 | 2016-08-19 08:34:57 +0300 | [diff] [blame] | 329 | /* In QED_LM_* defs */ |
| 330 | u32 supported_caps; |
| 331 | u32 advertised_caps; |
| 332 | u32 lp_caps; |
| 333 | |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 334 | u32 speed; /* In Mb/s */ |
| 335 | u8 duplex; /* In DUPLEX defs */ |
| 336 | u8 port; /* In PORT defs */ |
| 337 | bool autoneg; |
| 338 | u32 pause_config; |
| 339 | }; |
| 340 | |
Yuval Mintz | 1408cc1f | 2016-05-11 16:36:14 +0300 | [diff] [blame] | 341 | struct qed_probe_params { |
| 342 | enum qed_protocol protocol; |
| 343 | u32 dp_module; |
| 344 | u8 dp_level; |
| 345 | bool is_vf; |
| 346 | }; |
| 347 | |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 348 | #define QED_DRV_VER_STR_SIZE 12 |
| 349 | struct qed_slowpath_params { |
| 350 | u32 int_mode; |
| 351 | u8 drv_major; |
| 352 | u8 drv_minor; |
| 353 | u8 drv_rev; |
| 354 | u8 drv_eng; |
| 355 | u8 name[QED_DRV_VER_STR_SIZE]; |
| 356 | }; |
| 357 | |
| 358 | #define ILT_PAGE_SIZE_TCFC 0x8000 /* 32KB */ |
| 359 | |
| 360 | struct qed_int_info { |
| 361 | struct msix_entry *msix; |
| 362 | u8 msix_cnt; |
| 363 | |
| 364 | /* This should be updated by the protocol driver */ |
| 365 | u8 used_cnt; |
| 366 | }; |
| 367 | |
| 368 | struct qed_common_cb_ops { |
| 369 | void (*link_update)(void *dev, |
| 370 | struct qed_link_output *link); |
| 371 | }; |
| 372 | |
Sudarsana Reddy Kalluru | 03dc76c | 2016-04-28 20:20:52 -0400 | [diff] [blame] | 373 | struct qed_selftest_ops { |
| 374 | /** |
| 375 | * @brief selftest_interrupt - Perform interrupt test |
| 376 | * |
| 377 | * @param cdev |
| 378 | * |
| 379 | * @return 0 on success, error otherwise. |
| 380 | */ |
| 381 | int (*selftest_interrupt)(struct qed_dev *cdev); |
| 382 | |
| 383 | /** |
| 384 | * @brief selftest_memory - Perform memory test |
| 385 | * |
| 386 | * @param cdev |
| 387 | * |
| 388 | * @return 0 on success, error otherwise. |
| 389 | */ |
| 390 | int (*selftest_memory)(struct qed_dev *cdev); |
| 391 | |
| 392 | /** |
| 393 | * @brief selftest_register - Perform register test |
| 394 | * |
| 395 | * @param cdev |
| 396 | * |
| 397 | * @return 0 on success, error otherwise. |
| 398 | */ |
| 399 | int (*selftest_register)(struct qed_dev *cdev); |
| 400 | |
| 401 | /** |
| 402 | * @brief selftest_clock - Perform clock test |
| 403 | * |
| 404 | * @param cdev |
| 405 | * |
| 406 | * @return 0 on success, error otherwise. |
| 407 | */ |
| 408 | int (*selftest_clock)(struct qed_dev *cdev); |
Mintz, Yuval | 7a4b21b | 2016-10-31 07:14:22 +0200 | [diff] [blame] | 409 | |
| 410 | /** |
| 411 | * @brief selftest_nvram - Perform nvram test |
| 412 | * |
| 413 | * @param cdev |
| 414 | * |
| 415 | * @return 0 on success, error otherwise. |
| 416 | */ |
| 417 | int (*selftest_nvram) (struct qed_dev *cdev); |
Sudarsana Reddy Kalluru | 03dc76c | 2016-04-28 20:20:52 -0400 | [diff] [blame] | 418 | }; |
| 419 | |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 420 | struct qed_common_ops { |
Sudarsana Reddy Kalluru | 03dc76c | 2016-04-28 20:20:52 -0400 | [diff] [blame] | 421 | struct qed_selftest_ops *selftest; |
| 422 | |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 423 | struct qed_dev* (*probe)(struct pci_dev *dev, |
Yuval Mintz | 1408cc1f | 2016-05-11 16:36:14 +0300 | [diff] [blame] | 424 | struct qed_probe_params *params); |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 425 | |
| 426 | void (*remove)(struct qed_dev *cdev); |
| 427 | |
| 428 | int (*set_power_state)(struct qed_dev *cdev, |
| 429 | pci_power_t state); |
| 430 | |
| 431 | void (*set_id)(struct qed_dev *cdev, |
| 432 | char name[], |
| 433 | char ver_str[]); |
| 434 | |
| 435 | /* Client drivers need to make this call before slowpath_start. |
| 436 | * PF params required for the call before slowpath_start is |
| 437 | * documented within the qed_pf_params structure definition. |
| 438 | */ |
| 439 | void (*update_pf_params)(struct qed_dev *cdev, |
| 440 | struct qed_pf_params *params); |
| 441 | int (*slowpath_start)(struct qed_dev *cdev, |
| 442 | struct qed_slowpath_params *params); |
| 443 | |
| 444 | int (*slowpath_stop)(struct qed_dev *cdev); |
| 445 | |
| 446 | /* Requests to use `cnt' interrupts for fastpath. |
| 447 | * upon success, returns number of interrupts allocated for fastpath. |
| 448 | */ |
| 449 | int (*set_fp_int)(struct qed_dev *cdev, |
| 450 | u16 cnt); |
| 451 | |
| 452 | /* Fills `info' with pointers required for utilizing interrupts */ |
| 453 | int (*get_fp_int)(struct qed_dev *cdev, |
| 454 | struct qed_int_info *info); |
| 455 | |
| 456 | u32 (*sb_init)(struct qed_dev *cdev, |
| 457 | struct qed_sb_info *sb_info, |
| 458 | void *sb_virt_addr, |
| 459 | dma_addr_t sb_phy_addr, |
| 460 | u16 sb_id, |
| 461 | enum qed_sb_type type); |
| 462 | |
| 463 | u32 (*sb_release)(struct qed_dev *cdev, |
| 464 | struct qed_sb_info *sb_info, |
| 465 | u16 sb_id); |
| 466 | |
| 467 | void (*simd_handler_config)(struct qed_dev *cdev, |
| 468 | void *token, |
| 469 | int index, |
| 470 | void (*handler)(void *)); |
| 471 | |
| 472 | void (*simd_handler_clean)(struct qed_dev *cdev, |
| 473 | int index); |
Yuval Mintz | fe7cd2b | 2016-04-22 08:41:03 +0300 | [diff] [blame] | 474 | |
Tomer Tayar | e0971c8 | 2016-09-07 16:36:25 +0300 | [diff] [blame] | 475 | int (*dbg_all_data) (struct qed_dev *cdev, void *buffer); |
| 476 | |
| 477 | int (*dbg_all_data_size) (struct qed_dev *cdev); |
| 478 | |
Yuval Mintz | fe7cd2b | 2016-04-22 08:41:03 +0300 | [diff] [blame] | 479 | /** |
| 480 | * @brief can_link_change - can the instance change the link or not |
| 481 | * |
| 482 | * @param cdev |
| 483 | * |
| 484 | * @return true if link-change is allowed, false otherwise. |
| 485 | */ |
| 486 | bool (*can_link_change)(struct qed_dev *cdev); |
| 487 | |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 488 | /** |
| 489 | * @brief set_link - set links according to params |
| 490 | * |
| 491 | * @param cdev |
| 492 | * @param params - values used to override the default link configuration |
| 493 | * |
| 494 | * @return 0 on success, error otherwise. |
| 495 | */ |
| 496 | int (*set_link)(struct qed_dev *cdev, |
| 497 | struct qed_link_params *params); |
| 498 | |
| 499 | /** |
| 500 | * @brief get_link - returns the current link state. |
| 501 | * |
| 502 | * @param cdev |
| 503 | * @param if_link - structure to be filled with current link configuration. |
| 504 | */ |
| 505 | void (*get_link)(struct qed_dev *cdev, |
| 506 | struct qed_link_output *if_link); |
| 507 | |
| 508 | /** |
| 509 | * @brief - drains chip in case Tx completions fail to arrive due to pause. |
| 510 | * |
| 511 | * @param cdev |
| 512 | */ |
| 513 | int (*drain)(struct qed_dev *cdev); |
| 514 | |
| 515 | /** |
| 516 | * @brief update_msglvl - update module debug level |
| 517 | * |
| 518 | * @param cdev |
| 519 | * @param dp_module |
| 520 | * @param dp_level |
| 521 | */ |
| 522 | void (*update_msglvl)(struct qed_dev *cdev, |
| 523 | u32 dp_module, |
| 524 | u8 dp_level); |
| 525 | |
| 526 | int (*chain_alloc)(struct qed_dev *cdev, |
| 527 | enum qed_chain_use_mode intended_use, |
| 528 | enum qed_chain_mode mode, |
Yuval Mintz | a91eb52 | 2016-06-03 14:35:32 +0300 | [diff] [blame] | 529 | enum qed_chain_cnt_type cnt_type, |
| 530 | u32 num_elems, |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 531 | size_t elem_size, |
| 532 | struct qed_chain *p_chain); |
| 533 | |
| 534 | void (*chain_free)(struct qed_dev *cdev, |
| 535 | struct qed_chain *p_chain); |
Sudarsana Kalluru | 91420b8 | 2015-11-30 12:25:03 +0200 | [diff] [blame] | 536 | |
| 537 | /** |
Sudarsana Reddy Kalluru | 722003a | 2016-06-21 09:36:21 -0400 | [diff] [blame] | 538 | * @brief get_coalesce - Get coalesce parameters in usec |
| 539 | * |
| 540 | * @param cdev |
| 541 | * @param rx_coal - Rx coalesce value in usec |
| 542 | * @param tx_coal - Tx coalesce value in usec |
| 543 | * |
| 544 | */ |
| 545 | void (*get_coalesce)(struct qed_dev *cdev, u16 *rx_coal, u16 *tx_coal); |
| 546 | |
| 547 | /** |
| 548 | * @brief set_coalesce - Configure Rx coalesce value in usec |
| 549 | * |
| 550 | * @param cdev |
| 551 | * @param rx_coal - Rx coalesce value in usec |
| 552 | * @param tx_coal - Tx coalesce value in usec |
| 553 | * @param qid - Queue index |
| 554 | * @param sb_id - Status Block Id |
| 555 | * |
| 556 | * @return 0 on success, error otherwise. |
| 557 | */ |
| 558 | int (*set_coalesce)(struct qed_dev *cdev, u16 rx_coal, u16 tx_coal, |
| 559 | u8 qid, u16 sb_id); |
| 560 | |
| 561 | /** |
Sudarsana Kalluru | 91420b8 | 2015-11-30 12:25:03 +0200 | [diff] [blame] | 562 | * @brief set_led - Configure LED mode |
| 563 | * |
| 564 | * @param cdev |
| 565 | * @param mode - LED mode |
| 566 | * |
| 567 | * @return 0 on success, error otherwise. |
| 568 | */ |
| 569 | int (*set_led)(struct qed_dev *cdev, |
| 570 | enum qed_led_mode mode); |
Sudarsana Kalluru | 0fefbfb | 2016-10-31 07:14:21 +0200 | [diff] [blame] | 571 | |
| 572 | /** |
| 573 | * @brief update_drv_state - API to inform the change in the driver state. |
| 574 | * |
| 575 | * @param cdev |
| 576 | * @param active |
| 577 | * |
| 578 | */ |
| 579 | int (*update_drv_state)(struct qed_dev *cdev, bool active); |
| 580 | |
| 581 | /** |
| 582 | * @brief update_mac - API to inform the change in the mac address |
| 583 | * |
| 584 | * @param cdev |
| 585 | * @param mac |
| 586 | * |
| 587 | */ |
| 588 | int (*update_mac)(struct qed_dev *cdev, u8 *mac); |
| 589 | |
| 590 | /** |
| 591 | * @brief update_mtu - API to inform the change in the mtu |
| 592 | * |
| 593 | * @param cdev |
| 594 | * @param mtu |
| 595 | * |
| 596 | */ |
| 597 | int (*update_mtu)(struct qed_dev *cdev, u16 mtu); |
Mintz, Yuval | 14d3964 | 2016-10-31 07:14:23 +0200 | [diff] [blame] | 598 | |
| 599 | /** |
| 600 | * @brief update_wol - update of changes in the WoL configuration |
| 601 | * |
| 602 | * @param cdev |
| 603 | * @param enabled - true iff WoL should be enabled. |
| 604 | */ |
| 605 | int (*update_wol) (struct qed_dev *cdev, bool enabled); |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 606 | }; |
| 607 | |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 608 | #define MASK_FIELD(_name, _value) \ |
| 609 | ((_value) &= (_name ## _MASK)) |
| 610 | |
| 611 | #define FIELD_VALUE(_name, _value) \ |
| 612 | ((_value & _name ## _MASK) << _name ## _SHIFT) |
| 613 | |
| 614 | #define SET_FIELD(value, name, flag) \ |
| 615 | do { \ |
| 616 | (value) &= ~(name ## _MASK << name ## _SHIFT); \ |
| 617 | (value) |= (((u64)flag) << (name ## _SHIFT)); \ |
| 618 | } while (0) |
| 619 | |
| 620 | #define GET_FIELD(value, name) \ |
| 621 | (((value) >> (name ## _SHIFT)) & name ## _MASK) |
| 622 | |
| 623 | /* Debug print definitions */ |
| 624 | #define DP_ERR(cdev, fmt, ...) \ |
| 625 | pr_err("[%s:%d(%s)]" fmt, \ |
| 626 | __func__, __LINE__, \ |
| 627 | DP_NAME(cdev) ? DP_NAME(cdev) : "", \ |
| 628 | ## __VA_ARGS__) \ |
| 629 | |
| 630 | #define DP_NOTICE(cdev, fmt, ...) \ |
| 631 | do { \ |
| 632 | if (unlikely((cdev)->dp_level <= QED_LEVEL_NOTICE)) { \ |
| 633 | pr_notice("[%s:%d(%s)]" fmt, \ |
| 634 | __func__, __LINE__, \ |
| 635 | DP_NAME(cdev) ? DP_NAME(cdev) : "", \ |
| 636 | ## __VA_ARGS__); \ |
| 637 | \ |
| 638 | } \ |
| 639 | } while (0) |
| 640 | |
| 641 | #define DP_INFO(cdev, fmt, ...) \ |
| 642 | do { \ |
| 643 | if (unlikely((cdev)->dp_level <= QED_LEVEL_INFO)) { \ |
| 644 | pr_notice("[%s:%d(%s)]" fmt, \ |
| 645 | __func__, __LINE__, \ |
| 646 | DP_NAME(cdev) ? DP_NAME(cdev) : "", \ |
| 647 | ## __VA_ARGS__); \ |
| 648 | } \ |
| 649 | } while (0) |
| 650 | |
| 651 | #define DP_VERBOSE(cdev, module, fmt, ...) \ |
| 652 | do { \ |
| 653 | if (unlikely(((cdev)->dp_level <= QED_LEVEL_VERBOSE) && \ |
| 654 | ((cdev)->dp_module & module))) { \ |
| 655 | pr_notice("[%s:%d(%s)]" fmt, \ |
| 656 | __func__, __LINE__, \ |
| 657 | DP_NAME(cdev) ? DP_NAME(cdev) : "", \ |
| 658 | ## __VA_ARGS__); \ |
| 659 | } \ |
| 660 | } while (0) |
| 661 | |
| 662 | enum DP_LEVEL { |
| 663 | QED_LEVEL_VERBOSE = 0x0, |
| 664 | QED_LEVEL_INFO = 0x1, |
| 665 | QED_LEVEL_NOTICE = 0x2, |
| 666 | QED_LEVEL_ERR = 0x3, |
| 667 | }; |
| 668 | |
| 669 | #define QED_LOG_LEVEL_SHIFT (30) |
| 670 | #define QED_LOG_VERBOSE_MASK (0x3fffffff) |
| 671 | #define QED_LOG_INFO_MASK (0x40000000) |
| 672 | #define QED_LOG_NOTICE_MASK (0x80000000) |
| 673 | |
| 674 | enum DP_MODULE { |
| 675 | QED_MSG_SPQ = 0x10000, |
| 676 | QED_MSG_STATS = 0x20000, |
| 677 | QED_MSG_DCB = 0x40000, |
| 678 | QED_MSG_IOV = 0x80000, |
| 679 | QED_MSG_SP = 0x100000, |
| 680 | QED_MSG_STORAGE = 0x200000, |
| 681 | QED_MSG_CXT = 0x800000, |
Yuval Mintz | 0a7fb11 | 2016-10-01 21:59:55 +0300 | [diff] [blame] | 682 | QED_MSG_LL2 = 0x1000000, |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 683 | QED_MSG_ILT = 0x2000000, |
Ram Amrani | 51ff172 | 2016-10-01 21:59:57 +0300 | [diff] [blame] | 684 | QED_MSG_RDMA = 0x4000000, |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 685 | QED_MSG_DEBUG = 0x8000000, |
| 686 | /* to be added...up to 0x8000000 */ |
| 687 | }; |
| 688 | |
Yuval Mintz | fc48b7a | 2016-02-15 13:22:35 -0500 | [diff] [blame] | 689 | enum qed_mf_mode { |
| 690 | QED_MF_DEFAULT, |
| 691 | QED_MF_OVLAN, |
| 692 | QED_MF_NPAR, |
| 693 | }; |
| 694 | |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 695 | struct qed_eth_stats { |
| 696 | u64 no_buff_discards; |
| 697 | u64 packet_too_big_discard; |
| 698 | u64 ttl0_discard; |
| 699 | u64 rx_ucast_bytes; |
| 700 | u64 rx_mcast_bytes; |
| 701 | u64 rx_bcast_bytes; |
| 702 | u64 rx_ucast_pkts; |
| 703 | u64 rx_mcast_pkts; |
| 704 | u64 rx_bcast_pkts; |
| 705 | u64 mftag_filter_discards; |
| 706 | u64 mac_filter_discards; |
| 707 | u64 tx_ucast_bytes; |
| 708 | u64 tx_mcast_bytes; |
| 709 | u64 tx_bcast_bytes; |
| 710 | u64 tx_ucast_pkts; |
| 711 | u64 tx_mcast_pkts; |
| 712 | u64 tx_bcast_pkts; |
| 713 | u64 tx_err_drop_pkts; |
| 714 | u64 tpa_coalesced_pkts; |
| 715 | u64 tpa_coalesced_events; |
| 716 | u64 tpa_aborts_num; |
| 717 | u64 tpa_not_coalesced_pkts; |
| 718 | u64 tpa_coalesced_bytes; |
| 719 | |
| 720 | /* port */ |
| 721 | u64 rx_64_byte_packets; |
Yuval Mintz | d4967cf | 2016-04-22 08:41:01 +0300 | [diff] [blame] | 722 | u64 rx_65_to_127_byte_packets; |
| 723 | u64 rx_128_to_255_byte_packets; |
| 724 | u64 rx_256_to_511_byte_packets; |
| 725 | u64 rx_512_to_1023_byte_packets; |
| 726 | u64 rx_1024_to_1518_byte_packets; |
| 727 | u64 rx_1519_to_1522_byte_packets; |
| 728 | u64 rx_1519_to_2047_byte_packets; |
| 729 | u64 rx_2048_to_4095_byte_packets; |
| 730 | u64 rx_4096_to_9216_byte_packets; |
| 731 | u64 rx_9217_to_16383_byte_packets; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 732 | u64 rx_crc_errors; |
| 733 | u64 rx_mac_crtl_frames; |
| 734 | u64 rx_pause_frames; |
| 735 | u64 rx_pfc_frames; |
| 736 | u64 rx_align_errors; |
| 737 | u64 rx_carrier_errors; |
| 738 | u64 rx_oversize_packets; |
| 739 | u64 rx_jabbers; |
| 740 | u64 rx_undersize_packets; |
| 741 | u64 rx_fragments; |
| 742 | u64 tx_64_byte_packets; |
| 743 | u64 tx_65_to_127_byte_packets; |
| 744 | u64 tx_128_to_255_byte_packets; |
| 745 | u64 tx_256_to_511_byte_packets; |
| 746 | u64 tx_512_to_1023_byte_packets; |
| 747 | u64 tx_1024_to_1518_byte_packets; |
| 748 | u64 tx_1519_to_2047_byte_packets; |
| 749 | u64 tx_2048_to_4095_byte_packets; |
| 750 | u64 tx_4096_to_9216_byte_packets; |
| 751 | u64 tx_9217_to_16383_byte_packets; |
| 752 | u64 tx_pause_frames; |
| 753 | u64 tx_pfc_frames; |
| 754 | u64 tx_lpi_entry_count; |
| 755 | u64 tx_total_collisions; |
| 756 | u64 brb_truncates; |
| 757 | u64 brb_discards; |
| 758 | u64 rx_mac_bytes; |
| 759 | u64 rx_mac_uc_packets; |
| 760 | u64 rx_mac_mc_packets; |
| 761 | u64 rx_mac_bc_packets; |
| 762 | u64 rx_mac_frames_ok; |
| 763 | u64 tx_mac_bytes; |
| 764 | u64 tx_mac_uc_packets; |
| 765 | u64 tx_mac_mc_packets; |
| 766 | u64 tx_mac_bc_packets; |
| 767 | u64 tx_mac_ctrl_frames; |
| 768 | }; |
| 769 | |
| 770 | #define QED_SB_IDX 0x0002 |
| 771 | |
| 772 | #define RX_PI 0 |
| 773 | #define TX_PI(tc) (RX_PI + 1 + tc) |
| 774 | |
Yuval Mintz | 4ac801b | 2016-02-28 12:26:52 +0200 | [diff] [blame] | 775 | struct qed_sb_cnt_info { |
| 776 | int sb_cnt; |
| 777 | int sb_iov_cnt; |
| 778 | int sb_free_blk; |
| 779 | }; |
| 780 | |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 781 | static inline u16 qed_sb_update_sb_idx(struct qed_sb_info *sb_info) |
| 782 | { |
| 783 | u32 prod = 0; |
| 784 | u16 rc = 0; |
| 785 | |
| 786 | prod = le32_to_cpu(sb_info->sb_virt->prod_index) & |
| 787 | STATUS_BLOCK_PROD_INDEX_MASK; |
| 788 | if (sb_info->sb_ack != prod) { |
| 789 | sb_info->sb_ack = prod; |
| 790 | rc |= QED_SB_IDX; |
| 791 | } |
| 792 | |
| 793 | /* Let SB update */ |
| 794 | mmiowb(); |
| 795 | return rc; |
| 796 | } |
| 797 | |
| 798 | /** |
| 799 | * |
| 800 | * @brief This function creates an update command for interrupts that is |
| 801 | * written to the IGU. |
| 802 | * |
| 803 | * @param sb_info - This is the structure allocated and |
| 804 | * initialized per status block. Assumption is |
| 805 | * that it was initialized using qed_sb_init |
| 806 | * @param int_cmd - Enable/Disable/Nop |
| 807 | * @param upd_flg - whether igu consumer should be |
| 808 | * updated. |
| 809 | * |
| 810 | * @return inline void |
| 811 | */ |
| 812 | static inline void qed_sb_ack(struct qed_sb_info *sb_info, |
| 813 | enum igu_int_cmd int_cmd, |
| 814 | u8 upd_flg) |
| 815 | { |
| 816 | struct igu_prod_cons_update igu_ack = { 0 }; |
| 817 | |
| 818 | igu_ack.sb_id_and_flags = |
| 819 | ((sb_info->sb_ack << IGU_PROD_CONS_UPDATE_SB_INDEX_SHIFT) | |
| 820 | (upd_flg << IGU_PROD_CONS_UPDATE_UPDATE_FLAG_SHIFT) | |
| 821 | (int_cmd << IGU_PROD_CONS_UPDATE_ENABLE_INT_SHIFT) | |
| 822 | (IGU_SEG_ACCESS_REG << |
| 823 | IGU_PROD_CONS_UPDATE_SEGMENT_ACCESS_SHIFT)); |
| 824 | |
| 825 | DIRECT_REG_WR(sb_info->igu_addr, igu_ack.sb_id_and_flags); |
| 826 | |
| 827 | /* Both segments (interrupts & acks) are written to same place address; |
| 828 | * Need to guarantee all commands will be received (in-order) by HW. |
| 829 | */ |
| 830 | mmiowb(); |
| 831 | barrier(); |
| 832 | } |
| 833 | |
| 834 | static inline void __internal_ram_wr(void *p_hwfn, |
| 835 | void __iomem *addr, |
| 836 | int size, |
| 837 | u32 *data) |
| 838 | |
| 839 | { |
| 840 | unsigned int i; |
| 841 | |
| 842 | for (i = 0; i < size / sizeof(*data); i++) |
| 843 | DIRECT_REG_WR(&((u32 __iomem *)addr)[i], data[i]); |
| 844 | } |
| 845 | |
| 846 | static inline void internal_ram_wr(void __iomem *addr, |
| 847 | int size, |
| 848 | u32 *data) |
| 849 | { |
| 850 | __internal_ram_wr(NULL, addr, size, data); |
| 851 | } |
| 852 | |
Sudarsana Reddy Kalluru | 8c5ebd0 | 2016-04-10 12:43:00 +0300 | [diff] [blame] | 853 | enum qed_rss_caps { |
| 854 | QED_RSS_IPV4 = 0x1, |
| 855 | QED_RSS_IPV6 = 0x2, |
| 856 | QED_RSS_IPV4_TCP = 0x4, |
| 857 | QED_RSS_IPV6_TCP = 0x8, |
| 858 | QED_RSS_IPV4_UDP = 0x10, |
| 859 | QED_RSS_IPV6_UDP = 0x20, |
| 860 | }; |
| 861 | |
| 862 | #define QED_RSS_IND_TABLE_SIZE 128 |
| 863 | #define QED_RSS_KEY_SIZE 10 /* size in 32b chunks */ |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 864 | #endif |