0001
0002
0003
0004 #ifndef _VNIC_INTR_H_
0005 #define _VNIC_INTR_H_
0006
0007 #include <linux/pci.h>
0008 #include "vnic_dev.h"
0009
0010 #define VNIC_INTR_TIMER_MAX 0xffff
0011
0012 #define VNIC_INTR_TIMER_TYPE_ABS 0
0013 #define VNIC_INTR_TIMER_TYPE_QUIET 1
0014
0015
0016 struct vnic_intr_ctrl {
0017 u32 coalescing_timer;
0018 u32 pad0;
0019 u32 coalescing_value;
0020 u32 pad1;
0021 u32 coalescing_type;
0022 u32 pad2;
0023 u32 mask_on_assertion;
0024 u32 pad3;
0025 u32 mask;
0026 u32 pad4;
0027 u32 int_credits;
0028 u32 pad5;
0029 u32 int_credit_return;
0030 u32 pad6;
0031 };
0032
0033 struct vnic_intr {
0034 unsigned int index;
0035 struct vnic_dev *vdev;
0036 struct vnic_intr_ctrl __iomem *ctrl;
0037 };
0038
0039 static inline void
0040 svnic_intr_unmask(struct vnic_intr *intr)
0041 {
0042 iowrite32(0, &intr->ctrl->mask);
0043 }
0044
0045 static inline void
0046 svnic_intr_mask(struct vnic_intr *intr)
0047 {
0048 iowrite32(1, &intr->ctrl->mask);
0049 }
0050
0051 static inline void
0052 svnic_intr_return_credits(struct vnic_intr *intr,
0053 unsigned int credits,
0054 int unmask,
0055 int reset_timer)
0056 {
0057 #define VNIC_INTR_UNMASK_SHIFT 16
0058 #define VNIC_INTR_RESET_TIMER_SHIFT 17
0059
0060 u32 int_credit_return = (credits & 0xffff) |
0061 (unmask ? (1 << VNIC_INTR_UNMASK_SHIFT) : 0) |
0062 (reset_timer ? (1 << VNIC_INTR_RESET_TIMER_SHIFT) : 0);
0063
0064 iowrite32(int_credit_return, &intr->ctrl->int_credit_return);
0065 }
0066
0067 static inline unsigned int
0068 svnic_intr_credits(struct vnic_intr *intr)
0069 {
0070 return ioread32(&intr->ctrl->int_credits);
0071 }
0072
0073 static inline void
0074 svnic_intr_return_all_credits(struct vnic_intr *intr)
0075 {
0076 unsigned int credits = svnic_intr_credits(intr);
0077 int unmask = 1;
0078 int reset_timer = 1;
0079
0080 svnic_intr_return_credits(intr, credits, unmask, reset_timer);
0081 }
0082
0083 void svnic_intr_free(struct vnic_intr *);
0084 int svnic_intr_alloc(struct vnic_dev *, struct vnic_intr *, unsigned int);
0085 void svnic_intr_init(struct vnic_intr *intr,
0086 unsigned int coalescing_timer,
0087 unsigned int coalescing_type,
0088 unsigned int mask_on_assertion);
0089 void svnic_intr_clean(struct vnic_intr *);
0090
0091 #endif