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