vnic_intr.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Copyright 2008 Cisco Systems, Inc. All rights reserved.
  3. * Copyright 2007 Nuova Systems, Inc. All rights reserved.
  4. *
  5. * This program is free software; you may redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; version 2 of the License.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  10. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  11. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  12. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  13. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  14. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  15. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  16. * SOFTWARE.
  17. *
  18. */
  19. #ifndef _VNIC_INTR_H_
  20. #define _VNIC_INTR_H_
  21. #include <linux/pci.h>
  22. #include "vnic_dev.h"
  23. #define VNIC_INTR_TIMER_MAX 0xffff
  24. #define VNIC_INTR_TIMER_TYPE_ABS 0
  25. #define VNIC_INTR_TIMER_TYPE_QUIET 1
  26. /* Interrupt control */
  27. struct vnic_intr_ctrl {
  28. u32 coalescing_timer; /* 0x00 */
  29. u32 pad0;
  30. u32 coalescing_value; /* 0x08 */
  31. u32 pad1;
  32. u32 coalescing_type; /* 0x10 */
  33. u32 pad2;
  34. u32 mask_on_assertion; /* 0x18 */
  35. u32 pad3;
  36. u32 mask; /* 0x20 */
  37. u32 pad4;
  38. u32 int_credits; /* 0x28 */
  39. u32 pad5;
  40. u32 int_credit_return; /* 0x30 */
  41. u32 pad6;
  42. };
  43. struct vnic_intr {
  44. unsigned int index;
  45. struct vnic_dev *vdev;
  46. struct vnic_intr_ctrl __iomem *ctrl; /* memory-mapped */
  47. };
  48. static inline void vnic_intr_unmask(struct vnic_intr *intr)
  49. {
  50. iowrite32(0, &intr->ctrl->mask);
  51. }
  52. static inline void vnic_intr_mask(struct vnic_intr *intr)
  53. {
  54. iowrite32(1, &intr->ctrl->mask);
  55. }
  56. static inline void vnic_intr_return_credits(struct vnic_intr *intr,
  57. unsigned int credits, int unmask, int reset_timer)
  58. {
  59. #define VNIC_INTR_UNMASK_SHIFT 16
  60. #define VNIC_INTR_RESET_TIMER_SHIFT 17
  61. u32 int_credit_return = (credits & 0xffff) |
  62. (unmask ? (1 << VNIC_INTR_UNMASK_SHIFT) : 0) |
  63. (reset_timer ? (1 << VNIC_INTR_RESET_TIMER_SHIFT) : 0);
  64. iowrite32(int_credit_return, &intr->ctrl->int_credit_return);
  65. }
  66. static inline u32 vnic_intr_legacy_pba(u32 __iomem *legacy_pba)
  67. {
  68. /* read PBA without clearing */
  69. return ioread32(legacy_pba);
  70. }
  71. void vnic_intr_free(struct vnic_intr *intr);
  72. int vnic_intr_alloc(struct vnic_dev *vdev, struct vnic_intr *intr,
  73. unsigned int index);
  74. void vnic_intr_init(struct vnic_intr *intr, unsigned int coalescing_timer,
  75. unsigned int coalescing_type, unsigned int mask_on_assertion);
  76. void vnic_intr_clean(struct vnic_intr *intr);
  77. #endif /* _VNIC_INTR_H_ */