1 /* QLogic qed NIC Driver
2 * Copyright (c) 2015 QLogic Corporation
4 * This software is available under the terms of the GNU General Public License
5 * (GPL) Version 2, available from the file COPYING in the main directory of
9 #include <linux/types.h>
10 #include <asm/byteorder.h>
12 #include <linux/bitops.h>
13 #include <linux/delay.h>
14 #include <linux/dma-mapping.h>
15 #include <linux/errno.h>
16 #include <linux/interrupt.h>
17 #include <linux/kernel.h>
18 #include <linux/pci.h>
19 #include <linux/slab.h>
20 #include <linux/string.h>
24 #include "qed_init_ops.h"
27 #include "qed_reg_addr.h"
31 qed_int_comp_cb_t comp_cb;
35 struct qed_sb_sp_info {
36 struct qed_sb_info sb_info;
38 /* per protocol index data */
39 struct qed_pi_info pi_info_arr[PIS_PER_SB];
42 void qed_int_sp_dpc(unsigned long hwfn_cookie)
44 struct qed_hwfn *p_hwfn = (struct qed_hwfn *)hwfn_cookie;
45 struct qed_pi_info *pi_info = NULL;
46 struct qed_sb_info *sb_info;
51 DP_ERR(p_hwfn->cdev, "DPC called - no hwfn!\n");
55 if (!p_hwfn->p_sp_sb) {
56 DP_ERR(p_hwfn->cdev, "DPC called - no p_sp_sb\n");
60 sb_info = &p_hwfn->p_sp_sb->sb_info;
61 arr_size = ARRAY_SIZE(p_hwfn->p_sp_sb->pi_info_arr);
64 "Status block is NULL - cannot ack interrupts\n");
68 DP_VERBOSE(p_hwfn, NETIF_MSG_INTR, "DPC Called! (hwfn %p %d)\n",
69 p_hwfn, p_hwfn->my_id);
71 /* Disable ack for def status block. Required both for msix +
72 * inta in non-mask mode, in inta does no harm.
74 qed_sb_ack(sb_info, IGU_INT_DISABLE, 0);
76 /* Gather Interrupts/Attentions information */
77 if (!sb_info->sb_virt) {
80 "Interrupt Status block is NULL - cannot check for new interrupts!\n");
82 u32 tmp_index = sb_info->sb_ack;
84 rc = qed_sb_update_sb_idx(sb_info);
85 DP_VERBOSE(p_hwfn->cdev, NETIF_MSG_INTR,
86 "Interrupt indices: 0x%08x --> 0x%08x\n",
87 tmp_index, sb_info->sb_ack);
90 /* Check if we expect interrupts at this time. if not just ack them */
91 if (!(rc & QED_SB_EVENT_MASK)) {
92 qed_sb_ack(sb_info, IGU_INT_ENABLE, 1);
96 /* Check the validity of the DPC ptt. If not ack interrupts and fail */
97 if (!p_hwfn->p_dpc_ptt) {
98 DP_NOTICE(p_hwfn->cdev, "Failed to allocate PTT\n");
99 qed_sb_ack(sb_info, IGU_INT_ENABLE, 1);
103 if (rc & QED_SB_IDX) {
106 /* Look for a free index */
107 for (pi = 0; pi < arr_size; pi++) {
108 pi_info = &p_hwfn->p_sp_sb->pi_info_arr[pi];
109 if (pi_info->comp_cb)
110 pi_info->comp_cb(p_hwfn, pi_info->cookie);
114 qed_sb_ack(sb_info, IGU_INT_ENABLE, 1);
117 /* coalescing timeout = timeset << (timer_res + 1) */
118 #define QED_CAU_DEF_RX_USECS 24
119 #define QED_CAU_DEF_TX_USECS 48
121 void qed_init_cau_sb_entry(struct qed_hwfn *p_hwfn,
122 struct cau_sb_entry *p_sb_entry,
129 memset(p_sb_entry, 0, sizeof(*p_sb_entry));
131 SET_FIELD(p_sb_entry->params, CAU_SB_ENTRY_PF_NUMBER, pf_id);
132 SET_FIELD(p_sb_entry->params, CAU_SB_ENTRY_VF_NUMBER, vf_number);
133 SET_FIELD(p_sb_entry->params, CAU_SB_ENTRY_VF_VALID, vf_valid);
134 SET_FIELD(p_sb_entry->params, CAU_SB_ENTRY_SB_TIMESET0, 0x7F);
135 SET_FIELD(p_sb_entry->params, CAU_SB_ENTRY_SB_TIMESET1, 0x7F);
137 /* setting the time resultion to a fixed value ( = 1) */
138 SET_FIELD(p_sb_entry->params, CAU_SB_ENTRY_TIMER_RES0,
139 QED_CAU_DEF_RX_TIMER_RES);
140 SET_FIELD(p_sb_entry->params, CAU_SB_ENTRY_TIMER_RES1,
141 QED_CAU_DEF_TX_TIMER_RES);
143 cau_state = CAU_HC_DISABLE_STATE;
145 if (p_hwfn->cdev->int_coalescing_mode == QED_COAL_MODE_ENABLE) {
146 cau_state = CAU_HC_ENABLE_STATE;
147 if (!p_hwfn->cdev->rx_coalesce_usecs)
148 p_hwfn->cdev->rx_coalesce_usecs =
149 QED_CAU_DEF_RX_USECS;
150 if (!p_hwfn->cdev->tx_coalesce_usecs)
151 p_hwfn->cdev->tx_coalesce_usecs =
152 QED_CAU_DEF_TX_USECS;
155 SET_FIELD(p_sb_entry->data, CAU_SB_ENTRY_STATE0, cau_state);
156 SET_FIELD(p_sb_entry->data, CAU_SB_ENTRY_STATE1, cau_state);
159 void qed_int_cau_conf_sb(struct qed_hwfn *p_hwfn,
160 struct qed_ptt *p_ptt,
166 struct cau_sb_entry sb_entry;
169 qed_init_cau_sb_entry(p_hwfn, &sb_entry, p_hwfn->rel_pf_id,
170 vf_number, vf_valid);
172 if (p_hwfn->hw_init_done) {
173 val = CAU_REG_SB_ADDR_MEMORY + igu_sb_id * sizeof(u64);
174 qed_wr(p_hwfn, p_ptt, val, lower_32_bits(sb_phys));
175 qed_wr(p_hwfn, p_ptt, val + sizeof(u32),
176 upper_32_bits(sb_phys));
178 val = CAU_REG_SB_VAR_MEMORY + igu_sb_id * sizeof(u64);
179 qed_wr(p_hwfn, p_ptt, val, sb_entry.data);
180 qed_wr(p_hwfn, p_ptt, val + sizeof(u32), sb_entry.params);
182 /* Initialize Status Block Address */
183 STORE_RT_REG_AGG(p_hwfn,
184 CAU_REG_SB_ADDR_MEMORY_RT_OFFSET +
188 STORE_RT_REG_AGG(p_hwfn,
189 CAU_REG_SB_VAR_MEMORY_RT_OFFSET +
194 /* Configure pi coalescing if set */
195 if (p_hwfn->cdev->int_coalescing_mode == QED_COAL_MODE_ENABLE) {
196 u8 timeset = p_hwfn->cdev->rx_coalesce_usecs >>
197 (QED_CAU_DEF_RX_TIMER_RES + 1);
200 qed_int_cau_conf_pi(p_hwfn, p_ptt, igu_sb_id, RX_PI,
201 QED_COAL_RX_STATE_MACHINE,
204 timeset = p_hwfn->cdev->tx_coalesce_usecs >>
205 (QED_CAU_DEF_TX_TIMER_RES + 1);
207 for (i = 0; i < num_tc; i++) {
208 qed_int_cau_conf_pi(p_hwfn, p_ptt,
210 QED_COAL_TX_STATE_MACHINE,
216 void qed_int_cau_conf_pi(struct qed_hwfn *p_hwfn,
217 struct qed_ptt *p_ptt,
220 enum qed_coalescing_fsm coalescing_fsm,
223 struct cau_pi_entry pi_entry;
227 sb_offset = igu_sb_id * PIS_PER_SB;
228 memset(&pi_entry, 0, sizeof(struct cau_pi_entry));
230 SET_FIELD(pi_entry.prod, CAU_PI_ENTRY_PI_TIMESET, timeset);
231 if (coalescing_fsm == QED_COAL_RX_STATE_MACHINE)
232 SET_FIELD(pi_entry.prod, CAU_PI_ENTRY_FSM_SEL, 0);
234 SET_FIELD(pi_entry.prod, CAU_PI_ENTRY_FSM_SEL, 1);
236 pi_offset = sb_offset + pi_index;
237 if (p_hwfn->hw_init_done) {
238 qed_wr(p_hwfn, p_ptt,
239 CAU_REG_PI_MEMORY + pi_offset * sizeof(u32),
240 *((u32 *)&(pi_entry)));
243 CAU_REG_PI_MEMORY_RT_OFFSET + pi_offset,
244 *((u32 *)&(pi_entry)));
248 void qed_int_sb_setup(struct qed_hwfn *p_hwfn,
249 struct qed_ptt *p_ptt,
250 struct qed_sb_info *sb_info)
252 /* zero status block and ack counter */
254 memset(sb_info->sb_virt, 0, sizeof(*sb_info->sb_virt));
256 qed_int_cau_conf_sb(p_hwfn, p_ptt, sb_info->sb_phys,
257 sb_info->igu_sb_id, 0, 0);
261 * @brief qed_get_igu_sb_id - given a sw sb_id return the
269 static u16 qed_get_igu_sb_id(struct qed_hwfn *p_hwfn,
274 /* Assuming continuous set of IGU SBs dedicated for given PF */
275 if (sb_id == QED_SP_SB_ID)
276 igu_sb_id = p_hwfn->hw_info.p_igu_info->igu_dsb_id;
278 igu_sb_id = sb_id + p_hwfn->hw_info.p_igu_info->igu_base_sb;
280 DP_VERBOSE(p_hwfn, NETIF_MSG_INTR, "SB [%s] index is 0x%04x\n",
281 (sb_id == QED_SP_SB_ID) ? "DSB" : "non-DSB", igu_sb_id);
286 int qed_int_sb_init(struct qed_hwfn *p_hwfn,
287 struct qed_ptt *p_ptt,
288 struct qed_sb_info *sb_info,
290 dma_addr_t sb_phy_addr,
293 sb_info->sb_virt = sb_virt_addr;
294 sb_info->sb_phys = sb_phy_addr;
296 sb_info->igu_sb_id = qed_get_igu_sb_id(p_hwfn, sb_id);
298 if (sb_id != QED_SP_SB_ID) {
299 p_hwfn->sbs_info[sb_id] = sb_info;
303 sb_info->cdev = p_hwfn->cdev;
305 /* The igu address will hold the absolute address that needs to be
306 * written to for a specific status block
308 sb_info->igu_addr = (u8 __iomem *)p_hwfn->regview +
309 GTT_BAR0_MAP_REG_IGU_CMD +
310 (sb_info->igu_sb_id << 3);
312 sb_info->flags |= QED_SB_INFO_INIT;
314 qed_int_sb_setup(p_hwfn, p_ptt, sb_info);
319 int qed_int_sb_release(struct qed_hwfn *p_hwfn,
320 struct qed_sb_info *sb_info,
323 if (sb_id == QED_SP_SB_ID) {
324 DP_ERR(p_hwfn, "Do Not free sp sb using this function");
328 /* zero status block and ack counter */
330 memset(sb_info->sb_virt, 0, sizeof(*sb_info->sb_virt));
332 p_hwfn->sbs_info[sb_id] = NULL;
338 static void qed_int_sp_sb_free(struct qed_hwfn *p_hwfn)
340 struct qed_sb_sp_info *p_sb = p_hwfn->p_sp_sb;
343 if (p_sb->sb_info.sb_virt)
344 dma_free_coherent(&p_hwfn->cdev->pdev->dev,
345 SB_ALIGNED_SIZE(p_hwfn),
346 p_sb->sb_info.sb_virt,
347 p_sb->sb_info.sb_phys);
352 static int qed_int_sp_sb_alloc(struct qed_hwfn *p_hwfn,
353 struct qed_ptt *p_ptt)
355 struct qed_sb_sp_info *p_sb;
356 dma_addr_t p_phys = 0;
360 p_sb = kmalloc(sizeof(*p_sb), GFP_ATOMIC);
362 DP_NOTICE(p_hwfn, "Failed to allocate `struct qed_sb_info'\n");
367 p_virt = dma_alloc_coherent(&p_hwfn->cdev->pdev->dev,
368 SB_ALIGNED_SIZE(p_hwfn),
369 &p_phys, GFP_KERNEL);
371 DP_NOTICE(p_hwfn, "Failed to allocate status block\n");
376 /* Status Block setup */
377 p_hwfn->p_sp_sb = p_sb;
378 qed_int_sb_init(p_hwfn, p_ptt, &p_sb->sb_info, p_virt,
379 p_phys, QED_SP_SB_ID);
381 memset(p_sb->pi_info_arr, 0, sizeof(p_sb->pi_info_arr));
386 static void qed_int_sp_sb_setup(struct qed_hwfn *p_hwfn,
387 struct qed_ptt *p_ptt)
393 qed_int_sb_setup(p_hwfn, p_ptt, &p_hwfn->p_sp_sb->sb_info);
395 DP_NOTICE(p_hwfn->cdev,
396 "Failed to setup Slow path status block - NULL pointer\n");
399 int qed_int_register_cb(struct qed_hwfn *p_hwfn,
400 qed_int_comp_cb_t comp_cb,
405 struct qed_sb_sp_info *p_sp_sb = p_hwfn->p_sp_sb;
406 int qed_status = -ENOMEM;
409 /* Look for a free index */
410 for (pi = 0; pi < ARRAY_SIZE(p_sp_sb->pi_info_arr); pi++) {
411 if (!p_sp_sb->pi_info_arr[pi].comp_cb) {
412 p_sp_sb->pi_info_arr[pi].comp_cb = comp_cb;
413 p_sp_sb->pi_info_arr[pi].cookie = cookie;
415 *p_fw_cons = &p_sp_sb->sb_info.sb_virt->pi_array[pi];
424 int qed_int_unregister_cb(struct qed_hwfn *p_hwfn, u8 pi)
426 struct qed_sb_sp_info *p_sp_sb = p_hwfn->p_sp_sb;
427 int qed_status = -ENOMEM;
429 if (p_sp_sb->pi_info_arr[pi].comp_cb) {
430 p_sp_sb->pi_info_arr[pi].comp_cb = NULL;
431 p_sp_sb->pi_info_arr[pi].cookie = NULL;
438 u16 qed_int_get_sp_sb_id(struct qed_hwfn *p_hwfn)
440 return p_hwfn->p_sp_sb->sb_info.igu_sb_id;
443 void qed_int_igu_enable_int(struct qed_hwfn *p_hwfn,
444 struct qed_ptt *p_ptt,
445 enum qed_int_mode int_mode)
447 u32 igu_pf_conf = IGU_PF_CONF_FUNC_EN;
449 p_hwfn->cdev->int_mode = int_mode;
450 switch (p_hwfn->cdev->int_mode) {
451 case QED_INT_MODE_INTA:
452 igu_pf_conf |= IGU_PF_CONF_INT_LINE_EN;
453 igu_pf_conf |= IGU_PF_CONF_SINGLE_ISR_EN;
456 case QED_INT_MODE_MSI:
457 igu_pf_conf |= IGU_PF_CONF_MSI_MSIX_EN;
458 igu_pf_conf |= IGU_PF_CONF_SINGLE_ISR_EN;
461 case QED_INT_MODE_MSIX:
462 igu_pf_conf |= IGU_PF_CONF_MSI_MSIX_EN;
464 case QED_INT_MODE_POLL:
468 qed_wr(p_hwfn, p_ptt, IGU_REG_PF_CONFIGURATION, igu_pf_conf);
471 void qed_int_igu_enable(struct qed_hwfn *p_hwfn,
472 struct qed_ptt *p_ptt,
473 enum qed_int_mode int_mode)
477 p_hwfn->b_int_enabled = 1;
479 /* Mask non-link attentions */
480 for (i = 0; i < 9; i++)
481 qed_wr(p_hwfn, p_ptt,
482 MISC_REG_AEU_ENABLE1_IGU_OUT_0 + (i << 2), 0);
484 /* Enable interrupt Generation */
485 qed_int_igu_enable_int(p_hwfn, p_ptt, int_mode);
487 /* Flush the writes to IGU */
491 void qed_int_igu_disable_int(struct qed_hwfn *p_hwfn,
492 struct qed_ptt *p_ptt)
494 p_hwfn->b_int_enabled = 0;
496 qed_wr(p_hwfn, p_ptt, IGU_REG_PF_CONFIGURATION, 0);
499 #define IGU_CLEANUP_SLEEP_LENGTH (1000)
500 void qed_int_igu_cleanup_sb(struct qed_hwfn *p_hwfn,
501 struct qed_ptt *p_ptt,
507 u32 pxp_addr = IGU_CMD_INT_ACK_BASE + sb_id;
508 u32 sleep_cnt = IGU_CLEANUP_SLEEP_LENGTH;
515 /* Set the data field */
516 SET_FIELD(data, IGU_CLEANUP_CLEANUP_SET, cleanup_set ? 1 : 0);
517 SET_FIELD(data, IGU_CLEANUP_CLEANUP_TYPE, 0);
518 SET_FIELD(data, IGU_CLEANUP_COMMAND_TYPE, IGU_COMMAND_TYPE_SET);
520 /* Set the control register */
521 SET_FIELD(cmd_ctrl, IGU_CTRL_REG_PXP_ADDR, pxp_addr);
522 SET_FIELD(cmd_ctrl, IGU_CTRL_REG_FID, opaque_fid);
523 SET_FIELD(cmd_ctrl, IGU_CTRL_REG_TYPE, IGU_CTRL_CMD_TYPE_WR);
525 qed_wr(p_hwfn, p_ptt, IGU_REG_COMMAND_REG_32LSB_DATA, data);
529 qed_wr(p_hwfn, p_ptt, IGU_REG_COMMAND_REG_CTRL, cmd_ctrl);
531 /* Flush the write to IGU */
534 /* calculate where to read the status bit from */
535 sb_bit = 1 << (sb_id % 32);
536 sb_bit_addr = sb_id / 32 * sizeof(u32);
538 sb_bit_addr += IGU_REG_CLEANUP_STATUS_0;
540 /* Now wait for the command to complete */
542 val = qed_rd(p_hwfn, p_ptt, sb_bit_addr);
544 if ((val & sb_bit) == (cleanup_set ? sb_bit : 0))
547 usleep_range(5000, 10000);
548 } while (--sleep_cnt);
552 "Timeout waiting for clear status 0x%08x [for sb %d]\n",
556 void qed_int_igu_init_pure_rt_single(struct qed_hwfn *p_hwfn,
557 struct qed_ptt *p_ptt,
566 qed_int_igu_cleanup_sb(p_hwfn, p_ptt, sb_id, 1, opaque);
569 qed_int_igu_cleanup_sb(p_hwfn, p_ptt, sb_id, 0, opaque);
571 /* Clear the CAU for the SB */
572 for (pi = 0; pi < 12; pi++)
573 qed_wr(p_hwfn, p_ptt,
574 CAU_REG_PI_MEMORY + (sb_id * 12 + pi) * 4, 0);
577 void qed_int_igu_init_pure_rt(struct qed_hwfn *p_hwfn,
578 struct qed_ptt *p_ptt,
582 u32 igu_base_sb = p_hwfn->hw_info.p_igu_info->igu_base_sb;
583 u32 igu_sb_cnt = p_hwfn->hw_info.p_igu_info->igu_sb_cnt;
587 val = qed_rd(p_hwfn, p_ptt, IGU_REG_BLOCK_CONFIGURATION);
588 val |= IGU_REG_BLOCK_CONFIGURATION_VF_CLEANUP_EN;
589 val &= ~IGU_REG_BLOCK_CONFIGURATION_PXP_TPH_INTERFACE_EN;
590 qed_wr(p_hwfn, p_ptt, IGU_REG_BLOCK_CONFIGURATION, val);
592 DP_VERBOSE(p_hwfn, NETIF_MSG_INTR,
593 "IGU cleaning SBs [%d,...,%d]\n",
594 igu_base_sb, igu_base_sb + igu_sb_cnt - 1);
596 for (sb_id = igu_base_sb; sb_id < igu_base_sb + igu_sb_cnt; sb_id++)
597 qed_int_igu_init_pure_rt_single(p_hwfn, p_ptt, sb_id,
598 p_hwfn->hw_info.opaque_fid,
602 sb_id = p_hwfn->hw_info.p_igu_info->igu_dsb_id;
603 DP_VERBOSE(p_hwfn, NETIF_MSG_INTR,
604 "IGU cleaning slowpath SB [%d]\n", sb_id);
605 qed_int_igu_init_pure_rt_single(p_hwfn, p_ptt, sb_id,
606 p_hwfn->hw_info.opaque_fid,
611 int qed_int_igu_read_cam(struct qed_hwfn *p_hwfn,
612 struct qed_ptt *p_ptt)
614 struct qed_igu_info *p_igu_info;
615 struct qed_igu_block *blk;
618 u16 prev_sb_id = 0xFF;
620 p_hwfn->hw_info.p_igu_info = kzalloc(sizeof(*p_igu_info), GFP_ATOMIC);
622 if (!p_hwfn->hw_info.p_igu_info)
625 p_igu_info = p_hwfn->hw_info.p_igu_info;
627 /* Initialize base sb / sb cnt for PFs */
628 p_igu_info->igu_base_sb = 0xffff;
629 p_igu_info->igu_sb_cnt = 0;
630 p_igu_info->igu_dsb_id = 0xffff;
631 p_igu_info->igu_base_sb_iov = 0xffff;
633 for (sb_id = 0; sb_id < QED_MAPPING_MEMORY_SIZE(p_hwfn->cdev);
635 blk = &p_igu_info->igu_map.igu_blocks[sb_id];
637 val = qed_rd(p_hwfn, p_ptt,
638 IGU_REG_MAPPING_MEMORY + sizeof(u32) * sb_id);
640 /* stop scanning when hit first invalid PF entry */
641 if (!GET_FIELD(val, IGU_MAPPING_LINE_VALID) &&
642 GET_FIELD(val, IGU_MAPPING_LINE_PF_VALID))
645 blk->status = QED_IGU_STATUS_VALID;
646 blk->function_id = GET_FIELD(val,
647 IGU_MAPPING_LINE_FUNCTION_NUMBER);
648 blk->is_pf = GET_FIELD(val, IGU_MAPPING_LINE_PF_VALID);
649 blk->vector_number = GET_FIELD(val,
650 IGU_MAPPING_LINE_VECTOR_NUMBER);
652 DP_VERBOSE(p_hwfn, NETIF_MSG_INTR,
653 "IGU_BLOCK[sb_id]:%x:func_id = %d is_pf = %d vector_num = 0x%x\n",
654 val, blk->function_id, blk->is_pf,
658 if (blk->function_id == p_hwfn->rel_pf_id) {
659 blk->status |= QED_IGU_STATUS_PF;
661 if (blk->vector_number == 0) {
662 if (p_igu_info->igu_dsb_id == 0xffff)
663 p_igu_info->igu_dsb_id = sb_id;
665 if (p_igu_info->igu_base_sb ==
667 p_igu_info->igu_base_sb = sb_id;
668 } else if (prev_sb_id != sb_id - 1) {
669 DP_NOTICE(p_hwfn->cdev,
670 "consecutive igu vectors for HWFN %x broken",
675 /* we don't count the default */
676 (p_igu_info->igu_sb_cnt)++;
682 DP_VERBOSE(p_hwfn, NETIF_MSG_INTR,
683 "IGU igu_base_sb=0x%x igu_sb_cnt=%d igu_dsb_id=0x%x\n",
684 p_igu_info->igu_base_sb,
685 p_igu_info->igu_sb_cnt,
686 p_igu_info->igu_dsb_id);
688 if (p_igu_info->igu_base_sb == 0xffff ||
689 p_igu_info->igu_dsb_id == 0xffff ||
690 p_igu_info->igu_sb_cnt == 0) {
692 "IGU CAM returned invalid values igu_base_sb=0x%x igu_sb_cnt=%d igu_dsb_id=0x%x\n",
693 p_igu_info->igu_base_sb,
694 p_igu_info->igu_sb_cnt,
695 p_igu_info->igu_dsb_id);
703 * @brief Initialize igu runtime registers
707 void qed_int_igu_init_rt(struct qed_hwfn *p_hwfn)
711 igu_pf_conf |= IGU_PF_CONF_FUNC_EN;
713 STORE_RT_REG(p_hwfn, IGU_REG_PF_CONFIGURATION_RT_OFFSET, igu_pf_conf);
716 u64 qed_int_igu_read_sisr_reg(struct qed_hwfn *p_hwfn)
719 u32 intr_status_lo = 0;
720 u32 intr_status_hi = 0;
721 u32 lsb_igu_cmd_addr = IGU_REG_SISR_MDPC_WMASK_LSB_UPPER -
722 IGU_CMD_INT_ACK_BASE;
723 u32 msb_igu_cmd_addr = IGU_REG_SISR_MDPC_WMASK_MSB_UPPER -
724 IGU_CMD_INT_ACK_BASE;
726 intr_status_lo = REG_RD(p_hwfn,
727 GTT_BAR0_MAP_REG_IGU_CMD +
728 lsb_igu_cmd_addr * 8);
729 intr_status_hi = REG_RD(p_hwfn,
730 GTT_BAR0_MAP_REG_IGU_CMD +
731 msb_igu_cmd_addr * 8);
732 intr_status = ((u64)intr_status_hi << 32) + (u64)intr_status_lo;
737 static void qed_int_sp_dpc_setup(struct qed_hwfn *p_hwfn)
739 tasklet_init(p_hwfn->sp_dpc,
740 qed_int_sp_dpc, (unsigned long)p_hwfn);
741 p_hwfn->b_sp_dpc_enabled = true;
744 static int qed_int_sp_dpc_alloc(struct qed_hwfn *p_hwfn)
746 p_hwfn->sp_dpc = kmalloc(sizeof(*p_hwfn->sp_dpc), GFP_ATOMIC);
753 static void qed_int_sp_dpc_free(struct qed_hwfn *p_hwfn)
755 kfree(p_hwfn->sp_dpc);
758 int qed_int_alloc(struct qed_hwfn *p_hwfn,
759 struct qed_ptt *p_ptt)
763 rc = qed_int_sp_dpc_alloc(p_hwfn);
765 DP_ERR(p_hwfn->cdev, "Failed to allocate sp dpc mem\n");
768 rc = qed_int_sp_sb_alloc(p_hwfn, p_ptt);
770 DP_ERR(p_hwfn->cdev, "Failed to allocate sp sb mem\n");
777 void qed_int_free(struct qed_hwfn *p_hwfn)
779 qed_int_sp_sb_free(p_hwfn);
780 qed_int_sp_dpc_free(p_hwfn);
783 void qed_int_setup(struct qed_hwfn *p_hwfn,
784 struct qed_ptt *p_ptt)
786 qed_int_sp_sb_setup(p_hwfn, p_ptt);
787 qed_int_sp_dpc_setup(p_hwfn);
790 int qed_int_get_num_sbs(struct qed_hwfn *p_hwfn,
793 struct qed_igu_info *info = p_hwfn->hw_info.p_igu_info;
799 *p_iov_blks = info->free_blks;
801 return info->igu_sb_cnt;