bfa_defs_pport.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. /*
  2. * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
  3. * All rights reserved
  4. * www.brocade.com
  5. *
  6. * Linux driver for Brocade Fibre Channel Host Bus Adapter.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License (GPL) Version 2 as
  10. * published by the Free Software Foundation
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. */
  17. #ifndef __BFA_DEFS_PPORT_H__
  18. #define __BFA_DEFS_PPORT_H__
  19. #include <bfa_os_inc.h>
  20. #include <protocol/fc.h>
  21. #include <defs/bfa_defs_types.h>
  22. #include <defs/bfa_defs_qos.h>
  23. #include <cna/pstats/phyport_defs.h>
  24. /* Modify char* port_stt[] in bfal_port.c if a new state was added */
  25. enum bfa_pport_states {
  26. BFA_PPORT_ST_UNINIT = 1,
  27. BFA_PPORT_ST_ENABLING_QWAIT = 2,
  28. BFA_PPORT_ST_ENABLING = 3,
  29. BFA_PPORT_ST_LINKDOWN = 4,
  30. BFA_PPORT_ST_LINKUP = 5,
  31. BFA_PPORT_ST_DISABLING_QWAIT = 6,
  32. BFA_PPORT_ST_DISABLING = 7,
  33. BFA_PPORT_ST_DISABLED = 8,
  34. BFA_PPORT_ST_STOPPED = 9,
  35. BFA_PPORT_ST_IOCDOWN = 10,
  36. BFA_PPORT_ST_IOCDIS = 11,
  37. BFA_PPORT_ST_FWMISMATCH = 12,
  38. BFA_PPORT_ST_MAX_STATE,
  39. };
  40. /**
  41. * Port speed settings. Each specific speed is a bit field. Use multiple
  42. * bits to specify speeds to be selected for auto-negotiation.
  43. */
  44. enum bfa_pport_speed {
  45. BFA_PPORT_SPEED_UNKNOWN = 0,
  46. BFA_PPORT_SPEED_1GBPS = 1,
  47. BFA_PPORT_SPEED_2GBPS = 2,
  48. BFA_PPORT_SPEED_4GBPS = 4,
  49. BFA_PPORT_SPEED_8GBPS = 8,
  50. BFA_PPORT_SPEED_10GBPS = 10,
  51. BFA_PPORT_SPEED_AUTO =
  52. (BFA_PPORT_SPEED_1GBPS | BFA_PPORT_SPEED_2GBPS |
  53. BFA_PPORT_SPEED_4GBPS | BFA_PPORT_SPEED_8GBPS),
  54. };
  55. /**
  56. * Port operational type (in sync with SNIA port type).
  57. */
  58. enum bfa_pport_type {
  59. BFA_PPORT_TYPE_UNKNOWN = 1, /* port type is unknown */
  60. BFA_PPORT_TYPE_TRUNKED = 2, /* Trunked mode */
  61. BFA_PPORT_TYPE_NPORT = 5, /* P2P with switched fabric */
  62. BFA_PPORT_TYPE_NLPORT = 6, /* public loop */
  63. BFA_PPORT_TYPE_LPORT = 20, /* private loop */
  64. BFA_PPORT_TYPE_P2P = 21, /* P2P with no switched fabric */
  65. BFA_PPORT_TYPE_VPORT = 22, /* NPIV - virtual port */
  66. };
  67. /**
  68. * Port topology setting. A port's topology and fabric login status
  69. * determine its operational type.
  70. */
  71. enum bfa_pport_topology {
  72. BFA_PPORT_TOPOLOGY_NONE = 0, /* No valid topology */
  73. BFA_PPORT_TOPOLOGY_P2P = 1, /* P2P only */
  74. BFA_PPORT_TOPOLOGY_LOOP = 2, /* LOOP topology */
  75. BFA_PPORT_TOPOLOGY_AUTO = 3, /* auto topology selection */
  76. };
  77. /**
  78. * Physical port loopback types.
  79. */
  80. enum bfa_pport_opmode {
  81. BFA_PPORT_OPMODE_NORMAL = 0x00, /* normal non-loopback mode */
  82. BFA_PPORT_OPMODE_LB_INT = 0x01, /* internal loop back */
  83. BFA_PPORT_OPMODE_LB_SLW = 0x02, /* serial link wrapback (serdes) */
  84. BFA_PPORT_OPMODE_LB_EXT = 0x04, /* external loop back (serdes) */
  85. BFA_PPORT_OPMODE_LB_CBL = 0x08, /* cabled loop back */
  86. BFA_PPORT_OPMODE_LB_NLINT = 0x20, /* NL_Port internal loopback */
  87. };
  88. #define BFA_PPORT_OPMODE_LB_HARD(_mode) \
  89. ((_mode == BFA_PPORT_OPMODE_LB_INT) || \
  90. (_mode == BFA_PPORT_OPMODE_LB_SLW) || \
  91. (_mode == BFA_PPORT_OPMODE_LB_EXT))
  92. /**
  93. Port State (in sync with SNIA port state).
  94. */
  95. enum bfa_pport_snia_state {
  96. BFA_PPORT_STATE_UNKNOWN = 1, /* port is not initialized */
  97. BFA_PPORT_STATE_ONLINE = 2, /* port is ONLINE */
  98. BFA_PPORT_STATE_DISABLED = 3, /* port is disabled by user */
  99. BFA_PPORT_STATE_BYPASSED = 4, /* port is bypassed (in LOOP) */
  100. BFA_PPORT_STATE_DIAG = 5, /* port diagnostics is active */
  101. BFA_PPORT_STATE_LINKDOWN = 6, /* link is down */
  102. BFA_PPORT_STATE_LOOPBACK = 8, /* port is looped back */
  103. };
  104. /**
  105. * Port link state
  106. */
  107. enum bfa_pport_linkstate {
  108. BFA_PPORT_LINKUP = 1, /* Physical port/Trunk link up */
  109. BFA_PPORT_LINKDOWN = 2, /* Physical port/Trunk link down */
  110. BFA_PPORT_TRUNK_LINKDOWN = 3, /* Trunk link down (new tmaster) */
  111. };
  112. /**
  113. * Port link state event
  114. */
  115. #define bfa_pport_event_t enum bfa_pport_linkstate
  116. /**
  117. * Port link state reason code
  118. */
  119. enum bfa_pport_linkstate_rsn {
  120. BFA_PPORT_LINKSTATE_RSN_NONE = 0,
  121. BFA_PPORT_LINKSTATE_RSN_DISABLED = 1,
  122. BFA_PPORT_LINKSTATE_RSN_RX_NOS = 2,
  123. BFA_PPORT_LINKSTATE_RSN_RX_OLS = 3,
  124. BFA_PPORT_LINKSTATE_RSN_RX_LIP = 4,
  125. BFA_PPORT_LINKSTATE_RSN_RX_LIPF7 = 5,
  126. BFA_PPORT_LINKSTATE_RSN_SFP_REMOVED = 6,
  127. BFA_PPORT_LINKSTATE_RSN_PORT_FAULT = 7,
  128. BFA_PPORT_LINKSTATE_RSN_RX_LOS = 8,
  129. BFA_PPORT_LINKSTATE_RSN_LOCAL_FAULT = 9,
  130. BFA_PPORT_LINKSTATE_RSN_REMOTE_FAULT = 10,
  131. BFA_PPORT_LINKSTATE_RSN_TIMEOUT = 11,
  132. /* CEE related reason codes/errors */
  133. CEE_LLDP_INFO_AGED_OUT = 20,
  134. CEE_LLDP_SHUTDOWN_TLV_RCVD = 21,
  135. CEE_PEER_NOT_ADVERTISE_DCBX = 22,
  136. CEE_PEER_NOT_ADVERTISE_PG = 23,
  137. CEE_PEER_NOT_ADVERTISE_PFC = 24,
  138. CEE_PEER_NOT_ADVERTISE_FCOE = 25,
  139. CEE_PG_NOT_COMPATIBLE = 26,
  140. CEE_PFC_NOT_COMPATIBLE = 27,
  141. CEE_FCOE_NOT_COMPATIBLE = 28,
  142. CEE_BAD_PG_RCVD = 29,
  143. CEE_BAD_BW_RCVD = 30,
  144. CEE_BAD_PFC_RCVD = 31,
  145. CEE_BAD_FCOE_PRI_RCVD = 32,
  146. CEE_FCOE_PRI_PFC_OFF = 33,
  147. CEE_DUP_CONTROL_TLV_RCVD = 34,
  148. CEE_DUP_FEAT_TLV_RCVD = 35,
  149. CEE_APPLY_NEW_CFG = 36, /* reason, not an error */
  150. CEE_PROTOCOL_INIT = 37, /* reason, not an error */
  151. CEE_PHY_LINK_DOWN = 38,
  152. CEE_LLS_FCOE_ABSENT = 39,
  153. CEE_LLS_FCOE_DOWN = 40
  154. };
  155. /**
  156. * Default Target Rate Limiting Speed.
  157. */
  158. #define BFA_PPORT_DEF_TRL_SPEED BFA_PPORT_SPEED_1GBPS
  159. /**
  160. * Physical port configuration
  161. */
  162. struct bfa_pport_cfg_s {
  163. u8 topology; /* bfa_pport_topology */
  164. u8 speed; /* enum bfa_pport_speed */
  165. u8 trunked; /* trunked or not */
  166. u8 qos_enabled; /* qos enabled or not */
  167. u8 trunk_ports; /* bitmap of trunked ports */
  168. u8 cfg_hardalpa; /* is hard alpa configured */
  169. u16 maxfrsize; /* maximum frame size */
  170. u8 hardalpa; /* configured hard alpa */
  171. u8 rx_bbcredit; /* receive buffer credits */
  172. u8 tx_bbcredit; /* transmit buffer credits */
  173. u8 ratelimit; /* ratelimit enabled or not */
  174. u8 trl_def_speed; /* ratelimit default speed */
  175. u8 rsvd[3];
  176. u16 path_tov; /* device path timeout */
  177. u16 q_depth; /* SCSI Queue depth */
  178. };
  179. /**
  180. * Port attribute values.
  181. */
  182. struct bfa_pport_attr_s {
  183. /*
  184. * Static fields
  185. */
  186. wwn_t nwwn; /* node wwn */
  187. wwn_t pwwn; /* port wwn */
  188. enum fc_cos cos_supported; /* supported class of services */
  189. u32 rsvd;
  190. struct fc_symname_s port_symname; /* port symbolic name */
  191. enum bfa_pport_speed speed_supported; /* supported speeds */
  192. bfa_boolean_t pbind_enabled; /* Will be set if Persistent binding
  193. * enabled. Relevant only in Windows
  194. */
  195. /*
  196. * Configured values
  197. */
  198. struct bfa_pport_cfg_s pport_cfg; /* pport cfg */
  199. /*
  200. * Dynamic field - info from BFA
  201. */
  202. enum bfa_pport_states port_state; /* current port state */
  203. enum bfa_pport_speed speed; /* current speed */
  204. enum bfa_pport_topology topology; /* current topology */
  205. bfa_boolean_t beacon; /* current beacon status */
  206. bfa_boolean_t link_e2e_beacon;/* set if link beacon on */
  207. bfa_boolean_t plog_enabled; /* set if portlog is enabled*/
  208. /*
  209. * Dynamic field - info from FCS
  210. */
  211. u32 pid; /* port ID */
  212. enum bfa_pport_type port_type; /* current topology */
  213. u32 loopback; /* external loopback */
  214. u32 rsvd1;
  215. u32 rsvd2; /* padding for 64 bit */
  216. };
  217. /**
  218. * FC Port statistics.
  219. */
  220. struct bfa_pport_fc_stats_s {
  221. u64 secs_reset; /* seconds since stats is reset */
  222. u64 tx_frames; /* transmitted frames */
  223. u64 tx_words; /* transmitted words */
  224. u64 rx_frames; /* received frames */
  225. u64 rx_words; /* received words */
  226. u64 lip_count; /* LIPs seen */
  227. u64 nos_count; /* NOS count */
  228. u64 error_frames; /* errored frames (sent?) */
  229. u64 dropped_frames; /* dropped frames */
  230. u64 link_failures; /* link failure count */
  231. u64 loss_of_syncs; /* loss of sync count */
  232. u64 loss_of_signals;/* loss of signal count */
  233. u64 primseq_errs; /* primitive sequence protocol */
  234. u64 bad_os_count; /* invalid ordered set */
  235. u64 err_enc_out; /* Encoding error outside frame */
  236. u64 invalid_crcs; /* frames received with invalid CRC*/
  237. u64 undersized_frm; /* undersized frames */
  238. u64 oversized_frm; /* oversized frames */
  239. u64 bad_eof_frm; /* frames with bad EOF */
  240. struct bfa_qos_stats_s qos_stats; /* QoS statistics */
  241. };
  242. /**
  243. * Eth Port statistics.
  244. */
  245. struct bfa_pport_eth_stats_s {
  246. u64 secs_reset; /* seconds since stats is reset */
  247. u64 frame_64; /* both rx and tx counter */
  248. u64 frame_65_127; /* both rx and tx counter */
  249. u64 frame_128_255; /* both rx and tx counter */
  250. u64 frame_256_511; /* both rx and tx counter */
  251. u64 frame_512_1023; /* both rx and tx counter */
  252. u64 frame_1024_1518; /* both rx and tx counter */
  253. u64 frame_1519_1522; /* both rx and tx counter */
  254. u64 tx_bytes;
  255. u64 tx_packets;
  256. u64 tx_mcast_packets;
  257. u64 tx_bcast_packets;
  258. u64 tx_control_frame;
  259. u64 tx_drop;
  260. u64 tx_jabber;
  261. u64 tx_fcs_error;
  262. u64 tx_fragments;
  263. u64 rx_bytes;
  264. u64 rx_packets;
  265. u64 rx_mcast_packets;
  266. u64 rx_bcast_packets;
  267. u64 rx_control_frames;
  268. u64 rx_unknown_opcode;
  269. u64 rx_drop;
  270. u64 rx_jabber;
  271. u64 rx_fcs_error;
  272. u64 rx_alignment_error;
  273. u64 rx_frame_length_error;
  274. u64 rx_code_error;
  275. u64 rx_fragments;
  276. u64 rx_pause; /* BPC */
  277. u64 rx_zero_pause; /* BPC Pause cancellation */
  278. u64 tx_pause; /* BPC */
  279. u64 tx_zero_pause; /* BPC Pause cancellation */
  280. u64 rx_fcoe_pause; /* BPC */
  281. u64 rx_fcoe_zero_pause; /* BPC Pause cancellation */
  282. u64 tx_fcoe_pause; /* BPC */
  283. u64 tx_fcoe_zero_pause; /* BPC Pause cancellation */
  284. };
  285. /**
  286. * Port statistics.
  287. */
  288. union bfa_pport_stats_u {
  289. struct bfa_pport_fc_stats_s fc;
  290. struct bfa_pport_eth_stats_s eth;
  291. };
  292. /**
  293. * Port FCP mappings.
  294. */
  295. struct bfa_pport_fcpmap_s {
  296. char osdevname[256];
  297. u32 bus;
  298. u32 target;
  299. u32 oslun;
  300. u32 fcid;
  301. wwn_t nwwn;
  302. wwn_t pwwn;
  303. u64 fcplun;
  304. char luid[256];
  305. };
  306. /**
  307. * Port RNID info.
  308. */
  309. struct bfa_pport_rnid_s {
  310. wwn_t wwn;
  311. u32 unittype;
  312. u32 portid;
  313. u32 attached_nodes_num;
  314. u16 ip_version;
  315. u16 udp_port;
  316. u8 ipaddr[16];
  317. u16 rsvd;
  318. u16 topologydiscoveryflags;
  319. };
  320. /**
  321. * Link state information
  322. */
  323. struct bfa_pport_link_s {
  324. u8 linkstate; /* Link state bfa_pport_linkstate */
  325. u8 linkstate_rsn; /* bfa_pport_linkstate_rsn_t */
  326. u8 topology; /* P2P/LOOP bfa_pport_topology */
  327. u8 speed; /* Link speed (1/2/4/8 G) */
  328. u32 linkstate_opt; /* Linkstate optional data (debug) */
  329. u8 trunked; /* Trunked or not (1 or 0) */
  330. u8 resvd[3];
  331. struct bfa_qos_attr_s qos_attr; /* QoS Attributes */
  332. struct bfa_qos_vc_attr_s qos_vc_attr; /* VC info from ELP */
  333. union {
  334. struct {
  335. u8 tmaster;/* Trunk Master or
  336. * not (1 or 0) */
  337. u8 tlinks; /* Trunk links bitmap
  338. * (linkup) */
  339. u8 resv1; /* Reserved */
  340. } trunk_info;
  341. struct {
  342. u8 myalpa; /* alpa claimed */
  343. u8 login_req; /* Login required or
  344. * not (1 or 0) */
  345. u8 alpabm_val;/* alpa bitmap valid
  346. * or not (1 or 0) */
  347. struct fc_alpabm_s alpabm; /* alpa bitmap */
  348. } loop_info;
  349. } tl;
  350. };
  351. #endif /* __BFA_DEFS_PPORT_H__ */