blob: d85f93aea4650b670ecbbe171c303042c04fd8d8 [file] [log] [blame]
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001/*
2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
3 * All rights reserved
4 * www.brocade.com
5 *
6 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License (GPL) Version 2 as
10 * published by the Free Software Foundation
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 */
17
18#ifndef __BFA_DEFS_H__
19#define __BFA_DEFS_H__
20
21#include "bfa_fc.h"
Maggie Zhangf16a1752010-12-09 19:12:32 -080022#include "bfad_drv.h"
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070023
24#define BFA_MFG_SERIALNUM_SIZE 11
25#define STRSZ(_n) (((_n) + 4) & ~3)
26
Jing Huangacdc79a2010-10-18 17:15:55 -070027/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070028 * Manufacturing card type
29 */
30enum {
31 BFA_MFG_TYPE_CB_MAX = 825, /* Crossbow card type max */
32 BFA_MFG_TYPE_FC8P2 = 825, /* 8G 2port FC card */
33 BFA_MFG_TYPE_FC8P1 = 815, /* 8G 1port FC card */
34 BFA_MFG_TYPE_FC4P2 = 425, /* 4G 2port FC card */
35 BFA_MFG_TYPE_FC4P1 = 415, /* 4G 1port FC card */
36 BFA_MFG_TYPE_CNA10P2 = 1020, /* 10G 2port CNA card */
37 BFA_MFG_TYPE_CNA10P1 = 1010, /* 10G 1port CNA card */
38 BFA_MFG_TYPE_JAYHAWK = 804, /* Jayhawk mezz card */
39 BFA_MFG_TYPE_WANCHESE = 1007, /* Wanchese mezz card */
40 BFA_MFG_TYPE_ASTRA = 807, /* Astra mezz card */
41 BFA_MFG_TYPE_LIGHTNING_P0 = 902, /* Lightning mezz card - old */
42 BFA_MFG_TYPE_LIGHTNING = 1741, /* Lightning mezz card */
43 BFA_MFG_TYPE_INVALID = 0, /* Invalid card type */
44};
45
46#pragma pack(1)
47
Jing Huangacdc79a2010-10-18 17:15:55 -070048/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070049 * Check if Mezz card
50 */
51#define bfa_mfg_is_mezz(type) (( \
52 (type) == BFA_MFG_TYPE_JAYHAWK || \
53 (type) == BFA_MFG_TYPE_WANCHESE || \
54 (type) == BFA_MFG_TYPE_ASTRA || \
55 (type) == BFA_MFG_TYPE_LIGHTNING_P0 || \
56 (type) == BFA_MFG_TYPE_LIGHTNING))
57
Jing Huangacdc79a2010-10-18 17:15:55 -070058/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070059 * Check if the card having old wwn/mac handling
60 */
61#define bfa_mfg_is_old_wwn_mac_model(type) (( \
62 (type) == BFA_MFG_TYPE_FC8P2 || \
63 (type) == BFA_MFG_TYPE_FC8P1 || \
64 (type) == BFA_MFG_TYPE_FC4P2 || \
65 (type) == BFA_MFG_TYPE_FC4P1 || \
66 (type) == BFA_MFG_TYPE_CNA10P2 || \
67 (type) == BFA_MFG_TYPE_CNA10P1 || \
68 (type) == BFA_MFG_TYPE_JAYHAWK || \
69 (type) == BFA_MFG_TYPE_WANCHESE))
70
71#define bfa_mfg_increment_wwn_mac(m, i) \
72do { \
73 u32 t = ((u32)(m)[0] << 16) | ((u32)(m)[1] << 8) | \
74 (u32)(m)[2]; \
75 t += (i); \
76 (m)[0] = (t >> 16) & 0xFF; \
77 (m)[1] = (t >> 8) & 0xFF; \
78 (m)[2] = t & 0xFF; \
79} while (0)
80
Jing Huangacdc79a2010-10-18 17:15:55 -070081/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070082 * VPD data length
83 */
84#define BFA_MFG_VPD_LEN 512
85
Jing Huangacdc79a2010-10-18 17:15:55 -070086/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070087 * VPD vendor tag
88 */
89enum {
90 BFA_MFG_VPD_UNKNOWN = 0, /* vendor unknown */
91 BFA_MFG_VPD_IBM = 1, /* vendor IBM */
92 BFA_MFG_VPD_HP = 2, /* vendor HP */
93 BFA_MFG_VPD_DELL = 3, /* vendor DELL */
94 BFA_MFG_VPD_PCI_IBM = 0x08, /* PCI VPD IBM */
95 BFA_MFG_VPD_PCI_HP = 0x10, /* PCI VPD HP */
96 BFA_MFG_VPD_PCI_DELL = 0x20, /* PCI VPD DELL */
97 BFA_MFG_VPD_PCI_BRCD = 0xf8, /* PCI VPD Brocade */
98};
99
Jing Huangacdc79a2010-10-18 17:15:55 -0700100/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700101 * All numerical fields are in big-endian format.
102 */
103struct bfa_mfg_vpd_s {
104 u8 version; /* vpd data version */
105 u8 vpd_sig[3]; /* characters 'V', 'P', 'D' */
106 u8 chksum; /* u8 checksum */
107 u8 vendor; /* vendor */
108 u8 len; /* vpd data length excluding header */
109 u8 rsv;
110 u8 data[BFA_MFG_VPD_LEN]; /* vpd data */
111};
112
113#pragma pack()
114
Jing Huangacdc79a2010-10-18 17:15:55 -0700115/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700116 * Status return values
117 */
118enum bfa_status {
119 BFA_STATUS_OK = 0, /* Success */
120 BFA_STATUS_FAILED = 1, /* Operation failed */
121 BFA_STATUS_EINVAL = 2, /* Invalid params Check input
122 * parameters */
123 BFA_STATUS_ENOMEM = 3, /* Out of resources */
124 BFA_STATUS_ETIMER = 5, /* Timer expired - Retry, if persists,
125 * contact support */
126 BFA_STATUS_EPROTOCOL = 6, /* Protocol error */
127 BFA_STATUS_DEVBUSY = 13, /* Device busy - Retry operation */
128 BFA_STATUS_UNKNOWN_LWWN = 18, /* LPORT PWWN not found */
129 BFA_STATUS_UNKNOWN_RWWN = 19, /* RPORT PWWN not found */
130 BFA_STATUS_VPORT_EXISTS = 21, /* VPORT already exists */
131 BFA_STATUS_VPORT_MAX = 22, /* Reached max VPORT supported limit */
132 BFA_STATUS_UNSUPP_SPEED = 23, /* Invalid Speed Check speed setting */
133 BFA_STATUS_INVLD_DFSZ = 24, /* Invalid Max data field size */
134 BFA_STATUS_FABRIC_RJT = 29, /* Reject from attached fabric */
135 BFA_STATUS_VPORT_WWN_BP = 46, /* WWN is same as base port's WWN */
136 BFA_STATUS_NO_FCPIM_NEXUS = 52, /* No FCP Nexus exists with the rport */
137 BFA_STATUS_IOC_FAILURE = 56, /* IOC failure - Retry, if persists
138 * contact support */
139 BFA_STATUS_INVALID_WWN = 57, /* Invalid WWN */
140 BFA_STATUS_DIAG_BUSY = 71, /* diag busy */
141 BFA_STATUS_ENOFSAVE = 78, /* No saved firmware trace */
142 BFA_STATUS_IOC_DISABLED = 82, /* IOC is already disabled */
143 BFA_STATUS_INVALID_MAC = 134, /* Invalid MAC address */
144 BFA_STATUS_PBC = 154, /* Operation not allowed for pre-boot
145 * configuration */
146 BFA_STATUS_TRUNK_ENABLED = 164, /* Trunk is already enabled on
147 * this adapter */
148 BFA_STATUS_TRUNK_DISABLED = 165, /* Trunking is disabled on
149 * the adapter */
150 BFA_STATUS_IOPROFILE_OFF = 175, /* IO profile OFF */
151 BFA_STATUS_MAX_VAL /* Unknown error code */
152};
153#define bfa_status_t enum bfa_status
154
155enum bfa_eproto_status {
156 BFA_EPROTO_BAD_ACCEPT = 0,
157 BFA_EPROTO_UNKNOWN_RSP = 1
158};
159#define bfa_eproto_status_t enum bfa_eproto_status
160
161enum bfa_boolean {
162 BFA_FALSE = 0,
163 BFA_TRUE = 1
164};
165#define bfa_boolean_t enum bfa_boolean
166
167#define BFA_STRING_32 32
168#define BFA_VERSION_LEN 64
169
Jing Huangacdc79a2010-10-18 17:15:55 -0700170/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700171 * ---------------------- adapter definitions ------------
172 */
173
Jing Huangacdc79a2010-10-18 17:15:55 -0700174/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700175 * BFA adapter level attributes.
176 */
177enum {
178 BFA_ADAPTER_SERIAL_NUM_LEN = STRSZ(BFA_MFG_SERIALNUM_SIZE),
179 /*
180 *!< adapter serial num length
181 */
182 BFA_ADAPTER_MODEL_NAME_LEN = 16, /* model name length */
183 BFA_ADAPTER_MODEL_DESCR_LEN = 128, /* model description length */
184 BFA_ADAPTER_MFG_NAME_LEN = 8, /* manufacturer name length */
185 BFA_ADAPTER_SYM_NAME_LEN = 64, /* adapter symbolic name length */
186 BFA_ADAPTER_OS_TYPE_LEN = 64, /* adapter os type length */
187};
188
189struct bfa_adapter_attr_s {
190 char manufacturer[BFA_ADAPTER_MFG_NAME_LEN];
191 char serial_num[BFA_ADAPTER_SERIAL_NUM_LEN];
192 u32 card_type;
193 char model[BFA_ADAPTER_MODEL_NAME_LEN];
194 char model_descr[BFA_ADAPTER_MODEL_DESCR_LEN];
195 wwn_t pwwn;
196 char node_symname[FC_SYMNAME_MAX];
197 char hw_ver[BFA_VERSION_LEN];
198 char fw_ver[BFA_VERSION_LEN];
199 char optrom_ver[BFA_VERSION_LEN];
200 char os_type[BFA_ADAPTER_OS_TYPE_LEN];
201 struct bfa_mfg_vpd_s vpd;
202 struct mac_s mac;
203
204 u8 nports;
205 u8 max_speed;
206 u8 prototype;
207 char asic_rev;
208
209 u8 pcie_gen;
210 u8 pcie_lanes_orig;
211 u8 pcie_lanes;
212 u8 cna_capable;
213
214 u8 is_mezz;
215 u8 trunk_capable;
216};
217
Jing Huangacdc79a2010-10-18 17:15:55 -0700218/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700219 * ---------------------- IOC definitions ------------
220 */
221
222enum {
223 BFA_IOC_DRIVER_LEN = 16,
224 BFA_IOC_CHIP_REV_LEN = 8,
225};
226
Jing Huangacdc79a2010-10-18 17:15:55 -0700227/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700228 * Driver and firmware versions.
229 */
230struct bfa_ioc_driver_attr_s {
231 char driver[BFA_IOC_DRIVER_LEN]; /* driver name */
232 char driver_ver[BFA_VERSION_LEN]; /* driver version */
233 char fw_ver[BFA_VERSION_LEN]; /* firmware version */
234 char bios_ver[BFA_VERSION_LEN]; /* bios version */
235 char efi_ver[BFA_VERSION_LEN]; /* EFI version */
236 char ob_ver[BFA_VERSION_LEN]; /* openboot version */
237};
238
Jing Huangacdc79a2010-10-18 17:15:55 -0700239/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700240 * IOC PCI device attributes
241 */
242struct bfa_ioc_pci_attr_s {
243 u16 vendor_id; /* PCI vendor ID */
244 u16 device_id; /* PCI device ID */
245 u16 ssid; /* subsystem ID */
246 u16 ssvid; /* subsystem vendor ID */
247 u32 pcifn; /* PCI device function */
248 u32 rsvd; /* padding */
249 char chip_rev[BFA_IOC_CHIP_REV_LEN]; /* chip revision */
250};
251
Jing Huangacdc79a2010-10-18 17:15:55 -0700252/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700253 * IOC states
254 */
255enum bfa_ioc_state {
256 BFA_IOC_UNINIT = 1, /* IOC is in uninit state */
257 BFA_IOC_RESET = 2, /* IOC is in reset state */
258 BFA_IOC_SEMWAIT = 3, /* Waiting for IOC h/w semaphore */
259 BFA_IOC_HWINIT = 4, /* IOC h/w is being initialized */
260 BFA_IOC_GETATTR = 5, /* IOC is being configured */
261 BFA_IOC_OPERATIONAL = 6, /* IOC is operational */
262 BFA_IOC_INITFAIL = 7, /* IOC hardware failure */
263 BFA_IOC_FAIL = 8, /* IOC heart-beat failure */
264 BFA_IOC_DISABLING = 9, /* IOC is being disabled */
265 BFA_IOC_DISABLED = 10, /* IOC is disabled */
266 BFA_IOC_FWMISMATCH = 11, /* IOC f/w different from drivers */
267 BFA_IOC_ENABLING = 12, /* IOC is being enabled */
268};
269
Jing Huangacdc79a2010-10-18 17:15:55 -0700270/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700271 * IOC firmware stats
272 */
273struct bfa_fw_ioc_stats_s {
274 u32 enable_reqs;
275 u32 disable_reqs;
276 u32 get_attr_reqs;
277 u32 dbg_sync;
278 u32 dbg_dump;
279 u32 unknown_reqs;
280};
281
Jing Huangacdc79a2010-10-18 17:15:55 -0700282/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700283 * IOC driver stats
284 */
285struct bfa_ioc_drv_stats_s {
286 u32 ioc_isrs;
287 u32 ioc_enables;
288 u32 ioc_disables;
289 u32 ioc_hbfails;
290 u32 ioc_boots;
291 u32 stats_tmos;
292 u32 hb_count;
293 u32 disable_reqs;
294 u32 enable_reqs;
295 u32 disable_replies;
296 u32 enable_replies;
297};
298
Jing Huangacdc79a2010-10-18 17:15:55 -0700299/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700300 * IOC statistics
301 */
302struct bfa_ioc_stats_s {
303 struct bfa_ioc_drv_stats_s drv_stats; /* driver IOC stats */
304 struct bfa_fw_ioc_stats_s fw_stats; /* firmware IOC stats */
305};
306
307enum bfa_ioc_type_e {
308 BFA_IOC_TYPE_FC = 1,
309 BFA_IOC_TYPE_FCoE = 2,
310 BFA_IOC_TYPE_LL = 3,
311};
312
Jing Huangacdc79a2010-10-18 17:15:55 -0700313/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700314 * IOC attributes returned in queries
315 */
316struct bfa_ioc_attr_s {
317 enum bfa_ioc_type_e ioc_type;
318 enum bfa_ioc_state state; /* IOC state */
319 struct bfa_adapter_attr_s adapter_attr; /* HBA attributes */
320 struct bfa_ioc_driver_attr_s driver_attr; /* driver attr */
321 struct bfa_ioc_pci_attr_s pci_attr;
322 u8 port_id; /* port number */
323 u8 rsvd[7]; /* 64bit align */
324};
325
Jing Huangacdc79a2010-10-18 17:15:55 -0700326/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700327 * ---------------------- mfg definitions ------------
328 */
329
Jing Huangacdc79a2010-10-18 17:15:55 -0700330/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700331 * Checksum size
332 */
333#define BFA_MFG_CHKSUM_SIZE 16
334
335#define BFA_MFG_PARTNUM_SIZE 14
336#define BFA_MFG_SUPPLIER_ID_SIZE 10
337#define BFA_MFG_SUPPLIER_PARTNUM_SIZE 20
338#define BFA_MFG_SUPPLIER_SERIALNUM_SIZE 20
339#define BFA_MFG_SUPPLIER_REVISION_SIZE 4
340
341#pragma pack(1)
342
Jing Huangacdc79a2010-10-18 17:15:55 -0700343/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700344 * All numerical fields are in big-endian format.
345 */
346struct bfa_mfg_block_s {
347 u8 version; /* manufacturing block version */
348 u8 mfg_sig[3]; /* characters 'M', 'F', 'G' */
349 u16 mfgsize; /* mfg block size */
350 u16 u16_chksum; /* old u16 checksum */
351 char brcd_serialnum[STRSZ(BFA_MFG_SERIALNUM_SIZE)];
352 char brcd_partnum[STRSZ(BFA_MFG_PARTNUM_SIZE)];
353 u8 mfg_day; /* manufacturing day */
354 u8 mfg_month; /* manufacturing month */
355 u16 mfg_year; /* manufacturing year */
356 wwn_t mfg_wwn; /* wwn base for this adapter */
357 u8 num_wwn; /* number of wwns assigned */
358 u8 mfg_speeds; /* speeds allowed for this adapter */
359 u8 rsv[2];
360 char supplier_id[STRSZ(BFA_MFG_SUPPLIER_ID_SIZE)];
361 char supplier_partnum[STRSZ(BFA_MFG_SUPPLIER_PARTNUM_SIZE)];
362 char
363 supplier_serialnum[STRSZ(BFA_MFG_SUPPLIER_SERIALNUM_SIZE)];
364 char
365 supplier_revision[STRSZ(BFA_MFG_SUPPLIER_REVISION_SIZE)];
366 mac_t mfg_mac; /* mac address */
367 u8 num_mac; /* number of mac addresses */
368 u8 rsv2;
369 u32 mfg_type; /* card type */
370 u8 rsv3[108];
371 u8 md5_chksum[BFA_MFG_CHKSUM_SIZE]; /* md5 checksum */
372};
373
374#pragma pack()
375
Jing Huangacdc79a2010-10-18 17:15:55 -0700376/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700377 * ---------------------- pci definitions ------------
378 */
379
Jing Huangacdc79a2010-10-18 17:15:55 -0700380/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700381 * PCI device and vendor ID information
382 */
383enum {
384 BFA_PCI_VENDOR_ID_BROCADE = 0x1657,
385 BFA_PCI_DEVICE_ID_FC_8G2P = 0x13,
386 BFA_PCI_DEVICE_ID_FC_8G1P = 0x17,
387 BFA_PCI_DEVICE_ID_CT = 0x14,
388 BFA_PCI_DEVICE_ID_CT_FC = 0x21,
389};
390
391#define bfa_asic_id_ct(devid) \
392 ((devid) == BFA_PCI_DEVICE_ID_CT || \
393 (devid) == BFA_PCI_DEVICE_ID_CT_FC)
394
Jing Huangacdc79a2010-10-18 17:15:55 -0700395/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700396 * PCI sub-system device and vendor ID information
397 */
398enum {
399 BFA_PCI_FCOE_SSDEVICE_ID = 0x14,
400};
401
Jing Huangacdc79a2010-10-18 17:15:55 -0700402/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700403 * Maximum number of device address ranges mapped through different BAR(s)
404 */
405#define BFA_PCI_ACCESS_RANGES 1
406
407/*
408 * Port speed settings. Each specific speed is a bit field. Use multiple
409 * bits to specify speeds to be selected for auto-negotiation.
410 */
411enum bfa_port_speed {
412 BFA_PORT_SPEED_UNKNOWN = 0,
413 BFA_PORT_SPEED_1GBPS = 1,
414 BFA_PORT_SPEED_2GBPS = 2,
415 BFA_PORT_SPEED_4GBPS = 4,
416 BFA_PORT_SPEED_8GBPS = 8,
417 BFA_PORT_SPEED_10GBPS = 10,
418 BFA_PORT_SPEED_16GBPS = 16,
419 BFA_PORT_SPEED_AUTO =
420 (BFA_PORT_SPEED_1GBPS | BFA_PORT_SPEED_2GBPS |
421 BFA_PORT_SPEED_4GBPS | BFA_PORT_SPEED_8GBPS),
422};
423#define bfa_port_speed_t enum bfa_port_speed
424
425enum {
426 BFA_BOOT_BOOTLUN_MAX = 4, /* maximum boot lun per IOC */
427 BFA_PREBOOT_BOOTLUN_MAX = 8, /* maximum preboot lun per IOC */
428};
429
430#define BOOT_CFG_REV1 1
431#define BOOT_CFG_VLAN 1
432
Jing Huangacdc79a2010-10-18 17:15:55 -0700433/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700434 * Boot options setting. Boot options setting determines from where
435 * to get the boot lun information
436 */
437enum bfa_boot_bootopt {
438 BFA_BOOT_AUTO_DISCOVER = 0, /* Boot from blun provided by fabric */
439 BFA_BOOT_STORED_BLUN = 1, /* Boot from bluns stored in flash */
440 BFA_BOOT_FIRST_LUN = 2, /* Boot from first discovered blun */
441 BFA_BOOT_PBC = 3, /* Boot from pbc configured blun */
442};
443
444#pragma pack(1)
Jing Huangacdc79a2010-10-18 17:15:55 -0700445/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700446 * Boot lun information.
447 */
448struct bfa_boot_bootlun_s {
Maggie Zhangf3148782010-12-09 19:11:39 -0800449 wwn_t pwwn; /* port wwn of target */
450 struct scsi_lun lun; /* 64-bit lun */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700451};
452#pragma pack()
453
Jing Huangacdc79a2010-10-18 17:15:55 -0700454/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700455 * BOOT boot configuraton
456 */
457struct bfa_boot_pbc_s {
458 u8 enable; /* enable/disable SAN boot */
459 u8 speed; /* boot speed settings */
460 u8 topology; /* boot topology setting */
461 u8 rsvd1;
462 u32 nbluns; /* number of boot luns */
463 struct bfa_boot_bootlun_s pblun[BFA_PREBOOT_BOOTLUN_MAX];
464};
465
466#endif /* __BFA_DEFS_H__ */