[intelxl] Use admin queue to get port MAC address
Remove knowledge of the PRTPM_SA[HL] registers, and instead use the admin queue to retrieve the MAC address. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
+52
-45
@@ -44,47 +44,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
*
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* MAC address
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fetch initial MAC address and maximum frame size
|
||||
*
|
||||
* @v intelxl Intel device
|
||||
* @v netdev Network device
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int intelxl_fetch_mac ( struct intelxl_nic *intelxl,
|
||||
struct net_device *netdev ) {
|
||||
union intelxl_receive_address mac;
|
||||
uint32_t prtpm_sal;
|
||||
uint32_t prtpm_sah;
|
||||
|
||||
/* Read NVM-loaded address */
|
||||
prtpm_sal = readl ( intelxl->regs + INTELXL_PRTPM_SAL );
|
||||
prtpm_sah = readl ( intelxl->regs + INTELXL_PRTPM_SAH );
|
||||
mac.reg.low = cpu_to_le32 ( prtpm_sal );
|
||||
mac.reg.high = cpu_to_le32 ( prtpm_sah );
|
||||
|
||||
/* Check that address is valid */
|
||||
if ( ! is_valid_ether_addr ( mac.raw ) ) {
|
||||
DBGC ( intelxl, "INTELXL %p has invalid MAC address (%s)\n",
|
||||
intelxl, eth_ntoa ( mac.raw ) );
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
/* Copy MAC address */
|
||||
DBGC ( intelxl, "INTELXL %p has autoloaded MAC address %s\n",
|
||||
intelxl, eth_ntoa ( mac.raw ) );
|
||||
memcpy ( netdev->hw_addr, mac.raw, ETH_ALEN );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* MSI-X interrupts
|
||||
@@ -528,6 +487,54 @@ static int intelxl_admin_shutdown ( struct intelxl_nic *intelxl ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get MAC address
|
||||
*
|
||||
* @v netdev Network device
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int intelxl_admin_mac_read ( struct net_device *netdev ) {
|
||||
struct intelxl_nic *intelxl = netdev->priv;
|
||||
struct intelxl_admin_descriptor *cmd;
|
||||
struct intelxl_admin_mac_read_params *read;
|
||||
union intelxl_admin_buffer *buf;
|
||||
uint8_t *mac;
|
||||
int rc;
|
||||
|
||||
/* Populate descriptor */
|
||||
cmd = intelxl_admin_command_descriptor ( intelxl );
|
||||
cmd->opcode = cpu_to_le16 ( INTELXL_ADMIN_MAC_READ );
|
||||
cmd->flags = cpu_to_le16 ( INTELXL_ADMIN_FL_BUF );
|
||||
cmd->len = cpu_to_le16 ( sizeof ( buf->mac_read ) );
|
||||
read = &cmd->params.mac_read;
|
||||
buf = intelxl_admin_command_buffer ( intelxl );
|
||||
mac = buf->mac_read.pf;
|
||||
|
||||
/* Issue command */
|
||||
if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
|
||||
return rc;
|
||||
|
||||
/* Check that MAC address is present in response */
|
||||
if ( ! ( read->valid & INTELXL_ADMIN_MAC_READ_VALID_LAN ) ) {
|
||||
DBGC ( intelxl, "INTELXL %p has no MAC address\n", intelxl );
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
/* Check that address is valid */
|
||||
if ( ! is_valid_ether_addr ( mac ) ) {
|
||||
DBGC ( intelxl, "INTELXL %p has invalid MAC address (%s)\n",
|
||||
intelxl, eth_ntoa ( mac ) );
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
/* Copy MAC address */
|
||||
DBGC ( intelxl, "INTELXL %p has MAC address %s\n",
|
||||
intelxl, eth_ntoa ( mac ) );
|
||||
memcpy ( netdev->hw_addr, mac, ETH_ALEN );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear PXE mode
|
||||
*
|
||||
@@ -1721,9 +1728,9 @@ static int intelxl_probe ( struct pci_device *pci ) {
|
||||
if ( ( rc = intelxl_admin_promisc ( intelxl ) ) != 0 )
|
||||
goto err_admin_promisc;
|
||||
|
||||
/* Fetch MAC address and maximum frame size */
|
||||
if ( ( rc = intelxl_fetch_mac ( intelxl, netdev ) ) != 0 )
|
||||
goto err_fetch_mac;
|
||||
/* Get MAC address */
|
||||
if ( ( rc = intelxl_admin_mac_read ( netdev ) ) != 0 )
|
||||
goto err_admin_mac_read;
|
||||
|
||||
/* Configure queue register addresses */
|
||||
intelxl->tx.reg = INTELXL_QTX ( intelxl->queue );
|
||||
@@ -1756,7 +1763,7 @@ static int intelxl_probe ( struct pci_device *pci ) {
|
||||
|
||||
unregister_netdev ( netdev );
|
||||
err_register_netdev:
|
||||
err_fetch_mac:
|
||||
err_admin_mac_read:
|
||||
err_admin_promisc:
|
||||
err_admin_vsi:
|
||||
err_admin_switch:
|
||||
|
||||
Reference in New Issue
Block a user