bfa_hw_cb.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
  3. * All rights reserved
  4. * www.brocade.com
  5. *
  6. * Linux driver for Brocade Fibre Channel Host Bus Adapter.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License (GPL) Version 2 as
  10. * published by the Free Software Foundation
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. */
  17. #include "bfad_drv.h"
  18. #include "bfa_modules.h"
  19. #include "bfi_reg.h"
  20. void
  21. bfa_hwcb_reginit(struct bfa_s *bfa)
  22. {
  23. struct bfa_iocfc_regs_s *bfa_regs = &bfa->iocfc.bfa_regs;
  24. void __iomem *kva = bfa_ioc_bar0(&bfa->ioc);
  25. int fn = bfa_ioc_pcifn(&bfa->ioc);
  26. if (fn == 0) {
  27. bfa_regs->intr_status = (kva + HOSTFN0_INT_STATUS);
  28. bfa_regs->intr_mask = (kva + HOSTFN0_INT_MSK);
  29. } else {
  30. bfa_regs->intr_status = (kva + HOSTFN1_INT_STATUS);
  31. bfa_regs->intr_mask = (kva + HOSTFN1_INT_MSK);
  32. }
  33. }
  34. void
  35. bfa_hwcb_reqq_ack(struct bfa_s *bfa, int reqq)
  36. {
  37. }
  38. static void
  39. bfa_hwcb_reqq_ack_msix(struct bfa_s *bfa, int reqq)
  40. {
  41. writel(__HFN_INT_CPE_Q0 << CPE_Q_NUM(bfa_ioc_pcifn(&bfa->ioc), reqq),
  42. bfa->iocfc.bfa_regs.intr_status);
  43. }
  44. void
  45. bfa_hwcb_rspq_ack(struct bfa_s *bfa, int rspq)
  46. {
  47. }
  48. static void
  49. bfa_hwcb_rspq_ack_msix(struct bfa_s *bfa, int rspq)
  50. {
  51. writel(__HFN_INT_RME_Q0 << RME_Q_NUM(bfa_ioc_pcifn(&bfa->ioc), rspq),
  52. bfa->iocfc.bfa_regs.intr_status);
  53. }
  54. void
  55. bfa_hwcb_msix_getvecs(struct bfa_s *bfa, u32 *msix_vecs_bmap,
  56. u32 *num_vecs, u32 *max_vec_bit)
  57. {
  58. #define __HFN_NUMINTS 13
  59. if (bfa_ioc_pcifn(&bfa->ioc) == 0) {
  60. *msix_vecs_bmap = (__HFN_INT_CPE_Q0 | __HFN_INT_CPE_Q1 |
  61. __HFN_INT_CPE_Q2 | __HFN_INT_CPE_Q3 |
  62. __HFN_INT_RME_Q0 | __HFN_INT_RME_Q1 |
  63. __HFN_INT_RME_Q2 | __HFN_INT_RME_Q3 |
  64. __HFN_INT_MBOX_LPU0);
  65. *max_vec_bit = __HFN_INT_MBOX_LPU0;
  66. } else {
  67. *msix_vecs_bmap = (__HFN_INT_CPE_Q4 | __HFN_INT_CPE_Q5 |
  68. __HFN_INT_CPE_Q6 | __HFN_INT_CPE_Q7 |
  69. __HFN_INT_RME_Q4 | __HFN_INT_RME_Q5 |
  70. __HFN_INT_RME_Q6 | __HFN_INT_RME_Q7 |
  71. __HFN_INT_MBOX_LPU1);
  72. *max_vec_bit = __HFN_INT_MBOX_LPU1;
  73. }
  74. *msix_vecs_bmap |= (__HFN_INT_ERR_EMC | __HFN_INT_ERR_LPU0 |
  75. __HFN_INT_ERR_LPU1 | __HFN_INT_ERR_PSS);
  76. *num_vecs = __HFN_NUMINTS;
  77. }
  78. /*
  79. * No special setup required for crossbow -- vector assignments are implicit.
  80. */
  81. void
  82. bfa_hwcb_msix_init(struct bfa_s *bfa, int nvecs)
  83. {
  84. int i;
  85. WARN_ON((nvecs != 1) && (nvecs != __HFN_NUMINTS));
  86. bfa->msix.nvecs = nvecs;
  87. if (nvecs == 1) {
  88. for (i = 0; i < BFI_MSIX_CB_MAX; i++)
  89. bfa->msix.handler[i] = bfa_msix_all;
  90. return;
  91. }
  92. for (i = BFI_MSIX_CPE_QMIN_CB; i <= BFI_MSIX_CPE_QMAX_CB; i++)
  93. bfa->msix.handler[i] = bfa_msix_reqq;
  94. for (i = BFI_MSIX_RME_QMIN_CB; i <= BFI_MSIX_RME_QMAX_CB; i++)
  95. bfa->msix.handler[i] = bfa_msix_rspq;
  96. for (; i < BFI_MSIX_CB_MAX; i++)
  97. bfa->msix.handler[i] = bfa_msix_lpu_err;
  98. }
  99. /*
  100. * Crossbow -- dummy, interrupts are masked
  101. */
  102. void
  103. bfa_hwcb_msix_install(struct bfa_s *bfa)
  104. {
  105. }
  106. void
  107. bfa_hwcb_msix_uninstall(struct bfa_s *bfa)
  108. {
  109. }
  110. /*
  111. * No special enable/disable -- vector assignments are implicit.
  112. */
  113. void
  114. bfa_hwcb_isr_mode_set(struct bfa_s *bfa, bfa_boolean_t msix)
  115. {
  116. bfa->iocfc.hwif.hw_reqq_ack = bfa_hwcb_reqq_ack_msix;
  117. bfa->iocfc.hwif.hw_rspq_ack = bfa_hwcb_rspq_ack_msix;
  118. }
  119. void
  120. bfa_hwcb_msix_get_rme_range(struct bfa_s *bfa, u32 *start, u32 *end)
  121. {
  122. *start = BFI_MSIX_RME_QMIN_CB;
  123. *end = BFI_MSIX_RME_QMAX_CB;
  124. }