Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(C) 2021 Marvell.
3 : : */
4 : :
5 : : #include "roc_api.h"
6 : : #include "roc_priv.h"
7 : :
8 : : static void
9 : 0 : tim_lf_irq(void *param)
10 : : {
11 : 0 : uintptr_t base = (uintptr_t)param;
12 : : uint64_t intr;
13 : : uint8_t ring;
14 : :
15 : 0 : ring = (base >> 12) & 0xFF;
16 : :
17 : 0 : intr = plt_read64(base + TIM_LF_NRSPERR_INT);
18 : 0 : plt_err("TIM RING %d TIM_LF_NRSPERR_INT=0x%" PRIx64 "", ring, intr);
19 : 0 : intr = plt_read64(base + TIM_LF_RAS_INT);
20 : 0 : plt_err("TIM RING %d TIM_LF_RAS_INT=0x%" PRIx64 "", ring, intr);
21 : :
22 : : /* Clear interrupt */
23 : : plt_write64(intr, base + TIM_LF_NRSPERR_INT);
24 : : plt_write64(intr, base + TIM_LF_RAS_INT);
25 : 0 : }
26 : :
27 : : static int
28 : 0 : tim_lf_register_irq(uintptr_t base, struct plt_intr_handle *handle,
29 : : uint16_t msix_offset)
30 : : {
31 : : unsigned int vec;
32 : : int rc;
33 : :
34 : 0 : vec = msix_offset + TIM_LF_INT_VEC_NRSPERR_INT;
35 : :
36 : : /* Clear err interrupt */
37 : 0 : plt_write64(~0ull, base + TIM_LF_NRSPERR_INT);
38 : : /* Set used interrupt vectors */
39 : 0 : rc = dev_irq_register(handle, tim_lf_irq, (void *)base, vec);
40 : : /* Enable hw interrupt */
41 : 0 : plt_write64(~0ull, base + TIM_LF_NRSPERR_INT_ENA_W1S);
42 : :
43 : 0 : vec = msix_offset + TIM_LF_INT_VEC_RAS_INT;
44 : :
45 : : /* Clear err interrupt */
46 : 0 : plt_write64(~0ull, base + TIM_LF_RAS_INT);
47 : : /* Set used interrupt vectors */
48 : 0 : rc = dev_irq_register(handle, tim_lf_irq, (void *)base, vec);
49 : : /* Enable hw interrupt */
50 : 0 : plt_write64(~0ull, base + TIM_LF_RAS_INT_ENA_W1S);
51 : :
52 : 0 : return rc;
53 : : }
54 : :
55 : : int
56 : 0 : tim_register_irq_priv(struct roc_tim *roc_tim, struct plt_intr_handle *handle,
57 : : uint8_t ring_id, uint16_t msix_offset)
58 : : {
59 : 0 : struct dev *dev = &roc_sso_to_sso_priv(roc_tim->roc_sso)->dev;
60 : : uintptr_t base;
61 : :
62 [ # # ]: 0 : if (msix_offset == MSIX_VECTOR_INVALID) {
63 : 0 : plt_err("Invalid MSIX offset for TIM LF %d", ring_id);
64 : 0 : return TIM_ERR_PARAM;
65 : : }
66 : :
67 : 0 : base = dev->bar2 + (RVU_BLOCK_ADDR_TIM << 20 | ring_id << 12);
68 : 0 : return tim_lf_register_irq(base, handle, msix_offset);
69 : : }
70 : :
71 : : static void
72 : 0 : tim_lf_unregister_irq(uintptr_t base, struct plt_intr_handle *handle,
73 : : uint16_t msix_offset)
74 : : {
75 : : unsigned int vec;
76 : :
77 : 0 : vec = msix_offset + TIM_LF_INT_VEC_NRSPERR_INT;
78 : :
79 : : /* Clear err interrupt */
80 : 0 : plt_write64(~0ull, base + TIM_LF_NRSPERR_INT_ENA_W1C);
81 : 0 : dev_irq_unregister(handle, tim_lf_irq, (void *)base, vec);
82 : :
83 : 0 : vec = msix_offset + TIM_LF_INT_VEC_RAS_INT;
84 : :
85 : : /* Clear err interrupt */
86 : 0 : plt_write64(~0ull, base + TIM_LF_RAS_INT_ENA_W1C);
87 : 0 : dev_irq_unregister(handle, tim_lf_irq, (void *)base, vec);
88 : 0 : }
89 : :
90 : : void
91 : 0 : tim_unregister_irq_priv(struct roc_tim *roc_tim, struct plt_intr_handle *handle,
92 : : uint8_t ring_id, uint16_t msix_offset)
93 : : {
94 : 0 : struct dev *dev = &roc_sso_to_sso_priv(roc_tim->roc_sso)->dev;
95 : : uintptr_t base;
96 : :
97 [ # # ]: 0 : if (msix_offset == MSIX_VECTOR_INVALID) {
98 : 0 : plt_err("Invalid MSIX offset for TIM LF %d", ring_id);
99 : 0 : return;
100 : : }
101 : :
102 : 0 : base = dev->bar2 + (RVU_BLOCK_ADDR_TIM << 20 | ring_id << 12);
103 : 0 : tim_lf_unregister_irq(base, handle, msix_offset);
104 : : }
|