upload tizen1.0 source
[kernel/linux-2.6.36.git] / drivers / scsi / bfa / include / protocol / fc.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 __FC_H__
19 #define __FC_H__
20
21 #include <protocol/types.h>
22
23 #pragma pack(1)
24
25 /*
26  * Fibre Channel Header Structure (FCHS) definition
27  */
28 struct fchs_s {
29 #ifdef __BIGENDIAN
30         u32        routing:4;   /* routing bits */
31         u32        cat_info:4;  /* category info */
32 #else
33         u32        cat_info:4;  /* category info */
34         u32        routing:4;   /* routing bits */
35 #endif
36         u32        d_id:24;     /* destination identifier */
37
38         u32        cs_ctl:8;    /* class specific control */
39         u32        s_id:24;     /* source identifier */
40
41         u32        type:8;              /* data structure type */
42         u32        f_ctl:24;    /* initial frame control */
43
44         u8         seq_id;              /* sequence identifier */
45         u8         df_ctl;              /* data field control */
46         u16        seq_cnt;     /* sequence count */
47
48         u16        ox_id;               /* originator exchange ID */
49         u16        rx_id;               /* responder exchange ID */
50
51         u32        ro;          /* relative offset */
52 };
53
54 #define FC_SOF_LEN      4
55 #define FC_EOF_LEN      4
56 #define FC_CRC_LEN      4
57
58 /*
59  * Fibre Channel BB_E Header Structure
60  */
61 struct fcbbehs_s {
62         u16     ver_rsvd;
63         u32     rsvd[2];
64         u32     rsvd__sof;
65 };
66
67 #define FC_SEQ_ID_MAX           256
68
69 /*
70  * routing bit definitions
71  */
72 enum {
73         FC_RTG_FC4_DEV_DATA     = 0x0,  /* FC-4 Device Data */
74         FC_RTG_EXT_LINK         = 0x2,  /* Extended Link Data */
75         FC_RTG_FC4_LINK_DATA    = 0x3,  /* FC-4 Link Data */
76         FC_RTG_VIDEO_DATA       = 0x4,  /* Video Data */
77         FC_RTG_EXT_HDR          = 0x5,  /* VFT, IFR or Encapsuled */
78         FC_RTG_BASIC_LINK       = 0x8,  /* Basic Link data */
79         FC_RTG_LINK_CTRL        = 0xC,  /* Link Control */
80 };
81
82 /*
83  * information category for extended link data and FC-4 Link Data
84  */
85 enum {
86         FC_CAT_LD_REQUEST       = 0x2,  /* Request */
87         FC_CAT_LD_REPLY         = 0x3,  /* Reply */
88         FC_CAT_LD_DIAG          = 0xF,  /* for DIAG use only */
89 };
90
91 /*
92  * information category for extended headers (VFT, IFR or encapsulation)
93  */
94 enum {
95         FC_CAT_VFT_HDR = 0x0,   /* Virtual fabric tagging header */
96         FC_CAT_IFR_HDR = 0x1,   /* Inter-Fabric routing header */
97         FC_CAT_ENC_HDR = 0x2,   /* Encapsulation header */
98 };
99
100 /*
101  * information category for FC-4 device data
102  */
103 enum {
104         FC_CAT_UNCATEG_INFO     = 0x0,  /* Uncategorized information */
105         FC_CAT_SOLICIT_DATA     = 0x1,  /* Solicited Data */
106         FC_CAT_UNSOLICIT_CTRL   = 0x2,  /* Unsolicited Control */
107         FC_CAT_SOLICIT_CTRL     = 0x3,  /* Solicited Control */
108         FC_CAT_UNSOLICIT_DATA   = 0x4,  /* Unsolicited Data */
109         FC_CAT_DATA_DESC        = 0x5,  /* Data Descriptor */
110         FC_CAT_UNSOLICIT_CMD    = 0x6,  /* Unsolicited Command */
111         FC_CAT_CMD_STATUS       = 0x7,  /* Command Status */
112 };
113
114 /*
115  * information category for Link Control
116  */
117 enum {
118         FC_CAT_ACK_1            = 0x00,
119         FC_CAT_ACK_0_N          = 0x01,
120         FC_CAT_P_RJT            = 0x02,
121         FC_CAT_F_RJT            = 0x03,
122         FC_CAT_P_BSY            = 0x04,
123         FC_CAT_F_BSY_DATA       = 0x05,
124         FC_CAT_F_BSY_LINK_CTL   = 0x06,
125         FC_CAT_F_LCR            = 0x07,
126         FC_CAT_NTY              = 0x08,
127         FC_CAT_END              = 0x09,
128 };
129
130 /*
131  * Type Field Definitions. FC-PH Section 18.5 pg. 165
132  */
133 enum {
134         FC_TYPE_BLS             = 0x0,  /* Basic Link Service */
135         FC_TYPE_ELS             = 0x1,  /* Extended Link Service */
136         FC_TYPE_IP              = 0x5,  /* IP */
137         FC_TYPE_FCP             = 0x8,  /* SCSI-FCP */
138         FC_TYPE_GPP             = 0x9,  /* SCSI_GPP */
139         FC_TYPE_SERVICES        = 0x20, /* Fibre Channel Services */
140         FC_TYPE_FC_FSS          = 0x22, /* Fabric Switch Services */
141         FC_TYPE_FC_AL           = 0x23, /* FC-AL */
142         FC_TYPE_FC_SNMP         = 0x24, /* FC-SNMP */
143         FC_TYPE_MAX             = 256,  /* 256 FC-4 types */
144 };
145
146 struct fc_fc4types_s{
147         u8         bits[FC_TYPE_MAX / 8];
148 };
149
150 /*
151  * Frame Control Definitions. FC-PH Table-45. pg. 168
152  */
153 enum {
154         FCTL_EC_ORIG = 0x000000,        /* exchange originator */
155         FCTL_EC_RESP = 0x800000,        /* exchange responder */
156         FCTL_SEQ_INI = 0x000000,        /* sequence initiator */
157         FCTL_SEQ_REC = 0x400000,        /* sequence recipient */
158         FCTL_FS_EXCH = 0x200000,        /* first sequence of xchg */
159         FCTL_LS_EXCH = 0x100000,        /* last sequence of xchg */
160         FCTL_END_SEQ = 0x080000,        /* last frame of sequence */
161         FCTL_SI_XFER = 0x010000,        /* seq initiative transfer */
162         FCTL_RO_PRESENT = 0x000008,     /* relative offset present */
163         FCTL_FILLBYTE_MASK = 0x000003   /* , fill byte mask */
164 };
165
166 /*
167  * Fabric Well Known Addresses
168  */
169 enum {
170         FC_MIN_WELL_KNOWN_ADDR          = 0xFFFFF0,
171         FC_DOMAIN_CONTROLLER_MASK       = 0xFFFC00,
172         FC_ALIAS_SERVER                 = 0xFFFFF8,
173         FC_MGMT_SERVER                  = 0xFFFFFA,
174         FC_TIME_SERVER                  = 0xFFFFFB,
175         FC_NAME_SERVER                  = 0xFFFFFC,
176         FC_FABRIC_CONTROLLER            = 0xFFFFFD,
177         FC_FABRIC_PORT                  = 0xFFFFFE,
178         FC_BROADCAST_SERVER             = 0xFFFFFF
179 };
180
181 /*
182  * domain/area/port defines
183  */
184 #define FC_DOMAIN_MASK  0xFF0000
185 #define FC_DOMAIN_SHIFT 16
186 #define FC_AREA_MASK    0x00FF00
187 #define FC_AREA_SHIFT   8
188 #define FC_PORT_MASK    0x0000FF
189 #define FC_PORT_SHIFT   0
190
191 #define FC_GET_DOMAIN(p)        (((p) & FC_DOMAIN_MASK) >> FC_DOMAIN_SHIFT)
192 #define FC_GET_AREA(p)          (((p) & FC_AREA_MASK) >> FC_AREA_SHIFT)
193 #define FC_GET_PORT(p)          (((p) & FC_PORT_MASK) >> FC_PORT_SHIFT)
194
195 #define FC_DOMAIN_CTRLR(p)      (FC_DOMAIN_CONTROLLER_MASK | (FC_GET_DOMAIN(p)))
196
197 enum {
198         FC_RXID_ANY = 0xFFFFU,
199 };
200
201 /*
202  * generic ELS command
203  */
204 struct fc_els_cmd_s{
205         u32        els_code:8;  /* ELS Command Code */
206         u32        reserved:24;
207 };
208
209 /*
210  * ELS Command Codes. FC-PH Table-75. pg. 223
211  */
212 enum {
213         FC_ELS_LS_RJT = 0x1,    /* Link Service Reject. */
214         FC_ELS_ACC = 0x02,      /* Accept */
215         FC_ELS_PLOGI = 0x03,    /* N_Port Login. */
216         FC_ELS_FLOGI = 0x04,    /* F_Port Login. */
217         FC_ELS_LOGO = 0x05,     /* Logout. */
218         FC_ELS_ABTX = 0x06,     /* Abort Exchange */
219         FC_ELS_RES = 0x08,      /* Read Exchange status */
220         FC_ELS_RSS = 0x09,      /* Read sequence status block */
221         FC_ELS_RSI = 0x0A,      /* Request Sequence Initiative */
222         FC_ELS_ESTC = 0x0C,     /* Estimate Credit. */
223         FC_ELS_RTV = 0x0E,      /* Read Timeout Value. */
224         FC_ELS_RLS = 0x0F,      /* Read Link Status. */
225         FC_ELS_ECHO = 0x10,     /* Echo */
226         FC_ELS_TEST = 0x11,     /* Test */
227         FC_ELS_RRQ = 0x12,      /* Reinstate Recovery Qualifier. */
228         FC_ELS_REC = 0x13,      /* Add this for TAPE support in FCR */
229         FC_ELS_PRLI = 0x20,     /* Process Login */
230         FC_ELS_PRLO = 0x21,     /* Process Logout. */
231         FC_ELS_SCN = 0x22,      /* State Change Notification. */
232         FC_ELS_TPRLO = 0x24,    /* Third Party Process Logout. */
233         FC_ELS_PDISC = 0x50,    /* Discover N_Port Parameters. */
234         FC_ELS_FDISC = 0x51,    /* Discover F_Port Parameters. */
235         FC_ELS_ADISC = 0x52,    /* Discover Address. */
236         FC_ELS_FAN = 0x60,      /* Fabric Address Notification */
237         FC_ELS_RSCN = 0x61,     /* Reg State Change Notification */
238         FC_ELS_SCR = 0x62,      /* State Change Registration. */
239         FC_ELS_RTIN = 0x77,     /* Mangement server request */
240         FC_ELS_RNID = 0x78,     /* Mangement server request */
241         FC_ELS_RLIR = 0x79,     /* Registered Link Incident Record */
242
243         FC_ELS_RPSC = 0x7D,     /* Report Port Speed Capabilities */
244         FC_ELS_QSA = 0x7E,      /* Query Security Attributes. Ref FC-SP */
245         FC_ELS_E2E_LBEACON = 0x81,
246                                 /* End-to-End Link Beacon */
247         FC_ELS_AUTH = 0x90,     /* Authentication. Ref FC-SP */
248         FC_ELS_RFCN = 0x97,     /* Request Fabric Change Notification. Ref
249                                  *FC-SP */
250
251 };
252
253 /*
254  *  Version numbers for FC-PH standards,
255  *  used in login to indicate what port
256  *  supports. See FC-PH-X table 158.
257  */
258 enum {
259         FC_PH_VER_4_3 = 0x09,
260         FC_PH_VER_PH_3 = 0x20,
261 };
262
263 /*
264  * PDU size defines
265  */
266 enum {
267         FC_MIN_PDUSZ = 512,
268         FC_MAX_PDUSZ = 2112,
269 };
270
271 /*
272  * N_Port PLOGI Common Service Parameters.
273  * FC-PH-x. Figure-76. pg. 308.
274  */
275 struct fc_plogi_csp_s{
276         u8         verhi;       /* FC-PH high version */
277         u8         verlo;       /* FC-PH low version */
278         u16        bbcred;      /* BB_Credit */
279
280 #ifdef __BIGENDIAN
281         u8         ciro:1,              /* continuously increasing RO */
282                         rro:1,          /* random relative offset */
283                         npiv_supp:1,    /* NPIV supported */
284                         port_type:1,    /* N_Port/F_port */
285                         altbbcred:1,    /* alternate BB_Credit */
286                         resolution:1,   /* ms/ns ED_TOV resolution */
287                         vvl_info:1,     /* VVL Info included */
288                         reserved1:1;
289
290         u8         hg_supp:1,
291                         query_dbc:1,
292                         security:1,
293                         sync_cap:1,
294                         r_t_tov:1,
295                         dh_dup_supp:1,
296                         cisc:1,         /* continuously increasing seq count */
297                         payload:1;
298 #else
299         u8         reserved2:2,
300                         resolution:1,   /* ms/ns ED_TOV resolution */
301                         altbbcred:1,    /* alternate BB_Credit */
302                         port_type:1,    /* N_Port/F_port */
303                         npiv_supp:1,    /* NPIV supported */
304                         rro:1,          /* random relative offset */
305                         ciro:1;         /* continuously increasing RO */
306
307         u8         payload:1,
308                         cisc:1,         /* continuously increasing seq count */
309                         dh_dup_supp:1,
310                         r_t_tov:1,
311                         sync_cap:1,
312                         security:1,
313                         query_dbc:1,
314                         hg_supp:1;
315 #endif
316
317         u16        rxsz;                /* recieve data_field size */
318
319         u16        conseq;
320         u16        ro_bitmap;
321
322         u32        e_d_tov;
323 };
324
325 /*
326  * N_Port PLOGI Class Specific Parameters.
327  * FC-PH-x. Figure 78. pg. 318.
328  */
329 struct fc_plogi_clp_s{
330 #ifdef __BIGENDIAN
331         u32        class_valid:1;
332         u32        intermix:1;  /* class intermix supported if set =1.
333                                          * valid only for class1. Reserved for
334                                          * class2 & class3
335                                          */
336         u32        reserved1:2;
337         u32        sequential:1;
338         u32        reserved2:3;
339 #else
340         u32        reserved2:3;
341         u32        sequential:1;
342         u32        reserved1:2;
343         u32        intermix:1;  /* class intermix supported if set =1.
344                                          * valid only for class1. Reserved for
345                                          * class2 & class3
346                                          */
347         u32        class_valid:1;
348 #endif
349
350         u32        reserved3:24;
351
352         u32        reserved4:16;
353         u32        rxsz:16;     /* Receive data_field size */
354
355         u32        reserved5:8;
356         u32        conseq:8;
357         u32        e2e_credit:16;       /* end to end credit */
358
359         u32        reserved7:8;
360         u32        ospx:8;
361         u32        reserved8:16;
362 };
363
364 #define FLOGI_VVL_BRCD    0x42524344 /* ASCII value for each character in
365                                       * string "BRCD" */
366
367 /*
368  * PLOGI els command and reply payload
369  */
370 struct fc_logi_s{
371         struct fc_els_cmd_s els_cmd;    /* ELS command code */
372         struct fc_plogi_csp_s  csp;             /* common service params */
373         wwn_t           port_name;
374         wwn_t           node_name;
375         struct fc_plogi_clp_s  class1;          /* class 1 service parameters */
376         struct fc_plogi_clp_s  class2;          /* class 2 service parameters */
377         struct fc_plogi_clp_s  class3;          /* class 3 service parameters */
378         struct fc_plogi_clp_s  class4;          /* class 4 service parameters */
379         u8         vvl[16];     /* vendor version level */
380 };
381
382 /*
383  * LOGO els command payload
384  */
385 struct fc_logo_s{
386         struct fc_els_cmd_s    els_cmd; /* ELS command code */
387         u32        res1:8;
388         u32        nport_id:24; /* N_Port identifier of source */
389         wwn_t           orig_port_name; /* Port name of the LOGO originator */
390 };
391
392 /*
393  * ADISC els command payload
394  */
395 struct fc_adisc_s {
396         struct fc_els_cmd_s    els_cmd; /* ELS command code */
397         u32        res1:8;
398         u32        orig_HA:24;  /* originator hard address */
399         wwn_t           orig_port_name; /* originator port name */
400         wwn_t           orig_node_name; /* originator node name */
401         u32        res2:8;
402         u32        nport_id:24; /* originator NPortID */
403 };
404
405 /*
406  * Exchange status block
407  */
408 struct fc_exch_status_blk_s{
409         u32        oxid:16;
410         u32        rxid:16;
411         u32        res1:8;
412         u32        orig_np:24;  /* originator NPortID */
413         u32        res2:8;
414         u32        resp_np:24;  /* responder NPortID */
415         u32        es_bits;
416         u32        res3;
417         /*
418          * un modified section of the fields
419          */
420 };
421
422 /*
423  * RES els command payload
424  */
425 struct fc_res_s {
426         struct fc_els_cmd_s    els_cmd; /* ELS command code */
427         u32        res1:8;
428         u32        nport_id:24; /* N_Port identifier of source */
429         u32        oxid:16;
430         u32        rxid:16;
431         u8         assoc_hdr[32];
432 };
433
434 /*
435  * RES els accept payload
436  */
437 struct fc_res_acc_s{
438         struct fc_els_cmd_s els_cmd;    /* ELS command code */
439         struct fc_exch_status_blk_s fc_exch_blk; /* Exchange status block */
440 };
441
442 /*
443  * REC els command payload
444  */
445 struct fc_rec_s {
446         struct fc_els_cmd_s    els_cmd; /* ELS command code */
447         u32        res1:8;
448         u32        nport_id:24; /* N_Port identifier of source */
449         u32        oxid:16;
450         u32        rxid:16;
451 };
452
453 #define FC_REC_ESB_OWN_RSP      0x80000000      /* responder owns */
454 #define FC_REC_ESB_SI           0x40000000      /* SI is owned  */
455 #define FC_REC_ESB_COMP         0x20000000      /* exchange is complete */
456 #define FC_REC_ESB_ENDCOND_ABN  0x10000000      /* abnormal ending      */
457 #define FC_REC_ESB_RQACT        0x04000000      /* recovery qual active */
458 #define FC_REC_ESB_ERRP_MSK     0x03000000
459 #define FC_REC_ESB_OXID_INV     0x00800000      /* invalid OXID         */
460 #define FC_REC_ESB_RXID_INV     0x00400000      /* invalid RXID         */
461 #define FC_REC_ESB_PRIO_INUSE   0x00200000
462
463 /*
464  * REC els accept payload
465  */
466 struct fc_rec_acc_s {
467         struct fc_els_cmd_s    els_cmd; /* ELS command code */
468         u32        oxid:16;
469         u32        rxid:16;
470         u32        res1:8;
471         u32        orig_id:24;  /* N_Port id of exchange originator */
472         u32        res2:8;
473         u32        resp_id:24;  /* N_Port id of exchange responder */
474         u32        count;               /* data transfer count */
475         u32        e_stat;              /* exchange status */
476 };
477
478 /*
479  * RSI els payload
480  */
481 struct fc_rsi_s {
482         struct fc_els_cmd_s    els_cmd;
483         u32        res1:8;
484         u32        orig_sid:24;
485         u32        oxid:16;
486         u32        rxid:16;
487 };
488
489 /*
490  * structure for PRLI paramater pages, both request & response
491  * see FC-PH-X table 113 & 115 for explanation also FCP table 8
492  */
493 struct fc_prli_params_s{
494         u32        reserved:16;
495 #ifdef __BIGENDIAN
496         u32        reserved1:5;
497         u32        rec_support:1;
498         u32        task_retry_id:1;
499         u32        retry:1;
500
501         u32        confirm:1;
502         u32        doverlay:1;
503         u32        initiator:1;
504         u32        target:1;
505         u32        cdmix:1;
506         u32        drmix:1;
507         u32        rxrdisab:1;
508         u32        wxrdisab:1;
509 #else
510         u32        retry:1;
511         u32        task_retry_id:1;
512         u32        rec_support:1;
513         u32        reserved1:5;
514
515         u32        wxrdisab:1;
516         u32        rxrdisab:1;
517         u32        drmix:1;
518         u32        cdmix:1;
519         u32        target:1;
520         u32        initiator:1;
521         u32        doverlay:1;
522         u32        confirm:1;
523 #endif
524 };
525
526 /*
527  * valid values for rspcode in PRLI ACC payload
528  */
529 enum {
530         FC_PRLI_ACC_XQTD = 0x1,         /* request executed */
531         FC_PRLI_ACC_PREDEF_IMG = 0x5,   /* predefined image - no prli needed */
532 };
533
534 struct fc_prli_params_page_s{
535         u32        type:8;
536         u32        codext:8;
537 #ifdef __BIGENDIAN
538         u32        origprocasv:1;
539         u32        rsppav:1;
540         u32        imagepair:1;
541         u32        reserved1:1;
542         u32        rspcode:4;
543 #else
544         u32        rspcode:4;
545         u32        reserved1:1;
546         u32        imagepair:1;
547         u32        rsppav:1;
548         u32        origprocasv:1;
549 #endif
550         u32        reserved2:8;
551
552         u32        origprocas;
553         u32        rspprocas;
554         struct fc_prli_params_s  servparams;
555 };
556
557 /*
558  * PRLI request and accept payload, FC-PH-X tables 112 & 114
559  */
560 struct fc_prli_s{
561         u32        command:8;
562         u32        pglen:8;
563         u32        pagebytes:16;
564         struct fc_prli_params_page_s parampage;
565 };
566
567 /*
568  * PRLO logout params page
569  */
570 struct fc_prlo_params_page_s{
571         u32        type:8;
572         u32        type_ext:8;
573 #ifdef __BIGENDIAN
574         u32        opa_valid:1; /* originator process associator
575                                          * valid
576                                          */
577         u32        rpa_valid:1; /* responder process associator valid */
578         u32        res1:14;
579 #else
580         u32        res1:14;
581         u32        rpa_valid:1; /* responder process associator valid */
582         u32        opa_valid:1; /* originator process associator
583                                          * valid
584                                          */
585 #endif
586         u32        orig_process_assc;
587         u32        resp_process_assc;
588
589         u32        res2;
590 };
591
592 /*
593  * PRLO els command payload
594  */
595 struct fc_prlo_s{
596         u32             command:8;
597         u32             page_len:8;
598         u32             payload_len:16;
599         struct fc_prlo_params_page_s    prlo_params[1];
600 };
601
602 /*
603  * PRLO Logout response parameter page
604  */
605 struct fc_prlo_acc_params_page_s{
606         u32        type:8;
607         u32        type_ext:8;
608
609 #ifdef __BIGENDIAN
610         u32        opa_valid:1; /* originator process associator
611                                          * valid
612                                          */
613         u32        rpa_valid:1; /* responder process associator valid */
614         u32        res1:14;
615 #else
616         u32        res1:14;
617         u32        rpa_valid:1; /* responder process associator valid */
618         u32        opa_valid:1; /* originator process associator
619                                          * valid
620                                          */
621 #endif
622         u32        orig_process_assc;
623         u32        resp_process_assc;
624
625         u32        fc4type_csp;
626 };
627
628 /*
629  * PRLO els command ACC payload
630  */
631 struct fc_prlo_acc_s{
632         u32        command:8;
633         u32        page_len:8;
634         u32        payload_len:16;
635         struct fc_prlo_acc_params_page_s prlo_acc_params[1];
636 };
637
638 /*
639  * SCR els command payload
640  */
641 enum {
642         FC_SCR_REG_FUNC_FABRIC_DETECTED = 0x01,
643         FC_SCR_REG_FUNC_N_PORT_DETECTED = 0x02,
644         FC_SCR_REG_FUNC_FULL = 0x03,
645         FC_SCR_REG_FUNC_CLEAR_REG = 0xFF,
646 };
647
648 /* SCR VU registrations */
649 enum {
650         FC_VU_SCR_REG_FUNC_FABRIC_NAME_CHANGE = 0x01
651 };
652
653 struct fc_scr_s{
654         u32 command:8;
655         u32 res:24;
656         u32 vu_reg_func:8; /* Vendor Unique Registrations */
657         u32 res1:16;
658         u32 reg_func:8;
659 };
660
661 /*
662  * Information category for Basic link data
663  */
664 enum {
665         FC_CAT_NOP      = 0x0,
666         FC_CAT_ABTS     = 0x1,
667         FC_CAT_RMC      = 0x2,
668         FC_CAT_BA_ACC   = 0x4,
669         FC_CAT_BA_RJT   = 0x5,
670         FC_CAT_PRMT     = 0x6,
671 };
672
673 /*
674  * LS_RJT els reply payload
675  */
676 struct fc_ls_rjt_s {
677         struct fc_els_cmd_s    els_cmd;         /* ELS command code */
678         u32        res1:8;
679         u32        reason_code:8;               /* Reason code for reject */
680         u32        reason_code_expl:8;  /* Reason code explanation */
681         u32        vendor_unique:8;     /* Vendor specific */
682 };
683
684 /*
685  * LS_RJT reason codes
686  */
687 enum {
688         FC_LS_RJT_RSN_INV_CMD_CODE      = 0x01,
689         FC_LS_RJT_RSN_LOGICAL_ERROR     = 0x03,
690         FC_LS_RJT_RSN_LOGICAL_BUSY      = 0x05,
691         FC_LS_RJT_RSN_PROTOCOL_ERROR    = 0x07,
692         FC_LS_RJT_RSN_UNABLE_TO_PERF_CMD = 0x09,
693         FC_LS_RJT_RSN_CMD_NOT_SUPP      = 0x0B,
694 };
695
696 /*
697  * LS_RJT reason code explanation
698  */
699 enum {
700         FC_LS_RJT_EXP_NO_ADDL_INFO              = 0x00,
701         FC_LS_RJT_EXP_SPARMS_ERR_OPTIONS        = 0x01,
702         FC_LS_RJT_EXP_SPARMS_ERR_INI_CTL        = 0x03,
703         FC_LS_RJT_EXP_SPARMS_ERR_REC_CTL        = 0x05,
704         FC_LS_RJT_EXP_SPARMS_ERR_RXSZ           = 0x07,
705         FC_LS_RJT_EXP_SPARMS_ERR_CONSEQ         = 0x09,
706         FC_LS_RJT_EXP_SPARMS_ERR_CREDIT         = 0x0B,
707         FC_LS_RJT_EXP_INV_PORT_NAME             = 0x0D,
708         FC_LS_RJT_EXP_INV_NODE_FABRIC_NAME      = 0x0E,
709         FC_LS_RJT_EXP_INV_CSP                   = 0x0F,
710         FC_LS_RJT_EXP_INV_ASSOC_HDR             = 0x11,
711         FC_LS_RJT_EXP_ASSOC_HDR_REQD            = 0x13,
712         FC_LS_RJT_EXP_INV_ORIG_S_ID             = 0x15,
713         FC_LS_RJT_EXP_INV_OXID_RXID_COMB        = 0x17,
714         FC_LS_RJT_EXP_CMD_ALREADY_IN_PROG       = 0x19,
715         FC_LS_RJT_EXP_LOGIN_REQUIRED            = 0x1E,
716         FC_LS_RJT_EXP_INVALID_NPORT_ID          = 0x1F,
717         FC_LS_RJT_EXP_INSUFF_RES                = 0x29,
718         FC_LS_RJT_EXP_CMD_NOT_SUPP              = 0x2C,
719         FC_LS_RJT_EXP_INV_PAYLOAD_LEN           = 0x2D,
720 };
721
722 /*
723  * RRQ els command payload
724  */
725 struct fc_rrq_s{
726         struct fc_els_cmd_s    els_cmd; /* ELS command code */
727         u32        res1:8;
728         u32        s_id:24;     /* exchange originator S_ID */
729
730         u32        ox_id:16;    /* originator exchange ID */
731         u32        rx_id:16;    /* responder exchange ID */
732
733         u32        res2[8];     /* optional association header */
734 };
735
736 /*
737  * ABTS BA_ACC reply payload
738  */
739 struct fc_ba_acc_s{
740         u32        seq_id_valid:8;      /* set to 0x00 for Abort Exchange */
741         u32        seq_id:8;    /* invalid for Abort Exchange */
742         u32        res2:16;
743         u32        ox_id:16;    /* OX_ID from ABTS frame */
744         u32        rx_id:16;    /* RX_ID from ABTS frame */
745         u32        low_seq_cnt:16;      /* set to 0x0000 for Abort Exchange */
746         u32        high_seq_cnt:16;/* set to 0xFFFF for Abort Exchange */
747 };
748
749 /*
750  * ABTS BA_RJT reject payload
751  */
752 struct fc_ba_rjt_s{
753         u32        res1:8;              /* Reserved */
754         u32        reason_code:8;       /* reason code for reject */
755         u32        reason_expl:8;       /* reason code explanation */
756         u32        vendor_unique:8;/* vendor unique reason code,set to 0 */
757 };
758
759 /*
760  * TPRLO logout parameter page
761  */
762 struct fc_tprlo_params_page_s{
763         u32        type:8;
764         u32        type_ext:8;
765
766 #ifdef __BIGENDIAN
767         u32        opa_valid:1;
768         u32        rpa_valid:1;
769         u32        tpo_nport_valid:1;
770         u32        global_process_logout:1;
771         u32        res1:12;
772 #else
773         u32        res1:12;
774         u32        global_process_logout:1;
775         u32        tpo_nport_valid:1;
776         u32        rpa_valid:1;
777         u32        opa_valid:1;
778 #endif
779
780         u32        orig_process_assc;
781         u32        resp_process_assc;
782
783         u32        res2:8;
784         u32        tpo_nport_id;
785 };
786
787 /*
788  * TPRLO ELS command payload
789  */
790 struct fc_tprlo_s{
791         u32        command:8;
792         u32        page_len:8;
793         u32        payload_len:16;
794
795         struct fc_tprlo_params_page_s tprlo_params[1];
796 };
797
798 enum fc_tprlo_type{
799         FC_GLOBAL_LOGO = 1,
800         FC_TPR_LOGO
801 };
802
803 /*
804  * TPRLO els command ACC payload
805  */
806 struct fc_tprlo_acc_s{
807         u32     command:8;
808         u32     page_len:8;
809         u32     payload_len:16;
810         struct fc_prlo_acc_params_page_s tprlo_acc_params[1];
811 };
812
813 /*
814  * RSCN els command req payload
815  */
816 #define FC_RSCN_PGLEN   0x4
817
818 enum fc_rscn_format{
819         FC_RSCN_FORMAT_PORTID   = 0x0,
820         FC_RSCN_FORMAT_AREA     = 0x1,
821         FC_RSCN_FORMAT_DOMAIN   = 0x2,
822         FC_RSCN_FORMAT_FABRIC   = 0x3,
823 };
824
825 struct fc_rscn_event_s{
826         u32        format:2;
827         u32        qualifier:4;
828         u32        resvd:2;
829         u32        portid:24;
830 };
831
832 struct fc_rscn_pl_s{
833         u8         command;
834         u8         pagelen;
835         u16        payldlen;
836         struct fc_rscn_event_s event[1];
837 };
838
839 /*
840  * ECHO els command req payload
841  */
842 struct fc_echo_s {
843         struct fc_els_cmd_s    els_cmd;
844 };
845
846 /*
847  * RNID els command
848  */
849
850 #define RNID_NODEID_DATA_FORMAT_COMMON                   0x00
851 #define RNID_NODEID_DATA_FORMAT_FCP3                     0x08
852 #define RNID_NODEID_DATA_FORMAT_DISCOVERY               0xDF
853
854 #define RNID_ASSOCIATED_TYPE_UNKNOWN                    0x00000001
855 #define RNID_ASSOCIATED_TYPE_OTHER                      0x00000002
856 #define RNID_ASSOCIATED_TYPE_HUB                        0x00000003
857 #define RNID_ASSOCIATED_TYPE_SWITCH                     0x00000004
858 #define RNID_ASSOCIATED_TYPE_GATEWAY                    0x00000005
859 #define RNID_ASSOCIATED_TYPE_STORAGE_DEVICE             0x00000009
860 #define RNID_ASSOCIATED_TYPE_HOST                       0x0000000A
861 #define RNID_ASSOCIATED_TYPE_STORAGE_SUBSYSTEM          0x0000000B
862 #define RNID_ASSOCIATED_TYPE_STORAGE_ACCESS_DEVICE      0x0000000E
863 #define RNID_ASSOCIATED_TYPE_NAS_SERVER                 0x00000011
864 #define RNID_ASSOCIATED_TYPE_BRIDGE                     0x00000002
865 #define RNID_ASSOCIATED_TYPE_VIRTUALIZATION_DEVICE      0x00000003
866 #define RNID_ASSOCIATED_TYPE_MULTI_FUNCTION_DEVICE      0x000000FF
867
868 /*
869  * RNID els command payload
870  */
871 struct fc_rnid_cmd_s{
872         struct fc_els_cmd_s    els_cmd;
873         u32        node_id_data_format:8;
874         u32        reserved:24;
875 };
876
877 /*
878  * RNID els response payload
879  */
880
881 struct fc_rnid_common_id_data_s{
882         wwn_t           port_name;
883         wwn_t           node_name;
884 };
885
886 struct fc_rnid_general_topology_data_s{
887         u32        vendor_unique[4];
888         u32        asso_type;
889         u32        phy_port_num;
890         u32        num_attached_nodes;
891         u32        node_mgmt:8;
892         u32        ip_version:8;
893         u32        udp_tcp_port_num:16;
894         u32        ip_address[4];
895         u32        reserved:16;
896         u32        vendor_specific:16;
897 };
898
899 struct fc_rnid_acc_s{
900         struct fc_els_cmd_s    els_cmd;
901         u32        node_id_data_format:8;
902         u32        common_id_data_length:8;
903         u32        reserved:8;
904         u32        specific_id_data_length:8;
905         struct fc_rnid_common_id_data_s common_id_data;
906         struct fc_rnid_general_topology_data_s gen_topology_data;
907 };
908
909 #define RNID_ASSOCIATED_TYPE_UNKNOWN                    0x00000001
910 #define RNID_ASSOCIATED_TYPE_OTHER                      0x00000002
911 #define RNID_ASSOCIATED_TYPE_HUB                        0x00000003
912 #define RNID_ASSOCIATED_TYPE_SWITCH                     0x00000004
913 #define RNID_ASSOCIATED_TYPE_GATEWAY                    0x00000005
914 #define RNID_ASSOCIATED_TYPE_STORAGE_DEVICE             0x00000009
915 #define RNID_ASSOCIATED_TYPE_HOST                       0x0000000A
916 #define RNID_ASSOCIATED_TYPE_STORAGE_SUBSYSTEM          0x0000000B
917 #define RNID_ASSOCIATED_TYPE_STORAGE_ACCESS_DEVICE      0x0000000E
918 #define RNID_ASSOCIATED_TYPE_NAS_SERVER                 0x00000011
919 #define RNID_ASSOCIATED_TYPE_BRIDGE                     0x00000002
920 #define RNID_ASSOCIATED_TYPE_VIRTUALIZATION_DEVICE      0x00000003
921 #define RNID_ASSOCIATED_TYPE_MULTI_FUNCTION_DEVICE      0x000000FF
922
923 enum fc_rpsc_speed_cap{
924         RPSC_SPEED_CAP_1G = 0x8000,
925         RPSC_SPEED_CAP_2G = 0x4000,
926         RPSC_SPEED_CAP_4G = 0x2000,
927         RPSC_SPEED_CAP_10G = 0x1000,
928         RPSC_SPEED_CAP_8G = 0x0800,
929         RPSC_SPEED_CAP_16G = 0x0400,
930
931         RPSC_SPEED_CAP_UNKNOWN = 0x0001,
932 };
933
934 enum fc_rpsc_op_speed_s{
935         RPSC_OP_SPEED_1G = 0x8000,
936         RPSC_OP_SPEED_2G = 0x4000,
937         RPSC_OP_SPEED_4G = 0x2000,
938         RPSC_OP_SPEED_10G = 0x1000,
939         RPSC_OP_SPEED_8G = 0x0800,
940         RPSC_OP_SPEED_16G = 0x0400,
941
942         RPSC_OP_SPEED_NOT_EST = 0x0001, /*! speed not established */
943 };
944
945 struct fc_rpsc_speed_info_s{
946         u16        port_speed_cap;      /*! see fc_rpsc_speed_cap_t */
947         u16        port_op_speed;       /*! see fc_rpsc_op_speed_t */
948 };
949
950 enum link_e2e_beacon_subcmd{
951         LINK_E2E_BEACON_ON = 1,
952         LINK_E2E_BEACON_OFF = 2
953 };
954
955 enum beacon_type{
956         BEACON_TYPE_NORMAL      = 1,    /*! Normal Beaconing. Green */
957         BEACON_TYPE_WARN        = 2,    /*! Warning Beaconing. Yellow/Amber */
958         BEACON_TYPE_CRITICAL    = 3     /*! Critical Beaconing. Red */
959 };
960
961 struct link_e2e_beacon_param_s {
962         u8         beacon_type; /* Beacon Type. See beacon_type_t */
963         u8         beacon_frequency;
964                                         /* Beacon frequency. Number of blinks
965                                          * per 10 seconds
966                                          */
967         u16        beacon_duration;/* Beacon duration (in Seconds). The
968                                          * command operation should be
969                                          * terminated at the end of this
970                                          * timeout value.
971                                          *
972                                          * Ignored if diag_sub_cmd is
973                                          * LINK_E2E_BEACON_OFF.
974                                          *
975                                          * If 0, beaconing will continue till a
976                                          * BEACON OFF request is received
977                                          */
978 };
979
980 /*
981  * Link E2E beacon request/good response format. For LS_RJTs use fc_ls_rjt_t
982  */
983 struct link_e2e_beacon_req_s{
984         u32        ls_code;     /*! FC_ELS_E2E_LBEACON in requests *
985                                          *or FC_ELS_ACC in good replies */
986         u32        ls_sub_cmd;  /*! See link_e2e_beacon_subcmd_t */
987         struct link_e2e_beacon_param_s beacon_parm;
988 };
989
990 /**
991  * If RPSC request is sent to the Domain Controller, the request is for
992  * all the ports within that domain (TODO - I don't think FOS implements
993  * this...).
994  */
995 struct fc_rpsc_cmd_s{
996         struct fc_els_cmd_s    els_cmd;
997 };
998
999 /*
1000  * RPSC Acc
1001  */
1002 struct fc_rpsc_acc_s{
1003         u32        command:8;
1004         u32        rsvd:8;
1005         u32        num_entries:16;
1006
1007         struct fc_rpsc_speed_info_s speed_info[1];
1008 };
1009
1010 /**
1011  * If RPSC2 request is sent to the Domain Controller,
1012  */
1013 #define FC_BRCD_TOKEN    0x42524344
1014
1015 struct fc_rpsc2_cmd_s{
1016         struct fc_els_cmd_s    els_cmd;
1017         u32             token;
1018         u16             resvd;
1019         u16             num_pids;       /* Number of pids in the request */
1020         struct  {
1021                 u32     rsvd1:8;
1022                 u32     pid:24; /* port identifier */
1023         } pid_list[1];
1024 };
1025
1026 enum fc_rpsc2_port_type{
1027         RPSC2_PORT_TYPE_UNKNOWN = 0,
1028         RPSC2_PORT_TYPE_NPORT   = 1,
1029         RPSC2_PORT_TYPE_NLPORT  = 2,
1030         RPSC2_PORT_TYPE_NPIV_PORT  = 0x5f,
1031         RPSC2_PORT_TYPE_NPORT_TRUNK  = 0x6f,
1032 };
1033
1034 /*
1035  * RPSC2 portInfo entry structure
1036  */
1037 struct fc_rpsc2_port_info_s{
1038     u32    pid;        /* PID */
1039     u16    resvd1;
1040     u16    index;      /* port number / index */
1041     u8     resvd2;
1042     u8          type;        /* port type N/NL/... */
1043     u16    speed;      /* port Operating Speed */
1044 };
1045
1046 /*
1047  * RPSC2 Accept payload
1048  */
1049 struct fc_rpsc2_acc_s{
1050         u8        els_cmd;
1051         u8        resvd;
1052         u16       num_pids;  /* Number of pids in the request */
1053         struct fc_rpsc2_port_info_s  port_info[1];    /* port information */
1054 };
1055
1056 /**
1057  * bit fields so that multiple classes can be specified
1058  */
1059 enum fc_cos{
1060         FC_CLASS_2      = 0x04,
1061         FC_CLASS_3      = 0x08,
1062         FC_CLASS_2_3    = 0x0C,
1063 };
1064
1065 /*
1066  * symbolic name
1067  */
1068 struct fc_symname_s{
1069         u8         symname[FC_SYMNAME_MAX];
1070 };
1071
1072 struct fc_alpabm_s{
1073         u8         alpa_bm[FC_ALPA_MAX / 8];
1074 };
1075
1076 /*
1077  * protocol default timeout values
1078  */
1079 #define FC_ED_TOV               2
1080 #define FC_REC_TOV              (FC_ED_TOV + 1)
1081 #define FC_RA_TOV               10
1082 #define FC_ELS_TOV              (2 * FC_RA_TOV)
1083 #define FC_FCCT_TOV             (3 * FC_RA_TOV)
1084
1085 /*
1086  * virtual fabric related defines
1087  */
1088 #define FC_VF_ID_NULL    0      /*  must not be used as VF_ID */
1089 #define FC_VF_ID_MIN     1
1090 #define FC_VF_ID_MAX     0xEFF
1091 #define FC_VF_ID_CTL     0xFEF  /*  control VF_ID */
1092
1093 /**
1094  * Virtual Fabric Tagging header format
1095  * @caution This is defined only in BIG ENDIAN format.
1096  */
1097 struct fc_vft_s{
1098         u32        r_ctl:8;
1099         u32        ver:2;
1100         u32        type:4;
1101         u32        res_a:2;
1102         u32        priority:3;
1103         u32        vf_id:12;
1104         u32        res_b:1;
1105         u32        hopct:8;
1106         u32        res_c:24;
1107 };
1108
1109 #pragma pack()
1110
1111 #endif