cna.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * Linux network driver for Brocade Converged Network Adapter.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License (GPL) Version 2 as
  6. * published by the Free Software Foundation
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * General Public License for more details.
  12. */
  13. /*
  14. * Copyright (c) 2006-2010 Brocade Communications Systems, Inc.
  15. * All rights reserved
  16. * www.brocade.com
  17. */
  18. #ifndef __CNA_H__
  19. #define __CNA_H__
  20. #include <linux/kernel.h>
  21. #include <linux/types.h>
  22. #include <linux/mutex.h>
  23. #include <linux/pci.h>
  24. #include <linux/delay.h>
  25. #include <linux/bitops.h>
  26. #include <linux/timer.h>
  27. #include <linux/interrupt.h>
  28. #include <linux/if_vlan.h>
  29. #include <linux/if_ether.h>
  30. #define bfa_sm_fault(__event) do { \
  31. pr_err("SM Assertion failure: %s: %d: event = %d\n", \
  32. __FILE__, __LINE__, __event); \
  33. } while (0)
  34. extern char bfa_version[];
  35. #define CNA_FW_FILE_CT "ctfw.bin"
  36. #define CNA_FW_FILE_CT2 "ct2fw.bin"
  37. #define FC_SYMNAME_MAX 256 /*!< max name server symbolic name size */
  38. #pragma pack(1)
  39. #define MAC_ADDRLEN (6)
  40. typedef struct mac { u8 mac[MAC_ADDRLEN]; } mac_t;
  41. #pragma pack()
  42. #define bfa_q_first(_q) ((void *)(((struct list_head *) (_q))->next))
  43. #define bfa_q_next(_qe) (((struct list_head *) (_qe))->next)
  44. #define bfa_q_prev(_qe) (((struct list_head *) (_qe))->prev)
  45. /*
  46. * bfa_q_qe_init - to initialize a queue element
  47. */
  48. #define bfa_q_qe_init(_qe) { \
  49. bfa_q_next(_qe) = (struct list_head *) NULL; \
  50. bfa_q_prev(_qe) = (struct list_head *) NULL; \
  51. }
  52. /*
  53. * bfa_q_deq - dequeue an element from head of the queue
  54. */
  55. #define bfa_q_deq(_q, _qe) { \
  56. if (!list_empty(_q)) { \
  57. (*((struct list_head **) (_qe))) = bfa_q_next(_q); \
  58. bfa_q_prev(bfa_q_next(*((struct list_head **) _qe))) = \
  59. (struct list_head *) (_q); \
  60. bfa_q_next(_q) = bfa_q_next(*((struct list_head **) _qe)); \
  61. bfa_q_qe_init(*((struct list_head **) _qe)); \
  62. } else { \
  63. *((struct list_head **)(_qe)) = NULL; \
  64. } \
  65. }
  66. /*
  67. * bfa_q_deq_tail - dequeue an element from tail of the queue
  68. */
  69. #define bfa_q_deq_tail(_q, _qe) { \
  70. if (!list_empty(_q)) { \
  71. *((struct list_head **) (_qe)) = bfa_q_prev(_q); \
  72. bfa_q_next(bfa_q_prev(*((struct list_head **) _qe))) = \
  73. (struct list_head *) (_q); \
  74. bfa_q_prev(_q) = bfa_q_prev(*(struct list_head **) _qe);\
  75. bfa_q_qe_init(*((struct list_head **) _qe)); \
  76. } else { \
  77. *((struct list_head **) (_qe)) = (struct list_head *) NULL; \
  78. } \
  79. }
  80. /*
  81. * bfa_add_tail_head - enqueue an element at the head of queue
  82. */
  83. #define bfa_q_enq_head(_q, _qe) { \
  84. if (!(bfa_q_next(_qe) == NULL) && (bfa_q_prev(_qe) == NULL)) \
  85. pr_err("Assertion failure: %s:%d: %d", \
  86. __FILE__, __LINE__, \
  87. (bfa_q_next(_qe) == NULL) && (bfa_q_prev(_qe) == NULL));\
  88. bfa_q_next(_qe) = bfa_q_next(_q); \
  89. bfa_q_prev(_qe) = (struct list_head *) (_q); \
  90. bfa_q_prev(bfa_q_next(_q)) = (struct list_head *) (_qe); \
  91. bfa_q_next(_q) = (struct list_head *) (_qe); \
  92. }
  93. #endif /* __CNA_H__ */