1 /*
2  * QLogic iSCSI Offload Driver
3  * Copyright (c) 2016 Cavium Inc.
4  *
5  * This software is available under the terms of the GNU General Public License
6  * (GPL) Version 2, available from the file COPYING in the main directory of
7  * this source tree.
8  */
9 
10 #ifndef NVM_ISCSI_CFG_H
11 #define NVM_ISCSI_CFG_H
12 
13 #define NUM_OF_ISCSI_TARGET_PER_PF    4   /* Defined as per the
14 					   * ISCSI IBFT constraint
15 					   */
16 #define NUM_OF_ISCSI_PF_SUPPORTED     4   /* One PF per Port -
17 					   * assuming 4 port card
18 					   */
19 
20 #define NVM_ISCSI_CFG_DHCP_NAME_MAX_LEN  256
21 
22 union nvm_iscsi_dhcp_vendor_id {
23 	u32 value[NVM_ISCSI_CFG_DHCP_NAME_MAX_LEN / 4];
24 	u8  byte[NVM_ISCSI_CFG_DHCP_NAME_MAX_LEN];
25 };
26 
27 #define NVM_ISCSI_IPV4_ADDR_BYTE_LEN 4
28 union nvm_iscsi_ipv4_addr {
29 	u32 addr;
30 	u8  byte[NVM_ISCSI_IPV4_ADDR_BYTE_LEN];
31 };
32 
33 #define NVM_ISCSI_IPV6_ADDR_BYTE_LEN 16
34 union nvm_iscsi_ipv6_addr {
35 	u32 addr[4];
36 	u8  byte[NVM_ISCSI_IPV6_ADDR_BYTE_LEN];
37 };
38 
39 struct nvm_iscsi_initiator_ipv4 {
40 	union nvm_iscsi_ipv4_addr addr;				/* 0x0 */
41 	union nvm_iscsi_ipv4_addr subnet_mask;			/* 0x4 */
42 	union nvm_iscsi_ipv4_addr gateway;			/* 0x8 */
43 	union nvm_iscsi_ipv4_addr primary_dns;			/* 0xC */
44 	union nvm_iscsi_ipv4_addr secondary_dns;		/* 0x10 */
45 	union nvm_iscsi_ipv4_addr dhcp_addr;			/* 0x14 */
46 
47 	union nvm_iscsi_ipv4_addr isns_server;			/* 0x18 */
48 	union nvm_iscsi_ipv4_addr slp_server;			/* 0x1C */
49 	union nvm_iscsi_ipv4_addr primay_radius_server;		/* 0x20 */
50 	union nvm_iscsi_ipv4_addr secondary_radius_server;	/* 0x24 */
51 
52 	union nvm_iscsi_ipv4_addr rsvd[4];			/* 0x28 */
53 };
54 
55 struct nvm_iscsi_initiator_ipv6 {
56 	union nvm_iscsi_ipv6_addr addr;				/* 0x0 */
57 	union nvm_iscsi_ipv6_addr subnet_mask;			/* 0x10 */
58 	union nvm_iscsi_ipv6_addr gateway;			/* 0x20 */
59 	union nvm_iscsi_ipv6_addr primary_dns;			/* 0x30 */
60 	union nvm_iscsi_ipv6_addr secondary_dns;		/* 0x40 */
61 	union nvm_iscsi_ipv6_addr dhcp_addr;			/* 0x50 */
62 
63 	union nvm_iscsi_ipv6_addr isns_server;			/* 0x60 */
64 	union nvm_iscsi_ipv6_addr slp_server;			/* 0x70 */
65 	union nvm_iscsi_ipv6_addr primay_radius_server;		/* 0x80 */
66 	union nvm_iscsi_ipv6_addr secondary_radius_server;	/* 0x90 */
67 
68 	union nvm_iscsi_ipv6_addr rsvd[3];			/* 0xA0 */
69 
70 	u32   config;						/* 0xD0 */
71 #define NVM_ISCSI_CFG_INITIATOR_IPV6_SUBNET_MASK_PREFIX_MASK      0x000000FF
72 #define NVM_ISCSI_CFG_INITIATOR_IPV6_SUBNET_MASK_PREFIX_OFFSET    0
73 
74 	u32   rsvd_1[3];
75 };
76 
77 #define NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN  256
78 union nvm_iscsi_name {
79 	u32 value[NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN / 4];
80 	u8  byte[NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN];
81 };
82 
83 #define NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN  256
84 union nvm_iscsi_chap_name {
85 	u32 value[NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN / 4];
86 	u8  byte[NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN];
87 };
88 
89 #define NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN  16 /* md5 need per RFC1996
90 					    * is 16 octets
91 					    */
92 union nvm_iscsi_chap_password {
93 	u32 value[NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN / 4];
94 	u8 byte[NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN];
95 };
96 
97 union nvm_iscsi_lun {
98 	u8  byte[8];
99 	u32 value[2];
100 };
101 
102 struct nvm_iscsi_generic {
103 	u32 ctrl_flags;						/* 0x0 */
104 #define NVM_ISCSI_CFG_GEN_CHAP_ENABLED                 BIT(0)
105 #define NVM_ISCSI_CFG_GEN_DHCP_TCPIP_CONFIG_ENABLED    BIT(1)
106 #define NVM_ISCSI_CFG_GEN_DHCP_ISCSI_CONFIG_ENABLED    BIT(2)
107 #define NVM_ISCSI_CFG_GEN_IPV6_ENABLED                 BIT(3)
108 #define NVM_ISCSI_CFG_GEN_IPV4_FALLBACK_ENABLED        BIT(4)
109 #define NVM_ISCSI_CFG_GEN_ISNS_WORLD_LOGIN             BIT(5)
110 #define NVM_ISCSI_CFG_GEN_ISNS_SELECTIVE_LOGIN         BIT(6)
111 #define NVM_ISCSI_CFG_GEN_ADDR_REDIRECT_ENABLED	       BIT(7)
112 #define NVM_ISCSI_CFG_GEN_CHAP_MUTUAL_ENABLED          BIT(8)
113 
114 	u32 timeout;						/* 0x4 */
115 #define NVM_ISCSI_CFG_GEN_DHCP_REQUEST_TIMEOUT_MASK       0x0000FFFF
116 #define NVM_ISCSI_CFG_GEN_DHCP_REQUEST_TIMEOUT_OFFSET     0
117 #define NVM_ISCSI_CFG_GEN_PORT_LOGIN_TIMEOUT_MASK         0xFFFF0000
118 #define NVM_ISCSI_CFG_GEN_PORT_LOGIN_TIMEOUT_OFFSET       16
119 
120 	union nvm_iscsi_dhcp_vendor_id  dhcp_vendor_id;		/* 0x8  */
121 	u32 rsvd[62];						/* 0x108 */
122 };
123 
124 struct nvm_iscsi_initiator {
125 	struct nvm_iscsi_initiator_ipv4 ipv4;			/* 0x0 */
126 	struct nvm_iscsi_initiator_ipv6 ipv6;			/* 0x38 */
127 
128 	union nvm_iscsi_name           initiator_name;		/* 0x118 */
129 	union nvm_iscsi_chap_name      chap_name;		/* 0x218 */
130 	union nvm_iscsi_chap_password  chap_password;		/* 0x318 */
131 
132 	u32 generic_cont0;					/* 0x398 */
133 #define NVM_ISCSI_CFG_INITIATOR_VLAN_MASK		0x0000FFFF
134 #define NVM_ISCSI_CFG_INITIATOR_VLAN_OFFSET		0
135 #define NVM_ISCSI_CFG_INITIATOR_IP_VERSION_MASK		0x00030000
136 #define NVM_ISCSI_CFG_INITIATOR_IP_VERSION_OFFSET	16
137 #define NVM_ISCSI_CFG_INITIATOR_IP_VERSION_4		1
138 #define NVM_ISCSI_CFG_INITIATOR_IP_VERSION_6		2
139 #define NVM_ISCSI_CFG_INITIATOR_IP_VERSION_4_AND_6	3
140 
141 	u32 ctrl_flags;
142 #define NVM_ISCSI_CFG_INITIATOR_IP_VERSION_PRIORITY_V6     BIT(0)
143 #define NVM_ISCSI_CFG_INITIATOR_VLAN_ENABLED               BIT(1)
144 
145 	u32 rsvd[116];						/* 0x32C */
146 };
147 
148 struct nvm_iscsi_target {
149 	u32 ctrl_flags;						/* 0x0 */
150 #define NVM_ISCSI_CFG_TARGET_ENABLED            BIT(0)
151 #define NVM_ISCSI_CFG_BOOT_TIME_LOGIN_STATUS    BIT(1)
152 
153 	u32 generic_cont0;					/* 0x4 */
154 #define NVM_ISCSI_CFG_TARGET_TCP_PORT_MASK      0x0000FFFF
155 #define NVM_ISCSI_CFG_TARGET_TCP_PORT_OFFSET    0
156 
157 	u32 ip_ver;
158 #define NVM_ISCSI_CFG_IPv4       4
159 #define NVM_ISCSI_CFG_IPv6       6
160 
161 	u32 rsvd_1[7];						/* 0x24 */
162 	union nvm_iscsi_ipv4_addr ipv4_addr;			/* 0x28 */
163 	union nvm_iscsi_ipv6_addr ipv6_addr;			/* 0x2C */
164 	union nvm_iscsi_lun lun;				/* 0x3C */
165 
166 	union nvm_iscsi_name           target_name;		/* 0x44 */
167 	union nvm_iscsi_chap_name      chap_name;		/* 0x144 */
168 	union nvm_iscsi_chap_password  chap_password;		/* 0x244 */
169 
170 	u32 rsvd_2[107];					/* 0x2C4 */
171 };
172 
173 struct nvm_iscsi_block {
174 	u32 id;							/* 0x0 */
175 #define NVM_ISCSI_CFG_BLK_MAPPED_PF_ID_MASK         0x0000000F
176 #define NVM_ISCSI_CFG_BLK_MAPPED_PF_ID_OFFSET       0
177 #define NVM_ISCSI_CFG_BLK_CTRL_FLAG_MASK            0x00000FF0
178 #define NVM_ISCSI_CFG_BLK_CTRL_FLAG_OFFSET          4
179 #define NVM_ISCSI_CFG_BLK_CTRL_FLAG_IS_NOT_EMPTY    BIT(0)
180 #define NVM_ISCSI_CFG_BLK_CTRL_FLAG_PF_MAPPED       BIT(1)
181 
182 	u32 rsvd_1[5];						/* 0x4 */
183 
184 	struct nvm_iscsi_generic     generic;			/* 0x18 */
185 	struct nvm_iscsi_initiator   initiator;			/* 0x218 */
186 	struct nvm_iscsi_target      target[NUM_OF_ISCSI_TARGET_PER_PF];
187 								/* 0x718 */
188 
189 	u32 rsvd_2[58];						/* 0x1718 */
190 	/* total size - 0x1800 - 6K block */
191 };
192 
193 struct nvm_iscsi_cfg {
194 	u32 id;							/* 0x0 */
195 #define NVM_ISCSI_CFG_BLK_VERSION_MINOR_MASK     0x000000FF
196 #define NVM_ISCSI_CFG_BLK_VERSION_MAJOR_MASK     0x0000FF00
197 #define NVM_ISCSI_CFG_BLK_SIGNATURE_MASK         0xFFFF0000
198 #define NVM_ISCSI_CFG_BLK_SIGNATURE              0x49430000 /* IC - Iscsi
199 							     * Config
200 							     */
201 
202 #define NVM_ISCSI_CFG_BLK_VERSION_MAJOR          0
203 #define NVM_ISCSI_CFG_BLK_VERSION_MINOR          10
204 #define NVM_ISCSI_CFG_BLK_VERSION ((NVM_ISCSI_CFG_BLK_VERSION_MAJOR << 8) | \
205 				   NVM_ISCSI_CFG_BLK_VERSION_MINOR)
206 
207 	struct nvm_iscsi_block	block[NUM_OF_ISCSI_PF_SUPPORTED]; /* 0x4 */
208 };
209 
210 #endif
211