bfa_aen.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. #ifndef __BFA_AEN_H__
  18. #define __BFA_AEN_H__
  19. #include "defs/bfa_defs_aen.h"
  20. #define BFA_AEN_MAX_ENTRY 512
  21. extern s32 bfa_aen_max_cfg_entry;
  22. struct bfa_aen_s {
  23. void *bfad;
  24. s32 max_entry;
  25. s32 write_index;
  26. s32 read_index;
  27. u32 bfad_num;
  28. u32 seq_num;
  29. void (*aen_cb_notify)(void *bfad);
  30. void (*gettimeofday)(struct bfa_timeval_s *tv);
  31. struct bfa_trc_mod_s *trcmod;
  32. struct bfa_aen_entry_s list[BFA_AEN_MAX_ENTRY]; /* Must be the last */
  33. };
  34. /**
  35. * Public APIs
  36. */
  37. static inline void
  38. bfa_aen_set_max_cfg_entry(int max_entry)
  39. {
  40. bfa_aen_max_cfg_entry = max_entry;
  41. }
  42. static inline s32
  43. bfa_aen_get_max_cfg_entry(void)
  44. {
  45. return bfa_aen_max_cfg_entry;
  46. }
  47. static inline s32
  48. bfa_aen_get_meminfo(void)
  49. {
  50. return (sizeof(struct bfa_aen_entry_s) * bfa_aen_get_max_cfg_entry());
  51. }
  52. static inline s32
  53. bfa_aen_get_wi(struct bfa_aen_s *aen)
  54. {
  55. return aen->write_index;
  56. }
  57. static inline s32
  58. bfa_aen_get_ri(struct bfa_aen_s *aen)
  59. {
  60. return aen->read_index;
  61. }
  62. static inline s32
  63. bfa_aen_fetch_count(struct bfa_aen_s *aen, s32 read_index)
  64. {
  65. return ((aen->write_index + aen->max_entry) - read_index)
  66. % aen->max_entry;
  67. }
  68. s32 bfa_aen_init(struct bfa_aen_s *aen, struct bfa_trc_mod_s *trcmod,
  69. void *bfad, u32 inst_id, void (*aen_cb_notify)(void *),
  70. void (*gettimeofday)(struct bfa_timeval_s *));
  71. s32 bfa_aen_post(struct bfa_aen_s *aen, enum bfa_aen_category aen_category,
  72. int aen_type, union bfa_aen_data_u *aen_data);
  73. s32 bfa_aen_fetch(struct bfa_aen_s *aen, struct bfa_aen_entry_s *aen_entry,
  74. s32 entry_space, s32 rii, s32 *ri_arr,
  75. s32 ri_arr_cnt);
  76. s32 bfa_aen_get_inst(struct bfa_aen_s *aen);
  77. #endif /* __BFA_AEN_H__ */