bfa_fcs.h 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
  4. * Copyright (c) 2014- QLogic Corporation.
  5. * All rights reserved
  6. * www.qlogic.com
  7. *
  8. * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.
  9. */
  10. #ifndef __BFA_FCS_H__
  11. #define __BFA_FCS_H__
  12. #include "bfa_cs.h"
  13. #include "bfa_defs.h"
  14. #include "bfa_defs_fcs.h"
  15. #include "bfa_modules.h"
  16. #include "bfa_fc.h"
  17. #define BFA_FCS_OS_STR_LEN 64
  18. /*
  19. * !!! Only append to the enums defined here to avoid any versioning
  20. * !!! needed between trace utility and driver version
  21. */
  22. enum {
  23. BFA_TRC_FCS_FCS = 1,
  24. BFA_TRC_FCS_PORT = 2,
  25. BFA_TRC_FCS_RPORT = 3,
  26. BFA_TRC_FCS_FCPIM = 4,
  27. };
  28. struct bfa_fcs_s;
  29. #define __fcs_min_cfg(__fcs) ((__fcs)->min_cfg)
  30. #define BFA_FCS_BRCD_SWITCH_OUI 0x051e
  31. #define N2N_LOCAL_PID 0x010000
  32. #define N2N_REMOTE_PID 0x020000
  33. #define BFA_FCS_RETRY_TIMEOUT 2000
  34. #define BFA_FCS_MAX_NS_RETRIES 5
  35. #define BFA_FCS_PID_IS_WKA(pid) ((bfa_ntoh3b(pid) > 0xFFF000) ? 1 : 0)
  36. #define BFA_FCS_MAX_RPORT_LOGINS 1024
  37. /*
  38. * VPort NS State Machine events
  39. */
  40. enum vport_ns_event {
  41. NSSM_EVENT_PORT_ONLINE = 1,
  42. NSSM_EVENT_PORT_OFFLINE = 2,
  43. NSSM_EVENT_PLOGI_SENT = 3,
  44. NSSM_EVENT_RSP_OK = 4,
  45. NSSM_EVENT_RSP_ERROR = 5,
  46. NSSM_EVENT_TIMEOUT = 6,
  47. NSSM_EVENT_NS_QUERY = 7,
  48. NSSM_EVENT_RSPNID_SENT = 8,
  49. NSSM_EVENT_RFTID_SENT = 9,
  50. NSSM_EVENT_RFFID_SENT = 10,
  51. NSSM_EVENT_GIDFT_SENT = 11,
  52. NSSM_EVENT_RNNID_SENT = 12,
  53. NSSM_EVENT_RSNN_NN_SENT = 13,
  54. };
  55. struct bfa_fcs_lport_ns_s;
  56. typedef void (*bfa_fcs_lport_ns_sm_t)(struct bfa_fcs_lport_ns_s *fsm, enum vport_ns_event);
  57. struct bfa_fcs_lport_ns_s {
  58. bfa_fcs_lport_ns_sm_t sm; /* state machine */
  59. struct bfa_timer_s timer;
  60. struct bfa_fcs_lport_s *port; /* parent port */
  61. struct bfa_fcxp_s *fcxp;
  62. struct bfa_fcxp_wqe_s fcxp_wqe;
  63. u8 num_rnnid_retries;
  64. u8 num_rsnn_nn_retries;
  65. };
  66. /*
  67. * VPort SCN State Machine events
  68. */
  69. enum port_scn_event {
  70. SCNSM_EVENT_PORT_ONLINE = 1,
  71. SCNSM_EVENT_PORT_OFFLINE = 2,
  72. SCNSM_EVENT_RSP_OK = 3,
  73. SCNSM_EVENT_RSP_ERROR = 4,
  74. SCNSM_EVENT_TIMEOUT = 5,
  75. SCNSM_EVENT_SCR_SENT = 6,
  76. };
  77. struct bfa_fcs_lport_scn_s;
  78. typedef void (*bfa_fcs_lport_scn_sm_t)(struct bfa_fcs_lport_scn_s *fsm, enum port_scn_event);
  79. struct bfa_fcs_lport_scn_s {
  80. bfa_fcs_lport_scn_sm_t sm; /* state machine */
  81. struct bfa_timer_s timer;
  82. struct bfa_fcs_lport_s *port; /* parent port */
  83. struct bfa_fcxp_s *fcxp;
  84. struct bfa_fcxp_wqe_s fcxp_wqe;
  85. };
  86. /*
  87. * FDMI State Machine events
  88. */
  89. enum port_fdmi_event {
  90. FDMISM_EVENT_PORT_ONLINE = 1,
  91. FDMISM_EVENT_PORT_OFFLINE = 2,
  92. FDMISM_EVENT_RSP_OK = 4,
  93. FDMISM_EVENT_RSP_ERROR = 5,
  94. FDMISM_EVENT_TIMEOUT = 6,
  95. FDMISM_EVENT_RHBA_SENT = 7,
  96. FDMISM_EVENT_RPRT_SENT = 8,
  97. FDMISM_EVENT_RPA_SENT = 9,
  98. };
  99. struct bfa_fcs_lport_fdmi_s;
  100. typedef void (*bfa_fcs_lport_fdmi_sm_t)(struct bfa_fcs_lport_fdmi_s *fsm, enum port_fdmi_event);
  101. struct bfa_fcs_lport_fdmi_s {
  102. bfa_fcs_lport_fdmi_sm_t sm; /* state machine */
  103. struct bfa_timer_s timer;
  104. struct bfa_fcs_lport_ms_s *ms; /* parent ms */
  105. struct bfa_fcxp_s *fcxp;
  106. struct bfa_fcxp_wqe_s fcxp_wqe;
  107. u8 retry_cnt; /* retry count */
  108. u8 rsvd[3];
  109. };
  110. /*
  111. * MS State Machine events
  112. */
  113. enum port_ms_event {
  114. MSSM_EVENT_PORT_ONLINE = 1,
  115. MSSM_EVENT_PORT_OFFLINE = 2,
  116. MSSM_EVENT_RSP_OK = 3,
  117. MSSM_EVENT_RSP_ERROR = 4,
  118. MSSM_EVENT_TIMEOUT = 5,
  119. MSSM_EVENT_FCXP_SENT = 6,
  120. MSSM_EVENT_PORT_FABRIC_RSCN = 7
  121. };
  122. struct bfa_fcs_lport_ms_s;
  123. typedef void (*bfa_fcs_lport_ms_sm_t)(struct bfa_fcs_lport_ms_s *fsm, enum port_ms_event);
  124. struct bfa_fcs_lport_ms_s {
  125. bfa_fcs_lport_ms_sm_t sm; /* state machine */
  126. struct bfa_timer_s timer;
  127. struct bfa_fcs_lport_s *port; /* parent port */
  128. struct bfa_fcxp_s *fcxp;
  129. struct bfa_fcxp_wqe_s fcxp_wqe;
  130. struct bfa_fcs_lport_fdmi_s fdmi; /* FDMI component of MS */
  131. u8 retry_cnt; /* retry count */
  132. u8 rsvd[3];
  133. };
  134. struct bfa_fcs_lport_fab_s {
  135. struct bfa_fcs_lport_ns_s ns; /* NS component of port */
  136. struct bfa_fcs_lport_scn_s scn; /* scn component of port */
  137. struct bfa_fcs_lport_ms_s ms; /* MS component of port */
  138. };
  139. #define MAX_ALPA_COUNT 127
  140. struct bfa_fcs_lport_loop_s {
  141. u8 num_alpa; /* Num of ALPA entries in the map */
  142. u8 alpabm_valid; /* alpa bitmap valid or not (1 or 0) */
  143. u8 alpa_pos_map[MAX_ALPA_COUNT]; /* ALPA Positional Map */
  144. struct bfa_fcs_lport_s *port; /* parent port */
  145. };
  146. struct bfa_fcs_lport_n2n_s {
  147. u32 rsvd;
  148. __be16 reply_oxid; /* ox_id from the req flogi to be
  149. *used in flogi acc */
  150. wwn_t rem_port_wwn; /* Attached port's wwn */
  151. };
  152. union bfa_fcs_lport_topo_u {
  153. struct bfa_fcs_lport_fab_s pfab;
  154. struct bfa_fcs_lport_loop_s ploop;
  155. struct bfa_fcs_lport_n2n_s pn2n;
  156. };
  157. /*
  158. * fcs_port_sm FCS logical port state machine
  159. */
  160. enum bfa_fcs_lport_event {
  161. BFA_FCS_PORT_SM_CREATE = 1,
  162. BFA_FCS_PORT_SM_ONLINE = 2,
  163. BFA_FCS_PORT_SM_OFFLINE = 3,
  164. BFA_FCS_PORT_SM_DELETE = 4,
  165. BFA_FCS_PORT_SM_DELRPORT = 5,
  166. BFA_FCS_PORT_SM_STOP = 6,
  167. };
  168. struct bfa_fcs_lport_s;
  169. typedef void (*bfa_fcs_lport_sm_t)(struct bfa_fcs_lport_s *fsm, enum bfa_fcs_lport_event);
  170. struct bfa_fcs_lport_s {
  171. struct list_head qe; /* used by port/vport */
  172. bfa_fcs_lport_sm_t sm; /* state machine */
  173. struct bfa_fcs_fabric_s *fabric; /* parent fabric */
  174. struct bfa_lport_cfg_s port_cfg; /* port configuration */
  175. struct bfa_timer_s link_timer; /* timer for link offline */
  176. u32 pid:24; /* FC address */
  177. u8 lp_tag; /* lport tag */
  178. u16 num_rports; /* Num of r-ports */
  179. struct list_head rport_q; /* queue of discovered r-ports */
  180. struct bfa_fcs_s *fcs; /* FCS instance */
  181. union bfa_fcs_lport_topo_u port_topo; /* fabric/loop/n2n details */
  182. struct bfad_port_s *bfad_port; /* driver peer instance */
  183. struct bfa_fcs_vport_s *vport; /* NULL for base ports */
  184. struct bfa_fcxp_s *fcxp;
  185. struct bfa_fcxp_wqe_s fcxp_wqe;
  186. struct bfa_lport_stats_s stats;
  187. struct bfa_wc_s wc; /* waiting counter for events */
  188. };
  189. #define BFA_FCS_GET_HAL_FROM_PORT(port) (port->fcs->bfa)
  190. #define BFA_FCS_GET_NS_FROM_PORT(port) (&port->port_topo.pfab.ns)
  191. #define BFA_FCS_GET_SCN_FROM_PORT(port) (&port->port_topo.pfab.scn)
  192. #define BFA_FCS_GET_MS_FROM_PORT(port) (&port->port_topo.pfab.ms)
  193. #define BFA_FCS_GET_FDMI_FROM_PORT(port) (&port->port_topo.pfab.ms.fdmi)
  194. #define BFA_FCS_VPORT_IS_INITIATOR_MODE(port) \
  195. (port->port_cfg.roles & BFA_LPORT_ROLE_FCP_IM)
  196. /*
  197. * forward declaration
  198. */
  199. struct bfad_vf_s;
  200. enum bfa_fcs_fabric_type {
  201. BFA_FCS_FABRIC_UNKNOWN = 0,
  202. BFA_FCS_FABRIC_SWITCHED = 1,
  203. BFA_FCS_FABRIC_N2N = 2,
  204. BFA_FCS_FABRIC_LOOP = 3,
  205. };
  206. /*
  207. * Fabric state machine events
  208. */
  209. enum bfa_fcs_fabric_event {
  210. BFA_FCS_FABRIC_SM_CREATE = 1, /* create from driver */
  211. BFA_FCS_FABRIC_SM_DELETE = 2, /* delete from driver */
  212. BFA_FCS_FABRIC_SM_LINK_DOWN = 3, /* link down from port */
  213. BFA_FCS_FABRIC_SM_LINK_UP = 4, /* link up from port */
  214. BFA_FCS_FABRIC_SM_CONT_OP = 5, /* flogi/auth continue op */
  215. BFA_FCS_FABRIC_SM_RETRY_OP = 6, /* flogi/auth retry op */
  216. BFA_FCS_FABRIC_SM_NO_FABRIC = 7, /* from flogi/auth */
  217. BFA_FCS_FABRIC_SM_PERF_EVFP = 8, /* from flogi/auth */
  218. BFA_FCS_FABRIC_SM_ISOLATE = 9, /* from EVFP processing */
  219. BFA_FCS_FABRIC_SM_NO_TAGGING = 10, /* no VFT tagging from EVFP */
  220. BFA_FCS_FABRIC_SM_DELAYED = 11, /* timeout delay event */
  221. BFA_FCS_FABRIC_SM_AUTH_FAILED = 12, /* auth failed */
  222. BFA_FCS_FABRIC_SM_AUTH_SUCCESS = 13, /* auth successful */
  223. BFA_FCS_FABRIC_SM_DELCOMP = 14, /* all vports deleted event */
  224. BFA_FCS_FABRIC_SM_LOOPBACK = 15, /* Received our own FLOGI */
  225. BFA_FCS_FABRIC_SM_START = 16, /* from driver */
  226. BFA_FCS_FABRIC_SM_STOP = 17, /* Stop from driver */
  227. BFA_FCS_FABRIC_SM_STOPCOMP = 18, /* Stop completion */
  228. BFA_FCS_FABRIC_SM_LOGOCOMP = 19, /* FLOGO completion */
  229. };
  230. struct bfa_fcs_fabric_s;
  231. typedef void (*bfa_fcs_fabric_sm_t)(struct bfa_fcs_fabric_s *fsm, enum bfa_fcs_fabric_event);
  232. struct bfa_fcs_fabric_s {
  233. struct list_head qe; /* queue element */
  234. bfa_fcs_fabric_sm_t sm; /* state machine */
  235. struct bfa_fcs_s *fcs; /* FCS instance */
  236. struct bfa_fcs_lport_s bport; /* base logical port */
  237. enum bfa_fcs_fabric_type fab_type; /* fabric type */
  238. enum bfa_port_type oper_type; /* current link topology */
  239. u8 is_vf; /* is virtual fabric? */
  240. u8 is_npiv; /* is NPIV supported ? */
  241. u8 is_auth; /* is Security/Auth supported ? */
  242. u16 bb_credit; /* BB credit from fabric */
  243. u16 vf_id; /* virtual fabric ID */
  244. u16 num_vports; /* num vports */
  245. u16 rsvd;
  246. struct list_head vport_q; /* queue of virtual ports */
  247. struct list_head vf_q; /* queue of virtual fabrics */
  248. struct bfad_vf_s *vf_drv; /* driver vf structure */
  249. struct bfa_timer_s link_timer; /* Link Failure timer. Vport */
  250. wwn_t fabric_name; /* attached fabric name */
  251. bfa_boolean_t auth_reqd; /* authentication required */
  252. struct bfa_timer_s delay_timer; /* delay timer */
  253. union {
  254. u16 swp_vfid;/* switch port VF id */
  255. } event_arg;
  256. struct bfa_wc_s wc; /* wait counter for delete */
  257. struct bfa_vf_stats_s stats; /* fabric/vf stats */
  258. struct bfa_lps_s *lps; /* lport login services */
  259. u8 fabric_ip_addr[BFA_FCS_FABRIC_IPADDR_SZ];
  260. /* attached fabric's ip addr */
  261. struct bfa_wc_s stop_wc; /* wait counter for stop */
  262. };
  263. #define bfa_fcs_fabric_npiv_capable(__f) ((__f)->is_npiv)
  264. #define bfa_fcs_fabric_is_switched(__f) \
  265. ((__f)->fab_type == BFA_FCS_FABRIC_SWITCHED)
  266. /*
  267. * The design calls for a single implementation of base fabric and vf.
  268. */
  269. #define bfa_fcs_vf_t struct bfa_fcs_fabric_s
  270. struct bfa_vf_event_s {
  271. u32 undefined;
  272. };
  273. /*
  274. * @todo : need to move to a global config file.
  275. * Maximum Rports supported per port (physical/logical).
  276. */
  277. #define BFA_FCS_MAX_RPORTS_SUPP 256 /* @todo : tentative value */
  278. #define bfa_fcs_lport_t struct bfa_fcs_lport_s
  279. /*
  280. * Symbolic Name related defines
  281. * Total bytes 255.
  282. * Physical Port's symbolic name 128 bytes.
  283. * For Vports, Vport's symbolic name is appended to the Physical port's
  284. * Symbolic Name.
  285. *
  286. * Physical Port's symbolic name Format : (Total 128 bytes)
  287. * Adapter Model number/name : 16 bytes
  288. * Driver Version : 10 bytes
  289. * Host Machine Name : 30 bytes
  290. * Host OS Info : 44 bytes
  291. * Host OS PATCH Info : 16 bytes
  292. * ( remaining 12 bytes reserved to be used for separator)
  293. */
  294. #define BFA_FCS_PORT_SYMBNAME_SEPARATOR " | "
  295. #define BFA_FCS_PORT_SYMBNAME_MODEL_SZ 16
  296. #define BFA_FCS_PORT_SYMBNAME_VERSION_SZ 10
  297. #define BFA_FCS_PORT_SYMBNAME_MACHINENAME_SZ 30
  298. #define BFA_FCS_PORT_SYMBNAME_OSINFO_SZ 44
  299. #define BFA_FCS_PORT_SYMBNAME_OSPATCH_SZ 16
  300. /*
  301. * Get FC port ID for a logical port.
  302. */
  303. #define bfa_fcs_lport_get_fcid(_lport) ((_lport)->pid)
  304. #define bfa_fcs_lport_get_pwwn(_lport) ((_lport)->port_cfg.pwwn)
  305. #define bfa_fcs_lport_get_nwwn(_lport) ((_lport)->port_cfg.nwwn)
  306. #define bfa_fcs_lport_get_psym_name(_lport) ((_lport)->port_cfg.sym_name)
  307. #define bfa_fcs_lport_get_nsym_name(_lport) ((_lport)->port_cfg.node_sym_name)
  308. #define bfa_fcs_lport_is_initiator(_lport) \
  309. ((_lport)->port_cfg.roles & BFA_LPORT_ROLE_FCP_IM)
  310. #define bfa_fcs_lport_get_nrports(_lport) \
  311. ((_lport) ? (_lport)->num_rports : 0)
  312. static inline struct bfad_port_s *
  313. bfa_fcs_lport_get_drvport(struct bfa_fcs_lport_s *port)
  314. {
  315. return port->bfad_port;
  316. }
  317. #define bfa_fcs_lport_get_opertype(_lport) ((_lport)->fabric->oper_type)
  318. #define bfa_fcs_lport_get_fabric_name(_lport) ((_lport)->fabric->fabric_name)
  319. #define bfa_fcs_lport_get_fabric_ipaddr(_lport) \
  320. ((_lport)->fabric->fabric_ip_addr)
  321. /*
  322. * bfa fcs port public functions
  323. */
  324. bfa_boolean_t bfa_fcs_lport_is_online(struct bfa_fcs_lport_s *port);
  325. struct bfa_fcs_lport_s *bfa_fcs_get_base_port(struct bfa_fcs_s *fcs);
  326. void bfa_fcs_lport_get_rport_quals(struct bfa_fcs_lport_s *port,
  327. struct bfa_rport_qualifier_s rport[], int *nrports);
  328. wwn_t bfa_fcs_lport_get_rport(struct bfa_fcs_lport_s *port, wwn_t wwn,
  329. int index, int nrports, bfa_boolean_t bwwn);
  330. struct bfa_fcs_lport_s *bfa_fcs_lookup_port(struct bfa_fcs_s *fcs,
  331. u16 vf_id, wwn_t lpwwn);
  332. void bfa_fcs_lport_set_symname(struct bfa_fcs_lport_s *port, char *symname);
  333. void bfa_fcs_lport_get_info(struct bfa_fcs_lport_s *port,
  334. struct bfa_lport_info_s *port_info);
  335. void bfa_fcs_lport_get_attr(struct bfa_fcs_lport_s *port,
  336. struct bfa_lport_attr_s *port_attr);
  337. void bfa_fcs_lport_get_stats(struct bfa_fcs_lport_s *fcs_port,
  338. struct bfa_lport_stats_s *port_stats);
  339. void bfa_fcs_lport_clear_stats(struct bfa_fcs_lport_s *fcs_port);
  340. enum bfa_port_speed bfa_fcs_lport_get_rport_max_speed(
  341. struct bfa_fcs_lport_s *port);
  342. /* MS FCS routines */
  343. void bfa_fcs_lport_ms_init(struct bfa_fcs_lport_s *port);
  344. void bfa_fcs_lport_ms_offline(struct bfa_fcs_lport_s *port);
  345. void bfa_fcs_lport_ms_online(struct bfa_fcs_lport_s *port);
  346. void bfa_fcs_lport_ms_fabric_rscn(struct bfa_fcs_lport_s *port);
  347. /* FDMI FCS routines */
  348. void bfa_fcs_lport_fdmi_init(struct bfa_fcs_lport_ms_s *ms);
  349. void bfa_fcs_lport_fdmi_offline(struct bfa_fcs_lport_ms_s *ms);
  350. void bfa_fcs_lport_fdmi_online(struct bfa_fcs_lport_ms_s *ms);
  351. void bfa_fcs_lport_uf_recv(struct bfa_fcs_lport_s *lport, struct fchs_s *fchs,
  352. u16 len);
  353. void bfa_fcs_lport_attach(struct bfa_fcs_lport_s *lport, struct bfa_fcs_s *fcs,
  354. u16 vf_id, struct bfa_fcs_vport_s *vport);
  355. void bfa_fcs_lport_init(struct bfa_fcs_lport_s *lport,
  356. struct bfa_lport_cfg_s *port_cfg);
  357. void bfa_fcs_lport_online(struct bfa_fcs_lport_s *port);
  358. void bfa_fcs_lport_offline(struct bfa_fcs_lport_s *port);
  359. void bfa_fcs_lport_delete(struct bfa_fcs_lport_s *port);
  360. void bfa_fcs_lport_stop(struct bfa_fcs_lport_s *port);
  361. struct bfa_fcs_rport_s *bfa_fcs_lport_get_rport_by_pid(
  362. struct bfa_fcs_lport_s *port, u32 pid);
  363. struct bfa_fcs_rport_s *bfa_fcs_lport_get_rport_by_old_pid(
  364. struct bfa_fcs_lport_s *port, u32 pid);
  365. struct bfa_fcs_rport_s *bfa_fcs_lport_get_rport_by_pwwn(
  366. struct bfa_fcs_lport_s *port, wwn_t pwwn);
  367. struct bfa_fcs_rport_s *bfa_fcs_lport_get_rport_by_nwwn(
  368. struct bfa_fcs_lport_s *port, wwn_t nwwn);
  369. struct bfa_fcs_rport_s *bfa_fcs_lport_get_rport_by_qualifier(
  370. struct bfa_fcs_lport_s *port, wwn_t pwwn, u32 pid);
  371. void bfa_fcs_lport_add_rport(struct bfa_fcs_lport_s *port,
  372. struct bfa_fcs_rport_s *rport);
  373. void bfa_fcs_lport_del_rport(struct bfa_fcs_lport_s *port,
  374. struct bfa_fcs_rport_s *rport);
  375. void bfa_fcs_lport_ns_init(struct bfa_fcs_lport_s *vport);
  376. void bfa_fcs_lport_ns_offline(struct bfa_fcs_lport_s *vport);
  377. void bfa_fcs_lport_ns_online(struct bfa_fcs_lport_s *vport);
  378. void bfa_fcs_lport_ns_query(struct bfa_fcs_lport_s *port);
  379. void bfa_fcs_lport_ns_util_send_rspn_id(void *cbarg,
  380. struct bfa_fcxp_s *fcxp_alloced);
  381. void bfa_fcs_lport_scn_init(struct bfa_fcs_lport_s *vport);
  382. void bfa_fcs_lport_scn_offline(struct bfa_fcs_lport_s *vport);
  383. void bfa_fcs_lport_fab_scn_online(struct bfa_fcs_lport_s *vport);
  384. void bfa_fcs_lport_scn_process_rscn(struct bfa_fcs_lport_s *port,
  385. struct fchs_s *rx_frame, u32 len);
  386. void bfa_fcs_lport_lip_scn_online(bfa_fcs_lport_t *port);
  387. /*
  388. * VPort State Machine events
  389. */
  390. enum bfa_fcs_vport_event {
  391. BFA_FCS_VPORT_SM_CREATE = 1, /* vport create event */
  392. BFA_FCS_VPORT_SM_DELETE = 2, /* vport delete event */
  393. BFA_FCS_VPORT_SM_START = 3, /* vport start request */
  394. BFA_FCS_VPORT_SM_STOP = 4, /* stop: unsupported */
  395. BFA_FCS_VPORT_SM_ONLINE = 5, /* fabric online */
  396. BFA_FCS_VPORT_SM_OFFLINE = 6, /* fabric offline event */
  397. BFA_FCS_VPORT_SM_FRMSENT = 7, /* fdisc/logo sent events */
  398. BFA_FCS_VPORT_SM_RSP_OK = 8, /* good response */
  399. BFA_FCS_VPORT_SM_RSP_ERROR = 9, /* error/bad response */
  400. BFA_FCS_VPORT_SM_TIMEOUT = 10, /* delay timer event */
  401. BFA_FCS_VPORT_SM_DELCOMP = 11, /* lport delete completion */
  402. BFA_FCS_VPORT_SM_RSP_DUP_WWN = 12, /* Dup wnn error*/
  403. BFA_FCS_VPORT_SM_RSP_FAILED = 13, /* non-retryable failure */
  404. BFA_FCS_VPORT_SM_STOPCOMP = 14, /* vport delete completion */
  405. BFA_FCS_VPORT_SM_FABRIC_MAX = 15, /* max vports on fabric */
  406. };
  407. struct bfa_fcs_vport_s;
  408. typedef void (*bfa_fcs_vport_sm_t)(struct bfa_fcs_vport_s *fsm, enum bfa_fcs_vport_event);
  409. struct bfa_fcs_vport_s {
  410. struct list_head qe; /* queue elem */
  411. bfa_fcs_vport_sm_t sm; /* state machine */
  412. bfa_fcs_lport_t lport; /* logical port */
  413. struct bfa_timer_s timer;
  414. struct bfad_vport_s *vport_drv; /* Driver private */
  415. struct bfa_vport_stats_s vport_stats; /* vport statistics */
  416. struct bfa_lps_s *lps; /* Lport login service*/
  417. int fdisc_retries;
  418. };
  419. #define bfa_fcs_vport_get_port(vport) \
  420. ((struct bfa_fcs_lport_s *)(&vport->port))
  421. /*
  422. * bfa fcs vport public functions
  423. */
  424. bfa_status_t bfa_fcs_vport_create(struct bfa_fcs_vport_s *vport,
  425. struct bfa_fcs_s *fcs, u16 vf_id,
  426. struct bfa_lport_cfg_s *port_cfg,
  427. struct bfad_vport_s *vport_drv);
  428. bfa_status_t bfa_fcs_pbc_vport_create(struct bfa_fcs_vport_s *vport,
  429. struct bfa_fcs_s *fcs, u16 vf_id,
  430. struct bfa_lport_cfg_s *port_cfg,
  431. struct bfad_vport_s *vport_drv);
  432. bfa_boolean_t bfa_fcs_is_pbc_vport(struct bfa_fcs_vport_s *vport);
  433. bfa_status_t bfa_fcs_vport_delete(struct bfa_fcs_vport_s *vport);
  434. bfa_status_t bfa_fcs_vport_start(struct bfa_fcs_vport_s *vport);
  435. bfa_status_t bfa_fcs_vport_stop(struct bfa_fcs_vport_s *vport);
  436. void bfa_fcs_vport_get_attr(struct bfa_fcs_vport_s *vport,
  437. struct bfa_vport_attr_s *vport_attr);
  438. struct bfa_fcs_vport_s *bfa_fcs_vport_lookup(struct bfa_fcs_s *fcs,
  439. u16 vf_id, wwn_t vpwwn);
  440. void bfa_fcs_vport_cleanup(struct bfa_fcs_vport_s *vport);
  441. void bfa_fcs_vport_online(struct bfa_fcs_vport_s *vport);
  442. void bfa_fcs_vport_offline(struct bfa_fcs_vport_s *vport);
  443. void bfa_fcs_vport_delete_comp(struct bfa_fcs_vport_s *vport);
  444. void bfa_fcs_vport_fcs_delete(struct bfa_fcs_vport_s *vport);
  445. void bfa_fcs_vport_fcs_stop(struct bfa_fcs_vport_s *vport);
  446. void bfa_fcs_vport_stop_comp(struct bfa_fcs_vport_s *vport);
  447. #define BFA_FCS_RPORT_DEF_DEL_TIMEOUT 90 /* in secs */
  448. #define BFA_FCS_RPORT_MAX_RETRIES (5)
  449. /*
  450. * forward declarations
  451. */
  452. struct bfad_rport_s;
  453. struct bfa_fcs_itnim_s;
  454. struct bfa_fcs_tin_s;
  455. struct bfa_fcs_iprp_s;
  456. /*
  457. * fcs_rport_ftrs_sm FCS rport state machine events
  458. */
  459. enum rpf_event {
  460. RPFSM_EVENT_RPORT_OFFLINE = 1, /* Rport offline */
  461. RPFSM_EVENT_RPORT_ONLINE = 2, /* Rport online */
  462. RPFSM_EVENT_FCXP_SENT = 3, /* Frame from has been sent */
  463. RPFSM_EVENT_TIMEOUT = 4, /* Rport SM timeout event */
  464. RPFSM_EVENT_RPSC_COMP = 5,
  465. RPFSM_EVENT_RPSC_FAIL = 6,
  466. RPFSM_EVENT_RPSC_ERROR = 7,
  467. };
  468. struct bfa_fcs_rpf_s;
  469. typedef void (*bfa_fcs_rpf_sm_t)(struct bfa_fcs_rpf_s *, enum rpf_event);
  470. /* Rport Features (RPF) */
  471. struct bfa_fcs_rpf_s {
  472. bfa_fcs_rpf_sm_t sm; /* state machine */
  473. struct bfa_fcs_rport_s *rport; /* parent rport */
  474. struct bfa_timer_s timer; /* general purpose timer */
  475. struct bfa_fcxp_s *fcxp; /* FCXP needed for discarding */
  476. struct bfa_fcxp_wqe_s fcxp_wqe; /* fcxp wait queue element */
  477. int rpsc_retries; /* max RPSC retry attempts */
  478. enum bfa_port_speed rpsc_speed;
  479. /* Current Speed from RPSC. O if RPSC fails */
  480. enum bfa_port_speed assigned_speed;
  481. /*
  482. * Speed assigned by the user. will be used if RPSC is
  483. * not supported by the rport.
  484. */
  485. };
  486. /*
  487. * fcs_rport_sm FCS rport state machine events
  488. */
  489. enum rport_event {
  490. RPSM_EVENT_PLOGI_SEND = 1, /* new rport; start with PLOGI */
  491. RPSM_EVENT_PLOGI_RCVD = 2, /* Inbound PLOGI from remote port */
  492. RPSM_EVENT_PLOGI_COMP = 3, /* PLOGI completed to rport */
  493. RPSM_EVENT_LOGO_RCVD = 4, /* LOGO from remote device */
  494. RPSM_EVENT_LOGO_IMP = 5, /* implicit logo for SLER */
  495. RPSM_EVENT_FCXP_SENT = 6, /* Frame from has been sent */
  496. RPSM_EVENT_DELETE = 7, /* RPORT delete request */
  497. RPSM_EVENT_FAB_SCN = 8, /* state change notification */
  498. RPSM_EVENT_ACCEPTED = 9, /* Good response from remote device */
  499. RPSM_EVENT_FAILED = 10, /* Request to rport failed. */
  500. RPSM_EVENT_TIMEOUT = 11, /* Rport SM timeout event */
  501. RPSM_EVENT_HCB_ONLINE = 12, /* BFA rport online callback */
  502. RPSM_EVENT_HCB_OFFLINE = 13, /* BFA rport offline callback */
  503. RPSM_EVENT_FC4_OFFLINE = 14, /* FC-4 offline complete */
  504. RPSM_EVENT_ADDRESS_CHANGE = 15, /* Rport's PID has changed */
  505. RPSM_EVENT_ADDRESS_DISC = 16, /* Need to Discover rport's PID */
  506. RPSM_EVENT_PRLO_RCVD = 17, /* PRLO from remote device */
  507. RPSM_EVENT_PLOGI_RETRY = 18, /* Retry PLOGI continuously */
  508. RPSM_EVENT_SCN_OFFLINE = 19, /* loop scn offline */
  509. RPSM_EVENT_SCN_ONLINE = 20, /* loop scn online */
  510. RPSM_EVENT_FC4_FCS_ONLINE = 21, /* FC-4 FCS online complete */
  511. };
  512. struct bfa_fcs_rport_s;
  513. typedef void (*bfa_fcs_rport_sm_t)(struct bfa_fcs_rport_s *, enum rport_event);
  514. struct bfa_fcs_rport_s {
  515. struct list_head qe; /* used by port/vport */
  516. struct bfa_fcs_lport_s *port; /* parent FCS port */
  517. struct bfa_fcs_s *fcs; /* fcs instance */
  518. struct bfad_rport_s *rp_drv; /* driver peer instance */
  519. u32 pid; /* port ID of rport */
  520. u32 old_pid; /* PID before rport goes offline */
  521. u16 maxfrsize; /* maximum frame size */
  522. __be16 reply_oxid; /* OX_ID of inbound requests */
  523. enum fc_cos fc_cos; /* FC classes of service supp */
  524. bfa_boolean_t cisc; /* CISC capable device */
  525. bfa_boolean_t prlo; /* processing prlo or LOGO */
  526. bfa_boolean_t plogi_pending; /* Rx Plogi Pending */
  527. wwn_t pwwn; /* port wwn of rport */
  528. wwn_t nwwn; /* node wwn of rport */
  529. struct bfa_rport_symname_s psym_name; /* port symbolic name */
  530. bfa_fcs_rport_sm_t sm; /* state machine */
  531. struct bfa_timer_s timer; /* general purpose timer */
  532. struct bfa_fcs_itnim_s *itnim; /* ITN initiator mode role */
  533. struct bfa_fcs_tin_s *tin; /* ITN initiator mode role */
  534. struct bfa_fcs_iprp_s *iprp; /* IP/FC role */
  535. struct bfa_rport_s *bfa_rport; /* BFA Rport */
  536. struct bfa_fcxp_s *fcxp; /* FCXP needed for discarding */
  537. int plogi_retries; /* max plogi retry attempts */
  538. int ns_retries; /* max NS query retry attempts */
  539. struct bfa_fcxp_wqe_s fcxp_wqe; /* fcxp wait queue element */
  540. struct bfa_rport_stats_s stats; /* rport stats */
  541. enum bfa_rport_function scsi_function; /* Initiator/Target */
  542. struct bfa_fcs_rpf_s rpf; /* Rport features module */
  543. bfa_boolean_t scn_online; /* SCN online flag */
  544. };
  545. static inline struct bfa_rport_s *
  546. bfa_fcs_rport_get_halrport(struct bfa_fcs_rport_s *rport)
  547. {
  548. return rport->bfa_rport;
  549. }
  550. /*
  551. * bfa fcs rport API functions
  552. */
  553. void bfa_fcs_rport_get_attr(struct bfa_fcs_rport_s *rport,
  554. struct bfa_rport_attr_s *attr);
  555. struct bfa_fcs_rport_s *bfa_fcs_rport_lookup(struct bfa_fcs_lport_s *port,
  556. wwn_t rpwwn);
  557. struct bfa_fcs_rport_s *bfa_fcs_rport_lookup_by_nwwn(
  558. struct bfa_fcs_lport_s *port, wwn_t rnwwn);
  559. void bfa_fcs_rport_set_del_timeout(u8 rport_tmo);
  560. void bfa_fcs_rport_set_max_logins(u32 max_logins);
  561. void bfa_fcs_rport_uf_recv(struct bfa_fcs_rport_s *rport,
  562. struct fchs_s *fchs, u16 len);
  563. void bfa_fcs_rport_scn(struct bfa_fcs_rport_s *rport);
  564. struct bfa_fcs_rport_s *bfa_fcs_rport_create(struct bfa_fcs_lport_s *port,
  565. u32 pid);
  566. void bfa_fcs_rport_start(struct bfa_fcs_lport_s *port, struct fchs_s *rx_fchs,
  567. struct fc_logi_s *plogi_rsp);
  568. void bfa_fcs_rport_plogi_create(struct bfa_fcs_lport_s *port,
  569. struct fchs_s *rx_fchs,
  570. struct fc_logi_s *plogi);
  571. void bfa_fcs_rport_plogi(struct bfa_fcs_rport_s *rport, struct fchs_s *fchs,
  572. struct fc_logi_s *plogi);
  573. void bfa_fcs_rport_prlo(struct bfa_fcs_rport_s *rport, __be16 ox_id);
  574. void bfa_fcs_rport_itntm_ack(struct bfa_fcs_rport_s *rport);
  575. void bfa_fcs_rport_fcptm_offline_done(struct bfa_fcs_rport_s *rport);
  576. int bfa_fcs_rport_get_state(struct bfa_fcs_rport_s *rport);
  577. struct bfa_fcs_rport_s *bfa_fcs_rport_create_by_wwn(
  578. struct bfa_fcs_lport_s *port, wwn_t wwn);
  579. void bfa_fcs_rpf_init(struct bfa_fcs_rport_s *rport);
  580. void bfa_fcs_rpf_rport_online(struct bfa_fcs_rport_s *rport);
  581. void bfa_fcs_rpf_rport_offline(struct bfa_fcs_rport_s *rport);
  582. /*
  583. * fcs_itnim_sm FCS itnim state machine events
  584. */
  585. enum bfa_fcs_itnim_event {
  586. BFA_FCS_ITNIM_SM_FCS_ONLINE = 1, /* rport online event */
  587. BFA_FCS_ITNIM_SM_OFFLINE = 2, /* rport offline */
  588. BFA_FCS_ITNIM_SM_FRMSENT = 3, /* prli frame is sent */
  589. BFA_FCS_ITNIM_SM_RSP_OK = 4, /* good response */
  590. BFA_FCS_ITNIM_SM_RSP_ERROR = 5, /* error response */
  591. BFA_FCS_ITNIM_SM_TIMEOUT = 6, /* delay timeout */
  592. BFA_FCS_ITNIM_SM_HCB_OFFLINE = 7, /* BFA online callback */
  593. BFA_FCS_ITNIM_SM_HCB_ONLINE = 8, /* BFA offline callback */
  594. BFA_FCS_ITNIM_SM_INITIATOR = 9, /* rport is initiator */
  595. BFA_FCS_ITNIM_SM_DELETE = 10, /* delete event from rport */
  596. BFA_FCS_ITNIM_SM_PRLO = 11, /* delete event from rport */
  597. BFA_FCS_ITNIM_SM_RSP_NOT_SUPP = 12, /* cmd not supported rsp */
  598. BFA_FCS_ITNIM_SM_HAL_ONLINE = 13, /* bfa rport online event */
  599. };
  600. struct bfa_fcs_itnim_s;
  601. typedef void (*bfa_fcs_itnim_sm_t)(struct bfa_fcs_itnim_s *, enum bfa_fcs_itnim_event);
  602. /*
  603. * forward declarations
  604. */
  605. struct bfad_itnim_s;
  606. struct bfa_fcs_itnim_s {
  607. bfa_fcs_itnim_sm_t sm; /* state machine */
  608. struct bfa_fcs_rport_s *rport; /* parent remote rport */
  609. struct bfad_itnim_s *itnim_drv; /* driver peer instance */
  610. struct bfa_fcs_s *fcs; /* fcs instance */
  611. struct bfa_timer_s timer; /* timer functions */
  612. struct bfa_itnim_s *bfa_itnim; /* BFA itnim struct */
  613. u32 prli_retries; /* max prli retry attempts */
  614. bfa_boolean_t seq_rec; /* seq recovery support */
  615. bfa_boolean_t rec_support; /* REC supported */
  616. bfa_boolean_t conf_comp; /* FCP_CONF support */
  617. bfa_boolean_t task_retry_id; /* task retry id supp */
  618. struct bfa_fcxp_wqe_s fcxp_wqe; /* wait qelem for fcxp */
  619. struct bfa_fcxp_s *fcxp; /* FCXP in use */
  620. struct bfa_itnim_stats_s stats; /* itn statistics */
  621. };
  622. #define bfa_fcs_fcxp_alloc(__fcs, __req) \
  623. bfa_fcxp_req_rsp_alloc(NULL, (__fcs)->bfa, 0, 0, \
  624. NULL, NULL, NULL, NULL, __req)
  625. #define bfa_fcs_fcxp_alloc_wait(__bfa, __wqe, __alloc_cbfn, \
  626. __alloc_cbarg, __req) \
  627. bfa_fcxp_req_rsp_alloc_wait(__bfa, __wqe, __alloc_cbfn, \
  628. __alloc_cbarg, NULL, 0, 0, NULL, NULL, NULL, NULL, __req)
  629. static inline struct bfad_port_s *
  630. bfa_fcs_itnim_get_drvport(struct bfa_fcs_itnim_s *itnim)
  631. {
  632. return itnim->rport->port->bfad_port;
  633. }
  634. static inline struct bfa_fcs_lport_s *
  635. bfa_fcs_itnim_get_port(struct bfa_fcs_itnim_s *itnim)
  636. {
  637. return itnim->rport->port;
  638. }
  639. static inline wwn_t
  640. bfa_fcs_itnim_get_nwwn(struct bfa_fcs_itnim_s *itnim)
  641. {
  642. return itnim->rport->nwwn;
  643. }
  644. static inline wwn_t
  645. bfa_fcs_itnim_get_pwwn(struct bfa_fcs_itnim_s *itnim)
  646. {
  647. return itnim->rport->pwwn;
  648. }
  649. static inline u32
  650. bfa_fcs_itnim_get_fcid(struct bfa_fcs_itnim_s *itnim)
  651. {
  652. return itnim->rport->pid;
  653. }
  654. static inline u32
  655. bfa_fcs_itnim_get_maxfrsize(struct bfa_fcs_itnim_s *itnim)
  656. {
  657. return itnim->rport->maxfrsize;
  658. }
  659. static inline enum fc_cos
  660. bfa_fcs_itnim_get_cos(struct bfa_fcs_itnim_s *itnim)
  661. {
  662. return itnim->rport->fc_cos;
  663. }
  664. static inline struct bfad_itnim_s *
  665. bfa_fcs_itnim_get_drvitn(struct bfa_fcs_itnim_s *itnim)
  666. {
  667. return itnim->itnim_drv;
  668. }
  669. static inline struct bfa_itnim_s *
  670. bfa_fcs_itnim_get_halitn(struct bfa_fcs_itnim_s *itnim)
  671. {
  672. return itnim->bfa_itnim;
  673. }
  674. /*
  675. * bfa fcs FCP Initiator mode API functions
  676. */
  677. void bfa_fcs_itnim_get_attr(struct bfa_fcs_itnim_s *itnim,
  678. struct bfa_itnim_attr_s *attr);
  679. void bfa_fcs_itnim_get_stats(struct bfa_fcs_itnim_s *itnim,
  680. struct bfa_itnim_stats_s *stats);
  681. struct bfa_fcs_itnim_s *bfa_fcs_itnim_lookup(struct bfa_fcs_lport_s *port,
  682. wwn_t rpwwn);
  683. bfa_status_t bfa_fcs_itnim_attr_get(struct bfa_fcs_lport_s *port, wwn_t rpwwn,
  684. struct bfa_itnim_attr_s *attr);
  685. bfa_status_t bfa_fcs_itnim_stats_get(struct bfa_fcs_lport_s *port, wwn_t rpwwn,
  686. struct bfa_itnim_stats_s *stats);
  687. bfa_status_t bfa_fcs_itnim_stats_clear(struct bfa_fcs_lport_s *port,
  688. wwn_t rpwwn);
  689. struct bfa_fcs_itnim_s *bfa_fcs_itnim_create(struct bfa_fcs_rport_s *rport);
  690. void bfa_fcs_itnim_delete(struct bfa_fcs_itnim_s *itnim);
  691. void bfa_fcs_itnim_rport_offline(struct bfa_fcs_itnim_s *itnim);
  692. void bfa_fcs_itnim_brp_online(struct bfa_fcs_itnim_s *itnim);
  693. bfa_status_t bfa_fcs_itnim_get_online_state(struct bfa_fcs_itnim_s *itnim);
  694. void bfa_fcs_itnim_is_initiator(struct bfa_fcs_itnim_s *itnim);
  695. void bfa_fcs_fcpim_uf_recv(struct bfa_fcs_itnim_s *itnim,
  696. struct fchs_s *fchs, u16 len);
  697. #define BFA_FCS_FDMI_SUPP_SPEEDS_4G (FDMI_TRANS_SPEED_1G | \
  698. FDMI_TRANS_SPEED_2G | \
  699. FDMI_TRANS_SPEED_4G)
  700. #define BFA_FCS_FDMI_SUPP_SPEEDS_8G (FDMI_TRANS_SPEED_1G | \
  701. FDMI_TRANS_SPEED_2G | \
  702. FDMI_TRANS_SPEED_4G | \
  703. FDMI_TRANS_SPEED_8G)
  704. #define BFA_FCS_FDMI_SUPP_SPEEDS_16G (FDMI_TRANS_SPEED_2G | \
  705. FDMI_TRANS_SPEED_4G | \
  706. FDMI_TRANS_SPEED_8G | \
  707. FDMI_TRANS_SPEED_16G)
  708. #define BFA_FCS_FDMI_SUPP_SPEEDS_10G FDMI_TRANS_SPEED_10G
  709. #define BFA_FCS_FDMI_VENDOR_INFO_LEN 8
  710. #define BFA_FCS_FDMI_FC4_TYPE_LEN 32
  711. /*
  712. * HBA Attribute Block : BFA internal representation. Note : Some variable
  713. * sizes have been trimmed to suit BFA For Ex : Model will be "QLogic ". Based
  714. * on this the size has been reduced to 16 bytes from the standard's 64 bytes.
  715. */
  716. struct bfa_fcs_fdmi_hba_attr_s {
  717. wwn_t node_name;
  718. u8 manufacturer[64];
  719. u8 serial_num[64];
  720. u8 model[16];
  721. u8 model_desc[128];
  722. u8 hw_version[8];
  723. u8 driver_version[BFA_VERSION_LEN];
  724. u8 option_rom_ver[BFA_VERSION_LEN];
  725. u8 fw_version[BFA_VERSION_LEN];
  726. u8 os_name[256];
  727. __be32 max_ct_pyld;
  728. struct bfa_lport_symname_s node_sym_name;
  729. u8 vendor_info[BFA_FCS_FDMI_VENDOR_INFO_LEN];
  730. __be32 num_ports;
  731. wwn_t fabric_name;
  732. u8 bios_ver[BFA_VERSION_LEN];
  733. };
  734. /*
  735. * Port Attribute Block
  736. */
  737. struct bfa_fcs_fdmi_port_attr_s {
  738. u8 supp_fc4_types[BFA_FCS_FDMI_FC4_TYPE_LEN];
  739. __be32 supp_speed; /* supported speed */
  740. __be32 curr_speed; /* current Speed */
  741. __be32 max_frm_size; /* max frame size */
  742. u8 os_device_name[256]; /* OS device Name */
  743. u8 host_name[256]; /* host name */
  744. wwn_t port_name;
  745. wwn_t node_name;
  746. struct bfa_lport_symname_s port_sym_name;
  747. __be32 port_type;
  748. enum fc_cos scos;
  749. wwn_t port_fabric_name;
  750. u8 port_act_fc4_type[BFA_FCS_FDMI_FC4_TYPE_LEN];
  751. __be32 port_state;
  752. __be32 num_ports;
  753. };
  754. struct bfa_fcs_stats_s {
  755. struct {
  756. u32 untagged; /* untagged receive frames */
  757. u32 tagged; /* tagged receive frames */
  758. u32 vfid_unknown; /* VF id is unknown */
  759. } uf;
  760. };
  761. struct bfa_fcs_driver_info_s {
  762. u8 version[BFA_VERSION_LEN]; /* Driver Version */
  763. u8 host_machine_name[BFA_FCS_OS_STR_LEN];
  764. u8 host_os_name[BFA_FCS_OS_STR_LEN]; /* OS name and version */
  765. u8 host_os_patch[BFA_FCS_OS_STR_LEN]; /* patch or service pack */
  766. u8 os_device_name[BFA_FCS_OS_STR_LEN]; /* Driver Device Name */
  767. };
  768. struct bfa_fcs_s {
  769. struct bfa_s *bfa; /* corresponding BFA bfa instance */
  770. struct bfad_s *bfad; /* corresponding BDA driver instance */
  771. struct bfa_trc_mod_s *trcmod; /* tracing module */
  772. bfa_boolean_t vf_enabled; /* VF mode is enabled */
  773. bfa_boolean_t fdmi_enabled; /* FDMI is enabled */
  774. bfa_boolean_t min_cfg; /* min cfg enabled/disabled */
  775. u16 port_vfid; /* port default VF ID */
  776. struct bfa_fcs_driver_info_s driver_info;
  777. struct bfa_fcs_fabric_s fabric; /* base fabric state machine */
  778. struct bfa_fcs_stats_s stats; /* FCS statistics */
  779. struct bfa_wc_s wc; /* waiting counter */
  780. int fcs_aen_seq;
  781. u32 num_rport_logins;
  782. };
  783. /*
  784. * fcs_fabric_sm fabric state machine functions
  785. */
  786. /*
  787. * bfa fcs API functions
  788. */
  789. void bfa_fcs_attach(struct bfa_fcs_s *fcs, struct bfa_s *bfa,
  790. struct bfad_s *bfad,
  791. bfa_boolean_t min_cfg);
  792. void bfa_fcs_init(struct bfa_fcs_s *fcs);
  793. void bfa_fcs_pbc_vport_init(struct bfa_fcs_s *fcs);
  794. void bfa_fcs_update_cfg(struct bfa_fcs_s *fcs);
  795. void bfa_fcs_driver_info_init(struct bfa_fcs_s *fcs,
  796. struct bfa_fcs_driver_info_s *driver_info);
  797. void bfa_fcs_exit(struct bfa_fcs_s *fcs);
  798. void bfa_fcs_stop(struct bfa_fcs_s *fcs);
  799. /*
  800. * bfa fcs vf public functions
  801. */
  802. bfa_fcs_vf_t *bfa_fcs_vf_lookup(struct bfa_fcs_s *fcs, u16 vf_id);
  803. void bfa_fcs_vf_get_ports(bfa_fcs_vf_t *vf, wwn_t vpwwn[], int *nports);
  804. /*
  805. * fabric protected interface functions
  806. */
  807. void bfa_fcs_fabric_modinit(struct bfa_fcs_s *fcs);
  808. void bfa_fcs_fabric_link_up(struct bfa_fcs_fabric_s *fabric);
  809. void bfa_fcs_fabric_link_down(struct bfa_fcs_fabric_s *fabric);
  810. void bfa_fcs_fabric_addvport(struct bfa_fcs_fabric_s *fabric,
  811. struct bfa_fcs_vport_s *vport);
  812. void bfa_fcs_fabric_delvport(struct bfa_fcs_fabric_s *fabric,
  813. struct bfa_fcs_vport_s *vport);
  814. struct bfa_fcs_vport_s *bfa_fcs_fabric_vport_lookup(
  815. struct bfa_fcs_fabric_s *fabric, wwn_t pwwn);
  816. void bfa_fcs_fabric_modstart(struct bfa_fcs_s *fcs);
  817. void bfa_fcs_fabric_uf_recv(struct bfa_fcs_fabric_s *fabric,
  818. struct fchs_s *fchs, u16 len);
  819. void bfa_fcs_fabric_psymb_init(struct bfa_fcs_fabric_s *fabric);
  820. void bfa_fcs_fabric_nsymb_init(struct bfa_fcs_fabric_s *fabric);
  821. void bfa_fcs_fabric_set_fabric_name(struct bfa_fcs_fabric_s *fabric,
  822. wwn_t fabric_name);
  823. u16 bfa_fcs_fabric_get_switch_oui(struct bfa_fcs_fabric_s *fabric);
  824. void bfa_fcs_fabric_modstop(struct bfa_fcs_s *fcs);
  825. void bfa_fcs_fabric_sm_online(struct bfa_fcs_fabric_s *fabric,
  826. enum bfa_fcs_fabric_event event);
  827. void bfa_fcs_fabric_sm_loopback(struct bfa_fcs_fabric_s *fabric,
  828. enum bfa_fcs_fabric_event event);
  829. void bfa_fcs_fabric_sm_auth_failed(struct bfa_fcs_fabric_s *fabric,
  830. enum bfa_fcs_fabric_event event);
  831. /*
  832. * BFA FCS callback interfaces
  833. */
  834. /*
  835. * fcb Main fcs callbacks
  836. */
  837. struct bfad_port_s;
  838. struct bfad_vport_s;
  839. /*
  840. * lport callbacks
  841. */
  842. struct bfad_port_s *bfa_fcb_lport_new(struct bfad_s *bfad,
  843. struct bfa_fcs_lport_s *port,
  844. enum bfa_lport_role roles,
  845. struct bfad_vf_s *vf_drv,
  846. struct bfad_vport_s *vp_drv);
  847. /*
  848. * vport callbacks
  849. */
  850. void bfa_fcb_pbc_vport_create(struct bfad_s *bfad, struct bfi_pbc_vport_s);
  851. /*
  852. * rport callbacks
  853. */
  854. bfa_status_t bfa_fcb_rport_alloc(struct bfad_s *bfad,
  855. struct bfa_fcs_rport_s **rport,
  856. struct bfad_rport_s **rport_drv);
  857. /*
  858. * itnim callbacks
  859. */
  860. int bfa_fcb_itnim_alloc(struct bfad_s *bfad, struct bfa_fcs_itnim_s **itnim,
  861. struct bfad_itnim_s **itnim_drv);
  862. void bfa_fcb_itnim_free(struct bfad_s *bfad,
  863. struct bfad_itnim_s *itnim_drv);
  864. void bfa_fcb_itnim_online(struct bfad_itnim_s *itnim_drv);
  865. void bfa_fcb_itnim_offline(struct bfad_itnim_s *itnim_drv);
  866. #endif /* __BFA_FCS_H__ */