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
0013 #include "vnic_dev.h"
0014 #include "vnic_intr.h"
0015 #include "enic.h"
0016
0017 void vnic_intr_free(struct vnic_intr *intr)
0018 {
0019 intr->ctrl = NULL;
0020 }
0021
0022 int vnic_intr_alloc(struct vnic_dev *vdev, struct vnic_intr *intr,
0023 unsigned int index)
0024 {
0025 intr->index = index;
0026 intr->vdev = vdev;
0027
0028 intr->ctrl = vnic_dev_get_res(vdev, RES_TYPE_INTR_CTRL, index);
0029 if (!intr->ctrl) {
0030 vdev_err(vdev, "Failed to hook INTR[%d].ctrl resource\n",
0031 index);
0032 return -EINVAL;
0033 }
0034
0035 return 0;
0036 }
0037
0038 void vnic_intr_init(struct vnic_intr *intr, u32 coalescing_timer,
0039 unsigned int coalescing_type, unsigned int mask_on_assertion)
0040 {
0041 vnic_intr_coalescing_timer_set(intr, coalescing_timer);
0042 iowrite32(coalescing_type, &intr->ctrl->coalescing_type);
0043 iowrite32(mask_on_assertion, &intr->ctrl->mask_on_assertion);
0044 iowrite32(0, &intr->ctrl->int_credits);
0045 }
0046
0047 void vnic_intr_coalescing_timer_set(struct vnic_intr *intr,
0048 u32 coalescing_timer)
0049 {
0050 iowrite32(vnic_dev_intr_coal_timer_usec_to_hw(intr->vdev,
0051 coalescing_timer), &intr->ctrl->coalescing_timer);
0052 }
0053
0054 void vnic_intr_clean(struct vnic_intr *intr)
0055 {
0056 iowrite32(0, &intr->ctrl->int_credits);
0057 }