1 /*
2  * Linux network driver for QLogic BR-series Converged Network Adapter.
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License (GPL) Version 2 as
6  * published by the Free Software Foundation
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * General Public License for more details.
12  */
13 /*
14  * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
15  * Copyright (c) 2014-2015 QLogic Corporation
16  * All rights reserved
17  * www.qlogic.com
18  */
19 #ifndef __BFA_DEFS_MFG_COMM_H__
20 #define __BFA_DEFS_MFG_COMM_H__
21 
22 #include "bfa_defs.h"
23 
24 /* Manufacturing block version */
25 #define BFA_MFG_VERSION				3
26 #define BFA_MFG_VERSION_UNINIT			0xFF
27 
28 /* Manufacturing block encrypted version */
29 #define BFA_MFG_ENC_VER				2
30 
31 /* Manufacturing block version 1 length */
32 #define BFA_MFG_VER1_LEN			128
33 
34 /* Manufacturing block header length */
35 #define BFA_MFG_HDR_LEN				4
36 
37 #define BFA_MFG_SERIALNUM_SIZE			11
38 #define STRSZ(_n)				(((_n) + 4) & ~3)
39 
40 /* Manufacturing card type */
41 enum {
42 	BFA_MFG_TYPE_CB_MAX  = 825,      /*!< Crossbow card type max	*/
43 	BFA_MFG_TYPE_FC8P2   = 825,      /*!< 8G 2port FC card		*/
44 	BFA_MFG_TYPE_FC8P1   = 815,      /*!< 8G 1port FC card		*/
45 	BFA_MFG_TYPE_FC4P2   = 425,      /*!< 4G 2port FC card		*/
46 	BFA_MFG_TYPE_FC4P1   = 415,      /*!< 4G 1port FC card		*/
47 	BFA_MFG_TYPE_CNA10P2 = 1020,     /*!< 10G 2port CNA card	*/
48 	BFA_MFG_TYPE_CNA10P1 = 1010,     /*!< 10G 1port CNA card	*/
49 	BFA_MFG_TYPE_JAYHAWK = 804,	 /*!< Jayhawk mezz card		*/
50 	BFA_MFG_TYPE_WANCHESE = 1007,	 /*!< Wanchese mezz card	*/
51 	BFA_MFG_TYPE_ASTRA    = 807,	 /*!< Astra mezz card		*/
52 	BFA_MFG_TYPE_LIGHTNING_P0 = 902, /*!< Lightning mezz card - old	*/
53 	BFA_MFG_TYPE_LIGHTNING = 1741,	 /*!< Lightning mezz card	*/
54 	BFA_MFG_TYPE_PROWLER_F = 1560,	 /*!< Prowler FC only cards	*/
55 	BFA_MFG_TYPE_PROWLER_N = 1410,	 /*!< Prowler NIC only cards	*/
56 	BFA_MFG_TYPE_PROWLER_C = 1710,	 /*!< Prowler CNA only cards	*/
57 	BFA_MFG_TYPE_PROWLER_D = 1860,	 /*!< Prowler Dual cards	*/
58 	BFA_MFG_TYPE_CHINOOK   = 1867,	 /*!< Chinook cards		*/
59 	BFA_MFG_TYPE_INVALID = 0,	 /*!< Invalid card type		*/
60 };
61 
62 /* Check if Mezz card */
63 #define bfa_mfg_is_mezz(type) (( \
64 	(type) == BFA_MFG_TYPE_JAYHAWK || \
65 	(type) == BFA_MFG_TYPE_WANCHESE || \
66 	(type) == BFA_MFG_TYPE_ASTRA || \
67 	(type) == BFA_MFG_TYPE_LIGHTNING_P0 || \
68 	(type) == BFA_MFG_TYPE_LIGHTNING || \
69 	(type) == BFA_MFG_TYPE_CHINOOK))
70 
71 enum {
72 	CB_GPIO_TTV	= (1),		/*!< TTV debug capable cards	*/
73 	CB_GPIO_FC8P2   = (2),		/*!< 8G 2port FC card		*/
74 	CB_GPIO_FC8P1   = (3),		/*!< 8G 1port FC card		*/
75 	CB_GPIO_FC4P2   = (4),		/*!< 4G 2port FC card		*/
76 	CB_GPIO_FC4P1   = (5),		/*!< 4G 1port FC card		*/
77 	CB_GPIO_DFLY    = (6),		/*!< 8G 2port FC mezzanine card	*/
78 	CB_GPIO_PROTO   = BIT(7)	/*!< 8G 2port FC prototypes	*/
79 };
80 
81 #define bfa_mfg_adapter_prop_init_gpio(gpio, card_type, prop)	\
82 do {								\
83 	if ((gpio) & CB_GPIO_PROTO) {				\
84 		(prop) |= BFI_ADAPTER_PROTO;			\
85 		(gpio) &= ~CB_GPIO_PROTO;			\
86 	}							\
87 	switch (gpio) {						\
88 	case CB_GPIO_TTV:					\
89 		(prop) |= BFI_ADAPTER_TTV;			\
90 	case CB_GPIO_DFLY:					\
91 	case CB_GPIO_FC8P2:					\
92 		(prop) |= BFI_ADAPTER_SETP(NPORTS, 2);		\
93 		(prop) |= BFI_ADAPTER_SETP(SPEED, 8);		\
94 		(card_type) = BFA_MFG_TYPE_FC8P2;		\
95 		break;						\
96 	case CB_GPIO_FC8P1:					\
97 		(prop) |= BFI_ADAPTER_SETP(NPORTS, 1);		\
98 		(prop) |= BFI_ADAPTER_SETP(SPEED, 8);		\
99 		(card_type) = BFA_MFG_TYPE_FC8P1;		\
100 		break;						\
101 	case CB_GPIO_FC4P2:					\
102 		(prop) |= BFI_ADAPTER_SETP(NPORTS, 2);		\
103 		(prop) |= BFI_ADAPTER_SETP(SPEED, 4);		\
104 		(card_type) = BFA_MFG_TYPE_FC4P2;		\
105 		break;						\
106 	case CB_GPIO_FC4P1:					\
107 		(prop) |= BFI_ADAPTER_SETP(NPORTS, 1);		\
108 		(prop) |= BFI_ADAPTER_SETP(SPEED, 4);		\
109 		(card_type) = BFA_MFG_TYPE_FC4P1;		\
110 		break;						\
111 	default:						\
112 		(prop) |= BFI_ADAPTER_UNSUPP;			\
113 		(card_type) = BFA_MFG_TYPE_INVALID;		\
114 	}							\
115 } while (0)
116 
117 /* VPD data length */
118 #define BFA_MFG_VPD_LEN			512
119 #define BFA_MFG_VPD_LEN_INVALID		0
120 
121 #define BFA_MFG_VPD_PCI_HDR_OFF		137
122 #define BFA_MFG_VPD_PCI_VER_MASK	0x07	/*!< version mask 3 bits */
123 #define BFA_MFG_VPD_PCI_VDR_MASK	0xf8	/*!< vendor mask 5 bits */
124 
125 /* VPD vendor tag */
126 enum {
127 	BFA_MFG_VPD_UNKNOWN	= 0,     /*!< vendor unknown		*/
128 	BFA_MFG_VPD_IBM		= 1,     /*!< vendor IBM		*/
129 	BFA_MFG_VPD_HP		= 2,     /*!< vendor HP			*/
130 	BFA_MFG_VPD_DELL	= 3,     /*!< vendor DELL		*/
131 	BFA_MFG_VPD_PCI_IBM	= 0x08,  /*!< PCI VPD IBM		*/
132 	BFA_MFG_VPD_PCI_HP	= 0x10,  /*!< PCI VPD HP		*/
133 	BFA_MFG_VPD_PCI_DELL	= 0x20,  /*!< PCI VPD DELL		*/
134 	BFA_MFG_VPD_PCI_BRCD	= 0xf8,  /*!< PCI VPD Brocade		*/
135 };
136 
137 /* BFA adapter flash vpd data definition.
138  *
139  * All numerical fields are in big-endian format.
140  */
141 struct bfa_mfg_vpd {
142 	u8		version;	/*!< vpd data version */
143 	u8		vpd_sig[3];	/*!< characters 'V', 'P', 'D' */
144 	u8		chksum;		/*!< u8 checksum */
145 	u8		vendor;		/*!< vendor */
146 	u8	len;		/*!< vpd data length excluding header */
147 	u8	rsv;
148 	u8		data[BFA_MFG_VPD_LEN];	/*!< vpd data */
149 } __packed;
150 
151 #endif /* __BFA_DEFS_MFG_H__ */
152