Files
@ bd21c8aa7237
Branch filter:
Location: vmkdrivers/vmkdrivers/src_92/include/scsi/scsi_transport_fc.h
bd21c8aa7237
35.6 KiB
text/x-chdr
ESXi-6.0.0b
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 | /*
* Portions Copyright 2008, 2010 VMware, Inc.
*/
/*
* FiberChannel transport specific attributes exported to sysfs.
*
* Copyright (c) 2003 Silicon Graphics, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* ========
*
* Copyright (C) 2004-2007 James Smart, Emulex Corporation
* Rewrite for host, target, device, and remote port attributes,
* statistics, and service functions...
*
*/
#ifndef SCSI_TRANSPORT_FC_H
#define SCSI_TRANSPORT_FC_H
#include <linux/sched.h>
#include <scsi/scsi.h>
#include <scsi/scsi_netlink.h>
struct scsi_transport_template;
/*
* FC Port definitions - Following FC HBAAPI guidelines
*
* Note: Not all binary values for the different fields match HBAAPI.
* Instead, we use densely packed ordinal values or enums.
* We get away with this as we never present the actual binary values
* externally. For sysfs, we always present the string that describes
* the value. Thus, an admin doesn't need a magic HBAAPI decoder ring
* to understand the values. The HBAAPI user-space library is free to
* convert the strings into the HBAAPI-specified binary values.
*
* Note: Not all HBAAPI-defined values are contained in the definitions
* below. Those not appropriate to an fc_host (e.g. FCP initiator) have
* been removed.
*/
/*
* fc_port_type: If you alter this, you also need to alter scsi_transport_fc.c
* (for the ascii descriptions).
*/
enum fc_port_type {
FC_PORTTYPE_UNKNOWN,
FC_PORTTYPE_OTHER,
FC_PORTTYPE_NOTPRESENT,
FC_PORTTYPE_NPORT, /* Attached to FPort */
FC_PORTTYPE_NLPORT, /* (Public) Loop w/ FLPort */
FC_PORTTYPE_LPORT, /* (Private) Loop w/o FLPort */
FC_PORTTYPE_PTP, /* Point to Point w/ another NPort */
FC_PORTTYPE_NPIV, /* VPORT based on NPIV */
};
/*
* fc_port_state: If you alter this, you also need to alter scsi_transport_fc.c
* (for the ascii descriptions).
*/
enum fc_port_state {
FC_PORTSTATE_UNKNOWN,
FC_PORTSTATE_NOTPRESENT,
FC_PORTSTATE_ONLINE,
FC_PORTSTATE_OFFLINE, /* User has taken Port Offline */
FC_PORTSTATE_BLOCKED,
FC_PORTSTATE_BYPASSED,
FC_PORTSTATE_DIAGNOSTICS,
FC_PORTSTATE_LINKDOWN,
FC_PORTSTATE_ERROR,
FC_PORTSTATE_LOOPBACK,
FC_PORTSTATE_DELETED,
};
/*
* fc_vport_state: If you alter this, you also need to alter
* scsi_transport_fc.c (for the ascii descriptions).
*/
enum fc_vport_state {
FC_VPORT_UNKNOWN,
FC_VPORT_ACTIVE,
FC_VPORT_DISABLED,
FC_VPORT_LINKDOWN,
FC_VPORT_INITIALIZING,
FC_VPORT_NO_FABRIC_SUPP,
FC_VPORT_NO_FABRIC_RSCS,
FC_VPORT_FABRIC_LOGOUT,
FC_VPORT_FABRIC_REJ_WWN,
FC_VPORT_FAILED,
};
/*
* FC Classes of Service
* Note: values are not enumerated, as they can be "or'd" together
* for reporting (e.g. report supported_classes). If you alter this list,
* you also need to alter scsi_transport_fc.c (for the ascii descriptions).
*/
#define FC_COS_UNSPECIFIED 0
#define FC_COS_CLASS1 2
#define FC_COS_CLASS2 4
#define FC_COS_CLASS3 8
#define FC_COS_CLASS4 0x10
#define FC_COS_CLASS6 0x40
/*
* FC Port Speeds
* Note: values are not enumerated, as they can be "or'd" together
* for reporting (e.g. report supported_speeds). If you alter this list,
* you also need to alter scsi_transport_fc.c (for the ascii descriptions).
*/
#define FC_PORTSPEED_UNKNOWN 0 /* Unknown - transceiver
incapable of reporting */
#define FC_PORTSPEED_1GBIT 1
#define FC_PORTSPEED_2GBIT 2
#define FC_PORTSPEED_4GBIT 4
#define FC_PORTSPEED_10GBIT 8
#define FC_PORTSPEED_8GBIT 0x10
#define FC_PORTSPEED_16GBIT 0x20
#define FC_PORTSPEED_NOT_NEGOTIATED (1 << 15) /* Speed not established */
/*
* fc_tgtid_binding_type: If you alter this, you also need to alter
* scsi_transport_fc.c (for the ascii descriptions).
*/
enum fc_tgtid_binding_type {
FC_TGTID_BIND_NONE,
FC_TGTID_BIND_BY_WWPN,
FC_TGTID_BIND_BY_WWNN,
FC_TGTID_BIND_BY_ID,
};
/*
* FC Port Roles
* Note: values are not enumerated, as they can be "or'd" together
* for reporting (e.g. report roles). If you alter this list,
* you also need to alter scsi_transport_fc.c (for the ascii descriptions).
*/
#define FC_PORT_ROLE_UNKNOWN 0x00
#define FC_PORT_ROLE_FCP_TARGET 0x01
#define FC_PORT_ROLE_FCP_INITIATOR 0x02
#define FC_PORT_ROLE_IP_PORT 0x04
/* The following are for compatibility */
#define FC_RPORT_ROLE_UNKNOWN FC_PORT_ROLE_UNKNOWN
#define FC_RPORT_ROLE_FCP_TARGET FC_PORT_ROLE_FCP_TARGET
#define FC_RPORT_ROLE_FCP_INITIATOR FC_PORT_ROLE_FCP_INITIATOR
#define FC_RPORT_ROLE_IP_PORT FC_PORT_ROLE_IP_PORT
/* Macro for use in defining Virtual Port attributes */
#define FC_VPORT_ATTR(_name,_mode,_show,_store) \
struct class_device_attribute class_device_attr_vport_##_name = \
__ATTR(_name,_mode,_show,_store)
/*
* FC Virtual Port Attributes
*
* This structure exists for each FC port is a virtual FC port. Virtual
* ports share the physical link with the Physical port. Each virtual
* ports has a unique presense on the SAN, and may be instantiated via
* NPIV, Virtual Fabrics, or via additional ALPAs. As the vport is a
* unique presense, each vport has it's own view of the fabric,
* authentication priviledge, and priorities.
*
* A virtual port may support 1 or more FC4 roles. Typically it is a
* FCP Initiator. It could be a FCP Target, or exist sole for an IP over FC
* roles. FC port attributes for the vport will be reported on any
* fc_host class object allocated for an FCP Initiator.
*
* --
*
* Fixed attributes are not expected to change. The driver is
* expected to set these values after receiving the fc_vport structure
* via the vport_create() call from the transport.
* The transport fully manages all get functions w/o driver interaction.
*
* Dynamic attributes are expected to change. The driver participates
* in all get/set operations via functions provided by the driver.
*
* Private attributes are transport-managed values. They are fully
* managed by the transport w/o driver interaction.
*/
#define FC_VPORT_SYMBOLIC_NAMELEN 64
struct fc_vport {
/* Fixed Attributes */
/* Dynamic Attributes */
/* Private (Transport-managed) Attributes */
enum fc_vport_state vport_state;
enum fc_vport_state vport_last_state;
u64 node_name;
u64 port_name;
u32 roles;
u32 vport_id; /* Admin Identifier for the vport */
enum fc_port_type vport_type;
char symbolic_name[FC_VPORT_SYMBOLIC_NAMELEN];
/* exported data */
void *dd_data; /* Used for driver-specific storage */
/* internal data */
struct Scsi_Host *shost; /* Physical Port Parent */
#if defined(__VMKLNX__)
struct Scsi_Host *vhost; /* Virtual host assigned to this vport */
#endif
unsigned int channel;
u32 number;
u8 flags;
struct list_head peers;
struct device dev;
struct work_struct vport_delete_work;
} __attribute__((aligned(sizeof(unsigned long))));
/* bit field values for struct fc_vport "flags" field: */
#define FC_VPORT_CREATING 0x01
#define FC_VPORT_DELETING 0x02
#define FC_VPORT_DELETED 0x04
#define FC_VPORT_DEL 0x06 /* Any DELETE state */
#if defined(__VMKLNX__)
#define FC_VPORT_LEGACY 0x80 /* Legacy Vport */
#endif
#define dev_to_vport(d) \
container_of(d, struct fc_vport, dev)
#define transport_class_to_vport(classdev) \
dev_to_vport(classdev->dev)
#define vport_to_shost(v) \
(v->shost)
#define vport_to_shost_channel(v) \
(v->channel)
#define vport_to_parent(v) \
(v->dev.parent)
/* Error return codes for vport_create() callback */
#define VPCERR_UNSUPPORTED -ENOSYS /* no driver/adapter
support */
#define VPCERR_BAD_WWN -ENOTUNIQ /* driver validation
of WWNs failed */
#define VPCERR_NO_FABRIC_SUPP -EOPNOTSUPP /* Fabric connection
is loop or the
Fabric Port does
not support NPIV */
/*
* fc_rport_identifiers: This set of data contains all elements
* to uniquely identify a remote FC port. The driver uses this data
* to report the existence of a remote FC port in the topology. Internally,
* the transport uses this data for attributes and to manage consistent
* target id bindings.
*/
struct fc_rport_identifiers {
u64 node_name;
u64 port_name;
u32 port_id;
u32 roles;
};
/* Macro for use in defining Remote Port attributes */
#define FC_RPORT_ATTR(_name,_mode,_show,_store) \
struct class_device_attribute class_device_attr_rport_##_name = \
__ATTR(_name,_mode,_show,_store)
/*
* FC Remote Port Attributes
*
* This structure exists for each remote FC port that a LLDD notifies
* the subsystem of. A remote FC port may or may not be a SCSI Target,
* also be a SCSI initiator, IP endpoint, etc. As such, the remote
* port is considered a separate entity, independent of "role" (such
* as scsi target).
*
* --
*
* Attributes are based on HBAAPI V2.0 definitions. Only those
* attributes that are determinable by the local port (aka Host)
* are contained.
*
* Fixed attributes are not expected to change. The driver is
* expected to set these values after successfully calling
* fc_remote_port_add(). The transport fully manages all get functions
* w/o driver interaction.
*
* Dynamic attributes are expected to change. The driver participates
* in all get/set operations via functions provided by the driver.
*
* Private attributes are transport-managed values. They are fully
* managed by the transport w/o driver interaction.
*/
struct fc_rport { /* aka fc_starget_attrs */
/* Fixed Attributes */
u32 maxframe_size;
u32 supported_classes;
/* Dynamic Attributes */
u32 dev_loss_tmo; /* Remote Port loss timeout in seconds. */
/* Private (Transport-managed) Attributes */
u64 node_name;
u64 port_name;
u32 port_id;
u32 roles;
enum fc_port_state port_state; /* Will only be ONLINE or UNKNOWN */
u32 scsi_target_id;
u32 fast_io_fail_tmo;
/* exported data */
void *dd_data; /* Used for driver-specific storage */
/* internal data */
unsigned int channel;
u32 number;
u8 flags;
struct list_head peers;
struct device dev;
#if defined(__VMKLNX__)
struct delayed_work dev_loss_work;
#else /* !defined(__VMKLNX__) */
struct work_struct dev_loss_work;
#endif /* defined(__VMKLNX__) */
struct work_struct scan_work;
#if defined(__VMKLNX__)
struct delayed_work fail_io_work;
#else /* !defined(__VMKLNX__) */
struct work_struct fail_io_work;
#endif /* defined(__VMKLNX__) */
struct work_struct stgt_delete_work;
struct work_struct rport_delete_work;
} __attribute__((aligned(sizeof(unsigned long))));
/* bit field values for struct fc_rport "flags" field: */
#define FC_RPORT_DEVLOSS_PENDING 0x01
#define FC_RPORT_SCAN_PENDING 0x02
#define dev_to_rport(d) \
container_of(d, struct fc_rport, dev)
#define transport_class_to_rport(classdev) \
dev_to_rport(classdev->dev)
/**
* rport_to_shost - find the shost, given a rport
* @r: a pointer to struct fc_rport
*
* Given @r as as an argument to this macro, it returns a pointer to its
* corresponding struct Scsi_Host.
*
* RETURN VALUE:
* Returns a pointer to struct Scsi_Host if successful. Returns NULL otherwise.
*
*/
/* _VMKLNX_CODECHECK_: rport_to_shost */
#define rport_to_shost(r) \
dev_to_shost(r->dev.parent)
/*
* FC SCSI Target Attributes
*
* The SCSI Target is considered an extention of a remote port (as
* a remote port can be more than a SCSI Target). Within the scsi
* subsystem, we leave the Target as a separate entity. Doing so
* provides backward compatibility with prior FC transport api's,
* and lets remote ports be handled entirely within the FC transport
* and independently from the scsi subsystem. The drawback is that
* some data will be duplicated.
*/
struct fc_starget_attrs { /* aka fc_target_attrs */
/* Dynamic Attributes */
u64 node_name;
u64 port_name;
u32 port_id;
};
/**
* fc_starget_node_name - Returns FC host's starget node name
* @x: pointer to the scsi host
*
* Returns FC host's starget node name
*
* SYNOPSIS:
* #define fc_starget_node_name(x)
*
* RETURN VALUE:
* FC host's starget node name
*
*/
/* _VMKLNX_CODECHECK_: fc_starget_node_name */
#define fc_starget_node_name(x) \
(((struct fc_starget_attrs *)&(x)->starget_data)->node_name)
/**
* fc_starget_port_name - Returns FC host's starget port name
* @x: pointer to the scsi host
*
* Returns FC host's starget port name
*
* SYNOPSIS:
* #define fc_starget_port_name(x)
*
* RETURN VALUE:
* FC host's starget port name
*
*/
/* _VMKLNX_CODECHECK_: fc_starget_port_name */
#define fc_starget_port_name(x) \
(((struct fc_starget_attrs *)&(x)->starget_data)->port_name)
/**
* fc_starget_port_id - Returns FC host's starget port id
* @x: pointer to the scsi host
*
* Returns FC host's starget port id
*
* SYNOPSIS:
* #define fc_starget_port_id(x)
*
* RETURN VALUE:
* FC host's starget port id
*
*/
/* _VMKLNX_CODECHECK_: fc_starget_port_id */
#define fc_starget_port_id(x) \
(((struct fc_starget_attrs *)&(x)->starget_data)->port_id)
/**
* starget_to_rport - Get the FC remote port of a SCSI target's parent
* @s: SCSI target
*
* If the SCSI target's parent is a fibre channel remote port, get that
* remote port.
*
* SYNOPSIS:
* #define starget_to_rport(s)
*
* RETURN VALUE:
* The remote port on success, NULL on failure
*
*/
/* _VMKLNX_CODECHECK_: starget_to_rport */
#define starget_to_rport(s) \
scsi_is_fc_rport(s->dev.parent) ? dev_to_rport(s->dev.parent) : NULL
/*
* FC Local Port (Host) Statistics
*/
/* FC Statistics - Following FC HBAAPI v2.0 guidelines */
struct fc_host_statistics {
/* port statistics */
u64 seconds_since_last_reset;
u64 tx_frames;
u64 tx_words;
u64 rx_frames;
u64 rx_words;
u64 lip_count;
u64 nos_count;
u64 error_frames;
u64 dumped_frames;
u64 link_failure_count;
u64 loss_of_sync_count;
u64 loss_of_signal_count;
u64 prim_seq_protocol_err_count;
u64 invalid_tx_word_count;
u64 invalid_crc_count;
/* fc4 statistics (only FCP supported currently) */
u64 fcp_input_requests;
u64 fcp_output_requests;
u64 fcp_control_requests;
u64 fcp_input_megabytes;
u64 fcp_output_megabytes;
};
/*
* FC Event Codes - Polled and Async, following FC HBAAPI v2.0 guidelines
*/
/*
* fc_host_event_code: If you alter this, you also need to alter
* scsi_transport_fc.c (for the ascii descriptions).
*/
enum fc_host_event_code {
FCH_EVT_LIP = 0x1,
FCH_EVT_LINKUP = 0x2,
FCH_EVT_LINKDOWN = 0x3,
FCH_EVT_LIPRESET = 0x4,
FCH_EVT_RSCN = 0x5,
FCH_EVT_ADAPTER_CHANGE = 0x103,
FCH_EVT_PORT_UNKNOWN = 0x200,
FCH_EVT_PORT_OFFLINE = 0x201,
FCH_EVT_PORT_ONLINE = 0x202,
FCH_EVT_PORT_FABRIC = 0x204,
FCH_EVT_LINK_UNKNOWN = 0x500,
FCH_EVT_VENDOR_UNIQUE = 0xffff,
};
/*
* FC Local Port (Host) Attributes
*
* Attributes are based on HBAAPI V2.0 definitions.
* Note: OSDeviceName is determined by user-space library
*
* Fixed attributes are not expected to change. The driver is
* expected to set these values after successfully calling scsi_add_host().
* The transport fully manages all get functions w/o driver interaction.
*
* Dynamic attributes are expected to change. The driver participates
* in all get/set operations via functions provided by the driver.
*
* Private attributes are transport-managed values. They are fully
* managed by the transport w/o driver interaction.
*/
#define FC_FC4_LIST_SIZE 32
#define FC_SYMBOLIC_NAME_SIZE 256
#define FC_VERSION_STRING_SIZE 64
#define FC_SERIAL_NUMBER_SIZE 80
struct fc_host_attrs {
/* Fixed Attributes */
u64 node_name;
u64 port_name;
u64 permanent_port_name;
u32 supported_classes;
u8 supported_fc4s[FC_FC4_LIST_SIZE];
u32 supported_speeds;
u32 maxframe_size;
u16 max_npiv_vports;
char serial_number[FC_SERIAL_NUMBER_SIZE];
/* Dynamic Attributes */
u32 port_id;
enum fc_port_type port_type;
enum fc_port_state port_state;
u8 active_fc4s[FC_FC4_LIST_SIZE];
u32 speed;
u64 fabric_name;
char symbolic_name[FC_SYMBOLIC_NAME_SIZE];
char system_hostname[FC_SYMBOLIC_NAME_SIZE];
/* Private (Transport-managed) Attributes */
enum fc_tgtid_binding_type tgtid_bind_type;
/* internal data */
struct list_head rports;
struct list_head rport_bindings;
struct list_head vports;
u32 next_rport_number;
u32 next_target_id;
u32 next_vport_number;
u16 npiv_vports_inuse;
/* work queues for rport state manipulation */
char work_q_name[KOBJ_NAME_LEN];
struct workqueue_struct *work_q;
char devloss_work_q_name[KOBJ_NAME_LEN];
struct workqueue_struct *devloss_work_q;
#if defined(__VMKLNX__)
/*
* Used for storing fc adapter status
*/
atomic_t vmklnx_flag;
/*
* Add place for future use
*/
void *cna_ops;
#endif
};
/**
* shost_to_fc_host - Return shost_data element of scsi host
* @x: pointer to the scsi host
*
* Returns the pointer to struct fc_host_attrs associated with the scsi host
*
* SYNOPSIS:
* #define shost_to_fc_host(x)
*
* RETURN VALUE:
* pointer to struct fc_host_attrs
*
*/
/* _VMKLNX_CODECHECK_: shost_to_fc_host */
#define shost_to_fc_host(x) \
((struct fc_host_attrs *)(x)->shost_data)
/**
* fc_host_node_name - Returns FC host's node name
* @x: pointer to the scsi host
*
* Returns FC host's node name
*
* SYNOPSIS:
* #define fc_host_node_name(x)
*
* RETURN VALUE:
* FC host's node name
*
*/
/* _VMKLNX_CODECHECK_: fc_host_node_name */
#define fc_host_node_name(x) \
(((struct fc_host_attrs *)(x)->shost_data)->node_name)
/**
* fc_host_port_name - Returns FC host's port name
* @x: pointer to the scsi host
*
* Returns FC host's port name
*
* SYNOPSIS:
* #define fc_host_port_name(x)
*
* RETURN VALUE:
* FC host's port name
*
*/
/* _VMKLNX_CODECHECK_: fc_host_port_name */
#define fc_host_port_name(x) \
(((struct fc_host_attrs *)(x)->shost_data)->port_name)
/**
* fc_host_permanent_port_name - Returns FC host's permanent port name
* @x: pointer to the scsi host
*
* Returns FC host's permanent port name
*
* SYNOPSIS:
* #define fc_host_permanent_port_name(x)
*
* RETURN VALUE:
* FC host's permanent port name
*
*/
/* _VMKLNX_CODECHECK_: fc_host_permanent_port_name */
#define fc_host_permanent_port_name(x) \
(((struct fc_host_attrs *)(x)->shost_data)->permanent_port_name)
/**
* fc_host_supported_classes - Returns FC host's supported FC classes
* @x: pointer to the scsi host
*
* Returns FC host's supported FC classes
*
* SYNOPSIS:
* #define fc_host_supported_classes(x)
*
* RETURN VALUE:
* FC host's supported FC classes
*
*/
/* _VMKLNX_CODECHECK_: fc_host_supported_classes */
#define fc_host_supported_classes(x) \
(((struct fc_host_attrs *)(x)->shost_data)->supported_classes)
/**
* fc_host_supported_fc4s - Returns the array of FC host's supported fc4s list
* @x: pointer to the scsi host
*
* Returns the array of FC host's supported fc4s list
*
* SYNOPSIS:
* #define fc_host_supported_fc4s(x)
*
* RETURN VALUE:
* Returns the array of FC host's supported fc4s list
*
*/
/* _VMKLNX_CODECHECK_: fc_host_supported_fc4s */
#define fc_host_supported_fc4s(x) \
(((struct fc_host_attrs *)(x)->shost_data)->supported_fc4s)
/**
* fc_host_supported_speeds - Returns FC host's supported speeds
* @x: pointer to the scsi host
*
* Returns FC host's supported speeds
*
* SYNOPSIS:
* #define fc_host_supported_speeds(x)
*
* RETURN VALUE:
* FC host's supported speeds
*
*/
/* _VMKLNX_CODECHECK_: fc_host_supported_speeds */
#define fc_host_supported_speeds(x) \
(((struct fc_host_attrs *)(x)->shost_data)->supported_speeds)
/**
* fc_host_maxframe_size - Returns FC host's maximum supported frame size
* @x: pointer to the scsi host
*
* Returns FC host's maximum supported frame size
*
* SYNOPSIS:
* #define fc_host_maxframe_size(x)
*
* RETURN VALUE:
* FC host's maximum supported frame size
*
*/
/* _VMKLNX_CODECHECK_: fc_host_maxframe_size */
#define fc_host_maxframe_size(x) \
(((struct fc_host_attrs *)(x)->shost_data)->maxframe_size)
/**
* fc_host_max_npiv_vports - Returns FC host's maximum supported npiv vports
* @x: pointer to the scsi host
*
* Returns FC host's maximum supported npiv vports
*
* SYNOPSIS:
* #define fc_host_max_npiv_vports(x)
*
* RETURN VALUE:
* FC host's maximum supported npiv vports
*
*/
/* _VMKLNX_CODECHECK_: fc_host_max_npiv_vports */
#define fc_host_max_npiv_vports(x) \
(((struct fc_host_attrs *)(x)->shost_data)->max_npiv_vports)
/**
* fc_host_serial_number - Returns FC host's serial number
* @x: pointer to the scsi host
*
* Returns FC host's serial number
*
* SYNOPSIS:
* #define fc_host_serial_number(x)
*
* RETURN VALUE:
* FC host's serial number
*
*/
/* _VMKLNX_CODECHECK_: fc_host_serial_number */
#define fc_host_serial_number(x) \
(((struct fc_host_attrs *)(x)->shost_data)->serial_number)
/**
* fc_host_port_id - Returns FC host's port id
* @x: pointer to the scsi host
*
* Returns FC host's port id
*
* SYNOPSIS:
* #define fc_host_port_id(x)
*
* RETURN VALUE:
* FC host's port id
*
*/
/* _VMKLNX_CODECHECK_: fc_host_port_id */
#define fc_host_port_id(x) \
(((struct fc_host_attrs *)(x)->shost_data)->port_id)
/**
* fc_host_port_type - Returns FC host's port type
* @x: pointer to the scsi host
*
* Returns FC host's port type
*
* SYNOPSIS:
* #define fc_host_port_type(x)
*
* RETURN VALUE:
* FC host's port type
*
*/
/* _VMKLNX_CODECHECK_: fc_host_port_type */
#define fc_host_port_type(x) \
(((struct fc_host_attrs *)(x)->shost_data)->port_type)
/**
* fc_host_port_state - Returns FC host's port state
* @x: pointer to the scsi host
*
* Returns FC host's port state
*
* SYNOPSIS:
* #define fc_host_port_state(x)
*
* RETURN VALUE:
* FC host's port state
*
*/
/* _VMKLNX_CODECHECK_: fc_host_port_state */
#define fc_host_port_state(x) \
(((struct fc_host_attrs *)(x)->shost_data)->port_state)
/**
* fc_host_active_fc4s - Returns FC host's active_fc4s array
* @x: pointer to the scsi host
*
* Returns FC host's active_fc4s array
*
* SYNOPSIS:
* #define fc_host_active_fc4s(x)
*
* RETURN VALUE:
* FC host's active_fc4s array
*
*/
/* _VMKLNX_CODECHECK_: fc_host_active_fc4s */
#define fc_host_active_fc4s(x) \
(((struct fc_host_attrs *)(x)->shost_data)->active_fc4s)
/**
* fc_host_speed - Returns FC host's speed
* @x: pointer to the scsi host
*
* Returns FC host's speed
*
* SYNOPSIS:
* #define fc_host_speed(x)
*
* RETURN VALUE:
* FC host's speed
*
*/
/* _VMKLNX_CODECHECK_: fc_host_speed */
#define fc_host_speed(x) \
(((struct fc_host_attrs *)(x)->shost_data)->speed)
/**
* fc_host_fabric_name - Returns FC host's fabric_name
* @x: pointer to the scsi host
*
* Returns FC host's fabric_name
*
* SYNOPSIS:
* #define fc_host_fabric_name(x)
*
* RETURN VALUE:
* FC host's fabric_name
*
*/
/* _VMKLNX_CODECHECK_: fc_host_fabric_name */
#define fc_host_fabric_name(x) \
(((struct fc_host_attrs *)(x)->shost_data)->fabric_name)
/**
* fc_host_symbolic_name - Returns FC host's symbolic_name
* @x: pointer to the scsi host
*
* Returns the string of FC host's symbolic_name
*
* SYNOPSIS:
* #define fc_host_symbolic_name(x)
*
* RETURN VALUE:
* The string of FC host's symbolic_name
*
*/
/* _VMKLNX_CODECHECK_: fc_host_symbolic_name */
#define fc_host_symbolic_name(x) \
(((struct fc_host_attrs *)(x)->shost_data)->symbolic_name)
/**
* fc_host_system_hostname - Returns FC host's system_hostname
* @x: pointer to the scsi host
*
* Returns the string of FC host's system_hostname
*
* SYNOPSIS:
* #define fc_host_system_hostname(x)
*
* RETURN VALUE:
* The string of FC host's system_hostname
*
*/
/* _VMKLNX_CODECHECK_: fc_host_system_hostname */
#define fc_host_system_hostname(x) \
(((struct fc_host_attrs *)(x)->shost_data)->system_hostname)
/**
* fc_host_tgtid_bind_type - Returns FC host's tgtid binding type
* @x: pointer to the scsi host
*
* Returns FC host's tgtid binding type
*
* SYNOPSIS:
* #define fc_host_tgtid_bind_type(x)
*
* RETURN VALUE:
* FC host's tgtid binding type
*
*/
/* _VMKLNX_CODECHECK_: fc_host_tgtid_bind_type */
#define fc_host_tgtid_bind_type(x) \
(((struct fc_host_attrs *)(x)->shost_data)->tgtid_bind_type)
/**
* fc_host_rports - Returns FC host's rports list
* @x: pointer to the scsi host
*
* Returns pointer to FC host's rports list
*
* SYNOPSIS:
* #define fc_host_rports(x)
*
* RETURN VALUE:
* Pointer to FC host's rports list
*
*/
/* _VMKLNX_CODECHECK_: fc_host_rports */
#define fc_host_rports(x) \
(((struct fc_host_attrs *)(x)->shost_data)->rports)
/**
* fc_host_rport_bindings - Returns FC host's rport_bindings list
* @x: pointer to the scsi host
*
* Returns pointer to FC host's rport_bindings list
*
* SYNOPSIS:
* #define fc_host_rport_bindings(x)
*
* RETURN VALUE:
* Pointer to FC host's rport_bindings list
*
*/
/* _VMKLNX_CODECHECK_: fc_host_rport_bindings */
#define fc_host_rport_bindings(x) \
(((struct fc_host_attrs *)(x)->shost_data)->rport_bindings)
/**
* fc_host_vports - Returns FC host's vports list
* @x: pointer to the scsi host
*
* Returns pointer to FC host's vports list
*
* SYNOPSIS:
* #define fc_host_vports(x)
*
* RETURN VALUE:
* Pointer to FC host's vports list
*
*/
/* _VMKLNX_CODECHECK_: fc_host_vports */
#define fc_host_vports(x) \
(((struct fc_host_attrs *)(x)->shost_data)->vports)
/**
* fc_host_next_rport_number - Returns FC host's next rport number
* @x: pointer to the scsi host
*
* Returns FC host's next rport number
*
* SYNOPSIS:
* #define fc_host_next_rport_number(x)
*
* RETURN VALUE:
* FC host's next rport number
*
*/
/* _VMKLNX_CODECHECK_: fc_host_next_rport_number */
#define fc_host_next_rport_number(x) \
(((struct fc_host_attrs *)(x)->shost_data)->next_rport_number)
/**
* fc_host_next_target_id - Returns FC host's next target id
* @x: pointer to the scsi host
*
* Returns FC host's next target id
*
* SYNOPSIS:
* #define fc_host_next_target_id(x)
*
* RETURN VALUE:
* FC host's next target id
*
*/
/* _VMKLNX_CODECHECK_: fc_host_next_target_id */
#define fc_host_next_target_id(x) \
(((struct fc_host_attrs *)(x)->shost_data)->next_target_id)
/**
* fc_host_next_vport_number - Returns FC host's next vport number
* @x: pointer to the scsi host
*
* Returns FC host's next vport number
*
* SYNOPSIS:
* #define fc_host_next_vport_number(x)
*
* RETURN VALUE:
* FC host's next vport number
*
*/
/* _VMKLNX_CODECHECK_: fc_host_next_vport_number */
#define fc_host_next_vport_number(x) \
(((struct fc_host_attrs *)(x)->shost_data)->next_vport_number)
/**
* fc_host_npiv_vports_inuse - Returns FC host's attribute npiv_vports_inuse
* @x: pointer to the scsi host
*
* Returns FC host's attribute npiv_vports_inuse
*
* SYNOPSIS:
* #define fc_host_npiv_vports_inuse(x)
*
* RETURN VALUE:
* FC host's attribute npiv_vports_inuse
*
*/
/* _VMKLNX_CODECHECK_: fc_host_npiv_vports_inuse */
#define fc_host_npiv_vports_inuse(x) \
(((struct fc_host_attrs *)(x)->shost_data)->npiv_vports_inuse)
/**
* fc_host_work_q_name - Returns FC host's work_q name
* @x: pointer to the scsi host
*
* Returns the string of FC host's work_q name
*
* SYNOPSIS:
* #define fc_host_work_q_name(x)
*
* RETURN VALUE:
* The string of FC host's work_q name
*
*/
/* _VMKLNX_CODECHECK_: fc_host_work_q_name */
#define fc_host_work_q_name(x) \
(((struct fc_host_attrs *)(x)->shost_data)->work_q_name)
/**
* fc_host_work_q - Returns pointer to FC host's work_q
* @x: pointer to the scsi host
*
* Returns pointer to FC host's work_q
*
* SYNOPSIS:
* #define fc_host_work_q(x)
*
* RETURN VALUE:
* Pointer to FC host's work_q
*
*/
/* _VMKLNX_CODECHECK_: fc_host_work_q */
#define fc_host_work_q(x) \
(((struct fc_host_attrs *)(x)->shost_data)->work_q)
/**
* fc_host_devloss_work_q_name - Returns the name of FC host's devloss_work_q
* @x: pointer to the scsi host
*
* Returns the name of FC host's devloss_work_q
*
* SYNOPSIS:
* #define fc_host_devloss_work_q_name(x)
*
* RETURN VALUE:
* The string of FC host's devloss_work_q name
*
*/
/* _VMKLNX_CODECHECK_: fc_host_devloss_work_q_name */
#define fc_host_devloss_work_q_name(x) \
(((struct fc_host_attrs *)(x)->shost_data)->devloss_work_q_name)
/**
* fc_host_devloss_work_q - Returns FC host's devloss_work_q
* @x: pointer to the scsi host
*
* Returns FC host's devloss_work_q
*
* SYNOPSIS:
* #define fc_host_devloss_work_q(x)
*
* RETURN VALUE:
* Pointer to FC host's devloss_work_q
*
*/
/* _VMKLNX_CODECHECK_: fc_host_devloss_work_q */
#define fc_host_devloss_work_q(x) \
(((struct fc_host_attrs *)(x)->shost_data)->devloss_work_q)
/* The functions by which the transport class and the driver communicate */
struct fc_function_template {
void (*get_rport_dev_loss_tmo)(struct fc_rport *);
void (*set_rport_dev_loss_tmo)(struct fc_rport *, u32);
void (*get_starget_node_name)(struct scsi_target *);
void (*get_starget_port_name)(struct scsi_target *);
void (*get_starget_port_id)(struct scsi_target *);
void (*get_host_port_id)(struct Scsi_Host *);
void (*get_host_port_type)(struct Scsi_Host *);
void (*get_host_port_state)(struct Scsi_Host *);
void (*get_host_active_fc4s)(struct Scsi_Host *);
void (*get_host_speed)(struct Scsi_Host *);
void (*get_host_fabric_name)(struct Scsi_Host *);
void (*get_host_symbolic_name)(struct Scsi_Host *);
void (*set_host_system_hostname)(struct Scsi_Host *);
struct fc_host_statistics * (*get_fc_host_stats)(struct Scsi_Host *);
void (*reset_fc_host_stats)(struct Scsi_Host *);
int (*issue_fc_host_lip)(struct Scsi_Host *);
void (*dev_loss_tmo_callbk)(struct fc_rport *);
void (*terminate_rport_io)(struct fc_rport *);
void (*set_vport_symbolic_name)(struct fc_vport *);
int (*vport_create)(struct fc_vport *, bool);
int (*vport_disable)(struct fc_vport *, bool);
int (*vport_delete)(struct fc_vport *);
/* allocation lengths for host-specific data */
u32 dd_fcrport_size;
u32 dd_fcvport_size;
/*
* The driver sets these to tell the transport class it
* wants the attributes displayed in sysfs. If the show_ flag
* is not set, the attribute will be private to the transport
* class
*/
/* remote port fixed attributes */
unsigned long show_rport_maxframe_size:1;
unsigned long show_rport_supported_classes:1;
unsigned long show_rport_dev_loss_tmo:1;
/*
* target dynamic attributes
* These should all be "1" if the driver uses the remote port
* add/delete functions (so attributes reflect rport values).
*/
unsigned long show_starget_node_name:1;
unsigned long show_starget_port_name:1;
unsigned long show_starget_port_id:1;
/* host fixed attributes */
unsigned long show_host_node_name:1;
unsigned long show_host_port_name:1;
unsigned long show_host_permanent_port_name:1;
unsigned long show_host_supported_classes:1;
unsigned long show_host_supported_fc4s:1;
unsigned long show_host_supported_speeds:1;
unsigned long show_host_maxframe_size:1;
unsigned long show_host_serial_number:1;
/* host dynamic attributes */
unsigned long show_host_port_id:1;
unsigned long show_host_port_type:1;
unsigned long show_host_port_state:1;
unsigned long show_host_active_fc4s:1;
unsigned long show_host_speed:1;
unsigned long show_host_fabric_name:1;
unsigned long show_host_symbolic_name:1;
unsigned long show_host_system_hostname:1;
};
/**
* fc_remote_port_chkready - called to validate the remote port state
* prior to initiating I/O to the port
* @rport: remote port to be checked
*
* Called to validate the remote port state
* prior to initiating I/O to the port
*
* RETURN VALUE:
* Returns a scsi result code that can be returned by the LLDD
*
**/
/* _VMKLNX_CODECHECK_: fc_remote_port_chkready */
static inline int
fc_remote_port_chkready(struct fc_rport *rport)
{
int result;
switch (rport->port_state) {
case FC_PORTSTATE_ONLINE:
if (rport->roles & FC_PORT_ROLE_FCP_TARGET)
result = 0;
else if (rport->flags & FC_RPORT_DEVLOSS_PENDING)
result = DID_IMM_RETRY << 16;
else
result = DID_NO_CONNECT << 16;
break;
case FC_PORTSTATE_BLOCKED:
result = DID_IMM_RETRY << 16;
break;
default:
result = DID_NO_CONNECT << 16;
break;
}
return result;
}
/**
* wwn_to_u64 - convert a wwn into u64 represenation
* @wwn: a pointer to the wwn to be converted
*
* Convert an 8-byte wwn into u64 format.
*
* RETURN VALUE:
* This function returns an 8-byte wwn into u64 format
* where wwn[0] is the MSB and wwn[7] is the LSB of the u64 value.
*
*/
/* _VMKLNX_CODECHECK_: wwn_to_u64 */
static inline u64 wwn_to_u64(u8 *wwn)
{
return (u64)wwn[0] << 56 | (u64)wwn[1] << 48 |
(u64)wwn[2] << 40 | (u64)wwn[3] << 32 |
(u64)wwn[4] << 24 | (u64)wwn[5] << 16 |
(u64)wwn[6] << 8 | (u64)wwn[7];
}
/**
* u64_to_wwn - convert wwid to wwn
* @inm: 64 bit wwid
* @wwn: pointer to 8 byte buffer to recieve wwn
*
* Convert world wide id to world wide name
* return value : none
*/
/* _VMKLNX_CODECHECK_: u64_to_wwn */
static inline void u64_to_wwn(u64 inm, u8 *wwn)
{
wwn[0] = (inm >> 56) & 0xff;
wwn[1] = (inm >> 48) & 0xff;
wwn[2] = (inm >> 40) & 0xff;
wwn[3] = (inm >> 32) & 0xff;
wwn[4] = (inm >> 24) & 0xff;
wwn[5] = (inm >> 16) & 0xff;
wwn[6] = (inm >> 8) & 0xff;
wwn[7] = inm & 0xff;
}
/**
* fc_vport_set_state - Set a vport's state
* @vport: virtual port whose state is changing
* @new_state: new state
*
* Set a vport's state. Saves the old state, excepting the transitory states
* of initializing and sending the ELS traffic to instantiate the vport on
* the link.
*
* Note:
* This function assumes the driver has surrounded this with the proper locking
* to ensure a coherent state change.
*
* RETURN VALUE:
* None
*
*/
/* _VMKLNX_CODECHECK_: fc_vport_set_state */
static inline void
fc_vport_set_state(struct fc_vport *vport, enum fc_vport_state new_state)
{
if ((new_state != FC_VPORT_UNKNOWN) &&
(new_state != FC_VPORT_INITIALIZING))
vport->vport_last_state = vport->vport_state;
vport->vport_state = new_state;
}
struct scsi_transport_template *fc_attach_transport(
struct fc_function_template *);
void fc_release_transport(struct scsi_transport_template *);
void fc_remove_host(struct Scsi_Host *);
struct fc_rport *fc_remote_port_add(struct Scsi_Host *shost,
int channel, struct fc_rport_identifiers *ids);
void fc_remote_port_delete(struct fc_rport *rport);
void fc_remote_port_rolechg(struct fc_rport *rport, u32 roles);
int scsi_is_fc_rport(const struct device *);
u32 fc_get_event_number(void);
void fc_host_post_event(struct Scsi_Host *shost, u32 event_number,
enum fc_host_event_code event_code, u32 event_data);
void fc_host_post_vendor_event(struct Scsi_Host *shost, u32 event_number,
u32 data_len, char * data_buf, u64 vendor_id);
/* Note: when specifying vendor_id to fc_host_post_vendor_event()
* be sure to read the Vendor Type and ID formatting requirements
* specified in scsi_netlink.h
*/
#endif /* SCSI_TRANSPORT_FC_H */
|