bfa_fcs.h 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969
  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. struct bfa_fcs_lport_s *bfa_fcs_lookup_port(struct bfa_fcs_s *fcs,
  329. u16 vf_id, wwn_t lpwwn);
  330. void bfa_fcs_lport_set_symname(struct bfa_fcs_lport_s *port, char *symname);
  331. void bfa_fcs_lport_get_attr(struct bfa_fcs_lport_s *port,
  332. struct bfa_lport_attr_s *port_attr);
  333. void bfa_fcs_lport_get_stats(struct bfa_fcs_lport_s *fcs_port,
  334. struct bfa_lport_stats_s *port_stats);
  335. void bfa_fcs_lport_clear_stats(struct bfa_fcs_lport_s *fcs_port);
  336. enum bfa_port_speed bfa_fcs_lport_get_rport_max_speed(
  337. struct bfa_fcs_lport_s *port);
  338. /* MS FCS routines */
  339. void bfa_fcs_lport_ms_init(struct bfa_fcs_lport_s *port);
  340. void bfa_fcs_lport_ms_offline(struct bfa_fcs_lport_s *port);
  341. void bfa_fcs_lport_ms_online(struct bfa_fcs_lport_s *port);
  342. void bfa_fcs_lport_ms_fabric_rscn(struct bfa_fcs_lport_s *port);
  343. /* FDMI FCS routines */
  344. void bfa_fcs_lport_fdmi_init(struct bfa_fcs_lport_ms_s *ms);
  345. void bfa_fcs_lport_fdmi_offline(struct bfa_fcs_lport_ms_s *ms);
  346. void bfa_fcs_lport_fdmi_online(struct bfa_fcs_lport_ms_s *ms);
  347. void bfa_fcs_lport_uf_recv(struct bfa_fcs_lport_s *lport, struct fchs_s *fchs,
  348. u16 len);
  349. void bfa_fcs_lport_attach(struct bfa_fcs_lport_s *lport, struct bfa_fcs_s *fcs,
  350. u16 vf_id, struct bfa_fcs_vport_s *vport);
  351. void bfa_fcs_lport_init(struct bfa_fcs_lport_s *lport,
  352. struct bfa_lport_cfg_s *port_cfg);
  353. void bfa_fcs_lport_online(struct bfa_fcs_lport_s *port);
  354. void bfa_fcs_lport_offline(struct bfa_fcs_lport_s *port);
  355. void bfa_fcs_lport_delete(struct bfa_fcs_lport_s *port);
  356. void bfa_fcs_lport_stop(struct bfa_fcs_lport_s *port);
  357. struct bfa_fcs_rport_s *bfa_fcs_lport_get_rport_by_pid(
  358. struct bfa_fcs_lport_s *port, u32 pid);
  359. struct bfa_fcs_rport_s *bfa_fcs_lport_get_rport_by_old_pid(
  360. struct bfa_fcs_lport_s *port, u32 pid);
  361. struct bfa_fcs_rport_s *bfa_fcs_lport_get_rport_by_pwwn(
  362. struct bfa_fcs_lport_s *port, wwn_t pwwn);
  363. struct bfa_fcs_rport_s *bfa_fcs_lport_get_rport_by_qualifier(
  364. struct bfa_fcs_lport_s *port, wwn_t pwwn, u32 pid);
  365. void bfa_fcs_lport_add_rport(struct bfa_fcs_lport_s *port,
  366. struct bfa_fcs_rport_s *rport);
  367. void bfa_fcs_lport_del_rport(struct bfa_fcs_lport_s *port,
  368. struct bfa_fcs_rport_s *rport);
  369. void bfa_fcs_lport_ns_init(struct bfa_fcs_lport_s *vport);
  370. void bfa_fcs_lport_ns_offline(struct bfa_fcs_lport_s *vport);
  371. void bfa_fcs_lport_ns_online(struct bfa_fcs_lport_s *vport);
  372. void bfa_fcs_lport_ns_query(struct bfa_fcs_lport_s *port);
  373. void bfa_fcs_lport_ns_util_send_rspn_id(void *cbarg,
  374. struct bfa_fcxp_s *fcxp_alloced);
  375. void bfa_fcs_lport_scn_init(struct bfa_fcs_lport_s *vport);
  376. void bfa_fcs_lport_scn_offline(struct bfa_fcs_lport_s *vport);
  377. void bfa_fcs_lport_fab_scn_online(struct bfa_fcs_lport_s *vport);
  378. void bfa_fcs_lport_scn_process_rscn(struct bfa_fcs_lport_s *port,
  379. struct fchs_s *rx_frame, u32 len);
  380. void bfa_fcs_lport_lip_scn_online(bfa_fcs_lport_t *port);
  381. /*
  382. * VPort State Machine events
  383. */
  384. enum bfa_fcs_vport_event {
  385. BFA_FCS_VPORT_SM_CREATE = 1, /* vport create event */
  386. BFA_FCS_VPORT_SM_DELETE = 2, /* vport delete event */
  387. BFA_FCS_VPORT_SM_START = 3, /* vport start request */
  388. BFA_FCS_VPORT_SM_STOP = 4, /* stop: unsupported */
  389. BFA_FCS_VPORT_SM_ONLINE = 5, /* fabric online */
  390. BFA_FCS_VPORT_SM_OFFLINE = 6, /* fabric offline event */
  391. BFA_FCS_VPORT_SM_FRMSENT = 7, /* fdisc/logo sent events */
  392. BFA_FCS_VPORT_SM_RSP_OK = 8, /* good response */
  393. BFA_FCS_VPORT_SM_RSP_ERROR = 9, /* error/bad response */
  394. BFA_FCS_VPORT_SM_TIMEOUT = 10, /* delay timer event */
  395. BFA_FCS_VPORT_SM_DELCOMP = 11, /* lport delete completion */
  396. BFA_FCS_VPORT_SM_RSP_DUP_WWN = 12, /* Dup wnn error*/
  397. BFA_FCS_VPORT_SM_RSP_FAILED = 13, /* non-retryable failure */
  398. BFA_FCS_VPORT_SM_STOPCOMP = 14, /* vport delete completion */
  399. BFA_FCS_VPORT_SM_FABRIC_MAX = 15, /* max vports on fabric */
  400. };
  401. struct bfa_fcs_vport_s;
  402. typedef void (*bfa_fcs_vport_sm_t)(struct bfa_fcs_vport_s *fsm, enum bfa_fcs_vport_event);
  403. struct bfa_fcs_vport_s {
  404. struct list_head qe; /* queue elem */
  405. bfa_fcs_vport_sm_t sm; /* state machine */
  406. bfa_fcs_lport_t lport; /* logical port */
  407. struct bfa_timer_s timer;
  408. struct bfad_vport_s *vport_drv; /* Driver private */
  409. struct bfa_vport_stats_s vport_stats; /* vport statistics */
  410. struct bfa_lps_s *lps; /* Lport login service*/
  411. int fdisc_retries;
  412. };
  413. #define bfa_fcs_vport_get_port(vport) \
  414. ((struct bfa_fcs_lport_s *)(&vport->port))
  415. /*
  416. * bfa fcs vport public functions
  417. */
  418. bfa_status_t bfa_fcs_vport_create(struct bfa_fcs_vport_s *vport,
  419. struct bfa_fcs_s *fcs, u16 vf_id,
  420. struct bfa_lport_cfg_s *port_cfg,
  421. struct bfad_vport_s *vport_drv);
  422. bfa_status_t bfa_fcs_pbc_vport_create(struct bfa_fcs_vport_s *vport,
  423. struct bfa_fcs_s *fcs, u16 vf_id,
  424. struct bfa_lport_cfg_s *port_cfg,
  425. struct bfad_vport_s *vport_drv);
  426. bfa_status_t bfa_fcs_vport_delete(struct bfa_fcs_vport_s *vport);
  427. bfa_status_t bfa_fcs_vport_start(struct bfa_fcs_vport_s *vport);
  428. bfa_status_t bfa_fcs_vport_stop(struct bfa_fcs_vport_s *vport);
  429. void bfa_fcs_vport_get_attr(struct bfa_fcs_vport_s *vport,
  430. struct bfa_vport_attr_s *vport_attr);
  431. struct bfa_fcs_vport_s *bfa_fcs_vport_lookup(struct bfa_fcs_s *fcs,
  432. u16 vf_id, wwn_t vpwwn);
  433. void bfa_fcs_vport_online(struct bfa_fcs_vport_s *vport);
  434. void bfa_fcs_vport_offline(struct bfa_fcs_vport_s *vport);
  435. void bfa_fcs_vport_delete_comp(struct bfa_fcs_vport_s *vport);
  436. void bfa_fcs_vport_fcs_delete(struct bfa_fcs_vport_s *vport);
  437. void bfa_fcs_vport_fcs_stop(struct bfa_fcs_vport_s *vport);
  438. void bfa_fcs_vport_stop_comp(struct bfa_fcs_vport_s *vport);
  439. #define BFA_FCS_RPORT_DEF_DEL_TIMEOUT 90 /* in secs */
  440. #define BFA_FCS_RPORT_MAX_RETRIES (5)
  441. /*
  442. * forward declarations
  443. */
  444. struct bfad_rport_s;
  445. struct bfa_fcs_itnim_s;
  446. struct bfa_fcs_tin_s;
  447. struct bfa_fcs_iprp_s;
  448. /*
  449. * fcs_rport_ftrs_sm FCS rport state machine events
  450. */
  451. enum rpf_event {
  452. RPFSM_EVENT_RPORT_OFFLINE = 1, /* Rport offline */
  453. RPFSM_EVENT_RPORT_ONLINE = 2, /* Rport online */
  454. RPFSM_EVENT_FCXP_SENT = 3, /* Frame from has been sent */
  455. RPFSM_EVENT_TIMEOUT = 4, /* Rport SM timeout event */
  456. RPFSM_EVENT_RPSC_COMP = 5,
  457. RPFSM_EVENT_RPSC_FAIL = 6,
  458. RPFSM_EVENT_RPSC_ERROR = 7,
  459. };
  460. struct bfa_fcs_rpf_s;
  461. typedef void (*bfa_fcs_rpf_sm_t)(struct bfa_fcs_rpf_s *, enum rpf_event);
  462. /* Rport Features (RPF) */
  463. struct bfa_fcs_rpf_s {
  464. bfa_fcs_rpf_sm_t sm; /* state machine */
  465. struct bfa_fcs_rport_s *rport; /* parent rport */
  466. struct bfa_timer_s timer; /* general purpose timer */
  467. struct bfa_fcxp_s *fcxp; /* FCXP needed for discarding */
  468. struct bfa_fcxp_wqe_s fcxp_wqe; /* fcxp wait queue element */
  469. int rpsc_retries; /* max RPSC retry attempts */
  470. enum bfa_port_speed rpsc_speed;
  471. /* Current Speed from RPSC. O if RPSC fails */
  472. enum bfa_port_speed assigned_speed;
  473. /*
  474. * Speed assigned by the user. will be used if RPSC is
  475. * not supported by the rport.
  476. */
  477. };
  478. /*
  479. * fcs_rport_sm FCS rport state machine events
  480. */
  481. enum rport_event {
  482. RPSM_EVENT_PLOGI_SEND = 1, /* new rport; start with PLOGI */
  483. RPSM_EVENT_PLOGI_RCVD = 2, /* Inbound PLOGI from remote port */
  484. RPSM_EVENT_PLOGI_COMP = 3, /* PLOGI completed to rport */
  485. RPSM_EVENT_LOGO_RCVD = 4, /* LOGO from remote device */
  486. RPSM_EVENT_LOGO_IMP = 5, /* implicit logo for SLER */
  487. RPSM_EVENT_FCXP_SENT = 6, /* Frame from has been sent */
  488. RPSM_EVENT_DELETE = 7, /* RPORT delete request */
  489. RPSM_EVENT_FAB_SCN = 8, /* state change notification */
  490. RPSM_EVENT_ACCEPTED = 9, /* Good response from remote device */
  491. RPSM_EVENT_FAILED = 10, /* Request to rport failed. */
  492. RPSM_EVENT_TIMEOUT = 11, /* Rport SM timeout event */
  493. RPSM_EVENT_HCB_ONLINE = 12, /* BFA rport online callback */
  494. RPSM_EVENT_HCB_OFFLINE = 13, /* BFA rport offline callback */
  495. RPSM_EVENT_FC4_OFFLINE = 14, /* FC-4 offline complete */
  496. RPSM_EVENT_ADDRESS_CHANGE = 15, /* Rport's PID has changed */
  497. RPSM_EVENT_ADDRESS_DISC = 16, /* Need to Discover rport's PID */
  498. RPSM_EVENT_PRLO_RCVD = 17, /* PRLO from remote device */
  499. RPSM_EVENT_PLOGI_RETRY = 18, /* Retry PLOGI continuously */
  500. RPSM_EVENT_SCN_OFFLINE = 19, /* loop scn offline */
  501. RPSM_EVENT_SCN_ONLINE = 20, /* loop scn online */
  502. RPSM_EVENT_FC4_FCS_ONLINE = 21, /* FC-4 FCS online complete */
  503. };
  504. struct bfa_fcs_rport_s;
  505. typedef void (*bfa_fcs_rport_sm_t)(struct bfa_fcs_rport_s *, enum rport_event);
  506. struct bfa_fcs_rport_s {
  507. struct list_head qe; /* used by port/vport */
  508. struct bfa_fcs_lport_s *port; /* parent FCS port */
  509. struct bfa_fcs_s *fcs; /* fcs instance */
  510. struct bfad_rport_s *rp_drv; /* driver peer instance */
  511. u32 pid; /* port ID of rport */
  512. u32 old_pid; /* PID before rport goes offline */
  513. u16 maxfrsize; /* maximum frame size */
  514. __be16 reply_oxid; /* OX_ID of inbound requests */
  515. enum fc_cos fc_cos; /* FC classes of service supp */
  516. bfa_boolean_t cisc; /* CISC capable device */
  517. bfa_boolean_t prlo; /* processing prlo or LOGO */
  518. bfa_boolean_t plogi_pending; /* Rx Plogi Pending */
  519. wwn_t pwwn; /* port wwn of rport */
  520. wwn_t nwwn; /* node wwn of rport */
  521. struct bfa_rport_symname_s psym_name; /* port symbolic name */
  522. bfa_fcs_rport_sm_t sm; /* state machine */
  523. struct bfa_timer_s timer; /* general purpose timer */
  524. struct bfa_fcs_itnim_s *itnim; /* ITN initiator mode role */
  525. struct bfa_fcs_tin_s *tin; /* ITN initiator mode role */
  526. struct bfa_fcs_iprp_s *iprp; /* IP/FC role */
  527. struct bfa_rport_s *bfa_rport; /* BFA Rport */
  528. struct bfa_fcxp_s *fcxp; /* FCXP needed for discarding */
  529. int plogi_retries; /* max plogi retry attempts */
  530. int ns_retries; /* max NS query retry attempts */
  531. struct bfa_fcxp_wqe_s fcxp_wqe; /* fcxp wait queue element */
  532. struct bfa_rport_stats_s stats; /* rport stats */
  533. enum bfa_rport_function scsi_function; /* Initiator/Target */
  534. struct bfa_fcs_rpf_s rpf; /* Rport features module */
  535. bfa_boolean_t scn_online; /* SCN online flag */
  536. };
  537. static inline struct bfa_rport_s *
  538. bfa_fcs_rport_get_halrport(struct bfa_fcs_rport_s *rport)
  539. {
  540. return rport->bfa_rport;
  541. }
  542. /*
  543. * bfa fcs rport API functions
  544. */
  545. void bfa_fcs_rport_get_attr(struct bfa_fcs_rport_s *rport,
  546. struct bfa_rport_attr_s *attr);
  547. struct bfa_fcs_rport_s *bfa_fcs_rport_lookup(struct bfa_fcs_lport_s *port,
  548. wwn_t rpwwn);
  549. void bfa_fcs_rport_set_del_timeout(u8 rport_tmo);
  550. void bfa_fcs_rport_set_max_logins(u32 max_logins);
  551. void bfa_fcs_rport_uf_recv(struct bfa_fcs_rport_s *rport,
  552. struct fchs_s *fchs, u16 len);
  553. void bfa_fcs_rport_scn(struct bfa_fcs_rport_s *rport);
  554. struct bfa_fcs_rport_s *bfa_fcs_rport_create(struct bfa_fcs_lport_s *port,
  555. u32 pid);
  556. void bfa_fcs_rport_plogi_create(struct bfa_fcs_lport_s *port,
  557. struct fchs_s *rx_fchs,
  558. struct fc_logi_s *plogi);
  559. void bfa_fcs_rport_plogi(struct bfa_fcs_rport_s *rport, struct fchs_s *fchs,
  560. struct fc_logi_s *plogi);
  561. void bfa_fcs_rport_prlo(struct bfa_fcs_rport_s *rport, __be16 ox_id);
  562. void bfa_fcs_rport_itntm_ack(struct bfa_fcs_rport_s *rport);
  563. void bfa_fcs_rport_fcptm_offline_done(struct bfa_fcs_rport_s *rport);
  564. int bfa_fcs_rport_get_state(struct bfa_fcs_rport_s *rport);
  565. struct bfa_fcs_rport_s *bfa_fcs_rport_create_by_wwn(
  566. struct bfa_fcs_lport_s *port, wwn_t wwn);
  567. void bfa_fcs_rpf_init(struct bfa_fcs_rport_s *rport);
  568. void bfa_fcs_rpf_rport_online(struct bfa_fcs_rport_s *rport);
  569. void bfa_fcs_rpf_rport_offline(struct bfa_fcs_rport_s *rport);
  570. /*
  571. * fcs_itnim_sm FCS itnim state machine events
  572. */
  573. enum bfa_fcs_itnim_event {
  574. BFA_FCS_ITNIM_SM_FCS_ONLINE = 1, /* rport online event */
  575. BFA_FCS_ITNIM_SM_OFFLINE = 2, /* rport offline */
  576. BFA_FCS_ITNIM_SM_FRMSENT = 3, /* prli frame is sent */
  577. BFA_FCS_ITNIM_SM_RSP_OK = 4, /* good response */
  578. BFA_FCS_ITNIM_SM_RSP_ERROR = 5, /* error response */
  579. BFA_FCS_ITNIM_SM_TIMEOUT = 6, /* delay timeout */
  580. BFA_FCS_ITNIM_SM_HCB_OFFLINE = 7, /* BFA online callback */
  581. BFA_FCS_ITNIM_SM_HCB_ONLINE = 8, /* BFA offline callback */
  582. BFA_FCS_ITNIM_SM_INITIATOR = 9, /* rport is initiator */
  583. BFA_FCS_ITNIM_SM_DELETE = 10, /* delete event from rport */
  584. BFA_FCS_ITNIM_SM_PRLO = 11, /* delete event from rport */
  585. BFA_FCS_ITNIM_SM_RSP_NOT_SUPP = 12, /* cmd not supported rsp */
  586. BFA_FCS_ITNIM_SM_HAL_ONLINE = 13, /* bfa rport online event */
  587. };
  588. struct bfa_fcs_itnim_s;
  589. typedef void (*bfa_fcs_itnim_sm_t)(struct bfa_fcs_itnim_s *, enum bfa_fcs_itnim_event);
  590. /*
  591. * forward declarations
  592. */
  593. struct bfad_itnim_s;
  594. struct bfa_fcs_itnim_s {
  595. bfa_fcs_itnim_sm_t sm; /* state machine */
  596. struct bfa_fcs_rport_s *rport; /* parent remote rport */
  597. struct bfad_itnim_s *itnim_drv; /* driver peer instance */
  598. struct bfa_fcs_s *fcs; /* fcs instance */
  599. struct bfa_timer_s timer; /* timer functions */
  600. struct bfa_itnim_s *bfa_itnim; /* BFA itnim struct */
  601. u32 prli_retries; /* max prli retry attempts */
  602. bfa_boolean_t seq_rec; /* seq recovery support */
  603. bfa_boolean_t rec_support; /* REC supported */
  604. bfa_boolean_t conf_comp; /* FCP_CONF support */
  605. bfa_boolean_t task_retry_id; /* task retry id supp */
  606. struct bfa_fcxp_wqe_s fcxp_wqe; /* wait qelem for fcxp */
  607. struct bfa_fcxp_s *fcxp; /* FCXP in use */
  608. struct bfa_itnim_stats_s stats; /* itn statistics */
  609. };
  610. #define bfa_fcs_fcxp_alloc(__fcs, __req) \
  611. bfa_fcxp_req_rsp_alloc(NULL, (__fcs)->bfa, 0, 0, \
  612. NULL, NULL, NULL, NULL, __req)
  613. #define bfa_fcs_fcxp_alloc_wait(__bfa, __wqe, __alloc_cbfn, \
  614. __alloc_cbarg, __req) \
  615. bfa_fcxp_req_rsp_alloc_wait(__bfa, __wqe, __alloc_cbfn, \
  616. __alloc_cbarg, NULL, 0, 0, NULL, NULL, NULL, NULL, __req)
  617. static inline struct bfad_port_s *
  618. bfa_fcs_itnim_get_drvport(struct bfa_fcs_itnim_s *itnim)
  619. {
  620. return itnim->rport->port->bfad_port;
  621. }
  622. static inline struct bfa_fcs_lport_s *
  623. bfa_fcs_itnim_get_port(struct bfa_fcs_itnim_s *itnim)
  624. {
  625. return itnim->rport->port;
  626. }
  627. static inline wwn_t
  628. bfa_fcs_itnim_get_nwwn(struct bfa_fcs_itnim_s *itnim)
  629. {
  630. return itnim->rport->nwwn;
  631. }
  632. static inline wwn_t
  633. bfa_fcs_itnim_get_pwwn(struct bfa_fcs_itnim_s *itnim)
  634. {
  635. return itnim->rport->pwwn;
  636. }
  637. static inline u32
  638. bfa_fcs_itnim_get_fcid(struct bfa_fcs_itnim_s *itnim)
  639. {
  640. return itnim->rport->pid;
  641. }
  642. static inline u32
  643. bfa_fcs_itnim_get_maxfrsize(struct bfa_fcs_itnim_s *itnim)
  644. {
  645. return itnim->rport->maxfrsize;
  646. }
  647. static inline enum fc_cos
  648. bfa_fcs_itnim_get_cos(struct bfa_fcs_itnim_s *itnim)
  649. {
  650. return itnim->rport->fc_cos;
  651. }
  652. static inline struct bfad_itnim_s *
  653. bfa_fcs_itnim_get_drvitn(struct bfa_fcs_itnim_s *itnim)
  654. {
  655. return itnim->itnim_drv;
  656. }
  657. static inline struct bfa_itnim_s *
  658. bfa_fcs_itnim_get_halitn(struct bfa_fcs_itnim_s *itnim)
  659. {
  660. return itnim->bfa_itnim;
  661. }
  662. /*
  663. * bfa fcs FCP Initiator mode API functions
  664. */
  665. void bfa_fcs_itnim_get_attr(struct bfa_fcs_itnim_s *itnim,
  666. struct bfa_itnim_attr_s *attr);
  667. void bfa_fcs_itnim_get_stats(struct bfa_fcs_itnim_s *itnim,
  668. struct bfa_itnim_stats_s *stats);
  669. struct bfa_fcs_itnim_s *bfa_fcs_itnim_lookup(struct bfa_fcs_lport_s *port,
  670. wwn_t rpwwn);
  671. bfa_status_t bfa_fcs_itnim_attr_get(struct bfa_fcs_lport_s *port, wwn_t rpwwn,
  672. struct bfa_itnim_attr_s *attr);
  673. bfa_status_t bfa_fcs_itnim_stats_get(struct bfa_fcs_lport_s *port, wwn_t rpwwn,
  674. struct bfa_itnim_stats_s *stats);
  675. bfa_status_t bfa_fcs_itnim_stats_clear(struct bfa_fcs_lport_s *port,
  676. wwn_t rpwwn);
  677. struct bfa_fcs_itnim_s *bfa_fcs_itnim_create(struct bfa_fcs_rport_s *rport);
  678. void bfa_fcs_itnim_delete(struct bfa_fcs_itnim_s *itnim);
  679. void bfa_fcs_itnim_rport_offline(struct bfa_fcs_itnim_s *itnim);
  680. void bfa_fcs_itnim_brp_online(struct bfa_fcs_itnim_s *itnim);
  681. bfa_status_t bfa_fcs_itnim_get_online_state(struct bfa_fcs_itnim_s *itnim);
  682. void bfa_fcs_itnim_is_initiator(struct bfa_fcs_itnim_s *itnim);
  683. void bfa_fcs_fcpim_uf_recv(struct bfa_fcs_itnim_s *itnim,
  684. struct fchs_s *fchs, u16 len);
  685. #define BFA_FCS_FDMI_SUPP_SPEEDS_4G (FDMI_TRANS_SPEED_1G | \
  686. FDMI_TRANS_SPEED_2G | \
  687. FDMI_TRANS_SPEED_4G)
  688. #define BFA_FCS_FDMI_SUPP_SPEEDS_8G (FDMI_TRANS_SPEED_1G | \
  689. FDMI_TRANS_SPEED_2G | \
  690. FDMI_TRANS_SPEED_4G | \
  691. FDMI_TRANS_SPEED_8G)
  692. #define BFA_FCS_FDMI_SUPP_SPEEDS_16G (FDMI_TRANS_SPEED_2G | \
  693. FDMI_TRANS_SPEED_4G | \
  694. FDMI_TRANS_SPEED_8G | \
  695. FDMI_TRANS_SPEED_16G)
  696. #define BFA_FCS_FDMI_SUPP_SPEEDS_10G FDMI_TRANS_SPEED_10G
  697. #define BFA_FCS_FDMI_VENDOR_INFO_LEN 8
  698. #define BFA_FCS_FDMI_FC4_TYPE_LEN 32
  699. /*
  700. * HBA Attribute Block : BFA internal representation. Note : Some variable
  701. * sizes have been trimmed to suit BFA For Ex : Model will be "QLogic ". Based
  702. * on this the size has been reduced to 16 bytes from the standard's 64 bytes.
  703. */
  704. struct bfa_fcs_fdmi_hba_attr_s {
  705. wwn_t node_name;
  706. u8 manufacturer[64];
  707. u8 serial_num[64];
  708. u8 model[16];
  709. u8 model_desc[128];
  710. u8 hw_version[8];
  711. u8 driver_version[BFA_VERSION_LEN];
  712. u8 option_rom_ver[BFA_VERSION_LEN];
  713. u8 fw_version[BFA_VERSION_LEN];
  714. u8 os_name[256];
  715. __be32 max_ct_pyld;
  716. struct bfa_lport_symname_s node_sym_name;
  717. u8 vendor_info[BFA_FCS_FDMI_VENDOR_INFO_LEN];
  718. __be32 num_ports;
  719. wwn_t fabric_name;
  720. u8 bios_ver[BFA_VERSION_LEN];
  721. };
  722. /*
  723. * Port Attribute Block
  724. */
  725. struct bfa_fcs_fdmi_port_attr_s {
  726. u8 supp_fc4_types[BFA_FCS_FDMI_FC4_TYPE_LEN];
  727. __be32 supp_speed; /* supported speed */
  728. __be32 curr_speed; /* current Speed */
  729. __be32 max_frm_size; /* max frame size */
  730. u8 os_device_name[256]; /* OS device Name */
  731. u8 host_name[256]; /* host name */
  732. wwn_t port_name;
  733. wwn_t node_name;
  734. struct bfa_lport_symname_s port_sym_name;
  735. __be32 port_type;
  736. enum fc_cos scos;
  737. wwn_t port_fabric_name;
  738. u8 port_act_fc4_type[BFA_FCS_FDMI_FC4_TYPE_LEN];
  739. __be32 port_state;
  740. __be32 num_ports;
  741. };
  742. struct bfa_fcs_stats_s {
  743. struct {
  744. u32 untagged; /* untagged receive frames */
  745. u32 tagged; /* tagged receive frames */
  746. u32 vfid_unknown; /* VF id is unknown */
  747. } uf;
  748. };
  749. struct bfa_fcs_driver_info_s {
  750. u8 version[BFA_VERSION_LEN]; /* Driver Version */
  751. u8 host_machine_name[BFA_FCS_OS_STR_LEN];
  752. u8 host_os_name[BFA_FCS_OS_STR_LEN]; /* OS name and version */
  753. u8 host_os_patch[BFA_FCS_OS_STR_LEN]; /* patch or service pack */
  754. u8 os_device_name[BFA_FCS_OS_STR_LEN]; /* Driver Device Name */
  755. };
  756. struct bfa_fcs_s {
  757. struct bfa_s *bfa; /* corresponding BFA bfa instance */
  758. struct bfad_s *bfad; /* corresponding BDA driver instance */
  759. struct bfa_trc_mod_s *trcmod; /* tracing module */
  760. bfa_boolean_t vf_enabled; /* VF mode is enabled */
  761. bfa_boolean_t fdmi_enabled; /* FDMI is enabled */
  762. bfa_boolean_t min_cfg; /* min cfg enabled/disabled */
  763. u16 port_vfid; /* port default VF ID */
  764. struct bfa_fcs_driver_info_s driver_info;
  765. struct bfa_fcs_fabric_s fabric; /* base fabric state machine */
  766. struct bfa_fcs_stats_s stats; /* FCS statistics */
  767. struct bfa_wc_s wc; /* waiting counter */
  768. int fcs_aen_seq;
  769. u32 num_rport_logins;
  770. };
  771. /*
  772. * fcs_fabric_sm fabric state machine functions
  773. */
  774. /*
  775. * bfa fcs API functions
  776. */
  777. void bfa_fcs_attach(struct bfa_fcs_s *fcs, struct bfa_s *bfa,
  778. struct bfad_s *bfad,
  779. bfa_boolean_t min_cfg);
  780. void bfa_fcs_init(struct bfa_fcs_s *fcs);
  781. void bfa_fcs_pbc_vport_init(struct bfa_fcs_s *fcs);
  782. void bfa_fcs_update_cfg(struct bfa_fcs_s *fcs);
  783. void bfa_fcs_driver_info_init(struct bfa_fcs_s *fcs,
  784. struct bfa_fcs_driver_info_s *driver_info);
  785. void bfa_fcs_exit(struct bfa_fcs_s *fcs);
  786. void bfa_fcs_stop(struct bfa_fcs_s *fcs);
  787. /*
  788. * bfa fcs vf public functions
  789. */
  790. bfa_fcs_vf_t *bfa_fcs_vf_lookup(struct bfa_fcs_s *fcs, u16 vf_id);
  791. void bfa_fcs_vf_get_ports(bfa_fcs_vf_t *vf, wwn_t vpwwn[], int *nports);
  792. /*
  793. * fabric protected interface functions
  794. */
  795. void bfa_fcs_fabric_modinit(struct bfa_fcs_s *fcs);
  796. void bfa_fcs_fabric_link_up(struct bfa_fcs_fabric_s *fabric);
  797. void bfa_fcs_fabric_link_down(struct bfa_fcs_fabric_s *fabric);
  798. void bfa_fcs_fabric_addvport(struct bfa_fcs_fabric_s *fabric,
  799. struct bfa_fcs_vport_s *vport);
  800. void bfa_fcs_fabric_delvport(struct bfa_fcs_fabric_s *fabric,
  801. struct bfa_fcs_vport_s *vport);
  802. struct bfa_fcs_vport_s *bfa_fcs_fabric_vport_lookup(
  803. struct bfa_fcs_fabric_s *fabric, wwn_t pwwn);
  804. void bfa_fcs_fabric_modstart(struct bfa_fcs_s *fcs);
  805. void bfa_fcs_fabric_uf_recv(struct bfa_fcs_fabric_s *fabric,
  806. struct fchs_s *fchs, u16 len);
  807. void bfa_fcs_fabric_psymb_init(struct bfa_fcs_fabric_s *fabric);
  808. void bfa_fcs_fabric_nsymb_init(struct bfa_fcs_fabric_s *fabric);
  809. void bfa_fcs_fabric_set_fabric_name(struct bfa_fcs_fabric_s *fabric,
  810. wwn_t fabric_name);
  811. u16 bfa_fcs_fabric_get_switch_oui(struct bfa_fcs_fabric_s *fabric);
  812. void bfa_fcs_fabric_modstop(struct bfa_fcs_s *fcs);
  813. void bfa_fcs_fabric_sm_online(struct bfa_fcs_fabric_s *fabric,
  814. enum bfa_fcs_fabric_event event);
  815. void bfa_fcs_fabric_sm_loopback(struct bfa_fcs_fabric_s *fabric,
  816. enum bfa_fcs_fabric_event event);
  817. void bfa_fcs_fabric_sm_auth_failed(struct bfa_fcs_fabric_s *fabric,
  818. enum bfa_fcs_fabric_event event);
  819. /*
  820. * BFA FCS callback interfaces
  821. */
  822. /*
  823. * fcb Main fcs callbacks
  824. */
  825. struct bfad_port_s;
  826. struct bfad_vport_s;
  827. /*
  828. * lport callbacks
  829. */
  830. struct bfad_port_s *bfa_fcb_lport_new(struct bfad_s *bfad,
  831. struct bfa_fcs_lport_s *port,
  832. enum bfa_lport_role roles,
  833. struct bfad_vf_s *vf_drv,
  834. struct bfad_vport_s *vp_drv);
  835. /*
  836. * vport callbacks
  837. */
  838. void bfa_fcb_pbc_vport_create(struct bfad_s *bfad, struct bfi_pbc_vport_s);
  839. /*
  840. * rport callbacks
  841. */
  842. bfa_status_t bfa_fcb_rport_alloc(struct bfad_s *bfad,
  843. struct bfa_fcs_rport_s **rport,
  844. struct bfad_rport_s **rport_drv);
  845. /*
  846. * itnim callbacks
  847. */
  848. int bfa_fcb_itnim_alloc(struct bfad_s *bfad, struct bfa_fcs_itnim_s **itnim,
  849. struct bfad_itnim_s **itnim_drv);
  850. void bfa_fcb_itnim_free(struct bfad_s *bfad,
  851. struct bfad_itnim_s *itnim_drv);
  852. void bfa_fcb_itnim_online(struct bfad_itnim_s *itnim_drv);
  853. void bfa_fcb_itnim_offline(struct bfad_itnim_s *itnim_drv);
  854. #endif /* __BFA_FCS_H__ */