chiark / gitweb /
[PATCH] more extras/multipath updates
[elogind.git] / extras / multipath / main.h
1 /*
2  * Soft:        Description here...
3  *
4  * Version:     $Id: main.h,v 0.0.1 2003/09/18 15:13:38 cvaroqui Exp $
5  *
6  * Author:      Copyright (C) 2003 Christophe Varoqui
7  *
8  *              This program is distributed in the hope that it will be useful,
9  *              but WITHOUT ANY WARRANTY; without even the implied warranty of
10  *              MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  *              See the GNU General Public License for more details.
12  *
13  *              This program is free software; you can redistribute it and/or
14  *              modify it under the terms of the GNU General Public License
15  *              as published by the Free Software Foundation; either version
16  *              2 of the License, or (at your option) any later version.
17  */
18
19 #ifndef _MAIN_H
20 #define _MAIN_H
21
22 /* local includes */
23 #include "sg_include.h"
24
25 /* exerpt from "sg_err.h" */
26 #define SCSI_CHECK_CONDITION    0x2
27 #define SCSI_COMMAND_TERMINATED 0x22
28 #define SG_ERR_DRIVER_SENSE     0x08
29
30 /* exerpt from "scsi.h" */
31 #define RECOVERED_ERROR     0x01
32 #define SCSI_IOCTL_GET_IDLUN            0x5382
33 #define SCSI_IOCTL_GET_BUS_NUMBER       0x5386
34
35 /* global defs */
36 #define WWID_SIZE       33
37 #define MAX_DEVS        128
38 #define MAX_MP          MAX_DEVS / 2
39 #define MAX_MP_PATHS    MAX_DEVS / 4
40 #define FILE_NAME_SIZE  256
41 #define INQUIRY_CMDLEN  6
42 #define INQUIRY_CMD     0x12
43 #define SENSE_BUFF_LEN  32
44 #define DEF_TIMEOUT     60000
45 #define EBUFF_SZ        256
46 #define TUR_CMD_LEN     6
47 #define MX_ALLOC_LEN    255
48 #define BLKGETSIZE      _IO(0x12,96)
49 #define DM_TARGET       "striped"
50 /*
51 #define DM_TARGET       "multipath"
52 #define DM_POLL_INTERVAL        10
53 #define DM_PATH_SELECTOR        "latency"
54 */
55
56 #define PINDEX(x,y)     mp[(x)].pindex[(y)]
57
58 /* global types */
59 struct scsi_idlun {
60         int dev_id;
61         int host_unique_id;
62         int host_no;
63 };
64
65 struct sg_id {
66         int host_no;
67         int channel;
68         int scsi_id;
69         int lun;
70         int scsi_type;
71         short h_cmd_per_lun;
72         short d_queue_depth;
73         int unused1;
74         int unused2;
75 };
76
77 struct scsi_dev {
78         char dev[FILE_NAME_SIZE];
79         struct scsi_idlun scsi_id;
80         int host_no;
81 };
82
83 struct path {
84         char dev[FILE_NAME_SIZE];
85         char sg_dev[FILE_NAME_SIZE];
86         struct scsi_idlun scsi_id;
87         struct sg_id sg_id;
88         int state;
89         char wwid[WWID_SIZE];
90         char vendor_id[8];
91         char product_id[16];
92         char rev[4];
93 };
94
95 struct multipath {
96         char wwid[WWID_SIZE];
97         int npaths;
98         int pindex[MAX_MP_PATHS];
99 };
100
101 struct env {
102         int max_devs;
103         int verbose;
104         int quiet;
105         int dry_run;
106         int with_sysfs;
107         char sysfs_path[FILE_NAME_SIZE];
108 };
109
110 /* Build version */
111 #define PROG    "multipath"
112
113 #define VERSION_CODE 0x000009
114 #define DATE_CODE    0x0C0503
115
116 #define MULTIPATH_VERSION(version)      \
117         (version >> 16) & 0xFF,         \
118         (version >> 8) & 0xFF,          \
119         version & 0xFF
120
121 #define VERSION_STRING PROG" v%d.%d.%d (%.2d/%.2d, 20%.2d)\n",  \
122                 MULTIPATH_VERSION(VERSION_CODE),                \
123                 MULTIPATH_VERSION(DATE_CODE)
124
125 #endif