vnic_intr.c 1.1 KB

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