diff options
Diffstat (limited to 'src/drivers/net/intelxl.c')
-rw-r--r-- | src/drivers/net/intelxl.c | 97 |
1 files changed, 52 insertions, 45 deletions
diff --git a/src/drivers/net/intelxl.c b/src/drivers/net/intelxl.c index 438657fd3..dcc8db562 100644 --- a/src/drivers/net/intelxl.c +++ b/src/drivers/net/intelxl.c @@ -46,47 +46,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 * ****************************************************************************** @@ -529,6 +488,54 @@ static int intelxl_admin_shutdown ( struct intelxl_nic *intelxl ) { } /** + * 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 * * @v intelxl Intel device @@ -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: |