bfa_hw_cb.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. * Copyright (c) 2005-2009 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 <bfa_priv.h>
  18. #include <bfi/bfi_cbreg.h>
  19. void
  20. bfa_hwcb_reginit(struct bfa_s *bfa)
  21. {
  22. struct bfa_iocfc_regs_s *bfa_regs = &bfa->iocfc.bfa_regs;
  23. bfa_os_addr_t kva = bfa_ioc_bar0(&bfa->ioc);
  24. int i, q, fn = bfa_ioc_pcifn(&bfa->ioc);
  25. if (fn == 0) {
  26. bfa_regs->intr_status = (kva + HOSTFN0_INT_STATUS);
  27. bfa_regs->intr_mask = (kva + HOSTFN0_INT_MSK);
  28. } else {
  29. bfa_regs->intr_status = (kva + HOSTFN1_INT_STATUS);
  30. bfa_regs->intr_mask = (kva + HOSTFN1_INT_MSK);
  31. }
  32. for (i = 0; i < BFI_IOC_MAX_CQS; i++) {
  33. /*
  34. * CPE registers
  35. */
  36. q = CPE_Q_NUM(fn, i);
  37. bfa_regs->cpe_q_pi[i] = (kva + CPE_Q_PI(q));
  38. bfa_regs->cpe_q_ci[i] = (kva + CPE_Q_CI(q));
  39. bfa_regs->cpe_q_depth[i] = (kva + CPE_Q_DEPTH(q));
  40. /*
  41. * RME registers
  42. */
  43. q = CPE_Q_NUM(fn, i);
  44. bfa_regs->rme_q_pi[i] = (kva + RME_Q_PI(q));
  45. bfa_regs->rme_q_ci[i] = (kva + RME_Q_CI(q));
  46. bfa_regs->rme_q_depth[i] = (kva + RME_Q_DEPTH(q));
  47. }
  48. }
  49. void
  50. bfa_hwcb_rspq_ack(struct bfa_s *bfa, int rspq)
  51. {
  52. }
  53. static void
  54. bfa_hwcb_rspq_ack_msix(struct bfa_s *bfa, int rspq)
  55. {
  56. bfa_reg_write(bfa->iocfc.bfa_regs.intr_status,
  57. __HFN_INT_RME_Q0 << RME_Q_NUM(bfa_ioc_pcifn(&bfa->ioc), rspq));
  58. }
  59. void
  60. bfa_hwcb_msix_getvecs(struct bfa_s *bfa, u32 *msix_vecs_bmap,
  61. u32 *num_vecs, u32 *max_vec_bit)
  62. {
  63. #define __HFN_NUMINTS 13
  64. if (bfa_ioc_pcifn(&bfa->ioc) == 0) {
  65. *msix_vecs_bmap = (__HFN_INT_CPE_Q0 | __HFN_INT_CPE_Q1 |
  66. __HFN_INT_CPE_Q2 | __HFN_INT_CPE_Q3 |
  67. __HFN_INT_RME_Q0 | __HFN_INT_RME_Q1 |
  68. __HFN_INT_RME_Q2 | __HFN_INT_RME_Q3 |
  69. __HFN_INT_MBOX_LPU0);
  70. *max_vec_bit = __HFN_INT_MBOX_LPU0;
  71. } else {
  72. *msix_vecs_bmap = (__HFN_INT_CPE_Q4 | __HFN_INT_CPE_Q5 |
  73. __HFN_INT_CPE_Q6 | __HFN_INT_CPE_Q7 |
  74. __HFN_INT_RME_Q4 | __HFN_INT_RME_Q5 |
  75. __HFN_INT_RME_Q6 | __HFN_INT_RME_Q7 |
  76. __HFN_INT_MBOX_LPU1);
  77. *max_vec_bit = __HFN_INT_MBOX_LPU1;
  78. }
  79. *msix_vecs_bmap |= (__HFN_INT_ERR_EMC | __HFN_INT_ERR_LPU0 |
  80. __HFN_INT_ERR_LPU1 | __HFN_INT_ERR_PSS);
  81. *num_vecs = __HFN_NUMINTS;
  82. }
  83. /**
  84. * No special setup required for crossbow -- vector assignments are implicit.
  85. */
  86. void
  87. bfa_hwcb_msix_init(struct bfa_s *bfa, int nvecs)
  88. {
  89. int i;
  90. bfa_assert((nvecs == 1) || (nvecs == __HFN_NUMINTS));
  91. bfa->msix.nvecs = nvecs;
  92. if (nvecs == 1) {
  93. for (i = 0; i < BFA_MSIX_CB_MAX; i++)
  94. bfa->msix.handler[i] = bfa_msix_all;
  95. return;
  96. }
  97. for (i = BFA_MSIX_CPE_Q0; i <= BFA_MSIX_CPE_Q7; i++)
  98. bfa->msix.handler[i] = bfa_msix_reqq;
  99. for (i = BFA_MSIX_RME_Q0; i <= BFA_MSIX_RME_Q7; i++)
  100. bfa->msix.handler[i] = bfa_msix_rspq;
  101. for (; i < BFA_MSIX_CB_MAX; i++)
  102. bfa->msix.handler[i] = bfa_msix_lpu_err;
  103. }
  104. /**
  105. * Crossbow -- dummy, interrupts are masked
  106. */
  107. void
  108. bfa_hwcb_msix_install(struct bfa_s *bfa)
  109. {
  110. }
  111. void
  112. bfa_hwcb_msix_uninstall(struct bfa_s *bfa)
  113. {
  114. }
  115. /**
  116. * No special enable/disable -- vector assignments are implicit.
  117. */
  118. void
  119. bfa_hwcb_isr_mode_set(struct bfa_s *bfa, bfa_boolean_t msix)
  120. {
  121. bfa->iocfc.hwif.hw_rspq_ack = bfa_hwcb_rspq_ack_msix;
  122. }