bfa_fcs_uf.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. /**
  18. * bfa_fcs_uf.c BFA FCS UF ( Unsolicited Frames)
  19. */
  20. #include <fcs/bfa_fcs.h>
  21. #include <bfa_svc.h>
  22. #include <fcs/bfa_fcs_fabric.h>
  23. #include "fcs.h"
  24. #include "fcs_trcmod.h"
  25. #include "fcs_fabric.h"
  26. #include "fcs_uf.h"
  27. BFA_TRC_FILE(FCS, UF);
  28. /**
  29. * BFA callback for unsolicited frame receive handler.
  30. *
  31. * @param[in] cbarg callback arg for receive handler
  32. * @param[in] uf unsolicited frame descriptor
  33. *
  34. * @return None
  35. */
  36. static void
  37. bfa_fcs_uf_recv(void *cbarg, struct bfa_uf_s *uf)
  38. {
  39. struct bfa_fcs_s *fcs = (struct bfa_fcs_s *) cbarg;
  40. struct fchs_s *fchs = bfa_uf_get_frmbuf(uf);
  41. u16 len = bfa_uf_get_frmlen(uf);
  42. struct fc_vft_s *vft;
  43. struct bfa_fcs_fabric_s *fabric;
  44. /**
  45. * check for VFT header
  46. */
  47. if (fchs->routing == FC_RTG_EXT_HDR &&
  48. fchs->cat_info == FC_CAT_VFT_HDR) {
  49. bfa_stats(fcs, uf.tagged);
  50. vft = bfa_uf_get_frmbuf(uf);
  51. if (fcs->port_vfid == vft->vf_id)
  52. fabric = &fcs->fabric;
  53. else
  54. fabric = bfa_fcs_vf_lookup(fcs, (u16) vft->vf_id);
  55. /**
  56. * drop frame if vfid is unknown
  57. */
  58. if (!fabric) {
  59. bfa_assert(0);
  60. bfa_stats(fcs, uf.vfid_unknown);
  61. bfa_uf_free(uf);
  62. return;
  63. }
  64. /**
  65. * skip vft header
  66. */
  67. fchs = (struct fchs_s *) (vft + 1);
  68. len -= sizeof(struct fc_vft_s);
  69. bfa_trc(fcs, vft->vf_id);
  70. } else {
  71. bfa_stats(fcs, uf.untagged);
  72. fabric = &fcs->fabric;
  73. }
  74. bfa_trc(fcs, ((u32 *) fchs)[0]);
  75. bfa_trc(fcs, ((u32 *) fchs)[1]);
  76. bfa_trc(fcs, ((u32 *) fchs)[2]);
  77. bfa_trc(fcs, ((u32 *) fchs)[3]);
  78. bfa_trc(fcs, ((u32 *) fchs)[4]);
  79. bfa_trc(fcs, ((u32 *) fchs)[5]);
  80. bfa_trc(fcs, len);
  81. bfa_fcs_fabric_uf_recv(fabric, fchs, len);
  82. bfa_uf_free(uf);
  83. }
  84. void
  85. bfa_fcs_uf_modinit(struct bfa_fcs_s *fcs)
  86. {
  87. bfa_uf_recv_register(fcs->bfa, bfa_fcs_uf_recv, fcs);
  88. }
  89. void
  90. bfa_fcs_uf_modexit(struct bfa_fcs_s *fcs)
  91. {
  92. bfa_fcs_modexit_comp(fcs);
  93. }