vnic_intr.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright 2008 Cisco Systems, Inc. All rights reserved.
  4. * Copyright 2007 Nuova Systems, Inc. All rights reserved.
  5. */
  6. #include <linux/kernel.h>
  7. #include <linux/errno.h>
  8. #include <linux/types.h>
  9. #include <linux/pci.h>
  10. #include <linux/delay.h>
  11. #include "vnic_dev.h"
  12. #include "vnic_intr.h"
  13. void vnic_intr_free(struct vnic_intr *intr)
  14. {
  15. intr->ctrl = NULL;
  16. }
  17. int vnic_intr_alloc(struct vnic_dev *vdev, struct vnic_intr *intr,
  18. unsigned int index)
  19. {
  20. intr->index = index;
  21. intr->vdev = vdev;
  22. intr->ctrl = vnic_dev_get_res(vdev, RES_TYPE_INTR_CTRL, index);
  23. if (!intr->ctrl) {
  24. printk(KERN_ERR "Failed to hook INTR[%d].ctrl resource\n",
  25. index);
  26. return -EINVAL;
  27. }
  28. return 0;
  29. }
  30. void vnic_intr_init(struct vnic_intr *intr, unsigned int coalescing_timer,
  31. unsigned int coalescing_type, unsigned int mask_on_assertion)
  32. {
  33. iowrite32(coalescing_timer, &intr->ctrl->coalescing_timer);
  34. iowrite32(coalescing_type, &intr->ctrl->coalescing_type);
  35. iowrite32(mask_on_assertion, &intr->ctrl->mask_on_assertion);
  36. iowrite32(0, &intr->ctrl->int_credits);
  37. }
  38. void vnic_intr_clean(struct vnic_intr *intr)
  39. {
  40. iowrite32(0, &intr->ctrl->int_credits);
  41. }