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