xref: /illumos-gate/usr/src/uts/common/io/bnxe/577xx/hsi/mcp/bdn.h (revision d14abf155341d55053c76eeec58b787a456b753b)
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 (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://www.opensolaris.org/os/licensing.
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  * Copyright 2014 QLogic Corporation
22  * The contents of this file are subject to the terms of the
23  * QLogic End User License (the "License").
24  * You may not use this file except in compliance with the License.
25  *
26  * You can obtain a copy of the License at
27  * http://www.qlogic.com/Resources/Documents/DriverDownloadHelp/
28  * QLogic_End_User_Software_License.txt
29  * See the License for the specific language governing permissions
30  * and limitations under the License.
31  *
32  *
33  * Name: bdn.h
34  *
35  * Description: BDN definitions
36  *
37  * Author: Yaniv Rosner
38  *
39  ****************************************************************************/
40 
41 #ifndef BDN_H
42 #define BDN_H
43 
44 struct Codec_Info {
45 	u32_t version;	/* Version of Codec */
46 
47 	enum codec_location {
48 		e_None		= 0,
49 		e_Here		= 1,
50 		e_FRU_EEPROM	= 2
51 	} loc; /* DEFAULT e-None */
52 	u16_t total_size;	/* total size of Codec in bytes.Max size 32K (64K?)*/
53 	u16_t num_msg_segments;	/* number of segments = total size / max message payload size */
54 };
55 
56 #define MAX_CODEC_SIZE		0x8000
57 #define CODEC_SEGMENT_SIZE	0x400
58 #define NUMBER_OF_SEGMENTS (MAX_CODEC_SIZE/CODEC_SEGMENT_SIZE)
59 struct codec_t {
60 	u8_t data[NUMBER_OF_SEGMENTS][CODEC_SEGMENT_SIZE];
61 };
62 
63 typedef u32 bdn_cfg;
64 #define BDN_CFG_SIZE_MASK 		0x0000ffff
65 #define BDN_CFG_SIZE_OFFSET		0
66 #define BDN_CFG_STATE_MASK 		0x00ff0000
67 #define BDN_CFG_STATE_OFFSET		16
68 	#define BDN_CFG_STATE_ACTIVE	0x00010000
69 	#define BDN_CFG_STATE_PENDING	0x00020000
70 
71 struct bdn_fcoe_boot_target {
72 	u16 wwpn;
73 	u16 lUNID;
74 };
75 
76 #if 0
77 #define MAX_FCOE_IBOOT_PORT_ID 8  /* @@@TBD - what's this ? */
78 #define MAX_IBOOT_TARGETS	8
79 struct bdn_fcoe_boot_next_dlr {
80 	bdn_cfg hdr;
81 	u16 fcoe_boot_enable;
82 	u16 fcoe_cvid;
83 	u16 fcoe_wwnn;
84 	u16 n_port_id[MAX_FCOE_IBOOT_PORT_ID];	//Still Not sure how big the array is
85 	struct fcoe_boot_target targets[MAX_IBOOT_TARGETS];	//Still Not sure how big the array is
86 };
87 
88 struct bdn_fcoe_boot {	// Main fcoe_iboot struct
89 	fcoe_iboot_next_dlr next_dlr;	// Hold substruct per each activation type
90 };
91 #endif
92 struct bdn_netport_now {
93 	bdn_cfg hdr;
94 	u8 enable_port;
95 	u8 rsrv;
96 	u8 num_pfs_min_bw;
97 	u8 num_pfs_max_bw;
98 	u8 min_bw[E2_FUNC_MAX]; /* 4 PFs in 2 port mode / 2 PFs in 4 port mode */
99 	u8 max_bw[E2_FUNC_MAX]; /* 4 PFs in 2 port mode / 2 PFs in 4 port mode */
100 };
101 
102 struct bdn_netport_on_port_reset {
103 	bdn_cfg hdr;
104 	u32 link_config;
105 /* Same definitions as in PORT_HW_CFG_SPEED_CAPABILITY_D3_MASK */
106 #define BDN_LINK_CONFIG_ADVERTISED_SPEED_MASK	0x0000ffff
107 #define BDN_LINK_CONFIG_ADVERTISED_SPEED_SHIFT	0
108 /* Same definitions as PORT_FEATURE_FLOW_CONTROL_MASK */
109 #define BDN_LINK_CONFIG_FLOW_CONTROL_MASK	0x00070000
110 #define BDN_LINK_CONFIG_FLOW_CONTROL_SHIFT	16
111 
112 #define BDN_LINK_CONFIG_PFC_ENABLED_MASK	0x00080000
113 #define BDN_LINK_CONFIG_PFC_ENABLED_SHIFT	19
114 
115 #define BDN_LINK_CONFIG_EEE_ENABLED_MASK	0x00100000
116 #define BDN_LINK_CONFIG_EEE_ENABLED_SHIFT	20
117 };
118 
119 struct bdn_netport_next_os_boot {
120 	bdn_cfg hdr;
121 	u8   num_pfs;
122 	u8   num_vf_per_pf[E2_FUNC_MAX];
123 };
124 
125 struct bdn_netport {
126 	struct bdn_netport_now now;
127 	struct bdn_netport_on_port_reset on_port_reset; /* On Port Reset */
128 	struct bdn_netport_next_os_boot next_os_boot; /* Next OS Boot */
129 };
130 
131 #define CONNECTION_ID_LEN 16
132 struct bdn_flexfunc_now {
133 	bdn_cfg hdr;
134 	u8 connection_id[CONNECTION_ID_LEN];
135 	u8 fnic_enabled;
136 	u8 rsrv[3];
137 };
138 
139 struct bdn_flexfunc_next_os_boot {
140 	bdn_cfg hdr;
141 	u8 mac_addr[6];
142 	u8 func_type;
143 	u8 boot_mode;
144 };
145 
146 struct bdn_flex_func {
147 	struct bdn_flexfunc_now now;
148 	struct bdn_flexfunc_next_os_boot next_os_boot; /* Next OS Boot */
149 };
150 
151 #ifndef PF_NUM_MAX
152 #define PF_NUM_MAX 8
153 #endif
154 
155 struct bdn {
156 	u32 size;
157 	u32 uuid;	// Unique identifer of the slot/chassis of the blade
158 	struct Codec_Info codec_info;
159 	struct codec_t codec;
160 	struct bdn_netport netport[PORT_MAX * NVM_PATH_MAX];
161 	struct bdn_flex_func flexfunc[PF_NUM_MAX];
162 	//struct bdn_pxe_boot pxe_boot;
163 	//struct bdn_iscsi_boot iscsi_boot;
164 	//struct bdn_fcoe_boot fcoe_boot;
165 	u32 crc;
166 };
167 
168 union bdn_image {
169 	struct bdn bdn;
170 	u8_t rsrv[0x9000];
171 };
172 
173 /* Expected BDN size is basically the offset of rsrv within the bdn structure */
174 #define BDN_SIZE (sizeof(struct bdn))
175 
176 #define BDN_CODEC_INFO()		  (ASN1_P->bdn_addr + OFFSETOF(struct bdn, codec_info))
177 #define BDN_CODEC_DATA()		  (ASN1_P->bdn_addr + OFFSETOF(struct bdn, codec))
178 #define BDN_NETPORT_NOW(papo)		  (ASN1_P->bdn_addr + OFFSETOF(struct bdn, netport[(papo.path << 1) + papo.port].now))
179 #define BDN_NETPORT_ON_PORT_RESET(papo)   (ASN1_P->bdn_addr + OFFSETOF(struct bdn, netport[(papo.path << 1) + papo.port].on_port_reset))
180 #define BDN_NETPORT_NEXT_OS_BOOT(papo)	  (ASN1_P->bdn_addr + OFFSETOF(struct bdn, netport[(papo.path << 1) + papo.port].next_os_boot))
181 #define BDN_FLEXFUNC_NOW(pf_num)	  (ASN1_P->bdn_addr + OFFSETOF(struct bdn, flexfunc[pf_num].now))
182 #define BDN_FLEXFUNC_NEXT_OS_BOOT(pf_num) (ASN1_P->bdn_addr + OFFSETOF(struct bdn, flexfunc[pf_num].next_os_boot))
183 #define BDN_CRC()			  (ASN1_P->bdn_addr + sizeof(union bdn_image))
184 
185 /*----------------------------------------------------------------------------
186  * ------------------------------ Function Prototypes ------------------------
187  * ---------------------------------------------------------------------------
188  */
189 
190 int bd_populate_os_reset_config(void);
191 int bd_populate_port_reset_config(int path, int port);
192 #endif /* BDN_H */
193