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