/* SPDX-License-Identifier: GPL-2.0 */1/*2* Copyright 2008 Cisco Systems, Inc. All rights reserved.3*/4#ifndef _FC_FIP_H_5#define _FC_FIP_H_67#include <scsi/fc/fc_ns.h>89/*10* This version is based on:11* http://www.t11.org/ftp/t11/pub/fc/bb-5/08-543v1.pdf12* and T11 FC-BB-6 13-091v5.pdf (December 2013 VN2VN proposal)13*/1415#define FIP_DEF_PRI 128 /* default selection priority */16#define FIP_DEF_FC_MAP 0x0efc00 /* default FCoE MAP (MAC OUI) value */17#define FIP_DEF_FKA 8000 /* default FCF keep-alive/advert period (mS) */18#define FIP_VN_KA_PERIOD 90000 /* required VN_port keep-alive period (mS) */19#define FIP_FCF_FUZZ 100 /* random time added by FCF (mS) */2021/*22* VN2VN proposed-standard values.23*/24#define FIP_VN_FC_MAP 0x0efd00 /* MAC OUI for VN2VN use */25#define FIP_VN_PROBE_WAIT 100 /* interval between VN2VN probes (ms) */26#define FIP_VN_ANN_WAIT 400 /* interval between VN2VN announcements (ms) */27#define FIP_VN_RLIM_INT 10000 /* interval between probes when rate limited */28#define FIP_VN_RLIM_COUNT 10 /* number of probes before rate limiting */29#define FIP_VN_BEACON_INT 8000 /* interval between VN2VN beacons */30#define FIP_VN_BEACON_FUZZ 100 /* random time to add to beacon period (ms) */3132/*33* Multicast MAC addresses. T11-adopted.34*/35#define FIP_ALL_FCOE_MACS ((__u8[6]) { 1, 0x10, 0x18, 1, 0, 0 })36#define FIP_ALL_ENODE_MACS ((__u8[6]) { 1, 0x10, 0x18, 1, 0, 1 })37#define FIP_ALL_FCF_MACS ((__u8[6]) { 1, 0x10, 0x18, 1, 0, 2 })38#define FIP_ALL_VN2VN_MACS ((__u8[6]) { 1, 0x10, 0x18, 1, 0, 4 })39#define FIP_ALL_P2P_MACS ((__u8[6]) { 1, 0x10, 0x18, 1, 0, 5 })4041#define FIP_VER 1 /* version for fip_header */4243struct fip_header {44__u8 fip_ver; /* upper 4 bits are the version */45__u8 fip_resv1; /* reserved */46__be16 fip_op; /* operation code */47__u8 fip_resv2; /* reserved */48__u8 fip_subcode; /* lower 4 bits are sub-code */49__be16 fip_dl_len; /* length of descriptors in words */50__be16 fip_flags; /* header flags */51} __attribute__((packed));5253#define FIP_VER_SHIFT 454#define FIP_VER_ENCAPS(v) ((v) << FIP_VER_SHIFT)55#define FIP_VER_DECAPS(v) ((v) >> FIP_VER_SHIFT)56#define FIP_BPW 4 /* bytes per word for lengths */5758/*59* fip_op.60*/61enum fip_opcode {62FIP_OP_DISC = 1, /* discovery, advertisement, etc. */63FIP_OP_LS = 2, /* Link Service request or reply */64FIP_OP_CTRL = 3, /* Keep Alive / Link Reset */65FIP_OP_VLAN = 4, /* VLAN discovery */66FIP_OP_VN2VN = 5, /* VN2VN operation */67FIP_OP_VENDOR_MIN = 0xfff8, /* min vendor-specific opcode */68FIP_OP_VENDOR_MAX = 0xfffe, /* max vendor-specific opcode */69};7071/*72* Subcodes for FIP_OP_DISC.73*/74enum fip_disc_subcode {75FIP_SC_SOL = 1, /* solicitation */76FIP_SC_ADV = 2, /* advertisement */77};7879/*80* Subcodes for FIP_OP_LS.81*/82enum fip_trans_subcode {83FIP_SC_REQ = 1, /* request */84FIP_SC_REP = 2, /* reply */85};8687/*88* Subcodes for FIP_OP_RESET.89*/90enum fip_reset_subcode {91FIP_SC_KEEP_ALIVE = 1, /* keep-alive from VN_Port */92FIP_SC_CLR_VLINK = 2, /* clear virtual link from VF_Port */93};9495/*96* Subcodes for FIP_OP_VLAN.97*/98enum fip_vlan_subcode {99FIP_SC_VL_REQ = 1, /* vlan request */100FIP_SC_VL_NOTE = 2, /* vlan notification */101FIP_SC_VL_VN2VN_NOTE = 3, /* VN2VN vlan notification */102};103104/*105* Subcodes for FIP_OP_VN2VN.106*/107enum fip_vn2vn_subcode {108FIP_SC_VN_PROBE_REQ = 1, /* probe request */109FIP_SC_VN_PROBE_REP = 2, /* probe reply */110FIP_SC_VN_CLAIM_NOTIFY = 3, /* claim notification */111FIP_SC_VN_CLAIM_REP = 4, /* claim response */112FIP_SC_VN_BEACON = 5, /* beacon */113};114115/*116* flags in header fip_flags.117*/118enum fip_flag {119FIP_FL_FPMA = 0x8000, /* supports FPMA fabric-provided MACs */120FIP_FL_SPMA = 0x4000, /* supports SPMA server-provided MACs */121FIP_FL_FCF = 0x0020, /* originated from a controlling FCF */122FIP_FL_FDF = 0x0010, /* originated from an FDF */123FIP_FL_REC_OR_P2P = 0x0008, /* configured addr or point-to-point */124FIP_FL_AVAIL = 0x0004, /* available for FLOGI/ELP */125FIP_FL_SOL = 0x0002, /* this is a solicited message */126FIP_FL_FPORT = 0x0001, /* sent from an F port */127};128129/*130* Common descriptor header format.131*/132struct fip_desc {133__u8 fip_dtype; /* type - see below */134__u8 fip_dlen; /* length - in 32-bit words */135};136137enum fip_desc_type {138FIP_DT_PRI = 1, /* priority for forwarder selection */139FIP_DT_MAC = 2, /* MAC address */140FIP_DT_MAP_OUI = 3, /* FC-MAP OUI */141FIP_DT_NAME = 4, /* switch name or node name */142FIP_DT_FAB = 5, /* fabric descriptor */143FIP_DT_FCOE_SIZE = 6, /* max FCoE frame size */144FIP_DT_FLOGI = 7, /* FLOGI request or response */145FIP_DT_FDISC = 8, /* FDISC request or response */146FIP_DT_LOGO = 9, /* LOGO request or response */147FIP_DT_ELP = 10, /* ELP request or response */148FIP_DT_VN_ID = 11, /* VN_Node Identifier */149FIP_DT_FKA = 12, /* advertisement keep-alive period */150FIP_DT_VENDOR = 13, /* vendor ID */151FIP_DT_VLAN = 14, /* vlan number */152FIP_DT_FC4F = 15, /* FC-4 features */153FIP_DT_LIMIT, /* max defined desc_type + 1 */154FIP_DT_NON_CRITICAL = 128, /* First non-critical descriptor */155FIP_DT_CLR_VLINKS = 128, /* Clear virtual links reason code */156FIP_DT_VENDOR_BASE = 241, /* first vendor-specific desc_type */157};158159/*160* FIP_DT_PRI - priority descriptor.161*/162struct fip_pri_desc {163struct fip_desc fd_desc;164__u8 fd_resvd;165__u8 fd_pri; /* FCF priority: higher is better */166} __attribute__((packed));167168/*169* FIP_DT_MAC - MAC address descriptor.170*/171struct fip_mac_desc {172struct fip_desc fd_desc;173__u8 fd_mac[ETH_ALEN];174} __attribute__((packed));175176/*177* FIP_DT_MAP - descriptor.178*/179struct fip_map_desc {180struct fip_desc fd_desc;181__u8 fd_resvd[3];182__u8 fd_map[3];183} __attribute__((packed));184185/*186* FIP_DT_NAME descriptor.187*/188struct fip_wwn_desc {189struct fip_desc fd_desc;190__u8 fd_resvd[2];191__be64 fd_wwn; /* 64-bit WWN, unaligned */192} __attribute__((packed));193194/*195* FIP_DT_FAB descriptor.196*/197struct fip_fab_desc {198struct fip_desc fd_desc;199__be16 fd_vfid; /* virtual fabric ID */200__u8 fd_resvd;201__u8 fd_map[3]; /* FC-MAP value */202__be64 fd_wwn; /* fabric name, unaligned */203} __attribute__((packed));204205/*206* FIP_DT_FCOE_SIZE descriptor.207*/208struct fip_size_desc {209struct fip_desc fd_desc;210__be16 fd_size;211} __attribute__((packed));212213/*214* Descriptor that encapsulates an ELS or ILS frame.215* The encapsulated frame immediately follows this header, without216* SOF, EOF, or CRC.217*/218struct fip_encaps {219struct fip_desc fd_desc;220__u8 fd_resvd[2];221} __attribute__((packed));222223/*224* FIP_DT_VN_ID - VN_Node Identifier descriptor.225*/226struct fip_vn_desc {227struct fip_desc fd_desc;228__u8 fd_mac[ETH_ALEN];229__u8 fd_resvd;230__u8 fd_fc_id[3];231__be64 fd_wwpn; /* port name, unaligned */232} __attribute__((packed));233234/*235* FIP_DT_FKA - Advertisement keep-alive period.236*/237struct fip_fka_desc {238struct fip_desc fd_desc;239__u8 fd_resvd;240__u8 fd_flags; /* bit0 is fka disable flag */241__be32 fd_fka_period; /* adv./keep-alive period in mS */242} __attribute__((packed));243244/*245* flags for fip_fka_desc.fd_flags246*/247enum fip_fka_flags {248FIP_FKA_ADV_D = 0x01, /* no need for FKA from ENode */249};250251/* FIP_DT_FKA flags */252253/*254* FIP_DT_VLAN descriptor255*/256struct fip_vlan_desc {257struct fip_desc fd_desc;258__be16 fd_vlan; /* Note: highest 4 bytes are unused */259} __attribute__((packed));260261/*262* FIP_DT_FC4F - FC-4 features.263*/264struct fip_fc4_feat {265struct fip_desc fd_desc;266__u8 fd_resvd[2];267struct fc_ns_fts fd_fts;268struct fc_ns_ff fd_ff;269} __attribute__((packed));270271/*272* FIP_DT_VENDOR descriptor.273*/274struct fip_vendor_desc {275struct fip_desc fd_desc;276__u8 fd_resvd[2];277__u8 fd_vendor_id[8];278} __attribute__((packed));279280#endif /* _FC_FIP_H_ */281282283