Browse Source

[thunderx] Use ThunderxConfigProtocol to obtain board configuration

Following changes were introduced:
 - added GetBgxProp and GetLmacProp methods to ThunderxConfigProtocol
 - replaced direct BOARD_CFG access with usage of introduced methods
 - removed redundant BOARD_CFG
 - changed GUID of ThunderxConfigProtocol, as this is not compatible
   with previous version
 - changed UINTN* to UINT64* buffer type to fix issue on 32-bit
   platforms with MAC address

This change allows us to avoid alignment of BOARD_CFG definitions
every time it changes in UEFI.

Signed-off-by: Konrad Adamczyk <konrad.adamczyk@cavium.com>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Adamczyk, Konrad 7 years ago
parent
commit
fd6d1f4660
2 changed files with 60 additions and 110 deletions
  1. 15
    9
      src/drivers/net/thunderx.c
  2. 45
    101
      src/drivers/net/thunderxcfg.h

+ 15
- 9
src/drivers/net/thunderx.c View File

@@ -1494,18 +1494,24 @@ static void txnic_bgx_init ( struct txnic_bgx *bgx, unsigned int type ) {
1494 1494
  */
1495 1495
 static void txnic_bgx_mac ( struct txnic_lmac *lmac ) {
1496 1496
 	struct txnic_bgx *bgx = lmac->bgx;
1497
-	BOARD_CFG *boardcfg;
1498
-	NODE_CFG *nodecfg;
1499
-	BGX_CFG *bgxcfg;
1500
-	LMAC_CFG *lmaccfg;
1497
+	unsigned int lmac_idx = TXNIC_LMAC_IDX ( lmac->idx );
1498
+	uint64_t mac;
1499
+	EFI_STATUS efirc;
1500
+	int rc;
1501 1501
 
1502 1502
 	/* Extract MAC from Board Configuration protocol, if available */
1503 1503
 	if ( txcfg ) {
1504
-		boardcfg = txcfg->BoardConfig;
1505
-		nodecfg = &boardcfg->Node[ bgx->node % MAX_NODES ];
1506
-		bgxcfg = &nodecfg->BgxCfg[ bgx->idx % BGX_PER_NODE_COUNT ];
1507
-		lmaccfg = &bgxcfg->Lmacs[ lmac->idx % LMAC_PER_BGX_COUNT ];
1508
-		lmac->mac.be64 = cpu_to_be64 ( lmaccfg->MacAddress );
1504
+		if ( ( efirc = txcfg->GetLmacProp ( txcfg, bgx->node, bgx->idx,
1505
+						    lmac_idx, MAC_ADDRESS,
1506
+						    sizeof ( mac ),
1507
+						    &mac ) ) == 0 ) {
1508
+			lmac->mac.be64 = cpu_to_be64 ( mac );
1509
+		} else {
1510
+			rc = -EEFI ( efirc );
1511
+			DBGC ( TXNICCOL ( bgx ), "TXNIC %d/%d/%d could not get "
1512
+			       "MAC address: %s\n", bgx->node, bgx->idx,
1513
+			       lmac->idx, strerror ( rc ) );
1514
+		}
1509 1515
 	} else {
1510 1516
 		DBGC ( TXNICCOL ( bgx ), "TXNIC %d/%d/%d has no board "
1511 1517
 		       "configuration protocol\n", bgx->node, bgx->idx,

+ 45
- 101
src/drivers/net/thunderxcfg.h View File

@@ -63,104 +63,6 @@ FILE_LICENCE ( BSD2 );
63 63
 
64 64
 #define THUNDERX_CPU_ID(node, cluster, core) (((node) << 16) | ((cluster) << 8) | (core))
65 65
 
66
-//TODO: Put common type definitions in separate common include file
67
-typedef enum {
68
-    BGX_MODE_SGMII, /* 1 lane, 1.250 Gbaud */
69
-    BGX_MODE_XAUI,  /* 4 lanes, 3.125 Gbaud */
70
-    BGX_MODE_DXAUI, /* 4 lanes, 6.250 Gbaud */
71
-    BGX_MODE_RXAUI, /* 2 lanes, 6.250 Gbaud */
72
-    BGX_MODE_XFI,   /* 1 lane, 10.3125 Gbaud */
73
-    BGX_MODE_XLAUI, /* 4 lanes, 10.3125 Gbaud */
74
-    BGX_MODE_10G_KR,/* 1 lane, 10.3125 Gbaud */
75
-    BGX_MODE_40G_KR,/* 4 lanes, 10.3125 Gbaud */
76
-    BGX_MODE_UNKNOWN
77
-} BGX_MODE_T;
78
-
79
-typedef enum {
80
-    EBB8800,
81
-    EBB8804,
82
-    CRB_1S,
83
-    CRB_2S,
84
-    ASIANCAT,
85
-    GBT_MT60,
86
-    INVENTEC_P3E003,
87
-    BOARD_MAX
88
-} BOARD_TYPE;
89
-
90
-typedef struct {
91
-    BOOLEAN Enabled;
92
-    UINT64  LaneToSds;
93
-    UINT64  MacAddress;
94
-} LMAC_CFG;
95
-
96
-typedef struct {
97
-    BOOLEAN BgxEnabled;
98
-    BGX_MODE_T BgxMode;
99
-    UINTN    LmacCount; //Maximum number of LMAcs
100
-    UINT64   BaseAddress;
101
-    UINT64   LmacType;
102
-    /* Bit mask of QLMs connected to this BGX */
103
-    UINT64   QlmMask;
104
-    UINT64   QlmFreq;
105
-    BOOLEAN  UseTraining;
106
-    LMAC_CFG Lmacs[LMAC_PER_BGX_COUNT];
107
-} BGX_CFG;
108
-
109
-typedef struct {
110
-    BOOLEAN PemUsable;
111
-} PEM_CFG;
112
-
113
-typedef struct {
114
-    enum { NotPresent, Empty, Available } Status;
115
-    UINT8 Type;
116
-    UINT8 SubType;
117
-    UINT8 Rank;
118
-    UINT16 Mfg;
119
-    UINTN SizeMb;
120
-    UINTN Speed;
121
-    CHAR8 Serial[16];
122
-    CHAR8 PartNo[24];
123
-} DIMM_CFG;
124
-
125
-typedef struct {
126
-    DIMM_CFG DimmCfg[DIMM_PER_LMC_COUNT];
127
-} LMC_CFG;
128
-
129
-typedef struct {
130
-    BOOLEAN Core[CORE_COUNT];
131
-    BGX_CFG BgxCfg[BGX_PER_NODE_COUNT];
132
-    PEM_CFG PemCfg[PEM_PER_NODE_COUNT];
133
-    LMC_CFG LmcCfg[LMC_PER_NODE_COUNT];
134
-    UINT64 RamStart;
135
-    UINT64 RamReserve;
136
-    UINT64 RamSize;
137
-    UINTN CPUSpeed;
138
-    UINTN CPUVersion;
139
-} NODE_CFG;
140
-
141
-#define MAX_SERIAL 32
142
-#define MAX_REVISION 32
143
-typedef struct {
144
-    BOARD_TYPE BoardType;
145
-    CHAR8 Serial[MAX_SERIAL];
146
-    CHAR8 Revision[MAX_REVISION];
147
-    UINTN NumNodes;
148
-    UINTN BmcBootTwsiBus;
149
-    UINTN BmcBootTwsiAddr;
150
-    UINTN RtcTwsiBus;
151
-    UINTN RtcTwsiAddr;
152
-    /* IPMI support*/
153
-    UINTN BmcIpmiTwsiBus;
154
-    UINTN BmcIpmiTwsiAddr;
155
-    NODE_CFG Node[MAX_NODES];
156
-    UINT16 CpuClusterCount;
157
-    UINT16 CpuPerClusterCount;
158
-    UINT16 PcieSegmentCount;
159
-    UINT64 MacAddrRangeStart;
160
-    UINTN DdrSpeed;
161
-    UINT64 AcpiOemTableId;
162
-} BOARD_CFG;
163
-
164 66
 /******************************************************************************
165 67
  *
166 68
  * From ThunderConfigProtocol.h
@@ -183,13 +85,30 @@ typedef struct {
183 85
  */
184 86
 
185 87
 #define EFI_THUNDER_CONFIG_PROTOCOL_GUID \
186
-  {0xb75a0608, 0x99ff, 0x11e5, {0x9b, 0xeb, 0x00, 0x14, 0xd1, 0xfa, 0x23, 0x5c}}
88
+  {0xc12b1873, 0xac17, 0x4176, {0xac, 0x77, 0x7e, 0xcb, 0x4d, 0xef, 0xff, 0xec}}
187 89
 
188 90
 ///
189 91
 /// Forward declaration
190 92
 ///
191 93
 typedef struct _EFI_THUNDER_CONFIG_PROTOCOL EFI_THUNDER_CONFIG_PROTOCOL;
192 94
 
95
+typedef enum {
96
+  BGX_ENABLED,
97
+  BGX_MODE,
98
+  LMAC_COUNT,
99
+  BASE_ADDRESS,
100
+  LMAC_TYPE_BGX,
101
+  QLM_MASK,
102
+  QLM_FREQ,
103
+  USE_TRAINING
104
+} BGX_PROPERTY;
105
+
106
+typedef enum {
107
+  ENABLED,
108
+  LANE_TO_SDS,
109
+  MAC_ADDRESS
110
+} LMAC_PROPERTY;
111
+
193 112
 ///
194 113
 /// Function prototypes
195 114
 ///
@@ -197,7 +116,30 @@ typedef
197 116
 EFI_STATUS
198 117
 (EFIAPI *EFI_THUNDER_CONFIG_PROTOCOL_GET_CONFIG)(
199 118
   IN EFI_THUNDER_CONFIG_PROTOCOL  *This,
200
-  OUT BOARD_CFG** cfg
119
+  OUT VOID** cfg
120
+  );
121
+
122
+typedef
123
+EFI_STATUS
124
+(EFIAPI *EFI_THUNDER_CONFIG_PROTOCOL_GET_BGX_PROP)(
125
+  IN EFI_THUNDER_CONFIG_PROTOCOL   *This,
126
+  IN UINTN                         NodeId,
127
+  IN UINTN                         BgxId,
128
+  IN BGX_PROPERTY                  BgxProp,
129
+  IN UINT64                        ValueSize,
130
+  OUT UINT64                       *Value
131
+  );
132
+
133
+typedef
134
+EFI_STATUS
135
+(EFIAPI *EFI_THUNDER_CONFIG_PROTOCOL_GET_LMAC_PROP)(
136
+  IN EFI_THUNDER_CONFIG_PROTOCOL   *This,
137
+  IN UINTN                         NodeId,
138
+  IN UINTN                         BgxId,
139
+  IN UINTN                         LmacId,
140
+  IN LMAC_PROPERTY                 LmacProp,
141
+  IN UINT64                        ValueSize,
142
+  OUT UINT64                       *Value
201 143
   );
202 144
 
203 145
 ///
@@ -205,7 +147,9 @@ EFI_STATUS
205 147
 ///
206 148
 struct _EFI_THUNDER_CONFIG_PROTOCOL {
207 149
   EFI_THUNDER_CONFIG_PROTOCOL_GET_CONFIG GetConfig;
208
-  BOARD_CFG* BoardConfig;
150
+  EFI_THUNDER_CONFIG_PROTOCOL_GET_BGX_PROP GetBgxProp;
151
+  EFI_THUNDER_CONFIG_PROTOCOL_GET_LMAC_PROP GetLmacProp;
152
+  VOID* BoardConfig;
209 153
 };
210 154
 
211 155
 #endif /* _THUNDERXCFG_H */

Loading…
Cancel
Save