1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright 2014 Cisco Systems, Inc. All rights reserved. */
10 #define VNIC_INTR_TIMER_MAX 0xffff
12 #define VNIC_INTR_TIMER_TYPE_ABS 0
13 #define VNIC_INTR_TIMER_TYPE_QUIET 1
15 /* Interrupt control */
16 struct vnic_intr_ctrl
{
17 u32 coalescing_timer
; /* 0x00 */
19 u32 coalescing_value
; /* 0x08 */
21 u32 coalescing_type
; /* 0x10 */
23 u32 mask_on_assertion
; /* 0x18 */
27 u32 int_credits
; /* 0x28 */
29 u32 int_credit_return
; /* 0x30 */
35 struct vnic_dev
*vdev
;
36 struct vnic_intr_ctrl __iomem
*ctrl
; /* memory-mapped */
40 svnic_intr_unmask(struct vnic_intr
*intr
)
42 iowrite32(0, &intr
->ctrl
->mask
);
46 svnic_intr_mask(struct vnic_intr
*intr
)
48 iowrite32(1, &intr
->ctrl
->mask
);
52 svnic_intr_return_credits(struct vnic_intr
*intr
,
57 #define VNIC_INTR_UNMASK_SHIFT 16
58 #define VNIC_INTR_RESET_TIMER_SHIFT 17
60 u32 int_credit_return
= (credits
& 0xffff) |
61 (unmask
? (1 << VNIC_INTR_UNMASK_SHIFT
) : 0) |
62 (reset_timer
? (1 << VNIC_INTR_RESET_TIMER_SHIFT
) : 0);
64 iowrite32(int_credit_return
, &intr
->ctrl
->int_credit_return
);
67 static inline unsigned int
68 svnic_intr_credits(struct vnic_intr
*intr
)
70 return ioread32(&intr
->ctrl
->int_credits
);
74 svnic_intr_return_all_credits(struct vnic_intr
*intr
)
76 unsigned int credits
= svnic_intr_credits(intr
);
80 svnic_intr_return_credits(intr
, credits
, unmask
, reset_timer
);
83 void svnic_intr_free(struct vnic_intr
*);
84 int svnic_intr_alloc(struct vnic_dev
*, struct vnic_intr
*, unsigned int);
85 void svnic_intr_init(struct vnic_intr
*intr
,
86 unsigned int coalescing_timer
,
87 unsigned int coalescing_type
,
88 unsigned int mask_on_assertion
);
89 void svnic_intr_clean(struct vnic_intr
*);
91 #endif /* _VNIC_INTR_H_ */