bfa_fcs_lport.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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_port.h BFA fcs port module public interface
  19. */
  20. #ifndef __BFA_FCS_PORT_H__
  21. #define __BFA_FCS_PORT_H__
  22. #include <defs/bfa_defs_status.h>
  23. #include <defs/bfa_defs_port.h>
  24. #include <defs/bfa_defs_pport.h>
  25. #include <defs/bfa_defs_rport.h>
  26. #include <cs/bfa_q.h>
  27. #include <bfa_svc.h>
  28. #include <cs/bfa_wc.h>
  29. struct bfa_fcs_s;
  30. struct bfa_fcs_fabric_s;
  31. /*
  32. * Maximum Rports supported per port (physical/logical).
  33. */
  34. #define BFA_FCS_MAX_RPORTS_SUPP 256 /* @todo : tentative value */
  35. struct bfa_fcs_port_ns_s {
  36. bfa_sm_t sm; /* state machine */
  37. struct bfa_timer_s timer;
  38. struct bfa_fcs_port_s *port; /* parent port */
  39. struct bfa_fcxp_s *fcxp;
  40. struct bfa_fcxp_wqe_s fcxp_wqe;
  41. };
  42. struct bfa_fcs_port_scn_s {
  43. bfa_sm_t sm; /* state machine */
  44. struct bfa_timer_s timer;
  45. struct bfa_fcs_port_s *port; /* parent port */
  46. struct bfa_fcxp_s *fcxp;
  47. struct bfa_fcxp_wqe_s fcxp_wqe;
  48. };
  49. struct bfa_fcs_port_fdmi_s {
  50. bfa_sm_t sm; /* state machine */
  51. struct bfa_timer_s timer;
  52. struct bfa_fcs_port_ms_s *ms; /* parent ms */
  53. struct bfa_fcxp_s *fcxp;
  54. struct bfa_fcxp_wqe_s fcxp_wqe;
  55. u8 retry_cnt; /* retry count */
  56. u8 rsvd[3];
  57. };
  58. struct bfa_fcs_port_ms_s {
  59. bfa_sm_t sm; /* state machine */
  60. struct bfa_timer_s timer;
  61. struct bfa_fcs_port_s *port; /* parent port */
  62. struct bfa_fcxp_s *fcxp;
  63. struct bfa_fcxp_wqe_s fcxp_wqe;
  64. struct bfa_fcs_port_fdmi_s fdmi; /* FDMI component of MS */
  65. u8 retry_cnt; /* retry count */
  66. u8 rsvd[3];
  67. };
  68. struct bfa_fcs_port_fab_s {
  69. struct bfa_fcs_port_ns_s ns; /* NS component of port */
  70. struct bfa_fcs_port_scn_s scn; /* scn component of port */
  71. struct bfa_fcs_port_ms_s ms; /* MS component of port */
  72. };
  73. #define MAX_ALPA_COUNT 127
  74. struct bfa_fcs_port_loop_s {
  75. u8 num_alpa; /* Num of ALPA entries in the map */
  76. u8 alpa_pos_map[MAX_ALPA_COUNT]; /* ALPA Positional
  77. *Map */
  78. struct bfa_fcs_port_s *port; /* parent port */
  79. };
  80. struct bfa_fcs_port_n2n_s {
  81. u32 rsvd;
  82. u16 reply_oxid; /* ox_id from the req flogi to be
  83. *used in flogi acc */
  84. wwn_t rem_port_wwn; /* Attached port's wwn */
  85. };
  86. union bfa_fcs_port_topo_u {
  87. struct bfa_fcs_port_fab_s pfab;
  88. struct bfa_fcs_port_loop_s ploop;
  89. struct bfa_fcs_port_n2n_s pn2n;
  90. };
  91. struct bfa_fcs_port_s {
  92. struct list_head qe; /* used by port/vport */
  93. bfa_sm_t sm; /* state machine */
  94. struct bfa_fcs_fabric_s *fabric;/* parent fabric */
  95. struct bfa_port_cfg_s port_cfg;/* port configuration */
  96. struct bfa_timer_s link_timer; /* timer for link offline */
  97. u32 pid:24; /* FC address */
  98. u8 lp_tag; /* lport tag */
  99. u16 num_rports; /* Num of r-ports */
  100. struct list_head rport_q; /* queue of discovered r-ports */
  101. struct bfa_fcs_s *fcs; /* FCS instance */
  102. union bfa_fcs_port_topo_u port_topo; /* fabric/loop/n2n details */
  103. struct bfad_port_s *bfad_port; /* driver peer instance */
  104. struct bfa_fcs_vport_s *vport; /* NULL for base ports */
  105. struct bfa_fcxp_s *fcxp;
  106. struct bfa_fcxp_wqe_s fcxp_wqe;
  107. struct bfa_port_stats_s stats;
  108. struct bfa_wc_s wc; /* waiting counter for events */
  109. };
  110. #define bfa_fcs_lport_t struct bfa_fcs_port_s
  111. /**
  112. * Symbolic Name related defines
  113. * Total bytes 255.
  114. * Physical Port's symbolic name 128 bytes.
  115. * For Vports, Vport's symbolic name is appended to the Physical port's
  116. * Symbolic Name.
  117. *
  118. * Physical Port's symbolic name Format : (Total 128 bytes)
  119. * Adapter Model number/name : 12 bytes
  120. * Driver Version : 10 bytes
  121. * Host Machine Name : 30 bytes
  122. * Host OS Info : 48 bytes
  123. * Host OS PATCH Info : 16 bytes
  124. * ( remaining 12 bytes reserved to be used for separator)
  125. */
  126. #define BFA_FCS_PORT_SYMBNAME_SEPARATOR " | "
  127. #define BFA_FCS_PORT_SYMBNAME_MODEL_SZ 12
  128. #define BFA_FCS_PORT_SYMBNAME_VERSION_SZ 10
  129. #define BFA_FCS_PORT_SYMBNAME_MACHINENAME_SZ 30
  130. #define BFA_FCS_PORT_SYMBNAME_OSINFO_SZ 48
  131. #define BFA_FCS_PORT_SYMBNAME_OSPATCH_SZ 16
  132. /**
  133. * Get FC port ID for a logical port.
  134. */
  135. #define bfa_fcs_port_get_fcid(_lport) ((_lport)->pid)
  136. #define bfa_fcs_port_get_pwwn(_lport) ((_lport)->port_cfg.pwwn)
  137. #define bfa_fcs_port_get_nwwn(_lport) ((_lport)->port_cfg.nwwn)
  138. #define bfa_fcs_port_get_psym_name(_lport) ((_lport)->port_cfg.sym_name)
  139. #define bfa_fcs_port_is_initiator(_lport) \
  140. ((_lport)->port_cfg.roles & BFA_PORT_ROLE_FCP_IM)
  141. #define bfa_fcs_port_is_target(_lport) \
  142. ((_lport)->port_cfg.roles & BFA_PORT_ROLE_FCP_TM)
  143. #define bfa_fcs_port_get_nrports(_lport) \
  144. ((_lport) ? (_lport)->num_rports : 0)
  145. static inline struct bfad_port_s *
  146. bfa_fcs_port_get_drvport(struct bfa_fcs_port_s *port)
  147. {
  148. return port->bfad_port;
  149. }
  150. #define bfa_fcs_port_get_opertype(_lport) ((_lport)->fabric->oper_type)
  151. #define bfa_fcs_port_get_fabric_name(_lport) ((_lport)->fabric->fabric_name)
  152. #define bfa_fcs_port_get_fabric_ipaddr(_lport) \
  153. ((_lport)->fabric->fabric_ip_addr)
  154. /**
  155. * bfa fcs port public functions
  156. */
  157. void bfa_fcs_cfg_base_port(struct bfa_fcs_s *fcs,
  158. struct bfa_port_cfg_s *port_cfg);
  159. struct bfa_fcs_port_s *bfa_fcs_get_base_port(struct bfa_fcs_s *fcs);
  160. void bfa_fcs_port_get_rports(struct bfa_fcs_port_s *port,
  161. wwn_t rport_wwns[], int *nrports);
  162. wwn_t bfa_fcs_port_get_rport(struct bfa_fcs_port_s *port, wwn_t wwn,
  163. int index, int nrports, bfa_boolean_t bwwn);
  164. struct bfa_fcs_port_s *bfa_fcs_lookup_port(struct bfa_fcs_s *fcs,
  165. u16 vf_id, wwn_t lpwwn);
  166. void bfa_fcs_port_get_info(struct bfa_fcs_port_s *port,
  167. struct bfa_port_info_s *port_info);
  168. void bfa_fcs_port_get_attr(struct bfa_fcs_port_s *port,
  169. struct bfa_port_attr_s *port_attr);
  170. void bfa_fcs_port_get_stats(struct bfa_fcs_port_s *fcs_port,
  171. struct bfa_port_stats_s *port_stats);
  172. void bfa_fcs_port_clear_stats(struct bfa_fcs_port_s *fcs_port);
  173. enum bfa_pport_speed bfa_fcs_port_get_rport_max_speed(
  174. struct bfa_fcs_port_s *port);
  175. void bfa_fcs_port_enable_ipfc_roles(struct bfa_fcs_port_s *fcs_port);
  176. void bfa_fcs_port_disable_ipfc_roles(struct bfa_fcs_port_s *fcs_port);
  177. #endif /* __BFA_FCS_PORT_H__ */