xref: /openbmc/linux/drivers/scsi/cxlflash/main.h (revision c21e0bbf)
1 /*
2  * CXL Flash Device Driver
3  *
4  * Written by: Manoj N. Kumar <manoj@linux.vnet.ibm.com>, IBM Corporation
5  *             Matthew R. Ochs <mrochs@linux.vnet.ibm.com>, IBM Corporation
6  *
7  * Copyright (C) 2015 IBM Corporation
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version
12  * 2 of the License, or (at your option) any later version.
13  */
14 
15 #ifndef _CXLFLASH_MAIN_H
16 #define _CXLFLASH_MAIN_H
17 
18 #include <linux/list.h>
19 #include <linux/types.h>
20 #include <scsi/scsi.h>
21 #include <scsi/scsi_device.h>
22 
23 #define CXLFLASH_NAME		"cxlflash"
24 #define CXLFLASH_ADAPTER_NAME	"IBM POWER CXL Flash Adapter"
25 #define CXLFLASH_DRIVER_DATE	"(June 2, 2015)"
26 
27 #define PCI_DEVICE_ID_IBM_CORSA	0x04F0
28 #define CXLFLASH_SUBS_DEV_ID	0x04F0
29 
30 /* Since there is only one target, make it 0 */
31 #define CXLFLASH_TARGET		0
32 #define CXLFLASH_MAX_CDB_LEN	16
33 
34 /* Really only one target per bus since the Texan is directly attached */
35 #define CXLFLASH_MAX_NUM_TARGETS_PER_BUS	1
36 #define CXLFLASH_MAX_NUM_LUNS_PER_TARGET	65536
37 
38 #define CXLFLASH_PCI_ERROR_RECOVERY_TIMEOUT	(120 * HZ)
39 
40 #define NUM_FC_PORTS	CXLFLASH_NUM_FC_PORTS	/* ports per AFU */
41 
42 /* FC defines */
43 #define FC_MTIP_CMDCONFIG 0x010
44 #define FC_MTIP_STATUS 0x018
45 
46 #define FC_PNAME 0x300
47 #define FC_CONFIG 0x320
48 #define FC_CONFIG2 0x328
49 #define FC_STATUS 0x330
50 #define FC_ERROR 0x380
51 #define FC_ERRCAP 0x388
52 #define FC_ERRMSK 0x390
53 #define FC_CNT_CRCERR 0x538
54 #define FC_CRC_THRESH 0x580
55 
56 #define FC_MTIP_CMDCONFIG_ONLINE	0x20ULL
57 #define FC_MTIP_CMDCONFIG_OFFLINE	0x40ULL
58 
59 #define FC_MTIP_STATUS_MASK		0x30ULL
60 #define FC_MTIP_STATUS_ONLINE		0x20ULL
61 #define FC_MTIP_STATUS_OFFLINE		0x10ULL
62 
63 /* TIMEOUT and RETRY definitions */
64 
65 /* AFU command timeout values */
66 #define MC_AFU_SYNC_TIMEOUT	5	/* 5 secs */
67 
68 /* AFU command room retry limit */
69 #define MC_ROOM_RETRY_CNT	10
70 
71 /* FC CRC clear periodic timer */
72 #define MC_CRC_THRESH 100	/* threshold in 5 mins */
73 
74 #define FC_PORT_STATUS_RETRY_CNT 100	/* 100 100ms retries = 10 seconds */
75 #define FC_PORT_STATUS_RETRY_INTERVAL_US 100000	/* microseconds */
76 
77 /* VPD defines */
78 #define CXLFLASH_VPD_LEN	256
79 #define WWPN_LEN	16
80 #define WWPN_BUF_LEN	(WWPN_LEN + 1)
81 
82 enum undo_level {
83 	RELEASE_CONTEXT = 0,
84 	FREE_IRQ,
85 	UNMAP_ONE,
86 	UNMAP_TWO,
87 	UNMAP_THREE,
88 	UNDO_START
89 };
90 
91 struct dev_dependent_vals {
92 	u64 max_sectors;
93 };
94 
95 struct asyc_intr_info {
96 	u64 status;
97 	char *desc;
98 	u8 port;
99 	u8 action;
100 #define CLR_FC_ERROR	0x01
101 #define LINK_RESET	0x02
102 };
103 
104 #endif /* _CXLFLASH_MAIN_H */
105