fc_fs.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. //
  2. // Copyright 2026 Aarav Ravindra Kharade
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  17. /*
  18. * Copyright(c) 2007 Intel Corporation. All rights reserved.
  19. *
  20. * Maintained at www.Open-FCoE.org
  21. */
  22. #ifndef _FC_FS_H_
  23. #define _FC_FS_H_
  24. #include <linux/types.h>
  25. /*
  26. * Fibre Channel Framing and Signalling definitions.
  27. * From T11 FC-FS-2 Rev 0.90 - 9 August 2005.
  28. */
  29. /*
  30. * Frame header
  31. */
  32. struct fc_frame_header {
  33. __u8 fh_r_ctl; /* routing control */
  34. __u8 fh_d_id[3]; /* Destination ID */
  35. __u8 fh_cs_ctl; /* class of service control / pri */
  36. __u8 fh_s_id[3]; /* Source ID */
  37. __u8 fh_type; /* see enum fc_fh_type below */
  38. __u8 fh_f_ctl[3]; /* frame control */
  39. __u8 fh_seq_id; /* sequence ID */
  40. __u8 fh_df_ctl; /* data field control */
  41. __be16 fh_seq_cnt; /* sequence count */
  42. __be16 fh_ox_id; /* originator exchange ID */
  43. __be16 fh_rx_id; /* responder exchange ID */
  44. __be32 fh_parm_offset; /* parameter or relative offset */
  45. };
  46. #define FC_FRAME_HEADER_LEN 24 /* expected length of structure */
  47. #define FC_MAX_PAYLOAD 2112U /* max payload length in bytes */
  48. #define FC_MIN_MAX_PAYLOAD 256U /* lower limit on max payload */
  49. #define FC_MAX_FRAME (FC_MAX_PAYLOAD + FC_FRAME_HEADER_LEN)
  50. #define FC_MIN_MAX_FRAME (FC_MIN_MAX_PAYLOAD + FC_FRAME_HEADER_LEN)
  51. /*
  52. * fh_r_ctl - Routing control definitions.
  53. */
  54. /*
  55. * FC-4 device_data.
  56. */
  57. enum fc_rctl {
  58. FC_RCTL_DD_UNCAT = 0x00, /* uncategorized information */
  59. FC_RCTL_DD_SOL_DATA = 0x01, /* solicited data */
  60. FC_RCTL_DD_UNSOL_CTL = 0x02, /* unsolicited control */
  61. FC_RCTL_DD_SOL_CTL = 0x03, /* solicited control or reply */
  62. FC_RCTL_DD_UNSOL_DATA = 0x04, /* unsolicited data */
  63. FC_RCTL_DD_DATA_DESC = 0x05, /* data descriptor */
  64. FC_RCTL_DD_UNSOL_CMD = 0x06, /* unsolicited command */
  65. FC_RCTL_DD_CMD_STATUS = 0x07, /* command status */
  66. #define FC_RCTL_ILS_REQ FC_RCTL_DD_UNSOL_CTL /* ILS request */
  67. #define FC_RCTL_ILS_REP FC_RCTL_DD_SOL_CTL /* ILS reply */
  68. /*
  69. * Extended Link_Data
  70. */
  71. FC_RCTL_ELS_REQ = 0x22, /* extended link services request */
  72. FC_RCTL_ELS_REP = 0x23, /* extended link services reply */
  73. FC_RCTL_ELS4_REQ = 0x32, /* FC-4 ELS request */
  74. FC_RCTL_ELS4_REP = 0x33, /* FC-4 ELS reply */
  75. /*
  76. * Optional Extended Headers
  77. */
  78. FC_RCTL_VFTH = 0x50, /* virtual fabric tagging header */
  79. FC_RCTL_IFRH = 0x51, /* inter-fabric routing header */
  80. FC_RCTL_ENCH = 0x52, /* encapsulation header */
  81. /*
  82. * Basic Link Services fh_r_ctl values.
  83. */
  84. FC_RCTL_BA_NOP = 0x80, /* basic link service NOP */
  85. FC_RCTL_BA_ABTS = 0x81, /* basic link service abort */
  86. FC_RCTL_BA_RMC = 0x82, /* remove connection */
  87. FC_RCTL_BA_ACC = 0x84, /* basic accept */
  88. FC_RCTL_BA_RJT = 0x85, /* basic reject */
  89. FC_RCTL_BA_PRMT = 0x86, /* dedicated connection preempted */
  90. /*
  91. * Link Control Information.
  92. */
  93. FC_RCTL_ACK_1 = 0xc0, /* acknowledge_1 */
  94. FC_RCTL_ACK_0 = 0xc1, /* acknowledge_0 */
  95. FC_RCTL_P_RJT = 0xc2, /* port reject */
  96. FC_RCTL_F_RJT = 0xc3, /* fabric reject */
  97. FC_RCTL_P_BSY = 0xc4, /* port busy */
  98. FC_RCTL_F_BSY = 0xc5, /* fabric busy to data frame */
  99. FC_RCTL_F_BSYL = 0xc6, /* fabric busy to link control frame */
  100. FC_RCTL_LCR = 0xc7, /* link credit reset */
  101. FC_RCTL_END = 0xc9, /* end */
  102. };
  103. /* incomplete list of definitions */
  104. /*
  105. * R_CTL names initializer.
  106. * Please keep this matching the above definitions.
  107. */
  108. #define FC_RCTL_NAMES_INIT { \
  109. [FC_RCTL_DD_UNCAT] = "uncat", \
  110. [FC_RCTL_DD_SOL_DATA] = "sol data", \
  111. [FC_RCTL_DD_UNSOL_CTL] = "unsol ctl", \
  112. [FC_RCTL_DD_SOL_CTL] = "sol ctl/reply", \
  113. [FC_RCTL_DD_UNSOL_DATA] = "unsol data", \
  114. [FC_RCTL_DD_DATA_DESC] = "data desc", \
  115. [FC_RCTL_DD_UNSOL_CMD] = "unsol cmd", \
  116. [FC_RCTL_DD_CMD_STATUS] = "cmd status", \
  117. [FC_RCTL_ELS_REQ] = "ELS req", \
  118. [FC_RCTL_ELS_REP] = "ELS rep", \
  119. [FC_RCTL_ELS4_REQ] = "FC-4 ELS req", \
  120. [FC_RCTL_ELS4_REP] = "FC-4 ELS rep", \
  121. [FC_RCTL_BA_NOP] = "BLS NOP", \
  122. [FC_RCTL_BA_ABTS] = "BLS abort", \
  123. [FC_RCTL_BA_RMC] = "BLS remove connection", \
  124. [FC_RCTL_BA_ACC] = "BLS accept", \
  125. [FC_RCTL_BA_RJT] = "BLS reject", \
  126. [FC_RCTL_BA_PRMT] = "BLS dedicated connection preempted", \
  127. [FC_RCTL_ACK_1] = "LC ACK_1", \
  128. [FC_RCTL_ACK_0] = "LC ACK_0", \
  129. [FC_RCTL_P_RJT] = "LC port reject", \
  130. [FC_RCTL_F_RJT] = "LC fabric reject", \
  131. [FC_RCTL_P_BSY] = "LC port busy", \
  132. [FC_RCTL_F_BSY] = "LC fabric busy to data frame", \
  133. [FC_RCTL_F_BSYL] = "LC fabric busy to link control frame",\
  134. [FC_RCTL_LCR] = "LC link credit reset", \
  135. [FC_RCTL_END] = "LC end", \
  136. }
  137. /*
  138. * Well-known fabric addresses.
  139. */
  140. enum fc_well_known_fid {
  141. FC_FID_NONE = 0x000000, /* No destination */
  142. FC_FID_BCAST = 0xffffff, /* broadcast */
  143. FC_FID_FLOGI = 0xfffffe, /* fabric login */
  144. FC_FID_FCTRL = 0xfffffd, /* fabric controller */
  145. FC_FID_DIR_SERV = 0xfffffc, /* directory server */
  146. FC_FID_TIME_SERV = 0xfffffb, /* time server */
  147. FC_FID_MGMT_SERV = 0xfffffa, /* management server */
  148. FC_FID_QOS = 0xfffff9, /* QoS Facilitator */
  149. FC_FID_ALIASES = 0xfffff8, /* alias server (FC-PH2) */
  150. FC_FID_SEC_KEY = 0xfffff7, /* Security key dist. server */
  151. FC_FID_CLOCK = 0xfffff6, /* clock synch server */
  152. FC_FID_MCAST_SERV = 0xfffff5, /* multicast server */
  153. };
  154. #define FC_FID_WELL_KNOWN_MAX 0xffffff /* highest well-known fabric ID */
  155. #define FC_FID_WELL_KNOWN_BASE 0xfffff5 /* start of well-known fabric ID */
  156. /*
  157. * Other well-known addresses, outside the above contiguous range.
  158. */
  159. #define FC_FID_DOM_MGR 0xfffc00 /* domain manager base */
  160. /*
  161. * Fabric ID bytes.
  162. */
  163. #define FC_FID_DOMAIN 0
  164. #define FC_FID_PORT 1
  165. #define FC_FID_LINK 2
  166. /*
  167. * fh_type codes
  168. */
  169. enum fc_fh_type {
  170. FC_TYPE_BLS = 0x00, /* basic link service */
  171. FC_TYPE_ELS = 0x01, /* extended link service */
  172. FC_TYPE_IP = 0x05, /* IP over FC, RFC 4338 */
  173. FC_TYPE_FCP = 0x08, /* SCSI FCP */
  174. FC_TYPE_CT = 0x20, /* Fibre Channel Services (FC-CT) */
  175. FC_TYPE_ILS = 0x22, /* internal link service */
  176. FC_TYPE_NVME = 0x28, /* FC-NVME */
  177. };
  178. /*
  179. * FC_TYPE names initializer.
  180. * Please keep this matching the above definitions.
  181. */
  182. #define FC_TYPE_NAMES_INIT { \
  183. [FC_TYPE_BLS] = "BLS", \
  184. [FC_TYPE_ELS] = "ELS", \
  185. [FC_TYPE_IP] = "IP", \
  186. [FC_TYPE_FCP] = "FCP", \
  187. [FC_TYPE_CT] = "CT", \
  188. [FC_TYPE_ILS] = "ILS", \
  189. [FC_TYPE_NVME] = "NVME", \
  190. }
  191. /*
  192. * Exchange IDs.
  193. */
  194. #define FC_XID_UNKNOWN 0xffff /* unknown exchange ID */
  195. #define FC_XID_MIN 0x0 /* supported min exchange ID */
  196. #define FC_XID_MAX 0xfffe /* supported max exchange ID */
  197. /*
  198. * fh_f_ctl - Frame control flags.
  199. */
  200. #define FC_FC_EX_CTX (1 << 23) /* sent by responder to exchange */
  201. #define FC_FC_SEQ_CTX (1 << 22) /* sent by responder to sequence */
  202. #define FC_FC_FIRST_SEQ (1 << 21) /* first sequence of this exchange */
  203. #define FC_FC_LAST_SEQ (1 << 20) /* last sequence of this exchange */
  204. #define FC_FC_END_SEQ (1 << 19) /* last frame of sequence */
  205. #define FC_FC_END_CONN (1 << 18) /* end of class 1 connection pending */
  206. #define FC_FC_RES_B17 (1 << 17) /* reserved */
  207. #define FC_FC_SEQ_INIT (1 << 16) /* transfer of sequence initiative */
  208. #define FC_FC_X_ID_REASS (1 << 15) /* exchange ID has been changed */
  209. #define FC_FC_X_ID_INVAL (1 << 14) /* exchange ID invalidated */
  210. #define FC_FC_ACK_1 (1 << 12) /* 13:12 = 1: ACK_1 expected */
  211. #define FC_FC_ACK_N (2 << 12) /* 13:12 = 2: ACK_N expected */
  212. #define FC_FC_ACK_0 (3 << 12) /* 13:12 = 3: ACK_0 expected */
  213. #define FC_FC_RES_B11 (1 << 11) /* reserved */
  214. #define FC_FC_RES_B10 (1 << 10) /* reserved */
  215. #define FC_FC_RETX_SEQ (1 << 9) /* retransmitted sequence */
  216. #define FC_FC_UNI_TX (1 << 8) /* unidirectional transmit (class 1) */
  217. #define FC_FC_CONT_SEQ(i) ((i) << 6)
  218. #define FC_FC_ABT_SEQ(i) ((i) << 4)
  219. #define FC_FC_REL_OFF (1 << 3) /* parameter is relative offset */
  220. #define FC_FC_RES2 (1 << 2) /* reserved */
  221. #define FC_FC_FILL(i) ((i) & 3) /* 1:0: bytes of trailing fill */
  222. /*
  223. * BA_ACC payload.
  224. */
  225. struct fc_ba_acc {
  226. __u8 ba_seq_id_val; /* SEQ_ID validity */
  227. #define FC_BA_SEQ_ID_VAL 0x80
  228. __u8 ba_seq_id; /* SEQ_ID of seq last deliverable */
  229. __u8 ba_resvd[2]; /* reserved */
  230. __be16 ba_ox_id; /* OX_ID for aborted seq or exch */
  231. __be16 ba_rx_id; /* RX_ID for aborted seq or exch */
  232. __be16 ba_low_seq_cnt; /* low SEQ_CNT of aborted seq */
  233. __be16 ba_high_seq_cnt; /* high SEQ_CNT of aborted seq */
  234. };
  235. /*
  236. * BA_RJT: Basic Reject payload.
  237. */
  238. struct fc_ba_rjt {
  239. __u8 br_resvd; /* reserved */
  240. __u8 br_reason; /* reason code */
  241. __u8 br_explan; /* reason explanation */
  242. __u8 br_vendor; /* vendor unique code */
  243. };
  244. /*
  245. * BA_RJT reason codes.
  246. * From FS-2.
  247. */
  248. enum fc_ba_rjt_reason {
  249. FC_BA_RJT_NONE = 0, /* in software this means no reject */
  250. FC_BA_RJT_INVL_CMD = 0x01, /* invalid command code */
  251. FC_BA_RJT_LOG_ERR = 0x03, /* logical error */
  252. FC_BA_RJT_LOG_BUSY = 0x05, /* logical busy */
  253. FC_BA_RJT_PROTO_ERR = 0x07, /* protocol error */
  254. FC_BA_RJT_UNABLE = 0x09, /* unable to perform request */
  255. FC_BA_RJT_VENDOR = 0xff, /* vendor-specific (see br_vendor) */
  256. };
  257. /*
  258. * BA_RJT reason code explanations.
  259. */
  260. enum fc_ba_rjt_explan {
  261. FC_BA_RJT_EXP_NONE = 0x00, /* no additional expanation */
  262. FC_BA_RJT_INV_XID = 0x03, /* invalid OX_ID-RX_ID combination */
  263. FC_BA_RJT_ABT = 0x05, /* sequence aborted, no seq info */
  264. };
  265. /*
  266. * P_RJT or F_RJT: Port Reject or Fabric Reject parameter field.
  267. */
  268. struct fc_pf_rjt {
  269. __u8 rj_action; /* reserved */
  270. __u8 rj_reason; /* reason code */
  271. __u8 rj_resvd; /* reserved */
  272. __u8 rj_vendor; /* vendor unique code */
  273. };
  274. /*
  275. * P_RJT and F_RJT reject reason codes.
  276. */
  277. enum fc_pf_rjt_reason {
  278. FC_RJT_NONE = 0, /* non-reject (reserved by standard) */
  279. FC_RJT_INVL_DID = 0x01, /* invalid destination ID */
  280. FC_RJT_INVL_SID = 0x02, /* invalid source ID */
  281. FC_RJT_P_UNAV_T = 0x03, /* port unavailable, temporary */
  282. FC_RJT_P_UNAV = 0x04, /* port unavailable, permanent */
  283. FC_RJT_CLS_UNSUP = 0x05, /* class not supported */
  284. FC_RJT_DEL_USAGE = 0x06, /* delimiter usage error */
  285. FC_RJT_TYPE_UNSUP = 0x07, /* type not supported */
  286. FC_RJT_LINK_CTL = 0x08, /* invalid link control */
  287. FC_RJT_R_CTL = 0x09, /* invalid R_CTL field */
  288. FC_RJT_F_CTL = 0x0a, /* invalid F_CTL field */
  289. FC_RJT_OX_ID = 0x0b, /* invalid originator exchange ID */
  290. FC_RJT_RX_ID = 0x0c, /* invalid responder exchange ID */
  291. FC_RJT_SEQ_ID = 0x0d, /* invalid sequence ID */
  292. FC_RJT_DF_CTL = 0x0e, /* invalid DF_CTL field */
  293. FC_RJT_SEQ_CNT = 0x0f, /* invalid SEQ_CNT field */
  294. FC_RJT_PARAM = 0x10, /* invalid parameter field */
  295. FC_RJT_EXCH_ERR = 0x11, /* exchange error */
  296. FC_RJT_PROTO = 0x12, /* protocol error */
  297. FC_RJT_LEN = 0x13, /* incorrect length */
  298. FC_RJT_UNEXP_ACK = 0x14, /* unexpected ACK */
  299. FC_RJT_FAB_CLASS = 0x15, /* class unsupported by fabric entity */
  300. FC_RJT_LOGI_REQ = 0x16, /* login required */
  301. FC_RJT_SEQ_XS = 0x17, /* excessive sequences attempted */
  302. FC_RJT_EXCH_EST = 0x18, /* unable to establish exchange */
  303. FC_RJT_FAB_UNAV = 0x1a, /* fabric unavailable */
  304. FC_RJT_VC_ID = 0x1b, /* invalid VC_ID (class 4) */
  305. FC_RJT_CS_CTL = 0x1c, /* invalid CS_CTL field */
  306. FC_RJT_INSUF_RES = 0x1d, /* insuff. resources for VC (Class 4) */
  307. FC_RJT_INVL_CLS = 0x1f, /* invalid class of service */
  308. FC_RJT_PREEMT_RJT = 0x20, /* preemption request rejected */
  309. FC_RJT_PREEMT_DIS = 0x21, /* preemption not enabled */
  310. FC_RJT_MCAST_ERR = 0x22, /* multicast error */
  311. FC_RJT_MCAST_ET = 0x23, /* multicast error terminate */
  312. FC_RJT_PRLI_REQ = 0x24, /* process login required */
  313. FC_RJT_INVL_ATT = 0x25, /* invalid attachment */
  314. FC_RJT_VENDOR = 0xff, /* vendor specific reject */
  315. };
  316. /* default timeout values */
  317. #define FC_DEF_E_D_TOV 2000UL
  318. #define FC_DEF_R_A_TOV 10000UL
  319. #endif /* _FC_FS_H_ */