aboutsummaryrefslogtreecommitdiffstats
path: root/src/drivers/net/intelxl.c
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2022-03-20 15:00:18 +0000
committerMichael Brown <mcb30@ipxe.org>2022-08-12 13:24:06 +0100
commit6871a7de705b6f6a4046f0d19da9bcd689c3bc8e (patch)
tree005671ba5af934f990e8920609e1bd827b873325 /src/drivers/net/intelxl.c
parent727b034f111ffbec26ecad0257871b8ade5cbb67 (diff)
downloadipxe-6871a7de705b6f6a4046f0d19da9bcd689c3bc8e.tar.gz
[intelxl] Use admin queue to set port MAC address and maximum frame size
Remove knowledge of the PRTGL_SA[HL] registers, and instead use the admin queue to set the MAC address and maximum frame size. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/drivers/net/intelxl.c')
-rw-r--r--src/drivers/net/intelxl.c79
1 files changed, 68 insertions, 11 deletions
diff --git a/src/drivers/net/intelxl.c b/src/drivers/net/intelxl.c
index dcc8db562..c8c527d53 100644
--- a/src/drivers/net/intelxl.c
+++ b/src/drivers/net/intelxl.c
@@ -536,6 +536,40 @@ static int intelxl_admin_mac_read ( struct net_device *netdev ) {
}
/**
+ * Set MAC address
+ *
+ * @v netdev Network device
+ * @ret rc Return status code
+ */
+static int intelxl_admin_mac_write ( struct net_device *netdev ) {
+ struct intelxl_nic *intelxl = netdev->priv;
+ struct intelxl_admin_descriptor *cmd;
+ struct intelxl_admin_mac_write_params *write;
+ union {
+ uint8_t raw[ETH_ALEN];
+ struct {
+ uint16_t high;
+ uint32_t low;
+ } __attribute__ (( packed ));
+ } mac;
+ int rc;
+
+ /* Populate descriptor */
+ cmd = intelxl_admin_command_descriptor ( intelxl );
+ cmd->opcode = cpu_to_le16 ( INTELXL_ADMIN_MAC_WRITE );
+ write = &cmd->params.mac_write;
+ memcpy ( mac.raw, netdev->ll_addr, ETH_ALEN );
+ write->high = bswap_16 ( mac.high );
+ write->low = bswap_32 ( mac.low );
+
+ /* Issue command */
+ if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
+ return rc;
+
+ return 0;
+}
+
+/**
* Clear PXE mode
*
* @v intelxl Intel device
@@ -687,6 +721,31 @@ static int intelxl_admin_promisc ( struct intelxl_nic *intelxl ) {
}
/**
+ * Set MAC configuration
+ *
+ * @v intelxl Intel device
+ * @ret rc Return status code
+ */
+static int intelxl_admin_mac_config ( struct intelxl_nic *intelxl ) {
+ struct intelxl_admin_descriptor *cmd;
+ struct intelxl_admin_mac_config_params *config;
+ int rc;
+
+ /* Populate descriptor */
+ cmd = intelxl_admin_command_descriptor ( intelxl );
+ cmd->opcode = cpu_to_le16 ( INTELXL_ADMIN_MAC_CONFIG );
+ config = &cmd->params.mac_config;
+ config->mfs = cpu_to_le16 ( intelxl->mfs );
+ config->flags = INTELXL_ADMIN_MAC_CONFIG_FL_CRC;
+
+ /* Issue command */
+ if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
+ return rc;
+
+ return 0;
+}
+
+/**
* Restart autonegotiation
*
* @v intelxl Intel device
@@ -1348,24 +1407,20 @@ void intelxl_empty_rx ( struct intelxl_nic *intelxl ) {
*/
static int intelxl_open ( struct net_device *netdev ) {
struct intelxl_nic *intelxl = netdev->priv;
- union intelxl_receive_address mac;
unsigned int queue;
- uint32_t prtgl_sal;
- uint32_t prtgl_sah;
int rc;
/* Calculate maximum frame size */
intelxl->mfs = ( ( ETH_HLEN + netdev->mtu + 4 /* CRC */ +
INTELXL_ALIGN - 1 ) & ~( INTELXL_ALIGN - 1 ) );
- /* Program MAC address and maximum frame size */
- memset ( &mac, 0, sizeof ( mac ) );
- memcpy ( mac.raw, netdev->ll_addr, sizeof ( mac.raw ) );
- prtgl_sal = le32_to_cpu ( mac.reg.low );
- prtgl_sah = ( le32_to_cpu ( mac.reg.high ) |
- INTELXL_PRTGL_SAH_MFS ( intelxl->mfs ) );
- writel ( prtgl_sal, intelxl->regs + INTELXL_PRTGL_SAL );
- writel ( prtgl_sah, intelxl->regs + INTELXL_PRTGL_SAH );
+ /* Set MAC address */
+ if ( ( rc = intelxl_admin_mac_write ( netdev ) ) != 0 )
+ goto err_mac_write;
+
+ /* Set maximum frame size */
+ if ( ( rc = intelxl_admin_mac_config ( intelxl ) ) != 0 )
+ goto err_mac_config;
/* Associate transmit queue to PF */
writel ( ( INTELXL_QXX_CTL_PFVF_Q_PF |
@@ -1408,6 +1463,8 @@ static int intelxl_open ( struct net_device *netdev ) {
err_create_tx:
intelxl_destroy_ring ( intelxl, &intelxl->rx );
err_create_rx:
+ err_mac_config:
+ err_mac_write:
return rc;
}