mirror of
https://github.com/ipxe/ipxe
synced 2025-12-13 23:41:45 +03:00
[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:
@@ -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
|
* MSI-X interrupts
|
||||||
@@ -528,6 +487,54 @@ static int intelxl_admin_shutdown ( struct intelxl_nic *intelxl ) {
|
|||||||
return 0;
|
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
|
* Clear PXE mode
|
||||||
*
|
*
|
||||||
@@ -1721,9 +1728,9 @@ static int intelxl_probe ( struct pci_device *pci ) {
|
|||||||
if ( ( rc = intelxl_admin_promisc ( intelxl ) ) != 0 )
|
if ( ( rc = intelxl_admin_promisc ( intelxl ) ) != 0 )
|
||||||
goto err_admin_promisc;
|
goto err_admin_promisc;
|
||||||
|
|
||||||
/* Fetch MAC address and maximum frame size */
|
/* Get MAC address */
|
||||||
if ( ( rc = intelxl_fetch_mac ( intelxl, netdev ) ) != 0 )
|
if ( ( rc = intelxl_admin_mac_read ( netdev ) ) != 0 )
|
||||||
goto err_fetch_mac;
|
goto err_admin_mac_read;
|
||||||
|
|
||||||
/* Configure queue register addresses */
|
/* Configure queue register addresses */
|
||||||
intelxl->tx.reg = INTELXL_QTX ( intelxl->queue );
|
intelxl->tx.reg = INTELXL_QTX ( intelxl->queue );
|
||||||
@@ -1756,7 +1763,7 @@ static int intelxl_probe ( struct pci_device *pci ) {
|
|||||||
|
|
||||||
unregister_netdev ( netdev );
|
unregister_netdev ( netdev );
|
||||||
err_register_netdev:
|
err_register_netdev:
|
||||||
err_fetch_mac:
|
err_admin_mac_read:
|
||||||
err_admin_promisc:
|
err_admin_promisc:
|
||||||
err_admin_vsi:
|
err_admin_vsi:
|
||||||
err_admin_switch:
|
err_admin_switch:
|
||||||
|
|||||||
@@ -145,6 +145,32 @@ struct intelxl_admin_shutdown_params {
|
|||||||
/** Driver is unloading */
|
/** Driver is unloading */
|
||||||
#define INTELXL_ADMIN_SHUTDOWN_UNLOADING 0x01
|
#define INTELXL_ADMIN_SHUTDOWN_UNLOADING 0x01
|
||||||
|
|
||||||
|
/** Admin queue Manage MAC Address Read command */
|
||||||
|
#define INTELXL_ADMIN_MAC_READ 0x0107
|
||||||
|
|
||||||
|
/** Admin queue Manage MAC Address Read command parameters */
|
||||||
|
struct intelxl_admin_mac_read_params {
|
||||||
|
/** Valid addresses */
|
||||||
|
uint8_t valid;
|
||||||
|
/** Reserved */
|
||||||
|
uint8_t reserved[15];
|
||||||
|
} __attribute__ (( packed ));
|
||||||
|
|
||||||
|
/** LAN MAC address is valid */
|
||||||
|
#define INTELXL_ADMIN_MAC_READ_VALID_LAN 0x10
|
||||||
|
|
||||||
|
/** Admin queue Manage MAC Address Read data buffer */
|
||||||
|
struct intelxl_admin_mac_read_buffer {
|
||||||
|
/** Physical function MAC address */
|
||||||
|
uint8_t pf[ETH_ALEN];
|
||||||
|
/** Reserved */
|
||||||
|
uint8_t reserved[ETH_ALEN];
|
||||||
|
/** Port MAC address */
|
||||||
|
uint8_t port[ETH_ALEN];
|
||||||
|
/** Physical function wake-on-LAN MAC address */
|
||||||
|
uint8_t wol[ETH_ALEN];
|
||||||
|
} __attribute__ (( packed ));
|
||||||
|
|
||||||
/** Admin queue Clear PXE Mode command */
|
/** Admin queue Clear PXE Mode command */
|
||||||
#define INTELXL_ADMIN_CLEAR_PXE 0x0110
|
#define INTELXL_ADMIN_CLEAR_PXE 0x0110
|
||||||
|
|
||||||
@@ -315,6 +341,8 @@ union intelxl_admin_params {
|
|||||||
struct intelxl_admin_driver_params driver;
|
struct intelxl_admin_driver_params driver;
|
||||||
/** Shutdown command parameters */
|
/** Shutdown command parameters */
|
||||||
struct intelxl_admin_shutdown_params shutdown;
|
struct intelxl_admin_shutdown_params shutdown;
|
||||||
|
/** Manage MAC Address Read command parameters */
|
||||||
|
struct intelxl_admin_mac_read_params mac_read;
|
||||||
/** Clear PXE Mode command parameters */
|
/** Clear PXE Mode command parameters */
|
||||||
struct intelxl_admin_clear_pxe_params pxe;
|
struct intelxl_admin_clear_pxe_params pxe;
|
||||||
/** Get Switch Configuration command parameters */
|
/** Get Switch Configuration command parameters */
|
||||||
@@ -336,6 +364,8 @@ union intelxl_admin_params {
|
|||||||
union intelxl_admin_buffer {
|
union intelxl_admin_buffer {
|
||||||
/** Driver Version data buffer */
|
/** Driver Version data buffer */
|
||||||
struct intelxl_admin_driver_buffer driver;
|
struct intelxl_admin_driver_buffer driver;
|
||||||
|
/** Manage MAC Address Read data buffer */
|
||||||
|
struct intelxl_admin_mac_read_buffer mac_read;
|
||||||
/** Get Switch Configuration data buffer */
|
/** Get Switch Configuration data buffer */
|
||||||
struct intelxl_admin_switch_buffer sw;
|
struct intelxl_admin_switch_buffer sw;
|
||||||
/** Get VSI Parameters data buffer */
|
/** Get VSI Parameters data buffer */
|
||||||
@@ -831,12 +861,6 @@ intelxl_init_ring ( struct intelxl_ring *ring, unsigned int count, size_t len,
|
|||||||
#define INTELXL_PRTGL_SAH 0x1e2140
|
#define INTELXL_PRTGL_SAH 0x1e2140
|
||||||
#define INTELXL_PRTGL_SAH_MFS(x) ( (x) << 16 ) /**< Max frame size */
|
#define INTELXL_PRTGL_SAH_MFS(x) ( (x) << 16 ) /**< Max frame size */
|
||||||
|
|
||||||
/** Physical Function MAC Address Low Register */
|
|
||||||
#define INTELXL_PRTPM_SAL 0x1e4440
|
|
||||||
|
|
||||||
/** Physical Function MAC Address High Register */
|
|
||||||
#define INTELXL_PRTPM_SAH 0x1e44c0
|
|
||||||
|
|
||||||
/** Receive address */
|
/** Receive address */
|
||||||
union intelxl_receive_address {
|
union intelxl_receive_address {
|
||||||
struct {
|
struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user