aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2022-03-18 12:41:33 +0000
committerMichael Brown <mcb30@ipxe.org>2022-08-12 13:03:12 +0100
commit727b034f111ffbec26ecad0257871b8ade5cbb67 (patch)
tree641e97a76b352f0eae2c06d7ba502fa749c1114d
parent06467ee70fd4750ecd2ae324f66055ff261cb713 (diff)
downloadipxe-727b034f111ffbec26ecad0257871b8ade5cbb67.zip
ipxe-727b034f111ffbec26ecad0257871b8ade5cbb67.tar.gz
ipxe-727b034f111ffbec26ecad0257871b8ade5cbb67.tar.bz2
[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>
-rw-r--r--src/drivers/net/intelxl.c97
-rw-r--r--src/drivers/net/intelxl.h36
2 files changed, 82 insertions, 51 deletions
diff --git a/src/drivers/net/intelxl.c b/src/drivers/net/intelxl.c
index 438657f..dcc8db5 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:
diff --git a/src/drivers/net/intelxl.h b/src/drivers/net/intelxl.h
index ddd3e88..610b301 100644
--- a/src/drivers/net/intelxl.h
+++ b/src/drivers/net/intelxl.h
@@ -145,6 +145,32 @@ struct intelxl_admin_shutdown_params {
/** Driver is unloading */
#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 */
#define INTELXL_ADMIN_CLEAR_PXE 0x0110
@@ -315,6 +341,8 @@ union intelxl_admin_params {
struct intelxl_admin_driver_params driver;
/** Shutdown command parameters */
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 */
struct intelxl_admin_clear_pxe_params pxe;
/** Get Switch Configuration command parameters */
@@ -336,6 +364,8 @@ union intelxl_admin_params {
union intelxl_admin_buffer {
/** Driver Version data buffer */
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 */
struct intelxl_admin_switch_buffer sw;
/** 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_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 */
union intelxl_receive_address {
struct {