drm/tests: hdmi: Fix memory leaks in drm_display_mode_from_cea_vic()
[drm/drm-misc.git] / drivers / scsi / snic / vnic_intr.h
blob7bff60fafb0783d9883e562373816d7242dd340a
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright 2014 Cisco Systems, Inc. All rights reserved. */
4 #ifndef _VNIC_INTR_H_
5 #define _VNIC_INTR_H_
7 #include <linux/pci.h>
8 #include "vnic_dev.h"
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 */
18 u32 pad0;
19 u32 coalescing_value; /* 0x08 */
20 u32 pad1;
21 u32 coalescing_type; /* 0x10 */
22 u32 pad2;
23 u32 mask_on_assertion; /* 0x18 */
24 u32 pad3;
25 u32 mask; /* 0x20 */
26 u32 pad4;
27 u32 int_credits; /* 0x28 */
28 u32 pad5;
29 u32 int_credit_return; /* 0x30 */
30 u32 pad6;
33 struct vnic_intr {
34 unsigned int index;
35 struct vnic_dev *vdev;
36 struct vnic_intr_ctrl __iomem *ctrl; /* memory-mapped */
39 static inline void
40 svnic_intr_unmask(struct vnic_intr *intr)
42 iowrite32(0, &intr->ctrl->mask);
45 static inline void
46 svnic_intr_mask(struct vnic_intr *intr)
48 iowrite32(1, &intr->ctrl->mask);
51 static inline void
52 svnic_intr_return_credits(struct vnic_intr *intr,
53 unsigned int credits,
54 int unmask,
55 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
68 svnic_intr_credits(struct vnic_intr *intr)
70 return ioread32(&intr->ctrl->int_credits);
73 static inline void
74 svnic_intr_return_all_credits(struct vnic_intr *intr)
76 unsigned int credits = svnic_intr_credits(intr);
77 int unmask = 1;
78 int reset_timer = 1;
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_ */