bfa_hw_ct.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. BFA_TRC_FILE(HAL, IOCFC_CT);
  21. /*
  22. * Dummy interrupt handler for handling spurious interrupt during chip-reinit.
  23. */
  24. static void
  25. bfa_hwct_msix_dummy(struct bfa_s *bfa, int vec)
  26. {
  27. }
  28. void
  29. bfa_hwct_reginit(struct bfa_s *bfa)
  30. {
  31. struct bfa_iocfc_regs_s *bfa_regs = &bfa->iocfc.bfa_regs;
  32. void __iomem *kva = bfa_ioc_bar0(&bfa->ioc);
  33. int fn = bfa_ioc_pcifn(&bfa->ioc);
  34. if (fn == 0) {
  35. bfa_regs->intr_status = (kva + HOSTFN0_INT_STATUS);
  36. bfa_regs->intr_mask = (kva + HOSTFN0_INT_MSK);
  37. } else {
  38. bfa_regs->intr_status = (kva + HOSTFN1_INT_STATUS);
  39. bfa_regs->intr_mask = (kva + HOSTFN1_INT_MSK);
  40. }
  41. }
  42. void
  43. bfa_hwct2_reginit(struct bfa_s *bfa)
  44. {
  45. struct bfa_iocfc_regs_s *bfa_regs = &bfa->iocfc.bfa_regs;
  46. void __iomem *kva = bfa_ioc_bar0(&bfa->ioc);
  47. bfa_regs->intr_status = (kva + CT2_HOSTFN_INT_STATUS);
  48. bfa_regs->intr_mask = (kva + CT2_HOSTFN_INTR_MASK);
  49. }
  50. void
  51. bfa_hwct_reqq_ack(struct bfa_s *bfa, int reqq)
  52. {
  53. u32 r32;
  54. r32 = readl(bfa->iocfc.bfa_regs.cpe_q_ctrl[reqq]);
  55. writel(r32, bfa->iocfc.bfa_regs.cpe_q_ctrl[reqq]);
  56. }
  57. /*
  58. * Actions to respond RME Interrupt for Catapult ASIC:
  59. * - Write 1 to Interrupt Status register (INTx only - done in bfa_intx())
  60. * - Acknowledge by writing to RME Queue Control register
  61. * - Update CI
  62. */
  63. void
  64. bfa_hwct_rspq_ack(struct bfa_s *bfa, int rspq, u32 ci)
  65. {
  66. u32 r32;
  67. r32 = readl(bfa->iocfc.bfa_regs.rme_q_ctrl[rspq]);
  68. writel(r32, bfa->iocfc.bfa_regs.rme_q_ctrl[rspq]);
  69. bfa_rspq_ci(bfa, rspq) = ci;
  70. writel(ci, bfa->iocfc.bfa_regs.rme_q_ci[rspq]);
  71. mmiowb();
  72. }
  73. /*
  74. * Actions to respond RME Interrupt for Catapult2 ASIC:
  75. * - Write 1 to Interrupt Status register (INTx only - done in bfa_intx())
  76. * - Update CI
  77. */
  78. void
  79. bfa_hwct2_rspq_ack(struct bfa_s *bfa, int rspq, u32 ci)
  80. {
  81. bfa_rspq_ci(bfa, rspq) = ci;
  82. writel(ci, bfa->iocfc.bfa_regs.rme_q_ci[rspq]);
  83. mmiowb();
  84. }
  85. void
  86. bfa_hwct_msix_getvecs(struct bfa_s *bfa, u32 *msix_vecs_bmap,
  87. u32 *num_vecs, u32 *max_vec_bit)
  88. {
  89. *msix_vecs_bmap = (1 << BFI_MSIX_CT_MAX) - 1;
  90. *max_vec_bit = (1 << (BFI_MSIX_CT_MAX - 1));
  91. *num_vecs = BFI_MSIX_CT_MAX;
  92. }
  93. /*
  94. * Setup MSI-X vector for catapult
  95. */
  96. void
  97. bfa_hwct_msix_init(struct bfa_s *bfa, int nvecs)
  98. {
  99. WARN_ON((nvecs != 1) && (nvecs != BFI_MSIX_CT_MAX));
  100. bfa_trc(bfa, nvecs);
  101. bfa->msix.nvecs = nvecs;
  102. bfa_hwct_msix_uninstall(bfa);
  103. }
  104. void
  105. bfa_hwct_msix_ctrl_install(struct bfa_s *bfa)
  106. {
  107. if (bfa->msix.nvecs == 0)
  108. return;
  109. if (bfa->msix.nvecs == 1)
  110. bfa->msix.handler[BFI_MSIX_LPU_ERR_CT] = bfa_msix_all;
  111. else
  112. bfa->msix.handler[BFI_MSIX_LPU_ERR_CT] = bfa_msix_lpu_err;
  113. }
  114. void
  115. bfa_hwct_msix_queue_install(struct bfa_s *bfa)
  116. {
  117. int i;
  118. if (bfa->msix.nvecs == 0)
  119. return;
  120. if (bfa->msix.nvecs == 1) {
  121. for (i = BFI_MSIX_CPE_QMIN_CT; i < BFI_MSIX_CT_MAX; i++)
  122. bfa->msix.handler[i] = bfa_msix_all;
  123. return;
  124. }
  125. for (i = BFI_MSIX_CPE_QMIN_CT; i <= BFI_MSIX_CPE_QMAX_CT; i++)
  126. bfa->msix.handler[i] = bfa_msix_reqq;
  127. for (i = BFI_MSIX_RME_QMIN_CT; i <= BFI_MSIX_RME_QMAX_CT; i++)
  128. bfa->msix.handler[i] = bfa_msix_rspq;
  129. }
  130. void
  131. bfa_hwct_msix_uninstall(struct bfa_s *bfa)
  132. {
  133. int i;
  134. for (i = 0; i < BFI_MSIX_CT_MAX; i++)
  135. bfa->msix.handler[i] = bfa_hwct_msix_dummy;
  136. }
  137. /*
  138. * Enable MSI-X vectors
  139. */
  140. void
  141. bfa_hwct_isr_mode_set(struct bfa_s *bfa, bfa_boolean_t msix)
  142. {
  143. bfa_trc(bfa, 0);
  144. bfa_ioc_isr_mode_set(&bfa->ioc, msix);
  145. }
  146. void
  147. bfa_hwct_msix_get_rme_range(struct bfa_s *bfa, u32 *start, u32 *end)
  148. {
  149. *start = BFI_MSIX_RME_QMIN_CT;
  150. *end = BFI_MSIX_RME_QMAX_CT;
  151. }