1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, v.1,  (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://opensource.org/licenses/CDDL-1.0.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 
22 /*
23 * Copyright 2014-2017 Cavium, Inc.
24 * The contents of this file are subject to the terms of the Common Development
25 * and Distribution License, v.1,  (the "License").
26 
27 * You may not use this file except in compliance with the License.
28 
29 * You can obtain a copy of the License at available
30 * at http://opensource.org/licenses/CDDL-1.0
31 
32 * See the License for the specific language governing permissions and
33 * limitations under the License.
34 */
35 
36 /****************************************************************************
37  *
38  * Name:        nvm_iscsi_cfg.h
39  *
40  * Description: NVM config file for iSCSI configurations
41  *
42  * Created:     04/11/2016
43  *
44  * Version:     0.2
45  *
46  ****************************************************************************/
47 
48 #ifndef NVM_ISCSI_CFG_H
49 #define NVM_ISCSI_CFG_H
50 
51 #define NUM_OF_ISCSI_TARGET_PER_PF    4   // Defined as per the ISCSI IBFT constraint
52 #define NUM_OF_ISCSI_PF_SUPPORTED     4   // One PF per Port - assuming 4 port card
53 
54 #define NVM_ISCSI_CFG_DHCP_NAME_MAX_LEN  256
55 
56 union nvm_iscsi_dhcp_vendor_id
57 {
58   u32 value[NVM_ISCSI_CFG_DHCP_NAME_MAX_LEN/4];
59   u8  byte[NVM_ISCSI_CFG_DHCP_NAME_MAX_LEN];
60 };
61 
62 #define NVM_ISCSI_IPV4_ADDR_BYTE_LEN 4
63 union nvm_iscsi_ipv4_addr
64 {
65   u32 addr;
66   u8  byte[NVM_ISCSI_IPV4_ADDR_BYTE_LEN];
67 };
68 
69 #define NVM_ISCSI_IPV6_ADDR_BYTE_LEN 16
70 union nvm_iscsi_ipv6_addr
71 {
72   u32 addr[4];
73   u8  byte[NVM_ISCSI_IPV6_ADDR_BYTE_LEN];
74 };
75 
76 struct nvm_iscsi_initiator_ipv4
77 {
78   union nvm_iscsi_ipv4_addr addr;                                             /* 0x0 */
79   union nvm_iscsi_ipv4_addr subnet_mask;                                      /* 0x4 */
80   union nvm_iscsi_ipv4_addr gateway;                                          /* 0x8 */
81   union nvm_iscsi_ipv4_addr primary_dns;                                      /* 0xC */
82   union nvm_iscsi_ipv4_addr secondary_dns;                                    /* 0x10 */
83   union nvm_iscsi_ipv4_addr dhcp_addr;                                        /* 0x14 */
84 
85   union nvm_iscsi_ipv4_addr isns_server;                                      /* 0x18 */
86   union nvm_iscsi_ipv4_addr slp_server;                                       /* 0x1C */
87   union nvm_iscsi_ipv4_addr primay_radius_server;                             /* 0x20 */
88   union nvm_iscsi_ipv4_addr secondary_radius_server;                          /* 0x24 */
89 
90   union nvm_iscsi_ipv4_addr rsvd[4];                                          /* 0x28 */
91 };
92 
93 struct nvm_iscsi_initiator_ipv6
94 {
95   union nvm_iscsi_ipv6_addr addr;                                             /* 0x0 */
96   union nvm_iscsi_ipv6_addr subnet_mask;                                      /* 0x10 */
97   union nvm_iscsi_ipv6_addr gateway;                                          /* 0x20 */
98   union nvm_iscsi_ipv6_addr primary_dns;                                      /* 0x30 */
99   union nvm_iscsi_ipv6_addr secondary_dns;                                    /* 0x40 */
100   union nvm_iscsi_ipv6_addr dhcp_addr;                                        /* 0x50 */
101 
102   union nvm_iscsi_ipv6_addr isns_server;                                      /* 0x60 */
103   union nvm_iscsi_ipv6_addr slp_server;                                       /* 0x70 */
104   union nvm_iscsi_ipv6_addr primay_radius_server;                             /* 0x80 */
105   union nvm_iscsi_ipv6_addr secondary_radius_server;                          /* 0x90 */
106 
107   union nvm_iscsi_ipv6_addr rsvd[3];                                          /* 0xA0 */
108 
109   u32   config;                                                               /* 0xD0 */
110   #define NVM_ISCSI_CFG_INITIATOR_IPV6_SUBNET_MASK_PREFIX_MASK      0x000000FF
111   #define NVM_ISCSI_CFG_INITIATOR_IPV6_SUBNET_MASK_PREFIX_OFFSET    0
112 
113   u32   rsvd_1[3];                                                            /* 0xD4 */
114 };
115 
116 
117 #define NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN  223
118 #define NVM_ISCSI_CFG_ISCSI_NAME_MAX_PLUS_RESERVED   256 // NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN + RESERVED for backward compatibility
119 
120 union nvm_iscsi_name
121 {
122   u32 value[NVM_ISCSI_CFG_ISCSI_NAME_MAX_PLUS_RESERVED/4];
123   u8  byte[NVM_ISCSI_CFG_ISCSI_NAME_MAX_PLUS_RESERVED];
124 };
125 
126 #define NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN   256
127 
128 union nvm_iscsi_chap_name
129 {
130   u32 value[NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN/4];
131   u8  byte[NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN];
132 };
133 
134 #define NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN  				16
135 // md5 need per RFC1996 is 16 octets
136 union nvm_iscsi_chap_password
137 {
138   u32 value[NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN/4];
139   u8 byte[NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN];
140 };
141 
142 union nvm_iscsi_lun
143 {
144   u8  byte[8];
145   u32 value[2];
146 };
147 
148 
149 struct nvm_iscsi_generic
150 {
151   u32 ctrl_flags;                                                             /* 0x0 */
152   #define NVM_ISCSI_CFG_GEN_CHAP_ENABLED                 (1 << 0)
153   #define NVM_ISCSI_CFG_GEN_DHCP_TCPIP_CONFIG_ENABLED    (1 << 1)
154   #define NVM_ISCSI_CFG_GEN_DHCP_ISCSI_CONFIG_ENABLED    (1 << 2)
155   #define NVM_ISCSI_CFG_GEN_IPV6_ENABLED                 (1 << 3)
156   #define NVM_ISCSI_CFG_GEN_IPV4_FALLBACK_ENABLED        (1 << 4)             // currently not supported
157   #define NVM_ISCSI_CFG_GEN_ISNS_WORLD_LOGIN             (1 << 5)
158   #define NVM_ISCSI_CFG_GEN_ISNS_SELECTIVE_LOGIN         (1 << 6)
159   #define NVM_ISCSI_CFG_GEN_ADDR_REDIRECT_ENABLED        (1 << 7)
160   #define NVM_ISCSI_CFG_GEN_CHAP_MUTUAL_ENABLED          (1 << 8)
161 
162   u32 timeout;                                                                /* 0x4 */
163   #define NVM_ISCSI_CFG_GEN_DHCP_REQUEST_TIMEOUT_MASK       0x0000FFFF
164   #define NVM_ISCSI_CFG_GEN_DHCP_REQUEST_TIMEOUT_OFFSET     0
165   #define NVM_ISCSI_CFG_GEN_PORT_LOGIN_TIMEOUT_MASK         0xFFFF0000
166   #define NVM_ISCSI_CFG_GEN_PORT_LOGIN_TIMEOUT_OFFSET       16
167 
168   union nvm_iscsi_dhcp_vendor_id  dhcp_vendor_id;                            /* 0x8  */
169   u32 rsvd[62];                                                              /* 0x108 */
170 };
171 
172 struct nvm_iscsi_initiator
173 {
174   struct nvm_iscsi_initiator_ipv4 ipv4;                                       /* 0x0 */
175   struct nvm_iscsi_initiator_ipv6 ipv6;                                       /* 0x38 */
176 
177   union nvm_iscsi_name           initiator_name;                              /* 0x118 */
178   union nvm_iscsi_chap_name      chap_name;                                   /* 0x218 */
179   union nvm_iscsi_chap_password  chap_password;                               /* 0x318 */
180 
181   u32 generic_cont0;                                                          /* 0x328 */
182   #define NVM_ISCSI_CFG_INITIATOR_VLAN_MASK                  0x0000FFFF
183   #define NVM_ISCSI_CFG_INITIATOR_VLAN_OFFSET                0
184   #define NVM_ISCSI_CFG_INITIATOR_RESERVED                   0x00030000
185 
186   u32 ctrl_flags;
187   #define NVM_ISCSI_CFG_INITIATOR_IP_VERSION_PRIORITY_V6     (1 << 0)
188   #define NVM_ISCSI_CFG_INITIATOR_VLAN_ENABLED               (1 << 1)
189 
190   u32 ip_ver;
191   #define NVM_ISCSI_CFG_INITIATOR_IP_MASK			                0x00000007
192   #define NVM_ISCSI_CFG_INITIATOR_IP_OFFSET			              0
193   #define NVM_ISCSI_CFG_INITIATOR_IPV4			                  1
194   #define NVM_ISCSI_CFG_INITIATOR_IPV6			                  2
195   #define NVM_ISCSI_CFG_INITIATOR_IPV4_IPV6			              4
196 
197   u32 rsvd[115];                                                              /* 0x32C */
198 };
199 
200 
201 struct nvm_iscsi_target
202 {
203   u32 ctrl_flags;                                                             /* 0x0 */
204   #define NVM_ISCSI_CFG_TARGET_ENABLED            (1 << 0)
205   #define NVM_ISCSI_CFG_BOOT_TIME_LOGIN_STATUS    (1 << 1)
206 
207   u32 generic_cont0;                                                          /* 0x4 */
208   #define NVM_ISCSI_CFG_TARGET_TCP_PORT_MASK      0x0000FFFF
209   #define NVM_ISCSI_CFG_TARGET_TCP_PORT_OFFSET    0
210 
211   u32 ip_ver;
212   #define NVM_ISCSI_CFG_TARGET_IP_MASK			      0x00000007
213   #define NVM_ISCSI_CFG_TARGET_IP_OFFSET			    0
214   #define NVM_ISCSI_CFG_TARGET_IPV4			 	        NVM_ISCSI_CFG_INITIATOR_IPV4
215   #define NVM_ISCSI_CFG_TARGET_IPV6				        NVM_ISCSI_CFG_INITIATOR_IPV6
216   #define NVM_ISCSI_CFG_TARGET_IPV4_IPV6			    NVM_ISCSI_CFG_INITIATOR_IPV4_IPV6   // currently not supported
217 
218   u32 rsvd_1[7];                                                              /* 0x24 */
219   union nvm_iscsi_ipv4_addr ipv4_addr;                                       /* 0x28 */
220   union nvm_iscsi_ipv6_addr ipv6_addr;                                       /* 0x2C */
221   union nvm_iscsi_lun lun;                                                   /* 0x3C */
222 
223   union nvm_iscsi_name           target_name;                                /* 0x44 */
224   union nvm_iscsi_chap_name      chap_name;                                  /* 0x144 */
225   union nvm_iscsi_chap_password  chap_password;                              /* 0x244 */
226 
227   u32 rsvd_2[107];                                                           /* 0x254 */
228 };
229 
230 struct nvm_iscsi_block
231 {
232   u32 id;                                                                     /* 0x0 */
233   #define NVM_ISCSI_CFG_BLK_MAPPED_PF_ID_MASK         0x0000000F
234   #define NVM_ISCSI_CFG_BLK_MAPPED_PF_ID_OFFSET       0
235   #define NVM_ISCSI_CFG_BLK_CTRL_FLAG_MASK            0x00000FF0
236   #define NVM_ISCSI_CFG_BLK_CTRL_FLAG_OFFSET          4
237   #define NVM_ISCSI_CFG_BLK_CTRL_FLAG_IS_NOT_EMPTY            (1 << 0)
238   #define NVM_ISCSI_CFG_BLK_CTRL_FLAG_PF_MAPPED               (1 << 1)
239 
240   u32 rsvd_1[5];                                                              /* 0x4 */
241 
242   struct nvm_iscsi_generic     generic;                                       /* 0x18 */
243   struct nvm_iscsi_initiator   initiator;                                     /* 0x218 */
244   struct nvm_iscsi_target      target[NUM_OF_ISCSI_TARGET_PER_PF];            /* 0x718 */
245 
246   u32 rsvd_2[58];                                                             /* 0x1718 */
247   /* total size - 0x1800 - 6K block */
248 };
249 
250 struct nvm_iscsi_cfg
251 {
252   u32 id;                                                                      /* 0x0 */
253   #define NVM_ISCSI_CFG_BLK_VERSION_MINOR_MASK     0x000000FF
254   #define NVM_ISCSI_CFG_BLK_VERSION_MAJOR_MASK     0x0000FF00
255   #define NVM_ISCSI_CFG_BLK_SIGNATURE_MASK         0xFFFF0000
256   #define NVM_ISCSI_CFG_BLK_SIGNATURE              0x49430000    // IC - Iscsi Config
257 
258   #define NVM_ISCSI_CFG_BLK_VERSION_MAJOR          0
259   #define NVM_ISCSI_CFG_BLK_VERSION_MINOR          11
260   #define NVM_ISCSI_CFG_BLK_VERSION                (NVM_ISCSI_CFG_BLK_VERSION_MAJOR << 8) | NVM_ISCSI_CFG_BLK_VERSION_MINOR;
261 
262   struct nvm_iscsi_block    block[NUM_OF_ISCSI_PF_SUPPORTED];               /* 0x4 */
263 };
264 
265 #endif
266 
267 
268