[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>
pull/697/head^2
Michael Brown 2022-03-20 15:00:18 +00:00
parent 727b034f11
commit 6871a7de70
2 changed files with 105 additions and 27 deletions

View File

@ -535,6 +535,40 @@ static int intelxl_admin_mac_read ( struct net_device *netdev ) {
return 0; return 0;
} }
/**
* 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 * Clear PXE mode
* *
@ -686,6 +720,31 @@ static int intelxl_admin_promisc ( struct intelxl_nic *intelxl ) {
return 0; return 0;
} }
/**
* 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 * Restart autonegotiation
* *
@ -1348,24 +1407,20 @@ void intelxl_empty_rx ( struct intelxl_nic *intelxl ) {
*/ */
static int intelxl_open ( struct net_device *netdev ) { static int intelxl_open ( struct net_device *netdev ) {
struct intelxl_nic *intelxl = netdev->priv; struct intelxl_nic *intelxl = netdev->priv;
union intelxl_receive_address mac;
unsigned int queue; unsigned int queue;
uint32_t prtgl_sal;
uint32_t prtgl_sah;
int rc; int rc;
/* Calculate maximum frame size */ /* Calculate maximum frame size */
intelxl->mfs = ( ( ETH_HLEN + netdev->mtu + 4 /* CRC */ + intelxl->mfs = ( ( ETH_HLEN + netdev->mtu + 4 /* CRC */ +
INTELXL_ALIGN - 1 ) & ~( INTELXL_ALIGN - 1 ) ); INTELXL_ALIGN - 1 ) & ~( INTELXL_ALIGN - 1 ) );
/* Program MAC address and maximum frame size */ /* Set MAC address */
memset ( &mac, 0, sizeof ( mac ) ); if ( ( rc = intelxl_admin_mac_write ( netdev ) ) != 0 )
memcpy ( mac.raw, netdev->ll_addr, sizeof ( mac.raw ) ); goto err_mac_write;
prtgl_sal = le32_to_cpu ( mac.reg.low );
prtgl_sah = ( le32_to_cpu ( mac.reg.high ) | /* Set maximum frame size */
INTELXL_PRTGL_SAH_MFS ( intelxl->mfs ) ); if ( ( rc = intelxl_admin_mac_config ( intelxl ) ) != 0 )
writel ( prtgl_sal, intelxl->regs + INTELXL_PRTGL_SAL ); goto err_mac_config;
writel ( prtgl_sah, intelxl->regs + INTELXL_PRTGL_SAH );
/* Associate transmit queue to PF */ /* Associate transmit queue to PF */
writel ( ( INTELXL_QXX_CTL_PFVF_Q_PF | writel ( ( INTELXL_QXX_CTL_PFVF_Q_PF |
@ -1408,6 +1463,8 @@ static int intelxl_open ( struct net_device *netdev ) {
err_create_tx: err_create_tx:
intelxl_destroy_ring ( intelxl, &intelxl->rx ); intelxl_destroy_ring ( intelxl, &intelxl->rx );
err_create_rx: err_create_rx:
err_mac_config:
err_mac_write:
return rc; return rc;
} }

View File

@ -171,6 +171,23 @@ struct intelxl_admin_mac_read_buffer {
uint8_t wol[ETH_ALEN]; uint8_t wol[ETH_ALEN];
} __attribute__ (( packed )); } __attribute__ (( packed ));
/** Admin queue Manage MAC Address Write command */
#define INTELXL_ADMIN_MAC_WRITE 0x0108
/** Admin queue Manage MAC Address Write command parameters */
struct intelxl_admin_mac_write_params {
/** Reserved */
uint8_t reserved_a[1];
/** Write type */
uint8_t type;
/** MAC address first 16 bits, byte-swapped */
uint16_t high;
/** MAC address last 32 bits, byte-swapped */
uint32_t low;
/** Reserved */
uint8_t reserved_b[8];
} __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
@ -289,6 +306,22 @@ struct intelxl_admin_promisc_params {
/** Promiscuous VLAN mode */ /** Promiscuous VLAN mode */
#define INTELXL_ADMIN_PROMISC_FL_VLAN 0x0010 #define INTELXL_ADMIN_PROMISC_FL_VLAN 0x0010
/** Admin queue Set MAC Configuration command */
#define INTELXL_ADMIN_MAC_CONFIG 0x0603
/** Admin queue Set MAC Configuration command parameters */
struct intelxl_admin_mac_config_params {
/** Maximum frame size */
uint16_t mfs;
/** Flags */
uint8_t flags;
/** Reserved */
uint8_t reserved[13];
} __attribute__ (( packed ));
/** Append CRC on transmit */
#define INTELXL_ADMIN_MAC_CONFIG_FL_CRC 0x04
/** Admin queue Restart Autonegotiation command */ /** Admin queue Restart Autonegotiation command */
#define INTELXL_ADMIN_AUTONEG 0x0605 #define INTELXL_ADMIN_AUTONEG 0x0605
@ -343,6 +376,8 @@ union intelxl_admin_params {
struct intelxl_admin_shutdown_params shutdown; struct intelxl_admin_shutdown_params shutdown;
/** Manage MAC Address Read command parameters */ /** Manage MAC Address Read command parameters */
struct intelxl_admin_mac_read_params mac_read; struct intelxl_admin_mac_read_params mac_read;
/** Manage MAC Address Write command parameters */
struct intelxl_admin_mac_write_params mac_write;
/** 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 */
@ -351,6 +386,8 @@ union intelxl_admin_params {
struct intelxl_admin_vsi_params vsi; struct intelxl_admin_vsi_params vsi;
/** Set VSI Promiscuous Modes command parameters */ /** Set VSI Promiscuous Modes command parameters */
struct intelxl_admin_promisc_params promisc; struct intelxl_admin_promisc_params promisc;
/** Set MAC Configuration command parameters */
struct intelxl_admin_mac_config_params mac_config;
/** Restart Autonegotiation command parameters */ /** Restart Autonegotiation command parameters */
struct intelxl_admin_autoneg_params autoneg; struct intelxl_admin_autoneg_params autoneg;
/** Get Link Status command parameters */ /** Get Link Status command parameters */
@ -854,22 +891,6 @@ intelxl_init_ring ( struct intelxl_ring *ring, unsigned int count, size_t len,
#define INTELXL_PFGEN_PORTNUM_PORT_NUM(x) \ #define INTELXL_PFGEN_PORTNUM_PORT_NUM(x) \
( ( (x) >> 0 ) & 0x3 ) /**< Port number */ ( ( (x) >> 0 ) & 0x3 ) /**< Port number */
/** Port MAC Address Low Register */
#define INTELXL_PRTGL_SAL 0x1e2120
/** Port MAC Address High Register */
#define INTELXL_PRTGL_SAH 0x1e2140
#define INTELXL_PRTGL_SAH_MFS(x) ( (x) << 16 ) /**< Max frame size */
/** Receive address */
union intelxl_receive_address {
struct {
uint32_t low;
uint32_t high;
} __attribute__ (( packed )) reg;
uint8_t raw[ETH_ALEN];
};
/** MSI-X interrupt */ /** MSI-X interrupt */
struct intelxl_msix { struct intelxl_msix {
/** PCI capability */ /** PCI capability */