095657bb9de4119082c1a350ec0cf9d8edfd9eb0
[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_host_pci_name(const struct path *pp, char *pci_name);
48 int sysfs_get_iscsi_ip_address(const struct path *pp, char *ip_address);
49 int sysfs_get_host_adapter_name(const struct path *pp,
50                                 char *adapter_name);
51 ssize_t sysfs_get_vpd (struct udev_device *udev, unsigned char pg,
52                        unsigned char *buff, size_t len);
53 ssize_t sysfs_get_inquiry(struct udev_device *udev,
54                           unsigned char *buff, size_t len);
55 int sysfs_get_asymmetric_access_state(struct path *pp,
56                                       char *buff, int buflen);
57 bool has_uid_fallback(struct path *pp);
58 int get_uid(struct path * pp, int path_state, struct udev_device *udev,
59             int allow_fallback);
60 bool is_vpd_page_supported(int fd, int pg);
61
62 /*
63  * discovery bitmask
64  */
65 enum discovery_mode {
66         __DI_SYSFS,
67         __DI_SERIAL,
68         __DI_CHECKER,
69         __DI_PRIO,
70         __DI_WWID,
71         __DI_BLACKLIST,
72         __DI_NOIO,
73         __DI_NOFALLBACK,
74 };
75
76 #define DI_SYSFS        (1 << __DI_SYSFS)
77 #define DI_SERIAL       (1 << __DI_SERIAL)
78 #define DI_CHECKER      (1 << __DI_CHECKER)
79 #define DI_PRIO         (1 << __DI_PRIO)
80 #define DI_WWID         (1 << __DI_WWID)
81 #define DI_BLACKLIST    (1 << __DI_BLACKLIST)
82 #define DI_NOIO         (1 << __DI_NOIO) /* Avoid IO on the device */
83 #define DI_NOFALLBACK   (1 << __DI_NOFALLBACK) /* do not allow wwid fallback */
84
85 #define DI_ALL          (DI_SYSFS  | DI_SERIAL | DI_CHECKER | DI_PRIO | \
86                          DI_WWID)
87
88 #endif /* DISCOVERY_H */