2 * Copyright 2014 Cisco Systems, Inc. All rights reserved.
4 * This program is free software; you may redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
9 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
11 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
12 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
13 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
14 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 #include <linux/pci.h>
24 #define VNIC_INTR_TIMER_MAX 0xffff
26 #define VNIC_INTR_TIMER_TYPE_ABS 0
27 #define VNIC_INTR_TIMER_TYPE_QUIET 1
29 /* Interrupt control */
30 struct vnic_intr_ctrl
{
31 u32 coalescing_timer
; /* 0x00 */
33 u32 coalescing_value
; /* 0x08 */
35 u32 coalescing_type
; /* 0x10 */
37 u32 mask_on_assertion
; /* 0x18 */
41 u32 int_credits
; /* 0x28 */
43 u32 int_credit_return
; /* 0x30 */
49 struct vnic_dev
*vdev
;
50 struct vnic_intr_ctrl __iomem
*ctrl
; /* memory-mapped */
54 svnic_intr_unmask(struct vnic_intr
*intr
)
56 iowrite32(0, &intr
->ctrl
->mask
);
60 svnic_intr_mask(struct vnic_intr
*intr
)
62 iowrite32(1, &intr
->ctrl
->mask
);
66 svnic_intr_return_credits(struct vnic_intr
*intr
,
71 #define VNIC_INTR_UNMASK_SHIFT 16
72 #define VNIC_INTR_RESET_TIMER_SHIFT 17
74 u32 int_credit_return
= (credits
& 0xffff) |
75 (unmask
? (1 << VNIC_INTR_UNMASK_SHIFT
) : 0) |
76 (reset_timer
? (1 << VNIC_INTR_RESET_TIMER_SHIFT
) : 0);
78 iowrite32(int_credit_return
, &intr
->ctrl
->int_credit_return
);
81 static inline unsigned int
82 svnic_intr_credits(struct vnic_intr
*intr
)
84 return ioread32(&intr
->ctrl
->int_credits
);
88 svnic_intr_return_all_credits(struct vnic_intr
*intr
)
90 unsigned int credits
= svnic_intr_credits(intr
);
94 svnic_intr_return_credits(intr
, credits
, unmask
, reset_timer
);
97 void svnic_intr_free(struct vnic_intr
*);
98 int svnic_intr_alloc(struct vnic_dev
*, struct vnic_intr
*, unsigned int);
99 void svnic_intr_init(struct vnic_intr
*intr
,
100 unsigned int coalescing_timer
,
101 unsigned int coalescing_type
,
102 unsigned int mask_on_assertion
);
103 void svnic_intr_clean(struct vnic_intr
*);
105 #endif /* _VNIC_INTR_H_ */