diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/scsi/fc/fc_ms.h | 213 | ||||
| -rw-r--r-- | include/scsi/fc_encode.h | 303 | ||||
| -rw-r--r-- | include/scsi/libfc.h | 11 |
3 files changed, 527 insertions, 0 deletions
diff --git a/include/scsi/fc/fc_ms.h b/include/scsi/fc/fc_ms.h new file mode 100644 index 000000000000..f52b921b5c70 --- /dev/null +++ b/include/scsi/fc/fc_ms.h | |||
| @@ -0,0 +1,213 @@ | |||
| 1 | /* * Copyright(c) 2011 Intel Corporation. All rights reserved. | ||
| 2 | * | ||
| 3 | * This program is free software; you can redistribute it and/or modify it | ||
| 4 | * under the terms and conditions of the GNU General Public License, | ||
| 5 | * version 2, as published by the Free Software Foundation. | ||
| 6 | * | ||
| 7 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
| 8 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 9 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 10 | * more details. | ||
| 11 | * | ||
| 12 | * You should have received a copy of the GNU General Public License along with | ||
| 13 | * this program; if not, write to the Free Software Foundation, Inc., | ||
| 14 | * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 15 | * | ||
| 16 | * Maintained at www.Open-FCoE.org | ||
| 17 | */ | ||
| 18 | |||
| 19 | #ifndef _FC_MS_H_ | ||
| 20 | #define _FC_MS_H_ | ||
| 21 | |||
| 22 | #include <linux/types.h> | ||
| 23 | |||
| 24 | /* | ||
| 25 | * Fibre Channel Services - Management Service (MS) | ||
| 26 | * From T11.org FC-GS-4 Rev 7.91 February 4, 2004 | ||
| 27 | */ | ||
| 28 | |||
| 29 | /* | ||
| 30 | * Fabric Device Management Interface | ||
| 31 | */ | ||
| 32 | |||
| 33 | /* | ||
| 34 | * Common-transport sub-type for FDMI | ||
| 35 | */ | ||
| 36 | #define FC_FDMI_SUBTYPE 0x10 /* fs_ct_hdr.ct_fs_subtype */ | ||
| 37 | |||
| 38 | /* | ||
| 39 | * Management server FDMI Requests. | ||
| 40 | */ | ||
| 41 | enum fc_fdmi_req { | ||
| 42 | FC_FDMI_GRHL = 0x0100, /* Get Registered HBA List */ | ||
| 43 | FC_FDMI_GHAT = 0x0101, /* Get HBA Attributes */ | ||
| 44 | FC_FDMI_GRPL = 0x0102, /* Get Registered Port List */ | ||
| 45 | FC_FDMI_GPAT = 0x0110, /* Get Port Attributes */ | ||
| 46 | FC_FDMI_RHBA = 0x0200, /* Register HBA */ | ||
| 47 | FC_FDMI_RHAT = 0x0201, /* Register HBA Attributes */ | ||
| 48 | FC_FDMI_RPRT = 0x0210, /* Register Port */ | ||
| 49 | FC_FDMI_RPA = 0x0211, /* Register Port Attributes */ | ||
| 50 | FC_FDMI_DHBA = 0x0300, /* Deregister HBA */ | ||
| 51 | FC_FDMI_DHAT = 0x0301, /* Deregister HBA Attributes */ | ||
| 52 | FC_FDMI_DPRT = 0x0310, /* Deregister Port */ | ||
| 53 | FC_FDMI_DPA = 0x0311, /* Deregister Port Attributes */ | ||
| 54 | }; | ||
| 55 | |||
| 56 | /* | ||
| 57 | * HBA Attribute Entry Type | ||
| 58 | */ | ||
| 59 | enum fc_fdmi_hba_attr_type { | ||
| 60 | FC_FDMI_HBA_ATTR_NODENAME = 0x0001, | ||
| 61 | FC_FDMI_HBA_ATTR_MANUFACTURER = 0x0002, | ||
| 62 | FC_FDMI_HBA_ATTR_SERIALNUMBER = 0x0003, | ||
| 63 | FC_FDMI_HBA_ATTR_MODEL = 0x0004, | ||
| 64 | FC_FDMI_HBA_ATTR_MODELDESCRIPTION = 0x0005, | ||
| 65 | FC_FDMI_HBA_ATTR_HARDWAREVERSION = 0x0006, | ||
| 66 | FC_FDMI_HBA_ATTR_DRIVERVERSION = 0x0007, | ||
| 67 | FC_FDMI_HBA_ATTR_OPTIONROMVERSION = 0x0008, | ||
| 68 | FC_FDMI_HBA_ATTR_FIRMWAREVERSION = 0x0009, | ||
| 69 | FC_FDMI_HBA_ATTR_OSNAMEVERSION = 0x000A, | ||
| 70 | FC_FDMI_HBA_ATTR_MAXCTPAYLOAD = 0x000B, | ||
| 71 | }; | ||
| 72 | |||
| 73 | /* | ||
| 74 | * HBA Attribute Length | ||
| 75 | */ | ||
| 76 | #define FC_FDMI_HBA_ATTR_NODENAME_LEN 8 | ||
| 77 | #define FC_FDMI_HBA_ATTR_MANUFACTURER_LEN 64 | ||
| 78 | #define FC_FDMI_HBA_ATTR_SERIALNUMBER_LEN 64 | ||
| 79 | #define FC_FDMI_HBA_ATTR_MODEL_LEN 256 | ||
| 80 | #define FC_FDMI_HBA_ATTR_MODELDESCR_LEN 256 | ||
| 81 | #define FC_FDMI_HBA_ATTR_HARDWAREVERSION_LEN 256 | ||
| 82 | #define FC_FDMI_HBA_ATTR_DRIVERVERSION_LEN 256 | ||
| 83 | #define FC_FDMI_HBA_ATTR_OPTIONROMVERSION_LEN 256 | ||
| 84 | #define FC_FDMI_HBA_ATTR_FIRMWAREVERSION_LEN 256 | ||
| 85 | #define FC_FDMI_HBA_ATTR_OSNAMEVERSION_LEN 256 | ||
| 86 | #define FC_FDMI_HBA_ATTR_MAXCTPAYLOAD_LEN 4 | ||
| 87 | |||
| 88 | /* | ||
| 89 | * Port Attribute Type | ||
| 90 | */ | ||
| 91 | enum fc_fdmi_port_attr_type { | ||
| 92 | FC_FDMI_PORT_ATTR_FC4TYPES = 0x0001, | ||
| 93 | FC_FDMI_PORT_ATTR_SUPPORTEDSPEED = 0x0002, | ||
| 94 | FC_FDMI_PORT_ATTR_CURRENTPORTSPEED = 0x0003, | ||
| 95 | FC_FDMI_PORT_ATTR_MAXFRAMESIZE = 0x0004, | ||
| 96 | FC_FDMI_PORT_ATTR_OSDEVICENAME = 0x0005, | ||
| 97 | FC_FDMI_PORT_ATTR_HOSTNAME = 0x0006, | ||
| 98 | }; | ||
| 99 | |||
| 100 | /* | ||
| 101 | * Port Attribute Length | ||
| 102 | */ | ||
| 103 | #define FC_FDMI_PORT_ATTR_FC4TYPES_LEN 32 | ||
| 104 | #define FC_FDMI_PORT_ATTR_SUPPORTEDSPEED_LEN 4 | ||
| 105 | #define FC_FDMI_PORT_ATTR_CURRENTPORTSPEED_LEN 4 | ||
| 106 | #define FC_FDMI_PORT_ATTR_MAXFRAMESIZE_LEN 4 | ||
| 107 | #define FC_FDMI_PORT_ATTR_OSDEVICENAME_LEN 256 | ||
| 108 | #define FC_FDMI_PORT_ATTR_HOSTNAME_LEN 256 | ||
| 109 | |||
| 110 | /* | ||
| 111 | * HBA Attribute ID | ||
| 112 | */ | ||
| 113 | struct fc_fdmi_hba_identifier { | ||
| 114 | __be64 id; | ||
| 115 | }; | ||
| 116 | |||
| 117 | /* | ||
| 118 | * Port Name | ||
| 119 | */ | ||
| 120 | struct fc_fdmi_port_name { | ||
| 121 | __be64 portname; | ||
| 122 | }; | ||
| 123 | |||
| 124 | /* | ||
| 125 | * Attribute Entry Block for HBA/Port Attributes | ||
| 126 | */ | ||
| 127 | #define FC_FDMI_ATTR_ENTRY_HEADER_LEN 4 | ||
| 128 | struct fc_fdmi_attr_entry { | ||
| 129 | __be16 type; | ||
| 130 | __be16 len; | ||
| 131 | __u8 value[1]; | ||
| 132 | } __attribute__((__packed__)); | ||
| 133 | |||
| 134 | /* | ||
| 135 | * Common for HBA/Port Attributes | ||
| 136 | */ | ||
| 137 | struct fs_fdmi_attrs { | ||
| 138 | __be32 numattrs; | ||
| 139 | struct fc_fdmi_attr_entry attr[1]; | ||
| 140 | } __attribute__((__packed__)); | ||
| 141 | |||
| 142 | /* | ||
| 143 | * Registered Port List | ||
| 144 | */ | ||
| 145 | struct fc_fdmi_rpl { | ||
| 146 | __be32 numport; | ||
| 147 | struct fc_fdmi_port_name port[1]; | ||
| 148 | } __attribute__((__packed__)); | ||
| 149 | |||
| 150 | /* | ||
| 151 | * Register HBA (RHBA) | ||
| 152 | */ | ||
| 153 | struct fc_fdmi_rhba { | ||
| 154 | struct fc_fdmi_hba_identifier hbaid; | ||
| 155 | struct fc_fdmi_rpl port; | ||
| 156 | struct fs_fdmi_attrs hba_attrs; | ||
| 157 | } __attribute__((__packed__)); | ||
| 158 | |||
| 159 | /* | ||
| 160 | * Register HBA Attributes (RHAT) | ||
| 161 | */ | ||
| 162 | struct fc_fdmi_rhat { | ||
| 163 | struct fc_fdmi_hba_identifier hbaid; | ||
| 164 | struct fs_fdmi_attrs hba_attrs; | ||
| 165 | } __attribute__((__packed__)); | ||
| 166 | |||
| 167 | /* | ||
| 168 | * Register Port (RPRT) | ||
| 169 | */ | ||
| 170 | struct fc_fdmi_rprt { | ||
| 171 | struct fc_fdmi_hba_identifier hbaid; | ||
| 172 | struct fc_fdmi_port_name port; | ||
| 173 | struct fs_fdmi_attrs hba_attrs; | ||
| 174 | } __attribute__((__packed__)); | ||
| 175 | |||
| 176 | /* | ||
| 177 | * Register Port Attributes (RPA) | ||
| 178 | */ | ||
| 179 | struct fc_fdmi_rpa { | ||
| 180 | struct fc_fdmi_port_name port; | ||
| 181 | struct fs_fdmi_attrs hba_attrs; | ||
| 182 | } __attribute__((__packed__)); | ||
| 183 | |||
| 184 | /* | ||
| 185 | * Deregister Port (DPRT) | ||
| 186 | */ | ||
| 187 | struct fc_fdmi_dprt { | ||
| 188 | struct fc_fdmi_port_name port; | ||
| 189 | } __attribute__((__packed__)); | ||
| 190 | |||
| 191 | /* | ||
| 192 | * Deregister Port Attributes (DPA) | ||
| 193 | */ | ||
| 194 | struct fc_fdmi_dpa { | ||
| 195 | struct fc_fdmi_port_name port; | ||
| 196 | struct fs_fdmi_attrs hba_attrs; | ||
| 197 | } __attribute__((__packed__)); | ||
| 198 | |||
| 199 | /* | ||
| 200 | * Deregister HBA Attributes (DHAT) | ||
| 201 | */ | ||
| 202 | struct fc_fdmi_dhat { | ||
| 203 | struct fc_fdmi_hba_identifier hbaid; | ||
| 204 | } __attribute__((__packed__)); | ||
| 205 | |||
| 206 | /* | ||
| 207 | * Deregister HBA (DHBA) | ||
| 208 | */ | ||
| 209 | struct fc_fdmi_dhba { | ||
| 210 | struct fc_fdmi_hba_identifier hbaid; | ||
| 211 | } __attribute__((__packed__)); | ||
| 212 | |||
| 213 | #endif /* _FC_MS_H_ */ | ||
diff --git a/include/scsi/fc_encode.h b/include/scsi/fc_encode.h index 73bc43329f86..35fd4744f3e9 100644 --- a/include/scsi/fc_encode.h +++ b/include/scsi/fc_encode.h | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | #ifndef _FC_ENCODE_H_ | 20 | #ifndef _FC_ENCODE_H_ |
| 21 | #define _FC_ENCODE_H_ | 21 | #define _FC_ENCODE_H_ |
| 22 | #include <asm/unaligned.h> | 22 | #include <asm/unaligned.h> |
| 23 | #include <linux/utsname.h> | ||
| 23 | 24 | ||
| 24 | /* | 25 | /* |
| 25 | * F_CTL values for simple requests and responses. | 26 | * F_CTL values for simple requests and responses. |
| @@ -43,6 +44,10 @@ struct fc_ct_req { | |||
| 43 | struct fc_ns_fid fid; | 44 | struct fc_ns_fid fid; |
| 44 | struct fc_ns_rsnn snn; | 45 | struct fc_ns_rsnn snn; |
| 45 | struct fc_ns_rspn spn; | 46 | struct fc_ns_rspn spn; |
| 47 | struct fc_fdmi_rhba rhba; | ||
| 48 | struct fc_fdmi_rpa rpa; | ||
| 49 | struct fc_fdmi_dprt dprt; | ||
| 50 | struct fc_fdmi_dhba dhba; | ||
| 46 | } payload; | 51 | } payload; |
| 47 | }; | 52 | }; |
| 48 | 53 | ||
| @@ -199,6 +204,300 @@ static inline int fc_ct_ns_fill(struct fc_lport *lport, | |||
| 199 | } | 204 | } |
| 200 | 205 | ||
| 201 | /** | 206 | /** |
| 207 | * fc_ct_ms_fill() - Fill in a mgmt service request frame | ||
| 208 | * @lport: local port. | ||
| 209 | * @fc_id: FC_ID of non-destination rport for GPN_ID and similar inquiries. | ||
| 210 | * @fp: frame to contain payload. | ||
| 211 | * @op: CT opcode. | ||
| 212 | * @r_ctl: pointer to FC header R_CTL. | ||
| 213 | * @fh_type: pointer to FC-4 type. | ||
| 214 | */ | ||
| 215 | static inline int fc_ct_ms_fill(struct fc_lport *lport, | ||
| 216 | u32 fc_id, struct fc_frame *fp, | ||
| 217 | unsigned int op, enum fc_rctl *r_ctl, | ||
| 218 | enum fc_fh_type *fh_type) | ||
| 219 | { | ||
| 220 | struct fc_ct_req *ct; | ||
| 221 | size_t len; | ||
| 222 | struct fc_fdmi_attr_entry *entry; | ||
| 223 | struct fs_fdmi_attrs *hba_attrs; | ||
| 224 | int numattrs = 0; | ||
| 225 | |||
| 226 | switch (op) { | ||
| 227 | case FC_FDMI_RHBA: | ||
| 228 | numattrs = 10; | ||
| 229 | len = sizeof(struct fc_fdmi_rhba); | ||
| 230 | len -= sizeof(struct fc_fdmi_attr_entry); | ||
| 231 | len += (numattrs * FC_FDMI_ATTR_ENTRY_HEADER_LEN); | ||
| 232 | len += FC_FDMI_HBA_ATTR_NODENAME_LEN; | ||
| 233 | len += FC_FDMI_HBA_ATTR_MANUFACTURER_LEN; | ||
| 234 | len += FC_FDMI_HBA_ATTR_SERIALNUMBER_LEN; | ||
| 235 | len += FC_FDMI_HBA_ATTR_MODEL_LEN; | ||
| 236 | len += FC_FDMI_HBA_ATTR_MODELDESCR_LEN; | ||
| 237 | len += FC_FDMI_HBA_ATTR_HARDWAREVERSION_LEN; | ||
| 238 | len += FC_FDMI_HBA_ATTR_DRIVERVERSION_LEN; | ||
| 239 | len += FC_FDMI_HBA_ATTR_OPTIONROMVERSION_LEN; | ||
| 240 | len += FC_FDMI_HBA_ATTR_FIRMWAREVERSION_LEN; | ||
| 241 | len += FC_FDMI_HBA_ATTR_OSNAMEVERSION_LEN; | ||
| 242 | ct = fc_ct_hdr_fill(fp, op, len, FC_FST_MGMT, | ||
| 243 | FC_FDMI_SUBTYPE); | ||
| 244 | |||
| 245 | /* HBA Identifier */ | ||
| 246 | put_unaligned_be64(lport->wwpn, &ct->payload.rhba.hbaid.id); | ||
| 247 | /* Number of Ports - always 1 */ | ||
| 248 | put_unaligned_be32(1, &ct->payload.rhba.port.numport); | ||
| 249 | /* Port Name */ | ||
| 250 | put_unaligned_be64(lport->wwpn, | ||
| 251 | &ct->payload.rhba.port.port[0].portname); | ||
| 252 | |||
| 253 | /* HBA Attributes */ | ||
| 254 | put_unaligned_be32(numattrs, | ||
| 255 | &ct->payload.rhba.hba_attrs.numattrs); | ||
| 256 | hba_attrs = &ct->payload.rhba.hba_attrs; | ||
| 257 | entry = (struct fc_fdmi_attr_entry *)hba_attrs->attr; | ||
| 258 | /* NodeName*/ | ||
| 259 | len = FC_FDMI_ATTR_ENTRY_HEADER_LEN; | ||
| 260 | len += FC_FDMI_HBA_ATTR_NODENAME_LEN; | ||
| 261 | put_unaligned_be16(FC_FDMI_HBA_ATTR_NODENAME, | ||
| 262 | &entry->type); | ||
| 263 | put_unaligned_be16(len, &entry->len); | ||
| 264 | put_unaligned_be64(lport->wwnn, | ||
| 265 | (__be64 *)&entry->value[0]); | ||
| 266 | |||
| 267 | /* Manufacturer */ | ||
| 268 | entry = (struct fc_fdmi_attr_entry *)((char *)entry->value + | ||
| 269 | FC_FDMI_HBA_ATTR_NODENAME_LEN); | ||
| 270 | len = FC_FDMI_ATTR_ENTRY_HEADER_LEN; | ||
| 271 | len += FC_FDMI_HBA_ATTR_MANUFACTURER_LEN; | ||
| 272 | put_unaligned_be16(FC_FDMI_HBA_ATTR_MANUFACTURER, | ||
| 273 | &entry->type); | ||
| 274 | put_unaligned_be16(len, &entry->len); | ||
| 275 | strncpy((char *)&entry->value, | ||
| 276 | fc_host_manufacturer(lport->host), | ||
| 277 | FC_FDMI_HBA_ATTR_MANUFACTURER_LEN); | ||
| 278 | |||
| 279 | /* SerialNumber */ | ||
| 280 | entry = (struct fc_fdmi_attr_entry *)((char *)entry->value + | ||
| 281 | FC_FDMI_HBA_ATTR_MANUFACTURER_LEN); | ||
| 282 | len = FC_FDMI_ATTR_ENTRY_HEADER_LEN; | ||
| 283 | len += FC_FDMI_HBA_ATTR_SERIALNUMBER_LEN; | ||
| 284 | put_unaligned_be16(FC_FDMI_HBA_ATTR_SERIALNUMBER, | ||
| 285 | &entry->type); | ||
| 286 | put_unaligned_be16(len, &entry->len); | ||
| 287 | strncpy((char *)&entry->value, | ||
| 288 | fc_host_serial_number(lport->host), | ||
| 289 | FC_FDMI_HBA_ATTR_SERIALNUMBER_LEN); | ||
| 290 | |||
| 291 | /* Model */ | ||
| 292 | entry = (struct fc_fdmi_attr_entry *)((char *)entry->value + | ||
| 293 | FC_FDMI_HBA_ATTR_SERIALNUMBER_LEN); | ||
| 294 | len = FC_FDMI_ATTR_ENTRY_HEADER_LEN; | ||
| 295 | len += FC_FDMI_HBA_ATTR_MODEL_LEN; | ||
| 296 | put_unaligned_be16(FC_FDMI_HBA_ATTR_MODEL, | ||
| 297 | &entry->type); | ||
| 298 | put_unaligned_be16(len, &entry->len); | ||
| 299 | strncpy((char *)&entry->value, | ||
| 300 | fc_host_model(lport->host), | ||
| 301 | FC_FDMI_HBA_ATTR_MODEL_LEN); | ||
| 302 | |||
| 303 | /* Model Description */ | ||
| 304 | entry = (struct fc_fdmi_attr_entry *)((char *)entry->value + | ||
| 305 | FC_FDMI_HBA_ATTR_MODEL_LEN); | ||
| 306 | len = FC_FDMI_ATTR_ENTRY_HEADER_LEN; | ||
| 307 | len += FC_FDMI_HBA_ATTR_MODELDESCR_LEN; | ||
| 308 | put_unaligned_be16(FC_FDMI_HBA_ATTR_MODELDESCRIPTION, | ||
| 309 | &entry->type); | ||
| 310 | put_unaligned_be16(len, &entry->len); | ||
| 311 | strncpy((char *)&entry->value, | ||
| 312 | fc_host_model_description(lport->host), | ||
| 313 | FC_FDMI_HBA_ATTR_MODELDESCR_LEN); | ||
| 314 | |||
| 315 | /* Hardware Version */ | ||
| 316 | entry = (struct fc_fdmi_attr_entry *)((char *)entry->value + | ||
| 317 | FC_FDMI_HBA_ATTR_MODELDESCR_LEN); | ||
| 318 | len = FC_FDMI_ATTR_ENTRY_HEADER_LEN; | ||
| 319 | len += FC_FDMI_HBA_ATTR_HARDWAREVERSION_LEN; | ||
| 320 | put_unaligned_be16(FC_FDMI_HBA_ATTR_HARDWAREVERSION, | ||
| 321 | &entry->type); | ||
| 322 | put_unaligned_be16(len, &entry->len); | ||
| 323 | strncpy((char *)&entry->value, | ||
| 324 | fc_host_hardware_version(lport->host), | ||
| 325 | FC_FDMI_HBA_ATTR_HARDWAREVERSION_LEN); | ||
| 326 | |||
| 327 | /* Driver Version */ | ||
| 328 | entry = (struct fc_fdmi_attr_entry *)((char *)entry->value + | ||
| 329 | FC_FDMI_HBA_ATTR_HARDWAREVERSION_LEN); | ||
| 330 | len = FC_FDMI_ATTR_ENTRY_HEADER_LEN; | ||
| 331 | len += FC_FDMI_HBA_ATTR_DRIVERVERSION_LEN; | ||
| 332 | put_unaligned_be16(FC_FDMI_HBA_ATTR_DRIVERVERSION, | ||
| 333 | &entry->type); | ||
| 334 | put_unaligned_be16(len, &entry->len); | ||
| 335 | strncpy((char *)&entry->value, | ||
| 336 | fc_host_driver_version(lport->host), | ||
| 337 | FC_FDMI_HBA_ATTR_DRIVERVERSION_LEN); | ||
| 338 | |||
| 339 | /* OptionROM Version */ | ||
| 340 | entry = (struct fc_fdmi_attr_entry *)((char *)entry->value + | ||
| 341 | FC_FDMI_HBA_ATTR_DRIVERVERSION_LEN); | ||
| 342 | len = FC_FDMI_ATTR_ENTRY_HEADER_LEN; | ||
| 343 | len += FC_FDMI_HBA_ATTR_OPTIONROMVERSION_LEN; | ||
| 344 | put_unaligned_be16(FC_FDMI_HBA_ATTR_OPTIONROMVERSION, | ||
| 345 | &entry->type); | ||
| 346 | put_unaligned_be16(len, &entry->len); | ||
| 347 | strncpy((char *)&entry->value, | ||
| 348 | fc_host_optionrom_version(lport->host), | ||
| 349 | FC_FDMI_HBA_ATTR_OPTIONROMVERSION_LEN); | ||
| 350 | |||
| 351 | /* Firmware Version */ | ||
| 352 | entry = (struct fc_fdmi_attr_entry *)((char *)entry->value + | ||
| 353 | FC_FDMI_HBA_ATTR_OPTIONROMVERSION_LEN); | ||
| 354 | len = FC_FDMI_ATTR_ENTRY_HEADER_LEN; | ||
| 355 | len += FC_FDMI_HBA_ATTR_FIRMWAREVERSION_LEN; | ||
| 356 | put_unaligned_be16(FC_FDMI_HBA_ATTR_FIRMWAREVERSION, | ||
| 357 | &entry->type); | ||
| 358 | put_unaligned_be16(len, &entry->len); | ||
| 359 | strncpy((char *)&entry->value, | ||
| 360 | fc_host_firmware_version(lport->host), | ||
| 361 | FC_FDMI_HBA_ATTR_FIRMWAREVERSION_LEN); | ||
| 362 | |||
| 363 | /* OS Name and Version */ | ||
| 364 | entry = (struct fc_fdmi_attr_entry *)((char *)entry->value + | ||
| 365 | FC_FDMI_HBA_ATTR_FIRMWAREVERSION_LEN); | ||
| 366 | len = FC_FDMI_ATTR_ENTRY_HEADER_LEN; | ||
| 367 | len += FC_FDMI_HBA_ATTR_OSNAMEVERSION_LEN; | ||
| 368 | put_unaligned_be16(FC_FDMI_HBA_ATTR_OSNAMEVERSION, | ||
| 369 | &entry->type); | ||
| 370 | put_unaligned_be16(len, &entry->len); | ||
| 371 | snprintf((char *)&entry->value, | ||
| 372 | FC_FDMI_HBA_ATTR_OSNAMEVERSION_LEN, | ||
| 373 | "%s v%s", | ||
| 374 | init_utsname()->sysname, | ||
| 375 | init_utsname()->release); | ||
| 376 | break; | ||
| 377 | case FC_FDMI_RPA: | ||
| 378 | numattrs = 6; | ||
| 379 | len = sizeof(struct fc_fdmi_rpa); | ||
| 380 | len -= sizeof(struct fc_fdmi_attr_entry); | ||
| 381 | len += (numattrs * FC_FDMI_ATTR_ENTRY_HEADER_LEN); | ||
| 382 | len += FC_FDMI_PORT_ATTR_FC4TYPES_LEN; | ||
| 383 | len += FC_FDMI_PORT_ATTR_SUPPORTEDSPEED_LEN; | ||
| 384 | len += FC_FDMI_PORT_ATTR_CURRENTPORTSPEED_LEN; | ||
| 385 | len += FC_FDMI_PORT_ATTR_MAXFRAMESIZE_LEN; | ||
| 386 | len += FC_FDMI_PORT_ATTR_OSDEVICENAME_LEN; | ||
| 387 | len += FC_FDMI_PORT_ATTR_HOSTNAME_LEN; | ||
| 388 | ct = fc_ct_hdr_fill(fp, op, len, FC_FST_MGMT, | ||
| 389 | FC_FDMI_SUBTYPE); | ||
| 390 | |||
| 391 | /* Port Name */ | ||
| 392 | put_unaligned_be64(lport->wwpn, | ||
| 393 | &ct->payload.rpa.port.portname); | ||
| 394 | |||
| 395 | /* Port Attributes */ | ||
| 396 | put_unaligned_be32(numattrs, | ||
| 397 | &ct->payload.rpa.hba_attrs.numattrs); | ||
| 398 | |||
| 399 | hba_attrs = &ct->payload.rpa.hba_attrs; | ||
| 400 | entry = (struct fc_fdmi_attr_entry *)hba_attrs->attr; | ||
| 401 | |||
| 402 | /* FC4 types */ | ||
| 403 | len = FC_FDMI_ATTR_ENTRY_HEADER_LEN; | ||
| 404 | len += FC_FDMI_PORT_ATTR_FC4TYPES_LEN; | ||
| 405 | put_unaligned_be16(FC_FDMI_PORT_ATTR_FC4TYPES, | ||
| 406 | &entry->type); | ||
| 407 | put_unaligned_be16(len, &entry->len); | ||
| 408 | memcpy(&entry->value, fc_host_supported_fc4s(lport->host), | ||
| 409 | FC_FDMI_PORT_ATTR_FC4TYPES_LEN); | ||
| 410 | |||
| 411 | /* Supported Speed */ | ||
| 412 | entry = (struct fc_fdmi_attr_entry *)((char *)entry->value + | ||
| 413 | FC_FDMI_PORT_ATTR_FC4TYPES_LEN); | ||
| 414 | len = FC_FDMI_ATTR_ENTRY_HEADER_LEN; | ||
| 415 | len += FC_FDMI_PORT_ATTR_SUPPORTEDSPEED_LEN; | ||
| 416 | put_unaligned_be16(FC_FDMI_PORT_ATTR_SUPPORTEDSPEED, | ||
| 417 | &entry->type); | ||
| 418 | put_unaligned_be16(len, &entry->len); | ||
| 419 | |||
| 420 | put_unaligned_be32(fc_host_supported_speeds(lport->host), | ||
| 421 | &entry->value); | ||
| 422 | |||
| 423 | /* Current Port Speed */ | ||
| 424 | entry = (struct fc_fdmi_attr_entry *)((char *)entry->value + | ||
| 425 | FC_FDMI_PORT_ATTR_SUPPORTEDSPEED_LEN); | ||
| 426 | len = FC_FDMI_ATTR_ENTRY_HEADER_LEN; | ||
| 427 | len += FC_FDMI_PORT_ATTR_CURRENTPORTSPEED_LEN; | ||
| 428 | put_unaligned_be16(FC_FDMI_PORT_ATTR_CURRENTPORTSPEED, | ||
| 429 | &entry->type); | ||
| 430 | put_unaligned_be16(len, &entry->len); | ||
| 431 | put_unaligned_be32(lport->link_speed, | ||
| 432 | &entry->value); | ||
| 433 | |||
| 434 | /* Max Frame Size */ | ||
| 435 | entry = (struct fc_fdmi_attr_entry *)((char *)entry->value + | ||
| 436 | FC_FDMI_PORT_ATTR_CURRENTPORTSPEED_LEN); | ||
| 437 | len = FC_FDMI_ATTR_ENTRY_HEADER_LEN; | ||
| 438 | len += FC_FDMI_PORT_ATTR_MAXFRAMESIZE_LEN; | ||
| 439 | put_unaligned_be16(FC_FDMI_PORT_ATTR_MAXFRAMESIZE, | ||
| 440 | &entry->type); | ||
| 441 | put_unaligned_be16(len, &entry->len); | ||
| 442 | put_unaligned_be32(fc_host_maxframe_size(lport->host), | ||
| 443 | &entry->value); | ||
| 444 | |||
| 445 | /* OS Device Name */ | ||
| 446 | entry = (struct fc_fdmi_attr_entry *)((char *)entry->value + | ||
| 447 | FC_FDMI_PORT_ATTR_MAXFRAMESIZE_LEN); | ||
| 448 | len = FC_FDMI_ATTR_ENTRY_HEADER_LEN; | ||
| 449 | len += FC_FDMI_PORT_ATTR_OSDEVICENAME_LEN; | ||
| 450 | put_unaligned_be16(FC_FDMI_PORT_ATTR_OSDEVICENAME, | ||
| 451 | &entry->type); | ||
| 452 | put_unaligned_be16(len, &entry->len); | ||
| 453 | /* Use the sysfs device name */ | ||
| 454 | strncpy((char *)&entry->value, | ||
| 455 | dev_name(&lport->host->shost_gendev), | ||
| 456 | strnlen(dev_name(&lport->host->shost_gendev), | ||
| 457 | FC_FDMI_PORT_ATTR_HOSTNAME_LEN)); | ||
| 458 | |||
| 459 | /* Host Name */ | ||
| 460 | entry = (struct fc_fdmi_attr_entry *)((char *)entry->value + | ||
| 461 | FC_FDMI_PORT_ATTR_OSDEVICENAME_LEN); | ||
| 462 | len = FC_FDMI_ATTR_ENTRY_HEADER_LEN; | ||
| 463 | len += FC_FDMI_PORT_ATTR_HOSTNAME_LEN; | ||
| 464 | put_unaligned_be16(FC_FDMI_PORT_ATTR_HOSTNAME, | ||
| 465 | &entry->type); | ||
| 466 | put_unaligned_be16(len, &entry->len); | ||
| 467 | if (strlen(fc_host_system_hostname(lport->host))) | ||
| 468 | strncpy((char *)&entry->value, | ||
| 469 | fc_host_system_hostname(lport->host), | ||
| 470 | strnlen(fc_host_system_hostname(lport->host), | ||
| 471 | FC_FDMI_PORT_ATTR_HOSTNAME_LEN)); | ||
| 472 | else | ||
| 473 | strncpy((char *)&entry->value, | ||
| 474 | init_utsname()->nodename, | ||
| 475 | FC_FDMI_PORT_ATTR_HOSTNAME_LEN); | ||
| 476 | break; | ||
| 477 | case FC_FDMI_DPRT: | ||
| 478 | len = sizeof(struct fc_fdmi_dprt); | ||
| 479 | ct = fc_ct_hdr_fill(fp, op, len, FC_FST_MGMT, | ||
| 480 | FC_FDMI_SUBTYPE); | ||
| 481 | /* Port Name */ | ||
| 482 | put_unaligned_be64(lport->wwpn, | ||
| 483 | &ct->payload.dprt.port.portname); | ||
| 484 | break; | ||
| 485 | case FC_FDMI_DHBA: | ||
| 486 | len = sizeof(struct fc_fdmi_dhba); | ||
| 487 | ct = fc_ct_hdr_fill(fp, op, len, FC_FST_MGMT, | ||
| 488 | FC_FDMI_SUBTYPE); | ||
| 489 | /* HBA Identifier */ | ||
| 490 | put_unaligned_be64(lport->wwpn, &ct->payload.dhba.hbaid.id); | ||
| 491 | break; | ||
| 492 | default: | ||
| 493 | return -EINVAL; | ||
| 494 | } | ||
| 495 | *r_ctl = FC_RCTL_DD_UNSOL_CTL; | ||
| 496 | *fh_type = FC_TYPE_CT; | ||
| 497 | return 0; | ||
| 498 | } | ||
| 499 | |||
| 500 | /** | ||
| 202 | * fc_ct_fill() - Fill in a common transport service request frame | 501 | * fc_ct_fill() - Fill in a common transport service request frame |
| 203 | * @lport: local port. | 502 | * @lport: local port. |
| 204 | * @fc_id: FC_ID of non-destination rport for GPN_ID and similar inquiries. | 503 | * @fc_id: FC_ID of non-destination rport for GPN_ID and similar inquiries. |
| @@ -215,6 +514,10 @@ static inline int fc_ct_fill(struct fc_lport *lport, | |||
| 215 | int rc = -EINVAL; | 514 | int rc = -EINVAL; |
| 216 | 515 | ||
| 217 | switch (fc_id) { | 516 | switch (fc_id) { |
| 517 | case FC_FID_MGMT_SERV: | ||
| 518 | rc = fc_ct_ms_fill(lport, fc_id, fp, op, r_ctl, fh_type); | ||
| 519 | *did = FC_FID_MGMT_SERV; | ||
| 520 | break; | ||
| 218 | case FC_FID_DIR_SERV: | 521 | case FC_FID_DIR_SERV: |
| 219 | default: | 522 | default: |
| 220 | rc = fc_ct_ns_fill(lport, fc_id, fp, op, r_ctl, fh_type); | 523 | rc = fc_ct_ns_fill(lport, fc_id, fp, op, r_ctl, fh_type); |
diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h index 6a3922fe0be0..8f9dfba3fcf0 100644 --- a/include/scsi/libfc.h +++ b/include/scsi/libfc.h | |||
| @@ -30,6 +30,7 @@ | |||
| 30 | 30 | ||
| 31 | #include <scsi/fc/fc_fcp.h> | 31 | #include <scsi/fc/fc_fcp.h> |
| 32 | #include <scsi/fc/fc_ns.h> | 32 | #include <scsi/fc/fc_ns.h> |
| 33 | #include <scsi/fc/fc_ms.h> | ||
| 33 | #include <scsi/fc/fc_els.h> | 34 | #include <scsi/fc/fc_els.h> |
| 34 | #include <scsi/fc/fc_gs.h> | 35 | #include <scsi/fc/fc_gs.h> |
| 35 | 36 | ||
| @@ -52,6 +53,8 @@ | |||
| 52 | * @LPORT_ST_RPN_ID: Register port name by ID (RPN_ID) sent | 53 | * @LPORT_ST_RPN_ID: Register port name by ID (RPN_ID) sent |
| 53 | * @LPORT_ST_RFT_ID: Register Fibre Channel types by ID (RFT_ID) sent | 54 | * @LPORT_ST_RFT_ID: Register Fibre Channel types by ID (RFT_ID) sent |
| 54 | * @LPORT_ST_RFF_ID: Register FC-4 Features by ID (RFF_ID) sent | 55 | * @LPORT_ST_RFF_ID: Register FC-4 Features by ID (RFF_ID) sent |
| 56 | * @LPORT_ST_FDMI: Waiting for mgmt server rport to become ready | ||
| 57 | * @LPORT_ST_RHBA: | ||
| 55 | * @LPORT_ST_SCR: State Change Register (SCR) sent | 58 | * @LPORT_ST_SCR: State Change Register (SCR) sent |
| 56 | * @LPORT_ST_READY: Ready for use | 59 | * @LPORT_ST_READY: Ready for use |
| 57 | * @LPORT_ST_LOGO: Local port logout (LOGO) sent | 60 | * @LPORT_ST_LOGO: Local port logout (LOGO) sent |
| @@ -66,6 +69,11 @@ enum fc_lport_state { | |||
| 66 | LPORT_ST_RSPN_ID, | 69 | LPORT_ST_RSPN_ID, |
| 67 | LPORT_ST_RFT_ID, | 70 | LPORT_ST_RFT_ID, |
| 68 | LPORT_ST_RFF_ID, | 71 | LPORT_ST_RFF_ID, |
| 72 | LPORT_ST_FDMI, | ||
| 73 | LPORT_ST_RHBA, | ||
| 74 | LPORT_ST_RPA, | ||
| 75 | LPORT_ST_DHBA, | ||
| 76 | LPORT_ST_DPRT, | ||
| 69 | LPORT_ST_SCR, | 77 | LPORT_ST_SCR, |
| 70 | LPORT_ST_READY, | 78 | LPORT_ST_READY, |
| 71 | LPORT_ST_LOGO, | 79 | LPORT_ST_LOGO, |
| @@ -797,6 +805,7 @@ enum fc_lport_event { | |||
| 797 | * @host: The SCSI host associated with a local port | 805 | * @host: The SCSI host associated with a local port |
| 798 | * @ema_list: Exchange manager anchor list | 806 | * @ema_list: Exchange manager anchor list |
| 799 | * @dns_rdata: The directory server remote port | 807 | * @dns_rdata: The directory server remote port |
| 808 | * @ms_rdata: The management server remote port | ||
| 800 | * @ptp_rdata: Point to point remote port | 809 | * @ptp_rdata: Point to point remote port |
| 801 | * @scsi_priv: FCP layer internal data | 810 | * @scsi_priv: FCP layer internal data |
| 802 | * @disc: Discovery context | 811 | * @disc: Discovery context |
| @@ -842,6 +851,7 @@ struct fc_lport { | |||
| 842 | struct Scsi_Host *host; | 851 | struct Scsi_Host *host; |
| 843 | struct list_head ema_list; | 852 | struct list_head ema_list; |
| 844 | struct fc_rport_priv *dns_rdata; | 853 | struct fc_rport_priv *dns_rdata; |
| 854 | struct fc_rport_priv *ms_rdata; | ||
| 845 | struct fc_rport_priv *ptp_rdata; | 855 | struct fc_rport_priv *ptp_rdata; |
| 846 | void *scsi_priv; | 856 | void *scsi_priv; |
| 847 | struct fc_disc disc; | 857 | struct fc_disc disc; |
| @@ -877,6 +887,7 @@ struct fc_lport { | |||
| 877 | u32 does_npiv:1; | 887 | u32 does_npiv:1; |
| 878 | u32 npiv_enabled:1; | 888 | u32 npiv_enabled:1; |
| 879 | u32 point_to_multipoint:1; | 889 | u32 point_to_multipoint:1; |
| 890 | u32 fdmi_enabled:1; | ||
| 880 | u32 mfs; | 891 | u32 mfs; |
| 881 | u8 max_retry_count; | 892 | u8 max_retry_count; |
| 882 | u8 max_rport_retry_count; | 893 | u8 max_rport_retry_count; |
