summaryrefslogtreecommitdiffstats
path: root/src/drivers/net/thunderx.c
diff options
context:
space:
mode:
authorMichael Brown2016-06-13 19:41:33 +0200
committerMichael Brown2016-06-18 20:28:38 +0200
commit25ae251dd918fd427e7e01d2befc0ac34aabcaa8 (patch)
tree3ca6a2f94df49c24d942c7b56e51a4a3b4fb29a9 /src/drivers/net/thunderx.c
parent[efi] Include VLAN in SNP device path if applicable (diff)
downloadipxe-25ae251dd918fd427e7e01d2befc0ac34aabcaa8.tar.gz
ipxe-25ae251dd918fd427e7e01d2befc0ac34aabcaa8.tar.xz
ipxe-25ae251dd918fd427e7e01d2befc0ac34aabcaa8.zip
[thunderx] Retrieve base MAC address via EFI_THUNDER_CONFIG_PROTOCOL
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/drivers/net/thunderx.c')
-rw-r--r--src/drivers/net/thunderx.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/drivers/net/thunderx.c b/src/drivers/net/thunderx.c
index 63aa23ef..306adc45 100644
--- a/src/drivers/net/thunderx.c
+++ b/src/drivers/net/thunderx.c
@@ -40,6 +40,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <ipxe/pciea.h>
#include <ipxe/umalloc.h>
#include "thunderx.h"
+#include "thunderxcfg.h"
/** @file
*
@@ -56,6 +57,10 @@ static LIST_HEAD ( txnic_pfs );
/** Debug colour for physical function and BGX messages */
#define TXNICCOL(x) ( &txnic_pfs + (x)->node )
+/** Board configuration protocol */
+static EFI_THUNDER_CONFIG_PROTOCOL *txcfg;
+EFI_REQUEST_PROTOCOL ( EFI_THUNDER_CONFIG_PROTOCOL, &txcfg );
+
/******************************************************************************
*
* Diagnostics
@@ -1479,6 +1484,39 @@ static void txnic_bgx_init ( struct txnic_bgx *bgx, unsigned int type ) {
}
/**
+ * Get MAC address
+ *
+ * @v lmac Logical MAC
+ */
+static void txnic_bgx_mac ( struct txnic_lmac *lmac ) {
+ struct txnic_bgx *bgx = lmac->bgx;
+ BOARD_CFG *boardcfg;
+ NODE_CFG *nodecfg;
+ BGX_CFG *bgxcfg;
+ LMAC_CFG *lmaccfg;
+
+ /* Extract MAC from Board Configuration protocol, if available */
+ if ( txcfg ) {
+ boardcfg = txcfg->BoardConfig;
+ nodecfg = &boardcfg->Node[ bgx->node % MAX_NODES ];
+ bgxcfg = &nodecfg->BgxCfg[ bgx->idx % BGX_PER_NODE_COUNT ];
+ lmaccfg = &bgxcfg->Lmacs[ lmac->idx % LMAC_PER_BGX_COUNT ];
+ lmac->mac.be64 = cpu_to_be64 ( lmaccfg->MacAddress );
+ } else {
+ DBGC ( TXNICCOL ( bgx ), "TXNIC %d/%d/%d has no board "
+ "configuration protocol\n", bgx->node, bgx->idx,
+ lmac->idx );
+ }
+
+ /* Use random MAC address if none available */
+ if ( ! lmac->mac.be64 ) {
+ DBGC ( TXNICCOL ( bgx ), "TXNIC %d/%d/%d has no MAC address\n",
+ bgx->node, bgx->idx, lmac->idx );
+ eth_random_addr ( lmac->mac.raw );
+ }
+}
+
+/**
* Initialise Super PHY Unit (SPU)
*
* @v lmac Logical MAC
@@ -1533,7 +1571,7 @@ static void txnic_bgx_lmac_init ( struct txnic_bgx *bgx,
lmac->idx = TXNIC_VNIC_IDX ( bgx->idx, lmac_idx );
/* Set MAC address */
- eth_random_addr ( lmac->mac.raw );
+ txnic_bgx_mac ( lmac );
/* Initialise PHY */
txnic_bgx_spu_init ( lmac );