0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef SCSI_TRANSPORT_FC_H
0011 #define SCSI_TRANSPORT_FC_H
0012
0013 #include <linux/sched.h>
0014 #include <linux/bsg-lib.h>
0015 #include <asm/unaligned.h>
0016 #include <scsi/scsi.h>
0017 #include <scsi/scsi_netlink.h>
0018 #include <scsi/scsi_host.h>
0019
0020 struct scsi_transport_template;
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042 enum fc_port_type {
0043 FC_PORTTYPE_UNKNOWN,
0044 FC_PORTTYPE_OTHER,
0045 FC_PORTTYPE_NOTPRESENT,
0046 FC_PORTTYPE_NPORT,
0047 FC_PORTTYPE_NLPORT,
0048 FC_PORTTYPE_LPORT,
0049 FC_PORTTYPE_PTP,
0050 FC_PORTTYPE_NPIV,
0051 };
0052
0053
0054
0055
0056
0057
0058 enum fc_port_state {
0059 FC_PORTSTATE_UNKNOWN,
0060 FC_PORTSTATE_NOTPRESENT,
0061 FC_PORTSTATE_ONLINE,
0062 FC_PORTSTATE_OFFLINE,
0063 FC_PORTSTATE_BLOCKED,
0064 FC_PORTSTATE_BYPASSED,
0065 FC_PORTSTATE_DIAGNOSTICS,
0066 FC_PORTSTATE_LINKDOWN,
0067 FC_PORTSTATE_ERROR,
0068 FC_PORTSTATE_LOOPBACK,
0069 FC_PORTSTATE_DELETED,
0070 FC_PORTSTATE_MARGINAL,
0071 };
0072
0073
0074
0075
0076
0077
0078 enum fc_vport_state {
0079 FC_VPORT_UNKNOWN,
0080 FC_VPORT_ACTIVE,
0081 FC_VPORT_DISABLED,
0082 FC_VPORT_LINKDOWN,
0083 FC_VPORT_INITIALIZING,
0084 FC_VPORT_NO_FABRIC_SUPP,
0085 FC_VPORT_NO_FABRIC_RSCS,
0086 FC_VPORT_FABRIC_LOGOUT,
0087 FC_VPORT_FABRIC_REJ_WWN,
0088 FC_VPORT_FAILED,
0089 };
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099 #define FC_COS_UNSPECIFIED 0
0100 #define FC_COS_CLASS1 2
0101 #define FC_COS_CLASS2 4
0102 #define FC_COS_CLASS3 8
0103 #define FC_COS_CLASS4 0x10
0104 #define FC_COS_CLASS6 0x40
0105
0106
0107
0108
0109
0110
0111
0112 #define FC_PORTSPEED_UNKNOWN 0
0113
0114 #define FC_PORTSPEED_1GBIT 1
0115 #define FC_PORTSPEED_2GBIT 2
0116 #define FC_PORTSPEED_10GBIT 4
0117 #define FC_PORTSPEED_4GBIT 8
0118 #define FC_PORTSPEED_8GBIT 0x10
0119 #define FC_PORTSPEED_16GBIT 0x20
0120 #define FC_PORTSPEED_32GBIT 0x40
0121 #define FC_PORTSPEED_20GBIT 0x80
0122 #define FC_PORTSPEED_40GBIT 0x100
0123 #define FC_PORTSPEED_50GBIT 0x200
0124 #define FC_PORTSPEED_100GBIT 0x400
0125 #define FC_PORTSPEED_25GBIT 0x800
0126 #define FC_PORTSPEED_64GBIT 0x1000
0127 #define FC_PORTSPEED_128GBIT 0x2000
0128 #define FC_PORTSPEED_256GBIT 0x4000
0129 #define FC_PORTSPEED_NOT_NEGOTIATED (1 << 15)
0130
0131
0132
0133
0134
0135 enum fc_tgtid_binding_type {
0136 FC_TGTID_BIND_NONE,
0137 FC_TGTID_BIND_BY_WWPN,
0138 FC_TGTID_BIND_BY_WWNN,
0139 FC_TGTID_BIND_BY_ID,
0140 };
0141
0142
0143
0144
0145
0146
0147
0148 #define FC_PORT_ROLE_UNKNOWN 0x00
0149 #define FC_PORT_ROLE_FCP_TARGET 0x01
0150 #define FC_PORT_ROLE_FCP_INITIATOR 0x02
0151 #define FC_PORT_ROLE_IP_PORT 0x04
0152 #define FC_PORT_ROLE_FCP_DUMMY_INITIATOR 0x08
0153 #define FC_PORT_ROLE_NVME_INITIATOR 0x10
0154 #define FC_PORT_ROLE_NVME_TARGET 0x20
0155 #define FC_PORT_ROLE_NVME_DISCOVERY 0x40
0156
0157
0158 #define FC_RPORT_ROLE_UNKNOWN FC_PORT_ROLE_UNKNOWN
0159 #define FC_RPORT_ROLE_FCP_TARGET FC_PORT_ROLE_FCP_TARGET
0160 #define FC_RPORT_ROLE_FCP_INITIATOR FC_PORT_ROLE_FCP_INITIATOR
0161 #define FC_RPORT_ROLE_IP_PORT FC_PORT_ROLE_IP_PORT
0162
0163
0164
0165 #define FC_VPORT_ATTR(_name,_mode,_show,_store) \
0166 struct device_attribute dev_attr_vport_##_name = \
0167 __ATTR(_name,_mode,_show,_store)
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180 #define FC_VPORT_SYMBOLIC_NAMELEN 64
0181 struct fc_vport_identifiers {
0182 u64 node_name;
0183 u64 port_name;
0184 u32 roles;
0185 bool disable;
0186 enum fc_port_type vport_type;
0187 char symbolic_name[FC_VPORT_SYMBOLIC_NAMELEN];
0188 };
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219 struct fc_vport {
0220
0221
0222
0223
0224
0225 enum fc_vport_state vport_state;
0226 enum fc_vport_state vport_last_state;
0227 u64 node_name;
0228 u64 port_name;
0229 u32 roles;
0230 u32 vport_id;
0231 enum fc_port_type vport_type;
0232 char symbolic_name[FC_VPORT_SYMBOLIC_NAMELEN];
0233
0234
0235 void *dd_data;
0236
0237
0238 struct Scsi_Host *shost;
0239 unsigned int channel;
0240 u32 number;
0241 u8 flags;
0242 struct list_head peers;
0243 struct device dev;
0244 struct work_struct vport_delete_work;
0245 } __attribute__((aligned(sizeof(unsigned long))));
0246
0247
0248 #define FC_VPORT_CREATING 0x01
0249 #define FC_VPORT_DELETING 0x02
0250 #define FC_VPORT_DELETED 0x04
0251 #define FC_VPORT_DEL 0x06
0252
0253 #define dev_to_vport(d) \
0254 container_of(d, struct fc_vport, dev)
0255 #define transport_class_to_vport(dev) \
0256 dev_to_vport(dev->parent)
0257 #define vport_to_shost(v) \
0258 (v->shost)
0259 #define vport_to_shost_channel(v) \
0260 (v->channel)
0261 #define vport_to_parent(v) \
0262 (v->dev.parent)
0263
0264
0265
0266 #define VPCERR_UNSUPPORTED -ENOSYS
0267
0268 #define VPCERR_BAD_WWN -ENOTUNIQ
0269
0270 #define VPCERR_NO_FABRIC_SUPP -EOPNOTSUPP
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282 struct fc_rport_identifiers {
0283 u64 node_name;
0284 u64 port_name;
0285 u32 port_id;
0286 u32 roles;
0287 };
0288
0289
0290
0291
0292 struct fc_fpin_stats {
0293
0294 u64 dn;
0295 u64 dn_unknown;
0296 u64 dn_timeout;
0297 u64 dn_unable_to_route;
0298 u64 dn_device_specific;
0299
0300
0301 u64 li;
0302 u64 li_failure_unknown;
0303 u64 li_link_failure_count;
0304 u64 li_loss_of_sync_count;
0305 u64 li_loss_of_signals_count;
0306 u64 li_prim_seq_err_count;
0307 u64 li_invalid_tx_word_count;
0308 u64 li_invalid_crc_count;
0309 u64 li_device_specific;
0310
0311
0312 u64 cn;
0313 u64 cn_clear;
0314 u64 cn_lost_credit;
0315 u64 cn_credit_stall;
0316 u64 cn_oversubscription;
0317 u64 cn_device_specific;
0318 };
0319
0320
0321 #define FC_RPORT_ATTR(_name,_mode,_show,_store) \
0322 struct device_attribute dev_attr_rport_##_name = \
0323 __ATTR(_name,_mode,_show,_store)
0324
0325
0326
0327
0328
0329
0330
0331
0332
0333
0334
0335
0336
0337
0338
0339
0340
0341
0342
0343
0344
0345
0346
0347
0348
0349
0350
0351
0352
0353 struct fc_rport {
0354
0355 u32 maxframe_size;
0356 u32 supported_classes;
0357
0358
0359 u32 dev_loss_tmo;
0360 struct fc_fpin_stats fpin_stats;
0361
0362
0363 u64 node_name;
0364 u64 port_name;
0365 u32 port_id;
0366 u32 roles;
0367 enum fc_port_state port_state;
0368 u32 scsi_target_id;
0369 u32 fast_io_fail_tmo;
0370
0371
0372 void *dd_data;
0373
0374
0375 unsigned int channel;
0376 u32 number;
0377 u8 flags;
0378 struct list_head peers;
0379 struct device dev;
0380 struct delayed_work dev_loss_work;
0381 struct work_struct scan_work;
0382 struct delayed_work fail_io_work;
0383 struct work_struct stgt_delete_work;
0384 struct work_struct rport_delete_work;
0385 struct request_queue *rqst_q;
0386 } __attribute__((aligned(sizeof(unsigned long))));
0387
0388
0389 #define FC_RPORT_DEVLOSS_PENDING 0x01
0390 #define FC_RPORT_SCAN_PENDING 0x02
0391 #define FC_RPORT_FAST_FAIL_TIMEDOUT 0x04
0392 #define FC_RPORT_DEVLOSS_CALLBK_DONE 0x08
0393
0394 #define dev_to_rport(d) \
0395 container_of(d, struct fc_rport, dev)
0396 #define transport_class_to_rport(dev) \
0397 dev_to_rport(dev->parent)
0398 #define rport_to_shost(r) \
0399 dev_to_shost(r->dev.parent)
0400
0401
0402
0403
0404
0405
0406
0407
0408
0409
0410
0411
0412
0413 struct fc_starget_attrs {
0414
0415 u64 node_name;
0416 u64 port_name;
0417 u32 port_id;
0418 };
0419
0420 #define fc_starget_node_name(x) \
0421 (((struct fc_starget_attrs *)&(x)->starget_data)->node_name)
0422 #define fc_starget_port_name(x) \
0423 (((struct fc_starget_attrs *)&(x)->starget_data)->port_name)
0424 #define fc_starget_port_id(x) \
0425 (((struct fc_starget_attrs *)&(x)->starget_data)->port_id)
0426
0427 #define starget_to_rport(s) \
0428 scsi_is_fc_rport(s->dev.parent) ? dev_to_rport(s->dev.parent) : NULL
0429
0430
0431
0432
0433
0434
0435
0436 struct fc_host_statistics {
0437
0438 u64 seconds_since_last_reset;
0439 u64 tx_frames;
0440 u64 tx_words;
0441 u64 rx_frames;
0442 u64 rx_words;
0443 u64 lip_count;
0444 u64 nos_count;
0445 u64 error_frames;
0446 u64 dumped_frames;
0447 u64 link_failure_count;
0448 u64 loss_of_sync_count;
0449 u64 loss_of_signal_count;
0450 u64 prim_seq_protocol_err_count;
0451 u64 invalid_tx_word_count;
0452 u64 invalid_crc_count;
0453
0454
0455 u64 fcp_input_requests;
0456 u64 fcp_output_requests;
0457 u64 fcp_control_requests;
0458 u64 fcp_input_megabytes;
0459 u64 fcp_output_megabytes;
0460 u64 fcp_packet_alloc_failures;
0461 u64 fcp_packet_aborts;
0462 u64 fcp_frame_alloc_failures;
0463
0464
0465 u64 fc_no_free_exch;
0466 u64 fc_no_free_exch_xid;
0467 u64 fc_xid_not_found;
0468 u64 fc_xid_busy;
0469 u64 fc_seq_not_found;
0470 u64 fc_non_bls_resp;
0471
0472
0473 u64 cn_sig_warn;
0474 u64 cn_sig_alarm;
0475 };
0476
0477
0478
0479
0480
0481
0482
0483
0484
0485
0486 enum fc_host_event_code {
0487 FCH_EVT_LIP = 0x1,
0488 FCH_EVT_LINKUP = 0x2,
0489 FCH_EVT_LINKDOWN = 0x3,
0490 FCH_EVT_LIPRESET = 0x4,
0491 FCH_EVT_RSCN = 0x5,
0492 FCH_EVT_ADAPTER_CHANGE = 0x103,
0493 FCH_EVT_PORT_UNKNOWN = 0x200,
0494 FCH_EVT_PORT_OFFLINE = 0x201,
0495 FCH_EVT_PORT_ONLINE = 0x202,
0496 FCH_EVT_PORT_FABRIC = 0x204,
0497 FCH_EVT_LINK_UNKNOWN = 0x500,
0498 FCH_EVT_LINK_FPIN = 0x501,
0499 FCH_EVT_VENDOR_UNIQUE = 0xffff,
0500 };
0501
0502
0503
0504
0505
0506
0507
0508
0509
0510
0511
0512
0513
0514
0515
0516
0517
0518
0519
0520 #define FC_VENDOR_IDENTIFIER 8
0521 #define FC_FC4_LIST_SIZE 32
0522 #define FC_SYMBOLIC_NAME_SIZE 256
0523 #define FC_VERSION_STRING_SIZE 64
0524 #define FC_SERIAL_NUMBER_SIZE 64
0525
0526 struct fc_host_attrs {
0527
0528 u64 node_name;
0529 u64 port_name;
0530 u64 permanent_port_name;
0531 u32 supported_classes;
0532 u8 supported_fc4s[FC_FC4_LIST_SIZE];
0533 u32 supported_speeds;
0534 u32 maxframe_size;
0535 u16 max_npiv_vports;
0536 u32 max_ct_payload;
0537 u32 num_ports;
0538 u32 num_discovered_ports;
0539 u32 bootbios_state;
0540 char serial_number[FC_SERIAL_NUMBER_SIZE];
0541 char manufacturer[FC_SERIAL_NUMBER_SIZE];
0542 char model[FC_SYMBOLIC_NAME_SIZE];
0543 char model_description[FC_SYMBOLIC_NAME_SIZE];
0544 char hardware_version[FC_VERSION_STRING_SIZE];
0545 char driver_version[FC_VERSION_STRING_SIZE];
0546 char firmware_version[FC_VERSION_STRING_SIZE];
0547 char optionrom_version[FC_VERSION_STRING_SIZE];
0548 char vendor_identifier[FC_VENDOR_IDENTIFIER];
0549 char bootbios_version[FC_SYMBOLIC_NAME_SIZE];
0550
0551
0552
0553 u32 port_id;
0554 enum fc_port_type port_type;
0555 enum fc_port_state port_state;
0556 u8 active_fc4s[FC_FC4_LIST_SIZE];
0557 u32 speed;
0558 u64 fabric_name;
0559 char symbolic_name[FC_SYMBOLIC_NAME_SIZE];
0560 char system_hostname[FC_SYMBOLIC_NAME_SIZE];
0561 u32 dev_loss_tmo;
0562 struct fc_fpin_stats fpin_stats;
0563
0564
0565 enum fc_tgtid_binding_type tgtid_bind_type;
0566
0567
0568 struct list_head rports;
0569 struct list_head rport_bindings;
0570 struct list_head vports;
0571 u32 next_rport_number;
0572 u32 next_target_id;
0573 u32 next_vport_number;
0574 u16 npiv_vports_inuse;
0575
0576
0577 char work_q_name[20];
0578 struct workqueue_struct *work_q;
0579 char devloss_work_q_name[20];
0580 struct workqueue_struct *devloss_work_q;
0581
0582
0583 struct request_queue *rqst_q;
0584
0585
0586 u8 fdmi_version;
0587 };
0588
0589 #define shost_to_fc_host(x) \
0590 ((struct fc_host_attrs *)(x)->shost_data)
0591
0592 #define fc_host_node_name(x) \
0593 (((struct fc_host_attrs *)(x)->shost_data)->node_name)
0594 #define fc_host_port_name(x) \
0595 (((struct fc_host_attrs *)(x)->shost_data)->port_name)
0596 #define fc_host_permanent_port_name(x) \
0597 (((struct fc_host_attrs *)(x)->shost_data)->permanent_port_name)
0598 #define fc_host_supported_classes(x) \
0599 (((struct fc_host_attrs *)(x)->shost_data)->supported_classes)
0600 #define fc_host_supported_fc4s(x) \
0601 (((struct fc_host_attrs *)(x)->shost_data)->supported_fc4s)
0602 #define fc_host_supported_speeds(x) \
0603 (((struct fc_host_attrs *)(x)->shost_data)->supported_speeds)
0604 #define fc_host_maxframe_size(x) \
0605 (((struct fc_host_attrs *)(x)->shost_data)->maxframe_size)
0606 #define fc_host_max_npiv_vports(x) \
0607 (((struct fc_host_attrs *)(x)->shost_data)->max_npiv_vports)
0608 #define fc_host_serial_number(x) \
0609 (((struct fc_host_attrs *)(x)->shost_data)->serial_number)
0610 #define fc_host_manufacturer(x) \
0611 (((struct fc_host_attrs *)(x)->shost_data)->manufacturer)
0612 #define fc_host_model(x) \
0613 (((struct fc_host_attrs *)(x)->shost_data)->model)
0614 #define fc_host_model_description(x) \
0615 (((struct fc_host_attrs *)(x)->shost_data)->model_description)
0616 #define fc_host_hardware_version(x) \
0617 (((struct fc_host_attrs *)(x)->shost_data)->hardware_version)
0618 #define fc_host_driver_version(x) \
0619 (((struct fc_host_attrs *)(x)->shost_data)->driver_version)
0620 #define fc_host_firmware_version(x) \
0621 (((struct fc_host_attrs *)(x)->shost_data)->firmware_version)
0622 #define fc_host_optionrom_version(x) \
0623 (((struct fc_host_attrs *)(x)->shost_data)->optionrom_version)
0624 #define fc_host_port_id(x) \
0625 (((struct fc_host_attrs *)(x)->shost_data)->port_id)
0626 #define fc_host_port_type(x) \
0627 (((struct fc_host_attrs *)(x)->shost_data)->port_type)
0628 #define fc_host_port_state(x) \
0629 (((struct fc_host_attrs *)(x)->shost_data)->port_state)
0630 #define fc_host_active_fc4s(x) \
0631 (((struct fc_host_attrs *)(x)->shost_data)->active_fc4s)
0632 #define fc_host_speed(x) \
0633 (((struct fc_host_attrs *)(x)->shost_data)->speed)
0634 #define fc_host_fabric_name(x) \
0635 (((struct fc_host_attrs *)(x)->shost_data)->fabric_name)
0636 #define fc_host_symbolic_name(x) \
0637 (((struct fc_host_attrs *)(x)->shost_data)->symbolic_name)
0638 #define fc_host_system_hostname(x) \
0639 (((struct fc_host_attrs *)(x)->shost_data)->system_hostname)
0640 #define fc_host_tgtid_bind_type(x) \
0641 (((struct fc_host_attrs *)(x)->shost_data)->tgtid_bind_type)
0642 #define fc_host_rports(x) \
0643 (((struct fc_host_attrs *)(x)->shost_data)->rports)
0644 #define fc_host_rport_bindings(x) \
0645 (((struct fc_host_attrs *)(x)->shost_data)->rport_bindings)
0646 #define fc_host_vports(x) \
0647 (((struct fc_host_attrs *)(x)->shost_data)->vports)
0648 #define fc_host_next_rport_number(x) \
0649 (((struct fc_host_attrs *)(x)->shost_data)->next_rport_number)
0650 #define fc_host_next_target_id(x) \
0651 (((struct fc_host_attrs *)(x)->shost_data)->next_target_id)
0652 #define fc_host_next_vport_number(x) \
0653 (((struct fc_host_attrs *)(x)->shost_data)->next_vport_number)
0654 #define fc_host_npiv_vports_inuse(x) \
0655 (((struct fc_host_attrs *)(x)->shost_data)->npiv_vports_inuse)
0656 #define fc_host_work_q_name(x) \
0657 (((struct fc_host_attrs *)(x)->shost_data)->work_q_name)
0658 #define fc_host_work_q(x) \
0659 (((struct fc_host_attrs *)(x)->shost_data)->work_q)
0660 #define fc_host_devloss_work_q_name(x) \
0661 (((struct fc_host_attrs *)(x)->shost_data)->devloss_work_q_name)
0662 #define fc_host_devloss_work_q(x) \
0663 (((struct fc_host_attrs *)(x)->shost_data)->devloss_work_q)
0664 #define fc_host_dev_loss_tmo(x) \
0665 (((struct fc_host_attrs *)(x)->shost_data)->dev_loss_tmo)
0666 #define fc_host_max_ct_payload(x) \
0667 (((struct fc_host_attrs *)(x)->shost_data)->max_ct_payload)
0668 #define fc_host_vendor_identifier(x) \
0669 (((struct fc_host_attrs *)(x)->shost_data)->vendor_identifier)
0670 #define fc_host_num_discovered_ports(x) \
0671 (((struct fc_host_attrs *)(x)->shost_data)->num_discovered_ports)
0672 #define fc_host_num_ports(x) \
0673 (((struct fc_host_attrs *)(x)->shost_data)->num_ports)
0674 #define fc_host_bootbios_version(x) \
0675 (((struct fc_host_attrs *)(x)->shost_data)->bootbios_version)
0676 #define fc_host_bootbios_state(x) \
0677 (((struct fc_host_attrs *)(x)->shost_data)->bootbios_state)
0678
0679
0680 struct fc_function_template {
0681 void (*get_rport_dev_loss_tmo)(struct fc_rport *);
0682 void (*set_rport_dev_loss_tmo)(struct fc_rport *, u32);
0683
0684 void (*get_starget_node_name)(struct scsi_target *);
0685 void (*get_starget_port_name)(struct scsi_target *);
0686 void (*get_starget_port_id)(struct scsi_target *);
0687
0688 void (*get_host_port_id)(struct Scsi_Host *);
0689 void (*get_host_port_type)(struct Scsi_Host *);
0690 void (*get_host_port_state)(struct Scsi_Host *);
0691 void (*get_host_active_fc4s)(struct Scsi_Host *);
0692 void (*get_host_speed)(struct Scsi_Host *);
0693 void (*get_host_fabric_name)(struct Scsi_Host *);
0694 void (*get_host_symbolic_name)(struct Scsi_Host *);
0695 void (*set_host_system_hostname)(struct Scsi_Host *);
0696
0697 struct fc_host_statistics * (*get_fc_host_stats)(struct Scsi_Host *);
0698 void (*reset_fc_host_stats)(struct Scsi_Host *);
0699
0700 int (*issue_fc_host_lip)(struct Scsi_Host *);
0701
0702 void (*dev_loss_tmo_callbk)(struct fc_rport *);
0703 void (*terminate_rport_io)(struct fc_rport *);
0704
0705 void (*set_vport_symbolic_name)(struct fc_vport *);
0706 int (*vport_create)(struct fc_vport *, bool);
0707 int (*vport_disable)(struct fc_vport *, bool);
0708 int (*vport_delete)(struct fc_vport *);
0709
0710
0711 int (*bsg_request)(struct bsg_job *);
0712 int (*bsg_timeout)(struct bsg_job *);
0713
0714
0715 u32 dd_fcrport_size;
0716 u32 dd_fcvport_size;
0717 u32 dd_bsg_size;
0718
0719
0720
0721
0722
0723
0724
0725
0726
0727 unsigned long show_rport_maxframe_size:1;
0728 unsigned long show_rport_supported_classes:1;
0729 unsigned long show_rport_dev_loss_tmo:1;
0730
0731
0732
0733
0734
0735
0736 unsigned long show_starget_node_name:1;
0737 unsigned long show_starget_port_name:1;
0738 unsigned long show_starget_port_id:1;
0739
0740
0741 unsigned long show_host_node_name:1;
0742 unsigned long show_host_port_name:1;
0743 unsigned long show_host_permanent_port_name:1;
0744 unsigned long show_host_supported_classes:1;
0745 unsigned long show_host_supported_fc4s:1;
0746 unsigned long show_host_supported_speeds:1;
0747 unsigned long show_host_maxframe_size:1;
0748 unsigned long show_host_serial_number:1;
0749 unsigned long show_host_manufacturer:1;
0750 unsigned long show_host_model:1;
0751 unsigned long show_host_model_description:1;
0752 unsigned long show_host_hardware_version:1;
0753 unsigned long show_host_driver_version:1;
0754 unsigned long show_host_firmware_version:1;
0755 unsigned long show_host_optionrom_version:1;
0756
0757 unsigned long show_host_port_id:1;
0758 unsigned long show_host_port_type:1;
0759 unsigned long show_host_port_state:1;
0760 unsigned long show_host_active_fc4s:1;
0761 unsigned long show_host_speed:1;
0762 unsigned long show_host_fabric_name:1;
0763 unsigned long show_host_symbolic_name:1;
0764 unsigned long show_host_system_hostname:1;
0765
0766 unsigned long disable_target_scan:1;
0767 };
0768
0769
0770
0771
0772
0773
0774
0775
0776
0777 static inline int
0778 fc_remote_port_chkready(struct fc_rport *rport)
0779 {
0780 int result;
0781
0782 switch (rport->port_state) {
0783 case FC_PORTSTATE_ONLINE:
0784 case FC_PORTSTATE_MARGINAL:
0785 if (rport->roles & FC_PORT_ROLE_FCP_TARGET)
0786 result = 0;
0787 else if (rport->flags & FC_RPORT_DEVLOSS_PENDING)
0788 result = DID_IMM_RETRY << 16;
0789 else
0790 result = DID_NO_CONNECT << 16;
0791 break;
0792 case FC_PORTSTATE_BLOCKED:
0793 if (rport->flags & FC_RPORT_FAST_FAIL_TIMEDOUT)
0794 result = DID_TRANSPORT_FAILFAST << 16;
0795 else
0796 result = DID_IMM_RETRY << 16;
0797 break;
0798 default:
0799 result = DID_NO_CONNECT << 16;
0800 break;
0801 }
0802 return result;
0803 }
0804
0805 static inline u64 wwn_to_u64(const u8 *wwn)
0806 {
0807 return get_unaligned_be64(wwn);
0808 }
0809
0810 static inline void u64_to_wwn(u64 inm, u8 *wwn)
0811 {
0812 put_unaligned_be64(inm, wwn);
0813 }
0814
0815
0816
0817
0818
0819
0820
0821
0822
0823
0824
0825
0826 static inline void
0827 fc_vport_set_state(struct fc_vport *vport, enum fc_vport_state new_state)
0828 {
0829 if ((new_state != FC_VPORT_UNKNOWN) &&
0830 (new_state != FC_VPORT_INITIALIZING))
0831 vport->vport_last_state = vport->vport_state;
0832 vport->vport_state = new_state;
0833 }
0834
0835 struct scsi_transport_template *fc_attach_transport(
0836 struct fc_function_template *);
0837 void fc_release_transport(struct scsi_transport_template *);
0838 void fc_remove_host(struct Scsi_Host *);
0839 struct fc_rport *fc_remote_port_add(struct Scsi_Host *shost,
0840 int channel, struct fc_rport_identifiers *ids);
0841 void fc_remote_port_delete(struct fc_rport *rport);
0842 void fc_remote_port_rolechg(struct fc_rport *rport, u32 roles);
0843 int scsi_is_fc_rport(const struct device *);
0844 u32 fc_get_event_number(void);
0845 void fc_host_post_event(struct Scsi_Host *shost, u32 event_number,
0846 enum fc_host_event_code event_code, u32 event_data);
0847 void fc_host_post_vendor_event(struct Scsi_Host *shost, u32 event_number,
0848 u32 data_len, char *data_buf, u64 vendor_id);
0849 struct fc_rport *fc_find_rport_by_wwpn(struct Scsi_Host *shost, u64 wwpn);
0850 void fc_host_post_fc_event(struct Scsi_Host *shost, u32 event_number,
0851 enum fc_host_event_code event_code,
0852 u32 data_len, char *data_buf, u64 vendor_id);
0853
0854
0855
0856
0857
0858
0859 void fc_host_fpin_rcv(struct Scsi_Host *shost, u32 fpin_len, char *fpin_buf);
0860 struct fc_vport *fc_vport_create(struct Scsi_Host *shost, int channel,
0861 struct fc_vport_identifiers *);
0862 int fc_vport_terminate(struct fc_vport *vport);
0863 int fc_block_rport(struct fc_rport *rport);
0864 int fc_block_scsi_eh(struct scsi_cmnd *cmnd);
0865 enum blk_eh_timer_return fc_eh_timed_out(struct scsi_cmnd *scmd);
0866 bool fc_eh_should_retry_cmd(struct scsi_cmnd *scmd);
0867
0868 static inline struct Scsi_Host *fc_bsg_to_shost(struct bsg_job *job)
0869 {
0870 if (scsi_is_host_device(job->dev))
0871 return dev_to_shost(job->dev);
0872 return rport_to_shost(dev_to_rport(job->dev));
0873 }
0874
0875 static inline struct fc_rport *fc_bsg_to_rport(struct bsg_job *job)
0876 {
0877 if (scsi_is_fc_rport(job->dev))
0878 return dev_to_rport(job->dev);
0879 return NULL;
0880 }
0881
0882 #endif