1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2008-2017 Cisco Systems, Inc. All rights reserved.
3 * Copyright 2007 Nuova Systems, Inc. All rights reserved.
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 */
39 static inline void vnic_intr_unmask(struct vnic_intr *intr)
41 iowrite32(0, &intr->ctrl->mask);
44 static inline void vnic_intr_mask(struct vnic_intr *intr)
46 iowrite32(1, &intr->ctrl->mask);
49 static inline int vnic_intr_masked(struct vnic_intr *intr)
51 return ioread32(&intr->ctrl->mask);
54 static inline void vnic_intr_return_credits(struct vnic_intr *intr,
55 unsigned int credits, int unmask, int reset_timer)
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 vnic_intr_credits(struct vnic_intr *intr)
69 return ioread32(&intr->ctrl->int_credits);
72 static inline void vnic_intr_return_all_credits(struct vnic_intr *intr)
74 unsigned int credits = vnic_intr_credits(intr);
78 vnic_intr_return_credits(intr, credits, unmask, reset_timer);
81 static inline u32 vnic_intr_legacy_pba(u32 __iomem *legacy_pba)
83 /* read PBA without clearing */
84 return ioread32(legacy_pba);
87 void vnic_intr_free(struct vnic_intr *intr);
88 int vnic_intr_alloc(struct vnic_dev *vdev, struct vnic_intr *intr,
90 void vnic_intr_init(struct vnic_intr *intr, u32 coalescing_timer,
91 unsigned int coalescing_type, unsigned int mask_on_assertion);
92 void vnic_intr_coalescing_timer_set(struct vnic_intr *intr,
93 u32 coalescing_timer);
94 void vnic_intr_clean(struct vnic_intr *intr);
96 #endif /* _VNIC_INTR_H_ */