bfa_fcs_lport.h 6.8 KB

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