0001
0002
0003
0004 #include <linux/kernel.h>
0005 #include <linux/errno.h>
0006 #include <linux/types.h>
0007 #include <linux/pci.h>
0008 #include <linux/delay.h>
0009 #include "vnic_dev.h"
0010 #include "vnic_intr.h"
0011
0012 void svnic_intr_free(struct vnic_intr *intr)
0013 {
0014 intr->ctrl = NULL;
0015 }
0016
0017 int svnic_intr_alloc(struct vnic_dev *vdev, struct vnic_intr *intr,
0018 unsigned int index)
0019 {
0020 intr->index = index;
0021 intr->vdev = vdev;
0022
0023 intr->ctrl = svnic_dev_get_res(vdev, RES_TYPE_INTR_CTRL, index);
0024 if (!intr->ctrl) {
0025 pr_err("Failed to hook INTR[%d].ctrl resource\n",
0026 index);
0027 return -EINVAL;
0028 }
0029
0030 return 0;
0031 }
0032
0033 void svnic_intr_init(struct vnic_intr *intr, unsigned int coalescing_timer,
0034 unsigned int coalescing_type, unsigned int mask_on_assertion)
0035 {
0036 iowrite32(coalescing_timer, &intr->ctrl->coalescing_timer);
0037 iowrite32(coalescing_type, &intr->ctrl->coalescing_type);
0038 iowrite32(mask_on_assertion, &intr->ctrl->mask_on_assertion);
0039 iowrite32(0, &intr->ctrl->int_credits);
0040 }
0041
0042 void svnic_intr_clean(struct vnic_intr *intr)
0043 {
0044 iowrite32(0, &intr->ctrl->int_credits);
0045 }