vnic_intr.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright 2014 Cisco Systems, Inc. All rights reserved.
  3. *
  4. * This program is free software; you may redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; version 2 of the License.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  9. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  10. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  11. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  12. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  13. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  14. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  15. * SOFTWARE.
  16. */
  17. #include <linux/kernel.h>
  18. #include <linux/errno.h>
  19. #include <linux/types.h>
  20. #include <linux/pci.h>
  21. #include <linux/delay.h>
  22. #include "vnic_dev.h"
  23. #include "vnic_intr.h"
  24. void svnic_intr_free(struct vnic_intr *intr)
  25. {
  26. intr->ctrl = NULL;
  27. }
  28. int svnic_intr_alloc(struct vnic_dev *vdev, struct vnic_intr *intr,
  29. unsigned int index)
  30. {
  31. intr->index = index;
  32. intr->vdev = vdev;
  33. intr->ctrl = svnic_dev_get_res(vdev, RES_TYPE_INTR_CTRL, index);
  34. if (!intr->ctrl) {
  35. pr_err("Failed to hook INTR[%d].ctrl resource\n",
  36. index);
  37. return -EINVAL;
  38. }
  39. return 0;
  40. }
  41. void svnic_intr_init(struct vnic_intr *intr, unsigned int coalescing_timer,
  42. unsigned int coalescing_type, unsigned int mask_on_assertion)
  43. {
  44. iowrite32(coalescing_timer, &intr->ctrl->coalescing_timer);
  45. iowrite32(coalescing_type, &intr->ctrl->coalescing_type);
  46. iowrite32(mask_on_assertion, &intr->ctrl->mask_on_assertion);
  47. iowrite32(0, &intr->ctrl->int_credits);
  48. }
  49. void svnic_intr_clean(struct vnic_intr *intr)
  50. {
  51. iowrite32(0, &intr->ctrl->int_credits);
  52. }