1 /*
2  * Linux network driver for Brocade Converged Network Adapter.
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License (GPL) Version 2 as
6  * published by the Free Software Foundation
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * General Public License for more details.
12  */
13 /*
14  * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
15  * All rights reserved
16  * www.brocade.com
17  */
18 
19 #ifndef __BFA_DEFS_CNA_H__
20 #define __BFA_DEFS_CNA_H__
21 
22 #include "bfa_defs.h"
23 
24 /**
25  * @brief
26  * FC physical port statistics.
27  */
28 struct bfa_port_fc_stats {
29 	u64	secs_reset;	/*!< Seconds since stats is reset */
30 	u64	tx_frames;	/*!< Tx frames			*/
31 	u64	tx_words;	/*!< Tx words			*/
32 	u64	tx_lip;		/*!< Tx LIP			*/
33 	u64	tx_nos;		/*!< Tx NOS			*/
34 	u64	tx_ols;		/*!< Tx OLS			*/
35 	u64	tx_lr;		/*!< Tx LR			*/
36 	u64	tx_lrr;		/*!< Tx LRR			*/
37 	u64	rx_frames;	/*!< Rx frames			*/
38 	u64	rx_words;	/*!< Rx words			*/
39 	u64	lip_count;	/*!< Rx LIP			*/
40 	u64	nos_count;	/*!< Rx NOS			*/
41 	u64	ols_count;	/*!< Rx OLS			*/
42 	u64	lr_count;	/*!< Rx LR			*/
43 	u64	lrr_count;	/*!< Rx LRR			*/
44 	u64	invalid_crcs;	/*!< Rx CRC err frames		*/
45 	u64	invalid_crc_gd_eof; /*!< Rx CRC err good EOF frames */
46 	u64	undersized_frm; /*!< Rx undersized frames	*/
47 	u64	oversized_frm;	/*!< Rx oversized frames	*/
48 	u64	bad_eof_frm;	/*!< Rx frames with bad EOF	*/
49 	u64	error_frames;	/*!< Errored frames		*/
50 	u64	dropped_frames;	/*!< Dropped frames		*/
51 	u64	link_failures;	/*!< Link Failure (LF) count	*/
52 	u64	loss_of_syncs;	/*!< Loss of sync count		*/
53 	u64	loss_of_signals; /*!< Loss of signal count	*/
54 	u64	primseq_errs;	/*!< Primitive sequence protocol err. */
55 	u64	bad_os_count;	/*!< Invalid ordered sets	*/
56 	u64	err_enc_out;	/*!< Encoding err nonframe_8b10b */
57 	u64	err_enc;	/*!< Encoding err frame_8b10b	*/
58 };
59 
60 /**
61  * @brief
62  * Eth Physical Port statistics.
63  */
64 struct bfa_port_eth_stats {
65 	u64	secs_reset;	/*!< Seconds since stats is reset */
66 	u64	frame_64;	/*!< Frames 64 bytes		*/
67 	u64	frame_65_127;	/*!< Frames 65-127 bytes	*/
68 	u64	frame_128_255;	/*!< Frames 128-255 bytes	*/
69 	u64	frame_256_511;	/*!< Frames 256-511 bytes	*/
70 	u64	frame_512_1023;	/*!< Frames 512-1023 bytes	*/
71 	u64	frame_1024_1518; /*!< Frames 1024-1518 bytes	*/
72 	u64	frame_1519_1522; /*!< Frames 1519-1522 bytes	*/
73 	u64	tx_bytes;	/*!< Tx bytes			*/
74 	u64	tx_packets;	 /*!< Tx packets		*/
75 	u64	tx_mcast_packets; /*!< Tx multicast packets	*/
76 	u64	tx_bcast_packets; /*!< Tx broadcast packets	*/
77 	u64	tx_control_frame; /*!< Tx control frame		*/
78 	u64	tx_drop;	/*!< Tx drops			*/
79 	u64	tx_jabber;	/*!< Tx jabber			*/
80 	u64	tx_fcs_error;	/*!< Tx FCS errors		*/
81 	u64	tx_fragments;	/*!< Tx fragments		*/
82 	u64	rx_bytes;	/*!< Rx bytes			*/
83 	u64	rx_packets;	/*!< Rx packets			*/
84 	u64	rx_mcast_packets; /*!< Rx multicast packets	*/
85 	u64	rx_bcast_packets; /*!< Rx broadcast packets	*/
86 	u64	rx_control_frames; /*!< Rx control frames	*/
87 	u64	rx_unknown_opcode; /*!< Rx unknown opcode	*/
88 	u64	rx_drop;	/*!< Rx drops			*/
89 	u64	rx_jabber;	/*!< Rx jabber			*/
90 	u64	rx_fcs_error;	/*!< Rx FCS errors		*/
91 	u64	rx_alignment_error; /*!< Rx alignment errors	*/
92 	u64	rx_frame_length_error; /*!< Rx frame len errors	*/
93 	u64	rx_code_error;	/*!< Rx code errors		*/
94 	u64	rx_fragments;	/*!< Rx fragments		*/
95 	u64	rx_pause;	/*!< Rx pause			*/
96 	u64	rx_zero_pause;	/*!< Rx zero pause		*/
97 	u64	tx_pause;	/*!< Tx pause			*/
98 	u64	tx_zero_pause;	/*!< Tx zero pause		*/
99 	u64	rx_fcoe_pause;	/*!< Rx FCoE pause		*/
100 	u64	rx_fcoe_zero_pause; /*!< Rx FCoE zero pause	*/
101 	u64	tx_fcoe_pause;	/*!< Tx FCoE pause		*/
102 	u64	tx_fcoe_zero_pause; /*!< Tx FCoE zero pause	*/
103 };
104 
105 /**
106  * @brief
107  *		Port statistics.
108  */
109 union bfa_port_stats_u {
110 	struct bfa_port_fc_stats fc;
111 	struct bfa_port_eth_stats eth;
112 };
113 
114 #pragma pack(1)
115 
116 #define BFA_CEE_LLDP_MAX_STRING_LEN (128)
117 #define BFA_CEE_DCBX_MAX_PRIORITY	(8)
118 #define BFA_CEE_DCBX_MAX_PGID		(8)
119 
120 #define BFA_CEE_LLDP_SYS_CAP_OTHER	0x0001
121 #define BFA_CEE_LLDP_SYS_CAP_REPEATER	0x0002
122 #define BFA_CEE_LLDP_SYS_CAP_MAC_BRIDGE	0x0004
123 #define BFA_CEE_LLDP_SYS_CAP_WLAN_AP	0x0008
124 #define BFA_CEE_LLDP_SYS_CAP_ROUTER	0x0010
125 #define BFA_CEE_LLDP_SYS_CAP_TELEPHONE	0x0020
126 #define BFA_CEE_LLDP_SYS_CAP_DOCSIS_CD	0x0040
127 #define BFA_CEE_LLDP_SYS_CAP_STATION	0x0080
128 #define BFA_CEE_LLDP_SYS_CAP_CVLAN	0x0100
129 #define BFA_CEE_LLDP_SYS_CAP_SVLAN	0x0200
130 #define BFA_CEE_LLDP_SYS_CAP_TPMR	0x0400
131 
132 /* LLDP string type */
133 struct bfa_cee_lldp_str {
134 	u8 sub_type;
135 	u8 len;
136 	u8 rsvd[2];
137 	u8 value[BFA_CEE_LLDP_MAX_STRING_LEN];
138 };
139 
140 /* LLDP paramters */
141 struct bfa_cee_lldp_cfg {
142 	struct bfa_cee_lldp_str chassis_id;
143 	struct bfa_cee_lldp_str port_id;
144 	struct bfa_cee_lldp_str port_desc;
145 	struct bfa_cee_lldp_str sys_name;
146 	struct bfa_cee_lldp_str sys_desc;
147 	struct bfa_cee_lldp_str mgmt_addr;
148 	u16 time_to_live;
149 	u16 enabled_system_cap;
150 };
151 
152 enum bfa_cee_dcbx_version {
153 	DCBX_PROTOCOL_PRECEE	= 1,
154 	DCBX_PROTOCOL_CEE	= 2,
155 };
156 
157 enum bfa_cee_lls {
158 	/* LLS is down because the TLV not sent by the peer */
159 	CEE_LLS_DOWN_NO_TLV = 0,
160 	/* LLS is down as advertised by the peer */
161 	CEE_LLS_DOWN	= 1,
162 	CEE_LLS_UP	= 2,
163 };
164 
165 /* CEE/DCBX parameters */
166 struct bfa_cee_dcbx_cfg {
167 	u8 pgid[BFA_CEE_DCBX_MAX_PRIORITY];
168 	u8 pg_percentage[BFA_CEE_DCBX_MAX_PGID];
169 	u8 pfc_primap; /* bitmap of priorties with PFC enabled */
170 	u8 fcoe_primap; /* bitmap of priorities used for FcoE traffic */
171 	u8 iscsi_primap; /* bitmap of priorities used for iSCSI traffic */
172 	u8 dcbx_version; /* operating version:CEE or preCEE */
173 	u8 lls_fcoe; /* FCoE Logical Link Status */
174 	u8 lls_lan; /* LAN Logical Link Status */
175 	u8 rsvd[2];
176 };
177 
178 /* CEE status */
179 /* Making this to tri-state for the benefit of port list command */
180 enum bfa_cee_status {
181 	CEE_UP = 0,
182 	CEE_PHY_UP = 1,
183 	CEE_LOOPBACK = 2,
184 	CEE_PHY_DOWN = 3,
185 };
186 
187 /* CEE Query */
188 struct bfa_cee_attr {
189 	u8	cee_status;
190 	u8 error_reason;
191 	struct bfa_cee_lldp_cfg lldp_remote;
192 	struct bfa_cee_dcbx_cfg dcbx_remote;
193 	mac_t src_mac;
194 	u8 link_speed;
195 	u8 nw_priority;
196 	u8 filler[2];
197 };
198 
199 /* LLDP/DCBX/CEE Statistics */
200 struct bfa_cee_stats {
201 	u32	lldp_tx_frames;		/*!< LLDP Tx Frames */
202 	u32	lldp_rx_frames;		/*!< LLDP Rx Frames */
203 	u32	lldp_rx_frames_invalid;	/*!< LLDP Rx Frames invalid */
204 	u32	lldp_rx_frames_new;	/*!< LLDP Rx Frames new */
205 	u32	lldp_tlvs_unrecognized;	/*!< LLDP Rx unrecognized TLVs */
206 	u32	lldp_rx_shutdown_tlvs;	/*!< LLDP Rx shutdown TLVs */
207 	u32	lldp_info_aged_out;	/*!< LLDP remote info aged out */
208 	u32	dcbx_phylink_ups;	/*!< DCBX phy link ups */
209 	u32	dcbx_phylink_downs;	/*!< DCBX phy link downs */
210 	u32	dcbx_rx_tlvs;		/*!< DCBX Rx TLVs */
211 	u32	dcbx_rx_tlvs_invalid;	/*!< DCBX Rx TLVs invalid */
212 	u32	dcbx_control_tlv_error;	/*!< DCBX control TLV errors */
213 	u32	dcbx_feature_tlv_error;	/*!< DCBX feature TLV errors */
214 	u32	dcbx_cee_cfg_new;	/*!< DCBX new CEE cfg rcvd */
215 	u32	cee_status_down;	/*!< CEE status down */
216 	u32	cee_status_up;		/*!< CEE status up */
217 	u32	cee_hw_cfg_changed;	/*!< CEE hw cfg changed */
218 	u32	cee_rx_invalid_cfg;	/*!< CEE invalid cfg */
219 };
220 
221 #pragma pack()
222 
223 #endif	/* __BFA_DEFS_CNA_H__ */
224