Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1 | /* QLogic qed NIC Driver |
Mintz, Yuval | e8f1cb5 | 2017-01-01 13:57:00 +0200 | [diff] [blame] | 2 | * Copyright (c) 2015-2017 QLogic Corporation |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 3 | * |
Mintz, Yuval | e8f1cb5 | 2017-01-01 13:57:00 +0200 | [diff] [blame] | 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. |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 31 | */ |
| 32 | |
| 33 | #include <linux/types.h> |
| 34 | #include <asm/byteorder.h> |
| 35 | #include <linux/io.h> |
| 36 | #include <linux/bitops.h> |
| 37 | #include <linux/delay.h> |
| 38 | #include <linux/dma-mapping.h> |
| 39 | #include <linux/errno.h> |
| 40 | #include <linux/interrupt.h> |
| 41 | #include <linux/kernel.h> |
| 42 | #include <linux/pci.h> |
| 43 | #include <linux/slab.h> |
| 44 | #include <linux/string.h> |
| 45 | #include "qed.h" |
| 46 | #include "qed_hsi.h" |
| 47 | #include "qed_hw.h" |
| 48 | #include "qed_init_ops.h" |
| 49 | #include "qed_int.h" |
| 50 | #include "qed_mcp.h" |
| 51 | #include "qed_reg_addr.h" |
| 52 | #include "qed_sp.h" |
Yuval Mintz | 1408cc1f | 2016-05-11 16:36:14 +0300 | [diff] [blame] | 53 | #include "qed_sriov.h" |
| 54 | #include "qed_vf.h" |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 55 | |
| 56 | struct qed_pi_info { |
| 57 | qed_int_comp_cb_t comp_cb; |
| 58 | void *cookie; |
| 59 | }; |
| 60 | |
| 61 | struct qed_sb_sp_info { |
| 62 | struct qed_sb_info sb_info; |
| 63 | |
| 64 | /* per protocol index data */ |
| 65 | struct qed_pi_info pi_info_arr[PIS_PER_SB]; |
| 66 | }; |
| 67 | |
Yuval Mintz | ff38577 | 2016-02-28 12:26:54 +0200 | [diff] [blame] | 68 | enum qed_attention_type { |
| 69 | QED_ATTN_TYPE_ATTN, |
| 70 | QED_ATTN_TYPE_PARITY, |
| 71 | }; |
| 72 | |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 73 | #define SB_ATTN_ALIGNED_SIZE(p_hwfn) \ |
| 74 | ALIGNED_TYPE_SIZE(struct atten_status_block, p_hwfn) |
| 75 | |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 76 | struct aeu_invert_reg_bit { |
| 77 | char bit_name[30]; |
| 78 | |
| 79 | #define ATTENTION_PARITY (1 << 0) |
| 80 | |
| 81 | #define ATTENTION_LENGTH_MASK (0x00000ff0) |
| 82 | #define ATTENTION_LENGTH_SHIFT (4) |
| 83 | #define ATTENTION_LENGTH(flags) (((flags) & ATTENTION_LENGTH_MASK) >> \ |
| 84 | ATTENTION_LENGTH_SHIFT) |
| 85 | #define ATTENTION_SINGLE (1 << ATTENTION_LENGTH_SHIFT) |
| 86 | #define ATTENTION_PAR (ATTENTION_SINGLE | ATTENTION_PARITY) |
| 87 | #define ATTENTION_PAR_INT ((2 << ATTENTION_LENGTH_SHIFT) | \ |
| 88 | ATTENTION_PARITY) |
| 89 | |
| 90 | /* Multiple bits start with this offset */ |
| 91 | #define ATTENTION_OFFSET_MASK (0x000ff000) |
| 92 | #define ATTENTION_OFFSET_SHIFT (12) |
| 93 | unsigned int flags; |
Yuval Mintz | ff38577 | 2016-02-28 12:26:54 +0200 | [diff] [blame] | 94 | |
Yuval Mintz | b4149dc7 | 2016-02-28 12:26:55 +0200 | [diff] [blame] | 95 | /* Callback to call if attention will be triggered */ |
| 96 | int (*cb)(struct qed_hwfn *p_hwfn); |
| 97 | |
Yuval Mintz | ff38577 | 2016-02-28 12:26:54 +0200 | [diff] [blame] | 98 | enum block_id block_index; |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 99 | }; |
| 100 | |
| 101 | struct aeu_invert_reg { |
| 102 | struct aeu_invert_reg_bit bits[32]; |
| 103 | }; |
| 104 | |
| 105 | #define MAX_ATTN_GRPS (8) |
| 106 | #define NUM_ATTN_REGS (9) |
| 107 | |
Yuval Mintz | b4149dc7 | 2016-02-28 12:26:55 +0200 | [diff] [blame] | 108 | /* Specific HW attention callbacks */ |
| 109 | static int qed_mcp_attn_cb(struct qed_hwfn *p_hwfn) |
| 110 | { |
| 111 | u32 tmp = qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, MCP_REG_CPU_STATE); |
| 112 | |
| 113 | /* This might occur on certain instances; Log it once then mask it */ |
| 114 | DP_INFO(p_hwfn->cdev, "MCP_REG_CPU_STATE: %08x - Masking...\n", |
| 115 | tmp); |
| 116 | qed_wr(p_hwfn, p_hwfn->p_dpc_ptt, MCP_REG_CPU_EVENT_MASK, |
| 117 | 0xffffffff); |
| 118 | |
| 119 | return 0; |
| 120 | } |
| 121 | |
| 122 | #define QED_PSWHST_ATTENTION_INCORRECT_ACCESS (0x1) |
| 123 | #define ATTENTION_INCORRECT_ACCESS_WR_MASK (0x1) |
| 124 | #define ATTENTION_INCORRECT_ACCESS_WR_SHIFT (0) |
| 125 | #define ATTENTION_INCORRECT_ACCESS_CLIENT_MASK (0xf) |
| 126 | #define ATTENTION_INCORRECT_ACCESS_CLIENT_SHIFT (1) |
| 127 | #define ATTENTION_INCORRECT_ACCESS_VF_VALID_MASK (0x1) |
| 128 | #define ATTENTION_INCORRECT_ACCESS_VF_VALID_SHIFT (5) |
| 129 | #define ATTENTION_INCORRECT_ACCESS_VF_ID_MASK (0xff) |
| 130 | #define ATTENTION_INCORRECT_ACCESS_VF_ID_SHIFT (6) |
| 131 | #define ATTENTION_INCORRECT_ACCESS_PF_ID_MASK (0xf) |
| 132 | #define ATTENTION_INCORRECT_ACCESS_PF_ID_SHIFT (14) |
| 133 | #define ATTENTION_INCORRECT_ACCESS_BYTE_EN_MASK (0xff) |
| 134 | #define ATTENTION_INCORRECT_ACCESS_BYTE_EN_SHIFT (18) |
| 135 | static int qed_pswhst_attn_cb(struct qed_hwfn *p_hwfn) |
| 136 | { |
| 137 | u32 tmp = qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, |
| 138 | PSWHST_REG_INCORRECT_ACCESS_VALID); |
| 139 | |
| 140 | if (tmp & QED_PSWHST_ATTENTION_INCORRECT_ACCESS) { |
| 141 | u32 addr, data, length; |
| 142 | |
| 143 | addr = qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, |
| 144 | PSWHST_REG_INCORRECT_ACCESS_ADDRESS); |
| 145 | data = qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, |
| 146 | PSWHST_REG_INCORRECT_ACCESS_DATA); |
| 147 | length = qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, |
| 148 | PSWHST_REG_INCORRECT_ACCESS_LENGTH); |
| 149 | |
| 150 | DP_INFO(p_hwfn->cdev, |
| 151 | "Incorrect access to %08x of length %08x - PF [%02x] VF [%04x] [valid %02x] client [%02x] write [%02x] Byte-Enable [%04x] [%08x]\n", |
| 152 | addr, length, |
| 153 | (u8) GET_FIELD(data, ATTENTION_INCORRECT_ACCESS_PF_ID), |
| 154 | (u8) GET_FIELD(data, ATTENTION_INCORRECT_ACCESS_VF_ID), |
| 155 | (u8) GET_FIELD(data, |
| 156 | ATTENTION_INCORRECT_ACCESS_VF_VALID), |
| 157 | (u8) GET_FIELD(data, |
| 158 | ATTENTION_INCORRECT_ACCESS_CLIENT), |
| 159 | (u8) GET_FIELD(data, ATTENTION_INCORRECT_ACCESS_WR), |
| 160 | (u8) GET_FIELD(data, |
| 161 | ATTENTION_INCORRECT_ACCESS_BYTE_EN), |
| 162 | data); |
| 163 | } |
| 164 | |
| 165 | return 0; |
| 166 | } |
| 167 | |
| 168 | #define QED_GRC_ATTENTION_VALID_BIT (1 << 0) |
| 169 | #define QED_GRC_ATTENTION_ADDRESS_MASK (0x7fffff) |
| 170 | #define QED_GRC_ATTENTION_ADDRESS_SHIFT (0) |
| 171 | #define QED_GRC_ATTENTION_RDWR_BIT (1 << 23) |
| 172 | #define QED_GRC_ATTENTION_MASTER_MASK (0xf) |
| 173 | #define QED_GRC_ATTENTION_MASTER_SHIFT (24) |
| 174 | #define QED_GRC_ATTENTION_PF_MASK (0xf) |
| 175 | #define QED_GRC_ATTENTION_PF_SHIFT (0) |
| 176 | #define QED_GRC_ATTENTION_VF_MASK (0xff) |
| 177 | #define QED_GRC_ATTENTION_VF_SHIFT (4) |
| 178 | #define QED_GRC_ATTENTION_PRIV_MASK (0x3) |
| 179 | #define QED_GRC_ATTENTION_PRIV_SHIFT (14) |
| 180 | #define QED_GRC_ATTENTION_PRIV_VF (0) |
| 181 | static const char *attn_master_to_str(u8 master) |
| 182 | { |
| 183 | switch (master) { |
| 184 | case 1: return "PXP"; |
| 185 | case 2: return "MCP"; |
| 186 | case 3: return "MSDM"; |
| 187 | case 4: return "PSDM"; |
| 188 | case 5: return "YSDM"; |
| 189 | case 6: return "USDM"; |
| 190 | case 7: return "TSDM"; |
| 191 | case 8: return "XSDM"; |
| 192 | case 9: return "DBU"; |
| 193 | case 10: return "DMAE"; |
| 194 | default: |
Masanari Iida | 9165dab | 2016-09-17 23:44:17 +0900 | [diff] [blame] | 195 | return "Unknown"; |
Yuval Mintz | b4149dc7 | 2016-02-28 12:26:55 +0200 | [diff] [blame] | 196 | } |
| 197 | } |
| 198 | |
| 199 | static int qed_grc_attn_cb(struct qed_hwfn *p_hwfn) |
| 200 | { |
| 201 | u32 tmp, tmp2; |
| 202 | |
| 203 | /* We've already cleared the timeout interrupt register, so we learn |
| 204 | * of interrupts via the validity register |
| 205 | */ |
| 206 | tmp = qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, |
| 207 | GRC_REG_TIMEOUT_ATTN_ACCESS_VALID); |
| 208 | if (!(tmp & QED_GRC_ATTENTION_VALID_BIT)) |
| 209 | goto out; |
| 210 | |
| 211 | /* Read the GRC timeout information */ |
| 212 | tmp = qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, |
| 213 | GRC_REG_TIMEOUT_ATTN_ACCESS_DATA_0); |
| 214 | tmp2 = qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, |
| 215 | GRC_REG_TIMEOUT_ATTN_ACCESS_DATA_1); |
| 216 | |
| 217 | DP_INFO(p_hwfn->cdev, |
| 218 | "GRC timeout [%08x:%08x] - %s Address [%08x] [Master %s] [PF: %02x %s %02x]\n", |
| 219 | tmp2, tmp, |
| 220 | (tmp & QED_GRC_ATTENTION_RDWR_BIT) ? "Write to" : "Read from", |
| 221 | GET_FIELD(tmp, QED_GRC_ATTENTION_ADDRESS) << 2, |
| 222 | attn_master_to_str(GET_FIELD(tmp, QED_GRC_ATTENTION_MASTER)), |
| 223 | GET_FIELD(tmp2, QED_GRC_ATTENTION_PF), |
| 224 | (GET_FIELD(tmp2, QED_GRC_ATTENTION_PRIV) == |
| 225 | QED_GRC_ATTENTION_PRIV_VF) ? "VF" : "(Ireelevant)", |
| 226 | GET_FIELD(tmp2, QED_GRC_ATTENTION_VF)); |
| 227 | |
| 228 | out: |
| 229 | /* Regardles of anything else, clean the validity bit */ |
| 230 | qed_wr(p_hwfn, p_hwfn->p_dpc_ptt, |
| 231 | GRC_REG_TIMEOUT_ATTN_ACCESS_VALID, 0); |
| 232 | return 0; |
| 233 | } |
| 234 | |
| 235 | #define PGLUE_ATTENTION_VALID (1 << 29) |
| 236 | #define PGLUE_ATTENTION_RD_VALID (1 << 26) |
| 237 | #define PGLUE_ATTENTION_DETAILS_PFID_MASK (0xf) |
| 238 | #define PGLUE_ATTENTION_DETAILS_PFID_SHIFT (20) |
| 239 | #define PGLUE_ATTENTION_DETAILS_VF_VALID_MASK (0x1) |
| 240 | #define PGLUE_ATTENTION_DETAILS_VF_VALID_SHIFT (19) |
| 241 | #define PGLUE_ATTENTION_DETAILS_VFID_MASK (0xff) |
| 242 | #define PGLUE_ATTENTION_DETAILS_VFID_SHIFT (24) |
| 243 | #define PGLUE_ATTENTION_DETAILS2_WAS_ERR_MASK (0x1) |
| 244 | #define PGLUE_ATTENTION_DETAILS2_WAS_ERR_SHIFT (21) |
| 245 | #define PGLUE_ATTENTION_DETAILS2_BME_MASK (0x1) |
| 246 | #define PGLUE_ATTENTION_DETAILS2_BME_SHIFT (22) |
| 247 | #define PGLUE_ATTENTION_DETAILS2_FID_EN_MASK (0x1) |
| 248 | #define PGLUE_ATTENTION_DETAILS2_FID_EN_SHIFT (23) |
| 249 | #define PGLUE_ATTENTION_ICPL_VALID (1 << 23) |
| 250 | #define PGLUE_ATTENTION_ZLR_VALID (1 << 25) |
| 251 | #define PGLUE_ATTENTION_ILT_VALID (1 << 23) |
| 252 | static int qed_pglub_rbc_attn_cb(struct qed_hwfn *p_hwfn) |
| 253 | { |
| 254 | u32 tmp; |
| 255 | |
| 256 | tmp = qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, |
| 257 | PGLUE_B_REG_TX_ERR_WR_DETAILS2); |
| 258 | if (tmp & PGLUE_ATTENTION_VALID) { |
| 259 | u32 addr_lo, addr_hi, details; |
| 260 | |
| 261 | addr_lo = qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, |
| 262 | PGLUE_B_REG_TX_ERR_WR_ADD_31_0); |
| 263 | addr_hi = qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, |
| 264 | PGLUE_B_REG_TX_ERR_WR_ADD_63_32); |
| 265 | details = qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, |
| 266 | PGLUE_B_REG_TX_ERR_WR_DETAILS); |
| 267 | |
| 268 | DP_INFO(p_hwfn, |
| 269 | "Illegal write by chip to [%08x:%08x] blocked.\n" |
| 270 | "Details: %08x [PFID %02x, VFID %02x, VF_VALID %02x]\n" |
| 271 | "Details2 %08x [Was_error %02x BME deassert %02x FID_enable deassert %02x]\n", |
| 272 | addr_hi, addr_lo, details, |
| 273 | (u8)GET_FIELD(details, PGLUE_ATTENTION_DETAILS_PFID), |
| 274 | (u8)GET_FIELD(details, PGLUE_ATTENTION_DETAILS_VFID), |
| 275 | GET_FIELD(details, |
| 276 | PGLUE_ATTENTION_DETAILS_VF_VALID) ? 1 : 0, |
| 277 | tmp, |
| 278 | GET_FIELD(tmp, |
| 279 | PGLUE_ATTENTION_DETAILS2_WAS_ERR) ? 1 : 0, |
| 280 | GET_FIELD(tmp, |
| 281 | PGLUE_ATTENTION_DETAILS2_BME) ? 1 : 0, |
| 282 | GET_FIELD(tmp, |
| 283 | PGLUE_ATTENTION_DETAILS2_FID_EN) ? 1 : 0); |
| 284 | } |
| 285 | |
| 286 | tmp = qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, |
| 287 | PGLUE_B_REG_TX_ERR_RD_DETAILS2); |
| 288 | if (tmp & PGLUE_ATTENTION_RD_VALID) { |
| 289 | u32 addr_lo, addr_hi, details; |
| 290 | |
| 291 | addr_lo = qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, |
| 292 | PGLUE_B_REG_TX_ERR_RD_ADD_31_0); |
| 293 | addr_hi = qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, |
| 294 | PGLUE_B_REG_TX_ERR_RD_ADD_63_32); |
| 295 | details = qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, |
| 296 | PGLUE_B_REG_TX_ERR_RD_DETAILS); |
| 297 | |
| 298 | DP_INFO(p_hwfn, |
| 299 | "Illegal read by chip from [%08x:%08x] blocked.\n" |
| 300 | " Details: %08x [PFID %02x, VFID %02x, VF_VALID %02x]\n" |
| 301 | " Details2 %08x [Was_error %02x BME deassert %02x FID_enable deassert %02x]\n", |
| 302 | addr_hi, addr_lo, details, |
| 303 | (u8)GET_FIELD(details, PGLUE_ATTENTION_DETAILS_PFID), |
| 304 | (u8)GET_FIELD(details, PGLUE_ATTENTION_DETAILS_VFID), |
| 305 | GET_FIELD(details, |
| 306 | PGLUE_ATTENTION_DETAILS_VF_VALID) ? 1 : 0, |
| 307 | tmp, |
| 308 | GET_FIELD(tmp, PGLUE_ATTENTION_DETAILS2_WAS_ERR) ? 1 |
| 309 | : 0, |
| 310 | GET_FIELD(tmp, PGLUE_ATTENTION_DETAILS2_BME) ? 1 : 0, |
| 311 | GET_FIELD(tmp, PGLUE_ATTENTION_DETAILS2_FID_EN) ? 1 |
| 312 | : 0); |
| 313 | } |
| 314 | |
| 315 | tmp = qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, |
| 316 | PGLUE_B_REG_TX_ERR_WR_DETAILS_ICPL); |
| 317 | if (tmp & PGLUE_ATTENTION_ICPL_VALID) |
| 318 | DP_INFO(p_hwfn, "ICPL eror - %08x\n", tmp); |
| 319 | |
| 320 | tmp = qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, |
| 321 | PGLUE_B_REG_MASTER_ZLR_ERR_DETAILS); |
| 322 | if (tmp & PGLUE_ATTENTION_ZLR_VALID) { |
| 323 | u32 addr_hi, addr_lo; |
| 324 | |
| 325 | addr_lo = qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, |
| 326 | PGLUE_B_REG_MASTER_ZLR_ERR_ADD_31_0); |
| 327 | addr_hi = qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, |
| 328 | PGLUE_B_REG_MASTER_ZLR_ERR_ADD_63_32); |
| 329 | |
| 330 | DP_INFO(p_hwfn, "ZLR eror - %08x [Address %08x:%08x]\n", |
| 331 | tmp, addr_hi, addr_lo); |
| 332 | } |
| 333 | |
| 334 | tmp = qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, |
| 335 | PGLUE_B_REG_VF_ILT_ERR_DETAILS2); |
| 336 | if (tmp & PGLUE_ATTENTION_ILT_VALID) { |
| 337 | u32 addr_hi, addr_lo, details; |
| 338 | |
| 339 | addr_lo = qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, |
| 340 | PGLUE_B_REG_VF_ILT_ERR_ADD_31_0); |
| 341 | addr_hi = qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, |
| 342 | PGLUE_B_REG_VF_ILT_ERR_ADD_63_32); |
| 343 | details = qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, |
| 344 | PGLUE_B_REG_VF_ILT_ERR_DETAILS); |
| 345 | |
| 346 | DP_INFO(p_hwfn, |
| 347 | "ILT error - Details %08x Details2 %08x [Address %08x:%08x]\n", |
| 348 | details, tmp, addr_hi, addr_lo); |
| 349 | } |
| 350 | |
| 351 | /* Clear the indications */ |
| 352 | qed_wr(p_hwfn, p_hwfn->p_dpc_ptt, |
| 353 | PGLUE_B_REG_LATCHED_ERRORS_CLR, (1 << 2)); |
| 354 | |
| 355 | return 0; |
| 356 | } |
| 357 | |
| 358 | #define QED_DORQ_ATTENTION_REASON_MASK (0xfffff) |
| 359 | #define QED_DORQ_ATTENTION_OPAQUE_MASK (0xffff) |
| 360 | #define QED_DORQ_ATTENTION_SIZE_MASK (0x7f) |
| 361 | #define QED_DORQ_ATTENTION_SIZE_SHIFT (16) |
| 362 | static int qed_dorq_attn_cb(struct qed_hwfn *p_hwfn) |
| 363 | { |
| 364 | u32 reason; |
| 365 | |
| 366 | reason = qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, DORQ_REG_DB_DROP_REASON) & |
| 367 | QED_DORQ_ATTENTION_REASON_MASK; |
| 368 | if (reason) { |
| 369 | u32 details = qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, |
| 370 | DORQ_REG_DB_DROP_DETAILS); |
| 371 | |
| 372 | DP_INFO(p_hwfn->cdev, |
Masanari Iida | 9165dab | 2016-09-17 23:44:17 +0900 | [diff] [blame] | 373 | "DORQ db_drop: address 0x%08x Opaque FID 0x%04x Size [bytes] 0x%08x Reason: 0x%08x\n", |
Yuval Mintz | b4149dc7 | 2016-02-28 12:26:55 +0200 | [diff] [blame] | 374 | qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, |
| 375 | DORQ_REG_DB_DROP_DETAILS_ADDRESS), |
| 376 | (u16)(details & QED_DORQ_ATTENTION_OPAQUE_MASK), |
| 377 | GET_FIELD(details, QED_DORQ_ATTENTION_SIZE) * 4, |
| 378 | reason); |
| 379 | } |
| 380 | |
| 381 | return -EINVAL; |
| 382 | } |
| 383 | |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 384 | /* Notice aeu_invert_reg must be defined in the same order of bits as HW; */ |
| 385 | static struct aeu_invert_reg aeu_descs[NUM_ATTN_REGS] = { |
| 386 | { |
| 387 | { /* After Invert 1 */ |
| 388 | {"GPIO0 function%d", |
Yuval Mintz | b4149dc7 | 2016-02-28 12:26:55 +0200 | [diff] [blame] | 389 | (32 << ATTENTION_LENGTH_SHIFT), NULL, MAX_BLOCK_ID}, |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 390 | } |
| 391 | }, |
| 392 | |
| 393 | { |
| 394 | { /* After Invert 2 */ |
Yuval Mintz | b4149dc7 | 2016-02-28 12:26:55 +0200 | [diff] [blame] | 395 | {"PGLUE config_space", ATTENTION_SINGLE, |
| 396 | NULL, MAX_BLOCK_ID}, |
| 397 | {"PGLUE misc_flr", ATTENTION_SINGLE, |
| 398 | NULL, MAX_BLOCK_ID}, |
| 399 | {"PGLUE B RBC", ATTENTION_PAR_INT, |
| 400 | qed_pglub_rbc_attn_cb, BLOCK_PGLUE_B}, |
| 401 | {"PGLUE misc_mctp", ATTENTION_SINGLE, |
| 402 | NULL, MAX_BLOCK_ID}, |
| 403 | {"Flash event", ATTENTION_SINGLE, NULL, MAX_BLOCK_ID}, |
| 404 | {"SMB event", ATTENTION_SINGLE, NULL, MAX_BLOCK_ID}, |
| 405 | {"Main Power", ATTENTION_SINGLE, NULL, MAX_BLOCK_ID}, |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 406 | {"SW timers #%d", (8 << ATTENTION_LENGTH_SHIFT) | |
Yuval Mintz | ff38577 | 2016-02-28 12:26:54 +0200 | [diff] [blame] | 407 | (1 << ATTENTION_OFFSET_SHIFT), |
Yuval Mintz | b4149dc7 | 2016-02-28 12:26:55 +0200 | [diff] [blame] | 408 | NULL, MAX_BLOCK_ID}, |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 409 | {"PCIE glue/PXP VPD %d", |
Yuval Mintz | b4149dc7 | 2016-02-28 12:26:55 +0200 | [diff] [blame] | 410 | (16 << ATTENTION_LENGTH_SHIFT), NULL, BLOCK_PGLCS}, |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 411 | } |
| 412 | }, |
| 413 | |
| 414 | { |
| 415 | { /* After Invert 3 */ |
| 416 | {"General Attention %d", |
Yuval Mintz | b4149dc7 | 2016-02-28 12:26:55 +0200 | [diff] [blame] | 417 | (32 << ATTENTION_LENGTH_SHIFT), NULL, MAX_BLOCK_ID}, |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 418 | } |
| 419 | }, |
| 420 | |
| 421 | { |
| 422 | { /* After Invert 4 */ |
Yuval Mintz | ff38577 | 2016-02-28 12:26:54 +0200 | [diff] [blame] | 423 | {"General Attention 32", ATTENTION_SINGLE, |
Yuval Mintz | b4149dc7 | 2016-02-28 12:26:55 +0200 | [diff] [blame] | 424 | NULL, MAX_BLOCK_ID}, |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 425 | {"General Attention %d", |
| 426 | (2 << ATTENTION_LENGTH_SHIFT) | |
Yuval Mintz | b4149dc7 | 2016-02-28 12:26:55 +0200 | [diff] [blame] | 427 | (33 << ATTENTION_OFFSET_SHIFT), NULL, MAX_BLOCK_ID}, |
Yuval Mintz | ff38577 | 2016-02-28 12:26:54 +0200 | [diff] [blame] | 428 | {"General Attention 35", ATTENTION_SINGLE, |
Yuval Mintz | b4149dc7 | 2016-02-28 12:26:55 +0200 | [diff] [blame] | 429 | NULL, MAX_BLOCK_ID}, |
Yuval Mintz | ff38577 | 2016-02-28 12:26:54 +0200 | [diff] [blame] | 430 | {"CNIG port %d", (4 << ATTENTION_LENGTH_SHIFT), |
Yuval Mintz | b4149dc7 | 2016-02-28 12:26:55 +0200 | [diff] [blame] | 431 | NULL, BLOCK_CNIG}, |
| 432 | {"MCP CPU", ATTENTION_SINGLE, |
| 433 | qed_mcp_attn_cb, MAX_BLOCK_ID}, |
| 434 | {"MCP Watchdog timer", ATTENTION_SINGLE, |
| 435 | NULL, MAX_BLOCK_ID}, |
| 436 | {"MCP M2P", ATTENTION_SINGLE, NULL, MAX_BLOCK_ID}, |
Yuval Mintz | ff38577 | 2016-02-28 12:26:54 +0200 | [diff] [blame] | 437 | {"AVS stop status ready", ATTENTION_SINGLE, |
Yuval Mintz | b4149dc7 | 2016-02-28 12:26:55 +0200 | [diff] [blame] | 438 | NULL, MAX_BLOCK_ID}, |
| 439 | {"MSTAT", ATTENTION_PAR_INT, NULL, MAX_BLOCK_ID}, |
| 440 | {"MSTAT per-path", ATTENTION_PAR_INT, |
| 441 | NULL, MAX_BLOCK_ID}, |
Yuval Mintz | ff38577 | 2016-02-28 12:26:54 +0200 | [diff] [blame] | 442 | {"Reserved %d", (6 << ATTENTION_LENGTH_SHIFT), |
Yuval Mintz | b4149dc7 | 2016-02-28 12:26:55 +0200 | [diff] [blame] | 443 | NULL, MAX_BLOCK_ID}, |
| 444 | {"NIG", ATTENTION_PAR_INT, NULL, BLOCK_NIG}, |
| 445 | {"BMB/OPTE/MCP", ATTENTION_PAR_INT, NULL, BLOCK_BMB}, |
| 446 | {"BTB", ATTENTION_PAR_INT, NULL, BLOCK_BTB}, |
| 447 | {"BRB", ATTENTION_PAR_INT, NULL, BLOCK_BRB}, |
| 448 | {"PRS", ATTENTION_PAR_INT, NULL, BLOCK_PRS}, |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 449 | } |
| 450 | }, |
| 451 | |
| 452 | { |
| 453 | { /* After Invert 5 */ |
Yuval Mintz | b4149dc7 | 2016-02-28 12:26:55 +0200 | [diff] [blame] | 454 | {"SRC", ATTENTION_PAR_INT, NULL, BLOCK_SRC}, |
| 455 | {"PB Client1", ATTENTION_PAR_INT, NULL, BLOCK_PBF_PB1}, |
| 456 | {"PB Client2", ATTENTION_PAR_INT, NULL, BLOCK_PBF_PB2}, |
| 457 | {"RPB", ATTENTION_PAR_INT, NULL, BLOCK_RPB}, |
| 458 | {"PBF", ATTENTION_PAR_INT, NULL, BLOCK_PBF}, |
| 459 | {"QM", ATTENTION_PAR_INT, NULL, BLOCK_QM}, |
| 460 | {"TM", ATTENTION_PAR_INT, NULL, BLOCK_TM}, |
| 461 | {"MCM", ATTENTION_PAR_INT, NULL, BLOCK_MCM}, |
| 462 | {"MSDM", ATTENTION_PAR_INT, NULL, BLOCK_MSDM}, |
| 463 | {"MSEM", ATTENTION_PAR_INT, NULL, BLOCK_MSEM}, |
| 464 | {"PCM", ATTENTION_PAR_INT, NULL, BLOCK_PCM}, |
| 465 | {"PSDM", ATTENTION_PAR_INT, NULL, BLOCK_PSDM}, |
| 466 | {"PSEM", ATTENTION_PAR_INT, NULL, BLOCK_PSEM}, |
| 467 | {"TCM", ATTENTION_PAR_INT, NULL, BLOCK_TCM}, |
| 468 | {"TSDM", ATTENTION_PAR_INT, NULL, BLOCK_TSDM}, |
| 469 | {"TSEM", ATTENTION_PAR_INT, NULL, BLOCK_TSEM}, |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 470 | } |
| 471 | }, |
| 472 | |
| 473 | { |
| 474 | { /* After Invert 6 */ |
Yuval Mintz | b4149dc7 | 2016-02-28 12:26:55 +0200 | [diff] [blame] | 475 | {"UCM", ATTENTION_PAR_INT, NULL, BLOCK_UCM}, |
| 476 | {"USDM", ATTENTION_PAR_INT, NULL, BLOCK_USDM}, |
| 477 | {"USEM", ATTENTION_PAR_INT, NULL, BLOCK_USEM}, |
| 478 | {"XCM", ATTENTION_PAR_INT, NULL, BLOCK_XCM}, |
| 479 | {"XSDM", ATTENTION_PAR_INT, NULL, BLOCK_XSDM}, |
| 480 | {"XSEM", ATTENTION_PAR_INT, NULL, BLOCK_XSEM}, |
| 481 | {"YCM", ATTENTION_PAR_INT, NULL, BLOCK_YCM}, |
| 482 | {"YSDM", ATTENTION_PAR_INT, NULL, BLOCK_YSDM}, |
| 483 | {"YSEM", ATTENTION_PAR_INT, NULL, BLOCK_YSEM}, |
| 484 | {"XYLD", ATTENTION_PAR_INT, NULL, BLOCK_XYLD}, |
| 485 | {"TMLD", ATTENTION_PAR_INT, NULL, BLOCK_TMLD}, |
| 486 | {"MYLD", ATTENTION_PAR_INT, NULL, BLOCK_MULD}, |
| 487 | {"YULD", ATTENTION_PAR_INT, NULL, BLOCK_YULD}, |
| 488 | {"DORQ", ATTENTION_PAR_INT, |
| 489 | qed_dorq_attn_cb, BLOCK_DORQ}, |
| 490 | {"DBG", ATTENTION_PAR_INT, NULL, BLOCK_DBG}, |
| 491 | {"IPC", ATTENTION_PAR_INT, NULL, BLOCK_IPC}, |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 492 | } |
| 493 | }, |
| 494 | |
| 495 | { |
| 496 | { /* After Invert 7 */ |
Yuval Mintz | b4149dc7 | 2016-02-28 12:26:55 +0200 | [diff] [blame] | 497 | {"CCFC", ATTENTION_PAR_INT, NULL, BLOCK_CCFC}, |
| 498 | {"CDU", ATTENTION_PAR_INT, NULL, BLOCK_CDU}, |
| 499 | {"DMAE", ATTENTION_PAR_INT, NULL, BLOCK_DMAE}, |
| 500 | {"IGU", ATTENTION_PAR_INT, NULL, BLOCK_IGU}, |
| 501 | {"ATC", ATTENTION_PAR_INT, NULL, MAX_BLOCK_ID}, |
| 502 | {"CAU", ATTENTION_PAR_INT, NULL, BLOCK_CAU}, |
| 503 | {"PTU", ATTENTION_PAR_INT, NULL, BLOCK_PTU}, |
| 504 | {"PRM", ATTENTION_PAR_INT, NULL, BLOCK_PRM}, |
| 505 | {"TCFC", ATTENTION_PAR_INT, NULL, BLOCK_TCFC}, |
| 506 | {"RDIF", ATTENTION_PAR_INT, NULL, BLOCK_RDIF}, |
| 507 | {"TDIF", ATTENTION_PAR_INT, NULL, BLOCK_TDIF}, |
| 508 | {"RSS", ATTENTION_PAR_INT, NULL, BLOCK_RSS}, |
| 509 | {"MISC", ATTENTION_PAR_INT, NULL, BLOCK_MISC}, |
| 510 | {"MISCS", ATTENTION_PAR_INT, NULL, BLOCK_MISCS}, |
| 511 | {"PCIE", ATTENTION_PAR, NULL, BLOCK_PCIE}, |
| 512 | {"Vaux PCI core", ATTENTION_SINGLE, NULL, BLOCK_PGLCS}, |
| 513 | {"PSWRQ", ATTENTION_PAR_INT, NULL, BLOCK_PSWRQ}, |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 514 | } |
| 515 | }, |
| 516 | |
| 517 | { |
| 518 | { /* After Invert 8 */ |
Yuval Mintz | b4149dc7 | 2016-02-28 12:26:55 +0200 | [diff] [blame] | 519 | {"PSWRQ (pci_clk)", ATTENTION_PAR_INT, |
| 520 | NULL, BLOCK_PSWRQ2}, |
| 521 | {"PSWWR", ATTENTION_PAR_INT, NULL, BLOCK_PSWWR}, |
| 522 | {"PSWWR (pci_clk)", ATTENTION_PAR_INT, |
| 523 | NULL, BLOCK_PSWWR2}, |
| 524 | {"PSWRD", ATTENTION_PAR_INT, NULL, BLOCK_PSWRD}, |
| 525 | {"PSWRD (pci_clk)", ATTENTION_PAR_INT, |
| 526 | NULL, BLOCK_PSWRD2}, |
| 527 | {"PSWHST", ATTENTION_PAR_INT, |
| 528 | qed_pswhst_attn_cb, BLOCK_PSWHST}, |
| 529 | {"PSWHST (pci_clk)", ATTENTION_PAR_INT, |
| 530 | NULL, BLOCK_PSWHST2}, |
| 531 | {"GRC", ATTENTION_PAR_INT, |
| 532 | qed_grc_attn_cb, BLOCK_GRC}, |
| 533 | {"CPMU", ATTENTION_PAR_INT, NULL, BLOCK_CPMU}, |
| 534 | {"NCSI", ATTENTION_PAR_INT, NULL, BLOCK_NCSI}, |
| 535 | {"MSEM PRAM", ATTENTION_PAR, NULL, MAX_BLOCK_ID}, |
| 536 | {"PSEM PRAM", ATTENTION_PAR, NULL, MAX_BLOCK_ID}, |
| 537 | {"TSEM PRAM", ATTENTION_PAR, NULL, MAX_BLOCK_ID}, |
| 538 | {"USEM PRAM", ATTENTION_PAR, NULL, MAX_BLOCK_ID}, |
| 539 | {"XSEM PRAM", ATTENTION_PAR, NULL, MAX_BLOCK_ID}, |
| 540 | {"YSEM PRAM", ATTENTION_PAR, NULL, MAX_BLOCK_ID}, |
| 541 | {"pxp_misc_mps", ATTENTION_PAR, NULL, BLOCK_PGLCS}, |
Yuval Mintz | ff38577 | 2016-02-28 12:26:54 +0200 | [diff] [blame] | 542 | {"PCIE glue/PXP Exp. ROM", ATTENTION_SINGLE, |
Yuval Mintz | b4149dc7 | 2016-02-28 12:26:55 +0200 | [diff] [blame] | 543 | NULL, BLOCK_PGLCS}, |
| 544 | {"PERST_B assertion", ATTENTION_SINGLE, |
| 545 | NULL, MAX_BLOCK_ID}, |
Yuval Mintz | ff38577 | 2016-02-28 12:26:54 +0200 | [diff] [blame] | 546 | {"PERST_B deassertion", ATTENTION_SINGLE, |
Yuval Mintz | b4149dc7 | 2016-02-28 12:26:55 +0200 | [diff] [blame] | 547 | NULL, MAX_BLOCK_ID}, |
Yuval Mintz | ff38577 | 2016-02-28 12:26:54 +0200 | [diff] [blame] | 548 | {"Reserved %d", (2 << ATTENTION_LENGTH_SHIFT), |
Yuval Mintz | b4149dc7 | 2016-02-28 12:26:55 +0200 | [diff] [blame] | 549 | NULL, MAX_BLOCK_ID}, |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 550 | } |
| 551 | }, |
| 552 | |
| 553 | { |
| 554 | { /* After Invert 9 */ |
Yuval Mintz | b4149dc7 | 2016-02-28 12:26:55 +0200 | [diff] [blame] | 555 | {"MCP Latched memory", ATTENTION_PAR, |
| 556 | NULL, MAX_BLOCK_ID}, |
Yuval Mintz | ff38577 | 2016-02-28 12:26:54 +0200 | [diff] [blame] | 557 | {"MCP Latched scratchpad cache", ATTENTION_SINGLE, |
Yuval Mintz | b4149dc7 | 2016-02-28 12:26:55 +0200 | [diff] [blame] | 558 | NULL, MAX_BLOCK_ID}, |
| 559 | {"MCP Latched ump_tx", ATTENTION_PAR, |
| 560 | NULL, MAX_BLOCK_ID}, |
Yuval Mintz | ff38577 | 2016-02-28 12:26:54 +0200 | [diff] [blame] | 561 | {"MCP Latched scratchpad", ATTENTION_PAR, |
Yuval Mintz | b4149dc7 | 2016-02-28 12:26:55 +0200 | [diff] [blame] | 562 | NULL, MAX_BLOCK_ID}, |
Yuval Mintz | ff38577 | 2016-02-28 12:26:54 +0200 | [diff] [blame] | 563 | {"Reserved %d", (28 << ATTENTION_LENGTH_SHIFT), |
Yuval Mintz | b4149dc7 | 2016-02-28 12:26:55 +0200 | [diff] [blame] | 564 | NULL, MAX_BLOCK_ID}, |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 565 | } |
| 566 | }, |
| 567 | }; |
| 568 | |
| 569 | #define ATTN_STATE_BITS (0xfff) |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 570 | #define ATTN_BITS_MASKABLE (0x3ff) |
| 571 | struct qed_sb_attn_info { |
| 572 | /* Virtual & Physical address of the SB */ |
| 573 | struct atten_status_block *sb_attn; |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 574 | dma_addr_t sb_phys; |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 575 | |
| 576 | /* Last seen running index */ |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 577 | u16 index; |
| 578 | |
| 579 | /* A mask of the AEU bits resulting in a parity error */ |
| 580 | u32 parity_mask[NUM_ATTN_REGS]; |
| 581 | |
| 582 | /* A pointer to the attention description structure */ |
| 583 | struct aeu_invert_reg *p_aeu_desc; |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 584 | |
| 585 | /* Previously asserted attentions, which are still unasserted */ |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 586 | u16 known_attn; |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 587 | |
| 588 | /* Cleanup address for the link's general hw attention */ |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 589 | u32 mfw_attn_addr; |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 590 | }; |
| 591 | |
| 592 | static inline u16 qed_attn_update_idx(struct qed_hwfn *p_hwfn, |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 593 | struct qed_sb_attn_info *p_sb_desc) |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 594 | { |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 595 | u16 rc = 0, index; |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 596 | |
| 597 | /* Make certain HW write took affect */ |
| 598 | mmiowb(); |
| 599 | |
| 600 | index = le16_to_cpu(p_sb_desc->sb_attn->sb_index); |
| 601 | if (p_sb_desc->index != index) { |
| 602 | p_sb_desc->index = index; |
| 603 | rc = QED_SB_ATT_IDX; |
| 604 | } |
| 605 | |
| 606 | /* Make certain we got a consistent view with HW */ |
| 607 | mmiowb(); |
| 608 | |
| 609 | return rc; |
| 610 | } |
| 611 | |
| 612 | /** |
| 613 | * @brief qed_int_assertion - handles asserted attention bits |
| 614 | * |
| 615 | * @param p_hwfn |
| 616 | * @param asserted_bits newly asserted bits |
| 617 | * @return int |
| 618 | */ |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 619 | static int qed_int_assertion(struct qed_hwfn *p_hwfn, u16 asserted_bits) |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 620 | { |
| 621 | struct qed_sb_attn_info *sb_attn_sw = p_hwfn->p_sb_attn; |
| 622 | u32 igu_mask; |
| 623 | |
| 624 | /* Mask the source of the attention in the IGU */ |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 625 | igu_mask = qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, IGU_REG_ATTENTION_ENABLE); |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 626 | DP_VERBOSE(p_hwfn, NETIF_MSG_INTR, "IGU mask: 0x%08x --> 0x%08x\n", |
| 627 | igu_mask, igu_mask & ~(asserted_bits & ATTN_BITS_MASKABLE)); |
| 628 | igu_mask &= ~(asserted_bits & ATTN_BITS_MASKABLE); |
| 629 | qed_wr(p_hwfn, p_hwfn->p_dpc_ptt, IGU_REG_ATTENTION_ENABLE, igu_mask); |
| 630 | |
| 631 | DP_VERBOSE(p_hwfn, NETIF_MSG_INTR, |
| 632 | "inner known ATTN state: 0x%04x --> 0x%04x\n", |
| 633 | sb_attn_sw->known_attn, |
| 634 | sb_attn_sw->known_attn | asserted_bits); |
| 635 | sb_attn_sw->known_attn |= asserted_bits; |
| 636 | |
| 637 | /* Handle MCP events */ |
| 638 | if (asserted_bits & 0x100) { |
| 639 | qed_mcp_handle_events(p_hwfn, p_hwfn->p_dpc_ptt); |
| 640 | /* Clean the MCP attention */ |
| 641 | qed_wr(p_hwfn, p_hwfn->p_dpc_ptt, |
| 642 | sb_attn_sw->mfw_attn_addr, 0); |
| 643 | } |
| 644 | |
| 645 | DIRECT_REG_WR((u8 __iomem *)p_hwfn->regview + |
| 646 | GTT_BAR0_MAP_REG_IGU_CMD + |
| 647 | ((IGU_CMD_ATTN_BIT_SET_UPPER - |
| 648 | IGU_CMD_INT_ACK_BASE) << 3), |
| 649 | (u32)asserted_bits); |
| 650 | |
| 651 | DP_VERBOSE(p_hwfn, NETIF_MSG_INTR, "set cmd IGU: 0x%04x\n", |
| 652 | asserted_bits); |
| 653 | |
| 654 | return 0; |
| 655 | } |
| 656 | |
Mintz, Yuval | 0ebbd1c | 2017-05-29 09:53:10 +0300 | [diff] [blame^] | 657 | static void qed_int_attn_print(struct qed_hwfn *p_hwfn, |
| 658 | enum block_id id, |
| 659 | enum dbg_attn_type type, bool b_clear) |
Yuval Mintz | ff38577 | 2016-02-28 12:26:54 +0200 | [diff] [blame] | 660 | { |
Mintz, Yuval | 0ebbd1c | 2017-05-29 09:53:10 +0300 | [diff] [blame^] | 661 | struct dbg_attn_block_result attn_results; |
| 662 | enum dbg_status status; |
Yuval Mintz | ff38577 | 2016-02-28 12:26:54 +0200 | [diff] [blame] | 663 | |
Mintz, Yuval | 0ebbd1c | 2017-05-29 09:53:10 +0300 | [diff] [blame^] | 664 | memset(&attn_results, 0, sizeof(attn_results)); |
Yuval Mintz | ff38577 | 2016-02-28 12:26:54 +0200 | [diff] [blame] | 665 | |
Mintz, Yuval | 0ebbd1c | 2017-05-29 09:53:10 +0300 | [diff] [blame^] | 666 | status = qed_dbg_read_attn(p_hwfn, p_hwfn->p_dpc_ptt, id, type, |
| 667 | b_clear, &attn_results); |
| 668 | if (status != DBG_STATUS_OK) |
Yuval Mintz | ff38577 | 2016-02-28 12:26:54 +0200 | [diff] [blame] | 669 | DP_NOTICE(p_hwfn, |
Mintz, Yuval | 0ebbd1c | 2017-05-29 09:53:10 +0300 | [diff] [blame^] | 670 | "Failed to parse attention information [status: %s]\n", |
| 671 | qed_dbg_get_status_str(status)); |
| 672 | else |
| 673 | qed_dbg_parse_attn(p_hwfn, &attn_results); |
Yuval Mintz | ff38577 | 2016-02-28 12:26:54 +0200 | [diff] [blame] | 674 | } |
| 675 | |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 676 | /** |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 677 | * @brief qed_int_deassertion_aeu_bit - handles the effects of a single |
| 678 | * cause of the attention |
| 679 | * |
| 680 | * @param p_hwfn |
| 681 | * @param p_aeu - descriptor of an AEU bit which caused the attention |
| 682 | * @param aeu_en_reg - register offset of the AEU enable reg. which configured |
| 683 | * this bit to this group. |
| 684 | * @param bit_index - index of this bit in the aeu_en_reg |
| 685 | * |
| 686 | * @return int |
| 687 | */ |
| 688 | static int |
| 689 | qed_int_deassertion_aeu_bit(struct qed_hwfn *p_hwfn, |
| 690 | struct aeu_invert_reg_bit *p_aeu, |
| 691 | u32 aeu_en_reg, |
| 692 | u32 bitmask) |
| 693 | { |
Mintz, Yuval | 0ebbd1c | 2017-05-29 09:53:10 +0300 | [diff] [blame^] | 694 | bool b_fatal = false; |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 695 | int rc = -EINVAL; |
Yuval Mintz | b4149dc7 | 2016-02-28 12:26:55 +0200 | [diff] [blame] | 696 | u32 val; |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 697 | |
| 698 | DP_INFO(p_hwfn, "Deasserted attention `%s'[%08x]\n", |
| 699 | p_aeu->bit_name, bitmask); |
| 700 | |
Yuval Mintz | b4149dc7 | 2016-02-28 12:26:55 +0200 | [diff] [blame] | 701 | /* Call callback before clearing the interrupt status */ |
| 702 | if (p_aeu->cb) { |
| 703 | DP_INFO(p_hwfn, "`%s (attention)': Calling Callback function\n", |
| 704 | p_aeu->bit_name); |
| 705 | rc = p_aeu->cb(p_hwfn); |
| 706 | } |
| 707 | |
Mintz, Yuval | 0ebbd1c | 2017-05-29 09:53:10 +0300 | [diff] [blame^] | 708 | if (rc) |
| 709 | b_fatal = true; |
Yuval Mintz | ff38577 | 2016-02-28 12:26:54 +0200 | [diff] [blame] | 710 | |
Mintz, Yuval | 0ebbd1c | 2017-05-29 09:53:10 +0300 | [diff] [blame^] | 711 | /* Print HW block interrupt registers */ |
| 712 | if (p_aeu->block_index != MAX_BLOCK_ID) |
| 713 | qed_int_attn_print(p_hwfn, p_aeu->block_index, |
| 714 | ATTN_TYPE_INTERRUPT, !b_fatal); |
Yuval Mintz | ff38577 | 2016-02-28 12:26:54 +0200 | [diff] [blame] | 715 | |
Yuval Mintz | ff38577 | 2016-02-28 12:26:54 +0200 | [diff] [blame] | 716 | |
Yuval Mintz | b4149dc7 | 2016-02-28 12:26:55 +0200 | [diff] [blame] | 717 | /* If the attention is benign, no need to prevent it */ |
| 718 | if (!rc) |
| 719 | goto out; |
| 720 | |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 721 | /* Prevent this Attention from being asserted in the future */ |
| 722 | val = qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, aeu_en_reg); |
Yuval Mintz | b4149dc7 | 2016-02-28 12:26:55 +0200 | [diff] [blame] | 723 | qed_wr(p_hwfn, p_hwfn->p_dpc_ptt, aeu_en_reg, (val & ~bitmask)); |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 724 | DP_INFO(p_hwfn, "`%s' - Disabled future attentions\n", |
| 725 | p_aeu->bit_name); |
| 726 | |
Yuval Mintz | b4149dc7 | 2016-02-28 12:26:55 +0200 | [diff] [blame] | 727 | out: |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 728 | return rc; |
| 729 | } |
| 730 | |
Yuval Mintz | ff38577 | 2016-02-28 12:26:54 +0200 | [diff] [blame] | 731 | /** |
| 732 | * @brief qed_int_deassertion_parity - handle a single parity AEU source |
| 733 | * |
| 734 | * @param p_hwfn |
| 735 | * @param p_aeu - descriptor of an AEU bit which caused the parity |
| 736 | * @param bit_index |
| 737 | */ |
| 738 | static void qed_int_deassertion_parity(struct qed_hwfn *p_hwfn, |
| 739 | struct aeu_invert_reg_bit *p_aeu, |
| 740 | u8 bit_index) |
| 741 | { |
| 742 | u32 block_id = p_aeu->block_index; |
| 743 | |
| 744 | DP_INFO(p_hwfn->cdev, "%s[%d] parity attention is set\n", |
| 745 | p_aeu->bit_name, bit_index); |
| 746 | |
| 747 | if (block_id != MAX_BLOCK_ID) { |
Mintz, Yuval | 0ebbd1c | 2017-05-29 09:53:10 +0300 | [diff] [blame^] | 748 | qed_int_attn_print(p_hwfn, block_id, ATTN_TYPE_PARITY, false); |
Yuval Mintz | ff38577 | 2016-02-28 12:26:54 +0200 | [diff] [blame] | 749 | |
| 750 | /* In BB, there's a single parity bit for several blocks */ |
| 751 | if (block_id == BLOCK_BTB) { |
Mintz, Yuval | 0ebbd1c | 2017-05-29 09:53:10 +0300 | [diff] [blame^] | 752 | qed_int_attn_print(p_hwfn, BLOCK_OPTE, |
| 753 | ATTN_TYPE_PARITY, false); |
| 754 | qed_int_attn_print(p_hwfn, BLOCK_MCP, |
| 755 | ATTN_TYPE_PARITY, false); |
Yuval Mintz | ff38577 | 2016-02-28 12:26:54 +0200 | [diff] [blame] | 756 | } |
| 757 | } |
| 758 | } |
| 759 | |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 760 | /** |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 761 | * @brief - handles deassertion of previously asserted attentions. |
| 762 | * |
| 763 | * @param p_hwfn |
| 764 | * @param deasserted_bits - newly deasserted bits |
| 765 | * @return int |
| 766 | * |
| 767 | */ |
| 768 | static int qed_int_deassertion(struct qed_hwfn *p_hwfn, |
| 769 | u16 deasserted_bits) |
| 770 | { |
| 771 | struct qed_sb_attn_info *sb_attn_sw = p_hwfn->p_sb_attn; |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 772 | u32 aeu_inv_arr[NUM_ATTN_REGS], aeu_mask; |
| 773 | u8 i, j, k, bit_idx; |
| 774 | int rc = 0; |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 775 | |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 776 | /* Read the attention registers in the AEU */ |
| 777 | for (i = 0; i < NUM_ATTN_REGS; i++) { |
| 778 | aeu_inv_arr[i] = qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, |
| 779 | MISC_REG_AEU_AFTER_INVERT_1_IGU + |
| 780 | i * 0x4); |
| 781 | DP_VERBOSE(p_hwfn, NETIF_MSG_INTR, |
| 782 | "Deasserted bits [%d]: %08x\n", |
| 783 | i, aeu_inv_arr[i]); |
| 784 | } |
| 785 | |
| 786 | /* Find parity attentions first */ |
| 787 | for (i = 0; i < NUM_ATTN_REGS; i++) { |
| 788 | struct aeu_invert_reg *p_aeu = &sb_attn_sw->p_aeu_desc[i]; |
| 789 | u32 en = qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, |
| 790 | MISC_REG_AEU_ENABLE1_IGU_OUT_0 + |
| 791 | i * sizeof(u32)); |
| 792 | u32 parities; |
| 793 | |
| 794 | /* Skip register in which no parity bit is currently set */ |
| 795 | parities = sb_attn_sw->parity_mask[i] & aeu_inv_arr[i] & en; |
| 796 | if (!parities) |
| 797 | continue; |
| 798 | |
| 799 | for (j = 0, bit_idx = 0; bit_idx < 32; j++) { |
| 800 | struct aeu_invert_reg_bit *p_bit = &p_aeu->bits[j]; |
| 801 | |
| 802 | if ((p_bit->flags & ATTENTION_PARITY) && |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 803 | !!(parities & BIT(bit_idx))) |
Yuval Mintz | ff38577 | 2016-02-28 12:26:54 +0200 | [diff] [blame] | 804 | qed_int_deassertion_parity(p_hwfn, p_bit, |
| 805 | bit_idx); |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 806 | |
| 807 | bit_idx += ATTENTION_LENGTH(p_bit->flags); |
| 808 | } |
| 809 | } |
| 810 | |
| 811 | /* Find non-parity cause for attention and act */ |
| 812 | for (k = 0; k < MAX_ATTN_GRPS; k++) { |
| 813 | struct aeu_invert_reg_bit *p_aeu; |
| 814 | |
| 815 | /* Handle only groups whose attention is currently deasserted */ |
| 816 | if (!(deasserted_bits & (1 << k))) |
| 817 | continue; |
| 818 | |
| 819 | for (i = 0; i < NUM_ATTN_REGS; i++) { |
| 820 | u32 aeu_en = MISC_REG_AEU_ENABLE1_IGU_OUT_0 + |
| 821 | i * sizeof(u32) + |
| 822 | k * sizeof(u32) * NUM_ATTN_REGS; |
| 823 | u32 en, bits; |
| 824 | |
| 825 | en = qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, aeu_en); |
| 826 | bits = aeu_inv_arr[i] & en; |
| 827 | |
| 828 | /* Skip if no bit from this group is currently set */ |
| 829 | if (!bits) |
| 830 | continue; |
| 831 | |
| 832 | /* Find all set bits from current register which belong |
| 833 | * to current group, making them responsible for the |
| 834 | * previous assertion. |
| 835 | */ |
| 836 | for (j = 0, bit_idx = 0; bit_idx < 32; j++) { |
| 837 | u8 bit, bit_len; |
| 838 | u32 bitmask; |
| 839 | |
| 840 | p_aeu = &sb_attn_sw->p_aeu_desc[i].bits[j]; |
| 841 | |
| 842 | /* No need to handle parity-only bits */ |
| 843 | if (p_aeu->flags == ATTENTION_PAR) |
| 844 | continue; |
| 845 | |
| 846 | bit = bit_idx; |
| 847 | bit_len = ATTENTION_LENGTH(p_aeu->flags); |
| 848 | if (p_aeu->flags & ATTENTION_PAR_INT) { |
| 849 | /* Skip Parity */ |
| 850 | bit++; |
| 851 | bit_len--; |
| 852 | } |
| 853 | |
| 854 | bitmask = bits & (((1 << bit_len) - 1) << bit); |
| 855 | if (bitmask) { |
| 856 | /* Handle source of the attention */ |
| 857 | qed_int_deassertion_aeu_bit(p_hwfn, |
| 858 | p_aeu, |
| 859 | aeu_en, |
| 860 | bitmask); |
| 861 | } |
| 862 | |
| 863 | bit_idx += ATTENTION_LENGTH(p_aeu->flags); |
| 864 | } |
| 865 | } |
| 866 | } |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 867 | |
| 868 | /* Clear IGU indication for the deasserted bits */ |
| 869 | DIRECT_REG_WR((u8 __iomem *)p_hwfn->regview + |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 870 | GTT_BAR0_MAP_REG_IGU_CMD + |
| 871 | ((IGU_CMD_ATTN_BIT_CLR_UPPER - |
| 872 | IGU_CMD_INT_ACK_BASE) << 3), |
| 873 | ~((u32)deasserted_bits)); |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 874 | |
| 875 | /* Unmask deasserted attentions in IGU */ |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 876 | aeu_mask = qed_rd(p_hwfn, p_hwfn->p_dpc_ptt, IGU_REG_ATTENTION_ENABLE); |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 877 | aeu_mask |= (deasserted_bits & ATTN_BITS_MASKABLE); |
| 878 | qed_wr(p_hwfn, p_hwfn->p_dpc_ptt, IGU_REG_ATTENTION_ENABLE, aeu_mask); |
| 879 | |
| 880 | /* Clear deassertion from inner state */ |
| 881 | sb_attn_sw->known_attn &= ~deasserted_bits; |
| 882 | |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 883 | return rc; |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 884 | } |
| 885 | |
| 886 | static int qed_int_attentions(struct qed_hwfn *p_hwfn) |
| 887 | { |
| 888 | struct qed_sb_attn_info *p_sb_attn_sw = p_hwfn->p_sb_attn; |
| 889 | struct atten_status_block *p_sb_attn = p_sb_attn_sw->sb_attn; |
| 890 | u32 attn_bits = 0, attn_acks = 0; |
| 891 | u16 asserted_bits, deasserted_bits; |
| 892 | __le16 index; |
| 893 | int rc = 0; |
| 894 | |
| 895 | /* Read current attention bits/acks - safeguard against attentions |
| 896 | * by guaranting work on a synchronized timeframe |
| 897 | */ |
| 898 | do { |
| 899 | index = p_sb_attn->sb_index; |
| 900 | attn_bits = le32_to_cpu(p_sb_attn->atten_bits); |
| 901 | attn_acks = le32_to_cpu(p_sb_attn->atten_ack); |
| 902 | } while (index != p_sb_attn->sb_index); |
| 903 | p_sb_attn->sb_index = index; |
| 904 | |
| 905 | /* Attention / Deassertion are meaningful (and in correct state) |
| 906 | * only when they differ and consistent with known state - deassertion |
| 907 | * when previous attention & current ack, and assertion when current |
| 908 | * attention with no previous attention |
| 909 | */ |
| 910 | asserted_bits = (attn_bits & ~attn_acks & ATTN_STATE_BITS) & |
| 911 | ~p_sb_attn_sw->known_attn; |
| 912 | deasserted_bits = (~attn_bits & attn_acks & ATTN_STATE_BITS) & |
| 913 | p_sb_attn_sw->known_attn; |
| 914 | |
| 915 | if ((asserted_bits & ~0x100) || (deasserted_bits & ~0x100)) { |
| 916 | DP_INFO(p_hwfn, |
| 917 | "Attention: Index: 0x%04x, Bits: 0x%08x, Acks: 0x%08x, asserted: 0x%04x, De-asserted 0x%04x [Prev. known: 0x%04x]\n", |
| 918 | index, attn_bits, attn_acks, asserted_bits, |
| 919 | deasserted_bits, p_sb_attn_sw->known_attn); |
| 920 | } else if (asserted_bits == 0x100) { |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 921 | DP_INFO(p_hwfn, "MFW indication via attention\n"); |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 922 | } else { |
| 923 | DP_VERBOSE(p_hwfn, NETIF_MSG_INTR, |
| 924 | "MFW indication [deassertion]\n"); |
| 925 | } |
| 926 | |
| 927 | if (asserted_bits) { |
| 928 | rc = qed_int_assertion(p_hwfn, asserted_bits); |
| 929 | if (rc) |
| 930 | return rc; |
| 931 | } |
| 932 | |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 933 | if (deasserted_bits) |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 934 | rc = qed_int_deassertion(p_hwfn, deasserted_bits); |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 935 | |
| 936 | return rc; |
| 937 | } |
| 938 | |
| 939 | static void qed_sb_ack_attn(struct qed_hwfn *p_hwfn, |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 940 | void __iomem *igu_addr, u32 ack_cons) |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 941 | { |
| 942 | struct igu_prod_cons_update igu_ack = { 0 }; |
| 943 | |
| 944 | igu_ack.sb_id_and_flags = |
| 945 | ((ack_cons << IGU_PROD_CONS_UPDATE_SB_INDEX_SHIFT) | |
| 946 | (1 << IGU_PROD_CONS_UPDATE_UPDATE_FLAG_SHIFT) | |
| 947 | (IGU_INT_NOP << IGU_PROD_CONS_UPDATE_ENABLE_INT_SHIFT) | |
| 948 | (IGU_SEG_ACCESS_ATTN << |
| 949 | IGU_PROD_CONS_UPDATE_SEGMENT_ACCESS_SHIFT)); |
| 950 | |
| 951 | DIRECT_REG_WR(igu_addr, igu_ack.sb_id_and_flags); |
| 952 | |
| 953 | /* Both segments (interrupts & acks) are written to same place address; |
| 954 | * Need to guarantee all commands will be received (in-order) by HW. |
| 955 | */ |
| 956 | mmiowb(); |
| 957 | barrier(); |
| 958 | } |
| 959 | |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 960 | void qed_int_sp_dpc(unsigned long hwfn_cookie) |
| 961 | { |
| 962 | struct qed_hwfn *p_hwfn = (struct qed_hwfn *)hwfn_cookie; |
| 963 | struct qed_pi_info *pi_info = NULL; |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 964 | struct qed_sb_attn_info *sb_attn; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 965 | struct qed_sb_info *sb_info; |
| 966 | int arr_size; |
| 967 | u16 rc = 0; |
| 968 | |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 969 | if (!p_hwfn->p_sp_sb) { |
| 970 | DP_ERR(p_hwfn->cdev, "DPC called - no p_sp_sb\n"); |
| 971 | return; |
| 972 | } |
| 973 | |
| 974 | sb_info = &p_hwfn->p_sp_sb->sb_info; |
| 975 | arr_size = ARRAY_SIZE(p_hwfn->p_sp_sb->pi_info_arr); |
| 976 | if (!sb_info) { |
| 977 | DP_ERR(p_hwfn->cdev, |
| 978 | "Status block is NULL - cannot ack interrupts\n"); |
| 979 | return; |
| 980 | } |
| 981 | |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 982 | if (!p_hwfn->p_sb_attn) { |
| 983 | DP_ERR(p_hwfn->cdev, "DPC called - no p_sb_attn"); |
| 984 | return; |
| 985 | } |
| 986 | sb_attn = p_hwfn->p_sb_attn; |
| 987 | |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 988 | DP_VERBOSE(p_hwfn, NETIF_MSG_INTR, "DPC Called! (hwfn %p %d)\n", |
| 989 | p_hwfn, p_hwfn->my_id); |
| 990 | |
| 991 | /* Disable ack for def status block. Required both for msix + |
| 992 | * inta in non-mask mode, in inta does no harm. |
| 993 | */ |
| 994 | qed_sb_ack(sb_info, IGU_INT_DISABLE, 0); |
| 995 | |
| 996 | /* Gather Interrupts/Attentions information */ |
| 997 | if (!sb_info->sb_virt) { |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 998 | DP_ERR(p_hwfn->cdev, |
| 999 | "Interrupt Status block is NULL - cannot check for new interrupts!\n"); |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1000 | } else { |
| 1001 | u32 tmp_index = sb_info->sb_ack; |
| 1002 | |
| 1003 | rc = qed_sb_update_sb_idx(sb_info); |
| 1004 | DP_VERBOSE(p_hwfn->cdev, NETIF_MSG_INTR, |
| 1005 | "Interrupt indices: 0x%08x --> 0x%08x\n", |
| 1006 | tmp_index, sb_info->sb_ack); |
| 1007 | } |
| 1008 | |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 1009 | if (!sb_attn || !sb_attn->sb_attn) { |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 1010 | DP_ERR(p_hwfn->cdev, |
| 1011 | "Attentions Status block is NULL - cannot check for new attentions!\n"); |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 1012 | } else { |
| 1013 | u16 tmp_index = sb_attn->index; |
| 1014 | |
| 1015 | rc |= qed_attn_update_idx(p_hwfn, sb_attn); |
| 1016 | DP_VERBOSE(p_hwfn->cdev, NETIF_MSG_INTR, |
| 1017 | "Attention indices: 0x%08x --> 0x%08x\n", |
| 1018 | tmp_index, sb_attn->index); |
| 1019 | } |
| 1020 | |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1021 | /* Check if we expect interrupts at this time. if not just ack them */ |
| 1022 | if (!(rc & QED_SB_EVENT_MASK)) { |
| 1023 | qed_sb_ack(sb_info, IGU_INT_ENABLE, 1); |
| 1024 | return; |
| 1025 | } |
| 1026 | |
| 1027 | /* Check the validity of the DPC ptt. If not ack interrupts and fail */ |
| 1028 | if (!p_hwfn->p_dpc_ptt) { |
| 1029 | DP_NOTICE(p_hwfn->cdev, "Failed to allocate PTT\n"); |
| 1030 | qed_sb_ack(sb_info, IGU_INT_ENABLE, 1); |
| 1031 | return; |
| 1032 | } |
| 1033 | |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 1034 | if (rc & QED_SB_ATT_IDX) |
| 1035 | qed_int_attentions(p_hwfn); |
| 1036 | |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1037 | if (rc & QED_SB_IDX) { |
| 1038 | int pi; |
| 1039 | |
| 1040 | /* Look for a free index */ |
| 1041 | for (pi = 0; pi < arr_size; pi++) { |
| 1042 | pi_info = &p_hwfn->p_sp_sb->pi_info_arr[pi]; |
| 1043 | if (pi_info->comp_cb) |
| 1044 | pi_info->comp_cb(p_hwfn, pi_info->cookie); |
| 1045 | } |
| 1046 | } |
| 1047 | |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 1048 | if (sb_attn && (rc & QED_SB_ATT_IDX)) |
| 1049 | /* This should be done before the interrupts are enabled, |
| 1050 | * since otherwise a new attention will be generated. |
| 1051 | */ |
| 1052 | qed_sb_ack_attn(p_hwfn, sb_info->igu_addr, sb_attn->index); |
| 1053 | |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1054 | qed_sb_ack(sb_info, IGU_INT_ENABLE, 1); |
| 1055 | } |
| 1056 | |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 1057 | static void qed_int_sb_attn_free(struct qed_hwfn *p_hwfn) |
| 1058 | { |
Yuval Mintz | 4ac801b | 2016-02-28 12:26:52 +0200 | [diff] [blame] | 1059 | struct qed_sb_attn_info *p_sb = p_hwfn->p_sb_attn; |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 1060 | |
Yuval Mintz | 4ac801b | 2016-02-28 12:26:52 +0200 | [diff] [blame] | 1061 | if (!p_sb) |
| 1062 | return; |
| 1063 | |
| 1064 | if (p_sb->sb_attn) |
| 1065 | dma_free_coherent(&p_hwfn->cdev->pdev->dev, |
| 1066 | SB_ATTN_ALIGNED_SIZE(p_hwfn), |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 1067 | p_sb->sb_attn, p_sb->sb_phys); |
Yuval Mintz | 4ac801b | 2016-02-28 12:26:52 +0200 | [diff] [blame] | 1068 | kfree(p_sb); |
Tomer Tayar | 3587cb8 | 2017-05-21 12:10:56 +0300 | [diff] [blame] | 1069 | p_hwfn->p_sb_attn = NULL; |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 1070 | } |
| 1071 | |
| 1072 | static void qed_int_sb_attn_setup(struct qed_hwfn *p_hwfn, |
| 1073 | struct qed_ptt *p_ptt) |
| 1074 | { |
| 1075 | struct qed_sb_attn_info *sb_info = p_hwfn->p_sb_attn; |
| 1076 | |
| 1077 | memset(sb_info->sb_attn, 0, sizeof(*sb_info->sb_attn)); |
| 1078 | |
| 1079 | sb_info->index = 0; |
| 1080 | sb_info->known_attn = 0; |
| 1081 | |
| 1082 | /* Configure Attention Status Block in IGU */ |
| 1083 | qed_wr(p_hwfn, p_ptt, IGU_REG_ATTN_MSG_ADDR_L, |
| 1084 | lower_32_bits(p_hwfn->p_sb_attn->sb_phys)); |
| 1085 | qed_wr(p_hwfn, p_ptt, IGU_REG_ATTN_MSG_ADDR_H, |
| 1086 | upper_32_bits(p_hwfn->p_sb_attn->sb_phys)); |
| 1087 | } |
| 1088 | |
| 1089 | static void qed_int_sb_attn_init(struct qed_hwfn *p_hwfn, |
| 1090 | struct qed_ptt *p_ptt, |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 1091 | void *sb_virt_addr, dma_addr_t sb_phy_addr) |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 1092 | { |
| 1093 | struct qed_sb_attn_info *sb_info = p_hwfn->p_sb_attn; |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 1094 | int i, j, k; |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 1095 | |
| 1096 | sb_info->sb_attn = sb_virt_addr; |
| 1097 | sb_info->sb_phys = sb_phy_addr; |
| 1098 | |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 1099 | /* Set the pointer to the AEU descriptors */ |
| 1100 | sb_info->p_aeu_desc = aeu_descs; |
| 1101 | |
| 1102 | /* Calculate Parity Masks */ |
| 1103 | memset(sb_info->parity_mask, 0, sizeof(u32) * NUM_ATTN_REGS); |
| 1104 | for (i = 0; i < NUM_ATTN_REGS; i++) { |
| 1105 | /* j is array index, k is bit index */ |
| 1106 | for (j = 0, k = 0; k < 32; j++) { |
| 1107 | unsigned int flags = aeu_descs[i].bits[j].flags; |
| 1108 | |
| 1109 | if (flags & ATTENTION_PARITY) |
| 1110 | sb_info->parity_mask[i] |= 1 << k; |
| 1111 | |
| 1112 | k += ATTENTION_LENGTH(flags); |
| 1113 | } |
| 1114 | DP_VERBOSE(p_hwfn, NETIF_MSG_INTR, |
| 1115 | "Attn Mask [Reg %d]: 0x%08x\n", |
| 1116 | i, sb_info->parity_mask[i]); |
| 1117 | } |
| 1118 | |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 1119 | /* Set the address of cleanup for the mcp attention */ |
| 1120 | sb_info->mfw_attn_addr = (p_hwfn->rel_pf_id << 3) + |
| 1121 | MISC_REG_AEU_GENERAL_ATTN_0; |
| 1122 | |
| 1123 | qed_int_sb_attn_setup(p_hwfn, p_ptt); |
| 1124 | } |
| 1125 | |
| 1126 | static int qed_int_sb_attn_alloc(struct qed_hwfn *p_hwfn, |
| 1127 | struct qed_ptt *p_ptt) |
| 1128 | { |
| 1129 | struct qed_dev *cdev = p_hwfn->cdev; |
| 1130 | struct qed_sb_attn_info *p_sb; |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 1131 | dma_addr_t p_phys = 0; |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 1132 | void *p_virt; |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 1133 | |
| 1134 | /* SB struct */ |
Yuval Mintz | 60fffb3 | 2016-02-21 11:40:07 +0200 | [diff] [blame] | 1135 | p_sb = kmalloc(sizeof(*p_sb), GFP_KERNEL); |
Joe Perches | 2591c28 | 2016-09-04 14:24:03 -0700 | [diff] [blame] | 1136 | if (!p_sb) |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 1137 | return -ENOMEM; |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 1138 | |
| 1139 | /* SB ring */ |
| 1140 | p_virt = dma_alloc_coherent(&cdev->pdev->dev, |
| 1141 | SB_ATTN_ALIGNED_SIZE(p_hwfn), |
| 1142 | &p_phys, GFP_KERNEL); |
| 1143 | |
| 1144 | if (!p_virt) { |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 1145 | kfree(p_sb); |
| 1146 | return -ENOMEM; |
| 1147 | } |
| 1148 | |
| 1149 | /* Attention setup */ |
| 1150 | p_hwfn->p_sb_attn = p_sb; |
| 1151 | qed_int_sb_attn_init(p_hwfn, p_ptt, p_virt, p_phys); |
| 1152 | |
| 1153 | return 0; |
| 1154 | } |
| 1155 | |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1156 | /* coalescing timeout = timeset << (timer_res + 1) */ |
| 1157 | #define QED_CAU_DEF_RX_USECS 24 |
| 1158 | #define QED_CAU_DEF_TX_USECS 48 |
| 1159 | |
| 1160 | void qed_init_cau_sb_entry(struct qed_hwfn *p_hwfn, |
| 1161 | struct cau_sb_entry *p_sb_entry, |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 1162 | u8 pf_id, u16 vf_number, u8 vf_valid) |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1163 | { |
Yuval Mintz | 4ac801b | 2016-02-28 12:26:52 +0200 | [diff] [blame] | 1164 | struct qed_dev *cdev = p_hwfn->cdev; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1165 | u32 cau_state; |
Sudarsana Reddy Kalluru | 722003a | 2016-06-21 09:36:21 -0400 | [diff] [blame] | 1166 | u8 timer_res; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1167 | |
| 1168 | memset(p_sb_entry, 0, sizeof(*p_sb_entry)); |
| 1169 | |
| 1170 | SET_FIELD(p_sb_entry->params, CAU_SB_ENTRY_PF_NUMBER, pf_id); |
| 1171 | SET_FIELD(p_sb_entry->params, CAU_SB_ENTRY_VF_NUMBER, vf_number); |
| 1172 | SET_FIELD(p_sb_entry->params, CAU_SB_ENTRY_VF_VALID, vf_valid); |
| 1173 | SET_FIELD(p_sb_entry->params, CAU_SB_ENTRY_SB_TIMESET0, 0x7F); |
| 1174 | SET_FIELD(p_sb_entry->params, CAU_SB_ENTRY_SB_TIMESET1, 0x7F); |
| 1175 | |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1176 | cau_state = CAU_HC_DISABLE_STATE; |
| 1177 | |
Yuval Mintz | 4ac801b | 2016-02-28 12:26:52 +0200 | [diff] [blame] | 1178 | if (cdev->int_coalescing_mode == QED_COAL_MODE_ENABLE) { |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1179 | cau_state = CAU_HC_ENABLE_STATE; |
Yuval Mintz | 4ac801b | 2016-02-28 12:26:52 +0200 | [diff] [blame] | 1180 | if (!cdev->rx_coalesce_usecs) |
| 1181 | cdev->rx_coalesce_usecs = QED_CAU_DEF_RX_USECS; |
| 1182 | if (!cdev->tx_coalesce_usecs) |
| 1183 | cdev->tx_coalesce_usecs = QED_CAU_DEF_TX_USECS; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1184 | } |
| 1185 | |
Sudarsana Reddy Kalluru | 722003a | 2016-06-21 09:36:21 -0400 | [diff] [blame] | 1186 | /* Coalesce = (timeset << timer-res), timeset is 7bit wide */ |
| 1187 | if (cdev->rx_coalesce_usecs <= 0x7F) |
| 1188 | timer_res = 0; |
| 1189 | else if (cdev->rx_coalesce_usecs <= 0xFF) |
| 1190 | timer_res = 1; |
| 1191 | else |
| 1192 | timer_res = 2; |
| 1193 | SET_FIELD(p_sb_entry->params, CAU_SB_ENTRY_TIMER_RES0, timer_res); |
| 1194 | |
| 1195 | if (cdev->tx_coalesce_usecs <= 0x7F) |
| 1196 | timer_res = 0; |
| 1197 | else if (cdev->tx_coalesce_usecs <= 0xFF) |
| 1198 | timer_res = 1; |
| 1199 | else |
| 1200 | timer_res = 2; |
| 1201 | SET_FIELD(p_sb_entry->params, CAU_SB_ENTRY_TIMER_RES1, timer_res); |
| 1202 | |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1203 | SET_FIELD(p_sb_entry->data, CAU_SB_ENTRY_STATE0, cau_state); |
| 1204 | SET_FIELD(p_sb_entry->data, CAU_SB_ENTRY_STATE1, cau_state); |
| 1205 | } |
| 1206 | |
| 1207 | void qed_int_cau_conf_sb(struct qed_hwfn *p_hwfn, |
| 1208 | struct qed_ptt *p_ptt, |
| 1209 | dma_addr_t sb_phys, |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 1210 | u16 igu_sb_id, u16 vf_number, u8 vf_valid) |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1211 | { |
| 1212 | struct cau_sb_entry sb_entry; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1213 | |
| 1214 | qed_init_cau_sb_entry(p_hwfn, &sb_entry, p_hwfn->rel_pf_id, |
| 1215 | vf_number, vf_valid); |
| 1216 | |
| 1217 | if (p_hwfn->hw_init_done) { |
Yuval Mintz | 0a0c5d3 | 2016-02-21 11:40:08 +0200 | [diff] [blame] | 1218 | /* Wide-bus, initialize via DMAE */ |
| 1219 | u64 phys_addr = (u64)sb_phys; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1220 | |
Yuval Mintz | 0a0c5d3 | 2016-02-21 11:40:08 +0200 | [diff] [blame] | 1221 | qed_dmae_host2grc(p_hwfn, p_ptt, (u64)(uintptr_t)&phys_addr, |
| 1222 | CAU_REG_SB_ADDR_MEMORY + |
| 1223 | igu_sb_id * sizeof(u64), 2, 0); |
| 1224 | qed_dmae_host2grc(p_hwfn, p_ptt, (u64)(uintptr_t)&sb_entry, |
| 1225 | CAU_REG_SB_VAR_MEMORY + |
| 1226 | igu_sb_id * sizeof(u64), 2, 0); |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1227 | } else { |
| 1228 | /* Initialize Status Block Address */ |
| 1229 | STORE_RT_REG_AGG(p_hwfn, |
| 1230 | CAU_REG_SB_ADDR_MEMORY_RT_OFFSET + |
| 1231 | igu_sb_id * 2, |
| 1232 | sb_phys); |
| 1233 | |
| 1234 | STORE_RT_REG_AGG(p_hwfn, |
| 1235 | CAU_REG_SB_VAR_MEMORY_RT_OFFSET + |
| 1236 | igu_sb_id * 2, |
| 1237 | sb_entry); |
| 1238 | } |
| 1239 | |
| 1240 | /* Configure pi coalescing if set */ |
| 1241 | if (p_hwfn->cdev->int_coalescing_mode == QED_COAL_MODE_ENABLE) { |
Ariel Elior | b5a9ee7 | 2017-04-03 12:21:09 +0300 | [diff] [blame] | 1242 | u8 num_tc = p_hwfn->hw_info.num_hw_tc; |
Sudarsana Reddy Kalluru | 722003a | 2016-06-21 09:36:21 -0400 | [diff] [blame] | 1243 | u8 timeset, timer_res; |
Ariel Elior | b5a9ee7 | 2017-04-03 12:21:09 +0300 | [diff] [blame] | 1244 | u8 i; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1245 | |
Sudarsana Reddy Kalluru | 722003a | 2016-06-21 09:36:21 -0400 | [diff] [blame] | 1246 | /* timeset = (coalesce >> timer-res), timeset is 7bit wide */ |
| 1247 | if (p_hwfn->cdev->rx_coalesce_usecs <= 0x7F) |
| 1248 | timer_res = 0; |
| 1249 | else if (p_hwfn->cdev->rx_coalesce_usecs <= 0xFF) |
| 1250 | timer_res = 1; |
| 1251 | else |
| 1252 | timer_res = 2; |
| 1253 | timeset = (u8)(p_hwfn->cdev->rx_coalesce_usecs >> timer_res); |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1254 | qed_int_cau_conf_pi(p_hwfn, p_ptt, igu_sb_id, RX_PI, |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 1255 | QED_COAL_RX_STATE_MACHINE, timeset); |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1256 | |
Sudarsana Reddy Kalluru | 722003a | 2016-06-21 09:36:21 -0400 | [diff] [blame] | 1257 | if (p_hwfn->cdev->tx_coalesce_usecs <= 0x7F) |
| 1258 | timer_res = 0; |
| 1259 | else if (p_hwfn->cdev->tx_coalesce_usecs <= 0xFF) |
| 1260 | timer_res = 1; |
| 1261 | else |
| 1262 | timer_res = 2; |
| 1263 | timeset = (u8)(p_hwfn->cdev->tx_coalesce_usecs >> timer_res); |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1264 | for (i = 0; i < num_tc; i++) { |
| 1265 | qed_int_cau_conf_pi(p_hwfn, p_ptt, |
| 1266 | igu_sb_id, TX_PI(i), |
| 1267 | QED_COAL_TX_STATE_MACHINE, |
| 1268 | timeset); |
| 1269 | } |
| 1270 | } |
| 1271 | } |
| 1272 | |
| 1273 | void qed_int_cau_conf_pi(struct qed_hwfn *p_hwfn, |
| 1274 | struct qed_ptt *p_ptt, |
| 1275 | u16 igu_sb_id, |
| 1276 | u32 pi_index, |
| 1277 | enum qed_coalescing_fsm coalescing_fsm, |
| 1278 | u8 timeset) |
| 1279 | { |
| 1280 | struct cau_pi_entry pi_entry; |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 1281 | u32 sb_offset, pi_offset; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1282 | |
Yuval Mintz | 1408cc1f | 2016-05-11 16:36:14 +0300 | [diff] [blame] | 1283 | if (IS_VF(p_hwfn->cdev)) |
| 1284 | return; |
| 1285 | |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1286 | sb_offset = igu_sb_id * PIS_PER_SB; |
| 1287 | memset(&pi_entry, 0, sizeof(struct cau_pi_entry)); |
| 1288 | |
| 1289 | SET_FIELD(pi_entry.prod, CAU_PI_ENTRY_PI_TIMESET, timeset); |
| 1290 | if (coalescing_fsm == QED_COAL_RX_STATE_MACHINE) |
| 1291 | SET_FIELD(pi_entry.prod, CAU_PI_ENTRY_FSM_SEL, 0); |
| 1292 | else |
| 1293 | SET_FIELD(pi_entry.prod, CAU_PI_ENTRY_FSM_SEL, 1); |
| 1294 | |
| 1295 | pi_offset = sb_offset + pi_index; |
| 1296 | if (p_hwfn->hw_init_done) { |
| 1297 | qed_wr(p_hwfn, p_ptt, |
| 1298 | CAU_REG_PI_MEMORY + pi_offset * sizeof(u32), |
| 1299 | *((u32 *)&(pi_entry))); |
| 1300 | } else { |
| 1301 | STORE_RT_REG(p_hwfn, |
| 1302 | CAU_REG_PI_MEMORY_RT_OFFSET + pi_offset, |
| 1303 | *((u32 *)&(pi_entry))); |
| 1304 | } |
| 1305 | } |
| 1306 | |
| 1307 | void qed_int_sb_setup(struct qed_hwfn *p_hwfn, |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 1308 | struct qed_ptt *p_ptt, struct qed_sb_info *sb_info) |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1309 | { |
| 1310 | /* zero status block and ack counter */ |
| 1311 | sb_info->sb_ack = 0; |
| 1312 | memset(sb_info->sb_virt, 0, sizeof(*sb_info->sb_virt)); |
| 1313 | |
Yuval Mintz | 1408cc1f | 2016-05-11 16:36:14 +0300 | [diff] [blame] | 1314 | if (IS_PF(p_hwfn->cdev)) |
| 1315 | qed_int_cau_conf_sb(p_hwfn, p_ptt, sb_info->sb_phys, |
| 1316 | sb_info->igu_sb_id, 0, 0); |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1317 | } |
| 1318 | |
| 1319 | /** |
| 1320 | * @brief qed_get_igu_sb_id - given a sw sb_id return the |
| 1321 | * igu_sb_id |
| 1322 | * |
| 1323 | * @param p_hwfn |
| 1324 | * @param sb_id |
| 1325 | * |
| 1326 | * @return u16 |
| 1327 | */ |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 1328 | static u16 qed_get_igu_sb_id(struct qed_hwfn *p_hwfn, u16 sb_id) |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1329 | { |
| 1330 | u16 igu_sb_id; |
| 1331 | |
| 1332 | /* Assuming continuous set of IGU SBs dedicated for given PF */ |
| 1333 | if (sb_id == QED_SP_SB_ID) |
| 1334 | igu_sb_id = p_hwfn->hw_info.p_igu_info->igu_dsb_id; |
Yuval Mintz | 1408cc1f | 2016-05-11 16:36:14 +0300 | [diff] [blame] | 1335 | else if (IS_PF(p_hwfn->cdev)) |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1336 | igu_sb_id = sb_id + p_hwfn->hw_info.p_igu_info->igu_base_sb; |
Yuval Mintz | 1408cc1f | 2016-05-11 16:36:14 +0300 | [diff] [blame] | 1337 | else |
| 1338 | igu_sb_id = qed_vf_get_igu_sb_id(p_hwfn, sb_id); |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1339 | |
Yuval Mintz | 525ef5c | 2016-08-15 10:42:45 +0300 | [diff] [blame] | 1340 | if (sb_id == QED_SP_SB_ID) |
| 1341 | DP_VERBOSE(p_hwfn, NETIF_MSG_INTR, |
| 1342 | "Slowpath SB index in IGU is 0x%04x\n", igu_sb_id); |
| 1343 | else |
| 1344 | DP_VERBOSE(p_hwfn, NETIF_MSG_INTR, |
| 1345 | "SB [%04x] <--> IGU SB [%04x]\n", sb_id, igu_sb_id); |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1346 | |
| 1347 | return igu_sb_id; |
| 1348 | } |
| 1349 | |
| 1350 | int qed_int_sb_init(struct qed_hwfn *p_hwfn, |
| 1351 | struct qed_ptt *p_ptt, |
| 1352 | struct qed_sb_info *sb_info, |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 1353 | void *sb_virt_addr, dma_addr_t sb_phy_addr, u16 sb_id) |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1354 | { |
| 1355 | sb_info->sb_virt = sb_virt_addr; |
| 1356 | sb_info->sb_phys = sb_phy_addr; |
| 1357 | |
| 1358 | sb_info->igu_sb_id = qed_get_igu_sb_id(p_hwfn, sb_id); |
| 1359 | |
| 1360 | if (sb_id != QED_SP_SB_ID) { |
| 1361 | p_hwfn->sbs_info[sb_id] = sb_info; |
| 1362 | p_hwfn->num_sbs++; |
| 1363 | } |
| 1364 | |
| 1365 | sb_info->cdev = p_hwfn->cdev; |
| 1366 | |
| 1367 | /* The igu address will hold the absolute address that needs to be |
| 1368 | * written to for a specific status block |
| 1369 | */ |
Yuval Mintz | 1408cc1f | 2016-05-11 16:36:14 +0300 | [diff] [blame] | 1370 | if (IS_PF(p_hwfn->cdev)) { |
| 1371 | sb_info->igu_addr = (u8 __iomem *)p_hwfn->regview + |
| 1372 | GTT_BAR0_MAP_REG_IGU_CMD + |
| 1373 | (sb_info->igu_sb_id << 3); |
| 1374 | } else { |
| 1375 | sb_info->igu_addr = (u8 __iomem *)p_hwfn->regview + |
| 1376 | PXP_VF_BAR0_START_IGU + |
| 1377 | ((IGU_CMD_INT_ACK_BASE + |
| 1378 | sb_info->igu_sb_id) << 3); |
| 1379 | } |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1380 | |
| 1381 | sb_info->flags |= QED_SB_INFO_INIT; |
| 1382 | |
| 1383 | qed_int_sb_setup(p_hwfn, p_ptt, sb_info); |
| 1384 | |
| 1385 | return 0; |
| 1386 | } |
| 1387 | |
| 1388 | int qed_int_sb_release(struct qed_hwfn *p_hwfn, |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 1389 | struct qed_sb_info *sb_info, u16 sb_id) |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1390 | { |
| 1391 | if (sb_id == QED_SP_SB_ID) { |
| 1392 | DP_ERR(p_hwfn, "Do Not free sp sb using this function"); |
| 1393 | return -EINVAL; |
| 1394 | } |
| 1395 | |
| 1396 | /* zero status block and ack counter */ |
| 1397 | sb_info->sb_ack = 0; |
| 1398 | memset(sb_info->sb_virt, 0, sizeof(*sb_info->sb_virt)); |
| 1399 | |
Yuval Mintz | 4ac801b | 2016-02-28 12:26:52 +0200 | [diff] [blame] | 1400 | if (p_hwfn->sbs_info[sb_id] != NULL) { |
| 1401 | p_hwfn->sbs_info[sb_id] = NULL; |
| 1402 | p_hwfn->num_sbs--; |
| 1403 | } |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1404 | |
| 1405 | return 0; |
| 1406 | } |
| 1407 | |
| 1408 | static void qed_int_sp_sb_free(struct qed_hwfn *p_hwfn) |
| 1409 | { |
| 1410 | struct qed_sb_sp_info *p_sb = p_hwfn->p_sp_sb; |
| 1411 | |
Yuval Mintz | 4ac801b | 2016-02-28 12:26:52 +0200 | [diff] [blame] | 1412 | if (!p_sb) |
| 1413 | return; |
| 1414 | |
| 1415 | if (p_sb->sb_info.sb_virt) |
| 1416 | dma_free_coherent(&p_hwfn->cdev->pdev->dev, |
| 1417 | SB_ALIGNED_SIZE(p_hwfn), |
| 1418 | p_sb->sb_info.sb_virt, |
| 1419 | p_sb->sb_info.sb_phys); |
| 1420 | kfree(p_sb); |
Tomer Tayar | 3587cb8 | 2017-05-21 12:10:56 +0300 | [diff] [blame] | 1421 | p_hwfn->p_sp_sb = NULL; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1422 | } |
| 1423 | |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 1424 | static int qed_int_sp_sb_alloc(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1425 | { |
| 1426 | struct qed_sb_sp_info *p_sb; |
| 1427 | dma_addr_t p_phys = 0; |
| 1428 | void *p_virt; |
| 1429 | |
| 1430 | /* SB struct */ |
Yuval Mintz | 60fffb3 | 2016-02-21 11:40:07 +0200 | [diff] [blame] | 1431 | p_sb = kmalloc(sizeof(*p_sb), GFP_KERNEL); |
Joe Perches | 2591c28 | 2016-09-04 14:24:03 -0700 | [diff] [blame] | 1432 | if (!p_sb) |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1433 | return -ENOMEM; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1434 | |
| 1435 | /* SB ring */ |
| 1436 | p_virt = dma_alloc_coherent(&p_hwfn->cdev->pdev->dev, |
| 1437 | SB_ALIGNED_SIZE(p_hwfn), |
| 1438 | &p_phys, GFP_KERNEL); |
| 1439 | if (!p_virt) { |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1440 | kfree(p_sb); |
| 1441 | return -ENOMEM; |
| 1442 | } |
| 1443 | |
| 1444 | /* Status Block setup */ |
| 1445 | p_hwfn->p_sp_sb = p_sb; |
| 1446 | qed_int_sb_init(p_hwfn, p_ptt, &p_sb->sb_info, p_virt, |
| 1447 | p_phys, QED_SP_SB_ID); |
| 1448 | |
| 1449 | memset(p_sb->pi_info_arr, 0, sizeof(p_sb->pi_info_arr)); |
| 1450 | |
| 1451 | return 0; |
| 1452 | } |
| 1453 | |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1454 | int qed_int_register_cb(struct qed_hwfn *p_hwfn, |
| 1455 | qed_int_comp_cb_t comp_cb, |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 1456 | void *cookie, u8 *sb_idx, __le16 **p_fw_cons) |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1457 | { |
| 1458 | struct qed_sb_sp_info *p_sp_sb = p_hwfn->p_sp_sb; |
Yuval Mintz | 4ac801b | 2016-02-28 12:26:52 +0200 | [diff] [blame] | 1459 | int rc = -ENOMEM; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1460 | u8 pi; |
| 1461 | |
| 1462 | /* Look for a free index */ |
| 1463 | for (pi = 0; pi < ARRAY_SIZE(p_sp_sb->pi_info_arr); pi++) { |
Yuval Mintz | 4ac801b | 2016-02-28 12:26:52 +0200 | [diff] [blame] | 1464 | if (p_sp_sb->pi_info_arr[pi].comp_cb) |
| 1465 | continue; |
| 1466 | |
| 1467 | p_sp_sb->pi_info_arr[pi].comp_cb = comp_cb; |
| 1468 | p_sp_sb->pi_info_arr[pi].cookie = cookie; |
| 1469 | *sb_idx = pi; |
| 1470 | *p_fw_cons = &p_sp_sb->sb_info.sb_virt->pi_array[pi]; |
| 1471 | rc = 0; |
| 1472 | break; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1473 | } |
| 1474 | |
Yuval Mintz | 4ac801b | 2016-02-28 12:26:52 +0200 | [diff] [blame] | 1475 | return rc; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1476 | } |
| 1477 | |
| 1478 | int qed_int_unregister_cb(struct qed_hwfn *p_hwfn, u8 pi) |
| 1479 | { |
| 1480 | struct qed_sb_sp_info *p_sp_sb = p_hwfn->p_sp_sb; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1481 | |
Yuval Mintz | 4ac801b | 2016-02-28 12:26:52 +0200 | [diff] [blame] | 1482 | if (p_sp_sb->pi_info_arr[pi].comp_cb == NULL) |
| 1483 | return -ENOMEM; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1484 | |
Yuval Mintz | 4ac801b | 2016-02-28 12:26:52 +0200 | [diff] [blame] | 1485 | p_sp_sb->pi_info_arr[pi].comp_cb = NULL; |
| 1486 | p_sp_sb->pi_info_arr[pi].cookie = NULL; |
| 1487 | |
| 1488 | return 0; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1489 | } |
| 1490 | |
| 1491 | u16 qed_int_get_sp_sb_id(struct qed_hwfn *p_hwfn) |
| 1492 | { |
| 1493 | return p_hwfn->p_sp_sb->sb_info.igu_sb_id; |
| 1494 | } |
| 1495 | |
| 1496 | void qed_int_igu_enable_int(struct qed_hwfn *p_hwfn, |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 1497 | struct qed_ptt *p_ptt, enum qed_int_mode int_mode) |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1498 | { |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 1499 | u32 igu_pf_conf = IGU_PF_CONF_FUNC_EN | IGU_PF_CONF_ATTN_BIT_EN; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1500 | |
| 1501 | p_hwfn->cdev->int_mode = int_mode; |
| 1502 | switch (p_hwfn->cdev->int_mode) { |
| 1503 | case QED_INT_MODE_INTA: |
| 1504 | igu_pf_conf |= IGU_PF_CONF_INT_LINE_EN; |
| 1505 | igu_pf_conf |= IGU_PF_CONF_SINGLE_ISR_EN; |
| 1506 | break; |
| 1507 | |
| 1508 | case QED_INT_MODE_MSI: |
| 1509 | igu_pf_conf |= IGU_PF_CONF_MSI_MSIX_EN; |
| 1510 | igu_pf_conf |= IGU_PF_CONF_SINGLE_ISR_EN; |
| 1511 | break; |
| 1512 | |
| 1513 | case QED_INT_MODE_MSIX: |
| 1514 | igu_pf_conf |= IGU_PF_CONF_MSI_MSIX_EN; |
| 1515 | break; |
| 1516 | case QED_INT_MODE_POLL: |
| 1517 | break; |
| 1518 | } |
| 1519 | |
| 1520 | qed_wr(p_hwfn, p_ptt, IGU_REG_PF_CONFIGURATION, igu_pf_conf); |
| 1521 | } |
| 1522 | |
Sudarsana Kalluru | 8f16bc9 | 2015-12-07 06:25:59 -0500 | [diff] [blame] | 1523 | int qed_int_igu_enable(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, |
| 1524 | enum qed_int_mode int_mode) |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1525 | { |
Colin Ian King | fea2485 | 2016-03-29 18:00:50 +0100 | [diff] [blame] | 1526 | int rc = 0; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1527 | |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 1528 | /* Configure AEU signal change to produce attentions */ |
| 1529 | qed_wr(p_hwfn, p_ptt, IGU_REG_ATTENTION_ENABLE, 0); |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 1530 | qed_wr(p_hwfn, p_ptt, IGU_REG_LEADING_EDGE_LATCH, 0xfff); |
| 1531 | qed_wr(p_hwfn, p_ptt, IGU_REG_TRAILING_EDGE_LATCH, 0xfff); |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 1532 | qed_wr(p_hwfn, p_ptt, IGU_REG_ATTENTION_ENABLE, 0xfff); |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 1533 | |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1534 | /* Flush the writes to IGU */ |
| 1535 | mmiowb(); |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 1536 | |
| 1537 | /* Unmask AEU signals toward IGU */ |
| 1538 | qed_wr(p_hwfn, p_ptt, MISC_REG_AEU_MASK_ATTN_IGU, 0xff); |
Sudarsana Kalluru | 8f16bc9 | 2015-12-07 06:25:59 -0500 | [diff] [blame] | 1539 | if ((int_mode != QED_INT_MODE_INTA) || IS_LEAD_HWFN(p_hwfn)) { |
| 1540 | rc = qed_slowpath_irq_req(p_hwfn); |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 1541 | if (rc) { |
Sudarsana Kalluru | 8f16bc9 | 2015-12-07 06:25:59 -0500 | [diff] [blame] | 1542 | DP_NOTICE(p_hwfn, "Slowpath IRQ request failed\n"); |
| 1543 | return -EINVAL; |
| 1544 | } |
| 1545 | p_hwfn->b_int_requested = true; |
| 1546 | } |
| 1547 | /* Enable interrupt Generation */ |
| 1548 | qed_int_igu_enable_int(p_hwfn, p_ptt, int_mode); |
| 1549 | p_hwfn->b_int_enabled = 1; |
| 1550 | |
| 1551 | return rc; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1552 | } |
| 1553 | |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 1554 | void qed_int_igu_disable_int(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1555 | { |
| 1556 | p_hwfn->b_int_enabled = 0; |
| 1557 | |
Yuval Mintz | 1408cc1f | 2016-05-11 16:36:14 +0300 | [diff] [blame] | 1558 | if (IS_VF(p_hwfn->cdev)) |
| 1559 | return; |
| 1560 | |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1561 | qed_wr(p_hwfn, p_ptt, IGU_REG_PF_CONFIGURATION, 0); |
| 1562 | } |
| 1563 | |
| 1564 | #define IGU_CLEANUP_SLEEP_LENGTH (1000) |
Yuval Mintz | b2b897e | 2016-05-15 14:48:06 +0300 | [diff] [blame] | 1565 | static void qed_int_igu_cleanup_sb(struct qed_hwfn *p_hwfn, |
| 1566 | struct qed_ptt *p_ptt, |
| 1567 | u32 sb_id, bool cleanup_set, u16 opaque_fid) |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1568 | { |
Yuval Mintz | b2b897e | 2016-05-15 14:48:06 +0300 | [diff] [blame] | 1569 | u32 cmd_ctrl = 0, val = 0, sb_bit = 0, sb_bit_addr = 0, data = 0; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1570 | u32 pxp_addr = IGU_CMD_INT_ACK_BASE + sb_id; |
| 1571 | u32 sleep_cnt = IGU_CLEANUP_SLEEP_LENGTH; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1572 | |
| 1573 | /* Set the data field */ |
| 1574 | SET_FIELD(data, IGU_CLEANUP_CLEANUP_SET, cleanup_set ? 1 : 0); |
| 1575 | SET_FIELD(data, IGU_CLEANUP_CLEANUP_TYPE, 0); |
| 1576 | SET_FIELD(data, IGU_CLEANUP_COMMAND_TYPE, IGU_COMMAND_TYPE_SET); |
| 1577 | |
| 1578 | /* Set the control register */ |
| 1579 | SET_FIELD(cmd_ctrl, IGU_CTRL_REG_PXP_ADDR, pxp_addr); |
| 1580 | SET_FIELD(cmd_ctrl, IGU_CTRL_REG_FID, opaque_fid); |
| 1581 | SET_FIELD(cmd_ctrl, IGU_CTRL_REG_TYPE, IGU_CTRL_CMD_TYPE_WR); |
| 1582 | |
| 1583 | qed_wr(p_hwfn, p_ptt, IGU_REG_COMMAND_REG_32LSB_DATA, data); |
| 1584 | |
| 1585 | barrier(); |
| 1586 | |
| 1587 | qed_wr(p_hwfn, p_ptt, IGU_REG_COMMAND_REG_CTRL, cmd_ctrl); |
| 1588 | |
| 1589 | /* Flush the write to IGU */ |
| 1590 | mmiowb(); |
| 1591 | |
| 1592 | /* calculate where to read the status bit from */ |
| 1593 | sb_bit = 1 << (sb_id % 32); |
| 1594 | sb_bit_addr = sb_id / 32 * sizeof(u32); |
| 1595 | |
| 1596 | sb_bit_addr += IGU_REG_CLEANUP_STATUS_0; |
| 1597 | |
| 1598 | /* Now wait for the command to complete */ |
| 1599 | do { |
| 1600 | val = qed_rd(p_hwfn, p_ptt, sb_bit_addr); |
| 1601 | |
| 1602 | if ((val & sb_bit) == (cleanup_set ? sb_bit : 0)) |
| 1603 | break; |
| 1604 | |
| 1605 | usleep_range(5000, 10000); |
| 1606 | } while (--sleep_cnt); |
| 1607 | |
| 1608 | if (!sleep_cnt) |
| 1609 | DP_NOTICE(p_hwfn, |
| 1610 | "Timeout waiting for clear status 0x%08x [for sb %d]\n", |
| 1611 | val, sb_id); |
| 1612 | } |
| 1613 | |
| 1614 | void qed_int_igu_init_pure_rt_single(struct qed_hwfn *p_hwfn, |
| 1615 | struct qed_ptt *p_ptt, |
Yuval Mintz | b2b897e | 2016-05-15 14:48:06 +0300 | [diff] [blame] | 1616 | u32 sb_id, u16 opaque, bool b_set) |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1617 | { |
Yuval Mintz | b2b897e | 2016-05-15 14:48:06 +0300 | [diff] [blame] | 1618 | int pi, i; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1619 | |
| 1620 | /* Set */ |
| 1621 | if (b_set) |
| 1622 | qed_int_igu_cleanup_sb(p_hwfn, p_ptt, sb_id, 1, opaque); |
| 1623 | |
| 1624 | /* Clear */ |
| 1625 | qed_int_igu_cleanup_sb(p_hwfn, p_ptt, sb_id, 0, opaque); |
| 1626 | |
Yuval Mintz | b2b897e | 2016-05-15 14:48:06 +0300 | [diff] [blame] | 1627 | /* Wait for the IGU SB to cleanup */ |
| 1628 | for (i = 0; i < IGU_CLEANUP_SLEEP_LENGTH; i++) { |
| 1629 | u32 val; |
| 1630 | |
| 1631 | val = qed_rd(p_hwfn, p_ptt, |
| 1632 | IGU_REG_WRITE_DONE_PENDING + ((sb_id / 32) * 4)); |
| 1633 | if (val & (1 << (sb_id % 32))) |
| 1634 | usleep_range(10, 20); |
| 1635 | else |
| 1636 | break; |
| 1637 | } |
| 1638 | if (i == IGU_CLEANUP_SLEEP_LENGTH) |
| 1639 | DP_NOTICE(p_hwfn, |
| 1640 | "Failed SB[0x%08x] still appearing in WRITE_DONE_PENDING\n", |
| 1641 | sb_id); |
| 1642 | |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1643 | /* Clear the CAU for the SB */ |
| 1644 | for (pi = 0; pi < 12; pi++) |
| 1645 | qed_wr(p_hwfn, p_ptt, |
| 1646 | CAU_REG_PI_MEMORY + (sb_id * 12 + pi) * 4, 0); |
| 1647 | } |
| 1648 | |
| 1649 | void qed_int_igu_init_pure_rt(struct qed_hwfn *p_hwfn, |
| 1650 | struct qed_ptt *p_ptt, |
Yuval Mintz | b2b897e | 2016-05-15 14:48:06 +0300 | [diff] [blame] | 1651 | bool b_set, bool b_slowpath) |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1652 | { |
| 1653 | u32 igu_base_sb = p_hwfn->hw_info.p_igu_info->igu_base_sb; |
| 1654 | u32 igu_sb_cnt = p_hwfn->hw_info.p_igu_info->igu_sb_cnt; |
Yuval Mintz | b2b897e | 2016-05-15 14:48:06 +0300 | [diff] [blame] | 1655 | u32 sb_id = 0, val = 0; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1656 | |
| 1657 | val = qed_rd(p_hwfn, p_ptt, IGU_REG_BLOCK_CONFIGURATION); |
| 1658 | val |= IGU_REG_BLOCK_CONFIGURATION_VF_CLEANUP_EN; |
| 1659 | val &= ~IGU_REG_BLOCK_CONFIGURATION_PXP_TPH_INTERFACE_EN; |
| 1660 | qed_wr(p_hwfn, p_ptt, IGU_REG_BLOCK_CONFIGURATION, val); |
| 1661 | |
| 1662 | DP_VERBOSE(p_hwfn, NETIF_MSG_INTR, |
| 1663 | "IGU cleaning SBs [%d,...,%d]\n", |
| 1664 | igu_base_sb, igu_base_sb + igu_sb_cnt - 1); |
| 1665 | |
| 1666 | for (sb_id = igu_base_sb; sb_id < igu_base_sb + igu_sb_cnt; sb_id++) |
| 1667 | qed_int_igu_init_pure_rt_single(p_hwfn, p_ptt, sb_id, |
| 1668 | p_hwfn->hw_info.opaque_fid, |
| 1669 | b_set); |
| 1670 | |
Yuval Mintz | b2b897e | 2016-05-15 14:48:06 +0300 | [diff] [blame] | 1671 | if (!b_slowpath) |
| 1672 | return; |
| 1673 | |
| 1674 | sb_id = p_hwfn->hw_info.p_igu_info->igu_dsb_id; |
| 1675 | DP_VERBOSE(p_hwfn, NETIF_MSG_INTR, |
| 1676 | "IGU cleaning slowpath SB [%d]\n", sb_id); |
| 1677 | qed_int_igu_init_pure_rt_single(p_hwfn, p_ptt, sb_id, |
| 1678 | p_hwfn->hw_info.opaque_fid, b_set); |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1679 | } |
| 1680 | |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 1681 | static u32 qed_int_igu_read_cam_block(struct qed_hwfn *p_hwfn, |
| 1682 | struct qed_ptt *p_ptt, u16 sb_id) |
Yuval Mintz | 4ac801b | 2016-02-28 12:26:52 +0200 | [diff] [blame] | 1683 | { |
| 1684 | u32 val = qed_rd(p_hwfn, p_ptt, |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 1685 | IGU_REG_MAPPING_MEMORY + sizeof(u32) * sb_id); |
Yuval Mintz | 4ac801b | 2016-02-28 12:26:52 +0200 | [diff] [blame] | 1686 | struct qed_igu_block *p_block; |
| 1687 | |
| 1688 | p_block = &p_hwfn->hw_info.p_igu_info->igu_map.igu_blocks[sb_id]; |
| 1689 | |
| 1690 | /* stop scanning when hit first invalid PF entry */ |
| 1691 | if (!GET_FIELD(val, IGU_MAPPING_LINE_VALID) && |
| 1692 | GET_FIELD(val, IGU_MAPPING_LINE_PF_VALID)) |
| 1693 | goto out; |
| 1694 | |
| 1695 | /* Fill the block information */ |
| 1696 | p_block->status = QED_IGU_STATUS_VALID; |
| 1697 | p_block->function_id = GET_FIELD(val, |
| 1698 | IGU_MAPPING_LINE_FUNCTION_NUMBER); |
| 1699 | p_block->is_pf = GET_FIELD(val, IGU_MAPPING_LINE_PF_VALID); |
| 1700 | p_block->vector_number = GET_FIELD(val, |
| 1701 | IGU_MAPPING_LINE_VECTOR_NUMBER); |
| 1702 | |
| 1703 | DP_VERBOSE(p_hwfn, NETIF_MSG_INTR, |
| 1704 | "IGU_BLOCK: [SB 0x%04x, Value in CAM 0x%08x] func_id = %d is_pf = %d vector_num = 0x%x\n", |
| 1705 | sb_id, val, p_block->function_id, |
| 1706 | p_block->is_pf, p_block->vector_number); |
| 1707 | |
| 1708 | out: |
| 1709 | return val; |
| 1710 | } |
| 1711 | |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 1712 | int qed_int_igu_read_cam(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1713 | { |
| 1714 | struct qed_igu_info *p_igu_info; |
Yuval Mintz | 1408cc1f | 2016-05-11 16:36:14 +0300 | [diff] [blame] | 1715 | u32 val, min_vf = 0, max_vf = 0; |
| 1716 | u16 sb_id, last_iov_sb_id = 0; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1717 | struct qed_igu_block *blk; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1718 | u16 prev_sb_id = 0xFF; |
| 1719 | |
Yuval Mintz | 60fffb3 | 2016-02-21 11:40:07 +0200 | [diff] [blame] | 1720 | p_hwfn->hw_info.p_igu_info = kzalloc(sizeof(*p_igu_info), GFP_KERNEL); |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1721 | if (!p_hwfn->hw_info.p_igu_info) |
| 1722 | return -ENOMEM; |
| 1723 | |
| 1724 | p_igu_info = p_hwfn->hw_info.p_igu_info; |
| 1725 | |
Yuval Mintz | 1408cc1f | 2016-05-11 16:36:14 +0300 | [diff] [blame] | 1726 | /* Initialize base sb / sb cnt for PFs and VFs */ |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1727 | p_igu_info->igu_base_sb = 0xffff; |
| 1728 | p_igu_info->igu_sb_cnt = 0; |
| 1729 | p_igu_info->igu_dsb_id = 0xffff; |
| 1730 | p_igu_info->igu_base_sb_iov = 0xffff; |
| 1731 | |
Yuval Mintz | 1408cc1f | 2016-05-11 16:36:14 +0300 | [diff] [blame] | 1732 | if (p_hwfn->cdev->p_iov_info) { |
| 1733 | struct qed_hw_sriov_info *p_iov = p_hwfn->cdev->p_iov_info; |
| 1734 | |
| 1735 | min_vf = p_iov->first_vf_in_pf; |
| 1736 | max_vf = p_iov->first_vf_in_pf + p_iov->total_vfs; |
| 1737 | } |
| 1738 | |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1739 | for (sb_id = 0; sb_id < QED_MAPPING_MEMORY_SIZE(p_hwfn->cdev); |
| 1740 | sb_id++) { |
| 1741 | blk = &p_igu_info->igu_map.igu_blocks[sb_id]; |
| 1742 | |
Yuval Mintz | 4ac801b | 2016-02-28 12:26:52 +0200 | [diff] [blame] | 1743 | val = qed_int_igu_read_cam_block(p_hwfn, p_ptt, sb_id); |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1744 | |
| 1745 | /* stop scanning when hit first invalid PF entry */ |
| 1746 | if (!GET_FIELD(val, IGU_MAPPING_LINE_VALID) && |
| 1747 | GET_FIELD(val, IGU_MAPPING_LINE_PF_VALID)) |
| 1748 | break; |
| 1749 | |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1750 | if (blk->is_pf) { |
| 1751 | if (blk->function_id == p_hwfn->rel_pf_id) { |
| 1752 | blk->status |= QED_IGU_STATUS_PF; |
| 1753 | |
| 1754 | if (blk->vector_number == 0) { |
| 1755 | if (p_igu_info->igu_dsb_id == 0xffff) |
| 1756 | p_igu_info->igu_dsb_id = sb_id; |
| 1757 | } else { |
| 1758 | if (p_igu_info->igu_base_sb == |
| 1759 | 0xffff) { |
| 1760 | p_igu_info->igu_base_sb = sb_id; |
| 1761 | } else if (prev_sb_id != sb_id - 1) { |
| 1762 | DP_NOTICE(p_hwfn->cdev, |
| 1763 | "consecutive igu vectors for HWFN %x broken", |
| 1764 | p_hwfn->rel_pf_id); |
| 1765 | break; |
| 1766 | } |
| 1767 | prev_sb_id = sb_id; |
| 1768 | /* we don't count the default */ |
| 1769 | (p_igu_info->igu_sb_cnt)++; |
| 1770 | } |
| 1771 | } |
Yuval Mintz | 1408cc1f | 2016-05-11 16:36:14 +0300 | [diff] [blame] | 1772 | } else { |
| 1773 | if ((blk->function_id >= min_vf) && |
| 1774 | (blk->function_id < max_vf)) { |
| 1775 | /* Available for VFs of this PF */ |
| 1776 | if (p_igu_info->igu_base_sb_iov == 0xffff) { |
| 1777 | p_igu_info->igu_base_sb_iov = sb_id; |
| 1778 | } else if (last_iov_sb_id != sb_id - 1) { |
| 1779 | if (!val) { |
| 1780 | DP_VERBOSE(p_hwfn->cdev, |
| 1781 | NETIF_MSG_INTR, |
| 1782 | "First uninitialized IGU CAM entry at index 0x%04x\n", |
| 1783 | sb_id); |
| 1784 | } else { |
| 1785 | DP_NOTICE(p_hwfn->cdev, |
| 1786 | "Consecutive igu vectors for HWFN %x vfs is broken [jumps from %04x to %04x]\n", |
| 1787 | p_hwfn->rel_pf_id, |
| 1788 | last_iov_sb_id, |
| 1789 | sb_id); } |
| 1790 | break; |
| 1791 | } |
| 1792 | blk->status |= QED_IGU_STATUS_FREE; |
| 1793 | p_hwfn->hw_info.p_igu_info->free_blks++; |
| 1794 | last_iov_sb_id = sb_id; |
| 1795 | } |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1796 | } |
| 1797 | } |
Mintz, Yuval | 5a1f965 | 2016-10-31 07:14:26 +0200 | [diff] [blame] | 1798 | |
| 1799 | /* There's a possibility the igu_sb_cnt_iov doesn't properly reflect |
| 1800 | * the number of VF SBs [especially for first VF on engine, as we can't |
Joe Perches | 8ac1ed7 | 2017-05-08 15:57:56 -0700 | [diff] [blame] | 1801 | * differentiate between empty entries and its entries]. |
Mintz, Yuval | 5a1f965 | 2016-10-31 07:14:26 +0200 | [diff] [blame] | 1802 | * Since we don't really support more SBs than VFs today, prevent any |
| 1803 | * such configuration by sanitizing the number of SBs to equal the |
| 1804 | * number of VFs. |
| 1805 | */ |
| 1806 | if (IS_PF_SRIOV(p_hwfn)) { |
| 1807 | u16 total_vfs = p_hwfn->cdev->p_iov_info->total_vfs; |
| 1808 | |
| 1809 | if (total_vfs < p_igu_info->free_blks) { |
| 1810 | DP_VERBOSE(p_hwfn, |
| 1811 | (NETIF_MSG_INTR | QED_MSG_IOV), |
| 1812 | "Limiting number of SBs for IOV - %04x --> %04x\n", |
| 1813 | p_igu_info->free_blks, |
| 1814 | p_hwfn->cdev->p_iov_info->total_vfs); |
| 1815 | p_igu_info->free_blks = total_vfs; |
| 1816 | } else if (total_vfs > p_igu_info->free_blks) { |
| 1817 | DP_NOTICE(p_hwfn, |
| 1818 | "IGU has only %04x SBs for VFs while the device has %04x VFs\n", |
| 1819 | p_igu_info->free_blks, total_vfs); |
| 1820 | return -EINVAL; |
| 1821 | } |
| 1822 | } |
Yuval Mintz | 1408cc1f | 2016-05-11 16:36:14 +0300 | [diff] [blame] | 1823 | p_igu_info->igu_sb_cnt_iov = p_igu_info->free_blks; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1824 | |
Yuval Mintz | 1408cc1f | 2016-05-11 16:36:14 +0300 | [diff] [blame] | 1825 | DP_VERBOSE( |
| 1826 | p_hwfn, |
| 1827 | NETIF_MSG_INTR, |
| 1828 | "IGU igu_base_sb=0x%x [IOV 0x%x] igu_sb_cnt=%d [IOV 0x%x] igu_dsb_id=0x%x\n", |
| 1829 | p_igu_info->igu_base_sb, |
| 1830 | p_igu_info->igu_base_sb_iov, |
| 1831 | p_igu_info->igu_sb_cnt, |
| 1832 | p_igu_info->igu_sb_cnt_iov, |
| 1833 | p_igu_info->igu_dsb_id); |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1834 | |
| 1835 | if (p_igu_info->igu_base_sb == 0xffff || |
| 1836 | p_igu_info->igu_dsb_id == 0xffff || |
| 1837 | p_igu_info->igu_sb_cnt == 0) { |
| 1838 | DP_NOTICE(p_hwfn, |
| 1839 | "IGU CAM returned invalid values igu_base_sb=0x%x igu_sb_cnt=%d igu_dsb_id=0x%x\n", |
| 1840 | p_igu_info->igu_base_sb, |
| 1841 | p_igu_info->igu_sb_cnt, |
| 1842 | p_igu_info->igu_dsb_id); |
| 1843 | return -EINVAL; |
| 1844 | } |
| 1845 | |
| 1846 | return 0; |
| 1847 | } |
| 1848 | |
| 1849 | /** |
| 1850 | * @brief Initialize igu runtime registers |
| 1851 | * |
| 1852 | * @param p_hwfn |
| 1853 | */ |
| 1854 | void qed_int_igu_init_rt(struct qed_hwfn *p_hwfn) |
| 1855 | { |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 1856 | u32 igu_pf_conf = IGU_PF_CONF_FUNC_EN; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1857 | |
| 1858 | STORE_RT_REG(p_hwfn, IGU_REG_PF_CONFIGURATION_RT_OFFSET, igu_pf_conf); |
| 1859 | } |
| 1860 | |
| 1861 | u64 qed_int_igu_read_sisr_reg(struct qed_hwfn *p_hwfn) |
| 1862 | { |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1863 | u32 lsb_igu_cmd_addr = IGU_REG_SISR_MDPC_WMASK_LSB_UPPER - |
| 1864 | IGU_CMD_INT_ACK_BASE; |
| 1865 | u32 msb_igu_cmd_addr = IGU_REG_SISR_MDPC_WMASK_MSB_UPPER - |
| 1866 | IGU_CMD_INT_ACK_BASE; |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 1867 | u32 intr_status_hi = 0, intr_status_lo = 0; |
| 1868 | u64 intr_status = 0; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1869 | |
| 1870 | intr_status_lo = REG_RD(p_hwfn, |
| 1871 | GTT_BAR0_MAP_REG_IGU_CMD + |
| 1872 | lsb_igu_cmd_addr * 8); |
| 1873 | intr_status_hi = REG_RD(p_hwfn, |
| 1874 | GTT_BAR0_MAP_REG_IGU_CMD + |
| 1875 | msb_igu_cmd_addr * 8); |
| 1876 | intr_status = ((u64)intr_status_hi << 32) + (u64)intr_status_lo; |
| 1877 | |
| 1878 | return intr_status; |
| 1879 | } |
| 1880 | |
| 1881 | static void qed_int_sp_dpc_setup(struct qed_hwfn *p_hwfn) |
| 1882 | { |
| 1883 | tasklet_init(p_hwfn->sp_dpc, |
| 1884 | qed_int_sp_dpc, (unsigned long)p_hwfn); |
| 1885 | p_hwfn->b_sp_dpc_enabled = true; |
| 1886 | } |
| 1887 | |
| 1888 | static int qed_int_sp_dpc_alloc(struct qed_hwfn *p_hwfn) |
| 1889 | { |
Yuval Mintz | 60fffb3 | 2016-02-21 11:40:07 +0200 | [diff] [blame] | 1890 | p_hwfn->sp_dpc = kmalloc(sizeof(*p_hwfn->sp_dpc), GFP_KERNEL); |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1891 | if (!p_hwfn->sp_dpc) |
| 1892 | return -ENOMEM; |
| 1893 | |
| 1894 | return 0; |
| 1895 | } |
| 1896 | |
| 1897 | static void qed_int_sp_dpc_free(struct qed_hwfn *p_hwfn) |
| 1898 | { |
| 1899 | kfree(p_hwfn->sp_dpc); |
Tomer Tayar | 3587cb8 | 2017-05-21 12:10:56 +0300 | [diff] [blame] | 1900 | p_hwfn->sp_dpc = NULL; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1901 | } |
| 1902 | |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 1903 | int qed_int_alloc(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1904 | { |
| 1905 | int rc = 0; |
| 1906 | |
| 1907 | rc = qed_int_sp_dpc_alloc(p_hwfn); |
Yuval Mintz | 83aeb93 | 2016-08-15 10:42:44 +0300 | [diff] [blame] | 1908 | if (rc) |
Joe Perches | 2591c28 | 2016-09-04 14:24:03 -0700 | [diff] [blame] | 1909 | return rc; |
| 1910 | |
| 1911 | rc = qed_int_sp_sb_alloc(p_hwfn, p_ptt); |
| 1912 | if (rc) |
| 1913 | return rc; |
| 1914 | |
| 1915 | rc = qed_int_sb_attn_alloc(p_hwfn, p_ptt); |
Yuval Mintz | 83aeb93 | 2016-08-15 10:42:44 +0300 | [diff] [blame] | 1916 | |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1917 | return rc; |
| 1918 | } |
| 1919 | |
| 1920 | void qed_int_free(struct qed_hwfn *p_hwfn) |
| 1921 | { |
| 1922 | qed_int_sp_sb_free(p_hwfn); |
Yuval Mintz | cc875c2 | 2015-10-26 11:02:31 +0200 | [diff] [blame] | 1923 | qed_int_sb_attn_free(p_hwfn); |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1924 | qed_int_sp_dpc_free(p_hwfn); |
| 1925 | } |
| 1926 | |
Yuval Mintz | 1a635e4 | 2016-08-15 10:42:43 +0300 | [diff] [blame] | 1927 | void qed_int_setup(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1928 | { |
Yuval Mintz | 0d956e8 | 2016-02-28 12:26:53 +0200 | [diff] [blame] | 1929 | qed_int_sb_setup(p_hwfn, p_ptt, &p_hwfn->p_sp_sb->sb_info); |
| 1930 | qed_int_sb_attn_setup(p_hwfn, p_ptt); |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1931 | qed_int_sp_dpc_setup(p_hwfn); |
| 1932 | } |
| 1933 | |
Yuval Mintz | 4ac801b | 2016-02-28 12:26:52 +0200 | [diff] [blame] | 1934 | void qed_int_get_num_sbs(struct qed_hwfn *p_hwfn, |
| 1935 | struct qed_sb_cnt_info *p_sb_cnt_info) |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1936 | { |
| 1937 | struct qed_igu_info *info = p_hwfn->hw_info.p_igu_info; |
| 1938 | |
Yuval Mintz | 4ac801b | 2016-02-28 12:26:52 +0200 | [diff] [blame] | 1939 | if (!info || !p_sb_cnt_info) |
| 1940 | return; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1941 | |
Yuval Mintz | 4ac801b | 2016-02-28 12:26:52 +0200 | [diff] [blame] | 1942 | p_sb_cnt_info->sb_cnt = info->igu_sb_cnt; |
| 1943 | p_sb_cnt_info->sb_iov_cnt = info->igu_sb_cnt_iov; |
| 1944 | p_sb_cnt_info->sb_free_blk = info->free_blks; |
Yuval Mintz | fe56b9e | 2015-10-26 11:02:25 +0200 | [diff] [blame] | 1945 | } |
Sudarsana Kalluru | 8f16bc9 | 2015-12-07 06:25:59 -0500 | [diff] [blame] | 1946 | |
Yuval Mintz | 1408cc1f | 2016-05-11 16:36:14 +0300 | [diff] [blame] | 1947 | u16 qed_int_queue_id_from_sb_id(struct qed_hwfn *p_hwfn, u16 sb_id) |
| 1948 | { |
| 1949 | struct qed_igu_info *p_info = p_hwfn->hw_info.p_igu_info; |
| 1950 | |
| 1951 | /* Determine origin of SB id */ |
| 1952 | if ((sb_id >= p_info->igu_base_sb) && |
| 1953 | (sb_id < p_info->igu_base_sb + p_info->igu_sb_cnt)) { |
| 1954 | return sb_id - p_info->igu_base_sb; |
| 1955 | } else if ((sb_id >= p_info->igu_base_sb_iov) && |
| 1956 | (sb_id < p_info->igu_base_sb_iov + p_info->igu_sb_cnt_iov)) { |
Mintz, Yuval | 5a1f965 | 2016-10-31 07:14:26 +0200 | [diff] [blame] | 1957 | /* We want the first VF queue to be adjacent to the |
| 1958 | * last PF queue. Since L2 queues can be partial to |
| 1959 | * SBs, we'll use the feature instead. |
| 1960 | */ |
| 1961 | return sb_id - p_info->igu_base_sb_iov + |
| 1962 | FEAT_NUM(p_hwfn, QED_PF_L2_QUE); |
Yuval Mintz | 1408cc1f | 2016-05-11 16:36:14 +0300 | [diff] [blame] | 1963 | } else { |
| 1964 | DP_NOTICE(p_hwfn, "SB %d not in range for function\n", sb_id); |
| 1965 | return 0; |
| 1966 | } |
| 1967 | } |
| 1968 | |
Sudarsana Kalluru | 8f16bc9 | 2015-12-07 06:25:59 -0500 | [diff] [blame] | 1969 | void qed_int_disable_post_isr_release(struct qed_dev *cdev) |
| 1970 | { |
| 1971 | int i; |
| 1972 | |
| 1973 | for_each_hwfn(cdev, i) |
| 1974 | cdev->hwfns[i].b_int_requested = false; |
| 1975 | } |
Sudarsana Reddy Kalluru | 722003a | 2016-06-21 09:36:21 -0400 | [diff] [blame] | 1976 | |
| 1977 | int qed_int_set_timer_res(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, |
| 1978 | u8 timer_res, u16 sb_id, bool tx) |
| 1979 | { |
| 1980 | struct cau_sb_entry sb_entry; |
| 1981 | int rc; |
| 1982 | |
| 1983 | if (!p_hwfn->hw_init_done) { |
| 1984 | DP_ERR(p_hwfn, "hardware not initialized yet\n"); |
| 1985 | return -EINVAL; |
| 1986 | } |
| 1987 | |
| 1988 | rc = qed_dmae_grc2host(p_hwfn, p_ptt, CAU_REG_SB_VAR_MEMORY + |
| 1989 | sb_id * sizeof(u64), |
| 1990 | (u64)(uintptr_t)&sb_entry, 2, 0); |
| 1991 | if (rc) { |
| 1992 | DP_ERR(p_hwfn, "dmae_grc2host failed %d\n", rc); |
| 1993 | return rc; |
| 1994 | } |
| 1995 | |
| 1996 | if (tx) |
| 1997 | SET_FIELD(sb_entry.params, CAU_SB_ENTRY_TIMER_RES1, timer_res); |
| 1998 | else |
| 1999 | SET_FIELD(sb_entry.params, CAU_SB_ENTRY_TIMER_RES0, timer_res); |
| 2000 | |
| 2001 | rc = qed_dmae_host2grc(p_hwfn, p_ptt, |
| 2002 | (u64)(uintptr_t)&sb_entry, |
| 2003 | CAU_REG_SB_VAR_MEMORY + |
| 2004 | sb_id * sizeof(u64), 2, 0); |
| 2005 | if (rc) { |
| 2006 | DP_ERR(p_hwfn, "dmae_host2grc failed %d\n", rc); |
| 2007 | return rc; |
| 2008 | } |
| 2009 | |
| 2010 | return rc; |
| 2011 | } |