[thunderx] Retrieve base MAC address via EFI_THUNDER_CONFIG_PROTOCOL

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2016-06-13 18:41:33 +01:00
parent 8f0bec4346
commit 25ae251dd9
2 changed files with 250 additions and 1 deletions

View File

@@ -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
@@ -1478,6 +1483,39 @@ static void txnic_bgx_init ( struct txnic_bgx *bgx, unsigned int type ) {
writeq ( global_config, ( bgx->regs + BGX_CMR_GLOBAL_CONFIG ) );
}
/**
* 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)
*
@@ -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 );