b151cc7a39a893fee6e24d8c3368dd22fed94c4b
[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
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, 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                               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, int checkint);
46 int sysfs_get_timeout(struct path *pp, unsigned int *timeout);
47 int sysfs_get_host_pci_name(struct path *pp, char *pci_name);
48 int sysfs_get_iscsi_ip_address(struct path *pp, char *ip_address);
49 ssize_t sysfs_get_vpd (struct udev_device * udev, int pg, unsigned char * buff,
50                        size_t len);
51 int sysfs_get_asymmetric_access_state(struct path *pp,
52                                       char *buff, int buflen);
53 int get_uid(struct path * pp, int path_state, struct udev_device *udev);
54
55 /*
56  * discovery bitmask
57  */
58 enum discovery_mode {
59         __DI_SYSFS,
60         __DI_SERIAL,
61         __DI_CHECKER,
62         __DI_PRIO,
63         __DI_WWID,
64         __DI_BLACKLIST,
65         __DI_NOIO,
66 };
67
68 #define DI_SYSFS        (1 << __DI_SYSFS)
69 #define DI_SERIAL       (1 << __DI_SERIAL)
70 #define DI_CHECKER      (1 << __DI_CHECKER)
71 #define DI_PRIO         (1 << __DI_PRIO)
72 #define DI_WWID         (1 << __DI_WWID)
73 #define DI_BLACKLIST    (1 << __DI_BLACKLIST)
74 #define DI_NOIO         (1 << __DI_NOIO) /* Avoid IO on the device */
75
76 #define DI_ALL          (DI_SYSFS  | DI_SERIAL | DI_CHECKER | DI_PRIO | \
77                          DI_WWID)
78
79 #endif /* DISCOVERY_H */