/*1* Copyright 2008 Cisco Systems, Inc. All rights reserved.2*3* This program is free software; you may redistribute it and/or modify4* it under the terms of the GNU General Public License as published by5* the Free Software Foundation; version 2 of the License.6*7* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,8* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF9* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND10* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS11* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN12* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN13* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE14* SOFTWARE.15*/16#ifndef _FC_FIP_H_17#define _FC_FIP_H_1819#include <scsi/fc/fc_ns.h>2021/*22* This version is based on:23* http://www.t11.org/ftp/t11/pub/fc/bb-5/08-543v1.pdf24* and T11 FC-BB-6 10-019v4.pdf (June 2010 VN2VN proposal)25*/2627#define FIP_DEF_PRI 128 /* default selection priority */28#define FIP_DEF_FC_MAP 0x0efc00 /* default FCoE MAP (MAC OUI) value */29#define FIP_DEF_FKA 8000 /* default FCF keep-alive/advert period (mS) */30#define FIP_VN_KA_PERIOD 90000 /* required VN_port keep-alive period (mS) */31#define FIP_FCF_FUZZ 100 /* random time added by FCF (mS) */3233/*34* VN2VN proposed-standard values.35*/36#define FIP_VN_FC_MAP 0x0efd00 /* MAC OUI for VN2VN use */37#define FIP_VN_PROBE_WAIT 100 /* interval between VN2VN probes (ms) */38#define FIP_VN_ANN_WAIT 400 /* interval between VN2VN announcements (ms) */39#define FIP_VN_RLIM_INT 10000 /* interval between probes when rate limited */40#define FIP_VN_RLIM_COUNT 10 /* number of probes before rate limiting */41#define FIP_VN_BEACON_INT 8000 /* interval between VN2VN beacons */42#define FIP_VN_BEACON_FUZZ 100 /* random time to add to beacon period (ms) */4344/*45* Multicast MAC addresses. T11-adopted.46*/47#define FIP_ALL_FCOE_MACS ((__u8[6]) { 1, 0x10, 0x18, 1, 0, 0 })48#define FIP_ALL_ENODE_MACS ((__u8[6]) { 1, 0x10, 0x18, 1, 0, 1 })49#define FIP_ALL_FCF_MACS ((__u8[6]) { 1, 0x10, 0x18, 1, 0, 2 })50#define FIP_ALL_VN2VN_MACS ((__u8[6]) { 1, 0x10, 0x18, 1, 0, 4 })51#define FIP_ALL_P2P_MACS ((__u8[6]) { 1, 0x10, 0x18, 1, 0, 5 })5253#define FIP_VER 1 /* version for fip_header */5455struct fip_header {56__u8 fip_ver; /* upper 4 bits are the version */57__u8 fip_resv1; /* reserved */58__be16 fip_op; /* operation code */59__u8 fip_resv2; /* reserved */60__u8 fip_subcode; /* lower 4 bits are sub-code */61__be16 fip_dl_len; /* length of descriptors in words */62__be16 fip_flags; /* header flags */63} __attribute__((packed));6465#define FIP_VER_SHIFT 466#define FIP_VER_ENCAPS(v) ((v) << FIP_VER_SHIFT)67#define FIP_VER_DECAPS(v) ((v) >> FIP_VER_SHIFT)68#define FIP_BPW 4 /* bytes per word for lengths */6970/*71* fip_op.72*/73enum fip_opcode {74FIP_OP_DISC = 1, /* discovery, advertisement, etc. */75FIP_OP_LS = 2, /* Link Service request or reply */76FIP_OP_CTRL = 3, /* Keep Alive / Link Reset */77FIP_OP_VLAN = 4, /* VLAN discovery */78FIP_OP_VN2VN = 5, /* VN2VN operation */79FIP_OP_VENDOR_MIN = 0xfff8, /* min vendor-specific opcode */80FIP_OP_VENDOR_MAX = 0xfffe, /* max vendor-specific opcode */81};8283/*84* Subcodes for FIP_OP_DISC.85*/86enum fip_disc_subcode {87FIP_SC_SOL = 1, /* solicitation */88FIP_SC_ADV = 2, /* advertisement */89};9091/*92* Subcodes for FIP_OP_LS.93*/94enum fip_trans_subcode {95FIP_SC_REQ = 1, /* request */96FIP_SC_REP = 2, /* reply */97};9899/*100* Subcodes for FIP_OP_RESET.101*/102enum fip_reset_subcode {103FIP_SC_KEEP_ALIVE = 1, /* keep-alive from VN_Port */104FIP_SC_CLR_VLINK = 2, /* clear virtual link from VF_Port */105};106107/*108* Subcodes for FIP_OP_VLAN.109*/110enum fip_vlan_subcode {111FIP_SC_VL_REQ = 1, /* request */112FIP_SC_VL_REP = 2, /* reply */113};114115/*116* Subcodes for FIP_OP_VN2VN.117*/118enum fip_vn2vn_subcode {119FIP_SC_VN_PROBE_REQ = 1, /* probe request */120FIP_SC_VN_PROBE_REP = 2, /* probe reply */121FIP_SC_VN_CLAIM_NOTIFY = 3, /* claim notification */122FIP_SC_VN_CLAIM_REP = 4, /* claim response */123FIP_SC_VN_BEACON = 5, /* beacon */124};125126/*127* flags in header fip_flags.128*/129enum fip_flag {130FIP_FL_FPMA = 0x8000, /* supports FPMA fabric-provided MACs */131FIP_FL_SPMA = 0x4000, /* supports SPMA server-provided MACs */132FIP_FL_REC_OR_P2P = 0x0008, /* configured addr or point-to-point */133FIP_FL_AVAIL = 0x0004, /* available for FLOGI/ELP */134FIP_FL_SOL = 0x0002, /* this is a solicited message */135FIP_FL_FPORT = 0x0001, /* sent from an F port */136};137138/*139* Common descriptor header format.140*/141struct fip_desc {142__u8 fip_dtype; /* type - see below */143__u8 fip_dlen; /* length - in 32-bit words */144};145146enum fip_desc_type {147FIP_DT_PRI = 1, /* priority for forwarder selection */148FIP_DT_MAC = 2, /* MAC address */149FIP_DT_MAP_OUI = 3, /* FC-MAP OUI */150FIP_DT_NAME = 4, /* switch name or node name */151FIP_DT_FAB = 5, /* fabric descriptor */152FIP_DT_FCOE_SIZE = 6, /* max FCoE frame size */153FIP_DT_FLOGI = 7, /* FLOGI request or response */154FIP_DT_FDISC = 8, /* FDISC request or response */155FIP_DT_LOGO = 9, /* LOGO request or response */156FIP_DT_ELP = 10, /* ELP request or response */157FIP_DT_VN_ID = 11, /* VN_Node Identifier */158FIP_DT_FKA = 12, /* advertisement keep-alive period */159FIP_DT_VENDOR = 13, /* vendor ID */160FIP_DT_VLAN = 14, /* vlan number */161FIP_DT_FC4F = 15, /* FC-4 features */162FIP_DT_LIMIT, /* max defined desc_type + 1 */163FIP_DT_VENDOR_BASE = 128, /* first vendor-specific desc_type */164};165166/*167* FIP_DT_PRI - priority descriptor.168*/169struct fip_pri_desc {170struct fip_desc fd_desc;171__u8 fd_resvd;172__u8 fd_pri; /* FCF priority: higher is better */173} __attribute__((packed));174175/*176* FIP_DT_MAC - MAC address descriptor.177*/178struct fip_mac_desc {179struct fip_desc fd_desc;180__u8 fd_mac[ETH_ALEN];181} __attribute__((packed));182183/*184* FIP_DT_MAP - descriptor.185*/186struct fip_map_desc {187struct fip_desc fd_desc;188__u8 fd_resvd[3];189__u8 fd_map[3];190} __attribute__((packed));191192/*193* FIP_DT_NAME descriptor.194*/195struct fip_wwn_desc {196struct fip_desc fd_desc;197__u8 fd_resvd[2];198__be64 fd_wwn; /* 64-bit WWN, unaligned */199} __attribute__((packed));200201/*202* FIP_DT_FAB descriptor.203*/204struct fip_fab_desc {205struct fip_desc fd_desc;206__be16 fd_vfid; /* virtual fabric ID */207__u8 fd_resvd;208__u8 fd_map[3]; /* FC-MAP value */209__be64 fd_wwn; /* fabric name, unaligned */210} __attribute__((packed));211212/*213* FIP_DT_FCOE_SIZE descriptor.214*/215struct fip_size_desc {216struct fip_desc fd_desc;217__be16 fd_size;218} __attribute__((packed));219220/*221* Descriptor that encapsulates an ELS or ILS frame.222* The encapsulated frame immediately follows this header, without223* SOF, EOF, or CRC.224*/225struct fip_encaps {226struct fip_desc fd_desc;227__u8 fd_resvd[2];228} __attribute__((packed));229230/*231* FIP_DT_VN_ID - VN_Node Identifier descriptor.232*/233struct fip_vn_desc {234struct fip_desc fd_desc;235__u8 fd_mac[ETH_ALEN];236__u8 fd_resvd;237__u8 fd_fc_id[3];238__be64 fd_wwpn; /* port name, unaligned */239} __attribute__((packed));240241/*242* FIP_DT_FKA - Advertisement keep-alive period.243*/244struct fip_fka_desc {245struct fip_desc fd_desc;246__u8 fd_resvd;247__u8 fd_flags; /* bit0 is fka disable flag */248__be32 fd_fka_period; /* adv./keep-alive period in mS */249} __attribute__((packed));250251/*252* flags for fip_fka_desc.fd_flags253*/254enum fip_fka_flags {255FIP_FKA_ADV_D = 0x01, /* no need for FKA from ENode */256};257258/* FIP_DT_FKA flags */259260/*261* FIP_DT_FC4F - FC-4 features.262*/263struct fip_fc4_feat {264struct fip_desc fd_desc;265__u8 fd_resvd[2];266struct fc_ns_fts fd_fts;267struct fc_ns_ff fd_ff;268} __attribute__((packed));269270/*271* FIP_DT_VENDOR descriptor.272*/273struct fip_vendor_desc {274struct fip_desc fd_desc;275__u8 fd_resvd[2];276__u8 fd_vendor_id[8];277} __attribute__((packed));278279#endif /* _FC_FIP_H_ */280281282