diff options
author | Michael Brown <mcb30@ipxe.org> | 2022-08-08 14:34:47 +0100 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2022-08-11 14:53:54 +0100 |
commit | 67f8878e102accdff5f82130c0c0dd85ebc698d0 (patch) | |
tree | 801a11538b063ebbbbe8d6f1fa0dfb6a75de8069 | |
parent | 9e46ffa924397e72f750a5a4848a42c597396742 (diff) | |
download | ipxe-67f8878e102accdff5f82130c0c0dd85ebc698d0.zip ipxe-67f8878e102accdff5f82130c0c0dd85ebc698d0.tar.gz ipxe-67f8878e102accdff5f82130c0c0dd85ebc698d0.tar.bz2 |
[intelxl] Handle admin events via a callback
The physical and virtual function drivers each care about precisely
one admin queue event type. Simplify event handling by using a
per-driver callback instead of the existing weak function symbol.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r-- | src/drivers/net/intelxl.c | 39 | ||||
-rw-r--r-- | src/drivers/net/intelxl.h | 15 | ||||
-rw-r--r-- | src/drivers/net/intelxlvf.c | 19 |
3 files changed, 43 insertions, 30 deletions
diff --git a/src/drivers/net/intelxl.c b/src/drivers/net/intelxl.c index be4e911..e31595e 100644 --- a/src/drivers/net/intelxl.c +++ b/src/drivers/net/intelxl.c @@ -743,18 +743,26 @@ static int intelxl_admin_link ( struct net_device *netdev ) { } /** - * Handle virtual function event (when VF driver is not present) + * Handle admin event * * @v netdev Network device - * @v evt Admin queue event descriptor - * @v buf Admin queue event data buffer + * @v evt Event descriptor + * @v buf Data buffer */ -__weak void -intelxlvf_admin_event ( struct net_device *netdev __unused, - struct intelxl_admin_descriptor *evt __unused, - union intelxl_admin_buffer *buf __unused ) { +static void intelxl_admin_event ( struct net_device *netdev, + struct intelxl_admin_descriptor *evt, + union intelxl_admin_buffer *buf __unused ) { + struct intelxl_nic *intelxl = netdev->priv; - /* Nothing to do */ + /* Ignore unrecognised events */ + if ( evt->opcode != cpu_to_le16 ( INTELXL_ADMIN_LINK ) ) { + DBGC ( intelxl, "INTELXL %p unrecognised event opcode " + "%#04x\n", intelxl, le16_to_cpu ( evt->opcode ) ); + return; + } + + /* Update link status */ + intelxl_admin_link ( netdev ); } /** @@ -806,19 +814,7 @@ void intelxl_poll_admin ( struct net_device *netdev ) { } /* Handle event */ - switch ( evt->opcode ) { - case cpu_to_le16 ( INTELXL_ADMIN_LINK ): - intelxl_admin_link ( netdev ); - break; - case cpu_to_le16 ( INTELXL_ADMIN_SEND_TO_VF ): - intelxlvf_admin_event ( netdev, evt, buf ); - break; - default: - DBGC ( intelxl, "INTELXL %p admin event %#x " - "unrecognised opcode %#04x\n", intelxl, - admin->index, le16_to_cpu ( evt->opcode ) ); - break; - } + intelxl->handle ( netdev, evt, buf ); /* Reset descriptor and refill queue */ intelxl_admin_event_init ( intelxl, admin->index ); @@ -1645,6 +1641,7 @@ static int intelxl_probe ( struct pci_device *pci ) { netdev->dev = &pci->dev; memset ( intelxl, 0, sizeof ( *intelxl ) ); intelxl->intr = INTELXL_PFINT_DYN_CTL0; + intelxl->handle = intelxl_admin_event; intelxl_init_admin ( &intelxl->command, INTELXL_ADMIN_CMD, &intelxl_admin_offsets ); intelxl_init_admin ( &intelxl->event, INTELXL_ADMIN_EVT, diff --git a/src/drivers/net/intelxl.h b/src/drivers/net/intelxl.h index 066eb0f..cd0d2ee 100644 --- a/src/drivers/net/intelxl.h +++ b/src/drivers/net/intelxl.h @@ -1103,6 +1103,17 @@ struct intelxl_nic { struct intelxl_ring rx; /** Receive I/O buffers */ struct io_buffer *rx_iobuf[INTELXL_RX_NUM_DESC]; + + /** + * Handle admin event + * + * @v netdev Network device + * @v evt Event descriptor + * @v buf Data buffer + */ + void ( * handle ) ( struct net_device *netdev, + struct intelxl_admin_descriptor *evt, + union intelxl_admin_buffer *buf ); }; extern int intelxl_msix_enable ( struct intelxl_nic *intelxl, @@ -1129,8 +1140,4 @@ extern int intelxl_transmit ( struct net_device *netdev, struct io_buffer *iobuf ); extern void intelxl_poll ( struct net_device *netdev ); -extern void intelxlvf_admin_event ( struct net_device *netdev, - struct intelxl_admin_descriptor *evt, - union intelxl_admin_buffer *buf ); - #endif /* _INTELXL_H */ diff --git a/src/drivers/net/intelxlvf.c b/src/drivers/net/intelxlvf.c index ed78589..6f52f13 100644 --- a/src/drivers/net/intelxlvf.c +++ b/src/drivers/net/intelxlvf.c @@ -261,19 +261,27 @@ intelxlvf_admin_status ( struct net_device *netdev, } /** - * Handle virtual function event + * Handle admin event * * @v netdev Network device * @v evt Admin queue event descriptor * @v buf Admin queue event data buffer */ -void intelxlvf_admin_event ( struct net_device *netdev, - struct intelxl_admin_descriptor *evt, - union intelxl_admin_buffer *buf ) { +static void intelxlvf_admin_event ( struct net_device *netdev, + struct intelxl_admin_descriptor *evt, + union intelxl_admin_buffer *buf ) { struct intelxl_nic *intelxl = netdev->priv; - unsigned int vopcode = le32_to_cpu ( evt->vopcode ); + unsigned int vopcode; + + /* Ignore unrecognised events */ + if ( evt->opcode != cpu_to_le16 ( INTELXL_ADMIN_SEND_TO_VF ) ) { + DBGC ( intelxl, "INTELXL %p unrecognised event opcode " + "%#04x\n", intelxl, le16_to_cpu ( evt->opcode ) ); + return; + } /* Record command response if applicable */ + vopcode = le32_to_cpu ( evt->vopcode ); if ( vopcode == intelxl->vopcode ) { memcpy ( &intelxl->vbuf, buf, sizeof ( intelxl->vbuf ) ); intelxl->vopcode = 0; @@ -626,6 +634,7 @@ static int intelxlvf_probe ( struct pci_device *pci ) { netdev->dev = &pci->dev; memset ( intelxl, 0, sizeof ( *intelxl ) ); intelxl->intr = INTELXLVF_VFINT_DYN_CTLN ( INTELXLVF_MSIX_VECTOR ); + intelxl->handle = intelxlvf_admin_event; intelxl_init_admin ( &intelxl->command, INTELXLVF_ADMIN, &intelxlvf_admin_command_offsets ); intelxl_init_admin ( &intelxl->event, INTELXLVF_ADMIN, |