0001
0002 #ifndef SCSI_TRANSPORT_SRP_H
0003 #define SCSI_TRANSPORT_SRP_H
0004
0005 #include <linux/transport_class.h>
0006 #include <linux/types.h>
0007 #include <linux/mutex.h>
0008
0009 #define SRP_RPORT_ROLE_INITIATOR 0
0010 #define SRP_RPORT_ROLE_TARGET 1
0011
0012 struct srp_rport_identifiers {
0013 u8 port_id[16];
0014 u8 roles;
0015 };
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 enum srp_rport_state {
0026 SRP_RPORT_RUNNING,
0027 SRP_RPORT_BLOCKED,
0028 SRP_RPORT_FAIL_FAST,
0029 SRP_RPORT_LOST,
0030 };
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053 struct srp_rport {
0054
0055
0056 struct device dev;
0057
0058 u8 port_id[16];
0059 u8 roles;
0060
0061
0062
0063 void *lld_data;
0064
0065 struct mutex mutex;
0066 enum srp_rport_state state;
0067 int reconnect_delay;
0068 int failed_reconnects;
0069 struct delayed_work reconnect_work;
0070 int fast_io_fail_tmo;
0071 int dev_loss_tmo;
0072 struct delayed_work fast_io_fail_work;
0073 struct delayed_work dev_loss_work;
0074 };
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093 struct srp_function_template {
0094
0095 bool has_rport_state;
0096 bool reset_timer_if_blocked;
0097 int *reconnect_delay;
0098 int *fast_io_fail_tmo;
0099 int *dev_loss_tmo;
0100 int (*reconnect)(struct srp_rport *rport);
0101 void (*terminate_rport_io)(struct srp_rport *rport);
0102 void (*rport_delete)(struct srp_rport *rport);
0103 };
0104
0105 extern struct scsi_transport_template *
0106 srp_attach_transport(struct srp_function_template *);
0107 extern void srp_release_transport(struct scsi_transport_template *);
0108
0109 extern void srp_rport_get(struct srp_rport *rport);
0110 extern void srp_rport_put(struct srp_rport *rport);
0111 extern struct srp_rport *srp_rport_add(struct Scsi_Host *,
0112 struct srp_rport_identifiers *);
0113 extern void srp_rport_del(struct srp_rport *);
0114 extern int srp_tmo_valid(int reconnect_delay, int fast_io_fail_tmo,
0115 long dev_loss_tmo);
0116 int srp_parse_tmo(int *tmo, const char *buf);
0117 extern int srp_reconnect_rport(struct srp_rport *rport);
0118 extern void srp_start_tl_fail_timers(struct srp_rport *rport);
0119 extern void srp_remove_host(struct Scsi_Host *);
0120 extern void srp_stop_rport_timers(struct srp_rport *rport);
0121 enum blk_eh_timer_return srp_timed_out(struct scsi_cmnd *scmd);
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131 static inline int srp_chkready(struct srp_rport *rport)
0132 {
0133 switch (rport->state) {
0134 case SRP_RPORT_RUNNING:
0135 case SRP_RPORT_BLOCKED:
0136 default:
0137 return 0;
0138 case SRP_RPORT_FAIL_FAST:
0139 return DID_TRANSPORT_FAILFAST << 16;
0140 case SRP_RPORT_LOST:
0141 return DID_NO_CONNECT << 16;
0142 }
0143 }
0144
0145 #endif