1 /*
2  * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
3  * All rights reserved
4  * www.brocade.com
5  *
6  * Linux driver for Brocade Fibre Channel Host Bus Adapter.
7  *
8  * This program is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License (GPL) Version 2 as
10  * published by the Free Software Foundation
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License for more details.
16  */
17 
18 #ifndef __BFA_DEFS_SVC_H__
19 #define __BFA_DEFS_SVC_H__
20 
21 #include "bfa_defs.h"
22 #include "bfa_fc.h"
23 #include "bfi.h"
24 
25 #define BFA_IOCFC_INTR_DELAY	1125
26 #define BFA_IOCFC_INTR_LATENCY	225
27 #define BFA_IOCFCOE_INTR_DELAY	25
28 #define BFA_IOCFCOE_INTR_LATENCY 5
29 
30 /*
31  * Interrupt coalescing configuration.
32  */
33 #pragma pack(1)
34 struct bfa_iocfc_intr_attr_s {
35 	u8		coalesce;	/*  enable/disable coalescing */
36 	u8		rsvd[3];
37 	__be16		latency;	/*  latency in microseconds   */
38 	__be16		delay;		/*  delay in microseconds     */
39 };
40 
41 /*
42  * IOC firmware configuraton
43  */
44 struct bfa_iocfc_fwcfg_s {
45 	u16		num_fabrics;	/*  number of fabrics		*/
46 	u16		num_lports;	/*  number of local lports	*/
47 	u16		num_rports;	/*  number of remote ports	*/
48 	u16		num_ioim_reqs;	/*  number of IO reqs		*/
49 	u16		num_tskim_reqs;	/*  task management requests	*/
50 	u16		num_fwtio_reqs;	/* number of TM IO reqs in FW   */
51 	u16		num_fcxp_reqs;	/*  unassisted FC exchanges	*/
52 	u16		num_uf_bufs;	/*  unsolicited recv buffers	*/
53 	u8		num_cqs;
54 	u8		fw_tick_res;	/*  FW clock resolution in ms */
55 	u8		rsvd[6];
56 };
57 #pragma pack()
58 
59 struct bfa_iocfc_drvcfg_s {
60 	u16		num_reqq_elems;	/*  number of req queue elements */
61 	u16		num_rspq_elems;	/*  number of rsp queue elements */
62 	u16		num_sgpgs;	/*  number of total SG pages	 */
63 	u16		num_sboot_tgts;	/*  number of SAN boot targets	 */
64 	u16		num_sboot_luns;	/*  number of SAN boot luns	 */
65 	u16		ioc_recover;	/*  IOC recovery mode		 */
66 	u16		min_cfg;	/*  minimum configuration	 */
67 	u16		path_tov;	/*  device path timeout		*/
68 	u16		num_tio_reqs;	/* number of TM IO reqs	*/
69 	u8		port_mode;
70 	u8		rsvd_a;
71 	bfa_boolean_t	delay_comp;	/* delay completion of failed
72 					 * inflight IOs */
73 	u16		num_ttsk_reqs;	 /* TM task management requests */
74 	u32		rsvd;
75 };
76 
77 /*
78  * IOC configuration
79  */
80 struct bfa_iocfc_cfg_s {
81 	struct bfa_iocfc_fwcfg_s	fwcfg;	/*  firmware side config */
82 	struct bfa_iocfc_drvcfg_s	drvcfg;	/*  driver side config	  */
83 };
84 
85 /*
86  * IOC firmware IO stats
87  */
88 struct bfa_fw_ioim_stats_s {
89 	u32	host_abort;		/*  IO aborted by host driver*/
90 	u32	host_cleanup;		/*  IO clean up by host driver */
91 
92 	u32	fw_io_timeout;		/*  IOs timedout */
93 	u32	fw_frm_parse;		/*  frame parsed by f/w */
94 	u32	fw_frm_data;		/*  fcp_data frame parsed by f/w */
95 	u32	fw_frm_rsp;		/*  fcp_rsp frame parsed by f/w */
96 	u32	fw_frm_xfer_rdy;	/*  xfer_rdy frame parsed by f/w */
97 	u32	fw_frm_bls_acc;		/*  BLS ACC  frame parsed by f/w */
98 	u32	fw_frm_tgt_abort;	/*  target ABTS parsed by f/w */
99 	u32	fw_frm_unknown;		/*  unknown parsed by f/w */
100 	u32	fw_data_dma;		/*  f/w DMA'ed the data frame */
101 	u32	fw_frm_drop;		/*  f/w drop the frame */
102 
103 	u32	rec_timeout;		/*  FW rec timed out */
104 	u32	error_rec;		/*  FW sending rec on
105 					 *  an error condition*/
106 	u32	wait_for_si;		/*  FW wait for SI */
107 	u32	rec_rsp_inval;		/*  REC rsp invalid */
108 	u32	seqr_io_abort;		/*  target does not know cmd so abort */
109 	u32	seqr_io_retry;		/*  SEQR failed so retry IO */
110 
111 	u32	itn_cisc_upd_rsp;	/*  ITN cisc updated on fcp_rsp */
112 	u32	itn_cisc_upd_data;	/*  ITN cisc updated on fcp_data */
113 	u32	itn_cisc_upd_xfer_rdy;	/*  ITN cisc updated on fcp_data */
114 
115 	u32	fcp_data_lost;		/*  fcp data lost */
116 
117 	u32	ro_set_in_xfer_rdy;	/*  Target set RO in Xfer_rdy frame */
118 	u32	xfer_rdy_ooo_err;	/*  Out of order Xfer_rdy received */
119 	u32	xfer_rdy_unknown_err;	/*  unknown error in xfer_rdy frame */
120 
121 	u32	io_abort_timeout;	/*  ABTS timedout  */
122 	u32	sler_initiated;		/*  SLER initiated */
123 
124 	u32	unexp_fcp_rsp;		/*  fcp response in wrong state */
125 
126 	u32	fcp_rsp_under_run;	/*  fcp rsp IO underrun */
127 	u32     fcp_rsp_under_run_wr;   /*  fcp rsp IO underrun for write */
128 	u32	fcp_rsp_under_run_err;	/*  fcp rsp IO underrun error */
129 	u32     fcp_rsp_resid_inval;    /*  invalid residue */
130 	u32	fcp_rsp_over_run;	/*  fcp rsp IO overrun */
131 	u32	fcp_rsp_over_run_err;	/*  fcp rsp IO overrun error */
132 	u32	fcp_rsp_proto_err;	/*  protocol error in fcp rsp */
133 	u32	fcp_rsp_sense_err;	/*  error in sense info in fcp rsp */
134 	u32	fcp_conf_req;		/*  FCP conf requested */
135 
136 	u32	tgt_aborted_io;		/*  target initiated abort */
137 
138 	u32	ioh_edtov_timeout_event;/*  IOH edtov timer popped */
139 	u32	ioh_fcp_rsp_excp_event;	/*  IOH FCP_RSP exception */
140 	u32	ioh_fcp_conf_event;	/*  IOH FCP_CONF */
141 	u32	ioh_mult_frm_rsp_event;	/*  IOH multi_frame FCP_RSP */
142 	u32	ioh_hit_class2_event;	/*  IOH hit class2 */
143 	u32	ioh_miss_other_event;	/*  IOH miss other */
144 	u32	ioh_seq_cnt_err_event;	/*  IOH seq cnt error */
145 	u32	ioh_len_err_event;	/*  IOH len error - fcp_dl !=
146 					 *  bytes xfered */
147 	u32	ioh_seq_len_err_event;	/*  IOH seq len error */
148 	u32	ioh_data_oor_event;	/*  Data out of range */
149 	u32	ioh_ro_ooo_event;	/*  Relative offset out of range */
150 	u32	ioh_cpu_owned_event;	/*  IOH hit -iost owned by f/w */
151 	u32	ioh_unexp_frame_event;	/*  unexpected frame received
152 					 *  count */
153 	u32	ioh_err_int;		/*  IOH error int during data-phase
154 					 *  for scsi write */
155 };
156 
157 struct bfa_fw_tio_stats_s {
158 	u32	tio_conf_proc;	    /* TIO CONF processed */
159 	u32	tio_conf_drop;      /* TIO CONF dropped */
160 	u32	tio_cleanup_req;    /* TIO cleanup requested */
161 	u32	tio_cleanup_comp;   /* TIO cleanup completed */
162 	u32	tio_abort_rsp;      /* TIO abort response */
163 	u32	tio_abort_rsp_comp; /* TIO abort rsp completed */
164 	u32	tio_abts_req;       /* TIO ABTS requested */
165 	u32	tio_abts_ack;       /* TIO ABTS ack-ed */
166 	u32	tio_abts_ack_nocomp;/* TIO ABTS ack-ed but not completed */
167 	u32	tio_abts_tmo;       /* TIO ABTS timeout */
168 	u32	tio_snsdata_dma;    /* TIO sense data DMA */
169 	u32	tio_rxwchan_wait;   /* TIO waiting for RX wait channel */
170 	u32	tio_rxwchan_avail;  /* TIO RX wait channel available */
171 	u32	tio_hit_bls;        /* TIO IOH BLS event */
172 	u32	tio_uf_recv;        /* TIO received UF */
173 	u32	tio_rd_invalid_sm;  /* TIO read reqst in wrong state machine */
174 	u32	tio_wr_invalid_sm;  /* TIO write reqst in wrong state machine */
175 
176 	u32	ds_rxwchan_wait;    /* DS waiting for RX wait channel */
177 	u32	ds_rxwchan_avail;   /* DS RX wait channel available */
178 	u32	ds_unaligned_rd;    /* DS unaligned read */
179 	u32	ds_rdcomp_invalid_sm; /* DS read completed in wrong state
180 				       * machine */
181 	u32	ds_wrcomp_invalid_sm; /* DS write completed in wrong state
182 				       * machine */
183 	u32	ds_flush_req;       /* DS flush requested */
184 	u32	ds_flush_comp;      /* DS flush completed */
185 	u32	ds_xfrdy_exp;       /* DS XFER_RDY expired */
186 	u32	ds_seq_cnt_err;     /* DS seq cnt error */
187 	u32	ds_seq_len_err;     /* DS seq len error */
188 	u32	ds_data_oor;        /* DS data out of order */
189 	u32	ds_hit_bls;	    /* DS hit BLS */
190 	u32	ds_edtov_timer_exp; /* DS edtov expired */
191 	u32	ds_cpu_owned;       /* DS cpu owned */
192 	u32	ds_hit_class2;      /* DS hit class2 */
193 	u32	ds_length_err;      /* DS length error */
194 	u32	ds_ro_ooo_err;      /* DS relative offset out-of-order error */
195 	u32	ds_rectov_timer_exp;/* DS rectov expired */
196 	u32	ds_unexp_fr_err;    /* DS unexp frame error */
197 };
198 
199 /*
200  * IOC firmware IO stats
201  */
202 struct bfa_fw_io_stats_s {
203 	struct bfa_fw_ioim_stats_s	ioim_stats;
204 	struct bfa_fw_tio_stats_s	tio_stats;
205 };
206 
207 /*
208  * IOC port firmware stats
209  */
210 
211 struct bfa_fw_port_fpg_stats_s {
212 	u32    intr_evt;
213 	u32    intr;
214 	u32    intr_excess;
215 	u32    intr_cause0;
216 	u32    intr_other;
217 	u32    intr_other_ign;
218 	u32    sig_lost;
219 	u32    sig_regained;
220 	u32    sync_lost;
221 	u32    sync_to;
222 	u32    sync_regained;
223 	u32    div2_overflow;
224 	u32    div2_underflow;
225 	u32    efifo_overflow;
226 	u32    efifo_underflow;
227 	u32    idle_rx;
228 	u32    lrr_rx;
229 	u32    lr_rx;
230 	u32    ols_rx;
231 	u32    nos_rx;
232 	u32    lip_rx;
233 	u32    arbf0_rx;
234 	u32    arb_rx;
235 	u32    mrk_rx;
236 	u32    const_mrk_rx;
237 	u32    prim_unknown;
238 };
239 
240 
241 struct bfa_fw_port_lksm_stats_s {
242 	u32    hwsm_success;       /*  hwsm state machine success          */
243 	u32    hwsm_fails;         /*  hwsm fails                          */
244 	u32    hwsm_wdtov;         /*  hwsm timed out                      */
245 	u32    swsm_success;       /*  swsm success                        */
246 	u32    swsm_fails;         /*  swsm fails                          */
247 	u32    swsm_wdtov;         /*  swsm timed out                      */
248 	u32    busybufs;           /*  link init failed due to busybuf     */
249 	u32    buf_waits;          /*  bufwait state entries               */
250 	u32    link_fails;         /*  link failures                       */
251 	u32    psp_errors;         /*  primitive sequence protocol errors  */
252 	u32    lr_unexp;           /*  No. of times LR rx-ed unexpectedly  */
253 	u32    lrr_unexp;          /*  No. of times LRR rx-ed unexpectedly */
254 	u32    lr_tx;              /*  No. of times LR tx started          */
255 	u32    lrr_tx;             /*  No. of times LRR tx started         */
256 	u32    ols_tx;             /*  No. of times OLS tx started         */
257 	u32    nos_tx;             /*  No. of times NOS tx started         */
258 	u32    hwsm_lrr_rx;        /*  No. of times LRR rx-ed by HWSM      */
259 	u32    hwsm_lr_rx;         /*  No. of times LR rx-ed by HWSM       */
260 	u32    bbsc_lr;		   /* LKSM LR tx for credit recovery       */
261 };
262 
263 struct bfa_fw_port_snsm_stats_s {
264 	u32    hwsm_success;       /*  Successful hwsm terminations        */
265 	u32    hwsm_fails;         /*  hwsm fail count                     */
266 	u32    hwsm_wdtov;         /*  hwsm timed out                      */
267 	u32    swsm_success;       /*  swsm success                        */
268 	u32    swsm_wdtov;         /*  swsm timed out                      */
269 	u32    error_resets;       /*  error resets initiated by upsm      */
270 	u32    sync_lost;          /*  Sync loss count                     */
271 	u32    sig_lost;           /*  Signal loss count                   */
272 	u32    asn8g_attempts;	   /* SNSM HWSM at 8Gbps attempts	   */
273 };
274 
275 struct bfa_fw_port_physm_stats_s {
276 	u32    module_inserts;     /*  Module insert count                 */
277 	u32    module_xtracts;     /*  Module extracts count               */
278 	u32    module_invalids;    /*  Invalid module inserted count       */
279 	u32    module_read_ign;    /*  Module validation status ignored    */
280 	u32    laser_faults;       /*  Laser fault count                   */
281 	u32    rsvd;
282 };
283 
284 struct bfa_fw_fip_stats_s {
285 	u32    vlan_req;           /*  vlan discovery requests             */
286 	u32    vlan_notify;        /*  vlan notifications                  */
287 	u32    vlan_err;           /*  vlan response error                 */
288 	u32    vlan_timeouts;      /*  vlan disvoery timeouts              */
289 	u32    vlan_invalids;      /*  invalid vlan in discovery advert.   */
290 	u32    disc_req;           /*  Discovery solicit requests          */
291 	u32    disc_rsp;           /*  Discovery solicit response          */
292 	u32    disc_err;           /*  Discovery advt. parse errors        */
293 	u32    disc_unsol;         /*  Discovery unsolicited               */
294 	u32    disc_timeouts;      /*  Discovery timeouts                  */
295 	u32    disc_fcf_unavail;   /*  Discovery FCF Not Avail.            */
296 	u32    linksvc_unsupp;     /*  Unsupported link service req        */
297 	u32    linksvc_err;        /*  Parse error in link service req     */
298 	u32    logo_req;           /*  FIP logos received                  */
299 	u32    clrvlink_req;       /*  Clear virtual link req              */
300 	u32    op_unsupp;          /*  Unsupported FIP operation           */
301 	u32    untagged;           /*  Untagged frames (ignored)           */
302 	u32    invalid_version;    /*  Invalid FIP version                 */
303 };
304 
305 struct bfa_fw_lps_stats_s {
306 	u32    mac_invalids;       /*  Invalid mac assigned                */
307 	u32    rsvd;
308 };
309 
310 struct bfa_fw_fcoe_stats_s {
311 	u32    cee_linkups;        /*  CEE link up count                   */
312 	u32    cee_linkdns;        /*  CEE link down count                 */
313 	u32    fip_linkups;        /*  FIP link up count                   */
314 	u32    fip_linkdns;        /*  FIP link up count                   */
315 	u32    fip_fails;          /*  FIP fail count                      */
316 	u32    mac_invalids;       /*  Invalid mac assigned                */
317 };
318 
319 /*
320  * IOC firmware FCoE port stats
321  */
322 struct bfa_fw_fcoe_port_stats_s {
323 	struct bfa_fw_fcoe_stats_s		fcoe_stats;
324 	struct bfa_fw_fip_stats_s		fip_stats;
325 };
326 
327 /*
328  * IOC firmware FC uport stats
329  */
330 struct bfa_fw_fc_uport_stats_s {
331 	struct bfa_fw_port_snsm_stats_s		snsm_stats;
332 	struct bfa_fw_port_lksm_stats_s		lksm_stats;
333 };
334 
335 /*
336  * IOC firmware FC port stats
337  */
338 union bfa_fw_fc_port_stats_s {
339 	struct bfa_fw_fc_uport_stats_s		fc_stats;
340 	struct bfa_fw_fcoe_port_stats_s		fcoe_stats;
341 };
342 
343 /*
344  * IOC firmware port stats
345  */
346 struct bfa_fw_port_stats_s {
347 	struct bfa_fw_port_fpg_stats_s		fpg_stats;
348 	struct bfa_fw_port_physm_stats_s	physm_stats;
349 	union  bfa_fw_fc_port_stats_s		fc_port;
350 };
351 
352 /*
353  * fcxchg module statistics
354  */
355 struct bfa_fw_fcxchg_stats_s {
356 	u32	ua_tag_inv;
357 	u32	ua_state_inv;
358 };
359 
360 struct bfa_fw_lpsm_stats_s {
361 	u32	cls_rx;
362 	u32	cls_tx;
363 };
364 
365 /*
366  *  Trunk statistics
367  */
368 struct bfa_fw_trunk_stats_s {
369 	u32 emt_recvd;		/*  Trunk EMT received		*/
370 	u32 emt_accepted;	/*  Trunk EMT Accepted		*/
371 	u32 emt_rejected;	/*  Trunk EMT rejected		*/
372 	u32 etp_recvd;		/*  Trunk ETP received		*/
373 	u32 etp_accepted;	/*  Trunk ETP Accepted		*/
374 	u32 etp_rejected;	/*  Trunk ETP rejected		*/
375 	u32 lr_recvd;		/*  Trunk LR received		*/
376 	u32 rsvd;		/*  padding for 64 bit alignment */
377 };
378 
379 struct bfa_fw_advsm_stats_s {
380 	u32 flogi_sent;		/*  Flogi sent			*/
381 	u32 flogi_acc_recvd;	/*  Flogi Acc received		*/
382 	u32 flogi_rjt_recvd;	/*  Flogi rejects received	*/
383 	u32 flogi_retries;	/*  Flogi retries		*/
384 
385 	u32 elp_recvd;		/*  ELP received		*/
386 	u32 elp_accepted;	/*  ELP Accepted		*/
387 	u32 elp_rejected;	/*  ELP rejected		*/
388 	u32 elp_dropped;	/*  ELP dropped			*/
389 };
390 
391 /*
392  * IOCFC firmware stats
393  */
394 struct bfa_fw_iocfc_stats_s {
395 	u32	cfg_reqs;	/*  cfg request */
396 	u32	updq_reqs;	/*  update queue request */
397 	u32	ic_reqs;	/*  interrupt coalesce reqs */
398 	u32	unknown_reqs;
399 	u32	set_intr_reqs;	/*  set interrupt reqs */
400 };
401 
402 /*
403  * IOC attributes returned in queries
404  */
405 struct bfa_iocfc_attr_s {
406 	struct bfa_iocfc_cfg_s		config;		/*  IOCFC config   */
407 	struct bfa_iocfc_intr_attr_s	intr_attr;	/*  interrupt attr */
408 };
409 
410 /*
411  * Eth_sndrcv mod stats
412  */
413 struct bfa_fw_eth_sndrcv_stats_s {
414 	u32	crc_err;
415 	u32	rsvd;		/*  64bit align    */
416 };
417 
418 /*
419  * CT MAC mod stats
420  */
421 struct bfa_fw_mac_mod_stats_s {
422 	u32	mac_on;		/*  MAC got turned-on */
423 	u32	link_up;	/*  link-up */
424 	u32	signal_off;	/*  lost signal */
425 	u32	dfe_on;		/*  DFE on */
426 	u32	mac_reset;	/*  # of MAC reset to bring lnk up */
427 	u32	pcs_reset;	/*  # of PCS reset to bring lnk up */
428 	u32	loopback;	/*  MAC got into serdes loopback */
429 	u32	lb_mac_reset;
430 			/*  # of MAC reset to bring link up in loopback */
431 	u32	lb_pcs_reset;
432 			/*  # of PCS reset to bring link up in loopback */
433 	u32	rsvd;		/*  64bit align    */
434 };
435 
436 /*
437  * CT MOD stats
438  */
439 struct bfa_fw_ct_mod_stats_s {
440 	u32	rxa_rds_undrun;	/*  RxA RDS underrun */
441 	u32	rad_bpc_ovfl;	/*  RAD BPC overflow */
442 	u32	rad_rlb_bpc_ovfl; /*  RAD RLB BPC overflow */
443 	u32	bpc_fcs_err;	/*  BPC FCS_ERR */
444 	u32	txa_tso_hdr;	/*  TxA TSO header too long */
445 	u32	rsvd;		/*  64bit align    */
446 };
447 
448 /*
449  * IOC firmware stats
450  */
451 struct bfa_fw_stats_s {
452 	struct bfa_fw_ioc_stats_s	ioc_stats;
453 	struct bfa_fw_iocfc_stats_s	iocfc_stats;
454 	struct bfa_fw_io_stats_s	io_stats;
455 	struct bfa_fw_port_stats_s	port_stats;
456 	struct bfa_fw_fcxchg_stats_s	fcxchg_stats;
457 	struct bfa_fw_lpsm_stats_s	lpsm_stats;
458 	struct bfa_fw_lps_stats_s	lps_stats;
459 	struct bfa_fw_trunk_stats_s	trunk_stats;
460 	struct bfa_fw_advsm_stats_s	advsm_stats;
461 	struct bfa_fw_mac_mod_stats_s	macmod_stats;
462 	struct bfa_fw_ct_mod_stats_s	ctmod_stats;
463 	struct bfa_fw_eth_sndrcv_stats_s	ethsndrcv_stats;
464 };
465 
466 #define BFA_IOCFC_PATHTOV_MAX	60
467 #define BFA_IOCFC_QDEPTH_MAX	2000
468 
469 /*
470  * QoS states
471  */
472 enum bfa_qos_state {
473 	BFA_QOS_DISABLED = 0,		/* QoS is disabled */
474 	BFA_QOS_ONLINE = 1,		/*  QoS is online */
475 	BFA_QOS_OFFLINE = 2,		/*  QoS is offline */
476 };
477 
478 /*
479  * QoS  Priority levels.
480  */
481 enum bfa_qos_priority {
482 	BFA_QOS_UNKNOWN = 0,
483 	BFA_QOS_HIGH  = 1,	/*  QoS Priority Level High */
484 	BFA_QOS_MED  =  2,	/*  QoS Priority Level Medium */
485 	BFA_QOS_LOW  =  3,	/*  QoS Priority Level Low */
486 };
487 
488 /*
489  * QoS  bandwidth allocation for each priority level
490  */
491 enum bfa_qos_bw_alloc {
492 	BFA_QOS_BW_HIGH  = 60,	/*  bandwidth allocation for High */
493 	BFA_QOS_BW_MED  =  30,	/*  bandwidth allocation for Medium */
494 	BFA_QOS_BW_LOW  =  10,	/*  bandwidth allocation for Low */
495 };
496 #pragma pack(1)
497 /*
498  * QoS attribute returned in QoS Query
499  */
500 struct bfa_qos_attr_s {
501 	u8		state;		/*  QoS current state */
502 	u8		rsvd[3];
503 	u32  total_bb_cr;		/*  Total BB Credits */
504 };
505 
506 /*
507  * These fields should be displayed only from the CLI.
508  * There will be a separate BFAL API (get_qos_vc_attr ?)
509  * to retrieve this.
510  *
511  */
512 #define  BFA_QOS_MAX_VC  16
513 
514 struct bfa_qos_vc_info_s {
515 	u8 vc_credit;
516 	u8 borrow_credit;
517 	u8 priority;
518 	u8 resvd;
519 };
520 
521 struct bfa_qos_vc_attr_s {
522 	u16  total_vc_count;                    /*  Total VC Count */
523 	u16  shared_credit;
524 	u32  elp_opmode_flags;
525 	struct bfa_qos_vc_info_s vc_info[BFA_QOS_MAX_VC];  /* as many as
526 							    * total_vc_count */
527 };
528 
529 /*
530  * QoS statistics
531  */
532 struct bfa_qos_stats_s {
533 	u32	flogi_sent;		/*  QoS Flogi sent */
534 	u32	flogi_acc_recvd;	/*  QoS Flogi Acc received */
535 	u32	flogi_rjt_recvd;	/*  QoS Flogi rejects received */
536 	u32	flogi_retries;		/*  QoS Flogi retries */
537 
538 	u32	elp_recvd;		/*  QoS ELP received */
539 	u32	elp_accepted;		/*  QoS ELP Accepted */
540 	u32	elp_rejected;		/*  QoS ELP rejected */
541 	u32	elp_dropped;		/*  QoS ELP dropped  */
542 
543 	u32	qos_rscn_recvd;		/*  QoS RSCN received */
544 	u32	rsvd;			/* padding for 64 bit alignment */
545 };
546 
547 /*
548  * FCoE statistics
549  */
550 struct bfa_fcoe_stats_s {
551 	u64	secs_reset;	/*  Seconds since stats reset	     */
552 	u64	cee_linkups;	/*  CEE link up			     */
553 	u64	cee_linkdns;	/*  CEE link down		     */
554 	u64	fip_linkups;	/*  FIP link up			     */
555 	u64	fip_linkdns;	/*  FIP link down		     */
556 	u64	fip_fails;	/*  FIP failures		     */
557 	u64	mac_invalids;	/*  Invalid mac assignments	     */
558 	u64	vlan_req;	/*  Vlan requests		     */
559 	u64	vlan_notify;	/*  Vlan notifications		     */
560 	u64	vlan_err;	/*  Vlan notification errors	     */
561 	u64	vlan_timeouts;	/*  Vlan request timeouts	     */
562 	u64	vlan_invalids;	/*  Vlan invalids		     */
563 	u64	disc_req;	/*  Discovery requests		     */
564 	u64	disc_rsp;	/*  Discovery responses		     */
565 	u64	disc_err;	/*  Discovery error frames	     */
566 	u64	disc_unsol;	/*  Discovery unsolicited	     */
567 	u64	disc_timeouts;	/*  Discovery timeouts		     */
568 	u64	disc_fcf_unavail; /*  Discovery FCF not avail	     */
569 	u64	linksvc_unsupp;	/*  FIP link service req unsupp	     */
570 	u64	linksvc_err;	/*  FIP link service req errors	     */
571 	u64	logo_req;	/*  FIP logos received		     */
572 	u64	clrvlink_req;	/*  Clear virtual link requests	     */
573 	u64	op_unsupp;	/*  FIP operation unsupp.	     */
574 	u64	untagged;	/*  FIP untagged frames		     */
575 	u64	txf_ucast;	/*  Tx FCoE unicast frames	     */
576 	u64	txf_ucast_vlan;	/*  Tx FCoE unicast vlan frames      */
577 	u64	txf_ucast_octets; /*  Tx FCoE unicast octets	     */
578 	u64	txf_mcast;	/*  Tx FCoE multicast frames	     */
579 	u64	txf_mcast_vlan;	/*  Tx FCoE multicast vlan frames    */
580 	u64	txf_mcast_octets; /*  Tx FCoE multicast octets	     */
581 	u64	txf_bcast;	/*  Tx FCoE broadcast frames	     */
582 	u64	txf_bcast_vlan;	/*  Tx FCoE broadcast vlan frames    */
583 	u64	txf_bcast_octets; /*  Tx FCoE broadcast octets	     */
584 	u64	txf_timeout;	  /*  Tx timeouts		     */
585 	u64	txf_parity_errors; /*  Transmit parity err	     */
586 	u64	txf_fid_parity_errors; /*  Transmit FID parity err   */
587 	u64	rxf_ucast_octets; /*  Rx FCoE unicast octets	     */
588 	u64	rxf_ucast;	/*  Rx FCoE unicast frames	     */
589 	u64	rxf_ucast_vlan;	/*  Rx FCoE unicast vlan frames	     */
590 	u64	rxf_mcast_octets; /*  Rx FCoE multicast octets	     */
591 	u64	rxf_mcast;	/*  Rx FCoE multicast frames	     */
592 	u64	rxf_mcast_vlan;	/*  Rx FCoE multicast vlan frames    */
593 	u64	rxf_bcast_octets; /*  Rx FCoE broadcast octets	     */
594 	u64	rxf_bcast;	/*  Rx FCoE broadcast frames	     */
595 	u64	rxf_bcast_vlan;	/*  Rx FCoE broadcast vlan frames    */
596 };
597 
598 /*
599  * QoS or FCoE stats (fcport stats excluding physical FC port stats)
600  */
601 union bfa_fcport_stats_u {
602 	struct bfa_qos_stats_s	fcqos;
603 	struct bfa_fcoe_stats_s	fcoe;
604 };
605 #pragma pack()
606 
607 struct bfa_fcpim_del_itn_stats_s {
608 	u32	del_itn_iocomp_aborted;	   /* Aborted IO requests	      */
609 	u32	del_itn_iocomp_timedout;   /* IO timeouts		      */
610 	u32	del_itn_iocom_sqer_needed; /* IO retry for SQ error recovery  */
611 	u32	del_itn_iocom_res_free;    /* Delayed freeing of IO resources */
612 	u32	del_itn_iocom_hostabrts;   /* Host IO abort requests	      */
613 	u32	del_itn_total_ios;	   /* Total IO count		      */
614 	u32	del_io_iocdowns;	   /* IO cleaned-up due to IOC down   */
615 	u32	del_tm_iocdowns;	   /* TM cleaned-up due to IOC down   */
616 };
617 
618 struct bfa_itnim_iostats_s {
619 
620 	u32	total_ios;		/*  Total IO Requests		*/
621 	u32	input_reqs;		/*  Data in-bound requests	*/
622 	u32	output_reqs;		/*  Data out-bound requests	*/
623 	u32	io_comps;		/*  Total IO Completions	*/
624 	u32	wr_throughput;		/*  Write data transferred in bytes */
625 	u32	rd_throughput;		/*  Read data transferred in bytes  */
626 
627 	u32	iocomp_ok;		/*  Slowpath IO completions	*/
628 	u32	iocomp_underrun;	/*  IO underrun		*/
629 	u32	iocomp_overrun;		/*  IO overrun			*/
630 	u32	qwait;			/*  IO Request-Q wait		*/
631 	u32	qresumes;		/*  IO Request-Q wait done	*/
632 	u32	no_iotags;		/*  No free IO tag		*/
633 	u32	iocomp_timedout;	/*  IO timeouts		*/
634 	u32	iocom_nexus_abort;	/*  IO failure due to target offline */
635 	u32	iocom_proto_err;	/*  IO protocol errors		*/
636 	u32	iocom_dif_err;		/*  IO SBC-3 protection errors	*/
637 
638 	u32	iocom_sqer_needed;	/*  fcp-2 error recovery failed	*/
639 	u32	iocom_res_free;		/*  Delayed freeing of IO tag	*/
640 
641 
642 	u32	io_aborts;		/*  Host IO abort requests	*/
643 	u32	iocom_hostabrts;	/*  Host IO abort completions	*/
644 	u32	io_cleanups;		/*  IO clean-up requests	*/
645 	u32	path_tov_expired;	/*  IO path tov expired	*/
646 	u32	iocomp_aborted;		/*  IO abort completions	*/
647 	u32	io_iocdowns;		/*  IO cleaned-up due to IOC down */
648 	u32	iocom_utags;		/*  IO comp with unknown tags	*/
649 
650 	u32	io_tmaborts;		/*  Abort request due to TM command */
651 	u32	tm_io_comps;		/* Abort completion due to TM command */
652 
653 	u32	creates;		/*  IT Nexus create requests	*/
654 	u32	fw_create;		/*  IT Nexus FW create requests	*/
655 	u32	create_comps;		/*  IT Nexus FW create completions */
656 	u32	onlines;		/*  IT Nexus onlines		*/
657 	u32	offlines;		/*  IT Nexus offlines		*/
658 	u32	fw_delete;		/*  IT Nexus FW delete requests	*/
659 	u32	delete_comps;		/*  IT Nexus FW delete completions */
660 	u32	deletes;		/*  IT Nexus delete requests	   */
661 	u32	sler_events;		/*  SLER events		*/
662 	u32	ioc_disabled;		/*  Num IOC disables		*/
663 	u32	cleanup_comps;		/*  IT Nexus cleanup completions    */
664 
665 	u32	tm_cmnds;		/*  TM Requests		*/
666 	u32	tm_fw_rsps;		/*  TM Completions		*/
667 	u32	tm_success;		/*  TM initiated IO cleanup success */
668 	u32	tm_failures;		/*  TM initiated IO cleanup failure */
669 	u32	no_tskims;		/*  No free TM tag		*/
670 	u32	tm_qwait;		/*  TM Request-Q wait		*/
671 	u32	tm_qresumes;		/*  TM Request-Q wait done	*/
672 
673 	u32	tm_iocdowns;		/*  TM cleaned-up due to IOC down   */
674 	u32	tm_cleanups;		/*  TM cleanup requests	*/
675 	u32	tm_cleanup_comps;	/*  TM cleanup completions	*/
676 	u32	rsvd[6];
677 };
678 
679 /* Modify char* port_stt[] in bfal_port.c if a new state was added */
680 enum bfa_port_states {
681 	BFA_PORT_ST_UNINIT		= 1,
682 	BFA_PORT_ST_ENABLING_QWAIT	= 2,
683 	BFA_PORT_ST_ENABLING		= 3,
684 	BFA_PORT_ST_LINKDOWN		= 4,
685 	BFA_PORT_ST_LINKUP		= 5,
686 	BFA_PORT_ST_DISABLING_QWAIT	= 6,
687 	BFA_PORT_ST_DISABLING		= 7,
688 	BFA_PORT_ST_DISABLED		= 8,
689 	BFA_PORT_ST_STOPPED		= 9,
690 	BFA_PORT_ST_IOCDOWN		= 10,
691 	BFA_PORT_ST_IOCDIS		= 11,
692 	BFA_PORT_ST_FWMISMATCH		= 12,
693 	BFA_PORT_ST_PREBOOT_DISABLED	= 13,
694 	BFA_PORT_ST_TOGGLING_QWAIT	= 14,
695 	BFA_PORT_ST_ACQ_ADDR		= 15,
696 	BFA_PORT_ST_MAX_STATE,
697 };
698 
699 /*
700  *	Port operational type (in sync with SNIA port type).
701  */
702 enum bfa_port_type {
703 	BFA_PORT_TYPE_UNKNOWN	= 1,	/*  port type is unknown */
704 	BFA_PORT_TYPE_NPORT	= 5,	/*  P2P with switched fabric */
705 	BFA_PORT_TYPE_NLPORT	= 6,	/*  public loop */
706 	BFA_PORT_TYPE_LPORT	= 20,	/*  private loop */
707 	BFA_PORT_TYPE_P2P	= 21,	/*  P2P with no switched fabric */
708 	BFA_PORT_TYPE_VPORT	= 22,	/*  NPIV - virtual port */
709 };
710 
711 /*
712  *	Port topology setting. A port's topology and fabric login status
713  *	determine its operational type.
714  */
715 enum bfa_port_topology {
716 	BFA_PORT_TOPOLOGY_NONE = 0,	/*  No valid topology */
717 	BFA_PORT_TOPOLOGY_P2P  = 1,	/*  P2P only */
718 	BFA_PORT_TOPOLOGY_LOOP = 2,	/*  LOOP topology */
719 	BFA_PORT_TOPOLOGY_AUTO = 3,	/*  auto topology selection */
720 };
721 
722 /*
723  *	Physical port loopback types.
724  */
725 enum bfa_port_opmode {
726 	BFA_PORT_OPMODE_NORMAL   = 0x00, /*  normal non-loopback mode */
727 	BFA_PORT_OPMODE_LB_INT   = 0x01, /*  internal loop back */
728 	BFA_PORT_OPMODE_LB_SLW   = 0x02, /*  serial link wrapback (serdes) */
729 	BFA_PORT_OPMODE_LB_EXT   = 0x04, /*  external loop back (serdes) */
730 	BFA_PORT_OPMODE_LB_CBL   = 0x08, /*  cabled loop back */
731 	BFA_PORT_OPMODE_LB_NLINT = 0x20, /*  NL_Port internal loopback */
732 };
733 
734 #define BFA_PORT_OPMODE_LB_HARD(_mode)			\
735 	((_mode == BFA_PORT_OPMODE_LB_INT) ||		\
736 	(_mode == BFA_PORT_OPMODE_LB_SLW) ||		\
737 	(_mode == BFA_PORT_OPMODE_LB_EXT))
738 
739 /*
740  *	Port link state
741  */
742 enum bfa_port_linkstate {
743 	BFA_PORT_LINKUP		= 1,	/*  Physical port/Trunk link up */
744 	BFA_PORT_LINKDOWN	= 2,	/*  Physical port/Trunk link down */
745 };
746 
747 /*
748  *	Port link state reason code
749  */
750 enum bfa_port_linkstate_rsn {
751 	BFA_PORT_LINKSTATE_RSN_NONE		= 0,
752 	BFA_PORT_LINKSTATE_RSN_DISABLED		= 1,
753 	BFA_PORT_LINKSTATE_RSN_RX_NOS		= 2,
754 	BFA_PORT_LINKSTATE_RSN_RX_OLS		= 3,
755 	BFA_PORT_LINKSTATE_RSN_RX_LIP		= 4,
756 	BFA_PORT_LINKSTATE_RSN_RX_LIPF7		= 5,
757 	BFA_PORT_LINKSTATE_RSN_SFP_REMOVED	= 6,
758 	BFA_PORT_LINKSTATE_RSN_PORT_FAULT	= 7,
759 	BFA_PORT_LINKSTATE_RSN_RX_LOS		= 8,
760 	BFA_PORT_LINKSTATE_RSN_LOCAL_FAULT	= 9,
761 	BFA_PORT_LINKSTATE_RSN_REMOTE_FAULT	= 10,
762 	BFA_PORT_LINKSTATE_RSN_TIMEOUT		= 11,
763 
764 
765 
766 	/* CEE related reason codes/errors */
767 	CEE_LLDP_INFO_AGED_OUT			= 20,
768 	CEE_LLDP_SHUTDOWN_TLV_RCVD		= 21,
769 	CEE_PEER_NOT_ADVERTISE_DCBX		= 22,
770 	CEE_PEER_NOT_ADVERTISE_PG		= 23,
771 	CEE_PEER_NOT_ADVERTISE_PFC		= 24,
772 	CEE_PEER_NOT_ADVERTISE_FCOE		= 25,
773 	CEE_PG_NOT_COMPATIBLE			= 26,
774 	CEE_PFC_NOT_COMPATIBLE			= 27,
775 	CEE_FCOE_NOT_COMPATIBLE			= 28,
776 	CEE_BAD_PG_RCVD				= 29,
777 	CEE_BAD_BW_RCVD				= 30,
778 	CEE_BAD_PFC_RCVD			= 31,
779 	CEE_BAD_APP_PRI_RCVD			= 32,
780 	CEE_FCOE_PRI_PFC_OFF			= 33,
781 	CEE_DUP_CONTROL_TLV_RCVD		= 34,
782 	CEE_DUP_FEAT_TLV_RCVD			= 35,
783 	CEE_APPLY_NEW_CFG			= 36, /* reason, not error */
784 	CEE_PROTOCOL_INIT			= 37, /* reason, not error */
785 	CEE_PHY_LINK_DOWN			= 38,
786 	CEE_LLS_FCOE_ABSENT			= 39,
787 	CEE_LLS_FCOE_DOWN			= 40,
788 	CEE_ISCSI_NOT_COMPATIBLE		= 41,
789 	CEE_ISCSI_PRI_PFC_OFF			= 42,
790 	CEE_ISCSI_PRI_OVERLAP_FCOE_PRI		= 43
791 };
792 
793 #define MAX_LUN_MASK_CFG 16
794 
795 /*
796  * Initially flash content may be fff. On making LUN mask enable and disable
797  * state chnage.  when report lun command is being processed it goes from
798  * BFA_LUN_MASK_ACTIVE to BFA_LUN_MASK_FETCH and comes back to
799  * BFA_LUN_MASK_ACTIVE.
800  */
801 enum bfa_ioim_lun_mask_state_s {
802 	BFA_IOIM_LUN_MASK_INACTIVE = 0,
803 	BFA_IOIM_LUN_MASK_ACTIVE = 1,
804 	BFA_IOIM_LUN_MASK_FETCHED = 2,
805 };
806 
807 enum bfa_lunmask_state_s {
808 	BFA_LUNMASK_DISABLED = 0x00,
809 	BFA_LUNMASK_ENABLED = 0x01,
810 	BFA_LUNMASK_MINCFG = 0x02,
811 	BFA_LUNMASK_UNINITIALIZED = 0xff,
812 };
813 
814 #pragma pack(1)
815 /*
816  * LUN mask configuration
817  */
818 struct bfa_lun_mask_s {
819 	wwn_t		lp_wwn;
820 	wwn_t		rp_wwn;
821 	struct scsi_lun	lun;
822 	u8		ua;
823 	u8		rsvd[3];
824 	u16		rp_tag;
825 	u8		lp_tag;
826 	u8		state;
827 };
828 
829 #define MAX_LUN_MASK_CFG 16
830 struct bfa_lunmask_cfg_s {
831 	u32	status;
832 	u32	rsvd;
833 	struct bfa_lun_mask_s	lun_list[MAX_LUN_MASK_CFG];
834 };
835 
836 /*
837  *      Physical port configuration
838  */
839 struct bfa_port_cfg_s {
840 	u8	 topology;	/*  bfa_port_topology		*/
841 	u8	 speed;		/*  enum bfa_port_speed	*/
842 	u8	 trunked;	/*  trunked or not		*/
843 	u8	 qos_enabled;	/*  qos enabled or not		*/
844 	u8	 cfg_hardalpa;	/*  is hard alpa configured	*/
845 	u8	 hardalpa;	/*  configured hard alpa	*/
846 	__be16	 maxfrsize;	/*  maximum frame size		*/
847 	u8	 rx_bbcredit;	/*  receive buffer credits	*/
848 	u8	 tx_bbcredit;	/*  transmit buffer credits	*/
849 	u8	 ratelimit;	/*  ratelimit enabled or not	*/
850 	u8	 trl_def_speed;	/*  ratelimit default speed	*/
851 	u8	 bb_scn;	/*  BB_SCN value from FLOGI Exchg */
852 	u8	 bb_scn_state;	/*  Config state of BB_SCN */
853 	u8	 faa_state;	/*  FAA enabled/disabled        */
854 	u8	 rsvd[1];
855 	u16	 path_tov;	/*  device path timeout	*/
856 	u16	 q_depth;	/*  SCSI Queue depth		*/
857 };
858 #pragma pack()
859 
860 /*
861  *	Port attribute values.
862  */
863 struct bfa_port_attr_s {
864 	/*
865 	 * Static fields
866 	 */
867 	wwn_t			nwwn;		/*  node wwn */
868 	wwn_t			pwwn;		/*  port wwn */
869 	wwn_t			factorynwwn;	/*  factory node wwn */
870 	wwn_t			factorypwwn;	/*  factory port wwn */
871 	enum fc_cos		cos_supported;	/*  supported class of
872 						 *  services */
873 	u32			rsvd;
874 	struct fc_symname_s	port_symname;	/*  port symbolic name */
875 	enum bfa_port_speed	speed_supported; /* supported speeds */
876 	bfa_boolean_t		pbind_enabled;
877 
878 	/*
879 	 * Configured values
880 	 */
881 	struct bfa_port_cfg_s	pport_cfg;	/*  pport cfg */
882 
883 	/*
884 	 * Dynamic field - info from BFA
885 	 */
886 	enum bfa_port_states	port_state;	/*  current port state */
887 	enum bfa_port_speed	speed;		/*  current speed */
888 	enum bfa_port_topology	topology;	/*  current topology */
889 	bfa_boolean_t		beacon;		/*  current beacon status */
890 	bfa_boolean_t		link_e2e_beacon; /* link beacon is on */
891 	bfa_boolean_t		bbsc_op_status;	/* fc credit recovery oper
892 						 * state */
893 
894 	/*
895 	 * Dynamic field - info from FCS
896 	 */
897 	u32			pid;		/*  port ID */
898 	enum bfa_port_type	port_type;	/*  current topology */
899 	u32			loopback;	/*  external loopback */
900 	u32			authfail;	/*  auth fail state */
901 
902 	/* FCoE specific  */
903 	u16			fcoe_vlan;
904 	u8			rsvd1[2];
905 };
906 
907 /*
908  *	      Port FCP mappings.
909  */
910 struct bfa_port_fcpmap_s {
911 	char	osdevname[256];
912 	u32	bus;
913 	u32	target;
914 	u32	oslun;
915 	u32	fcid;
916 	wwn_t	nwwn;
917 	wwn_t	pwwn;
918 	u64	fcplun;
919 	char	luid[256];
920 };
921 
922 /*
923  *	      Port RNID info.
924  */
925 struct bfa_port_rnid_s {
926 	wwn_t	  wwn;
927 	u32	  unittype;
928 	u32	  portid;
929 	u32	  attached_nodes_num;
930 	u16	  ip_version;
931 	u16	  udp_port;
932 	u8	  ipaddr[16];
933 	u16	  rsvd;
934 	u16	  topologydiscoveryflags;
935 };
936 
937 #pragma pack(1)
938 struct bfa_fcport_fcf_s {
939 	wwn_t	name;		/*  FCF name		   */
940 	wwn_t	fabric_name;    /*  Fabric Name		   */
941 	u8	fipenabled;	/*  FIP enabled or not	   */
942 	u8	fipfailed;	/*  FIP failed or not	   */
943 	u8	resv[2];
944 	u8	pri;		/*  FCF priority	   */
945 	u8	version;	/*  FIP version used	   */
946 	u8	available;      /*  Available for login    */
947 	u8	fka_disabled;   /*  FKA is disabled	   */
948 	u8	maxsz_verified; /*  FCoE max size verified */
949 	u8	fc_map[3];      /*  FC map		   */
950 	__be16	vlan;		/*  FCoE vlan tag/priority */
951 	u32	fka_adv_per;    /*  FIP  ka advert. period */
952 	mac_t	mac;		/*  FCF mac		   */
953 };
954 
955 /*
956  *	Trunk states for BCU/BFAL
957  */
958 enum bfa_trunk_state {
959 	BFA_TRUNK_DISABLED	= 0,	/*  Trunk is not configured	*/
960 	BFA_TRUNK_ONLINE	= 1,	/*  Trunk is online		*/
961 	BFA_TRUNK_OFFLINE	= 2,	/*  Trunk is offline		*/
962 };
963 
964 /*
965  *	VC attributes for trunked link
966  */
967 struct bfa_trunk_vc_attr_s {
968 	u32 bb_credit;
969 	u32 elp_opmode_flags;
970 	u32 req_credit;
971 	u16 vc_credits[8];
972 };
973 
974 /*
975  *	Link state information
976  */
977 struct bfa_port_link_s {
978 	u8	 linkstate;	/*  Link state bfa_port_linkstate */
979 	u8	 linkstate_rsn;	/*  bfa_port_linkstate_rsn_t */
980 	u8	 topology;	/*  P2P/LOOP bfa_port_topology */
981 	u8	 speed;		/*  Link speed (1/2/4/8 G) */
982 	u32	 linkstate_opt; /*  Linkstate optional data (debug) */
983 	u8	 trunked;	/*  Trunked or not (1 or 0) */
984 	u8	 resvd[3];
985 	struct bfa_qos_attr_s  qos_attr;   /* QoS Attributes */
986 	union {
987 		struct bfa_qos_vc_attr_s qos_vc_attr;  /*  VC info from ELP */
988 		struct bfa_trunk_vc_attr_s trunk_vc_attr;
989 		struct bfa_fcport_fcf_s fcf; /*  FCF information (for FCoE) */
990 	} vc_fcf;
991 };
992 #pragma pack()
993 
994 enum bfa_trunk_link_fctl {
995 	BFA_TRUNK_LINK_FCTL_NORMAL,
996 	BFA_TRUNK_LINK_FCTL_VC,
997 	BFA_TRUNK_LINK_FCTL_VC_QOS,
998 };
999 
1000 enum bfa_trunk_link_state {
1001 	BFA_TRUNK_LINK_STATE_UP = 1,		/* link part of trunk */
1002 	BFA_TRUNK_LINK_STATE_DN_LINKDN = 2,	/* physical link down */
1003 	BFA_TRUNK_LINK_STATE_DN_GRP_MIS = 3,	/* trunk group different */
1004 	BFA_TRUNK_LINK_STATE_DN_SPD_MIS = 4,	/* speed mismatch */
1005 	BFA_TRUNK_LINK_STATE_DN_MODE_MIS = 5,	/* remote port not trunked */
1006 };
1007 
1008 #define BFA_TRUNK_MAX_PORTS	2
1009 struct bfa_trunk_link_attr_s {
1010 	wwn_t    trunk_wwn;
1011 	enum bfa_trunk_link_fctl fctl;
1012 	enum bfa_trunk_link_state link_state;
1013 	enum bfa_port_speed	speed;
1014 	u32 deskew;
1015 };
1016 
1017 struct bfa_trunk_attr_s {
1018 	enum bfa_trunk_state	state;
1019 	enum bfa_port_speed	speed;
1020 	u32		port_id;
1021 	u32		rsvd;
1022 	struct bfa_trunk_link_attr_s link_attr[BFA_TRUNK_MAX_PORTS];
1023 };
1024 
1025 struct bfa_rport_hal_stats_s {
1026 	u32        sm_un_cr;	    /*  uninit: create events      */
1027 	u32        sm_un_unexp;	    /*  uninit: exception events   */
1028 	u32        sm_cr_on;	    /*  created: online events     */
1029 	u32        sm_cr_del;	    /*  created: delete events     */
1030 	u32        sm_cr_hwf;	    /*  created: IOC down          */
1031 	u32        sm_cr_unexp;	    /*  created: exception events  */
1032 	u32        sm_fwc_rsp;	    /*  fw create: f/w responses   */
1033 	u32        sm_fwc_del;	    /*  fw create: delete events   */
1034 	u32        sm_fwc_off;	    /*  fw create: offline events  */
1035 	u32        sm_fwc_hwf;	    /*  fw create: IOC down        */
1036 	u32        sm_fwc_unexp;    /*  fw create: exception events*/
1037 	u32        sm_on_off;	    /*  online: offline events     */
1038 	u32        sm_on_del;	    /*  online: delete events      */
1039 	u32        sm_on_hwf;	    /*  online: IOC down events    */
1040 	u32        sm_on_unexp;	    /*  online: exception events   */
1041 	u32        sm_fwd_rsp;	    /*  fw delete: fw responses    */
1042 	u32        sm_fwd_del;	    /*  fw delete: delete events   */
1043 	u32        sm_fwd_hwf;	    /*  fw delete: IOC down events */
1044 	u32        sm_fwd_unexp;    /*  fw delete: exception events*/
1045 	u32        sm_off_del;	    /*  offline: delete events     */
1046 	u32        sm_off_on;	    /*  offline: online events     */
1047 	u32        sm_off_hwf;	    /*  offline: IOC down events   */
1048 	u32        sm_off_unexp;    /*  offline: exception events  */
1049 	u32        sm_del_fwrsp;    /*  delete: fw responses       */
1050 	u32        sm_del_hwf;	    /*  delete: IOC down events    */
1051 	u32        sm_del_unexp;    /*  delete: exception events   */
1052 	u32        sm_delp_fwrsp;   /*  delete pend: fw responses  */
1053 	u32        sm_delp_hwf;	    /*  delete pend: IOC downs     */
1054 	u32        sm_delp_unexp;   /*  delete pend: exceptions    */
1055 	u32        sm_offp_fwrsp;   /*  off-pending: fw responses  */
1056 	u32        sm_offp_del;	    /*  off-pending: deletes       */
1057 	u32        sm_offp_hwf;	    /*  off-pending: IOC downs     */
1058 	u32        sm_offp_unexp;   /*  off-pending: exceptions    */
1059 	u32        sm_iocd_off;	    /*  IOC down: offline events   */
1060 	u32        sm_iocd_del;	    /*  IOC down: delete events    */
1061 	u32        sm_iocd_on;	    /*  IOC down: online events    */
1062 	u32        sm_iocd_unexp;   /*  IOC down: exceptions       */
1063 	u32        rsvd;
1064 };
1065 #pragma pack(1)
1066 /*
1067  *  Rport's QoS attributes
1068  */
1069 struct bfa_rport_qos_attr_s {
1070 	u8		qos_priority;	/*  rport's QoS priority   */
1071 	u8		rsvd[3];
1072 	u32		qos_flow_id;	/*  QoS flow Id	 */
1073 };
1074 #pragma pack()
1075 
1076 #define BFA_IOBUCKET_MAX 14
1077 
1078 struct bfa_itnim_latency_s {
1079 	u32 min[BFA_IOBUCKET_MAX];
1080 	u32 max[BFA_IOBUCKET_MAX];
1081 	u32 count[BFA_IOBUCKET_MAX];
1082 	u32 avg[BFA_IOBUCKET_MAX];
1083 };
1084 
1085 struct bfa_itnim_ioprofile_s {
1086 	u32 clock_res_mul;
1087 	u32 clock_res_div;
1088 	u32 index;
1089 	u32 io_profile_start_time;	/*  IO profile start time	*/
1090 	u32 iocomps[BFA_IOBUCKET_MAX];	/*  IO completed	*/
1091 	struct bfa_itnim_latency_s io_latency;
1092 };
1093 
1094 /*
1095  *	vHBA port attribute values.
1096  */
1097 struct bfa_vhba_attr_s {
1098 	wwn_t	nwwn;       /* node wwn */
1099 	wwn_t	pwwn;       /* port wwn */
1100 	u32	pid;        /* port ID */
1101 	bfa_boolean_t       io_profile; /* get it from fcpim mod */
1102 	bfa_boolean_t       plog_enabled;   /* portlog is enabled */
1103 	u16	path_tov;
1104 	u8	rsvd[2];
1105 };
1106 
1107 /*
1108  * FC physical port statistics.
1109  */
1110 struct bfa_port_fc_stats_s {
1111 	u64     secs_reset;     /*  Seconds since stats is reset */
1112 	u64     tx_frames;      /*  Tx frames                   */
1113 	u64     tx_words;       /*  Tx words                    */
1114 	u64     tx_lip;         /*  Tx LIP                      */
1115 	u64     tx_nos;         /*  Tx NOS                      */
1116 	u64     tx_ols;         /*  Tx OLS                      */
1117 	u64     tx_lr;          /*  Tx LR                       */
1118 	u64     tx_lrr;         /*  Tx LRR                      */
1119 	u64     rx_frames;      /*  Rx frames                   */
1120 	u64     rx_words;       /*  Rx words                    */
1121 	u64     lip_count;      /*  Rx LIP                      */
1122 	u64     nos_count;      /*  Rx NOS                      */
1123 	u64     ols_count;      /*  Rx OLS                      */
1124 	u64     lr_count;       /*  Rx LR                       */
1125 	u64     lrr_count;      /*  Rx LRR                      */
1126 	u64     invalid_crcs;   /*  Rx CRC err frames           */
1127 	u64     invalid_crc_gd_eof; /*  Rx CRC err good EOF frames */
1128 	u64     undersized_frm; /*  Rx undersized frames        */
1129 	u64     oversized_frm;  /*  Rx oversized frames */
1130 	u64     bad_eof_frm;    /*  Rx frames with bad EOF      */
1131 	u64     error_frames;   /*  Errored frames              */
1132 	u64     dropped_frames; /*  Dropped frames              */
1133 	u64     link_failures;  /*  Link Failure (LF) count     */
1134 	u64     loss_of_syncs;  /*  Loss of sync count          */
1135 	u64     loss_of_signals; /*  Loss of signal count       */
1136 	u64     primseq_errs;   /*  Primitive sequence protocol err. */
1137 	u64     bad_os_count;   /*  Invalid ordered sets        */
1138 	u64     err_enc_out;    /*  Encoding err nonframe_8b10b */
1139 	u64     err_enc;        /*  Encoding err frame_8b10b    */
1140 	u64	bbsc_frames_lost; /* Credit Recovery-Frames Lost  */
1141 	u64	bbsc_credits_lost; /* Credit Recovery-Credits Lost */
1142 	u64	bbsc_link_resets; /* Credit Recovery-Link Resets   */
1143 };
1144 
1145 /*
1146  * Eth Physical Port statistics.
1147  */
1148 struct bfa_port_eth_stats_s {
1149 	u64     secs_reset;     /*  Seconds since stats is reset */
1150 	u64     frame_64;       /*  Frames 64 bytes             */
1151 	u64     frame_65_127;   /*  Frames 65-127 bytes */
1152 	u64     frame_128_255;  /*  Frames 128-255 bytes        */
1153 	u64     frame_256_511;  /*  Frames 256-511 bytes        */
1154 	u64     frame_512_1023; /*  Frames 512-1023 bytes       */
1155 	u64     frame_1024_1518; /*  Frames 1024-1518 bytes     */
1156 	u64     frame_1519_1522; /*  Frames 1519-1522 bytes     */
1157 	u64     tx_bytes;       /*  Tx bytes                    */
1158 	u64     tx_packets;      /*  Tx packets         */
1159 	u64     tx_mcast_packets; /*  Tx multicast packets      */
1160 	u64     tx_bcast_packets; /*  Tx broadcast packets      */
1161 	u64     tx_control_frame; /*  Tx control frame          */
1162 	u64     tx_drop;        /*  Tx drops                    */
1163 	u64     tx_jabber;      /*  Tx jabber                   */
1164 	u64     tx_fcs_error;   /*  Tx FCS errors               */
1165 	u64     tx_fragments;   /*  Tx fragments                */
1166 	u64     rx_bytes;       /*  Rx bytes                    */
1167 	u64     rx_packets;     /*  Rx packets                  */
1168 	u64     rx_mcast_packets; /*  Rx multicast packets      */
1169 	u64     rx_bcast_packets; /*  Rx broadcast packets      */
1170 	u64     rx_control_frames; /*  Rx control frames        */
1171 	u64     rx_unknown_opcode; /*  Rx unknown opcode        */
1172 	u64     rx_drop;        /*  Rx drops                    */
1173 	u64     rx_jabber;      /*  Rx jabber                   */
1174 	u64     rx_fcs_error;   /*  Rx FCS errors               */
1175 	u64     rx_alignment_error; /*  Rx alignment errors     */
1176 	u64     rx_frame_length_error; /*  Rx frame len errors  */
1177 	u64     rx_code_error;  /*  Rx code errors              */
1178 	u64     rx_fragments;   /*  Rx fragments                */
1179 	u64     rx_pause;       /*  Rx pause                    */
1180 	u64     rx_zero_pause;  /*  Rx zero pause               */
1181 	u64     tx_pause;       /*  Tx pause                    */
1182 	u64     tx_zero_pause;  /*  Tx zero pause               */
1183 	u64     rx_fcoe_pause;  /*  Rx FCoE pause               */
1184 	u64     rx_fcoe_zero_pause; /*  Rx FCoE zero pause      */
1185 	u64     tx_fcoe_pause;  /*  Tx FCoE pause               */
1186 	u64     tx_fcoe_zero_pause; /*  Tx FCoE zero pause      */
1187 	u64     rx_iscsi_pause; /*  Rx iSCSI pause              */
1188 	u64     rx_iscsi_zero_pause; /*  Rx iSCSI zero pause    */
1189 	u64     tx_iscsi_pause; /*  Tx iSCSI pause              */
1190 	u64     tx_iscsi_zero_pause; /*  Tx iSCSI zero pause    */
1191 };
1192 
1193 /*
1194  *              Port statistics.
1195  */
1196 union bfa_port_stats_u {
1197 	struct bfa_port_fc_stats_s      fc;
1198 	struct bfa_port_eth_stats_s     eth;
1199 };
1200 
1201 struct bfa_port_cfg_mode_s {
1202 	u16		max_pf;
1203 	u16		max_vf;
1204 	enum bfa_mode_s	mode;
1205 };
1206 
1207 #pragma pack(1)
1208 
1209 #define BFA_CEE_LLDP_MAX_STRING_LEN	(128)
1210 #define BFA_CEE_DCBX_MAX_PRIORITY	(8)
1211 #define BFA_CEE_DCBX_MAX_PGID		(8)
1212 
1213 struct bfa_cee_lldp_str_s {
1214 	u8	sub_type;
1215 	u8	len;
1216 	u8	rsvd[2];
1217 	u8	value[BFA_CEE_LLDP_MAX_STRING_LEN];
1218 };
1219 
1220 struct bfa_cee_lldp_cfg_s {
1221 	struct bfa_cee_lldp_str_s chassis_id;
1222 	struct bfa_cee_lldp_str_s port_id;
1223 	struct bfa_cee_lldp_str_s port_desc;
1224 	struct bfa_cee_lldp_str_s sys_name;
1225 	struct bfa_cee_lldp_str_s sys_desc;
1226 	struct bfa_cee_lldp_str_s mgmt_addr;
1227 	u16	time_to_live;
1228 	u16	enabled_system_cap;
1229 };
1230 
1231 /* CEE/DCBX parameters */
1232 struct bfa_cee_dcbx_cfg_s {
1233 	u8	pgid[BFA_CEE_DCBX_MAX_PRIORITY];
1234 	u8	pg_percentage[BFA_CEE_DCBX_MAX_PGID];
1235 	u8	pfc_primap; /* bitmap of priorties with PFC enabled */
1236 	u8	fcoe_primap; /* bitmap of priorities used for FcoE traffic */
1237 	u8	iscsi_primap; /* bitmap of priorities used for iSCSI traffic */
1238 	u8	dcbx_version; /* operating version:CEE or preCEE */
1239 	u8	lls_fcoe; /* FCoE Logical Link Status */
1240 	u8	lls_lan; /* LAN Logical Link Status */
1241 	u8	rsvd[2];
1242 };
1243 
1244 /* CEE Query */
1245 struct bfa_cee_attr_s {
1246 	u8	cee_status;
1247 	u8	error_reason;
1248 	struct bfa_cee_lldp_cfg_s lldp_remote;
1249 	struct bfa_cee_dcbx_cfg_s dcbx_remote;
1250 	mac_t src_mac;
1251 	u8	link_speed;
1252 	u8	nw_priority;
1253 	u8	filler[2];
1254 };
1255 
1256 /* LLDP/DCBX/CEE Statistics */
1257 struct bfa_cee_stats_s {
1258 	u32		lldp_tx_frames;		/* LLDP Tx Frames */
1259 	u32		lldp_rx_frames;		/* LLDP Rx Frames */
1260 	u32		lldp_rx_frames_invalid; /* LLDP Rx Frames invalid */
1261 	u32		lldp_rx_frames_new;     /* LLDP Rx Frames new */
1262 	u32		lldp_tlvs_unrecognized; /* LLDP Rx unrecog. TLVs */
1263 	u32		lldp_rx_shutdown_tlvs;  /* LLDP Rx shutdown TLVs */
1264 	u32		lldp_info_aged_out;     /* LLDP remote info aged */
1265 	u32		dcbx_phylink_ups;       /* DCBX phy link ups */
1266 	u32		dcbx_phylink_downs;     /* DCBX phy link downs */
1267 	u32		dcbx_rx_tlvs;           /* DCBX Rx TLVs */
1268 	u32		dcbx_rx_tlvs_invalid;   /* DCBX Rx TLVs invalid */
1269 	u32		dcbx_control_tlv_error; /* DCBX control TLV errors */
1270 	u32		dcbx_feature_tlv_error; /* DCBX feature TLV errors */
1271 	u32		dcbx_cee_cfg_new;       /* DCBX new CEE cfg rcvd */
1272 	u32		cee_status_down;        /* DCB status down */
1273 	u32		cee_status_up;          /* DCB status up */
1274 	u32		cee_hw_cfg_changed;     /* DCB hw cfg changed */
1275 	u32		cee_rx_invalid_cfg;     /* DCB invalid cfg */
1276 };
1277 
1278 #pragma pack()
1279 
1280 /*
1281  *			AEN related definitions
1282  */
1283 #define BFAD_NL_VENDOR_ID (((u64)0x01 << SCSI_NL_VID_TYPE_SHIFT) \
1284 			   | BFA_PCI_VENDOR_ID_BROCADE)
1285 
1286 /* BFA remote port events */
1287 enum bfa_rport_aen_event {
1288 	BFA_RPORT_AEN_ONLINE     = 1,   /* RPort online event */
1289 	BFA_RPORT_AEN_OFFLINE    = 2,   /* RPort offline event */
1290 	BFA_RPORT_AEN_DISCONNECT = 3,   /* RPort disconnect event */
1291 	BFA_RPORT_AEN_QOS_PRIO   = 4,   /* QOS priority change event */
1292 	BFA_RPORT_AEN_QOS_FLOWID = 5,   /* QOS flow Id change event */
1293 };
1294 
1295 struct bfa_rport_aen_data_s {
1296 	u16             vf_id;  /* vf_id of this logical port */
1297 	u16             rsvd[3];
1298 	wwn_t           ppwwn;  /* WWN of its physical port */
1299 	wwn_t           lpwwn;  /* WWN of this logical port */
1300 	wwn_t           rpwwn;  /* WWN of this remote port */
1301 	union {
1302 		struct bfa_rport_qos_attr_s qos;
1303 	} priv;
1304 };
1305 
1306 union bfa_aen_data_u {
1307 	struct bfa_adapter_aen_data_s	adapter;
1308 	struct bfa_port_aen_data_s	port;
1309 	struct bfa_lport_aen_data_s	lport;
1310 	struct bfa_rport_aen_data_s	rport;
1311 	struct bfa_itnim_aen_data_s	itnim;
1312 	struct bfa_audit_aen_data_s	audit;
1313 	struct bfa_ioc_aen_data_s	ioc;
1314 };
1315 
1316 #define BFA_AEN_MAX_ENTRY	512
1317 
1318 struct bfa_aen_entry_s {
1319 	struct list_head	qe;
1320 	enum bfa_aen_category   aen_category;
1321 	u32                     aen_type;
1322 	union bfa_aen_data_u    aen_data;
1323 	struct timeval          aen_tv;
1324 	u32                     seq_num;
1325 	u32                     bfad_num;
1326 };
1327 
1328 #endif /* __BFA_DEFS_SVC_H__ */
1329