upload tizen1.0 source
[kernel/linux-2.6.36.git] / drivers / scsi / bfa / include / defs / bfa_defs_pport.h
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
18 #ifndef __BFA_DEFS_PPORT_H__
19 #define __BFA_DEFS_PPORT_H__
20
21 #include <bfa_os_inc.h>
22 #include <protocol/fc.h>
23 #include <defs/bfa_defs_types.h>
24 #include <defs/bfa_defs_qos.h>
25 #include <cna/pstats/phyport_defs.h>
26
27 /* Modify char* port_stt[] in bfal_port.c if a new state was added */
28 enum bfa_pport_states {
29         BFA_PPORT_ST_UNINIT             = 1,
30         BFA_PPORT_ST_ENABLING_QWAIT     = 2,
31         BFA_PPORT_ST_ENABLING           = 3,
32         BFA_PPORT_ST_LINKDOWN           = 4,
33         BFA_PPORT_ST_LINKUP             = 5,
34         BFA_PPORT_ST_DISABLING_QWAIT    = 6,
35         BFA_PPORT_ST_DISABLING          = 7,
36         BFA_PPORT_ST_DISABLED           = 8,
37         BFA_PPORT_ST_STOPPED            = 9,
38         BFA_PPORT_ST_IOCDOWN            = 10,
39         BFA_PPORT_ST_IOCDIS             = 11,
40         BFA_PPORT_ST_FWMISMATCH         = 12,
41         BFA_PPORT_ST_PREBOOT_DISABLED   = 13,
42         BFA_PPORT_ST_MAX_STATE,
43 };
44
45 /**
46  *      Port speed settings. Each specific speed is a bit field. Use multiple
47  *      bits to specify speeds to be selected for auto-negotiation.
48  */
49 enum bfa_pport_speed {
50         BFA_PPORT_SPEED_UNKNOWN = 0,
51         BFA_PPORT_SPEED_1GBPS   = 1,
52         BFA_PPORT_SPEED_2GBPS   = 2,
53         BFA_PPORT_SPEED_4GBPS   = 4,
54         BFA_PPORT_SPEED_8GBPS   = 8,
55         BFA_PPORT_SPEED_10GBPS  = 10,
56         BFA_PPORT_SPEED_AUTO =
57                 (BFA_PPORT_SPEED_1GBPS | BFA_PPORT_SPEED_2GBPS |
58                  BFA_PPORT_SPEED_4GBPS | BFA_PPORT_SPEED_8GBPS),
59 };
60
61 /**
62  *              Port operational type (in sync with SNIA port type).
63  */
64 enum bfa_pport_type {
65         BFA_PPORT_TYPE_UNKNOWN = 1,     /*  port type is unknown */
66         BFA_PPORT_TYPE_TRUNKED = 2,     /*  Trunked mode */
67         BFA_PPORT_TYPE_NPORT   = 5,     /*  P2P with switched fabric */
68         BFA_PPORT_TYPE_NLPORT  = 6,     /*  public loop */
69         BFA_PPORT_TYPE_LPORT   = 20,    /*  private loop */
70         BFA_PPORT_TYPE_P2P     = 21,    /*  P2P with no switched fabric */
71         BFA_PPORT_TYPE_VPORT   = 22,    /*  NPIV - virtual port */
72 };
73
74 /**
75  *              Port topology setting. A port's topology and fabric login status
76  *              determine its operational type.
77  */
78 enum bfa_pport_topology {
79         BFA_PPORT_TOPOLOGY_NONE = 0,    /*  No valid topology */
80         BFA_PPORT_TOPOLOGY_P2P  = 1,    /*  P2P only */
81         BFA_PPORT_TOPOLOGY_LOOP = 2,    /*  LOOP topology */
82         BFA_PPORT_TOPOLOGY_AUTO = 3,    /*  auto topology selection */
83 };
84
85 /**
86  *              Physical port loopback types.
87  */
88 enum bfa_pport_opmode {
89         BFA_PPORT_OPMODE_NORMAL   = 0x00, /*  normal non-loopback mode */
90         BFA_PPORT_OPMODE_LB_INT   = 0x01, /*  internal loop back */
91         BFA_PPORT_OPMODE_LB_SLW   = 0x02, /*  serial link wrapback (serdes) */
92         BFA_PPORT_OPMODE_LB_EXT   = 0x04, /*  external loop back (serdes) */
93         BFA_PPORT_OPMODE_LB_CBL   = 0x08, /*  cabled loop back */
94         BFA_PPORT_OPMODE_LB_NLINT = 0x20, /*  NL_Port internal loopback */
95 };
96
97 #define BFA_PPORT_OPMODE_LB_HARD(_mode)                 \
98         ((_mode == BFA_PPORT_OPMODE_LB_INT) ||          \
99      (_mode == BFA_PPORT_OPMODE_LB_SLW) ||              \
100      (_mode == BFA_PPORT_OPMODE_LB_EXT))
101
102 /**
103                 Port State (in sync with SNIA port state).
104  */
105 enum bfa_pport_snia_state {
106         BFA_PPORT_STATE_UNKNOWN  = 1,   /*  port is not initialized */
107         BFA_PPORT_STATE_ONLINE   = 2,   /*  port is ONLINE */
108         BFA_PPORT_STATE_DISABLED = 3,   /*  port is disabled by user */
109         BFA_PPORT_STATE_BYPASSED = 4,   /*  port is bypassed (in LOOP) */
110         BFA_PPORT_STATE_DIAG     = 5,   /*  port diagnostics is active */
111         BFA_PPORT_STATE_LINKDOWN = 6,   /*  link is down */
112         BFA_PPORT_STATE_LOOPBACK = 8,   /*  port is looped back */
113 };
114
115 /**
116  *              Port link state
117  */
118 enum bfa_pport_linkstate {
119         BFA_PPORT_LINKUP         = 1,   /*  Physical port/Trunk link up */
120         BFA_PPORT_LINKDOWN       = 2,   /*  Physical port/Trunk link down */
121         BFA_PPORT_TRUNK_LINKDOWN = 3,   /*  Trunk link down (new tmaster) */
122 };
123
124 /**
125  *              Port link state event
126  */
127 #define bfa_pport_event_t enum bfa_pport_linkstate
128
129 /**
130  *              Port link state reason code
131  */
132 enum bfa_pport_linkstate_rsn {
133         BFA_PPORT_LINKSTATE_RSN_NONE            = 0,
134         BFA_PPORT_LINKSTATE_RSN_DISABLED        = 1,
135         BFA_PPORT_LINKSTATE_RSN_RX_NOS          = 2,
136         BFA_PPORT_LINKSTATE_RSN_RX_OLS          = 3,
137         BFA_PPORT_LINKSTATE_RSN_RX_LIP          = 4,
138         BFA_PPORT_LINKSTATE_RSN_RX_LIPF7        = 5,
139         BFA_PPORT_LINKSTATE_RSN_SFP_REMOVED     = 6,
140         BFA_PPORT_LINKSTATE_RSN_PORT_FAULT      = 7,
141         BFA_PPORT_LINKSTATE_RSN_RX_LOS          = 8,
142         BFA_PPORT_LINKSTATE_RSN_LOCAL_FAULT     = 9,
143         BFA_PPORT_LINKSTATE_RSN_REMOTE_FAULT    = 10,
144         BFA_PPORT_LINKSTATE_RSN_TIMEOUT         = 11,
145
146
147
148         /* CEE related reason codes/errors */
149         CEE_LLDP_INFO_AGED_OUT       = 20,
150         CEE_LLDP_SHUTDOWN_TLV_RCVD   = 21,
151         CEE_PEER_NOT_ADVERTISE_DCBX  = 22,
152         CEE_PEER_NOT_ADVERTISE_PG    = 23,
153         CEE_PEER_NOT_ADVERTISE_PFC   = 24,
154         CEE_PEER_NOT_ADVERTISE_FCOE  = 25,
155         CEE_PG_NOT_COMPATIBLE        = 26,
156         CEE_PFC_NOT_COMPATIBLE       = 27,
157         CEE_FCOE_NOT_COMPATIBLE      = 28,
158         CEE_BAD_PG_RCVD              = 29,
159         CEE_BAD_BW_RCVD              = 30,
160         CEE_BAD_PFC_RCVD             = 31,
161         CEE_BAD_FCOE_PRI_RCVD        = 32,
162         CEE_FCOE_PRI_PFC_OFF         = 33,
163         CEE_DUP_CONTROL_TLV_RCVD     = 34,
164         CEE_DUP_FEAT_TLV_RCVD        = 35,
165         CEE_APPLY_NEW_CFG            = 36,      /* reason, not an error */
166         CEE_PROTOCOL_INIT            = 37,  /* reason, not an error */
167         CEE_PHY_LINK_DOWN            = 38,
168         CEE_LLS_FCOE_ABSENT          = 39,
169         CEE_LLS_FCOE_DOWN            = 40
170 };
171
172 /**
173  *      Default Target Rate Limiting Speed.
174  */
175 #define BFA_PPORT_DEF_TRL_SPEED  BFA_PPORT_SPEED_1GBPS
176
177 /**
178  *      Physical port configuration
179  */
180 struct bfa_pport_cfg_s {
181         u8         topology;    /*  bfa_pport_topology          */
182         u8         speed;               /*  enum bfa_pport_speed        */
183         u8         trunked;     /*  trunked or not              */
184         u8         qos_enabled; /*  qos enabled or not          */
185         u8         trunk_ports; /*  bitmap of trunked ports     */
186         u8         cfg_hardalpa;        /*  is hard alpa configured     */
187         u16        maxfrsize;   /*  maximum frame size          */
188         u8         hardalpa;    /*  configured hard alpa        */
189         u8         rx_bbcredit; /*  receive buffer credits      */
190         u8         tx_bbcredit; /*  transmit buffer credits     */
191         u8         ratelimit;   /*  ratelimit enabled or not    */
192         u8         trl_def_speed;       /*  ratelimit default speed     */
193         u8              rsvd[3];
194         u16     path_tov;       /*  device path timeout */
195         u16     q_depth;        /*  SCSI Queue depth            */
196 };
197
198 /**
199  *              Port attribute values.
200  */
201 struct bfa_pport_attr_s {
202         /*
203          * Static fields
204          */
205         wwn_t           nwwn;           /*  node wwn */
206         wwn_t           pwwn;           /*  port wwn */
207         wwn_t           factorynwwn;    /*  factory node wwn */
208         wwn_t           factorypwwn;    /*  factory port wwn */
209         enum fc_cos     cos_supported;  /*  supported class of services */
210         u32        rsvd;
211         struct fc_symname_s    port_symname;    /*  port symbolic name */
212         enum bfa_pport_speed speed_supported; /*  supported speeds */
213         bfa_boolean_t   pbind_enabled;  /*  Will be set if Persistent binding
214                                          *   enabled. Relevant only in Windows
215                                          */
216
217         /*
218          * Configured values
219          */
220         struct bfa_pport_cfg_s pport_cfg;       /*  pport cfg */
221
222         /*
223          * Dynamic field - info from BFA
224          */
225         enum bfa_pport_states   port_state;     /*  current port state */
226         enum bfa_pport_speed    speed;          /*  current speed */
227         enum bfa_pport_topology         topology;       /*  current topology */
228         bfa_boolean_t           beacon;         /*  current beacon status */
229         bfa_boolean_t           link_e2e_beacon;/*  set if link beacon on */
230         bfa_boolean_t           plog_enabled;   /*  set if portlog is enabled*/
231
232         /*
233          * Dynamic field - info from FCS
234          */
235         u32             pid;            /*  port ID */
236         enum bfa_pport_type     port_type;      /*  current topology */
237         u32             loopback;       /*  external loopback */
238         u32             authfail;       /* auth fail state */
239         u32             rsvd2;          /*  padding for 64 bit */
240 };
241
242 /**
243  *              FC Port statistics.
244  */
245 struct bfa_pport_fc_stats_s {
246         u64    secs_reset; /* Seconds since stats is reset     */
247         u64    tx_frames;  /* Tx frames                */
248         u64    tx_words;   /* Tx words                 */
249         u64    tx_lip;     /* Tx LIP               */
250         u64    tx_nos;     /* Tx NOS               */
251         u64    tx_ols;     /* Tx OLS               */
252         u64    tx_lr;      /* Tx LR                */
253         u64    tx_lrr;     /* Tx LRR               */
254         u64    rx_frames;  /* Rx frames                */
255         u64    rx_words;   /* Rx words                 */
256         u64    lip_count;  /* Rx LIP                   */
257         u64    nos_count;  /* Rx NOS               */
258         u64    ols_count;  /* Rx OLS               */
259         u64    lr_count;   /* Rx LR                */
260         u64    lrr_count;  /* Rx LRR               */
261         u64    invalid_crcs;   /* Rx CRC err frames            */
262         u64    invalid_crc_gd_eof; /* Rx CRC err good EOF frames   */
263         u64    undersized_frm; /* Rx undersized frames         */
264         u64    oversized_frm;  /* Rx oversized frames          */
265         u64    bad_eof_frm;    /* Rx frames with bad EOF       */
266         u64    error_frames;   /* Errored frames           */
267         u64    dropped_frames; /* Dropped frames           */
268         u64    link_failures;  /* Link Failure (LF) count          */
269         u64    loss_of_syncs;  /* Loss of sync count           */
270         u64    loss_of_signals;/* Loss of signal count         */
271         u64    primseq_errs;   /* Primitive sequence protocol err. */
272         u64    bad_os_count;   /* Invalid ordered sets         */
273         u64    err_enc_out;    /* Encoding err nonframe_8b10b      */
274         u64    err_enc;    /* Encoding err frame_8b10b         */
275 };
276
277 /**
278  *              Eth Port statistics.
279  */
280 struct bfa_pport_eth_stats_s {
281         u64    secs_reset;   /* Seconds since stats is reset   */
282         u64    frame_64;     /* Frames 64 bytes            */
283         u64    frame_65_127;     /* Frames 65-127 bytes        */
284         u64    frame_128_255;    /* Frames 128-255 bytes       */
285         u64    frame_256_511;    /* Frames 256-511 bytes       */
286         u64    frame_512_1023;   /* Frames 512-1023 bytes          */
287         u64    frame_1024_1518;  /* Frames 1024-1518 bytes         */
288         u64    frame_1519_1522;  /* Frames 1519-1522 bytes         */
289         u64    tx_bytes;     /* Tx bytes               */
290         u64    tx_packets;   /* Tx packets             */
291         u64    tx_mcast_packets; /* Tx multicast packets       */
292         u64    tx_bcast_packets; /* Tx broadcast packets       */
293         u64    tx_control_frame; /* Tx control frame           */
294         u64    tx_drop;      /* Tx drops               */
295         u64    tx_jabber;    /* Tx jabber              */
296         u64    tx_fcs_error;     /* Tx FCS error           */
297         u64    tx_fragments;     /* Tx fragments           */
298         u64    rx_bytes;     /* Rx bytes               */
299         u64    rx_packets;   /* Rx packets             */
300         u64    rx_mcast_packets; /* Rx multicast packets       */
301         u64    rx_bcast_packets; /* Rx broadcast packets       */
302         u64    rx_control_frames; /* Rx control frames         */
303         u64    rx_unknown_opcode; /* Rx unknown opcode         */
304         u64    rx_drop;      /* Rx drops               */
305         u64    rx_jabber;    /* Rx jabber              */
306         u64    rx_fcs_error;     /* Rx FCS errors              */
307         u64    rx_alignment_error; /* Rx alignment errors          */
308         u64    rx_frame_length_error; /* Rx frame len errors       */
309         u64    rx_code_error;    /* Rx code errors             */
310         u64    rx_fragments;     /* Rx fragments           */
311         u64    rx_pause;     /* Rx pause               */
312         u64    rx_zero_pause;    /* Rx zero pause              */
313         u64    tx_pause;     /* Tx pause               */
314         u64    tx_zero_pause;    /* Tx zero pause              */
315         u64    rx_fcoe_pause;    /* Rx FCoE pause              */
316         u64    rx_fcoe_zero_pause; /* Rx FCoE zero pause       */
317         u64    tx_fcoe_pause;    /* Tx FCoE pause              */
318         u64    tx_fcoe_zero_pause; /* Tx FCoE zero pause       */
319 };
320
321 /**
322  *              Port statistics.
323  */
324 union bfa_pport_stats_u {
325         struct bfa_pport_fc_stats_s     fc;
326         struct bfa_pport_eth_stats_s    eth;
327 };
328
329 /**
330  *              Port FCP mappings.
331  */
332 struct bfa_pport_fcpmap_s {
333         char            osdevname[256];
334         u32     bus;
335         u32        target;
336         u32        oslun;
337         u32        fcid;
338         wwn_t           nwwn;
339         wwn_t           pwwn;
340         u64        fcplun;
341         char            luid[256];
342 };
343
344 /**
345  *              Port RNI         */
346 struct bfa_pport_rnid_s {
347         wwn_t             wwn;
348         u32          unittype;
349         u32          portid;
350         u32          attached_nodes_num;
351         u16          ip_version;
352         u16          udp_port;
353         u8           ipaddr[16];
354         u16          rsvd;
355         u16          topologydiscoveryflags;
356 };
357
358 struct bfa_fcport_fcf_s {
359         wwn_t           name;           /* FCF name                 */
360         wwn_t           fabric_name;    /* Fabric Name              */
361         u8              fipenabled;     /* FIP enabled or not       */
362         u8              fipfailed;      /* FIP failed or not        */
363         u8              resv[2];
364         u8              pri;            /* FCF priority             */
365         u8              version;        /* FIP version used         */
366         u8              available;      /* Available  for  login    */
367         u8              fka_disabled;   /* FKA is disabled          */
368         u8              maxsz_verified; /* FCoE max size verified   */
369         u8              fc_map[3];      /* FC map                   */
370         u16             vlan;           /* FCoE vlan tag/priority   */
371         u32             fka_adv_per;    /* FIP  ka advert. period   */
372         struct mac_s    mac;            /* FCF mac                  */
373 };
374
375 /**
376  *              Link state information
377  */
378 struct bfa_pport_link_s {
379         u8         linkstate;   /*  Link state bfa_pport_linkstate */
380         u8         linkstate_rsn;       /*  bfa_pport_linkstate_rsn_t */
381         u8         topology;    /*  P2P/LOOP bfa_pport_topology */
382         u8         speed;               /*  Link speed (1/2/4/8 G) */
383         u32        linkstate_opt;       /*  Linkstate optional data (debug) */
384         u8         trunked;     /*  Trunked or not (1 or 0) */
385         u8         resvd[3];
386         struct bfa_qos_attr_s  qos_attr;   /* QoS Attributes */
387         union {
388                 struct bfa_qos_vc_attr_s qos_vc_attr;  /* VC info from ELP */
389                 struct bfa_fcport_fcf_s fcf;    /* FCF information (for FCoE) */
390         } vc_fcf;
391 };
392
393 #endif /* __BFA_DEFS_PPORT_H__ */