1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 #pragma once
3 
4 /*
5  * Copyright © IBM Corp. 2003
6  */
7 
8 #define MAX_PATH_LEN 512
9 
10 /*
11  * MAX_ATTR_LEN: maximum length of the result of reading a sysfs
12  * attribute.
13  */
14 #define MAX_ATTR_LEN 256
15 
16 /*
17  * MAX_SERIAL_LEN: the maximum length of the serial number, including
18  * added prefixes such as vendor and product (model) strings.
19  */
20 #define MAX_SERIAL_LEN 256
21 
22 /*
23  * MAX_BUFFER_LEN: maximum buffer size and line length used while reading
24  * the config file.
25  */
26 #define MAX_BUFFER_LEN 256
27 
28 struct scsi_id_device {
29         char vendor[9];
30         char model[17];
31         char revision[5];
32         char kernel[64];
33         char serial[MAX_SERIAL_LEN];
34         char serial_short[MAX_SERIAL_LEN];
35         unsigned type;
36         int use_sg;
37 
38         /* Always from page 0x80 e.g. 'B3G1P8500RWT' - may not be unique */
39         char unit_serial_number[MAX_SERIAL_LEN];
40 
41         /* NULs if not set - otherwise hex encoding using lower-case e.g. '50014ee0016eb572' */
42         char wwn[17];
43 
44         /* NULs if not set - otherwise hex encoding using lower-case e.g. '0xe00000d80000' */
45         char wwn_vendor_extension[17];
46 
47         /* NULs if not set - otherwise decimal number */
48         char tgpt_group[8];
49 };
50 
51 int scsi_std_inquiry(struct scsi_id_device *dev_scsi, const char *devname);
52 int scsi_get_serial(struct scsi_id_device *dev_scsi, const char *devname,
53                     int page_code, int len);
54 
55 /*
56  * Page code values.
57  */
58 enum page_code {
59         PAGE_83_PRE_SPC3 = -0x83,
60         PAGE_UNSPECIFIED = 0x00,
61         PAGE_80          = 0x80,
62         PAGE_83          = 0x83,
63 };
64