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