1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#include <linux/kernel.h>
21#include <linux/errno.h>
22#include <linux/types.h>
23#include <linux/pci.h>
24#include <linux/delay.h>
25
26#include "vnic_dev.h"
27#include "vnic_intr.h"
28#include "enic.h"
29
30void vnic_intr_free(struct vnic_intr *intr)
31{
32 intr->ctrl = NULL;
33}
34
35int vnic_intr_alloc(struct vnic_dev *vdev, struct vnic_intr *intr,
36 unsigned int index)
37{
38 intr->index = index;
39 intr->vdev = vdev;
40
41 intr->ctrl = vnic_dev_get_res(vdev, RES_TYPE_INTR_CTRL, index);
42 if (!intr->ctrl) {
43 vdev_err(vdev, "Failed to hook INTR[%d].ctrl resource\n",
44 index);
45 return -EINVAL;
46 }
47
48 return 0;
49}
50
51void vnic_intr_init(struct vnic_intr *intr, u32 coalescing_timer,
52 unsigned int coalescing_type, unsigned int mask_on_assertion)
53{
54 vnic_intr_coalescing_timer_set(intr, coalescing_timer);
55 iowrite32(coalescing_type, &intr->ctrl->coalescing_type);
56 iowrite32(mask_on_assertion, &intr->ctrl->mask_on_assertion);
57 iowrite32(0, &intr->ctrl->int_credits);
58}
59
60void vnic_intr_coalescing_timer_set(struct vnic_intr *intr,
61 u32 coalescing_timer)
62{
63 iowrite32(vnic_dev_intr_coal_timer_usec_to_hw(intr->vdev,
64 coalescing_timer), &intr->ctrl->coalescing_timer);
65}
66
67void vnic_intr_clean(struct vnic_intr *intr)
68{
69 iowrite32(0, &intr->ctrl->int_credits);
70}
71