Imported Upstream version 0.8.9
[platform/upstream/multipath-tools.git] / libmultipath / discovery.h
1 #ifndef DISCOVERY_H
2 #define DISCOVERY_H
3
4 #define SYSFS_PATH_SIZE 255
5 #define INQUIRY_CMDLEN  6
6 #define INQUIRY_CMD     0x12
7 #define SENSE_BUFF_LEN  32
8 #define RECOVERED_ERROR 0x01
9 #define MX_ALLOC_LEN    255
10 #define TUR_CMD_LEN     6
11
12 #ifndef BLKGETSIZE
13 #define BLKGETSIZE      _IO(0x12,96)
14 #endif
15
16 #ifndef DEF_TIMEOUT
17 #define DEF_TIMEOUT     30
18 #endif
19
20 /*
21  * excerpt from sg_err.h
22  */
23 #define SCSI_CHECK_CONDITION    0x2
24 #define SCSI_COMMAND_TERMINATED 0x22
25 #define SG_ERR_DRIVER_SENSE     0x08
26
27 #define PATHINFO_OK 0
28 #define PATHINFO_FAILED 1
29 #define PATHINFO_SKIPPED 2
30
31 struct config;
32
33 int path_discovery (vector pathvec, int flag);
34 int path_get_tpgs(struct path *pp); /* This function never returns TPGS_UNDEF */
35 int do_tur (char *);
36 int path_offline (struct path *);
37 int get_state (struct path * pp, struct config * conf, int daemon, int state);
38 int get_vpd_sgio (int fd, int pg, int vend_id, char * str, int maxlen);
39 int pathinfo (struct path * pp, struct config * conf, int mask);
40 int alloc_path_with_pathinfo (struct config *conf, struct udev_device *udevice,
41                               const char *wwid, int flag, struct path **pp_ptr);
42 int store_pathinfo (vector pathvec, struct config *conf,
43                     struct udev_device *udevice, int flag,
44                     struct path **pp_ptr);
45 int sysfs_set_scsi_tmo (struct multipath *mpp, unsigned int checkint);
46 int sysfs_get_timeout(const struct path *pp, unsigned int *timeout);
47 int sysfs_get_iscsi_ip_address(const struct path *pp, char *ip_address);
48 int sysfs_get_host_adapter_name(const struct path *pp,
49                                 char *adapter_name);
50 ssize_t sysfs_get_vpd (struct udev_device *udev, unsigned char pg,
51                        unsigned char *buff, size_t len);
52 ssize_t sysfs_get_inquiry(struct udev_device *udev,
53                           unsigned char *buff, size_t len);
54 int sysfs_get_asymmetric_access_state(struct path *pp,
55                                       char *buff, int buflen);
56 bool has_uid_fallback(struct path *pp);
57 int get_uid(struct path * pp, int path_state, struct udev_device *udev,
58             int allow_fallback);
59 bool is_vpd_page_supported(int fd, int pg);
60
61 /*
62  * discovery bitmask
63  */
64 enum discovery_mode {
65         __DI_SYSFS,
66         __DI_SERIAL,
67         __DI_CHECKER,
68         __DI_PRIO,
69         __DI_WWID,
70         __DI_BLACKLIST,
71         __DI_NOIO,
72         __DI_NOFALLBACK,
73 };
74
75 #define DI_SYSFS        (1 << __DI_SYSFS)
76 #define DI_SERIAL       (1 << __DI_SERIAL)
77 #define DI_CHECKER      (1 << __DI_CHECKER)
78 #define DI_PRIO         (1 << __DI_PRIO)
79 #define DI_WWID         (1 << __DI_WWID)
80 #define DI_BLACKLIST    (1 << __DI_BLACKLIST)
81 #define DI_NOIO         (1 << __DI_NOIO) /* Avoid IO on the device */
82 #define DI_NOFALLBACK   (1 << __DI_NOFALLBACK) /* do not allow wwid fallback */
83
84 #define DI_ALL          (DI_SYSFS  | DI_SERIAL | DI_CHECKER | DI_PRIO | \
85                          DI_WWID)
86
87 #endif /* DISCOVERY_H */