/drivers/scsi/bfa/bfa_fcs.h

http://github.com/mirrors/linux · C Header · 872 lines · 647 code · 106 blank · 119 comment · 1 complexity · 796774d32da63a8127fc865a190eefc7 MD5 · raw file

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