1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright 2008-2010 Cisco Systems, Inc. All rights reserved.
4 * Copyright 2007 Nuova Systems, Inc. All rights reserved.
10 #include <linux/pci.h>
14 #define VNIC_INTR_TIMER_TYPE_ABS 0
15 #define VNIC_INTR_TIMER_TYPE_QUIET 1
17 /* Interrupt control */
18 struct vnic_intr_ctrl
{
19 u32 coalescing_timer
; /* 0x00 */
21 u32 coalescing_value
; /* 0x08 */
23 u32 coalescing_type
; /* 0x10 */
25 u32 mask_on_assertion
; /* 0x18 */
29 u32 int_credits
; /* 0x28 */
31 u32 int_credit_return
; /* 0x30 */
37 struct vnic_dev
*vdev
;
38 struct vnic_intr_ctrl __iomem
*ctrl
; /* memory-mapped */
41 static inline void vnic_intr_unmask(struct vnic_intr
*intr
)
43 iowrite32(0, &intr
->ctrl
->mask
);
46 static inline void vnic_intr_mask(struct vnic_intr
*intr
)
48 iowrite32(1, &intr
->ctrl
->mask
);
51 static inline int vnic_intr_masked(struct vnic_intr
*intr
)
53 return ioread32(&intr
->ctrl
->mask
);
56 static inline void vnic_intr_return_credits(struct vnic_intr
*intr
,
57 unsigned int credits
, int unmask
, int reset_timer
)
59 #define VNIC_INTR_UNMASK_SHIFT 16
60 #define VNIC_INTR_RESET_TIMER_SHIFT 17
62 u32 int_credit_return
= (credits
& 0xffff) |
63 (unmask
? (1 << VNIC_INTR_UNMASK_SHIFT
) : 0) |
64 (reset_timer
? (1 << VNIC_INTR_RESET_TIMER_SHIFT
) : 0);
66 iowrite32(int_credit_return
, &intr
->ctrl
->int_credit_return
);
69 static inline unsigned int vnic_intr_credits(struct vnic_intr
*intr
)
71 return ioread32(&intr
->ctrl
->int_credits
);
74 static inline void vnic_intr_return_all_credits(struct vnic_intr
*intr
)
76 unsigned int credits
= vnic_intr_credits(intr
);
80 vnic_intr_return_credits(intr
, credits
, unmask
, reset_timer
);
83 static inline u32
vnic_intr_legacy_pba(u32 __iomem
*legacy_pba
)
85 /* read PBA without clearing */
86 return ioread32(legacy_pba
);
89 void vnic_intr_free(struct vnic_intr
*intr
);
90 int vnic_intr_alloc(struct vnic_dev
*vdev
, struct vnic_intr
*intr
,
92 void vnic_intr_init(struct vnic_intr
*intr
, u32 coalescing_timer
,
93 unsigned int coalescing_type
, unsigned int mask_on_assertion
);
94 void vnic_intr_coalescing_timer_set(struct vnic_intr
*intr
,
95 u32 coalescing_timer
);
96 void vnic_intr_clean(struct vnic_intr
*intr
);
98 #endif /* _VNIC_INTR_H_ */