bfa_hw_ct.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
  3. * Copyright (c) 2014- QLogic Corporation.
  4. * All rights reserved
  5. * www.qlogic.com
  6. *
  7. * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License (GPL) Version 2 as
  11. * published by the Free Software Foundation
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. */
  18. #include "bfad_drv.h"
  19. #include "bfa_modules.h"
  20. #include "bfi_reg.h"
  21. BFA_TRC_FILE(HAL, IOCFC_CT);
  22. /*
  23. * Dummy interrupt handler for handling spurious interrupt during chip-reinit.
  24. */
  25. static void
  26. bfa_hwct_msix_dummy(struct bfa_s *bfa, int vec)
  27. {
  28. }
  29. void
  30. bfa_hwct_reginit(struct bfa_s *bfa)
  31. {
  32. struct bfa_iocfc_regs_s *bfa_regs = &bfa->iocfc.bfa_regs;
  33. void __iomem *kva = bfa_ioc_bar0(&bfa->ioc);
  34. int fn = bfa_ioc_pcifn(&bfa->ioc);
  35. if (fn == 0) {
  36. bfa_regs->intr_status = (kva + HOSTFN0_INT_STATUS);
  37. bfa_regs->intr_mask = (kva + HOSTFN0_INT_MSK);
  38. } else {
  39. bfa_regs->intr_status = (kva + HOSTFN1_INT_STATUS);
  40. bfa_regs->intr_mask = (kva + HOSTFN1_INT_MSK);
  41. }
  42. }
  43. void
  44. bfa_hwct2_reginit(struct bfa_s *bfa)
  45. {
  46. struct bfa_iocfc_regs_s *bfa_regs = &bfa->iocfc.bfa_regs;
  47. void __iomem *kva = bfa_ioc_bar0(&bfa->ioc);
  48. bfa_regs->intr_status = (kva + CT2_HOSTFN_INT_STATUS);
  49. bfa_regs->intr_mask = (kva + CT2_HOSTFN_INTR_MASK);
  50. }
  51. void
  52. bfa_hwct_reqq_ack(struct bfa_s *bfa, int reqq)
  53. {
  54. u32 r32;
  55. r32 = readl(bfa->iocfc.bfa_regs.cpe_q_ctrl[reqq]);
  56. writel(r32, bfa->iocfc.bfa_regs.cpe_q_ctrl[reqq]);
  57. }
  58. /*
  59. * Actions to respond RME Interrupt for Catapult ASIC:
  60. * - Write 1 to Interrupt Status register (INTx only - done in bfa_intx())
  61. * - Acknowledge by writing to RME Queue Control register
  62. * - Update CI
  63. */
  64. void
  65. bfa_hwct_rspq_ack(struct bfa_s *bfa, int rspq, u32 ci)
  66. {
  67. u32 r32;
  68. r32 = readl(bfa->iocfc.bfa_regs.rme_q_ctrl[rspq]);
  69. writel(r32, bfa->iocfc.bfa_regs.rme_q_ctrl[rspq]);
  70. bfa_rspq_ci(bfa, rspq) = ci;
  71. writel(ci, bfa->iocfc.bfa_regs.rme_q_ci[rspq]);
  72. mmiowb();
  73. }
  74. /*
  75. * Actions to respond RME Interrupt for Catapult2 ASIC:
  76. * - Write 1 to Interrupt Status register (INTx only - done in bfa_intx())
  77. * - Update CI
  78. */
  79. void
  80. bfa_hwct2_rspq_ack(struct bfa_s *bfa, int rspq, u32 ci)
  81. {
  82. bfa_rspq_ci(bfa, rspq) = ci;
  83. writel(ci, bfa->iocfc.bfa_regs.rme_q_ci[rspq]);
  84. mmiowb();
  85. }
  86. void
  87. bfa_hwct_msix_getvecs(struct bfa_s *bfa, u32 *msix_vecs_bmap,
  88. u32 *num_vecs, u32 *max_vec_bit)
  89. {
  90. *msix_vecs_bmap = (1 << BFI_MSIX_CT_MAX) - 1;
  91. *max_vec_bit = (1 << (BFI_MSIX_CT_MAX - 1));
  92. *num_vecs = BFI_MSIX_CT_MAX;
  93. }
  94. /*
  95. * Setup MSI-X vector for catapult
  96. */
  97. void
  98. bfa_hwct_msix_init(struct bfa_s *bfa, int nvecs)
  99. {
  100. WARN_ON((nvecs != 1) && (nvecs != BFI_MSIX_CT_MAX));
  101. bfa_trc(bfa, nvecs);
  102. bfa->msix.nvecs = nvecs;
  103. bfa_hwct_msix_uninstall(bfa);
  104. }
  105. void
  106. bfa_hwct_msix_ctrl_install(struct bfa_s *bfa)
  107. {
  108. if (bfa->msix.nvecs == 0)
  109. return;
  110. if (bfa->msix.nvecs == 1)
  111. bfa->msix.handler[BFI_MSIX_LPU_ERR_CT] = bfa_msix_all;
  112. else
  113. bfa->msix.handler[BFI_MSIX_LPU_ERR_CT] = bfa_msix_lpu_err;
  114. }
  115. void
  116. bfa_hwct_msix_queue_install(struct bfa_s *bfa)
  117. {
  118. int i;
  119. if (bfa->msix.nvecs == 0)
  120. return;
  121. if (bfa->msix.nvecs == 1) {
  122. for (i = BFI_MSIX_CPE_QMIN_CT; i < BFI_MSIX_CT_MAX; i++)
  123. bfa->msix.handler[i] = bfa_msix_all;
  124. return;
  125. }
  126. for (i = BFI_MSIX_CPE_QMIN_CT; i <= BFI_MSIX_CPE_QMAX_CT; i++)
  127. bfa->msix.handler[i] = bfa_msix_reqq;
  128. for (i = BFI_MSIX_RME_QMIN_CT; i <= BFI_MSIX_RME_QMAX_CT; i++)
  129. bfa->msix.handler[i] = bfa_msix_rspq;
  130. }
  131. void
  132. bfa_hwct_msix_uninstall(struct bfa_s *bfa)
  133. {
  134. int i;
  135. for (i = 0; i < BFI_MSIX_CT_MAX; i++)
  136. bfa->msix.handler[i] = bfa_hwct_msix_dummy;
  137. }
  138. /*
  139. * Enable MSI-X vectors
  140. */
  141. void
  142. bfa_hwct_isr_mode_set(struct bfa_s *bfa, bfa_boolean_t msix)
  143. {
  144. bfa_trc(bfa, 0);
  145. bfa_ioc_isr_mode_set(&bfa->ioc, msix);
  146. }
  147. void
  148. bfa_hwct_msix_get_rme_range(struct bfa_s *bfa, u32 *start, u32 *end)
  149. {
  150. *start = BFI_MSIX_RME_QMIN_CT;
  151. *end = BFI_MSIX_RME_QMAX_CT;
  152. }