From c7b76e3adc3b4365aa3b490f24ae22375901c559 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 24 Jul 2024 14:30:58 +0100 Subject: [gve] Add driver for Google Virtual Ethernet NIC The Google Virtual Ethernet NIC (GVE or gVNIC) is found only in Google Cloud instances. There is essentially zero documentation available beyond the mostly uncommented source code in the Linux kernel. Signed-off-by: Michael Brown --- src/drivers/net/gve.c | 1607 +++++++++++++++++++++++++++++++++++++++++++++++++ src/drivers/net/gve.h | 702 +++++++++++++++++++++ 2 files changed, 2309 insertions(+) create mode 100644 src/drivers/net/gve.c create mode 100644 src/drivers/net/gve.h (limited to 'src/drivers') diff --git a/src/drivers/net/gve.c b/src/drivers/net/gve.c new file mode 100644 index 000000000..03edc0899 --- /dev/null +++ b/src/drivers/net/gve.c @@ -0,0 +1,1607 @@ +/* + * Copyright (C) 2024 Michael Brown . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + * + * You can also choose to distribute this program under the terms of + * the Unmodified Binary Distribution Licence (as given in the file + * COPYING.UBDL), provided that you have satisfied its requirements. + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "gve.h" + +/** @file + * + * Google Virtual Ethernet network driver + * + */ + +/* Disambiguate the various error causes */ +#define EINFO_EIO_ADMIN_UNSET \ + __einfo_uniqify ( EINFO_EIO, 0x00, "Uncompleted" ) +#define EIO_ADMIN_UNSET \ + __einfo_error ( EINFO_EIO_ADMIN_UNSET ) +#define EINFO_EIO_ADMIN_ABORTED \ + __einfo_uniqify ( EINFO_EIO, 0x10, "Aborted" ) +#define EIO_ADMIN_ABORTED \ + __einfo_error ( EINFO_EIO_ADMIN_ABORTED ) +#define EINFO_EIO_ADMIN_EXISTS \ + __einfo_uniqify ( EINFO_EIO, 0x11, "Already exists" ) +#define EIO_ADMIN_EXISTS \ + __einfo_error ( EINFO_EIO_ADMIN_EXISTS ) +#define EINFO_EIO_ADMIN_CANCELLED \ + __einfo_uniqify ( EINFO_EIO, 0x12, "Cancelled" ) +#define EIO_ADMIN_CANCELLED \ + __einfo_error ( EINFO_EIO_ADMIN_CANCELLED ) +#define EINFO_EIO_ADMIN_DATALOSS \ + __einfo_uniqify ( EINFO_EIO, 0x13, "Data loss" ) +#define EIO_ADMIN_DATALOSS \ + __einfo_error ( EINFO_EIO_ADMIN_DATALOSS ) +#define EINFO_EIO_ADMIN_DEADLINE \ + __einfo_uniqify ( EINFO_EIO, 0x14, "Deadline exceeded" ) +#define EIO_ADMIN_DEADLINE \ + __einfo_error ( EINFO_EIO_ADMIN_DEADLINE ) +#define EINFO_EIO_ADMIN_PRECONDITION \ + __einfo_uniqify ( EINFO_EIO, 0x15, "Failed precondition" ) +#define EIO_ADMIN_PRECONDITION \ + __einfo_error ( EINFO_EIO_ADMIN_PRECONDITION ) +#define EINFO_EIO_ADMIN_INTERNAL \ + __einfo_uniqify ( EINFO_EIO, 0x16, "Internal error" ) +#define EIO_ADMIN_INTERNAL \ + __einfo_error ( EINFO_EIO_ADMIN_INTERNAL ) +#define EINFO_EIO_ADMIN_INVAL \ + __einfo_uniqify ( EINFO_EIO, 0x17, "Invalid argument" ) +#define EIO_ADMIN_INVAL \ + __einfo_error ( EINFO_EIO_ADMIN_INVAL ) +#define EINFO_EIO_ADMIN_NOT_FOUND \ + __einfo_uniqify ( EINFO_EIO, 0x18, "Not found" ) +#define EIO_ADMIN_NOT_FOUND \ + __einfo_error ( EINFO_EIO_ADMIN_NOT_FOUND ) +#define EINFO_EIO_ADMIN_RANGE \ + __einfo_uniqify ( EINFO_EIO, 0x19, "Out of range" ) +#define EIO_ADMIN_RANGE \ + __einfo_error ( EINFO_EIO_ADMIN_RANGE ) +#define EINFO_EIO_ADMIN_PERM \ + __einfo_uniqify ( EINFO_EIO, 0x1a, "Permission denied" ) +#define EIO_ADMIN_PERM \ + __einfo_error ( EINFO_EIO_ADMIN_PERM ) +#define EINFO_EIO_ADMIN_UNAUTH \ + __einfo_uniqify ( EINFO_EIO, 0x1b, "Unauthenticated" ) +#define EIO_ADMIN_UNAUTH \ + __einfo_error ( EINFO_EIO_ADMIN_UNAUTH ) +#define EINFO_EIO_ADMIN_RESOURCE \ + __einfo_uniqify ( EINFO_EIO, 0x1c, "Resource exhausted" ) +#define EIO_ADMIN_RESOURCE \ + __einfo_error ( EINFO_EIO_ADMIN_RESOURCE ) +#define EINFO_EIO_ADMIN_UNAVAIL \ + __einfo_uniqify ( EINFO_EIO, 0x1d, "Unavailable" ) +#define EIO_ADMIN_UNAVAIL \ + __einfo_error ( EINFO_EIO_ADMIN_UNAVAIL ) +#define EINFO_EIO_ADMIN_NOTSUP \ + __einfo_uniqify ( EINFO_EIO, 0x1e, "Unimplemented" ) +#define EIO_ADMIN_NOTSUP \ + __einfo_error ( EINFO_EIO_ADMIN_NOTSUP ) +#define EINFO_EIO_ADMIN_UNKNOWN \ + __einfo_uniqify ( EINFO_EIO, 0x1f, "Unknown error" ) +#define EIO_ADMIN_UNKNOWN \ + __einfo_error ( EINFO_EIO_ADMIN_UNKNOWN ) +#define EIO_ADMIN( status ) \ + EUNIQ ( EINFO_EIO, ( (status) & 0x1f ), \ + EIO_ADMIN_UNSET, EIO_ADMIN_ABORTED, EIO_ADMIN_EXISTS, \ + EIO_ADMIN_CANCELLED, EIO_ADMIN_DATALOSS, \ + EIO_ADMIN_DEADLINE, EIO_ADMIN_NOT_FOUND, \ + EIO_ADMIN_RANGE, EIO_ADMIN_PERM, EIO_ADMIN_UNAUTH, \ + EIO_ADMIN_RESOURCE, EIO_ADMIN_UNAVAIL, \ + EIO_ADMIN_NOTSUP, EIO_ADMIN_UNKNOWN ) + +/****************************************************************************** + * + * Device reset + * + ****************************************************************************** + */ + +/** + * Reset hardware + * + * @v gve GVE device + * @ret rc Return status code + */ +static int gve_reset ( struct gve_nic *gve ) { + uint32_t pfn; + unsigned int i; + + /* Skip reset if admin queue page frame number is already + * clear. Triggering a reset on an already-reset device seems + * to cause a delayed reset to be scheduled. This can cause + * the device to end up in a reset loop, where each attempt to + * recover from reset triggers another reset a few seconds + * later. + */ + pfn = readl ( gve->cfg + GVE_CFG_ADMIN_PFN ); + if ( ! pfn ) { + DBGC ( gve, "GVE %p skipping reset\n", gve ); + return 0; + } + + /* Clear admin queue page frame number */ + writel ( 0, gve->cfg + GVE_CFG_ADMIN_PFN ); + wmb(); + + /* Wait for device to reset */ + for ( i = 0 ; i < GVE_RESET_MAX_WAIT_MS ; i++ ) { + + /* Delay */ + mdelay ( 1 ); + + /* Check for reset completion */ + pfn = readl ( gve->cfg + GVE_CFG_ADMIN_PFN ); + if ( ! pfn ) + return 0; + } + + DBGC ( gve, "GVE %p reset timed out (PFN %#08x devstat %#08x)\n", + gve, bswap_32 ( pfn ), + bswap_32 ( readl ( gve->cfg + GVE_CFG_DEVSTAT ) ) ); + return -ETIMEDOUT; +} + +/****************************************************************************** + * + * Admin queue + * + ****************************************************************************** + */ + +/** + * Allocate admin queue + * + * @v gve GVE device + * @ret rc Return status code + */ +static int gve_admin_alloc ( struct gve_nic *gve ) { + struct dma_device *dma = gve->dma; + struct gve_admin *admin = &gve->admin; + struct gve_irqs *irqs = &gve->irqs; + struct gve_events *events = &gve->events; + struct gve_scratch *scratch = &gve->scratch; + size_t admin_len = ( GVE_ADMIN_COUNT * sizeof ( admin->cmd[0] ) ); + size_t irqs_len = ( GVE_IRQ_COUNT * sizeof ( irqs->irq[0] ) ); + size_t events_len = ( GVE_EVENT_MAX * sizeof ( events->event[0] ) ); + size_t scratch_len = sizeof ( *scratch->buf ); + int rc; + + /* Allocate admin queue */ + admin->cmd = dma_alloc ( dma, &admin->map, admin_len, GVE_ALIGN ); + if ( ! admin->cmd ) { + rc = -ENOMEM; + goto err_admin; + } + + /* Allocate interrupt channels */ + irqs->irq = dma_alloc ( dma, &irqs->map, irqs_len, GVE_ALIGN ); + if ( ! irqs->irq ) { + rc = -ENOMEM; + goto err_irqs; + } + + /* Allocate event counters */ + events->event = dma_alloc ( dma, &events->map, events_len, GVE_ALIGN ); + if ( ! events->event ) { + rc = -ENOMEM; + goto err_events; + } + + /* Allocate scratch buffer */ + scratch->buf = dma_alloc ( dma, &scratch->map, scratch_len, GVE_ALIGN ); + if ( ! scratch->buf ) { + rc = -ENOMEM; + goto err_scratch; + } + + DBGC ( gve, "GVE %p AQ at [%08lx,%08lx)\n", + gve, virt_to_phys ( admin->cmd ), + ( virt_to_phys ( admin->cmd ) + admin_len ) ); + return 0; + + dma_free ( &scratch->map, scratch->buf, scratch_len ); + err_scratch: + dma_free ( &events->map, events->event, events_len ); + err_events: + dma_free ( &irqs->map, irqs->irq, irqs_len ); + err_irqs: + dma_free ( &admin->map, admin->cmd, admin_len ); + err_admin: + return rc; +} + +/** + * Free admin queue + * + * @v gve GVE device + */ +static void gve_admin_free ( struct gve_nic *gve ) { + struct gve_admin *admin = &gve->admin; + struct gve_irqs *irqs = &gve->irqs; + struct gve_events *events = &gve->events; + struct gve_scratch *scratch = &gve->scratch; + size_t admin_len = ( GVE_ADMIN_COUNT * sizeof ( admin->cmd[0] ) ); + size_t irqs_len = ( GVE_IRQ_COUNT * sizeof ( irqs->irq[0] ) ); + size_t events_len = ( GVE_EVENT_MAX * sizeof ( events->event[0] ) ); + size_t scratch_len = sizeof ( *scratch->buf ); + + /* Free scratch buffer */ + dma_free ( &scratch->map, scratch->buf, scratch_len ); + + /* Free event counter */ + dma_free ( &events->map, events->event, events_len ); + + /* Free interrupt channels */ + dma_free ( &irqs->map, irqs->irq, irqs_len ); + + /* Free admin queue */ + dma_free ( &admin->map, admin->cmd, admin_len ); +} + +/** + * Enable admin queue + * + * @v gve GVE device + */ +static void gve_admin_enable ( struct gve_nic *gve ) { + struct gve_admin *admin = &gve->admin; + size_t admin_len = ( GVE_ADMIN_COUNT * sizeof ( admin->cmd[0] ) ); + physaddr_t base; + + /* Reset queue */ + admin->prod = 0; + + /* Program queue addresses and capabilities */ + base = dma ( &admin->map, admin->cmd ); + writel ( bswap_32 ( base / GVE_PAGE_SIZE ), + gve->cfg + GVE_CFG_ADMIN_PFN ); + writel ( bswap_32 ( base & 0xffffffffUL ), + gve->cfg + GVE_CFG_ADMIN_BASE_LO ); + if ( sizeof ( base ) > sizeof ( uint32_t ) ) { + writel ( bswap_32 ( ( ( uint64_t ) base ) >> 32 ), + gve->cfg + GVE_CFG_ADMIN_BASE_HI ); + } else { + writel ( 0, gve->cfg + GVE_CFG_ADMIN_BASE_HI ); + } + writel ( bswap_16 ( admin_len ), gve->cfg + GVE_CFG_ADMIN_LEN ); + writel ( bswap_32 ( GVE_CFG_DRVSTAT_RUN ), gve->cfg + GVE_CFG_DRVSTAT ); +} + +/** + * Get next available admin queue command slot + * + * @v gve GVE device + * @ret cmd Admin queue command + */ +static union gve_admin_command * gve_admin_command ( struct gve_nic *gve ) { + struct gve_admin *admin = &gve->admin; + union gve_admin_command *cmd; + unsigned int index; + + /* Get next command slot */ + index = admin->prod; + cmd = &admin->cmd[ index % GVE_ADMIN_COUNT ]; + + /* Initialise request */ + memset ( cmd, 0, sizeof ( *cmd ) ); + + return cmd; +} + +/** + * Wait for admin queue command to complete + * + * @v gve GVE device + * @ret rc Return status code + */ +static int gve_admin_wait ( struct gve_nic *gve ) { + struct gve_admin *admin = &gve->admin; + uint32_t evt; + uint32_t pfn; + unsigned int i; + + /* Wait for any outstanding commands to complete */ + for ( i = 0 ; i < GVE_ADMIN_MAX_WAIT_MS ; i++ ) { + + /* Check event counter */ + rmb(); + evt = bswap_32 ( readl ( gve->cfg + GVE_CFG_ADMIN_EVT ) ); + if ( evt == admin->prod ) + return 0; + + /* Check for device reset */ + pfn = readl ( gve->cfg + GVE_CFG_ADMIN_PFN ); + if ( ! pfn ) + break; + + /* Delay */ + mdelay ( 1 ); + } + + DBGC ( gve, "GVE %p AQ %#02x %s (completed %#02x, status %#08x)\n", + gve, admin->prod, ( pfn ? "timed out" : "saw reset" ), evt, + bswap_32 ( readl ( gve->cfg + GVE_CFG_DEVSTAT ) ) ); + return ( pfn ? -ETIMEDOUT : -ECONNRESET ); +} + +/** + * Issue admin queue command + * + * @v gve GVE device + * @ret rc Return status code + */ +static int gve_admin ( struct gve_nic *gve ) { + struct gve_admin *admin = &gve->admin; + union gve_admin_command *cmd; + unsigned int index; + uint32_t opcode; + uint32_t status; + int rc; + + /* Ensure admin queue is idle */ + if ( ( rc = gve_admin_wait ( gve ) ) != 0 ) + return rc; + + /* Get next command slot */ + index = admin->prod; + cmd = &admin->cmd[ index % GVE_ADMIN_COUNT ]; + opcode = cmd->hdr.opcode; + DBGC2 ( gve, "GVE %p AQ %#02x command %#04x request:\n", + gve, index, opcode ); + DBGC2_HDA ( gve, 0, cmd, sizeof ( *cmd ) ); + + /* Increment producer counter */ + admin->prod++; + + /* Ring doorbell */ + wmb(); + writel ( bswap_32 ( admin->prod ), gve->cfg + GVE_CFG_ADMIN_DB ); + + /* Wait for command to complete */ + if ( ( rc = gve_admin_wait ( gve ) ) != 0 ) + return rc; + + /* Check command status */ + status = be32_to_cpu ( cmd->hdr.status ); + if ( status != GVE_ADMIN_STATUS_OK ) { + rc = -EIO_ADMIN ( status ); + DBGC ( gve, "GVE %p AQ %#02x command %#04x failed: %#08x\n", + gve, index, opcode, status ); + DBGC_HDA ( gve, 0, cmd, sizeof ( *cmd ) ); + DBGC ( gve, "GVE %p AQ error: %s\n", gve, strerror ( rc ) ); + return rc; + } + + DBGC2 ( gve, "GVE %p AQ %#02x command %#04x result:\n", + gve, index, opcode ); + DBGC2_HDA ( gve, 0, cmd, sizeof ( *cmd ) ); + return 0; +} + +/** + * Issue simple admin queue command + * + * @v gve GVE device + * @v opcode Operation code + * @v id ID parameter (or zero if not applicable) + * @ret rc Return status code + * + * Several admin queue commands take either an empty parameter list or + * a single 32-bit ID parameter. + */ +static int gve_admin_simple ( struct gve_nic *gve, unsigned int opcode, + unsigned int id ) { + union gve_admin_command *cmd; + int rc; + + /* Construct request */ + cmd = gve_admin_command ( gve ); + cmd->hdr.opcode = opcode; + cmd->simple.id = cpu_to_be32 ( id ); + + /* Issue command */ + if ( ( rc = gve_admin ( gve ) ) != 0 ) + return rc; + + return 0; +} + +/** + * Get device descriptor + * + * @v gve GVE device + * @ret rc Return status code + */ +static int gve_describe ( struct gve_nic *gve ) { + struct net_device *netdev = gve->netdev; + struct gve_device_descriptor *desc = &gve->scratch.buf->desc; + union gve_admin_command *cmd; + int rc; + + /* Construct request */ + cmd = gve_admin_command ( gve ); + cmd->hdr.opcode = GVE_ADMIN_DESCRIBE; + cmd->desc.addr = cpu_to_be64 ( dma ( &gve->scratch.map, desc ) ); + cmd->desc.ver = cpu_to_be32 ( GVE_ADMIN_DESCRIBE_VER ); + cmd->desc.len = cpu_to_be32 ( sizeof ( *desc ) ); + + /* Issue command */ + if ( ( rc = gve_admin ( gve ) ) != 0 ) + return rc; + DBGC2 ( gve, "GVE %p device descriptor:\n", gve ); + DBGC2_HDA ( gve, 0, desc, sizeof ( *desc ) ); + + /* Extract queue parameters */ + gve->events.count = be16_to_cpu ( desc->counters ); + if ( gve->events.count > GVE_EVENT_MAX ) + gve->events.count = GVE_EVENT_MAX; + gve->tx.count = be16_to_cpu ( desc->tx_count ); + gve->rx.count = be16_to_cpu ( desc->rx_count ); + DBGC ( gve, "GVE %p using %d TX, %d RX, %d/%d events\n", + gve, gve->tx.count, gve->rx.count, gve->events.count, + be16_to_cpu ( desc->counters ) ); + + /* Extract network parameters */ + build_assert ( sizeof ( desc->mac ) == ETH_ALEN ); + memcpy ( netdev->hw_addr, &desc->mac, sizeof ( desc->mac ) ); + netdev->mtu = be16_to_cpu ( desc->mtu ); + netdev->max_pkt_len = ( netdev->mtu + ETH_HLEN ); + DBGC ( gve, "GVE %p MAC %s (\"%s\") MTU %zd\n", + gve, eth_ntoa ( netdev->hw_addr ), + inet_ntoa ( desc->mac.in ), netdev->mtu ); + + return 0; +} + +/** + * Configure device resources + * + * @v gve GVE device + * @ret rc Return status code + */ +static int gve_configure ( struct gve_nic *gve ) { + struct gve_events *events = &gve->events; + struct gve_irqs *irqs = &gve->irqs; + union gve_admin_command *cmd; + unsigned int db_off; + unsigned int i; + int rc; + + /* Construct request */ + cmd = gve_admin_command ( gve ); + cmd->hdr.opcode = GVE_ADMIN_CONFIGURE; + cmd->conf.events = + cpu_to_be64 ( dma ( &events->map, events->event ) ); + cmd->conf.irqs = + cpu_to_be64 ( dma ( &irqs->map, irqs->irq ) ); + cmd->conf.num_events = cpu_to_be32 ( events->count ); + cmd->conf.num_irqs = cpu_to_be32 ( GVE_IRQ_COUNT ); + cmd->conf.irq_stride = cpu_to_be32 ( sizeof ( irqs->irq[0] ) ); + + /* Issue command */ + if ( ( rc = gve_admin ( gve ) ) != 0 ) + return rc; + + /* Disable all interrupts */ + for ( i = 0 ; i < GVE_IRQ_COUNT ; i++ ) { + db_off = ( be32_to_cpu ( irqs->irq[i].db_idx ) * + sizeof ( uint32_t ) ); + DBGC ( gve, "GVE %p IRQ %d doorbell +%#04x\n", gve, i, db_off ); + irqs->db[i] = ( gve->db + db_off ); + writel ( bswap_32 ( GVE_IRQ_DISABLE ), irqs->db[i] ); + } + + return 0; +} + +/** + * Deconfigure device resources + * + * @v gve GVE device + * @ret rc Return status code + */ +static int gve_deconfigure ( struct gve_nic *gve ) { + int rc; + + /* Issue command (with meaningless ID) */ + if ( ( rc = gve_admin_simple ( gve, GVE_ADMIN_DECONFIGURE, 0 ) ) != 0 ) + return rc; + + return 0; +} + +/** + * Register queue page list + * + * @v gve GVE device + * @v qpl Queue page list + * @ret rc Return status code + */ +static int gve_register ( struct gve_nic *gve, struct gve_qpl *qpl ) { + struct gve_pages *pages = &gve->scratch.buf->pages; + union gve_admin_command *cmd; + physaddr_t addr; + unsigned int i; + int rc; + + /* Build page address list */ + for ( i = 0 ; i < qpl->count ; i++ ) { + addr = user_to_phys ( qpl->data, ( i * GVE_PAGE_SIZE ) ); + pages->addr[i] = cpu_to_be64 ( dma_phys ( &qpl->map, addr ) ); + } + + /* Construct request */ + cmd = gve_admin_command ( gve ); + cmd->hdr.opcode = GVE_ADMIN_REGISTER; + cmd->reg.id = cpu_to_be32 ( qpl->id ); + cmd->reg.count = cpu_to_be32 ( qpl->count ); + cmd->reg.addr = cpu_to_be64 ( dma ( &gve->scratch.map, pages ) ); + cmd->reg.size = cpu_to_be64 ( GVE_PAGE_SIZE ); + + /* Issue command */ + if ( ( rc = gve_admin ( gve ) ) != 0 ) + return rc; + + return 0; +} + +/** + * Unregister page list + * + * @v gve GVE device + * @v qpl Queue page list + * @ret rc Return status code + */ +static int gve_unregister ( struct gve_nic *gve, struct gve_qpl *qpl ) { + int rc; + + /* Issue command */ + if ( ( rc = gve_admin_simple ( gve, GVE_ADMIN_UNREGISTER, + qpl->id ) ) != 0 ) { + return rc; + } + + return 0; +} + +/** + * Construct command to create transmit queue + * + * @v queue Transmit queue + * @v cmd Admin queue command + */ +static void gve_create_tx_param ( struct gve_queue *queue, + union gve_admin_command *cmd ) { + struct gve_admin_create_tx *create = &cmd->create_tx; + const struct gve_queue_type *type = queue->type; + physaddr_t desc = user_to_phys ( queue->desc, 0 ); + + /* Construct request parameters */ + create->res = cpu_to_be64 ( dma ( &queue->res_map, queue->res ) ); + create->desc = cpu_to_be64 ( dma_phys ( &queue->desc_map, desc ) ); + create->qpl_id = cpu_to_be32 ( type->qpl ); + create->notify_id = cpu_to_be32 ( type->irq ); +} + +/** + * Construct command to create receive queue + * + * @v queue Receive queue + * @v cmd Admin queue command + */ +static void gve_create_rx_param ( struct gve_queue *queue, + union gve_admin_command *cmd ) { + struct gve_admin_create_rx *create = &cmd->create_rx; + const struct gve_queue_type *type = queue->type; + physaddr_t desc = user_to_phys ( queue->desc, 0 ); + physaddr_t cmplt = user_to_phys ( queue->cmplt, 0 ); + + /* Construct request parameters */ + create->notify_id = cpu_to_be32 ( type->irq ); + create->res = cpu_to_be64 ( dma ( &queue->res_map, queue->res ) ); + create->desc = cpu_to_be64 ( dma_phys ( &queue->desc_map, desc ) ); + create->cmplt = cpu_to_be64 ( dma_phys ( &queue->cmplt_map, cmplt ) ); + create->qpl_id = cpu_to_be32 ( type->qpl ); + create->bufsz = cpu_to_be16 ( GVE_BUF_SIZE ); +} + +/** + * Create transmit or receive queue + * + * @v gve GVE device + * @v queue Descriptor queue + * @ret rc Return status code + */ +static int gve_create_queue ( struct gve_nic *gve, struct gve_queue *queue ) { + const struct gve_queue_type *type = queue->type; + union gve_admin_command *cmd; + unsigned int db_off; + unsigned int evt_idx; + int rc; + + /* Reset queue */ + queue->prod = 0; + queue->cons = 0; + + /* Construct request */ + cmd = gve_admin_command ( gve ); + cmd->hdr.opcode = type->create; + type->param ( queue, cmd ); + + /* Issue command */ + if ( ( rc = gve_admin ( gve ) ) != 0 ) + return rc; + + /* Record indices */ + db_off = ( be32_to_cpu ( queue->res->db_idx ) * sizeof ( uint32_t ) ); + evt_idx = be32_to_cpu ( queue->res->evt_idx ); + DBGC ( gve, "GVE %p %s doorbell +%#04x event counter %d\n", + gve, type->name, db_off, evt_idx ); + queue->db = ( gve->db + db_off ); + assert ( evt_idx < gve->events.count ); + queue->event = &gve->events.event[evt_idx]; + assert ( queue->event->count == 0 ); + + return 0; +} + +/** + * Destroy transmit or receive queue + * + * @v gve GVE device + * @v queue Descriptor queue + * @ret rc Return status code + */ +static int gve_destroy_queue ( struct gve_nic *gve, struct gve_queue *queue ) { + const struct gve_queue_type *type = queue->type; + int rc; + + /* Issue command */ + if ( ( rc = gve_admin_simple ( gve, type->destroy, 0 ) ) != 0 ) + return rc; + + return 0; +} + +/****************************************************************************** + * + * Network device interface + * + ****************************************************************************** + */ + +/** + * Allocate queue page list + * + * @v gve GVE device + * @v qpl Queue page list + * @v id Queue page list ID + * @v buffers Number of data buffers + * @ret rc Return status code + */ +static int gve_alloc_qpl ( struct gve_nic *gve, struct gve_qpl *qpl, + uint32_t id, unsigned int buffers ) { + size_t len; + + /* Record ID */ + qpl->id = id; + + /* Calculate number of pages required */ + build_assert ( GVE_BUF_SIZE <= GVE_PAGE_SIZE ); + qpl->count = ( ( buffers + GVE_BUF_PER_PAGE - 1 ) / GVE_BUF_PER_PAGE ); + + /* Allocate pages (as a single block) */ + len = ( qpl->count * GVE_PAGE_SIZE ); + qpl->data = dma_umalloc ( gve->dma, &qpl->map, len, GVE_ALIGN ); + if ( ! qpl->data ) + return -ENOMEM; + + DBGC ( gve, "GVE %p QPL %#08x at [%08lx,%08lx)\n", + gve, qpl->id, user_to_phys ( qpl->data, 0 ), + user_to_phys ( qpl->data, len ) ); + return 0; +} + +/** + * Free queue page list + * + * @v gve GVE device + * @v qpl Queue page list + */ +static void gve_free_qpl ( struct gve_nic *nic __unused, + struct gve_qpl *qpl ) { + size_t len = ( qpl->count * GVE_PAGE_SIZE ); + + /* Free pages */ + dma_ufree ( &qpl->map, qpl->data, len ); +} + +/** + * Get buffer address (within queue page list address space) + * + * @v queue Descriptor queue + * @v index Buffer index + * @ret addr Buffer address within queue page list address space + */ +static inline __attribute__ (( always_inline)) size_t +gve_address ( struct gve_queue *queue, unsigned int index ) { + + /* We allocate sufficient pages for the maximum fill level of + * buffers, and reuse the pages in strict rotation as we + * progress through the queue. + */ + return ( ( index & ( queue->fill - 1 ) ) * GVE_BUF_SIZE ); +} + +/** + * Get buffer address + * + * @v queue Descriptor queue + * @v index Buffer index + * @ret addr Buffer address + */ +static inline __attribute__ (( always_inline )) userptr_t +gve_buffer ( struct gve_queue *queue, unsigned int index ) { + + /* Pages are currently allocated as a single contiguous block */ + return userptr_add ( queue->qpl.data, gve_address ( queue, index ) ); +} + +/** + * Calculate next receive sequence number + * + * @v seq Current sequence number, or zero to start sequence + * @ret next Next sequence number + */ +static inline __attribute__ (( always_inline )) unsigned int +gve_next ( unsigned int seq ) { + + /* The receive completion sequence number is a modulo 7 + * counter that cycles through the non-zero three-bit values 1 + * to 7 inclusive. + * + * Since 7 is coprime to 2^n, this ensures that the sequence + * number changes each time that a new completion is written + * to memory. + * + * Since the counter takes only non-zero values, this ensures + * that the sequence number changes whenever a new completion + * is first written to a zero-initialised completion ring. + */ + seq = ( ( seq + 1 ) & GVE_RX_SEQ_MASK ); + return ( seq ? seq : 1 ); +} + +/** + * Allocate descriptor queue + * + * @v gve GVE device + * @v queue Descriptor queue + * @ret rc Return status code + */ +static int gve_alloc_queue ( struct gve_nic *gve, struct gve_queue *queue ) { + const struct gve_queue_type *type = queue->type; + struct dma_device *dma = gve->dma; + size_t desc_len = ( queue->count * type->desc_len ); + size_t cmplt_len = ( queue->count * type->cmplt_len ); + size_t res_len = sizeof ( *queue->res ); + struct gve_buffer buf; + size_t offset; + unsigned int i; + int rc; + + /* Sanity checks */ + if ( ( queue->count == 0 ) || + ( queue->count & ( queue->count - 1 ) ) ) { + DBGC ( gve, "GVE %p %s invalid queue size %d\n", + gve, type->name, queue->count ); + rc = -EINVAL; + goto err_sanity; + } + + /* Calculate maximum fill level */ + assert ( ( type->fill & ( type->fill - 1 ) ) == 0 ); + queue->fill = type->fill; + if ( queue->fill > queue->count ) + queue->fill = queue->count; + DBGC ( gve, "GVE %p %s using QPL %#08x with %d/%d descriptors\n", + gve, type->name, type->qpl, queue->fill, queue->count ); + + /* Allocate queue page list */ + if ( ( rc = gve_alloc_qpl ( gve, &queue->qpl, type->qpl, + queue->fill ) ) != 0 ) + goto err_qpl; + + /* Allocate descriptors */ + queue->desc = dma_umalloc ( dma, &queue->desc_map, desc_len, + GVE_ALIGN ); + if ( ! queue->desc ) { + rc = -ENOMEM; + goto err_desc; + } + DBGC ( gve, "GVE %p %s descriptors at [%08lx,%08lx)\n", + gve, type->name, user_to_phys ( queue->desc, 0 ), + user_to_phys ( queue->desc, desc_len ) ); + + /* Allocate completions */ + if ( cmplt_len ) { + queue->cmplt = dma_umalloc ( dma, &queue->cmplt_map, cmplt_len, + GVE_ALIGN ); + if ( ! queue->cmplt ) { + rc = -ENOMEM; + goto err_cmplt; + } + DBGC ( gve, "GVE %p %s completions at [%08lx,%08lx)\n", + gve, type->name, user_to_phys ( queue->cmplt, 0 ), + user_to_phys ( queue->cmplt, cmplt_len ) ); + } + + /* Allocate queue resources */ + queue->res = dma_alloc ( dma, &queue->res_map, res_len, GVE_ALIGN ); + if ( ! queue->res ) { + rc = -ENOMEM; + goto err_res; + } + memset ( queue->res, 0, res_len ); + + /* Populate descriptor offsets */ + offset = ( type->desc_len - sizeof ( buf ) ); + for ( i = 0 ; i < queue->count ; i++ ) { + buf.addr = cpu_to_be64 ( gve_address ( queue, i ) ); + copy_to_user ( queue->desc, offset, &buf, sizeof ( buf ) ); + offset += type->desc_len; + } + + return 0; + + dma_free ( &queue->res_map, queue->res, res_len ); + err_res: + if ( cmplt_len ) + dma_ufree ( &queue->cmplt_map, queue->cmplt, cmplt_len ); + err_cmplt: + dma_ufree ( &queue->desc_map, queue->desc, desc_len ); + err_desc: + gve_free_qpl ( gve, &queue->qpl ); + err_qpl: + err_sanity: + return rc; +} + +/** + * Free descriptor queue + * + * @v gve GVE device + * @v queue Descriptor queue + */ +static void gve_free_queue ( struct gve_nic *gve, struct gve_queue *queue ) { + const struct gve_queue_type *type = queue->type; + size_t desc_len = ( queue->count * type->desc_len ); + size_t cmplt_len = ( queue->count * type->cmplt_len ); + size_t res_len = sizeof ( *queue->res ); + + /* Free queue resources */ + dma_free ( &queue->res_map, queue->res, res_len ); + + /* Free completions, if applicable */ + if ( cmplt_len ) + dma_ufree ( &queue->cmplt_map, queue->cmplt, cmplt_len ); + + /* Free descriptors */ + dma_ufree ( &queue->desc_map, queue->desc, desc_len ); + + /* Free queue page list */ + gve_free_qpl ( gve, &queue->qpl ); +} + +/** + * Start up device + * + * @v gve GVE device + * @ret rc Return status code + */ +static int gve_start ( struct gve_nic *gve ) { + struct net_device *netdev = gve->netdev; + struct gve_queue *tx = &gve->tx; + struct gve_queue *rx = &gve->rx; + struct io_buffer *iobuf; + unsigned int i; + int rc; + + /* Cancel any pending transmissions */ + for ( i = 0 ; i < ( sizeof ( gve->tx_iobuf ) / + sizeof ( gve->tx_iobuf[0] ) ) ; i++ ) { + iobuf = gve->tx_iobuf[i]; + gve->tx_iobuf[i] = NULL; + if ( iobuf ) + netdev_tx_complete_err ( netdev, iobuf, -ECANCELED ); + } + + /* Invalidate receive completions */ + memset_user ( rx->cmplt, 0, 0, ( rx->count * rx->type->cmplt_len ) ); + + /* Reset receive sequence */ + gve->seq = gve_next ( 0 ); + + /* Configure device resources */ + if ( ( rc = gve_configure ( gve ) ) != 0 ) + goto err_configure; + + /* Register transmit queue page list */ + if ( ( rc = gve_register ( gve, &tx->qpl ) ) != 0 ) + goto err_register_tx; + + /* Register receive queue page list */ + if ( ( rc = gve_register ( gve, &rx->qpl ) ) != 0 ) + goto err_register_rx; + + /* Create transmit queue */ + if ( ( rc = gve_create_queue ( gve, tx ) ) != 0 ) + goto err_create_tx; + + /* Create receive queue */ + if ( ( rc = gve_create_queue ( gve, rx ) ) != 0 ) + goto err_create_rx; + + return 0; + + gve_destroy_queue ( gve, rx ); + err_create_rx: + gve_destroy_queue ( gve, tx ); + err_create_tx: + gve_unregister ( gve, &rx->qpl ); + err_register_rx: + gve_unregister ( gve, &tx->qpl ); + err_register_tx: + gve_deconfigure ( gve ); + err_configure: + return rc; +} + +/** + * Stop device + * + * @v gve GVE device + */ +static void gve_stop ( struct gve_nic *gve ) { + struct gve_queue *tx = &gve->tx; + struct gve_queue *rx = &gve->rx; + + /* Destroy queues */ + gve_destroy_queue ( gve, rx ); + gve_destroy_queue ( gve, tx ); + + /* Unregister page lists */ + gve_unregister ( gve, &rx->qpl ); + gve_unregister ( gve, &tx->qpl ); + + /* Deconfigure device */ + gve_deconfigure ( gve ); +} + +/** + * Device startup process + * + * @v gve GVE device + */ +static void gve_startup ( struct gve_nic *gve ) { + struct net_device *netdev = gve->netdev; + int rc; + + /* Reset device */ + if ( ( rc = gve_reset ( gve ) ) != 0 ) + goto err_reset; + + /* Enable admin queue */ + gve_admin_enable ( gve ); + + /* Start device */ + if ( ( rc = gve_start ( gve ) ) != 0 ) + goto err_start; + + /* Reset retry count */ + gve->retries = 0; + + /* (Ab)use link status to report startup status */ + netdev_link_up ( netdev ); + + return; + + gve_stop ( gve ); + err_start: + err_reset: + DBGC ( gve, "GVE %p startup failed: %s\n", gve, strerror ( rc ) ); + netdev_link_err ( netdev, rc ); + if ( gve->retries++ < GVE_RESET_MAX_RETRY ) + process_add ( &gve->startup ); +} + +/** + * Trigger startup process + * + * @v gve GVE device + */ +static void gve_restart ( struct gve_nic *gve ) { + struct net_device *netdev = gve->netdev; + + /* Mark link down to inhibit polling and transmit activity */ + netdev_link_down ( netdev ); + + /* Schedule startup process */ + process_add ( &gve->startup ); +} + +/** + * Reset recovery watchdog + * + * @v timer Reset recovery watchdog timer + * @v over Failure indicator + */ +static void gve_watchdog ( struct retry_timer *timer, int over __unused ) { + struct gve_nic *gve = container_of ( timer, struct gve_nic, watchdog ); + uint32_t activity; + uint32_t pfn; + int rc; + + /* Reschedule watchdog */ + start_timer_fixed ( &gve->watchdog, GVE_WATCHDOG_TIMEOUT ); + + /* Reset device (for test purposes) if applicable */ + if ( ( rc = inject_fault ( VM_MIGRATED_RATE ) ) != 0 ) { + DBGC ( gve, "GVE %p synthesising host reset\n", gve ); + writel ( 0, gve->cfg + GVE_CFG_ADMIN_PFN ); + } + + /* Check for activity since last timer invocation */ + activity = ( gve->tx.cons + gve->rx.cons ); + if ( activity != gve->activity ) { + gve->activity = activity; + return; + } + + /* Check for reset */ + pfn = readl ( gve->cfg + GVE_CFG_ADMIN_PFN ); + if ( pfn ) { + DBGC2 ( gve, "GVE %p idle but not in reset\n", gve ); + return; + } + + /* Schedule restart */ + DBGC ( gve, "GVE %p watchdog detected reset by host\n", gve ); + gve_restart ( gve ); +} + +/** + * Open network device + * + * @v netdev Network device + * @ret rc Return status code + */ +static int gve_open ( struct net_device *netdev ) { + struct gve_nic *gve = netdev->priv; + struct gve_queue *tx = &gve->tx; + struct gve_queue *rx = &gve->rx; + int rc; + + /* Allocate and prepopulate transmit queue */ + if ( ( rc = gve_alloc_queue ( gve, tx ) ) != 0 ) + goto err_alloc_tx; + + /* Allocate and prepopulate receive queue */ + if ( ( rc = gve_alloc_queue ( gve, rx ) ) != 0 ) + goto err_alloc_rx; + + /* Trigger startup */ + gve_restart ( gve ); + + /* Start reset recovery watchdog timer */ + start_timer_fixed ( &gve->watchdog, GVE_WATCHDOG_TIMEOUT ); + + return 0; + + gve_free_queue ( gve, rx ); + err_alloc_rx: + gve_free_queue ( gve, tx ); + err_alloc_tx: + return rc; +} + +/** + * Close network device + * + * @v netdev Network device + */ +static void gve_close ( struct net_device *netdev ) { + struct gve_nic *gve = netdev->priv; + struct gve_queue *tx = &gve->tx; + struct gve_queue *rx = &gve->rx; + + /* Stop reset recovery timer */ + stop_timer ( &gve->watchdog ); + + /* Terminate startup process */ + process_del ( &gve->startup ); + + /* Stop and reset device */ + gve_stop ( gve ); + gve_reset ( gve ); + + /* Free queues */ + gve_free_queue ( gve, rx ); + gve_free_queue ( gve, tx ); +} + +/** + * Transmit packet + * + * @v netdev Network device + * @v iobuf I/O buffer + * @ret rc Return status code + */ +static int gve_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) { + struct gve_nic *gve = netdev->priv; + struct gve_queue *tx = &gve->tx; + struct gve_tx_descriptor desc; + unsigned int count; + unsigned int index; + size_t frag_len; + size_t offset; + size_t len; + + /* Do nothing if queues are not yet set up */ + if ( ! netdev_link_ok ( netdev ) ) + return -ENETDOWN; + + /* Defer packet if there is no space in the transmit ring */ + len = iob_len ( iobuf ); + count = ( ( len + GVE_BUF_SIZE - 1 ) / GVE_BUF_SIZE ); + if ( ( ( tx->prod - tx->cons ) + count ) > tx->fill ) { + netdev_tx_defer ( netdev, iobuf ); + return 0; + } + + /* Copy packet to queue pages and populate descriptors */ + for ( offset = 0 ; offset < len ; offset += frag_len ) { + + /* Sanity check */ + assert ( gve->tx_iobuf[ tx->prod % GVE_TX_FILL ] == NULL ); + + /* Copy packet fragment */ + frag_len = ( len - offset ); + if ( frag_len > GVE_BUF_SIZE ) + frag_len = GVE_BUF_SIZE; + copy_to_user ( gve_buffer ( tx, tx->prod ), 0, + ( iobuf->data + offset ), frag_len ); + + /* Populate descriptor */ + index = ( tx->prod++ & ( tx->count - 1 ) ); + memset ( &desc.pkt, 0, sizeof ( desc.pkt ) ); + if ( offset ) { + desc.pkt.type = GVE_TX_TYPE_CONT; + } else { + desc.pkt.type = GVE_TX_TYPE_START; + desc.pkt.count = count; + desc.pkt.total = cpu_to_be16 ( len ); + } + desc.pkt.len = cpu_to_be16 ( frag_len ); + copy_to_user ( tx->desc, ( index * sizeof ( desc ) ), &desc, + sizeof ( desc.pkt ) ); + DBGC2 ( gve, "GVE %p TX %#04x %#02x:%#02x len %#04x/%#04x at " + "%#08zx\n", gve, index, desc.pkt.type, desc.pkt.count, + be16_to_cpu ( desc.pkt.len ), + be16_to_cpu ( desc.pkt.total ), + gve_address ( tx, index ) ); + } + assert ( ( tx->prod - tx->cons ) <= tx->fill ); + + /* Record I/O buffer against final descriptor */ + gve->tx_iobuf[ ( tx->prod - 1U ) % GVE_TX_FILL ] = iobuf; + + /* Ring doorbell */ + wmb(); + writel ( bswap_32 ( tx->prod ), tx->db ); + + return 0; +} + +/** + * Poll for completed transmissions + * + * @v netdev Network device + */ +static void gve_poll_tx ( struct net_device *netdev ) { + struct gve_nic *gve = netdev->priv; + struct gve_queue *tx = &gve->tx; + struct io_buffer *iobuf; + uint32_t count; + + /* Read event counter */ + count = be32_to_cpu ( tx->event->count ); + + /* Process transmit completions */ + while ( count != tx->cons ) { + DBGC2 ( gve, "GVE %p TX %#04x complete\n", gve, tx->cons ); + iobuf = gve->tx_iobuf[ tx->cons % GVE_TX_FILL ]; + gve->tx_iobuf[ tx->cons % GVE_TX_FILL ] = NULL; + tx->cons++; + if ( iobuf ) + netdev_tx_complete ( netdev, iobuf ); + } +} + +/** + * Poll for received packets + * + * @v netdev Network device + */ +static void gve_poll_rx ( struct net_device *netdev ) { + struct gve_nic *gve = netdev->priv; + struct gve_queue *rx = &gve->rx; + struct gve_rx_completion cmplt; + struct io_buffer *iobuf; + unsigned int index; + unsigned int seq; + uint32_t cons; + size_t offset; + size_t total; + size_t len; + int rc; + + /* Process receive completions */ + cons = rx->cons; + seq = gve->seq; + total = 0; + while ( 1 ) { + + /* Read next possible completion */ + index = ( cons++ & ( rx->count - 1 ) ); + offset = ( ( index * sizeof ( cmplt ) ) + + offsetof ( typeof ( cmplt ), pkt ) ); + copy_from_user ( &cmplt.pkt, rx->cmplt, offset, + sizeof ( cmplt.pkt ) ); + + /* Check sequence number */ + if ( ( cmplt.pkt.seq & GVE_RX_SEQ_MASK ) != seq ) + break; + seq = gve_next ( seq ); + + /* Parse completion */ + len = be16_to_cpu ( cmplt.pkt.len ); + DBGC2 ( gve, "GVE %p RX %#04x %#02x:%#02x len %#04zx at " + "%#08zx\n", gve, index, cmplt.pkt.seq, cmplt.pkt.flags, + len, gve_address ( rx, index ) ); + + /* Accumulate a complete packet */ + if ( cmplt.pkt.flags & GVE_RXF_ERROR ) { + total = 0; + } else { + total += len; + if ( cmplt.pkt.flags & GVE_RXF_MORE ) + continue; + } + gve->seq = seq; + + /* Allocate and populate I/O buffer */ + iobuf = ( total ? alloc_iob ( total ) : NULL ); + for ( ; rx->cons != cons ; rx->cons++ ) { + + /* Re-read completion length */ + index = ( rx->cons & ( rx->count - 1 ) ); + offset = ( ( index * sizeof ( cmplt ) ) + + offsetof ( typeof ( cmplt ), pkt.len ) ); + copy_from_user ( &cmplt.pkt, rx->cmplt, offset, + sizeof ( cmplt.pkt.len ) ); + + /* Copy data */ + if ( iobuf ) { + len = be16_to_cpu ( cmplt.pkt.len ); + copy_from_user ( iob_put ( iobuf, len ), + gve_buffer ( rx, rx->cons ), + 0, len ); + } + } + assert ( ( iobuf == NULL ) || ( iob_len ( iobuf ) == total ) ); + total = 0; + + /* Hand off packet to network stack */ + if ( iobuf ) { + iob_pull ( iobuf, GVE_RX_PAD ); + netdev_rx ( netdev, iobuf ); + } else { + rc = ( ( cmplt.pkt.flags & GVE_RXF_ERROR ) ? + -EIO : -ENOMEM ); + netdev_rx_err ( netdev, NULL, rc ); + } + + /* Sanity check */ + assert ( rx->cons == cons ); + assert ( gve->seq == seq ); + assert ( total == 0 ); + } +} + +/** + * Refill receive queue + * + * @v netdev Network device + */ +static void gve_refill_rx ( struct net_device *netdev ) { + struct gve_nic *gve = netdev->priv; + struct gve_queue *rx = &gve->rx; + unsigned int prod; + + /* The receive descriptors are prepopulated at the time of + * creating the receive queue (pointing to the preallocated + * queue pages). Refilling is therefore just a case of + * ringing the doorbell if the device is not yet aware of any + * available descriptors. + */ + prod = ( rx->cons + rx->fill ); + if ( prod != rx->prod ) { + rx->prod = prod; + writel ( bswap_32 ( prod ), rx->db ); + DBGC2 ( gve, "GVE %p RX %#04x ready\n", gve, rx->prod ); + } +} + +/** + * Poll for completed and received packets + * + * @v netdev Network device + */ +static void gve_poll ( struct net_device *netdev ) { + + /* Do nothing if queues are not yet set up */ + if ( ! netdev_link_ok ( netdev ) ) + return; + + /* Poll for transmit completions */ + gve_poll_tx ( netdev ); + + /* Poll for receive completions */ + gve_poll_rx ( netdev ); + + /* Refill receive queue */ + gve_refill_rx ( netdev ); +} + +/** GVE network device operations */ +static struct net_device_operations gve_operations = { + .open = gve_open, + .close = gve_close, + .transmit = gve_transmit, + .poll = gve_poll, +}; + +/****************************************************************************** + * + * PCI interface + * + ****************************************************************************** + */ + +/** Transmit descriptor queue type */ +static const struct gve_queue_type gve_tx_type = { + .name = "TX", + .param = gve_create_tx_param, + .qpl = GVE_TX_QPL, + .irq = GVE_TX_IRQ, + .fill = GVE_TX_FILL, + .desc_len = sizeof ( struct gve_tx_descriptor ), + .create = GVE_ADMIN_CREATE_TX, + .destroy = GVE_ADMIN_DESTROY_TX, +}; + +/** Receive descriptor queue type */ +static const struct gve_queue_type gve_rx_type = { + .name = "RX", + .param = gve_create_rx_param, + .qpl = GVE_RX_QPL, + .irq = GVE_RX_IRQ, + .fill = GVE_RX_FILL, + .desc_len = sizeof ( struct gve_rx_descriptor ), + .cmplt_len = sizeof ( struct gve_rx_completion ), + .create = GVE_ADMIN_CREATE_RX, + .destroy = GVE_ADMIN_DESTROY_RX, +}; + +/** + * Set up admin queue and get device description + * + * @v gve GVE device + * @ret rc Return status code + */ +static int gve_setup ( struct gve_nic *gve ) { + unsigned int i; + int rc; + + /* Attempt several times, since the device may decide to add + * in a few spurious resets. + */ + for ( i = 0 ; i < GVE_RESET_MAX_RETRY ; i++ ) { + + /* Reset device */ + if ( ( rc = gve_reset ( gve ) ) != 0 ) + continue; + + /* Enable admin queue */ + gve_admin_enable ( gve ); + + /* Fetch MAC address */ + if ( ( rc = gve_describe ( gve ) ) != 0 ) + continue; + + /* Success */ + return 0; + } + + DBGC ( gve, "GVE %p failed to get device description: %s\n", + gve, strerror ( rc ) ); + return rc; +} + +/** Device startup process descriptor */ +static struct process_descriptor gve_startup_desc = + PROC_DESC_ONCE ( struct gve_nic, startup, gve_startup ); + +/** + * Probe PCI device + * + * @v pci PCI device + * @ret rc Return status code + */ +static int gve_probe ( struct pci_device *pci ) { + struct net_device *netdev; + struct gve_nic *gve; + unsigned long cfg_start; + unsigned long db_start; + unsigned long db_size; + int rc; + + /* Allocate and initialise net device */ + netdev = alloc_etherdev ( sizeof ( *gve ) ); + if ( ! netdev ) { + rc = -ENOMEM; + goto err_alloc; + } + netdev_init ( netdev, &gve_operations ); + gve = netdev->priv; + pci_set_drvdata ( pci, netdev ); + netdev->dev = &pci->dev; + memset ( gve, 0, sizeof ( *gve ) ); + gve->netdev = netdev; + gve->tx.type = &gve_tx_type; + gve->rx.type = &gve_rx_type; + process_init ( &gve->startup, &gve_startup_desc, &netdev->refcnt ); + timer_init ( &gve->watchdog, gve_watchdog, &netdev->refcnt ); + + /* Fix up PCI device */ + adjust_pci_device ( pci ); + + /* Check PCI revision */ + pci_read_config_byte ( pci, PCI_REVISION, &gve->revision ); + DBGC ( gve, "GVE %p is revision %#02x\n", gve, gve->revision ); + + /* Map configuration registers */ + cfg_start = pci_bar_start ( pci, GVE_CFG_BAR ); + gve->cfg = pci_ioremap ( pci, cfg_start, GVE_CFG_SIZE ); + if ( ! gve->cfg ) { + rc = -ENODEV; + goto err_cfg; + } + + /* Map doorbell registers */ + db_start = pci_bar_start ( pci, GVE_DB_BAR ); + db_size = pci_bar_size ( pci, GVE_DB_BAR ); + gve->db = pci_ioremap ( pci, db_start, db_size ); + if ( ! gve->db ) { + rc = -ENODEV; + goto err_db; + } + + /* Configure DMA */ + gve->dma = &pci->dma; + dma_set_mask_64bit ( gve->dma ); + assert ( netdev->dma == NULL ); + + /* Allocate admin queue */ + if ( ( rc = gve_admin_alloc ( gve ) ) != 0 ) + goto err_admin; + + /* Set up the device */ + if ( ( rc = gve_setup ( gve ) ) != 0 ) + goto err_setup; + + /* Register network device */ + if ( ( rc = register_netdev ( netdev ) ) != 0 ) + goto err_register_netdev; + + return 0; + + unregister_netdev ( netdev ); + err_register_netdev: + err_setup: + gve_reset ( gve ); + gve_admin_free ( gve ); + err_admin: + iounmap ( gve->db ); + err_db: + iounmap ( gve->cfg ); + err_cfg: + netdev_nullify ( netdev ); + netdev_put ( netdev ); + err_alloc: + return rc; +} + +/** + * Remove PCI device + * + * @v pci PCI device + */ +static void gve_remove ( struct pci_device *pci ) { + struct net_device *netdev = pci_get_drvdata ( pci ); + struct gve_nic *gve = netdev->priv; + + /* Unregister network device */ + unregister_netdev ( netdev ); + + /* Reset device */ + gve_reset ( gve ); + + /* Free admin queue */ + gve_admin_free ( gve ); + + /* Unmap registers */ + iounmap ( gve->db ); + iounmap ( gve->cfg ); + + /* Free network device */ + netdev_nullify ( netdev ); + netdev_put ( netdev ); +} + +/** GVE PCI device IDs */ +static struct pci_device_id gve_nics[] = { + PCI_ROM ( 0x1ae0, 0x0042, "gve", "gVNIC", 0 ), +}; + +/** GVE PCI driver */ +struct pci_driver gve_driver __pci_driver = { + .ids = gve_nics, + .id_count = ( sizeof ( gve_nics ) / sizeof ( gve_nics[0] ) ), + .probe = gve_probe, + .remove = gve_remove, +}; diff --git a/src/drivers/net/gve.h b/src/drivers/net/gve.h new file mode 100644 index 000000000..2845699ac --- /dev/null +++ b/src/drivers/net/gve.h @@ -0,0 +1,702 @@ +#ifndef _GVE_H +#define _GVE_H + +/** @file + * + * Google Virtual Ethernet network driver + * + * The Google Virtual Ethernet NIC (GVE or gVNIC) is found only in + * Google Cloud instances. There is essentially zero documentation + * available beyond the mostly uncommented source code in the Linux + * kernel. + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#include +#include +#include +#include +#include +#include +#include + +struct gve_nic; + +/** + * A Google Cloud MAC address + * + * Google Cloud locally assigned MAC addresses encode the local IPv4 + * address in the trailing 32 bits, presumably as a performance + * optimisation to allow ARP resolution to be skipped by a suitably + * aware network stack. + */ +struct google_mac { + /** Reserved */ + uint8_t reserved[2]; + /** Local IPv4 address */ + struct in_addr in; +} __attribute__ (( packed )); + +/** Page size */ +#define GVE_PAGE_SIZE 0x1000 + +/** + * Address alignment + * + * All DMA data structure base addresses seem to need to be aligned to + * a page boundary. (This is not documented anywhere, but is inferred + * from existing source code and experimentation.) + */ +#define GVE_ALIGN GVE_PAGE_SIZE + +/** + * Length alignment + * + * All DMA data structure lengths seem to need to be aligned to a + * multiple of 64 bytes. (This is not documented anywhere, but is + * inferred from existing source code and experimentation.) + */ +#define GVE_LEN_ALIGN 64 + +/** Maximum number of pages per queue (must be a power of two) */ +#define GVE_QPL_MAX 16 + +/** Configuration BAR */ +#define GVE_CFG_BAR PCI_BASE_ADDRESS_0 + +/** + * Configuration BAR size + * + * All registers within the configuration BAR are big-endian. + */ +#define GVE_CFG_SIZE 0x1000 + +/** Device status */ +#define GVE_CFG_DEVSTAT 0x0000 +#define GVE_CFG_DEVSTAT_RESET 0x00000010UL /**< Device is reset */ + +/** Driver status */ +#define GVE_CFG_DRVSTAT 0x0004 +#define GVE_CFG_DRVSTAT_RUN 0x00000001UL /**< Run admin queue */ + +/** Maximum time to wait for reset */ +#define GVE_RESET_MAX_WAIT_MS 500 + +/** Admin queue page frame number (for older devices) */ +#define GVE_CFG_ADMIN_PFN 0x0010 + +/** Admin queue doorbell */ +#define GVE_CFG_ADMIN_DB 0x0014 + +/** Admin queue event counter */ +#define GVE_CFG_ADMIN_EVT 0x0018 + +/** Driver version (8-bit register) */ +#define GVE_CFG_VERSION 0x001f + +/** Admin queue base address high 32 bits */ +#define GVE_CFG_ADMIN_BASE_HI 0x0020 + +/** Admin queue base address low 32 bits */ +#define GVE_CFG_ADMIN_BASE_LO 0x0024 + +/** Admin queue base address length (16-bit register) */ +#define GVE_CFG_ADMIN_LEN 0x0028 + +/** Doorbell BAR */ +#define GVE_DB_BAR PCI_BASE_ADDRESS_2 + +/** + * Admin queue entry header + * + * All values within admin queue entries are big-endian. + */ +struct gve_admin_header { + /** Reserved */ + uint8_t reserved[3]; + /** Operation code */ + uint8_t opcode; + /** Status */ + uint32_t status; +} __attribute__ (( packed )); + +/** Command succeeded */ +#define GVE_ADMIN_STATUS_OK 0x00000001 + +/** Simple admin command */ +struct gve_admin_simple { + /** Header */ + struct gve_admin_header hdr; + /** ID */ + uint32_t id; +} __attribute__ (( packed )); + +/** Describe device command */ +#define GVE_ADMIN_DESCRIBE 0x0001 + +/** Describe device command */ +struct gve_admin_describe { + /** Header */ + struct gve_admin_header hdr; + /** Descriptor buffer address */ + uint64_t addr; + /** Descriptor version */ + uint32_t ver; + /** Descriptor maximum length */ + uint32_t len; +} __attribute__ (( packed )); + +/** Device descriptor version */ +#define GVE_ADMIN_DESCRIBE_VER 1 + +/** Device descriptor */ +struct gve_device_descriptor { + /** Reserved */ + uint8_t reserved_a[10]; + /** Number of transmit queue entries */ + uint16_t tx_count; + /** Number of receive queue entries */ + uint16_t rx_count; + /** Reserved */ + uint8_t reserved_b[2]; + /** Maximum transmit unit */ + uint16_t mtu; + /** Number of event counters */ + uint16_t counters; + /** Reserved */ + uint8_t reserved_c[4]; + /** MAC address */ + struct google_mac mac; + /** Reserved */ + uint8_t reserved_d[10]; +} __attribute__ (( packed )); + +/** Configure device resources command */ +#define GVE_ADMIN_CONFIGURE 0x0002 + +/** Configure device resources command */ +struct gve_admin_configure { + /** Header */ + struct gve_admin_header hdr; + /** Event counter array */ + uint64_t events; + /** IRQ doorbell address */ + uint64_t irqs; + /** Number of event counters */ + uint32_t num_events; + /** Number of IRQ doorbells */ + uint32_t num_irqs; + /** IRQ doorbell stride */ + uint32_t irq_stride; +} __attribute__ (( packed )); + +/** Register page list command */ +#define GVE_ADMIN_REGISTER 0x0003 + +/** Register page list command */ +struct gve_admin_register { + /** Header */ + struct gve_admin_header hdr; + /** Page list ID */ + uint32_t id; + /** Number of pages */ + uint32_t count; + /** Address list address */ + uint64_t addr; + /** Page size */ + uint64_t size; +} __attribute__ (( packed )); + +/** Page list */ +struct gve_pages { + /** Page address */ + uint64_t addr[GVE_QPL_MAX]; +} __attribute__ (( packed )); + +/** Unregister page list command */ +#define GVE_ADMIN_UNREGISTER 0x0004 + +/** Create transmit queue command */ +#define GVE_ADMIN_CREATE_TX 0x0005 + +/** Create transmit queue command */ +struct gve_admin_create_tx { + /** Header */ + struct gve_admin_header hdr; + /** Queue ID */ + uint32_t id; + /** Reserved */ + uint8_t reserved_a[4]; + /** Queue resources address */ + uint64_t res; + /** Descriptor ring address */ + uint64_t desc; + /** Queue page list ID */ + uint32_t qpl_id; + /** Notification channel ID */ + uint32_t notify_id; +} __attribute__ (( packed )); + +/** Create receive queue command */ +#define GVE_ADMIN_CREATE_RX 0x0006 + +/** Create receive queue command */ +struct gve_admin_create_rx { + /** Header */ + struct gve_admin_header hdr; + /** Queue ID */ + uint32_t id; + /** Index */ + uint32_t index; + /** Reserved */ + uint8_t reserved_a[4]; + /** Notification channel ID */ + uint32_t notify_id; + /** Queue resources address */ + uint64_t res; + /** Completion ring address */ + uint64_t cmplt; + /** Descriptor ring address */ + uint64_t desc; + /** Queue page list ID */ + uint32_t qpl_id; + /** Reserved */ + uint8_t reserved_b[2]; + /** Packet buffer size */ + uint16_t bufsz; +} __attribute__ (( packed )); + +/** Destroy transmit queue command */ +#define GVE_ADMIN_DESTROY_TX 0x0007 + +/** Destroy receive queue command */ +#define GVE_ADMIN_DESTROY_RX 0x0008 + +/** Deconfigure device resources command */ +#define GVE_ADMIN_DECONFIGURE 0x0009 + +/** An admin queue command */ +union gve_admin_command { + /** Header */ + struct gve_admin_header hdr; + /** Simple command */ + struct gve_admin_simple simple; + /** Describe device */ + struct gve_admin_describe desc; + /** Configure device resources */ + struct gve_admin_configure conf; + /** Register page list */ + struct gve_admin_register reg; + /** Create transmit queue */ + struct gve_admin_create_tx create_tx; + /** Create receive queue */ + struct gve_admin_create_rx create_rx; + /** Padding */ + uint8_t pad[64]; +}; + +/** + * Number of admin queue commands + * + * This is theoretically a policy decision. However, older revisions + * of the hardware seem to have only the "admin queue page frame + * number" register and no "admin queue length" register, with the + * implication that the admin queue must be exactly one page in + * length. + * + * Choose to use a one page (4kB) admin queue for both older and newer + * versions of the hardware, to minimise variability. + */ +#define GVE_ADMIN_COUNT ( GVE_PAGE_SIZE / sizeof ( union gve_admin_command ) ) + +/** Admin queue */ +struct gve_admin { + /** Commands */ + union gve_admin_command *cmd; + /** Producer counter */ + uint32_t prod; + /** DMA mapping */ + struct dma_mapping map; +}; + +/** Scratch buffer for admin queue commands */ +struct gve_scratch { + /** Buffer contents */ + union { + /** Device descriptor */ + struct gve_device_descriptor desc; + /** Page address list */ + struct gve_pages pages; + } *buf; + /** DMA mapping */ + struct dma_mapping map; +}; + +/** + * An event counter + * + * Written by the device to indicate completions. The device chooses + * which counter to use for each transmit queue, and stores the index + * of the chosen counter in the queue resources. + */ +struct gve_event { + /** Number of events that have occurred */ + volatile uint32_t count; +} __attribute__ (( packed )); + +/** + * Maximum number of event counters + * + * We tell the device how many event counters we have provided via the + * "configure device resources" admin queue command. The device will + * accept being given only a single counter, but will subsequently + * fail to create a receive queue. + * + * There is, of course, no documentation indicating how may event + * counters actually need to be provided. In the absence of evidence + * to the contrary, assume that 16 counters (i.e. the smallest number + * we can allocate, given the length alignment constraint on + * allocations) will be sufficient. + */ +#define GVE_EVENT_MAX ( GVE_LEN_ALIGN / sizeof ( struct gve_event ) ) + +/** Event counter array */ +struct gve_events { + /** Event counters */ + struct gve_event *event; + /** DMA mapping */ + struct dma_mapping map; + /** Actual number of event counters */ + unsigned int count; +}; + +/** An interrupt channel */ +struct gve_irq { + /** Interrupt doorbell index (within doorbell BAR) */ + uint32_t db_idx; + /** Reserved */ + uint8_t reserved[60]; +} __attribute__ (( packed )); + +/** + * Number of interrupt channels + * + * We tell the device how many interrupt channels we have provided via + * the "configure device resources" admin queue command. The device + * will accept being given zero interrupt channels, but will + * subsequently fail to create more than a single queue (either + * transmit or receive). + * + * There is, of course, no documentation indicating how may interrupt + * channels actually need to be provided. In the absence of evidence + * to the contrary, assume that two channels (one for transmit, one + * for receive) will be sufficient. + */ +#define GVE_IRQ_COUNT 2 + +/** Interrupt channel array */ +struct gve_irqs { + /** Interrupt channels */ + struct gve_irq *irq; + /** DMA mapping */ + struct dma_mapping map; + /** Interrupt doorbells */ + volatile uint32_t *db[GVE_IRQ_COUNT]; +}; + +/** Disable interrupts */ +#define GVE_IRQ_DISABLE 0x40000000UL + +/** + * Queue resources + * + * Written by the device to indicate the indices of the chosen event + * counter and descriptor doorbell register. + * + * This appears to be a largely pointless data structure: the relevant + * information is static for the lifetime of the queue and could + * trivially have been returned in the response for the "create + * transmit/receive queue" command, instead of requiring yet another + * page-aligned coherent DMA buffer allocation. + */ +struct gve_resources { + /** Descriptor doorbell index (within doorbell BAR) */ + uint32_t db_idx; + /** Event counter index (within event counter array) */ + uint32_t evt_idx; + /** Reserved */ + uint8_t reserved[56]; +} __attribute__ (( packed )); + +/** + * Queue data buffer size + * + * In theory, we may specify the size of receive buffers. However, + * the original version of the device seems not to have a parameter + * for this, and assumes the use of half-page (2kB) buffers. Choose + * to use this as the buffer size, on the assumption that older + * devices will not support any other buffer size. + */ +#define GVE_BUF_SIZE ( GVE_PAGE_SIZE / 2 ) + +/** Number of data buffers per page */ +#define GVE_BUF_PER_PAGE ( GVE_PAGE_SIZE / GVE_BUF_SIZE ) + +/** + * Queue page list + * + * The device uses preregistered pages for fast-path DMA operations + * (i.e. transmit and receive buffers). A list of device addresses + * for each page must be registered before the transmit or receive + * queue is created, and cannot subsequently be modified. + * + * The Linux driver allocates pages as DMA_TO_DEVICE or + * DMA_FROM_DEVICE as appropriate, and uses dma_sync_single_for_cpu() + * etc to ensure that data is copied to/from bounce buffers as needed. + * + * Unfortunately there is no such sync operation available within our + * DMA API, since we are constrained by the limitations imposed by + * EFI_PCI_IO_PROTOCOL. There is no way to synchronise a buffer + * without also [un]mapping it, and no way to force the reuse of the + * same device address for a subsequent remapping. We are therefore + * constrained to use only DMA-coherent buffers, since this is the + * only way we can repeatedly reuse the same device address. + * + * Newer versions of the gVNIC device support "raw DMA addressing + * (RDA)", which is essentially a prebuilt queue page list covering + * the whole of the guest address space. Unfortunately we cannot rely + * on this, since older versions will not support it. + * + * Experimentation suggests that the device will accept a request to + * create a queue page list covering the whole of the guest address + * space via two giant "pages" of 2^63 bytes each. However, + * experimentation also suggests that the device will accept any old + * garbage value as the "page size". In the total absence of any + * documentation, it is probably unsafe to conclude that the device is + * bothering to look at or respect the "page size" parameter: it is + * most likely just presuming the use of 4kB pages. + */ +struct gve_qpl { + /** Page addresses */ + userptr_t data; + /** Page mapping */ + struct dma_mapping map; + /** Number of pages */ + unsigned int count; + /** Queue page list ID */ + unsigned int id; +}; + +/** + * Maximum number of transmit buffers + * + * This is a policy decision. + */ +#define GVE_TX_FILL 8 + +/** Transmit queue page list ID */ +#define GVE_TX_QPL 0x18ae5458 + +/** Tranmsit queue interrupt channel */ +#define GVE_TX_IRQ 0 + +/** A transmit or receive buffer descriptor */ +struct gve_buffer { + /** Address (within queue page list address space) */ + uint64_t addr; +} __attribute__ (( packed )); + +/** A transmit packet descriptor */ +struct gve_tx_packet { + /** Type */ + uint8_t type; + /** Reserved */ + uint8_t reserved_a[2]; + /** Number of descriptors in this packet */ + uint8_t count; + /** Total length of this packet */ + uint16_t total; + /** Length of this descriptor */ + uint16_t len; +} __attribute__ (( packed )); + +/** A transmit descriptor */ +struct gve_tx_descriptor { + /** Packet descriptor */ + struct gve_tx_packet pkt; + /** Buffer descriptor */ + struct gve_buffer buf; +} __attribute__ (( packed )); + +/** Start of packet transmit descriptor type */ +#define GVE_TX_TYPE_START 0x00 + +/** Continuation of packet transmit descriptor type */ +#define GVE_TX_TYPE_CONT 0x20 + +/** + * Maximum number of receive buffers + * + * This is a policy decision. + */ +#define GVE_RX_FILL 16 + +/** Receive queue page list ID */ +#define GVE_RX_QPL 0x18ae5258 + +/** Receive queue interrupt channel */ +#define GVE_RX_IRQ 1 + +/** A receive descriptor */ +struct gve_rx_descriptor { + /** Buffer descriptor */ + struct gve_buffer buf; +} __attribute__ (( packed )); + +/** A receive packet descriptor */ +struct gve_rx_packet { + /** Length */ + uint16_t len; + /** Flags */ + uint8_t flags; + /** Sequence number */ + uint8_t seq; +} __attribute__ (( packed )); + +/** Receive error */ +#define GVE_RXF_ERROR 0x08 + +/** Receive packet continues into next descriptor */ +#define GVE_RXF_MORE 0x20 + +/** Receive sequence number mask */ +#define GVE_RX_SEQ_MASK 0x07 + +/** A receive completion descriptor */ +struct gve_rx_completion { + /** Reserved */ + uint8_t reserved[60]; + /** Packet descriptor */ + struct gve_rx_packet pkt; +} __attribute__ (( packed )); + +/** Padding at the start of all received packets */ +#define GVE_RX_PAD 2 + +/** A descriptor queue */ +struct gve_queue { + /** Descriptor ring */ + userptr_t desc; + /** Completion ring */ + userptr_t cmplt; + /** Queue resources */ + struct gve_resources *res; + + /** Queue type */ + const struct gve_queue_type *type; + /** Number of descriptors (must be a power of two) */ + unsigned int count; + /** Maximum fill level (must be a power of two) */ + unsigned int fill; + + /** Descriptor mapping */ + struct dma_mapping desc_map; + /** Completion mapping */ + struct dma_mapping cmplt_map; + /** Queue resources mapping */ + struct dma_mapping res_map; + + /** Doorbell register */ + volatile uint32_t *db; + /** Event counter */ + struct gve_event *event; + + /** Producer counter */ + uint32_t prod; + /** Consumer counter */ + uint32_t cons; + + /** Queue page list */ + struct gve_qpl qpl; +}; + +/** A descriptor queue type */ +struct gve_queue_type { + /** Name */ + const char *name; + /** + * Populate command parameters to create queue + * + * @v queue Descriptor queue + * @v cmd Admin queue command + */ + void ( * param ) ( struct gve_queue *queue, + union gve_admin_command *cmd ); + /** Queue page list ID */ + uint32_t qpl; + /** Interrupt channel */ + uint8_t irq; + /** Maximum fill level */ + uint8_t fill; + /** Descriptor size */ + uint8_t desc_len; + /** Completion size */ + uint8_t cmplt_len; + /** Command to create queue */ + uint8_t create; + /** Command to destroy queue */ + uint8_t destroy; +}; + +/** A Google Virtual Ethernet NIC */ +struct gve_nic { + /** Configuration registers */ + void *cfg; + /** Doorbell registers */ + void *db; + /** PCI revision */ + uint8_t revision; + /** Network device */ + struct net_device *netdev; + /** DMA device */ + struct dma_device *dma; + + /** Admin queue */ + struct gve_admin admin; + /** Interrupt channels */ + struct gve_irqs irqs; + /** Event counters */ + struct gve_events events; + /** Scratch buffer */ + struct gve_scratch scratch; + + /** Transmit queue */ + struct gve_queue tx; + /** Receive queue */ + struct gve_queue rx; + /** Transmit I/O buffers */ + struct io_buffer *tx_iobuf[GVE_TX_FILL]; + /** Receive sequence number */ + unsigned int seq; + + /** Startup process */ + struct process startup; + /** Startup process retry counter */ + unsigned int retries; + /** Reset recovery watchdog timer */ + struct retry_timer watchdog; + /** Reset recovery recorded activity counter */ + uint32_t activity; +}; + +/** Maximum time to wait for admin queue commands */ +#define GVE_ADMIN_MAX_WAIT_MS 500 + +/** Maximum number of times to reattempt device reset */ +#define GVE_RESET_MAX_RETRY 5 + +/** Time between reset recovery checks */ +#define GVE_WATCHDOG_TIMEOUT ( 1 * TICKS_PER_SEC ) + +#endif /* _GVE_H */ -- cgit v1.2.3-55-g7522 From d2d194bc60f012569fa95ed54693cb6663beb5ce Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 25 Jul 2024 00:10:38 +0100 Subject: [gve] Increase number of receive buffers to reduce packet loss Experiments suggest that using fewer than 64 receive buffers leads to excessive packet drop rates on some instance types (observed with a c3-standard-4 instance in europe-west4-a). Fix by increasing the number of receive data buffers (and adjusting the length of the registrable queue page address list to match). Signed-off-by: Michael Brown --- src/drivers/net/gve.c | 1 + src/drivers/net/gve.h | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/gve.c b/src/drivers/net/gve.c index 03edc0899..7f86dd219 100644 --- a/src/drivers/net/gve.c +++ b/src/drivers/net/gve.c @@ -722,6 +722,7 @@ static int gve_alloc_qpl ( struct gve_nic *gve, struct gve_qpl *qpl, /* Calculate number of pages required */ build_assert ( GVE_BUF_SIZE <= GVE_PAGE_SIZE ); qpl->count = ( ( buffers + GVE_BUF_PER_PAGE - 1 ) / GVE_BUF_PER_PAGE ); + assert ( qpl->count <= GVE_QPL_MAX ); /* Allocate pages (as a single block) */ len = ( qpl->count * GVE_PAGE_SIZE ); diff --git a/src/drivers/net/gve.h b/src/drivers/net/gve.h index 2845699ac..247d6e699 100644 --- a/src/drivers/net/gve.h +++ b/src/drivers/net/gve.h @@ -59,9 +59,6 @@ struct google_mac { */ #define GVE_LEN_ALIGN 64 -/** Maximum number of pages per queue (must be a power of two) */ -#define GVE_QPL_MAX 16 - /** Configuration BAR */ #define GVE_CFG_BAR PCI_BASE_ADDRESS_0 @@ -208,6 +205,14 @@ struct gve_admin_register { uint64_t size; } __attribute__ (( packed )); +/** + * Maximum number of pages per queue + * + * This is a policy decision. Must be sufficient to allow for both + * the transmit and receive queue fill levels. + */ +#define GVE_QPL_MAX 32 + /** Page list */ struct gve_pages { /** Page address */ @@ -538,9 +543,11 @@ struct gve_tx_descriptor { /** * Maximum number of receive buffers * - * This is a policy decision. + * This is a policy decision. Experiments suggest that using fewer + * than 64 receive buffers leads to excessive packet drop rates on + * some instance types. */ -#define GVE_RX_FILL 16 +#define GVE_RX_FILL 64 /** Receive queue page list ID */ #define GVE_RX_QPL 0x18ae5258 -- cgit v1.2.3-55-g7522 From 7c82ff0b6b12437bfc25d01d52308fc6fe2e1311 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 15 Aug 2024 08:46:41 +0100 Subject: [pci] Separate permission to probe buses from bus:dev.fn range discovery The UEFI device model requires us to not probe the PCI bus directly, but instead to wait to be offered the opportunity to drive devices via our driver service binding handle. We currently inhibit PCI bus probing by having pci_discover() return an empty range when using the EFI PCI I/O API. This has the unwanted side effect that scanning the bus manually using the "pciscan" command will also fail to discover any devices. Separate out the concept of being allowed to probe PCI buses from the mechanism for discovering PCI bus:dev.fn address ranges, so that this limitation may be removed. Signed-off-by: Michael Brown --- src/arch/x86/core/pcidirect.c | 1 + src/arch/x86/include/ipxe/pcibios.h | 10 ++++++++++ src/arch/x86/include/ipxe/pcicloud.h | 10 ++++++++++ src/arch/x86/include/ipxe/pcidirect.h | 10 ++++++++++ src/arch/x86/interface/pcbios/pcibios.c | 1 + src/arch/x86/interface/pcbios/pcicloud.c | 1 + src/drivers/bus/ecam.c | 1 + src/drivers/bus/pci.c | 4 ++++ src/include/ipxe/ecam.h | 10 ++++++++++ src/include/ipxe/efi/efi_pci_api.h | 10 ++++++++++ src/include/ipxe/linux/linux_pci.h | 10 ++++++++++ src/include/ipxe/pci_io.h | 7 +++++++ src/interface/efi/efi_pci.c | 1 + src/interface/linux/linux_pci.c | 1 + 14 files changed, 77 insertions(+) (limited to 'src/drivers') diff --git a/src/arch/x86/core/pcidirect.c b/src/arch/x86/core/pcidirect.c index f4659a1ac..90d4623b3 100644 --- a/src/arch/x86/core/pcidirect.c +++ b/src/arch/x86/core/pcidirect.c @@ -45,6 +45,7 @@ void pcidirect_prepare ( struct pci_device *pci, int where ) { PCIDIRECT_CONFIG_ADDRESS ); } +PROVIDE_PCIAPI_INLINE ( direct, pci_can_probe ); PROVIDE_PCIAPI_INLINE ( direct, pci_discover ); PROVIDE_PCIAPI_INLINE ( direct, pci_read_config_byte ); PROVIDE_PCIAPI_INLINE ( direct, pci_read_config_word ); diff --git a/src/arch/x86/include/ipxe/pcibios.h b/src/arch/x86/include/ipxe/pcibios.h index 3caea1cfe..ef9585654 100644 --- a/src/arch/x86/include/ipxe/pcibios.h +++ b/src/arch/x86/include/ipxe/pcibios.h @@ -32,6 +32,16 @@ extern int pcibios_read ( struct pci_device *pci, uint32_t command, extern int pcibios_write ( struct pci_device *pci, uint32_t command, uint32_t value ); +/** + * Check if PCI bus probing is allowed + * + * @ret ok Bus probing is allowed + */ +static inline __always_inline int +PCIAPI_INLINE ( pcbios, pci_can_probe ) ( void ) { + return 1; +} + /** * Read byte from PCI configuration space via PCI BIOS * diff --git a/src/arch/x86/include/ipxe/pcicloud.h b/src/arch/x86/include/ipxe/pcicloud.h index 52268908c..1feef56cb 100644 --- a/src/arch/x86/include/ipxe/pcicloud.h +++ b/src/arch/x86/include/ipxe/pcicloud.h @@ -15,4 +15,14 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define PCIAPI_PREFIX_cloud __cloud_ #endif +/** + * Check if PCI bus probing is allowed + * + * @ret ok Bus probing is allowed + */ +static inline __always_inline int +PCIAPI_INLINE ( cloud, pci_can_probe ) ( void ) { + return 1; +} + #endif /* _IPXE_PCICLOUD_H */ diff --git a/src/arch/x86/include/ipxe/pcidirect.h b/src/arch/x86/include/ipxe/pcidirect.h index 98c6a2bbb..999b52763 100644 --- a/src/arch/x86/include/ipxe/pcidirect.h +++ b/src/arch/x86/include/ipxe/pcidirect.h @@ -25,6 +25,16 @@ struct pci_device; extern void pcidirect_prepare ( struct pci_device *pci, int where ); +/** + * Check if PCI bus probing is allowed + * + * @ret ok Bus probing is allowed + */ +static inline __always_inline int +PCIAPI_INLINE ( direct, pci_can_probe ) ( void ) { + return 1; +} + /** * Find next PCI bus:dev.fn address range in system * diff --git a/src/arch/x86/interface/pcbios/pcibios.c b/src/arch/x86/interface/pcbios/pcibios.c index 7b7a769e3..ebe40ba7d 100644 --- a/src/arch/x86/interface/pcbios/pcibios.c +++ b/src/arch/x86/interface/pcbios/pcibios.c @@ -120,6 +120,7 @@ int pcibios_write ( struct pci_device *pci, uint32_t command, uint32_t value ){ return ( status >> 8 ); } +PROVIDE_PCIAPI_INLINE ( pcbios, pci_can_probe ); PROVIDE_PCIAPI ( pcbios, pci_discover, pcibios_discover ); PROVIDE_PCIAPI_INLINE ( pcbios, pci_read_config_byte ); PROVIDE_PCIAPI_INLINE ( pcbios, pci_read_config_word ); diff --git a/src/arch/x86/interface/pcbios/pcicloud.c b/src/arch/x86/interface/pcbios/pcicloud.c index 98ba38b31..f7d4a2da1 100644 --- a/src/arch/x86/interface/pcbios/pcicloud.c +++ b/src/arch/x86/interface/pcbios/pcicloud.c @@ -148,6 +148,7 @@ static void * pcicloud_ioremap ( struct pci_device *pci, return pcicloud->pci_ioremap ( pci, bus_addr, len ); } +PROVIDE_PCIAPI_INLINE ( cloud, pci_can_probe ); PROVIDE_PCIAPI ( cloud, pci_discover, pcicloud_discover ); PROVIDE_PCIAPI ( cloud, pci_read_config_byte, pcicloud_read_config_byte ); PROVIDE_PCIAPI ( cloud, pci_read_config_word, pcicloud_read_config_word ); diff --git a/src/drivers/bus/ecam.c b/src/drivers/bus/ecam.c index 5e3debddd..cde5952b8 100644 --- a/src/drivers/bus/ecam.c +++ b/src/drivers/bus/ecam.c @@ -276,6 +276,7 @@ int ecam_write ( struct pci_device *pci, unsigned int location, return 0; } +PROVIDE_PCIAPI_INLINE ( ecam, pci_can_probe ); PROVIDE_PCIAPI ( ecam, pci_discover, ecam_discover ); PROVIDE_PCIAPI_INLINE ( ecam, pci_read_config_byte ); PROVIDE_PCIAPI_INLINE ( ecam, pci_read_config_word ); diff --git a/src/drivers/bus/pci.c b/src/drivers/bus/pci.c index 92b389641..05c9a5c26 100644 --- a/src/drivers/bus/pci.c +++ b/src/drivers/bus/pci.c @@ -361,6 +361,10 @@ static int pcibus_probe ( struct root_device *rootdev ) { uint32_t busdevfn = 0; int rc; + /* Skip automatic probing if prohibited */ + if ( ! pci_can_probe() ) + return 0; + do { /* Allocate struct pci_device */ if ( ! pci ) diff --git a/src/include/ipxe/ecam.h b/src/include/ipxe/ecam.h index ff08aee5a..f656083f7 100644 --- a/src/include/ipxe/ecam.h +++ b/src/include/ipxe/ecam.h @@ -54,6 +54,16 @@ struct ecam_mapping { int rc; }; +/** + * Check if PCI bus probing is allowed + * + * @ret ok Bus probing is allowed + */ +static inline __always_inline int +PCIAPI_INLINE ( ecam, pci_can_probe ) ( void ) { + return 1; +} + extern struct pci_api ecam_api; #endif /* _IPXE_ECAM_H */ diff --git a/src/include/ipxe/efi/efi_pci_api.h b/src/include/ipxe/efi/efi_pci_api.h index cf5e1d020..0c4c1b72c 100644 --- a/src/include/ipxe/efi/efi_pci_api.h +++ b/src/include/ipxe/efi/efi_pci_api.h @@ -32,6 +32,16 @@ extern int efipci_read ( struct pci_device *pci, unsigned long location, extern int efipci_write ( struct pci_device *pci, unsigned long location, unsigned long value ); +/** + * Check if PCI bus probing is allowed + * + * @ret ok Bus probing is allowed + */ +static inline __always_inline int +PCIAPI_INLINE ( efi, pci_can_probe ) ( void ) { + return 0; +} + /** * Find next PCI bus:dev.fn address range in system * diff --git a/src/include/ipxe/linux/linux_pci.h b/src/include/ipxe/linux/linux_pci.h index ec6ff8b1c..2b19e13c3 100644 --- a/src/include/ipxe/linux/linux_pci.h +++ b/src/include/ipxe/linux/linux_pci.h @@ -22,6 +22,16 @@ extern int linux_pci_read ( struct pci_device *pci, unsigned long where, extern int linux_pci_write ( struct pci_device *pci, unsigned long where, unsigned long value, size_t len ); +/** + * Check if PCI bus probing is allowed + * + * @ret ok Bus probing is allowed + */ +static inline __always_inline int +PCIAPI_INLINE ( linux, pci_can_probe ) ( void ) { + return 1; +} + /** * Find next PCI bus:dev.fn address range in system * diff --git a/src/include/ipxe/pci_io.h b/src/include/ipxe/pci_io.h index 4c035b18b..322fdbb24 100644 --- a/src/include/ipxe/pci_io.h +++ b/src/include/ipxe/pci_io.h @@ -66,6 +66,13 @@ struct pci_range { /* Include all architecture-dependent I/O API headers */ #include +/** + * Check if PCI bus probing is allowed + * + * @ret ok Bus probing is allowed + */ +int pci_can_probe ( void ); + /** * Find next PCI bus:dev.fn address range in system * diff --git a/src/interface/efi/efi_pci.c b/src/interface/efi/efi_pci.c index e2eeeb344..61071d8a4 100644 --- a/src/interface/efi/efi_pci.c +++ b/src/interface/efi/efi_pci.c @@ -362,6 +362,7 @@ void * efipci_ioremap ( struct pci_device *pci, unsigned long bus_addr, return ioremap ( bus_addr, len ); } +PROVIDE_PCIAPI_INLINE ( efi, pci_can_probe ); PROVIDE_PCIAPI_INLINE ( efi, pci_discover ); PROVIDE_PCIAPI_INLINE ( efi, pci_read_config_byte ); PROVIDE_PCIAPI_INLINE ( efi, pci_read_config_word ); diff --git a/src/interface/linux/linux_pci.c b/src/interface/linux/linux_pci.c index 300844737..a3a0828c1 100644 --- a/src/interface/linux/linux_pci.c +++ b/src/interface/linux/linux_pci.c @@ -188,6 +188,7 @@ int linux_pci_write ( struct pci_device *pci, unsigned long where, return rc; } +PROVIDE_PCIAPI_INLINE ( linux, pci_can_probe ); PROVIDE_PCIAPI_INLINE ( linux, pci_discover ); PROVIDE_PCIAPI_INLINE ( linux, pci_read_config_byte ); PROVIDE_PCIAPI_INLINE ( linux, pci_read_config_word ); -- cgit v1.2.3-55-g7522 From 53f089b723e16eecb4fd2e2a59b74b3932431b30 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sun, 18 Aug 2024 10:43:52 +0100 Subject: [crypto] Pass asymmetric keys as ASN.1 cursors Asymmetric keys are invariably encountered within ASN.1 structures such as X.509 certificates, and the various large integers within an RSA key are themselves encoded using ASN.1. Simplify all code handling asymmetric keys by passing keys as a single ASN.1 cursor, rather than separate data and length pointers. Signed-off-by: Michael Brown --- src/crypto/cms.c | 3 +-- src/crypto/crypto_null.c | 4 +-- src/crypto/ocsp.c | 4 +-- src/crypto/rsa.c | 30 +++++---------------- src/crypto/x509.c | 9 +++---- src/drivers/net/iphone.c | 3 +-- src/include/ipxe/crypto.h | 23 +++++++--------- src/net/tls.c | 5 ++-- src/tests/pubkey_test.h | 37 ++++++++++---------------- src/tests/rsa_test.c | 68 +++++++++++++++++++++-------------------------- 10 files changed, 74 insertions(+), 112 deletions(-) (limited to 'src/drivers') diff --git a/src/crypto/cms.c b/src/crypto/cms.c index 1f33613f4..0b772f1cf 100644 --- a/src/crypto/cms.c +++ b/src/crypto/cms.c @@ -621,8 +621,7 @@ static int cms_verify_digest ( struct cms_message *cms, cms_digest ( cms, part, data, len, digest_out ); /* Initialise public-key algorithm */ - if ( ( rc = pubkey_init ( pubkey, ctx, public_key->raw.data, - public_key->raw.len ) ) != 0 ) { + if ( ( rc = pubkey_init ( pubkey, ctx, &public_key->raw ) ) != 0 ) { DBGC ( cms, "CMS %p/%p could not initialise public key: %s\n", cms, part, strerror ( rc ) ); goto err_init; diff --git a/src/crypto/crypto_null.c b/src/crypto/crypto_null.c index 0ad463c3e..b4169382b 100644 --- a/src/crypto/crypto_null.c +++ b/src/crypto/crypto_null.c @@ -93,8 +93,8 @@ struct cipher_algorithm cipher_null = { .auth = cipher_null_auth, }; -int pubkey_null_init ( void *ctx __unused, const void *key __unused, - size_t key_len __unused ) { +int pubkey_null_init ( void *ctx __unused, + const struct asn1_cursor *key __unused ) { return 0; } diff --git a/src/crypto/ocsp.c b/src/crypto/ocsp.c index cc957b40c..f35593454 100644 --- a/src/crypto/ocsp.c +++ b/src/crypto/ocsp.c @@ -857,8 +857,8 @@ static int ocsp_check_signature ( struct ocsp_check *ocsp, digest_final ( digest, digest_ctx, digest_out ); /* Initialise public-key algorithm */ - if ( ( rc = pubkey_init ( pubkey, pubkey_ctx, public_key->raw.data, - public_key->raw.len ) ) != 0 ) { + if ( ( rc = pubkey_init ( pubkey, pubkey_ctx, + &public_key->raw ) ) != 0 ) { DBGC ( ocsp, "OCSP %p \"%s\" could not initialise public key: " "%s\n", ocsp, x509_name ( ocsp->cert ), strerror ( rc )); goto err_init; diff --git a/src/crypto/rsa.c b/src/crypto/rsa.c index 16c67d822..2d288a953 100644 --- a/src/crypto/rsa.c +++ b/src/crypto/rsa.c @@ -233,27 +233,21 @@ static int rsa_parse_mod_exp ( struct asn1_cursor *modulus, * * @v ctx RSA context * @v key Key - * @v key_len Length of key * @ret rc Return status code */ -static int rsa_init ( void *ctx, const void *key, size_t key_len ) { +static int rsa_init ( void *ctx, const struct asn1_cursor *key ) { struct rsa_context *context = ctx; struct asn1_cursor modulus; struct asn1_cursor exponent; - struct asn1_cursor cursor; int rc; /* Initialise context */ memset ( context, 0, sizeof ( *context ) ); - /* Initialise cursor */ - cursor.data = key; - cursor.len = key_len; - /* Parse modulus and exponent */ - if ( ( rc = rsa_parse_mod_exp ( &modulus, &exponent, &cursor ) ) != 0 ){ + if ( ( rc = rsa_parse_mod_exp ( &modulus, &exponent, key ) ) != 0 ){ DBGC ( context, "RSA %p invalid modulus/exponent:\n", context ); - DBGC_HDA ( context, 0, cursor.data, cursor.len ); + DBGC_HDA ( context, 0, key->data, key->len ); goto err_parse; } @@ -592,33 +586,23 @@ static void rsa_final ( void *ctx ) { * Check for matching RSA public/private key pair * * @v private_key Private key - * @v private_key_len Private key length * @v public_key Public key - * @v public_key_len Public key length * @ret rc Return status code */ -static int rsa_match ( const void *private_key, size_t private_key_len, - const void *public_key, size_t public_key_len ) { +static int rsa_match ( const struct asn1_cursor *private_key, + const struct asn1_cursor *public_key ) { struct asn1_cursor private_modulus; struct asn1_cursor private_exponent; - struct asn1_cursor private_cursor; struct asn1_cursor public_modulus; struct asn1_cursor public_exponent; - struct asn1_cursor public_cursor; int rc; - /* Initialise cursors */ - private_cursor.data = private_key; - private_cursor.len = private_key_len; - public_cursor.data = public_key; - public_cursor.len = public_key_len; - /* Parse moduli and exponents */ if ( ( rc = rsa_parse_mod_exp ( &private_modulus, &private_exponent, - &private_cursor ) ) != 0 ) + private_key ) ) != 0 ) return rc; if ( ( rc = rsa_parse_mod_exp ( &public_modulus, &public_exponent, - &public_cursor ) ) != 0 ) + public_key ) ) != 0 ) return rc; /* Compare moduli */ diff --git a/src/crypto/x509.c b/src/crypto/x509.c index acb85620f..c0762740e 100644 --- a/src/crypto/x509.c +++ b/src/crypto/x509.c @@ -1149,8 +1149,8 @@ static int x509_check_signature ( struct x509_certificate *cert, } /* Verify signature using signer's public key */ - if ( ( rc = pubkey_init ( pubkey, pubkey_ctx, public_key->raw.data, - public_key->raw.len ) ) != 0 ) { + if ( ( rc = pubkey_init ( pubkey, pubkey_ctx, + &public_key->raw ) ) != 0 ) { DBGC ( cert, "X509 %p \"%s\" cannot initialise public key: " "%s\n", cert, x509_name ( cert ), strerror ( rc ) ); goto err_pubkey_init; @@ -1842,9 +1842,8 @@ struct x509_certificate * x509_find_key ( struct x509_chain *store, /* Check public key */ cert = link->cert; if ( pubkey_match ( cert->signature_algorithm->pubkey, - key->builder.data, key->builder.len, - cert->subject.public_key.raw.data, - cert->subject.public_key.raw.len ) == 0 ) + privkey_cursor ( key ), + &cert->subject.public_key.raw ) == 0 ) return x509_found ( store, cert ); } diff --git a/src/drivers/net/iphone.c b/src/drivers/net/iphone.c index bbac527bd..96eb0952b 100644 --- a/src/drivers/net/iphone.c +++ b/src/drivers/net/iphone.c @@ -367,8 +367,7 @@ static int icert_cert ( struct icert *icert, struct asn1_cursor *subject, int rc; /* Initialise "private" key */ - if ( ( rc = pubkey_init ( pubkey, pubkey_ctx, private->data, - private->len ) ) != 0 ) { + if ( ( rc = pubkey_init ( pubkey, pubkey_ctx, private ) ) != 0 ) { DBGC ( icert, "ICERT %p could not initialise private key: " "%s\n", icert, strerror ( rc ) ); goto err_pubkey_init; diff --git a/src/include/ipxe/crypto.h b/src/include/ipxe/crypto.h index a6f437655..8b6eb94f6 100644 --- a/src/include/ipxe/crypto.h +++ b/src/include/ipxe/crypto.h @@ -12,6 +12,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include /** A message digest algorithm */ struct digest_algorithm { @@ -126,10 +127,9 @@ struct pubkey_algorithm { * * @v ctx Context * @v key Key - * @v key_len Length of key * @ret rc Return status code */ - int ( * init ) ( void *ctx, const void *key, size_t key_len ); + int ( * init ) ( void *ctx, const struct asn1_cursor *key ); /** Calculate maximum output length * * @v ctx Context @@ -186,13 +186,11 @@ struct pubkey_algorithm { /** Check that public key matches private key * * @v private_key Private key - * @v private_key_len Private key length * @v public_key Public key - * @v public_key_len Public key length * @ret rc Return status code */ - int ( * match ) ( const void *private_key, size_t private_key_len, - const void *public_key, size_t public_key_len ); + int ( * match ) ( const struct asn1_cursor *private_key, + const struct asn1_cursor *public_key ); }; /** An elliptic curve */ @@ -282,8 +280,8 @@ is_auth_cipher ( struct cipher_algorithm *cipher ) { static inline __attribute__ (( always_inline )) int pubkey_init ( struct pubkey_algorithm *pubkey, void *ctx, - const void *key, size_t key_len ) { - return pubkey->init ( ctx, key, key_len ); + const struct asn1_cursor *key ) { + return pubkey->init ( ctx, key ); } static inline __attribute__ (( always_inline )) size_t @@ -324,10 +322,9 @@ pubkey_final ( struct pubkey_algorithm *pubkey, void *ctx ) { static inline __attribute__ (( always_inline )) int pubkey_match ( struct pubkey_algorithm *pubkey, - const void *private_key, size_t private_key_len, - const void *public_key, size_t public_key_len ) { - return pubkey->match ( private_key, private_key_len, public_key, - public_key_len ); + const struct asn1_cursor *private_key, + const struct asn1_cursor *public_key ) { + return pubkey->match ( private_key, public_key ); } static inline __attribute__ (( always_inline )) int @@ -348,7 +345,7 @@ extern void cipher_null_decrypt ( void *ctx, const void *src, void *dst, size_t len ); extern void cipher_null_auth ( void *ctx, void *auth ); -extern int pubkey_null_init ( void *ctx, const void *key, size_t key_len ); +extern int pubkey_null_init ( void *ctx, const struct asn1_cursor *key ); extern size_t pubkey_null_max_len ( void *ctx ); extern int pubkey_null_encrypt ( void *ctx, const void *plaintext, size_t plaintext_len, void *ciphertext ); diff --git a/src/net/tls.c b/src/net/tls.c index c08057103..a22626f41 100644 --- a/src/net/tls.c +++ b/src/net/tls.c @@ -1824,7 +1824,7 @@ static int tls_send_certificate_verify ( struct tls_connection *tls ) { tls_verify_handshake ( tls, digest_out ); /* Initialise public-key algorithm */ - if ( ( rc = pubkey_init ( pubkey, ctx, key->data, key->len ) ) != 0 ) { + if ( ( rc = pubkey_init ( pubkey, ctx, key ) ) != 0 ) { DBGC ( tls, "TLS %p could not initialise %s client private " "key: %s\n", tls, pubkey->name, strerror ( rc ) ); goto err_pubkey_init; @@ -3581,8 +3581,7 @@ static void tls_validator_done ( struct tls_connection *tls, int rc ) { /* Initialise public key algorithm */ if ( ( rc = pubkey_init ( pubkey, cipherspec->pubkey_ctx, - cert->subject.public_key.raw.data, - cert->subject.public_key.raw.len ) ) != 0 ) { + &cert->subject.public_key.raw ) ) != 0 ) { DBGC ( tls, "TLS %p cannot initialise public key: %s\n", tls, strerror ( rc ) ); goto err; diff --git a/src/tests/pubkey_test.h b/src/tests/pubkey_test.h index cd65b8703..214992238 100644 --- a/src/tests/pubkey_test.h +++ b/src/tests/pubkey_test.h @@ -12,17 +12,16 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * * @v pubkey Public key algorithm * @v key Key - * @v key_len Key length * @v ciphertext Ciphertext * @v ciphertext_len Ciphertext length * @v expected Expected plaintext * @v expected_len Expected plaintext length */ -#define pubkey_decrypt_ok( pubkey, key, key_len, ciphertext, \ - ciphertext_len, expected, expected_len ) do {\ +#define pubkey_decrypt_ok( pubkey, key, ciphertext, ciphertext_len, \ + expected, expected_len ) do { \ uint8_t ctx[ (pubkey)->ctxsize ]; \ \ - ok ( pubkey_init ( (pubkey), ctx, (key), (key_len) ) == 0 ); \ + ok ( pubkey_init ( (pubkey), ctx, (key) ) == 0 ); \ { \ size_t max_len = pubkey_max_len ( (pubkey), ctx ); \ uint8_t decrypted[ max_len ]; \ @@ -44,19 +43,15 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * * @v pubkey Public key algorithm * @v encrypt_key Encryption key - * @v encrypt_key_len Encryption key length * @v decrypt_key Decryption key - * @v decrypt_key_len Decryption key length * @v plaintext Plaintext * @v plaintext_len Plaintext length */ -#define pubkey_encrypt_ok( pubkey, encrypt_key, encrypt_key_len, \ - decrypt_key, decrypt_key_len, plaintext, \ +#define pubkey_encrypt_ok( pubkey, encrypt_key, decrypt_key, plaintext, \ plaintext_len ) do { \ uint8_t ctx[ (pubkey)->ctxsize ]; \ \ - ok ( pubkey_init ( (pubkey), ctx, (encrypt_key), \ - (encrypt_key_len) ) == 0 ); \ + ok ( pubkey_init ( (pubkey), ctx, (encrypt_key) ) == 0 ); \ { \ size_t max_len = pubkey_max_len ( (pubkey), ctx ); \ uint8_t encrypted[ max_len ]; \ @@ -68,9 +63,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); encrypted ); \ ok ( encrypted_len >= 0 ); \ pubkey_decrypt_ok ( (pubkey), (decrypt_key), \ - (decrypt_key_len), encrypted, \ - encrypted_len, (plaintext), \ - (plaintext_len) ); \ + encrypted, encrypted_len, \ + (plaintext), (plaintext_len) ); \ } \ pubkey_final ( (pubkey), ctx ); \ } while ( 0 ) @@ -80,15 +74,14 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * * @v pubkey Public key algorithm * @v key Key - * @v key_len Key length * @v digest Digest algorithm * @v plaintext Plaintext * @v plaintext_len Plaintext length * @v expected Expected signature * @v expected_len Expected signature length */ -#define pubkey_sign_ok( pubkey, key, key_len, digest, plaintext, \ - plaintext_len, expected, expected_len ) do { \ +#define pubkey_sign_ok( pubkey, key, digest, plaintext, plaintext_len, \ + expected, expected_len ) do { \ uint8_t ctx[ (pubkey)->ctxsize ]; \ uint8_t digestctx[ (digest)->ctxsize ]; \ uint8_t digestout[ (digest)->digestsize ]; \ @@ -98,7 +91,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); (plaintext_len) ); \ digest_final ( (digest), digestctx, digestout ); \ \ - ok ( pubkey_init ( (pubkey), ctx, (key), (key_len) ) == 0 ); \ + ok ( pubkey_init ( (pubkey), ctx, (key) ) == 0 ); \ { \ size_t max_len = pubkey_max_len ( (pubkey), ctx ); \ uint8_t signature[ max_len ]; \ @@ -118,14 +111,13 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * * @v pubkey Public key algorithm * @v key Key - * @v key_len Key length * @v digest Digest algorithm * @v plaintext Plaintext * @v plaintext_len Plaintext length * @v signature Signature * @v signature_len Signature length */ -#define pubkey_verify_ok( pubkey, key, key_len, digest, plaintext, \ +#define pubkey_verify_ok( pubkey, key, digest, plaintext, \ plaintext_len, signature, signature_len ) do {\ uint8_t ctx[ (pubkey)->ctxsize ]; \ uint8_t digestctx[ (digest)->ctxsize ]; \ @@ -136,7 +128,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); (plaintext_len) ); \ digest_final ( (digest), digestctx, digestout ); \ \ - ok ( pubkey_init ( (pubkey), ctx, (key), (key_len) ) == 0 ); \ + ok ( pubkey_init ( (pubkey), ctx, (key) ) == 0 ); \ ok ( pubkey_verify ( (pubkey), ctx, (digest), digestout, \ (signature), (signature_len) ) == 0 ); \ pubkey_final ( (pubkey), ctx ); \ @@ -147,14 +139,13 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * * @v pubkey Public key algorithm * @v key Key - * @v key_len Key length * @v digest Digest algorithm * @v plaintext Plaintext * @v plaintext_len Plaintext length * @v signature Signature * @v signature_len Signature length */ -#define pubkey_verify_fail_ok( pubkey, key, key_len, digest, plaintext, \ +#define pubkey_verify_fail_ok( pubkey, key, digest, plaintext, \ plaintext_len, signature, \ signature_len ) do { \ uint8_t ctx[ (pubkey)->ctxsize ]; \ @@ -166,7 +157,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); (plaintext_len) ); \ digest_final ( (digest), digestctx, digestout ); \ \ - ok ( pubkey_init ( (pubkey), ctx, (key), (key_len) ) == 0 ); \ + ok ( pubkey_init ( (pubkey), ctx, (key) ) == 0 ); \ ok ( pubkey_verify ( (pubkey), ctx, (digest), digestout, \ (signature), (signature_len) ) != 0 ); \ pubkey_final ( (pubkey), ctx ); \ diff --git a/src/tests/rsa_test.c b/src/tests/rsa_test.c index 46894f603..b1d522bc0 100644 --- a/src/tests/rsa_test.c +++ b/src/tests/rsa_test.c @@ -61,13 +61,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /** An RSA encryption and decryption self-test */ struct rsa_encrypt_decrypt_test { /** Private key */ - const void *private; - /** Private key length */ - size_t private_len; + const struct asn1_cursor private; /** Public key */ - const void *public; - /** Public key length */ - size_t public_len; + const struct asn1_cursor public; /** Plaintext */ const void *plaintext; /** Plaintext length */ @@ -100,10 +96,14 @@ struct rsa_encrypt_decrypt_test { static const uint8_t name ## _plaintext[] = PLAINTEXT; \ static const uint8_t name ## _ciphertext[] = CIPHERTEXT; \ static struct rsa_encrypt_decrypt_test name = { \ - .private = name ## _private, \ - .private_len = sizeof ( name ## _private ), \ - .public = name ## _public, \ - .public_len = sizeof ( name ## _public ), \ + .private = { \ + .data = name ## _private, \ + .len = sizeof ( name ## _private ), \ + }, \ + .public = { \ + .data = name ## _public, \ + .len = sizeof ( name ## _public ), \ + }, \ .plaintext = name ## _plaintext, \ .plaintext_len = sizeof ( name ## _plaintext ), \ .ciphertext = name ## _ciphertext, \ @@ -113,13 +113,9 @@ struct rsa_encrypt_decrypt_test { /** An RSA signature self-test */ struct rsa_signature_test { /** Private key */ - const void *private; - /** Private key length */ - size_t private_len; + const struct asn1_cursor private; /** Public key */ - const void *public; - /** Public key length */ - size_t public_len; + const struct asn1_cursor public; /** Plaintext */ const void *plaintext; /** Plaintext length */ @@ -150,10 +146,14 @@ struct rsa_signature_test { static const uint8_t name ## _plaintext[] = PLAINTEXT; \ static const uint8_t name ## _signature[] = SIGNATURE; \ static struct rsa_signature_test name = { \ - .private = name ## _private, \ - .private_len = sizeof ( name ## _private ), \ - .public = name ## _public, \ - .public_len = sizeof ( name ## _public ), \ + .private = { \ + .data = name ## _private, \ + .len = sizeof ( name ## _private ), \ + }, \ + .public = { \ + .data = name ## _public, \ + .len = sizeof ( name ## _public ), \ + }, \ .plaintext = name ## _plaintext, \ .plaintext_len = sizeof ( name ## _plaintext ), \ .algorithm = ALGORITHM, \ @@ -167,17 +167,14 @@ struct rsa_signature_test { * @v test RSA encryption and decryption test */ #define rsa_encrypt_decrypt_ok( test ) do { \ - pubkey_decrypt_ok ( &rsa_algorithm, (test)->private, \ - (test)->private_len, (test)->ciphertext, \ - (test)->ciphertext_len, (test)->plaintext, \ + pubkey_decrypt_ok ( &rsa_algorithm, &(test)->private, \ + (test)->ciphertext, (test)->ciphertext_len, \ + (test)->plaintext, (test)->plaintext_len );\ + pubkey_encrypt_ok ( &rsa_algorithm, &(test)->private, \ + &(test)->public, (test)->plaintext, \ (test)->plaintext_len ); \ - pubkey_encrypt_ok ( &rsa_algorithm, (test)->private, \ - (test)->private_len, (test)->public, \ - (test)->public_len, (test)->plaintext, \ - (test)->plaintext_len ); \ - pubkey_encrypt_ok ( &rsa_algorithm, (test)->public, \ - (test)->public_len, (test)->private, \ - (test)->private_len, (test)->plaintext, \ + pubkey_encrypt_ok ( &rsa_algorithm, &(test)->public, \ + &(test)->private, (test)->plaintext, \ (test)->plaintext_len ); \ } while ( 0 ) @@ -190,18 +187,15 @@ struct rsa_signature_test { #define rsa_signature_ok( test ) do { \ struct digest_algorithm *digest = (test)->algorithm->digest; \ uint8_t bad_signature[ (test)->signature_len ]; \ - pubkey_sign_ok ( &rsa_algorithm, (test)->private, \ - (test)->private_len, digest, \ + pubkey_sign_ok ( &rsa_algorithm, &(test)->private, digest, \ (test)->plaintext, (test)->plaintext_len, \ (test)->signature, (test)->signature_len ); \ - pubkey_verify_ok ( &rsa_algorithm, (test)->public, \ - (test)->public_len, digest, \ + pubkey_verify_ok ( &rsa_algorithm, &(test)->public, digest, \ (test)->plaintext, (test)->plaintext_len, \ (test)->signature, (test)->signature_len ); \ memset ( bad_signature, 0, sizeof ( bad_signature ) ); \ - pubkey_verify_fail_ok ( &rsa_algorithm, (test)->public, \ - (test)->public_len, digest, \ - (test)->plaintext, \ + pubkey_verify_fail_ok ( &rsa_algorithm, &(test)->public, \ + digest, (test)->plaintext, \ (test)->plaintext_len, bad_signature, \ sizeof ( bad_signature ) ); \ } while ( 0 ) -- cgit v1.2.3-55-g7522 From be2784649dcc5f57108eb2ab86c8d80f3f96b664 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 20 Aug 2024 22:44:15 +0100 Subject: [gve] Add missing error codes in EUNIQ() list of potential errors Signed-off-by: Michael Brown --- src/drivers/net/gve.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/gve.c b/src/drivers/net/gve.c index 7f86dd219..0193e769f 100644 --- a/src/drivers/net/gve.c +++ b/src/drivers/net/gve.c @@ -117,10 +117,11 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); EUNIQ ( EINFO_EIO, ( (status) & 0x1f ), \ EIO_ADMIN_UNSET, EIO_ADMIN_ABORTED, EIO_ADMIN_EXISTS, \ EIO_ADMIN_CANCELLED, EIO_ADMIN_DATALOSS, \ - EIO_ADMIN_DEADLINE, EIO_ADMIN_NOT_FOUND, \ - EIO_ADMIN_RANGE, EIO_ADMIN_PERM, EIO_ADMIN_UNAUTH, \ - EIO_ADMIN_RESOURCE, EIO_ADMIN_UNAVAIL, \ - EIO_ADMIN_NOTSUP, EIO_ADMIN_UNKNOWN ) + EIO_ADMIN_DEADLINE, EIO_ADMIN_PRECONDITION, \ + EIO_ADMIN_INTERNAL, EIO_ADMIN_INVAL, \ + EIO_ADMIN_NOT_FOUND, EIO_ADMIN_RANGE, EIO_ADMIN_PERM, \ + EIO_ADMIN_UNAUTH, EIO_ADMIN_RESOURCE, \ + EIO_ADMIN_UNAVAIL, EIO_ADMIN_NOTSUP, EIO_ADMIN_UNKNOWN ) /****************************************************************************** * -- cgit v1.2.3-55-g7522 From 46937a9df622d1e9fb5b1e926a04176b8855fdce Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 21 Aug 2024 16:25:10 +0100 Subject: [crypto] Remove the concept of a public-key algorithm reusable context Instances of cipher and digest algorithms tend to get called repeatedly to process substantial amounts of data. This is not true for public-key algorithms, which tend to get called only once or twice for a given key. Simplify the public-key algorithm API so that there is no reusable algorithm context. In particular, this allows callers to omit the error handling currently required to handle memory allocation (or key parsing) errors from pubkey_init(), and to omit the cleanup calls to pubkey_final(). This change does remove the ability for a caller to distinguish between a verification failure due to a memory allocation failure and a verification failure due to a bad signature. This difference is not material in practice: in both cases, for whatever reason, the caller was unable to verify the signature and so cannot proceed further, and the cause of the error will be visible to the user via the return status code. Signed-off-by: Michael Brown --- src/crypto/cms.c | 19 +-- src/crypto/crypto_null.c | 24 ++-- src/crypto/ocsp.c | 21 +--- src/crypto/rsa.c | 295 +++++++++++++++++++++++++++++----------------- src/crypto/x509.c | 13 +- src/drivers/net/iphone.c | 18 +-- src/include/ipxe/crypto.h | 96 ++++++--------- src/include/ipxe/rsa.h | 25 ---- src/include/ipxe/tls.h | 4 +- src/net/tls.c | 45 ++----- src/tests/pubkey_test.c | 142 +++++++--------------- 11 files changed, 304 insertions(+), 398 deletions(-) (limited to 'src/drivers') diff --git a/src/crypto/cms.c b/src/crypto/cms.c index 0b772f1cf..2e153d819 100644 --- a/src/crypto/cms.c +++ b/src/crypto/cms.c @@ -612,33 +612,22 @@ static int cms_verify_digest ( struct cms_message *cms, userptr_t data, size_t len ) { struct digest_algorithm *digest = part->digest; struct pubkey_algorithm *pubkey = part->pubkey; - struct x509_public_key *public_key = &cert->subject.public_key; + struct asn1_cursor *key = &cert->subject.public_key.raw; uint8_t digest_out[ digest->digestsize ]; - uint8_t ctx[ pubkey->ctxsize ]; int rc; /* Generate digest */ cms_digest ( cms, part, data, len, digest_out ); - /* Initialise public-key algorithm */ - if ( ( rc = pubkey_init ( pubkey, ctx, &public_key->raw ) ) != 0 ) { - DBGC ( cms, "CMS %p/%p could not initialise public key: %s\n", - cms, part, strerror ( rc ) ); - goto err_init; - } - /* Verify digest */ - if ( ( rc = pubkey_verify ( pubkey, ctx, digest, digest_out, + if ( ( rc = pubkey_verify ( pubkey, key, digest, digest_out, part->value, part->len ) ) != 0 ) { DBGC ( cms, "CMS %p/%p signature verification failed: %s\n", cms, part, strerror ( rc ) ); - goto err_verify; + return rc; } - err_verify: - pubkey_final ( pubkey, ctx ); - err_init: - return rc; + return 0; } /** diff --git a/src/crypto/crypto_null.c b/src/crypto/crypto_null.c index b4169382b..d5863f958 100644 --- a/src/crypto/crypto_null.c +++ b/src/crypto/crypto_null.c @@ -93,34 +93,31 @@ struct cipher_algorithm cipher_null = { .auth = cipher_null_auth, }; -int pubkey_null_init ( void *ctx __unused, - const struct asn1_cursor *key __unused ) { +size_t pubkey_null_max_len ( const struct asn1_cursor *key __unused ) { return 0; } -size_t pubkey_null_max_len ( void *ctx __unused ) { - return 0; -} - -int pubkey_null_encrypt ( void *ctx __unused, const void *plaintext __unused, +int pubkey_null_encrypt ( const struct asn1_cursor *key __unused, + const void *plaintext __unused, size_t plaintext_len __unused, void *ciphertext __unused ) { return 0; } -int pubkey_null_decrypt ( void *ctx __unused, const void *ciphertext __unused, +int pubkey_null_decrypt ( const struct asn1_cursor *key __unused, + const void *ciphertext __unused, size_t ciphertext_len __unused, void *plaintext __unused ) { return 0; } -int pubkey_null_sign ( void *ctx __unused, +int pubkey_null_sign ( const struct asn1_cursor *key __unused, struct digest_algorithm *digest __unused, const void *value __unused, void *signature __unused ) { return 0; } -int pubkey_null_verify ( void *ctx __unused, +int pubkey_null_verify ( const struct asn1_cursor *key __unused, struct digest_algorithm *digest __unused, const void *value __unused, const void *signature __unused , @@ -128,18 +125,11 @@ int pubkey_null_verify ( void *ctx __unused, return 0; } -void pubkey_null_final ( void *ctx __unused ) { - /* Do nothing */ -} - struct pubkey_algorithm pubkey_null = { .name = "null", - .ctxsize = 0, - .init = pubkey_null_init, .max_len = pubkey_null_max_len, .encrypt = pubkey_null_encrypt, .decrypt = pubkey_null_decrypt, .sign = pubkey_null_sign, .verify = pubkey_null_verify, - .final = pubkey_null_final, }; diff --git a/src/crypto/ocsp.c b/src/crypto/ocsp.c index f35593454..e65f7180a 100644 --- a/src/crypto/ocsp.c +++ b/src/crypto/ocsp.c @@ -844,10 +844,9 @@ static int ocsp_check_signature ( struct ocsp_check *ocsp, struct ocsp_response *response = &ocsp->response; struct digest_algorithm *digest = response->algorithm->digest; struct pubkey_algorithm *pubkey = response->algorithm->pubkey; - struct x509_public_key *public_key = &signer->subject.public_key; + struct asn1_cursor *key = &signer->subject.public_key.raw; uint8_t digest_ctx[ digest->ctxsize ]; uint8_t digest_out[ digest->digestsize ]; - uint8_t pubkey_ctx[ pubkey->ctxsize ]; int rc; /* Generate digest */ @@ -856,30 +855,18 @@ static int ocsp_check_signature ( struct ocsp_check *ocsp, response->tbs.len ); digest_final ( digest, digest_ctx, digest_out ); - /* Initialise public-key algorithm */ - if ( ( rc = pubkey_init ( pubkey, pubkey_ctx, - &public_key->raw ) ) != 0 ) { - DBGC ( ocsp, "OCSP %p \"%s\" could not initialise public key: " - "%s\n", ocsp, x509_name ( ocsp->cert ), strerror ( rc )); - goto err_init; - } - /* Verify digest */ - if ( ( rc = pubkey_verify ( pubkey, pubkey_ctx, digest, digest_out, + if ( ( rc = pubkey_verify ( pubkey, key, digest, digest_out, response->signature.data, response->signature.len ) ) != 0 ) { DBGC ( ocsp, "OCSP %p \"%s\" signature verification failed: " "%s\n", ocsp, x509_name ( ocsp->cert ), strerror ( rc )); - goto err_verify; + return rc; } DBGC2 ( ocsp, "OCSP %p \"%s\" signature is correct\n", ocsp, x509_name ( ocsp->cert ) ); - - err_verify: - pubkey_final ( pubkey, pubkey_ctx ); - err_init: - return rc; + return 0; } /** diff --git a/src/crypto/rsa.c b/src/crypto/rsa.c index 2d288a953..19472c121 100644 --- a/src/crypto/rsa.c +++ b/src/crypto/rsa.c @@ -47,6 +47,28 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define EINFO_EACCES_VERIFY \ __einfo_uniqify ( EINFO_EACCES, 0x01, "RSA signature incorrect" ) +/** An RSA context */ +struct rsa_context { + /** Allocated memory */ + void *dynamic; + /** Modulus */ + bigint_element_t *modulus0; + /** Modulus size */ + unsigned int size; + /** Modulus length */ + size_t max_len; + /** Exponent */ + bigint_element_t *exponent0; + /** Exponent size */ + unsigned int exponent_size; + /** Input buffer */ + bigint_element_t *input0; + /** Output buffer */ + bigint_element_t *output0; + /** Temporary working space for modular exponentiation */ + void *tmp; +}; + /** * Identify RSA prefix * @@ -69,10 +91,9 @@ rsa_find_prefix ( struct digest_algorithm *digest ) { * * @v context RSA context */ -static void rsa_free ( struct rsa_context *context ) { +static inline void rsa_free ( struct rsa_context *context ) { free ( context->dynamic ); - context->dynamic = NULL; } /** @@ -98,9 +119,6 @@ static int rsa_alloc ( struct rsa_context *context, size_t modulus_len, uint8_t tmp[tmp_len]; } __attribute__ (( packed )) *dynamic; - /* Free any existing dynamic storage */ - rsa_free ( context ); - /* Allocate dynamic storage */ dynamic = malloc ( sizeof ( *dynamic ) ); if ( ! dynamic ) @@ -231,12 +249,12 @@ static int rsa_parse_mod_exp ( struct asn1_cursor *modulus, /** * Initialise RSA cipher * - * @v ctx RSA context + * @v context RSA context * @v key Key * @ret rc Return status code */ -static int rsa_init ( void *ctx, const struct asn1_cursor *key ) { - struct rsa_context *context = ctx; +static int rsa_init ( struct rsa_context *context, + const struct asn1_cursor *key ) { struct asn1_cursor modulus; struct asn1_cursor exponent; int rc; @@ -277,13 +295,22 @@ static int rsa_init ( void *ctx, const struct asn1_cursor *key ) { /** * Calculate RSA maximum output length * - * @v ctx RSA context + * @v key Key * @ret max_len Maximum output length */ -static size_t rsa_max_len ( void *ctx ) { - struct rsa_context *context = ctx; +static size_t rsa_max_len ( const struct asn1_cursor *key ) { + struct asn1_cursor modulus; + struct asn1_cursor exponent; + int rc; - return context->max_len; + /* Parse moduli and exponents */ + if ( ( rc = rsa_parse_mod_exp ( &modulus, &exponent, key ) ) != 0 ) { + /* Return a zero maximum length on error */ + return 0; + } + + /* Output length can never exceed modulus length */ + return modulus.len; } /** @@ -314,111 +341,147 @@ static void rsa_cipher ( struct rsa_context *context, /** * Encrypt using RSA * - * @v ctx RSA context + * @v key Key * @v plaintext Plaintext * @v plaintext_len Length of plaintext * @v ciphertext Ciphertext * @ret ciphertext_len Length of ciphertext, or negative error */ -static int rsa_encrypt ( void *ctx, const void *plaintext, +static int rsa_encrypt ( const struct asn1_cursor *key, const void *plaintext, size_t plaintext_len, void *ciphertext ) { - struct rsa_context *context = ctx; + struct rsa_context context; void *temp; uint8_t *encoded; - size_t max_len = ( context->max_len - 11 ); - size_t random_nz_len = ( max_len - plaintext_len + 8 ); + size_t max_len; + size_t random_nz_len; int rc; + DBGC ( &context, "RSA %p encrypting:\n", &context ); + DBGC_HDA ( &context, 0, plaintext, plaintext_len ); + + /* Initialise context */ + if ( ( rc = rsa_init ( &context, key ) ) != 0 ) + goto err_init; + + /* Calculate lengths */ + max_len = ( context.max_len - 11 ); + random_nz_len = ( max_len - plaintext_len + 8 ); + /* Sanity check */ if ( plaintext_len > max_len ) { - DBGC ( context, "RSA %p plaintext too long (%zd bytes, max " - "%zd)\n", context, plaintext_len, max_len ); - return -ERANGE; + DBGC ( &context, "RSA %p plaintext too long (%zd bytes, max " + "%zd)\n", &context, plaintext_len, max_len ); + rc = -ERANGE; + goto err_sanity; } - DBGC ( context, "RSA %p encrypting:\n", context ); - DBGC_HDA ( context, 0, plaintext, plaintext_len ); /* Construct encoded message (using the big integer output * buffer as temporary storage) */ - temp = context->output0; + temp = context.output0; encoded = temp; encoded[0] = 0x00; encoded[1] = 0x02; if ( ( rc = get_random_nz ( &encoded[2], random_nz_len ) ) != 0 ) { - DBGC ( context, "RSA %p could not generate random data: %s\n", - context, strerror ( rc ) ); - return rc; + DBGC ( &context, "RSA %p could not generate random data: %s\n", + &context, strerror ( rc ) ); + goto err_random; } encoded[ 2 + random_nz_len ] = 0x00; - memcpy ( &encoded[ context->max_len - plaintext_len ], + memcpy ( &encoded[ context.max_len - plaintext_len ], plaintext, plaintext_len ); /* Encipher the encoded message */ - rsa_cipher ( context, encoded, ciphertext ); - DBGC ( context, "RSA %p encrypted:\n", context ); - DBGC_HDA ( context, 0, ciphertext, context->max_len ); + rsa_cipher ( &context, encoded, ciphertext ); + DBGC ( &context, "RSA %p encrypted:\n", &context ); + DBGC_HDA ( &context, 0, ciphertext, context.max_len ); + + /* Free context */ + rsa_free ( &context ); - return context->max_len; + return context.max_len; + + err_random: + err_sanity: + rsa_free ( &context ); + err_init: + return rc; } /** * Decrypt using RSA * - * @v ctx RSA context + * @v key Key * @v ciphertext Ciphertext * @v ciphertext_len Ciphertext length * @v plaintext Plaintext * @ret plaintext_len Plaintext length, or negative error */ -static int rsa_decrypt ( void *ctx, const void *ciphertext, +static int rsa_decrypt ( const struct asn1_cursor *key, const void *ciphertext, size_t ciphertext_len, void *plaintext ) { - struct rsa_context *context = ctx; + struct rsa_context context; void *temp; uint8_t *encoded; uint8_t *end; uint8_t *zero; uint8_t *start; size_t plaintext_len; + int rc; + + DBGC ( &context, "RSA %p decrypting:\n", &context ); + DBGC_HDA ( &context, 0, ciphertext, ciphertext_len ); + + /* Initialise context */ + if ( ( rc = rsa_init ( &context, key ) ) != 0 ) + goto err_init; /* Sanity check */ - if ( ciphertext_len != context->max_len ) { - DBGC ( context, "RSA %p ciphertext incorrect length (%zd " + if ( ciphertext_len != context.max_len ) { + DBGC ( &context, "RSA %p ciphertext incorrect length (%zd " "bytes, should be %zd)\n", - context, ciphertext_len, context->max_len ); - return -ERANGE; + &context, ciphertext_len, context.max_len ); + rc = -ERANGE; + goto err_sanity; } - DBGC ( context, "RSA %p decrypting:\n", context ); - DBGC_HDA ( context, 0, ciphertext, ciphertext_len ); /* Decipher the message (using the big integer input buffer as * temporary storage) */ - temp = context->input0; + temp = context.input0; encoded = temp; - rsa_cipher ( context, ciphertext, encoded ); + rsa_cipher ( &context, ciphertext, encoded ); /* Parse the message */ - end = ( encoded + context->max_len ); - if ( ( encoded[0] != 0x00 ) || ( encoded[1] != 0x02 ) ) - goto invalid; + end = ( encoded + context.max_len ); + if ( ( encoded[0] != 0x00 ) || ( encoded[1] != 0x02 ) ) { + rc = -EINVAL; + goto err_invalid; + } zero = memchr ( &encoded[2], 0, ( end - &encoded[2] ) ); - if ( ! zero ) - goto invalid; + if ( ! zero ) { + rc = -EINVAL; + goto err_invalid; + } start = ( zero + 1 ); plaintext_len = ( end - start ); /* Copy out message */ memcpy ( plaintext, start, plaintext_len ); - DBGC ( context, "RSA %p decrypted:\n", context ); - DBGC_HDA ( context, 0, plaintext, plaintext_len ); + DBGC ( &context, "RSA %p decrypted:\n", &context ); + DBGC_HDA ( &context, 0, plaintext, plaintext_len ); + + /* Free context */ + rsa_free ( &context ); return plaintext_len; - invalid: - DBGC ( context, "RSA %p invalid decrypted message:\n", context ); - DBGC_HDA ( context, 0, encoded, context->max_len ); - return -EINVAL; + err_invalid: + DBGC ( &context, "RSA %p invalid decrypted message:\n", &context ); + DBGC_HDA ( &context, 0, encoded, context.max_len ); + err_sanity: + rsa_free ( &context ); + err_init: + return rc; } /** @@ -452,9 +515,9 @@ static int rsa_encode_digest ( struct rsa_context *context, /* Sanity check */ max_len = ( context->max_len - 11 ); if ( digestinfo_len > max_len ) { - DBGC ( context, "RSA %p %s digestInfo too long (%zd bytes, max" - "%zd)\n", - context, digest->name, digestinfo_len, max_len ); + DBGC ( context, "RSA %p %s digestInfo too long (%zd bytes, " + "max %zd)\n", context, digest->name, digestinfo_len, + max_len ); return -ERANGE; } DBGC ( context, "RSA %p encoding %s digest:\n", @@ -482,104 +545,125 @@ static int rsa_encode_digest ( struct rsa_context *context, /** * Sign digest value using RSA * - * @v ctx RSA context + * @v key Key * @v digest Digest algorithm * @v value Digest value * @v signature Signature * @ret signature_len Signature length, or negative error */ -static int rsa_sign ( void *ctx, struct digest_algorithm *digest, - const void *value, void *signature ) { - struct rsa_context *context = ctx; +static int rsa_sign ( const struct asn1_cursor *key, + struct digest_algorithm *digest, const void *value, + void *signature ) { + struct rsa_context context; void *temp; int rc; - DBGC ( context, "RSA %p signing %s digest:\n", context, digest->name ); - DBGC_HDA ( context, 0, value, digest->digestsize ); + DBGC ( &context, "RSA %p signing %s digest:\n", + &context, digest->name ); + DBGC_HDA ( &context, 0, value, digest->digestsize ); + + /* Initialise context */ + if ( ( rc = rsa_init ( &context, key ) ) != 0 ) + goto err_init; /* Encode digest (using the big integer output buffer as * temporary storage) */ - temp = context->output0; - if ( ( rc = rsa_encode_digest ( context, digest, value, temp ) ) != 0 ) - return rc; + temp = context.output0; + if ( ( rc = rsa_encode_digest ( &context, digest, value, temp ) ) != 0 ) + goto err_encode; /* Encipher the encoded digest */ - rsa_cipher ( context, temp, signature ); - DBGC ( context, "RSA %p signed %s digest:\n", context, digest->name ); - DBGC_HDA ( context, 0, signature, context->max_len ); + rsa_cipher ( &context, temp, signature ); + DBGC ( &context, "RSA %p signed %s digest:\n", &context, digest->name ); + DBGC_HDA ( &context, 0, signature, context.max_len ); + + /* Free context */ + rsa_free ( &context ); - return context->max_len; + return context.max_len; + + err_encode: + rsa_free ( &context ); + err_init: + return rc; } /** * Verify signed digest value using RSA * - * @v ctx RSA context + * @v key Key * @v digest Digest algorithm * @v value Digest value * @v signature Signature * @v signature_len Signature length * @ret rc Return status code */ -static int rsa_verify ( void *ctx, struct digest_algorithm *digest, - const void *value, const void *signature, - size_t signature_len ) { - struct rsa_context *context = ctx; +static int rsa_verify ( const struct asn1_cursor *key, + struct digest_algorithm *digest, const void *value, + const void *signature, size_t signature_len ) { + struct rsa_context context; void *temp; void *expected; void *actual; int rc; + DBGC ( &context, "RSA %p verifying %s digest:\n", + &context, digest->name ); + DBGC_HDA ( &context, 0, value, digest->digestsize ); + DBGC_HDA ( &context, 0, signature, signature_len ); + + /* Initialise context */ + if ( ( rc = rsa_init ( &context, key ) ) != 0 ) + goto err_init; + /* Sanity check */ - if ( signature_len != context->max_len ) { - DBGC ( context, "RSA %p signature incorrect length (%zd " + if ( signature_len != context.max_len ) { + DBGC ( &context, "RSA %p signature incorrect length (%zd " "bytes, should be %zd)\n", - context, signature_len, context->max_len ); - return -ERANGE; + &context, signature_len, context.max_len ); + rc = -ERANGE; + goto err_sanity; } - DBGC ( context, "RSA %p verifying %s digest:\n", - context, digest->name ); - DBGC_HDA ( context, 0, value, digest->digestsize ); - DBGC_HDA ( context, 0, signature, signature_len ); /* Decipher the signature (using the big integer input buffer * as temporary storage) */ - temp = context->input0; + temp = context.input0; expected = temp; - rsa_cipher ( context, signature, expected ); - DBGC ( context, "RSA %p deciphered signature:\n", context ); - DBGC_HDA ( context, 0, expected, context->max_len ); + rsa_cipher ( &context, signature, expected ); + DBGC ( &context, "RSA %p deciphered signature:\n", &context ); + DBGC_HDA ( &context, 0, expected, context.max_len ); /* Encode digest (using the big integer output buffer as * temporary storage) */ - temp = context->output0; + temp = context.output0; actual = temp; - if ( ( rc = rsa_encode_digest ( context, digest, value, actual ) ) !=0 ) - return rc; + if ( ( rc = rsa_encode_digest ( &context, digest, value, + actual ) ) != 0 ) + goto err_encode; /* Verify the signature */ - if ( memcmp ( actual, expected, context->max_len ) != 0 ) { - DBGC ( context, "RSA %p signature verification failed\n", - context ); - return -EACCES_VERIFY; + if ( memcmp ( actual, expected, context.max_len ) != 0 ) { + DBGC ( &context, "RSA %p signature verification failed\n", + &context ); + rc = -EACCES_VERIFY; + goto err_verify; } - DBGC ( context, "RSA %p signature verified successfully\n", context ); - return 0; -} + /* Free context */ + rsa_free ( &context ); -/** - * Finalise RSA cipher - * - * @v ctx RSA context - */ -static void rsa_final ( void *ctx ) { - struct rsa_context *context = ctx; + DBGC ( &context, "RSA %p signature verified successfully\n", &context ); + return 0; - rsa_free ( context ); + err_verify: + err_encode: + err_sanity: + rsa_free ( &context ); + err_init: + return rc; } /** @@ -615,14 +699,11 @@ static int rsa_match ( const struct asn1_cursor *private_key, /** RSA public-key algorithm */ struct pubkey_algorithm rsa_algorithm = { .name = "rsa", - .ctxsize = RSA_CTX_SIZE, - .init = rsa_init, .max_len = rsa_max_len, .encrypt = rsa_encrypt, .decrypt = rsa_decrypt, .sign = rsa_sign, .verify = rsa_verify, - .final = rsa_final, .match = rsa_match, }; diff --git a/src/crypto/x509.c b/src/crypto/x509.c index c0762740e..4101c8094 100644 --- a/src/crypto/x509.c +++ b/src/crypto/x509.c @@ -1125,7 +1125,6 @@ static int x509_check_signature ( struct x509_certificate *cert, struct pubkey_algorithm *pubkey = algorithm->pubkey; uint8_t digest_ctx[ digest->ctxsize ]; uint8_t digest_out[ digest->digestsize ]; - uint8_t pubkey_ctx[ pubkey->ctxsize ]; int rc; /* Sanity check */ @@ -1149,14 +1148,8 @@ static int x509_check_signature ( struct x509_certificate *cert, } /* Verify signature using signer's public key */ - if ( ( rc = pubkey_init ( pubkey, pubkey_ctx, - &public_key->raw ) ) != 0 ) { - DBGC ( cert, "X509 %p \"%s\" cannot initialise public key: " - "%s\n", cert, x509_name ( cert ), strerror ( rc ) ); - goto err_pubkey_init; - } - if ( ( rc = pubkey_verify ( pubkey, pubkey_ctx, digest, digest_out, - signature->value.data, + if ( ( rc = pubkey_verify ( pubkey, &public_key->raw, digest, + digest_out, signature->value.data, signature->value.len ) ) != 0 ) { DBGC ( cert, "X509 %p \"%s\" signature verification failed: " "%s\n", cert, x509_name ( cert ), strerror ( rc ) ); @@ -1167,8 +1160,6 @@ static int x509_check_signature ( struct x509_certificate *cert, rc = 0; err_pubkey_verify: - pubkey_final ( pubkey, pubkey_ctx ); - err_pubkey_init: err_mismatch: return rc; } diff --git a/src/drivers/net/iphone.c b/src/drivers/net/iphone.c index 96eb0952b..08459a6e2 100644 --- a/src/drivers/net/iphone.c +++ b/src/drivers/net/iphone.c @@ -362,17 +362,9 @@ static int icert_cert ( struct icert *icert, struct asn1_cursor *subject, struct asn1_builder raw = { NULL, 0 }; uint8_t digest_ctx[SHA256_CTX_SIZE]; uint8_t digest_out[SHA256_DIGEST_SIZE]; - uint8_t pubkey_ctx[RSA_CTX_SIZE]; int len; int rc; - /* Initialise "private" key */ - if ( ( rc = pubkey_init ( pubkey, pubkey_ctx, private ) ) != 0 ) { - DBGC ( icert, "ICERT %p could not initialise private key: " - "%s\n", icert, strerror ( rc ) ); - goto err_pubkey_init; - } - /* Construct subjectPublicKeyInfo */ if ( ( rc = ( asn1_prepend_raw ( &spki, public->data, public->len ), asn1_prepend_raw ( &spki, icert_nul, @@ -406,14 +398,14 @@ static int icert_cert ( struct icert *icert, struct asn1_cursor *subject, digest_update ( digest, digest_ctx, tbs.data, tbs.len ); digest_final ( digest, digest_ctx, digest_out ); - /* Construct signature */ - if ( ( rc = asn1_grow ( &raw, pubkey_max_len ( pubkey, - pubkey_ctx ) ) ) != 0 ) { + /* Construct signature using "private" key */ + if ( ( rc = asn1_grow ( &raw, + pubkey_max_len ( pubkey, private ) ) ) != 0 ) { DBGC ( icert, "ICERT %p could not build signature: %s\n", icert, strerror ( rc ) ); goto err_grow; } - if ( ( len = pubkey_sign ( pubkey, pubkey_ctx, digest, digest_out, + if ( ( len = pubkey_sign ( pubkey, private, digest, digest_out, raw.data ) ) < 0 ) { rc = len; DBGC ( icert, "ICERT %p could not sign: %s\n", @@ -452,8 +444,6 @@ static int icert_cert ( struct icert *icert, struct asn1_cursor *subject, err_tbs: free ( spki.data ); err_spki: - pubkey_final ( pubkey, pubkey_ctx ); - err_pubkey_init: return rc; } diff --git a/src/include/ipxe/crypto.h b/src/include/ipxe/crypto.h index 8b6eb94f6..dcc73f3ef 100644 --- a/src/include/ipxe/crypto.h +++ b/src/include/ipxe/crypto.h @@ -121,68 +121,55 @@ struct cipher_algorithm { struct pubkey_algorithm { /** Algorithm name */ const char *name; - /** Context size */ - size_t ctxsize; - /** Initialise algorithm - * - * @v ctx Context - * @v key Key - * @ret rc Return status code - */ - int ( * init ) ( void *ctx, const struct asn1_cursor *key ); /** Calculate maximum output length * - * @v ctx Context + * @v key Key * @ret max_len Maximum output length */ - size_t ( * max_len ) ( void *ctx ); + size_t ( * max_len ) ( const struct asn1_cursor *key ); /** Encrypt * - * @v ctx Context + * @v key Key * @v plaintext Plaintext * @v plaintext_len Length of plaintext * @v ciphertext Ciphertext * @ret ciphertext_len Length of ciphertext, or negative error */ - int ( * encrypt ) ( void *ctx, const void *data, size_t len, - void *out ); + int ( * encrypt ) ( const struct asn1_cursor *key, const void *data, + size_t len, void *out ); /** Decrypt * - * @v ctx Context + * @v key Key * @v ciphertext Ciphertext * @v ciphertext_len Ciphertext length * @v plaintext Plaintext * @ret plaintext_len Plaintext length, or negative error */ - int ( * decrypt ) ( void *ctx, const void *data, size_t len, - void *out ); + int ( * decrypt ) ( const struct asn1_cursor *key, const void *data, + size_t len, void *out ); /** Sign digest value * - * @v ctx Context + * @v key Key * @v digest Digest algorithm * @v value Digest value * @v signature Signature * @ret signature_len Signature length, or negative error */ - int ( * sign ) ( void *ctx, struct digest_algorithm *digest, - const void *value, void *signature ); + int ( * sign ) ( const struct asn1_cursor *key, + struct digest_algorithm *digest, const void *value, + void *signature ); /** Verify signed digest value * - * @v ctx Context + * @v key Key * @v digest Digest algorithm * @v value Digest value * @v signature Signature * @v signature_len Signature length * @ret rc Return status code */ - int ( * verify ) ( void *ctx, struct digest_algorithm *digest, - const void *value, const void *signature, - size_t signature_len ); - /** Finalise algorithm - * - * @v ctx Context - */ - void ( * final ) ( void *ctx ); + int ( * verify ) ( const struct asn1_cursor *key, + struct digest_algorithm *digest, const void *value, + const void *signature, size_t signature_len ); /** Check that public key matches private key * * @v private_key Private key @@ -278,46 +265,36 @@ is_auth_cipher ( struct cipher_algorithm *cipher ) { return cipher->authsize; } -static inline __attribute__ (( always_inline )) int -pubkey_init ( struct pubkey_algorithm *pubkey, void *ctx, - const struct asn1_cursor *key ) { - return pubkey->init ( ctx, key ); -} - static inline __attribute__ (( always_inline )) size_t -pubkey_max_len ( struct pubkey_algorithm *pubkey, void *ctx ) { - return pubkey->max_len ( ctx ); +pubkey_max_len ( struct pubkey_algorithm *pubkey, + const struct asn1_cursor *key ) { + return pubkey->max_len ( key ); } static inline __attribute__ (( always_inline )) int -pubkey_encrypt ( struct pubkey_algorithm *pubkey, void *ctx, +pubkey_encrypt ( struct pubkey_algorithm *pubkey, const struct asn1_cursor *key, const void *data, size_t len, void *out ) { - return pubkey->encrypt ( ctx, data, len, out ); + return pubkey->encrypt ( key, data, len, out ); } static inline __attribute__ (( always_inline )) int -pubkey_decrypt ( struct pubkey_algorithm *pubkey, void *ctx, +pubkey_decrypt ( struct pubkey_algorithm *pubkey, const struct asn1_cursor *key, const void *data, size_t len, void *out ) { - return pubkey->decrypt ( ctx, data, len, out ); + return pubkey->decrypt ( key, data, len, out ); } static inline __attribute__ (( always_inline )) int -pubkey_sign ( struct pubkey_algorithm *pubkey, void *ctx, +pubkey_sign ( struct pubkey_algorithm *pubkey, const struct asn1_cursor *key, struct digest_algorithm *digest, const void *value, void *signature ) { - return pubkey->sign ( ctx, digest, value, signature ); + return pubkey->sign ( key, digest, value, signature ); } static inline __attribute__ (( always_inline )) int -pubkey_verify ( struct pubkey_algorithm *pubkey, void *ctx, +pubkey_verify ( struct pubkey_algorithm *pubkey, const struct asn1_cursor *key, struct digest_algorithm *digest, const void *value, const void *signature, size_t signature_len ) { - return pubkey->verify ( ctx, digest, value, signature, signature_len ); -} - -static inline __attribute__ (( always_inline )) void -pubkey_final ( struct pubkey_algorithm *pubkey, void *ctx ) { - pubkey->final ( ctx ); + return pubkey->verify ( key, digest, value, signature, signature_len ); } static inline __attribute__ (( always_inline )) int @@ -345,15 +322,18 @@ extern void cipher_null_decrypt ( void *ctx, const void *src, void *dst, size_t len ); extern void cipher_null_auth ( void *ctx, void *auth ); -extern int pubkey_null_init ( void *ctx, const struct asn1_cursor *key ); -extern size_t pubkey_null_max_len ( void *ctx ); -extern int pubkey_null_encrypt ( void *ctx, const void *plaintext, - size_t plaintext_len, void *ciphertext ); -extern int pubkey_null_decrypt ( void *ctx, const void *ciphertext, - size_t ciphertext_len, void *plaintext ); -extern int pubkey_null_sign ( void *ctx, struct digest_algorithm *digest, +extern size_t pubkey_null_max_len ( const struct asn1_cursor *key ); +extern int pubkey_null_encrypt ( const struct asn1_cursor *key, + const void *plaintext, size_t plaintext_len, + void *ciphertext ); +extern int pubkey_null_decrypt ( const struct asn1_cursor *key, + const void *ciphertext, size_t ciphertext_len, + void *plaintext ); +extern int pubkey_null_sign ( const struct asn1_cursor *key, + struct digest_algorithm *digest, const void *value, void *signature ); -extern int pubkey_null_verify ( void *ctx, struct digest_algorithm *digest, +extern int pubkey_null_verify ( const struct asn1_cursor *key, + struct digest_algorithm *digest, const void *value, const void *signature , size_t signature_len ); diff --git a/src/include/ipxe/rsa.h b/src/include/ipxe/rsa.h index a1b5e0c03..e36a75edf 100644 --- a/src/include/ipxe/rsa.h +++ b/src/include/ipxe/rsa.h @@ -55,31 +55,6 @@ struct rsa_digestinfo_prefix { /** Declare an RSA digestInfo prefix */ #define __rsa_digestinfo_prefix __table_entry ( RSA_DIGESTINFO_PREFIXES, 01 ) -/** An RSA context */ -struct rsa_context { - /** Allocated memory */ - void *dynamic; - /** Modulus */ - bigint_element_t *modulus0; - /** Modulus size */ - unsigned int size; - /** Modulus length */ - size_t max_len; - /** Exponent */ - bigint_element_t *exponent0; - /** Exponent size */ - unsigned int exponent_size; - /** Input buffer */ - bigint_element_t *input0; - /** Output buffer */ - bigint_element_t *output0; - /** Temporary working space for modular exponentiation */ - void *tmp; -}; - -/** RSA context size */ -#define RSA_CTX_SIZE sizeof ( struct rsa_context ) - extern struct pubkey_algorithm rsa_algorithm; #endif /* _IPXE_RSA_H */ diff --git a/src/include/ipxe/tls.h b/src/include/ipxe/tls.h index 9494eaa05..08d58689e 100644 --- a/src/include/ipxe/tls.h +++ b/src/include/ipxe/tls.h @@ -240,8 +240,6 @@ struct tls_cipherspec { struct tls_cipher_suite *suite; /** Dynamically-allocated storage */ void *dynamic; - /** Public key encryption context */ - void *pubkey_ctx; /** Bulk encryption cipher context */ void *cipher_ctx; /** MAC secret */ @@ -402,6 +400,8 @@ struct tls_server { struct x509_root *root; /** Certificate chain */ struct x509_chain *chain; + /** Public key (within server certificate) */ + struct asn1_cursor key; /** Certificate validator */ struct interface validator; /** Certificate validation pending operation */ diff --git a/src/net/tls.c b/src/net/tls.c index ec503e43d..ded100d0e 100644 --- a/src/net/tls.c +++ b/src/net/tls.c @@ -856,10 +856,6 @@ tls_find_cipher_suite ( unsigned int cipher_suite ) { static void tls_clear_cipher ( struct tls_connection *tls __unused, struct tls_cipherspec *cipherspec ) { - if ( cipherspec->suite ) { - pubkey_final ( cipherspec->suite->pubkey, - cipherspec->pubkey_ctx ); - } free ( cipherspec->dynamic ); memset ( cipherspec, 0, sizeof ( *cipherspec ) ); cipherspec->suite = &tls_cipher_suite_null; @@ -876,7 +872,6 @@ static void tls_clear_cipher ( struct tls_connection *tls __unused, static int tls_set_cipher ( struct tls_connection *tls, struct tls_cipherspec *cipherspec, struct tls_cipher_suite *suite ) { - struct pubkey_algorithm *pubkey = suite->pubkey; struct cipher_algorithm *cipher = suite->cipher; size_t total; void *dynamic; @@ -885,8 +880,7 @@ static int tls_set_cipher ( struct tls_connection *tls, tls_clear_cipher ( tls, cipherspec ); /* Allocate dynamic storage */ - total = ( pubkey->ctxsize + cipher->ctxsize + suite->mac_len + - suite->fixed_iv_len ); + total = ( cipher->ctxsize + suite->mac_len + suite->fixed_iv_len ); dynamic = zalloc ( total ); if ( ! dynamic ) { DBGC ( tls, "TLS %p could not allocate %zd bytes for crypto " @@ -896,7 +890,6 @@ static int tls_set_cipher ( struct tls_connection *tls, /* Assign storage */ cipherspec->dynamic = dynamic; - cipherspec->pubkey_ctx = dynamic; dynamic += pubkey->ctxsize; cipherspec->cipher_ctx = dynamic; dynamic += cipher->ctxsize; cipherspec->mac_secret = dynamic; dynamic += suite->mac_len; cipherspec->fixed_iv = dynamic; dynamic += suite->fixed_iv_len; @@ -1392,7 +1385,7 @@ static int tls_send_certificate ( struct tls_connection *tls ) { static int tls_send_client_key_exchange_pubkey ( struct tls_connection *tls ) { struct tls_cipherspec *cipherspec = &tls->tx.cipherspec.pending; struct pubkey_algorithm *pubkey = cipherspec->suite->pubkey; - size_t max_len = pubkey_max_len ( pubkey, cipherspec->pubkey_ctx ); + size_t max_len = pubkey_max_len ( pubkey, &tls->server.key ); struct { uint16_t version; uint8_t random[46]; @@ -1419,8 +1412,8 @@ static int tls_send_client_key_exchange_pubkey ( struct tls_connection *tls ) { /* Encrypt pre-master secret using server's public key */ memset ( &key_xchg, 0, sizeof ( key_xchg ) ); - len = pubkey_encrypt ( pubkey, cipherspec->pubkey_ctx, - &pre_master_secret, sizeof ( pre_master_secret ), + len = pubkey_encrypt ( pubkey, &tls->server.key, &pre_master_secret, + sizeof ( pre_master_secret ), key_xchg.encrypted_pre_master_secret ); if ( len < 0 ) { rc = len; @@ -1523,7 +1516,7 @@ static int tls_verify_dh_params ( struct tls_connection *tls, digest_final ( digest, ctx, hash ); /* Verify signature */ - if ( ( rc = pubkey_verify ( pubkey, cipherspec->pubkey_ctx, + if ( ( rc = pubkey_verify ( pubkey, &tls->server.key, digest, hash, signature, signature_len ) ) != 0 ) { DBGC ( tls, "TLS %p ServerKeyExchange failed " @@ -1820,20 +1813,12 @@ static int tls_send_certificate_verify ( struct tls_connection *tls ) { struct pubkey_algorithm *pubkey = cert->signature_algorithm->pubkey; struct asn1_cursor *key = privkey_cursor ( tls->client.key ); uint8_t digest_out[ digest->digestsize ]; - uint8_t ctx[ pubkey->ctxsize ]; struct tls_signature_hash_algorithm *sig_hash = NULL; int rc; /* Generate digest to be signed */ tls_verify_handshake ( tls, digest_out ); - /* Initialise public-key algorithm */ - if ( ( rc = pubkey_init ( pubkey, ctx, key ) ) != 0 ) { - DBGC ( tls, "TLS %p could not initialise %s client private " - "key: %s\n", tls, pubkey->name, strerror ( rc ) ); - goto err_pubkey_init; - } - /* TLSv1.2 and later use explicit algorithm identifiers */ if ( tls_version ( tls, TLS_VERSION_TLS_1_2 ) ) { sig_hash = tls_signature_hash_algorithm ( pubkey, digest ); @@ -1848,7 +1833,7 @@ static int tls_send_certificate_verify ( struct tls_connection *tls ) { /* Generate and transmit record */ { - size_t max_len = pubkey_max_len ( pubkey, ctx ); + size_t max_len = pubkey_max_len ( pubkey, key ); int use_sig_hash = ( ( sig_hash == NULL ) ? 0 : 1 ); struct { uint32_t type_length; @@ -1860,7 +1845,7 @@ static int tls_send_certificate_verify ( struct tls_connection *tls ) { int len; /* Sign digest */ - len = pubkey_sign ( pubkey, ctx, digest, digest_out, + len = pubkey_sign ( pubkey, key, digest, digest_out, certificate_verify.signature ); if ( len < 0 ) { rc = len; @@ -1893,8 +1878,6 @@ static int tls_send_certificate_verify ( struct tls_connection *tls ) { err_pubkey_sign: err_sig_hash: - pubkey_final ( pubkey, ctx ); - err_pubkey_init: return rc; } @@ -2312,6 +2295,7 @@ static int tls_parse_chain ( struct tls_connection *tls, int rc; /* Free any existing certificate chain */ + memset ( &tls->server.key, 0, sizeof ( tls->server.key ) ); x509_chain_put ( tls->server.chain ); tls->server.chain = NULL; @@ -2371,6 +2355,7 @@ static int tls_parse_chain ( struct tls_connection *tls, err_parse: err_overlength: err_underlength: + memset ( &tls->server.key, 0, sizeof ( tls->server.key ) ); x509_chain_put ( tls->server.chain ); tls->server.chain = NULL; err_alloc_chain: @@ -3555,8 +3540,6 @@ static struct interface_descriptor tls_cipherstream_desc = */ static void tls_validator_done ( struct tls_connection *tls, int rc ) { struct tls_session *session = tls->session; - struct tls_cipherspec *cipherspec = &tls->tx.cipherspec.pending; - struct pubkey_algorithm *pubkey = cipherspec->suite->pubkey; struct x509_certificate *cert; /* Mark validation as complete */ @@ -3584,13 +3567,9 @@ static void tls_validator_done ( struct tls_connection *tls, int rc ) { goto err; } - /* Initialise public key algorithm */ - if ( ( rc = pubkey_init ( pubkey, cipherspec->pubkey_ctx, - &cert->subject.public_key.raw ) ) != 0 ) { - DBGC ( tls, "TLS %p cannot initialise public key: %s\n", - tls, strerror ( rc ) ); - goto err; - } + /* Extract the now trusted server public key */ + memcpy ( &tls->server.key, &cert->subject.public_key.raw, + sizeof ( tls->server.key ) ); /* Schedule Client Key Exchange, Change Cipher, and Finished */ tls->tx.pending |= ( TLS_TX_CLIENT_KEY_EXCHANGE | diff --git a/src/tests/pubkey_test.c b/src/tests/pubkey_test.c index 93962516a..ff318bfb7 100644 --- a/src/tests/pubkey_test.c +++ b/src/tests/pubkey_test.c @@ -50,77 +50,41 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); void pubkey_okx ( struct pubkey_test *test, const char *file, unsigned int line ) { struct pubkey_algorithm *pubkey = test->pubkey; - uint8_t private_ctx[pubkey->ctxsize]; - uint8_t public_ctx[pubkey->ctxsize]; - size_t max_len; - - /* Initialize contexts */ - okx ( pubkey_init ( pubkey, private_ctx, &test->private ) == 0, - file, line ); - okx ( pubkey_init ( pubkey, public_ctx, &test->public ) == 0, - file, line ); - max_len = pubkey_max_len ( pubkey, private_ctx ); + size_t max_len = pubkey_max_len ( pubkey, &test->private ); + uint8_t encrypted[max_len]; + uint8_t decrypted[max_len]; + int encrypted_len; + int decrypted_len; /* Test decrypting with private key to obtain known plaintext */ - { - uint8_t decrypted[max_len]; - int decrypted_len; - - decrypted_len = pubkey_decrypt ( pubkey, private_ctx, - test->ciphertext, - test->ciphertext_len, - decrypted ); - okx ( decrypted_len == ( ( int ) test->plaintext_len ), - file, line ); - okx ( memcmp ( decrypted, test->plaintext, - test->plaintext_len ) == 0, file, line ); - } + decrypted_len = pubkey_decrypt ( pubkey, &test->private, + test->ciphertext, test->ciphertext_len, + decrypted ); + okx ( decrypted_len == ( ( int ) test->plaintext_len ), file, line ); + okx ( memcmp ( decrypted, test->plaintext, test->plaintext_len ) == 0, + file, line ); /* Test encrypting with private key and decrypting with public key */ - { - uint8_t encrypted[max_len]; - uint8_t decrypted[max_len]; - int encrypted_len; - int decrypted_len; - - encrypted_len = pubkey_encrypt ( pubkey, private_ctx, - test->plaintext, - test->plaintext_len, - encrypted ); - okx ( encrypted_len >= 0, file, line ); - decrypted_len = pubkey_decrypt ( pubkey, public_ctx, - encrypted, encrypted_len, - decrypted ); - okx ( decrypted_len == ( ( int ) test->plaintext_len ), - file, line ); - okx ( memcmp ( decrypted, test->plaintext, - test->plaintext_len ) == 0, file, line ); - } + encrypted_len = pubkey_encrypt ( pubkey, &test->private, + test->plaintext, test->plaintext_len, + encrypted ); + okx ( encrypted_len >= 0, file, line ); + decrypted_len = pubkey_decrypt ( pubkey, &test->public, encrypted, + encrypted_len, decrypted ); + okx ( decrypted_len == ( ( int ) test->plaintext_len ), file, line ); + okx ( memcmp ( decrypted, test->plaintext, test->plaintext_len ) == 0, + file, line ); /* Test encrypting with public key and decrypting with private key */ - { - uint8_t encrypted[max_len]; - uint8_t decrypted[max_len]; - int encrypted_len; - int decrypted_len; - - encrypted_len = pubkey_encrypt ( pubkey, public_ctx, - test->plaintext, - test->plaintext_len, - encrypted ); - okx ( encrypted_len >= 0, file, line ); - decrypted_len = pubkey_decrypt ( pubkey, private_ctx, - encrypted, encrypted_len, - decrypted ); - okx ( decrypted_len == ( ( int ) test->plaintext_len ), - file, line ); - okx ( memcmp ( decrypted, test->plaintext, - test->plaintext_len ) == 0, file, line ); - } - - /* Free contexts */ - pubkey_final ( pubkey, public_ctx ); - pubkey_final ( pubkey, private_ctx ); + encrypted_len = pubkey_encrypt ( pubkey, &test->public, + test->plaintext, test->plaintext_len, + encrypted ); + okx ( encrypted_len >= 0, file, line ); + decrypted_len = pubkey_decrypt ( pubkey, &test->private, encrypted, + encrypted_len, decrypted ); + okx ( decrypted_len == ( ( int ) test->plaintext_len ), file, line ); + okx ( memcmp ( decrypted, test->plaintext, test->plaintext_len ) == 0, + file, line ); } /** @@ -134,18 +98,12 @@ void pubkey_sign_okx ( struct pubkey_sign_test *test, const char *file, unsigned int line ) { struct pubkey_algorithm *pubkey = test->pubkey; struct digest_algorithm *digest = test->digest; - uint8_t private_ctx[pubkey->ctxsize]; - uint8_t public_ctx[pubkey->ctxsize]; + size_t max_len = pubkey_max_len ( pubkey, &test->private ); + uint8_t bad[test->signature_len]; uint8_t digestctx[digest->ctxsize ]; uint8_t digestout[digest->digestsize]; - size_t max_len; - - /* Initialize contexts */ - okx ( pubkey_init ( pubkey, private_ctx, &test->private ) == 0, - file, line ); - okx ( pubkey_init ( pubkey, public_ctx, &test->public ) == 0, - file, line ); - max_len = pubkey_max_len ( pubkey, private_ctx ); + uint8_t signature[max_len]; + int signature_len; /* Construct digest over plaintext */ digest_init ( digest, digestctx ); @@ -154,34 +112,20 @@ void pubkey_sign_okx ( struct pubkey_sign_test *test, const char *file, digest_final ( digest, digestctx, digestout ); /* Test signing using private key */ - { - uint8_t signature[max_len]; - int signature_len; - - signature_len = pubkey_sign ( pubkey, private_ctx, digest, - digestout, signature ); - okx ( signature_len == ( ( int ) test->signature_len ), - file, line ); - okx ( memcmp ( signature, test->signature, - test->signature_len ) == 0, file, line ); - } + signature_len = pubkey_sign ( pubkey, &test->private, digest, + digestout, signature ); + okx ( signature_len == ( ( int ) test->signature_len ), file, line ); + okx ( memcmp ( signature, test->signature, test->signature_len ) == 0, + file, line ); /* Test verification using public key */ - okx ( pubkey_verify ( pubkey, public_ctx, digest, digestout, + okx ( pubkey_verify ( pubkey, &test->public, digest, digestout, test->signature, test->signature_len ) == 0, file, line ); /* Test verification failure of modified signature */ - { - uint8_t bad[test->signature_len]; - - memcpy ( bad, test->signature, test->signature_len ); - bad[ test->signature_len / 2 ] ^= 0x40; - okx ( pubkey_verify ( pubkey, public_ctx, digest, digestout, - bad, sizeof ( bad ) ) != 0, file, line ); - } - - /* Free contexts */ - pubkey_final ( pubkey, public_ctx ); - pubkey_final ( pubkey, private_ctx ); + memcpy ( bad, test->signature, test->signature_len ); + bad[ test->signature_len / 2 ] ^= 0x40; + okx ( pubkey_verify ( pubkey, &test->public, digest, digestout, + bad, sizeof ( bad ) ) != 0, file, line ); } -- cgit v1.2.3-55-g7522 From 7f75d320f6d8ac7ec5185b2145da87f698aec273 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 2 Sep 2024 12:24:57 +0100 Subject: [etherfabric] Fix use of uninitialised variable in falcon_xaui_link_ok() The link status check in falcon_xaui_link_ok() reads from the FCN_XX_CORE_STAT_REG_MAC register only on production hardware (where the FPGA version reads as zero), but modifies the value and writes back to this register unconditionally. This triggers an uninitialised variable warning on newer versions of gcc. Fix by assuming that the register exists only on production hardware, and so moving the "modify-write" portion of the "read-modify-write" operation to also be covered by the same conditional check. Signed-off-by: Michael Brown --- src/drivers/net/etherfabric.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/etherfabric.c b/src/drivers/net/etherfabric.c index b40596bea..be30b71f7 100644 --- a/src/drivers/net/etherfabric.c +++ b/src/drivers/net/etherfabric.c @@ -2225,13 +2225,16 @@ falcon_xaui_link_ok ( struct efab_nic *efab ) sync = ( sync == FCN_XX_SYNC_STAT_DECODE_SYNCED ); link_ok = align_done && sync; - } - /* Clear link status ready for next read */ - EFAB_SET_DWORD_FIELD ( reg, FCN_XX_COMMA_DET, FCN_XX_COMMA_DET_RESET ); - EFAB_SET_DWORD_FIELD ( reg, FCN_XX_CHARERR, FCN_XX_CHARERR_RESET); - EFAB_SET_DWORD_FIELD ( reg, FCN_XX_DISPERR, FCN_XX_DISPERR_RESET); - falcon_xmac_writel ( efab, ®, FCN_XX_CORE_STAT_REG_MAC ); + /* Clear link status ready for next read */ + EFAB_SET_DWORD_FIELD ( reg, FCN_XX_COMMA_DET, + FCN_XX_COMMA_DET_RESET ); + EFAB_SET_DWORD_FIELD ( reg, FCN_XX_CHARERR, + FCN_XX_CHARERR_RESET ); + EFAB_SET_DWORD_FIELD ( reg, FCN_XX_DISPERR, + FCN_XX_DISPERR_RESET ); + falcon_xmac_writel ( efab, ®, FCN_XX_CORE_STAT_REG_MAC ); + } has_phyxs = ( efab->phy_op->mmds & ( 1 << MDIO_MMD_PHYXS ) ); if ( link_ok && has_phyxs ) { -- cgit v1.2.3-55-g7522 From c7f2e75519986f5847ba14ccd0e9b846c138aaaf Mon Sep 17 00:00:00 2001 From: Animesh Bhatt Date: Mon, 2 Sep 2024 13:45:54 +0100 Subject: [aqc1xx] Add support for Marvell AQtion Ethernet controller This patch adds support for the AQtion Ethernet controller, enabling iPXE to recognize and utilize the specific models (AQC114, AQC113, and AQC107). Tested-by: Animesh Bhatt Signed-off-by: Animesh Bhatt --- src/Makefile | 1 + src/drivers/net/marvell/aqc1xx.c | 629 ++++++++++++++++++++++++++++++++++++++ src/drivers/net/marvell/aqc1xx.h | 270 ++++++++++++++++ src/drivers/net/marvell/atl2_hw.c | 225 ++++++++++++++ src/drivers/net/marvell/atl2_hw.h | 94 ++++++ src/drivers/net/marvell/atl_hw.c | 313 +++++++++++++++++++ src/drivers/net/marvell/atl_hw.h | 83 +++++ src/include/ipxe/errfile.h | 3 + 8 files changed, 1618 insertions(+) create mode 100644 src/drivers/net/marvell/aqc1xx.c create mode 100644 src/drivers/net/marvell/aqc1xx.h create mode 100644 src/drivers/net/marvell/atl2_hw.c create mode 100644 src/drivers/net/marvell/atl2_hw.h create mode 100644 src/drivers/net/marvell/atl_hw.c create mode 100644 src/drivers/net/marvell/atl_hw.h (limited to 'src/drivers') diff --git a/src/Makefile b/src/Makefile index bc82cc6fe..95719628f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -77,6 +77,7 @@ SRCDIRS += drivers/net/efi SRCDIRS += drivers/net/tg3 SRCDIRS += drivers/net/bnxt SRCDIRS += drivers/net/sfc +SRCDIRS += drivers/net/marvell SRCDIRS += drivers/block SRCDIRS += drivers/nvs SRCDIRS += drivers/bitbash diff --git a/src/drivers/net/marvell/aqc1xx.c b/src/drivers/net/marvell/aqc1xx.c new file mode 100644 index 000000000..b108bf75d --- /dev/null +++ b/src/drivers/net/marvell/aqc1xx.c @@ -0,0 +1,629 @@ +/** @file + * + * Marvell AQtion family network card driver. + * + * Copyright(C) 2017-2024 Marvell + * + * SPDX-License-Identifier: BSD-2-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO,THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +FILE_LICENCE ( BSD2 ); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "aqc1xx.h" + +extern struct atl_hw_ops atl_hw; +extern struct atl_hw_ops atl2_hw; + +/** @file +* +* Marvell AQC network card driver +* +*/ + +static int atl_ring_alloc ( const struct atl_nic *nic, struct atl_ring *ring, + uint32_t desc_size, uint32_t reg_base ) { + physaddr_t phy_addr; + + /* Allocate ring buffer.*/ + ring->length = ATL_RING_SIZE * desc_size; + ring->ring = dma_alloc ( nic->dma, &ring->map, ring->length, + ring->length ); + + if ( !ring->ring ) + return -ENOMEM; + + /* Initialize the descriptor ring */ + memset ( ring->ring, 0, ring->length ); + + /* Program ring address */ + phy_addr = dma ( &ring->map, ring->ring ); + + /* Write ring address (hi & low parts).*/ + ATL_WRITE_REG ( ( uint32_t )phy_addr, reg_base ); + ATL_WRITE_REG ( ( uint32_t ) ( ( ( uint64_t )phy_addr ) >> 32 ), reg_base + 4 ); + + /* Write ring length.*/ + ATL_WRITE_REG ( ATL_RING_SIZE, reg_base + 8 ); + + ring->sw_head = ring->sw_tail = 0; + + DBGC ( nic, "AQUANTIA: %p ring is at [%08llx,%08llx), reg base %#x\n", + nic, ( ( unsigned long long )phy_addr ), + ( ( unsigned long long ) phy_addr + ring->length ), reg_base ); + + return 0; +} + +static void atl_ring_free ( struct atl_ring *ring ) { + dma_free ( &ring->map, ring->ring, ring->length ); + ring->ring = NULL; + ring->length = 0; +} + +static void atl_ring_next_dx ( unsigned int *val ) { + ++( *val ); + if ( *val == ATL_RING_SIZE ) + *val = 0; +} + +int atl_ring_full ( const struct atl_ring *ring ) { + unsigned int tail = ring->sw_tail; + atl_ring_next_dx ( &tail ); + return tail == ring->sw_head; +} + +void atl_rx_ring_fill ( struct atl_nic *nic ) { + struct atl_desc_rx *rx; + struct io_buffer *iobuf; + physaddr_t address; + unsigned int refilled = 0; + + /* Refill ring */ + while ( !atl_ring_full ( &nic->rx_ring ) ) { + + /* Allocate I/O buffer */ + iobuf = alloc_rx_iob ( ATL_RX_MAX_LEN, nic->dma ); + if ( !iobuf ) { + /* Wait for next refill */ + break; + } + + /* Get next receive descriptor */ + rx = ( struct atl_desc_rx * )nic->rx_ring.ring + + nic->rx_ring.sw_tail; + + /* Populate receive descriptor */ + address = iob_dma ( iobuf ); + rx->data_addr = address; + rx->hdr_addr = 0; + + /* Record I/O buffer */ + assert ( nic->iobufs[nic->rx_ring.sw_tail] == NULL ); + nic->iobufs[nic->rx_ring.sw_tail] = iobuf; + + DBGC( nic, "AQUANTIA: RX[%d] is [%llx,%llx)\n", + nic->rx_ring.sw_tail, + ( ( unsigned long long )address ), + ( ( unsigned long long )address + ATL_RX_MAX_LEN ) ); + + atl_ring_next_dx ( &nic->rx_ring.sw_tail ); + refilled++; + } + + /* Push descriptors to card, if applicable */ + if ( refilled ) { + wmb(); + ATL_WRITE_REG ( nic->rx_ring.sw_tail, ATL_RING_TAIL_PTR ); + } +} + +/** +* Open network device +* +* @v netdev Network device +* @ret rc Return status code +*/ +static int atl_open ( struct net_device *netdev ) { + struct atl_nic *nic = netdev->priv; + uint32_t ctrl = 0; + + /* Tx ring */ + if ( atl_ring_alloc ( nic, &nic->tx_ring, sizeof ( struct atl_desc_tx ), + ATL_TX_DMA_DESC_ADDR ) != 0 ) + goto err_tx_alloc; + + /* Rx ring */ + if ( atl_ring_alloc ( nic, &nic->rx_ring, sizeof ( struct atl_desc_rx ), + ATL_RX_DMA_DESC_ADDR ) != 0 ) + goto err_rx_alloc; + + /* Allocate interrupt vectors */ + ATL_WRITE_REG ( ( ATL_IRQ_CTRL_COR_EN | ATL_IRQ_CTRL_REG_RST_DIS ), + ATL_IRQ_CTRL ); + + /*TX & RX Interruprt Mapping*/ + ctrl = ATL_IRQ_MAP_REG1_RX0 | ATL_IRQ_MAP_REG1_RX0_EN | + ATL_IRQ_MAP_REG1_TX0 | ATL_IRQ_MAP_REG1_TX0_EN; + ATL_WRITE_REG ( ctrl, ATL_IRQ_MAP_REG1 ); + + /*TX interrupt ctrl reg*/ + ATL_WRITE_REG ( ATL_TX_IRQ_CTRL_WB_EN, ATL_TX_IRQ_CTRL ); + + /*RX interrupt ctrl reg*/ + ATL_WRITE_REG ( ATL_RX_IRQ_CTRL_WB_EN, ATL_RX_IRQ_CTRL ); + + /*RX data path*/ + ctrl = ATL_IRQ_TX | ATL_IRQ_RX; + /* itr mask */ + ATL_WRITE_REG ( ctrl, ATL_ITR_MSKS ); + ATL_WRITE_REG ( ( uint32_t )ATL_RX_MAX_LEN / 1024U, + ATL_RX_DMA_DESC_BUF_SIZE ); + + /*filter global ctrl */ + ctrl = ATL_RPF_CTRL1_BRC_EN | ATL_RPF_CTRL1_L2_PROMISC | + ATL_RPF_CTRL1_ACTION | ATL_RPF_CTRL1_BRC_TSH; + ATL_WRITE_REG ( ctrl, ATL_RPF_CTRL1 ); + + /* vlan promisc */ + ATL_WRITE_REG ( ATL_RPF_CTRL2_VLAN_PROMISC, ATL_RPF_CTRL2 ); + /* enable rpf2 */ + ATL_WRITE_REG ( ATL_RPF2_CTRL_EN, ATL_RPF2_CTRL ); + + /* RX Packet Buffer 0 Register 1 */ + ATL_WRITE_REG ( ATL_RPB0_CTRL1_SIZE, ATL_RPB0_CTRL1 ); + + /*RX Packet Buffer 0 Register 2 */ + ctrl = ATL_RPB0_CTRL2_LOW_TSH | ATL_RPB0_CTRL2_HIGH_TSH | + ATL_RPB0_CTRL2_FC_EN; + ATL_WRITE_REG ( ctrl, ATL_RPB0_CTRL2 ); + + /*RPB global ctrl*/ + ctrl = ATL_READ_REG ( ATL_RPB_CTRL ); + ctrl |= ( ATL_RPB_CTRL_EN | ATL_RPB_CTRL_FC ); + ATL_WRITE_REG ( ctrl, ATL_RPB_CTRL ); + + /*TX data path*/ + /* enable tpo2 */ + ATL_WRITE_REG ( ATL_TPO2_EN, ATL_TPO2_CTRL ); + /* tpb global ctrl *** */ + ATL_WRITE_REG ( ATL_TPB0_CTRL1_SIZE, ATL_TPB0_CTRL1 ); + + ctrl = ATL_TPB0_CTRL2_LOW_TSH | ATL_TPB0_CTRL2_HIGH_TSH; + /* tpb global ctrl *** */ + ATL_WRITE_REG ( ctrl, ATL_TPB0_CTRL2 ); + + ctrl = ATL_READ_REG ( ATL_TPB_CTRL ); + ctrl |= ( ATL_TPB_CTRL_EN | ATL_TPB_CTRL_PAD_EN ); + /* tpb global ctrl */ + ATL_WRITE_REG ( ctrl, ATL_TPB_CTRL ); + + /*Enable rings*/ + ATL_WRITE_REG ( ATL_READ_REG ( ATL_RING_TX_CTRL ) | ATL_RING_TX_CTRL_EN, + ATL_RING_TX_CTRL ); + ATL_WRITE_REG ( ATL_READ_REG ( ATL_RING_RX_CTRL ) | ATL_RING_RX_CTRL_EN, + ATL_RING_RX_CTRL ); + + if ( nic->flags == ATL_FLAG_A2 ) { + ATL_WRITE_REG ( ATL2_RPF_NEW_EN_ADR_EN, ATL2_RPF_NEW_EN_ADR ); + } + + atl_rx_ring_fill ( nic ); + + nic->hw_ops->start ( nic ); + + return 0; + +err_rx_alloc: + atl_ring_free ( &nic->tx_ring ); + +err_tx_alloc: + return -ENOMEM; +} + +/** +* Close network device +* +* @v netdev Network device +*/ +static void atl_close ( struct net_device *netdev ) { + struct atl_nic *nic = netdev->priv; + + nic->hw_ops->stop ( nic ); + /* rpb global ctrl */ + ATL_WRITE_REG ( ATL_RPB_CTRL_DIS, ATL_RPB_CTRL ); + /* tgb global ctrl */ + ATL_WRITE_REG ( ATL_TPB_CTRL_DIS, ATL_TPB_CTRL); + + ATL_WRITE_REG ( ATL_READ_REG ( ATL_RING_TX_CTRL ) | ( ~ATL_RING_TX_CTRL_EN ), + ATL_RING_TX_CTRL ); + ATL_WRITE_REG ( ATL_READ_REG ( ATL_RING_RX_CTRL ) | ( ~ATL_RING_RX_CTRL_EN ), + ATL_RING_RX_CTRL ); + + /* clear itr mask */ + ATL_WRITE_REG ( ATL_ITR_MSKS_DIS, ATL_ITR_MSKS ); + + /* Reset the NIC */ + nic->hw_ops->reset ( nic ); + + atl_ring_free ( &nic->tx_ring ); + atl_ring_free ( &nic->rx_ring ); +} + +/** +* Transmit packet +* +* @v netdev Network device +* @v iobuf I/O buffer +* @ret rc Return status code +*/ +int atl_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) { + struct atl_nic *nic = netdev->priv; + struct atl_desc_tx *tx; + physaddr_t address; + uint32_t len; + + /* Get next transmit descriptor */ + if ( atl_ring_full ( &nic->tx_ring ) ) { + DBGC ( nic, "AQUANTIA: %p out of transmit descriptors\n", nic ); + return -ENOBUFS; + } + + tx = ( struct atl_desc_tx * )nic->tx_ring.ring + nic->tx_ring.sw_tail; + + /* Populate transmit descriptor */ + memset ( tx, 0, sizeof ( *tx ) ); + address = iob_dma ( iobuf ); + tx->address = address; + len = iob_len ( iobuf ); + + tx->status = 0x1; + tx->status = ( (tx->status) & ~ATL_DESC_TX_BUF_LEN_MASK) | + ( (len << ATL_DESC_TX_BUF_LEN_OFFSET) & + ATL_DESC_TX_BUF_LEN_MASK ); + tx->status = ((tx->status) & ~ATL_DESC_TX_EOP_MASK) | + ( (ATL_DESC_TX_DX_EOP_VALUE << ATL_DESC_TX_EOP_OFFSET) & + ATL_DESC_TX_EOP_MASK ); + tx->status = ( (tx->status) & ~ATL_DESC_TX_CMD_MASK) | + ( (ATL_DESC_TX_CMD_VALUE << ATL_DESC_TX_CMD_OFFSET) & + ATL_DESC_TX_CMD_MASK ); + tx->flag = ( (tx->flag) & ~ATL_DESC_TX_PAY_LEN_MASK) | + ( (len << ATL_DESC_TX_PAY_LEN_OFFSET) & + ATL_DESC_TX_PAY_LEN_MASK ); + wmb(); + + DBGC2 ( nic, "AQUANTIA: %p TX[%d] is [%llx, %llx]\n", + nic, nic->tx_ring.sw_tail, + ( ( unsigned long long ) address ), + ( ( unsigned long long ) address + len ) ); + + atl_ring_next_dx ( &nic->tx_ring.sw_tail ); + ATL_WRITE_REG ( nic->tx_ring.sw_tail, ATL_RING_TAIL ); + + return 0; +} + +void atl_check_link ( struct net_device *netdev ) { + struct atl_nic *nic = netdev->priv; + uint32_t link_state; + + /* Read link status */ + link_state = nic->hw_ops->get_link ( nic ); + + DBGC ( nic, "AQUANTIA: %p link status is %08x\n", nic, link_state ); + + if ( link_state != nic->link_state ) { + if ( link_state ) { + DBGC ( nic, "AQUANTIA: link up\n"); + netdev_link_up ( netdev ); + } else { + DBGC ( nic, "AQUANTIA: link lost\n"); + netdev_link_down ( netdev ); + } + nic->link_state = link_state; + } +} + +/** +* Poll for completed packets +* +* @v netdev Network device +*/ +void atl_poll_tx ( struct net_device *netdev ) { + struct atl_nic *nic = netdev->priv; + struct atl_desc_tx_wb *tx; + + /* Check for completed packets */ + while ( nic->tx_ring.sw_head != nic->tx_ring.sw_tail ) { + + /* Get next transmit descriptor */ + tx = ( struct atl_desc_tx_wb * )nic->tx_ring.ring + + nic->tx_ring.sw_head; + + /* Stop if descriptor is still in use */ + if ( !( tx->status & cpu_to_le32 ( ATL_TX_DESC_STATUS_DD ) ) ) + return; + + DBGC2 ( nic, "AQUANTIA: %p TX[%d] complete\n", + nic, nic->tx_ring.sw_head ); + + /* Complete TX descriptor */ + atl_ring_next_dx ( &nic->tx_ring.sw_head ); + netdev_tx_complete_next ( netdev ); + } +} + +/** +* Poll for received packets +* +* @v netdev Network device +*/ +void atl_poll_rx ( struct net_device *netdev ) { + struct atl_nic *nic = netdev->priv; + struct atl_desc_rx_wb *rx; + struct io_buffer *iobuf; + size_t len; + + /* Check for received packets */ + while ( nic->rx_ring.sw_head != nic->rx_ring.sw_tail ) { + + /* Get next receive descriptor */ + rx = ( struct atl_desc_rx_wb * )nic->rx_ring.ring + + nic->rx_ring.sw_head; + + /* Stop if descriptor is still in use */ + if ( !( rx->status & cpu_to_le16( ATL_RX_DESC_STATUS_DD ) ) ) + return; + + /* Populate I/O buffer */ + iobuf = nic->iobufs[nic->rx_ring.sw_head]; + nic->iobufs[nic->rx_ring.sw_head] = NULL; + len = le16_to_cpu ( rx->pkt_len ); + iob_put ( iobuf, len ); + + /* Hand off to network stack */ + DBGC ( nic, "AQUANTIA: %p RX[%d] complete (length %zd)\n", + nic, nic->rx_ring.sw_head, len ); + + netdev_rx ( netdev, iobuf ); + + atl_ring_next_dx ( &nic->rx_ring.sw_head ); + } +} + +/** +* Poll for completed and received packets +* +* @v netdev Network device +*/ +static void atl_poll ( struct net_device *netdev ) { + struct atl_nic *nic = netdev->priv; + + /* Check link state */ + atl_check_link ( netdev ); + + /* Poll for TX completions */ + atl_poll_tx ( netdev ); + + /* Poll for RX completions */ + atl_poll_rx ( netdev ); + + /* Refill RX ring */ + atl_rx_ring_fill ( nic ); +} + +/** +* Enable or disable interrupts +* +* @v netdev Network device +* @v enable Interrupts should be enabled +*/ +static void atl_irq ( struct net_device *netdev, int enable ) { + struct atl_nic *nic = netdev->priv; + uint32_t mask; + + mask = ( ATL_IRQ_TX | ATL_IRQ_RX ); + if ( enable ) + ATL_WRITE_REG ( mask, ATL_ITR_MSKS ); + else + ATL_WRITE_REG ( mask, ATL_ITR_MSKC ); +} + +/** Marvell network device operations */ +static struct net_device_operations atl_operations = { + .open = atl_open, + .close = atl_close, + .transmit = atl_transmit, + .poll = atl_poll, + .irq = atl_irq, +}; + +/****************************************************************************** +* +* PCI interface +* +******************************************************************************* +*/ + +/** +* Probe PCI device +* +* @v pci PCI device +* @ret rc Return status code +*/ +static int atl_probe ( struct pci_device *pci ) { + struct net_device *netdev; + struct atl_nic *nic; + int rc = ENOERR; + uint32_t io_size = 0; + + /* Allocate and initialise net device */ + netdev = alloc_etherdev ( sizeof( *nic ) ); + if ( !netdev ) { + rc = -ENOMEM; + goto err_alloc; + } + netdev_init ( netdev, &atl_operations ); + nic = netdev->priv; + pci_set_drvdata ( pci, netdev ); + netdev->dev = &pci->dev; + memset( nic, 0, sizeof ( *nic ) ); + nic->flags = pci->id->driver_data; + + /* Fix up PCI device */ + adjust_pci_device ( pci ); + + switch ( nic->flags ) { + case ATL_FLAG_A1: + nic->hw_ops = &atl_hw; + io_size = ATL_BAR_SIZE; + break; + case ATL_FLAG_A2: + nic->hw_ops = &atl2_hw; + io_size = ATL2_BAR_SIZE; + break; + default: + goto err_unsupported; + break; + } + + /* Map registers */ + nic->regs = pci_ioremap ( pci, pci->membase, io_size ); + if ( !nic->regs ) { + rc = -ENODEV; + goto err_ioremap; + } + + /* Configure DMA */ + nic->dma = &pci->dma; + + /* Reset the NIC */ + if ( ( rc = nic->hw_ops->reset ( nic ) ) != 0 ) + goto err_reset; + + /* Get MAC Address */ + if ( ( rc = nic->hw_ops->get_mac ( nic, netdev->hw_addr ) ) != 0 ) + goto err_mac; + + /* Register network device */ + if ( ( rc = register_netdev ( netdev ) ) != 0 ) + goto err_register_netdev; + + /* Set initial link state */ + netdev_link_down ( netdev ); + + return 0; + +err_register_netdev: +err_mac: + nic->hw_ops->reset ( nic ); +err_reset: + iounmap ( nic->regs ); +err_ioremap: + netdev_nullify ( netdev ); + netdev_put ( netdev ); +err_unsupported: +err_alloc: + return rc; +} + +/** +* Remove PCI device +* +* @v pci PCI device +*/ +static void atl_remove ( struct pci_device *pci ) { + struct net_device *netdev = pci_get_drvdata ( pci ); + struct atl_nic *nic = netdev->priv; + + /* Unregister network device */ + unregister_netdev ( netdev ); + + /* Reset the NIC */ + nic->hw_ops->reset ( nic ); + + /* Free network device */ + iounmap ( nic->regs ); + netdev_nullify ( netdev ); + netdev_put ( netdev ); +} + +/** Marvell PCI device IDs */ +static struct pci_device_id atl_nics[] = { + /* Atlantic 1 */ + /* 10G */ + PCI_ROM ( 0x1D6A, 0x0001, "AQC07", "Marvell AQtion 10Gbit Network Adapter", ATL_FLAG_A1 ), + PCI_ROM ( 0x1D6A, 0xD107, "AQC07", "Marvell AQtion 10Gbit Network Adapter", ATL_FLAG_A1 ), + PCI_ROM ( 0x1D6A, 0x07B1, "AQC07", "Marvell AQtion 10Gbit Network Adapter", ATL_FLAG_A1 ), + PCI_ROM ( 0x1D6A, 0x87B1, "AQC07", "Marvell AQtion 10Gbit Network Adapter", ATL_FLAG_A1 ), + + /* SFP */ + PCI_ROM ( 0x1D6A, 0xD100, "AQC00", "Felicity Network Adapter", ATL_FLAG_A1 ), + PCI_ROM ( 0x1D6A, 0x00B1, "AQC00", "Felicity Network Adapter", ATL_FLAG_A1 ), + PCI_ROM ( 0x1D6A, 0x80B1, "AQC00", "Felicity Network Adapter", ATL_FLAG_A1 ), + + /* 5G */ + PCI_ROM ( 0x1D6A, 0xD108, "AQC08", "Marvell AQtion 5Gbit Network Adapter", ATL_FLAG_A1 ), + PCI_ROM ( 0x1D6A, 0x08B1, "AQC08", "Marvell AQtion 5Gbit Network Adapter", ATL_FLAG_A1 ), + PCI_ROM ( 0x1D6A, 0x88B1, "AQC08", "Marvell AQtion 5Gbit Network Adapter", ATL_FLAG_A1 ), + PCI_ROM ( 0x1D6A, 0x11B1, "AQC11", "Marvell AQtion 5Gbit Network Adapter", ATL_FLAG_A1 ), + PCI_ROM ( 0x1D6A, 0x91B1, "AQC11", "Marvell AQtion 5Gbit Network Adapter", ATL_FLAG_A1 ), + + /* 2.5G */ + PCI_ROM ( 0x1D6A, 0xD109, "AQC09", "Marvell AQtion 2.5Gbit Network Adapter", ATL_FLAG_A1 ), + PCI_ROM ( 0x1D6A, 0x09B1, "AQC09", "Marvell AQtion 2.5Gbit Network Adapter", ATL_FLAG_A1 ), + PCI_ROM ( 0x1D6A, 0x89B1, "AQC09", "Marvell AQtion 2.5Gbit Network Adapter", ATL_FLAG_A1 ), + PCI_ROM ( 0x1D6A, 0x12B1, "AQC12", "Marvell AQtion 2.5Gbit Network Adapter", ATL_FLAG_A1 ), + PCI_ROM ( 0x1D6A, 0x92B1, "AQC12", "Marvell AQtion 2.5Gbit Network Adapter", ATL_FLAG_A1 ), + + /* Atlantic 2 */ + PCI_ROM ( 0x1D6A, 0x00C0, "AQC13", "Marvell AQtion 10Gbit Network Adapter", ATL_FLAG_A2 ), + PCI_ROM ( 0x1D6A, 0x94C0, "AQC13", "Marvell AQtion 10Gbit Network Adapter", ATL_FLAG_A2 ), + PCI_ROM ( 0x1D6A, 0x93C0, "AQC13", "Marvell AQtion 10Gbit Network Adapter", ATL_FLAG_A2 ), + PCI_ROM ( 0x1D6A, 0x04C0, "AQC13", "Marvell AQtion 10Gbit Network Adapter", ATL_FLAG_A2 ), + PCI_ROM ( 0x1D6A, 0x14C0, "AQC13", "Marvell AQtion 10Gbit Network Adapter", ATL_FLAG_A2 ), + PCI_ROM ( 0x1D6A, 0x12C0, "AQC13", "Marvell AQtion 10Gbit Network Adapter", ATL_FLAG_A2 ), + PCI_ROM ( 0x1D6A, 0x03C0, "AQC14", "Marvell AQtion 5Gbit Network Adapter", ATL_FLAG_A2 ), +}; + +/** Marvell PCI driver */ +struct pci_driver atl_driver __pci_driver = { + .ids = atl_nics, + .id_count = ( sizeof( atl_nics ) / sizeof ( atl_nics[0] ) ), + .probe = atl_probe, + .remove = atl_remove, +}; diff --git a/src/drivers/net/marvell/aqc1xx.h b/src/drivers/net/marvell/aqc1xx.h new file mode 100644 index 000000000..26bdd00f0 --- /dev/null +++ b/src/drivers/net/marvell/aqc1xx.h @@ -0,0 +1,270 @@ +/** @file + * + * Marvell AQtion family network card driver definitions. + * + * Copyright(C) 2017-2024 Marvell + * + * SPDX-License-Identifier: BSD-2-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _ATLANTIC_H +#define _ATLANTIC_H + +FILE_LICENCE ( BSD2 ); + +#include +#include +#include + +#define ATL_BAR_SIZE 0x10000 +#define ATL2_BAR_SIZE 0x40000 +#define ATL_RING_SIZE 64 +#define ATL_RING_ALIGN 128 +#define ATL_RX_MAX_LEN 2048 + +#define ATL_IRQ_TX 0x00000001U +#define ATL_IRQ_RX 0x00000002U + +/*IRQ Status Register*/ +#define ATL_IRQ_STAT_REG 0x00002000U + +/* Interrupt Vector Allocation Register */ +#define ATL_IRQ_CTRL 0x00002300U +#define ATL_IRQ_CTRL_COR_EN 0x00000080U /*IRQ clear on read */ +#define ATL_IRQ_CTRL_REG_RST_DIS 0x20000000U /*Register reset disable */ + +/*TX/RX Interruprt Mapping*/ +#define ATL_IRQ_MAP_REG1 0x00002100U /*IRQ mapping register */ + +#define ATL_IRQ_MAP_REG1_RX0_EN 0x00008000U /*IRQ RX0 enable*/ +#define ATL_IRQ_MAP_REG1_RX0 0x00000100U /*IRQ RX0*/ + +#define ATL_IRQ_MAP_REG1_TX0_EN 0x80000000U /*IRQ TX0 enable*/ +#define ATL_IRQ_MAP_REG1_TX0 0x00000000U /*IRQ TX0*/ + +/*TX interrupt ctrl reg*/ +#define ATL_TX_IRQ_CTRL 0x00007B40U +#define ATL_TX_IRQ_CTRL_WB_EN 0x00000002U + +/*RX interrupt ctrl reg*/ +#define ATL_RX_IRQ_CTRL 0x00005A30U +#define ATL_RX_IRQ_CTRL_WB_EN 0x00000004U + +#define ATL_GLB_CTRL 0x00000000U + +#define ATL_PCI_CTRL 0x00001000U +#define ATL_PCI_CTRL_RST_DIS 0x20000000U + +#define ATL_RX_CTRL 0x00005000U +#define ATL_RX_CTRL_RST_DIS 0x20000000U /*RPB reset disable */ +#define ATL_TX_CTRL 0x00007000U +#define ATL_TX_CTRL_RST_DIS 0x20000000U /*TPB reset disable */ + +/*RX data path control registers*/ +#define ATL_RPF2_CTRL 0x00005040U +#define ATL_RPF2_CTRL_EN 0x000F0000U /* RPF2 enable*/ +#define ATL2_RPF_NEW_EN_ADR_EN 0x00000001U /*enable*/ +#define ATL2_RPF_NEW_EN_ADR 0x5104 + +#define ATL_RPF_CTRL1 0x00005100U +#define ATL_RPF_CTRL1_BRC_EN 0x00000001U /*Allow broadcast receive*/ +#define ATL_RPF_CTRL1_L2_PROMISC 0x00000008U /*L2 promiscious*/ +#define ATL_RPF_CTRL1_ACTION 0x00001000U /*Action to host*/ +#define ATL_RPF_CTRL1_BRC_TSH 0x00010000U /*Brc threshold 256 units per sec*/ + +#define ATL_RPF_CTRL2 0x00005280U +#define ATL_RPF_CTRL2_VLAN_PROMISC 0x00000002U /*VLAN promisc*/ + +#define ATL_RPB_CTRL_DIS 0x0 +#define ATL_RPB_CTRL 0x00005700U +#define ATL_RPB_CTRL_EN 0x00000001U /*RPB Enable*/ +#define ATL_RPB_CTRL_FC 0x00000010U /*RPB Enable*/ +#define ATL_RPB_CTRL_TC_MODE 0x00000100U /*RPB Traffic Class Mode*/ + +#define ATL_RPB0_CTRL1 0x00005710U +#define ATL_RPB0_CTRL1_SIZE 0x00000140U /*RPB size (in unit 1KB) \*/ + +#define ATL_RPB0_CTRL2 0x00005714U + +/*Buffer Low Threshold (70% of RPB size in unit 32B)*/ +#define ATL_RPB0_CTRL2_LOW_TSH 0x00000C00U +/*Buffer High Threshold(30% of RPB size in unit 32B)*/ +#define ATL_RPB0_CTRL2_HIGH_TSH 0x1C000000U +#define ATL_RPB0_CTRL2_FC_EN 0x80000000U /*Flow control Enable*/ + +#define ATL_RX_DMA_DESC_BUF_SIZE 0x00005b18U +#define ATL_RX_DMA_DESC_ADDR 0x00005b00U + +/*TX data path control registers*/ +#define ATL_TPO2_CTRL 0x00007040U +#define ATL_TPO2_EN 0x00010000U /*TPO2 Enable*/ + +#define ATL_TPB_CTRL_DIS 0x0 +#define ATL_TPB_CTRL 0x00007900U +#define ATL_TPB_CTRL_EN 0x00000001U /*TPB enable*/ +#define ATL_TPB_CTRL_PAD_EN 0x00000004U /*Tx pad insert enable*/ +#define ATL_TPB_CTRL_TC_MODE 0x00000100U /*Tx traffic Class Mode*/ + +#define ATL_TPB0_CTRL1 0x00007910U +#define ATL_TPB0_CTRL1_SIZE 0x000000A0U /*TPB Size (in unit 1KB)*/ + +#define ATL_TPB0_CTRL2 0x00007914U +/*Buffer Low Threshold(30% of RPB size in unit 32B)*/ +#define ATL_TPB0_CTRL2_LOW_TSH 0x00000600U +/*Buffer High Threshold(30% of RPB size in unit 32B)*/ +#define ATL_TPB0_CTRL2_HIGH_TSH 0x0E000000U + +#define ATL_TX_DMA_DESC_ADDR 0x00007c00U + +/*Rings control registers*/ +#define ATL_RING_TX_CTRL 0x00007c08U +#define ATL_RING_TX_CTRL_EN 0x80000000U /*Tx descriptor Enable*/ + +#define ATL_RING_RX_CTRL 0x00005b08U +#define ATL_RING_RX_CTRL_EN 0x80000000U /*Rx descriptor Enable*/ + +#define ATL_RING_TAIL 0x00007c10U +#define ATL_RING_TAIL_PTR 0x00005b10U + +/*IRQ control registers*/ +#define ATL_ITR_MSKS_DIS 0x0 +#define ATL_ITR_MSKS 0x00002060U +#define ATL_ITR_MSKS_LSW 0x0000000CU +#define ATL_ITR_MSKC 0x00002070U +#define ATL_ITR_MSKC_LSW 0x0000000CU + +/*Link advertising*/ +#define ATL_LINK_ADV 0x00000368U +#define ATL_SHUT_LINK 0x0 +#define ATL_LINK_ADV_AUTONEG 0xF20U + +#define ATL_LINK_ST 0x00000370U + +/*Semaphores*/ +#define ATL_SEM_RAM 0x000003a8U +#define ATL_SEM_RAM_RESET 0X1 + +/*Mailbox*/ +#define ATL_MBOX_ADDR 0x00000360U +#define ATL_MBOX_CTRL1 0x00000200U +#define ATL_MBOX_CTRL1_START_MBOX_OPT 0x8000 + +#define ATL_MBOX_CTRL3 0x00000208U +#define ATL_MBOX_CTRL5 0x0000020cU + +#define ATL_FLAG_A1 0x1 +#define ATL_FLAG_A2 0x2 + +/*write register*/ +#define ATL_WRITE_REG( VAL, REG ) writel( VAL, nic->regs + (REG) ) +#define ATL_READ_REG( REG ) readl( nic->regs + (REG) ) /*read register*/ + +struct atl_desc_tx { + uint64_t address; + uint32_t status; + uint32_t flag; +} __attribute__ (( packed )); + +#define ATL_DESC_TX_DX_TYPE_VALUE 0x1 + +#define ATL_DESC_TX_DX_EOP_VALUE 0x1 +#define ATL_DESC_TX_EOP_MASK 0x00200000 +#define ATL_DESC_TX_EOP_OFFSET 21 + +#define ATL_DESC_TX_CMD_MASK 0x3FC00000UL +#define ATL_DESC_TX_CMD_OFFSET 22 +#define ATL_DESC_TX_CMD_VALUE 0x22 + +#define ATL_DESC_TX_BUF_LEN_MASK 0x000FFFF0 +#define ATL_DESC_TX_BUF_LEN_OFFSET 5 + +#define ATL_DESC_TX_PAY_LEN_MASK 0xFFFFC000 +#define ATL_DESC_TX_PAY_LEN_OFFSET 14 + +struct atl_desc_tx_wb { + uint64_t rsvd1; + uint32_t status; + uint32_t rsvd4; +} __attribute__ (( packed )); + +#define ATL_TX_DESC_STATUS_DD 0x00100000UL + +struct atl_desc_rx { + uint64_t data_addr; + uint64_t hdr_addr; + +} __attribute__ (( packed )); + +struct atl_desc_rx_wb { + uint64_t rsvd2; + uint16_t status; + uint16_t pkt_len; + uint32_t rsvd4; +} __attribute__ (( packed )); + +#define ATL_RX_DESC_STATUS_DD 0x0001UL +#define ATL_RX_DESC_STATUS_EOP 0x0002UL +struct atl_ring { + unsigned int sw_tail; + unsigned int sw_head; + void *ring; + /** Descriptor ring DMA mapping */ + struct dma_mapping map; + unsigned int length; +}; + +struct atl_nic; + +struct atl_hw_ops { + int ( *reset ) ( struct atl_nic *nic ); + int ( *start ) ( struct atl_nic *nic ); + int ( *stop ) ( struct atl_nic *nic ); + int ( *get_link ) ( struct atl_nic *nic ); + int ( *get_mac ) ( struct atl_nic *, uint8_t *mac ); +}; + +/** An aQuanita network card */ +struct atl_nic { + /** Registers */ + void *regs; + /** Port number (for multi-port devices) */ + unsigned int port; + /** DMA device */ + struct dma_device *dma; + /** Flags */ + unsigned int flags; + struct atl_ring tx_ring; + struct atl_ring rx_ring; + struct io_buffer *iobufs[ATL_RING_SIZE]; + uint32_t link_state; + uint32_t mbox_addr; + struct atl_hw_ops *hw_ops; +}; + +struct atl_hw_stats { + uint32_t version; + uint32_t tid; +}; + +#endif /* _AQUANTIA_H */ diff --git a/src/drivers/net/marvell/atl2_hw.c b/src/drivers/net/marvell/atl2_hw.c new file mode 100644 index 000000000..805820709 --- /dev/null +++ b/src/drivers/net/marvell/atl2_hw.c @@ -0,0 +1,225 @@ +/** @file + * + * Marvell AQtion family network card driver, hardware-specific functions. + * + * Copyright(C) 2017-2024 Marvell + * + * SPDX-License-Identifier: BSD-2-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO,THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +FILE_LICENCE ( BSD2 ); + +#include +#include +#include +#include +#include +#include "aqc1xx.h" +#include "atl2_hw.h" + +static int atl2_hw_boot_completed_ ( struct atl_nic *nic ) { + uint32_t reset_status = ATL_READ_REG ( ATL2_GLB_RST_CTRL2 ); + + return ( reset_status & ATL2_RESET_STATUS_BOOT_COMPLETED_MASK ) || + ( ATL_READ_REG ( ATL2_HOST_ITR_REQ ) + & ATL2_FW_HOST_INTERRUPT_REQUEST_READY ); +} + +void atl2_hw_read_shared_in_ ( struct atl_nic *nic, uint32_t offset, + uint32_t *data, uint32_t len ) { + uint32_t i; + + for (i = 0; i < len; ++i ) + { + data[i] = ATL_READ_REG ( ATL2_MIF_SHARED_BUF_IN + offset + i * 4 ); + } +} + +void atl2_hw_write_shared_in_ ( struct atl_nic *nic, uint32_t offset, + uint32_t *data, uint32_t len ) { + uint32_t i; + + for ( i = 0; i < len; ++i ) + { + ATL_WRITE_REG ( data[i], ATL2_MIF_SHARED_BUF_IN + offset + i * 4 ); + } +} + +int atl2_hw_finish_ack_ ( struct atl_nic *nic, uint32_t ms ) { + uint32_t i; + int err = 0; + + ATL_WRITE_REG ( ATL_READ_REG ( ATL2_HOST_FINISHED_WRITE ) + | 1, ATL2_HOST_FINISHED_WRITE ); + + for ( i = 0; i < ( ms / 100 ); ++i ) + { + if ( ( ATL_READ_REG ( ATL2_MCP_BUSY_WRITE ) & 1 ) == 0 ) + { + break; + } + udelay ( ATL2_DELAY_100 ); + } + if (i == ( ms / 100 ) ) + err = -ETIME; + + return err; +} + +int atl2_hw_fw_init_ ( struct atl_nic *nic ) { + uint32_t val; + int err = 0; + + atl2_hw_read_shared_in_ ( nic, ATL2_LINK_CTRL_IN_OFF, &val, 1 ); + val |= ( ATL2_HOST_MODE_ACTIVE | ( 1U << 13 ) ); + atl2_hw_write_shared_in_ ( nic, ATL2_LINK_CTRL_IN_OFF, &val, 1 ); + + atl2_hw_read_shared_in_ ( nic, ATL2_MTU_IN_OFF, &val, 1 ); + val = 16352; + atl2_hw_write_shared_in_ ( nic, ATL2_MTU_IN_OFF, &val, 1 ); + + atl2_hw_read_shared_in_ ( nic, ATL2_LINK_OPTS_IN_OFF, &val, 1 ); + val = 0; + atl2_hw_write_shared_in_( nic, ATL2_LINK_OPTS_IN_OFF, &val, 1 ); + err = atl2_hw_finish_ack_ ( nic, 50000000 ); + + return err; +} + +int atl2_hw_reset ( struct atl_nic *nic ) { + int completed = 0; + uint32_t status = 0; + uint32_t request; + int err = 0; + int i; + + request = ATL2_RESET_STATUS_REQ_GSR; + + ATL_WRITE_REG ( request, ATL2_GLB_RST_CTRL2 ); + + /* Wait for boot code started every 10us, 200 ms */ + for ( i = 0; i < 20000; ++i ) + { + status = ATL_READ_REG ( ATL2_GLB_RST_CTRL2 ); + + if ( ( ( status & ATL2_RESET_STATUS_BC_STARTED ) && + ( status != 0xFFFFFFFFu ) ) ) + break; + + udelay ( ATL2_DELAY_10 ); + } + if ( i == 20000 ) + { + DBGC ( nic, "Boot code hanged" ); + err = -EIO; + goto err_exit; + } + + /* Wait for boot succeed, failed or host request every 10us, 480ms */ + for ( i = 0; i < 48000; ++i ) + { + completed = atl2_hw_boot_completed_ ( nic ); + if ( completed ) + break; + + udelay ( ATL2_DELAY_10 ); + } + + if ( !completed ) + { + DBGC ( nic, "FW Restart timed out" ); + err = -ETIME; + goto err_exit; + } + + status = ATL_READ_REG ( ATL2_GLB_RST_CTRL2 ); + + if ( status & ATL2_RESET_STATUS_BOOT_FAILED_MASK ) + { + err = -EIO; + DBGC ( nic, "FW Restart failed" ); + DBGC ( nic, "status = 0x%x", status ); + goto err_exit; + } + + if ( ATL_READ_REG ( ATL2_HOST_ITR_REQ ) + & ATL2_FW_HOST_INTERRUPT_REQUEST_READY ) + { + err = -ENOTSUP; + DBGC ( nic, "Dynamic FW load not implemented" ); + goto err_exit; + } + + err = atl2_hw_fw_init_ ( nic ); + +err_exit: + return err; +} + +int atl2_hw_start ( struct atl_nic *nic ) { + uint32_t val; + + atl2_hw_read_shared_in_ ( nic, ATL2_LINK_OPTS_IN_OFF, &val, 1 ); + val = 0x4B00FFE1; + atl2_hw_write_shared_in_ ( nic, ATL2_LINK_OPTS_IN_OFF, &val, 1 ); + + return atl2_hw_finish_ack_ ( nic, 100000 ); +} + +int atl2_hw_stop ( struct atl_nic *nic ) { + uint32_t val; + + atl2_hw_read_shared_in_ ( nic, ATL2_LINK_OPTS_IN_OFF, &val, 1 ); + val = 0; + atl2_hw_write_shared_in_ ( nic, ATL2_LINK_OPTS_IN_OFF, &val, 1 ); + + return atl2_hw_finish_ack_ ( nic, 100000 ); +} + +int atl2_hw_get_link ( struct atl_nic *nic ) { + uint32_t val; + + val = ATL_READ_REG ( ATL2_MIF_SHARED_BUF_OUT + ATL2_LINK_STS_OUT_OFF ); + + return ( ( val & 0xf ) != 0 ) && ( ( val & 0xF0 ) != 0 ); +} + +int atl2_hw_get_mac ( struct atl_nic *nic, uint8_t *mac ) { + uint32_t mac_addr[2] = {0}; + + atl2_hw_read_shared_in_ ( nic, ATL2_MAC_ADDR_IN_OFF, mac_addr, 2 ); + + memcpy ( mac, ( uint8_t * )mac_addr, 6 ); + + return 0; +} + +struct atl_hw_ops atl2_hw = { + .reset = atl2_hw_reset, + .start = atl2_hw_start, + .stop = atl2_hw_stop, + .get_link = atl2_hw_get_link, + .get_mac = atl2_hw_get_mac, +}; diff --git a/src/drivers/net/marvell/atl2_hw.h b/src/drivers/net/marvell/atl2_hw.h new file mode 100644 index 000000000..d044c21fa --- /dev/null +++ b/src/drivers/net/marvell/atl2_hw.h @@ -0,0 +1,94 @@ +/* + * Copyright(C) 2017-2024 Marvell + * + * SPDX-License-Identifier: BSD-2-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO,THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __ATL2_HW_H +#define __ATL2_HW_H + +FILE_LICENCE ( BSD2 ); + +#define ATL2_GLB_RST_CTRL2 0x3040 +#define ATL2_HOST_FINISHED_WRITE 0xE00 +#define ATL2_MCP_BUSY_WRITE 0xE04 +#define ATL2_HOST_ITR_REQ 0xF00 + + +#define ATL2_RESET_STATUS_REQ_GSR ( 1U << 0x0 ) +#define ATL2_RESET_STATUS_REQ_HOST_BOOT ( 1U << 0x8 ) +#define ATL2_RESET_STATUS_REQ_MAC_FAST_BOOT ( 1U << 0xA ) +#define ATL2_RESET_STATUS_REQ_PHY_FAST_BOOT ( 1U << 0xB ) + +#define ATL2_RESET_STATUS_HOST_LOAD_COMPLETED ( 1U << 0x10 ) +#define ATL2_RESET_STATUS_REQUIRE_HOST_LOAD ( 1U << 0x11 ) +#define ATL2_RESET_STATUS_BC_STARTED ( 1U << 0x18 ) +#define ATL2_RESET_STATUS_CRASH_DURING_INIT ( 1U << 0x1B ) +#define ATL2_RESET_STATUS_BC_FAILED ( 1U << 0x1C ) +#define ATL2_RESET_STATUS_FW_FAILED ( 1U << 0x1D ) +#define ATL2_RESET_STATUS_FW_SUCCEED ( 1U << 0x1F ) + +#define ATL2_RESET_STATUS_BOOT_FAILED_MASK ( ATL2_RESET_STATUS_CRASH_DURING_INIT | ATL2_RESET_STATUS_BC_FAILED | ATL2_RESET_STATUS_FW_FAILED ) +#define ATL2_RESET_STATUS_BOOT_COMPLETED_MASK ( ATL2_RESET_STATUS_BOOT_FAILED_MASK | ATL2_RESET_STATUS_FW_SUCCEED ) + +#define ATL2_FW_HOST_INTERRUPT_REQUEST_READY 0x0001 +#define ATL2_FW_HOST_INTERRUPT_MAC_READY 0x0004 +#define ATL2_FW_HOST_INTERRUPT_DATA_HANDLED 0x0100 +#define ATL2_FW_HOST_INTERRUPT_LINK_UP 0x0200 +#define ATL2_FW_HOST_INTERRUPT_LINK_DOWN 0x0400 +#define ATL2_FW_HOST_INTERRUPT_PHY_FAULT 0x0800 +#define ATL2_FW_HOST_INTERRUPT_MAC_FAULT 0x1000 +#define ATL2_FW_HOST_INTERRUPT_TEMPERATURE_WARNING 0x2000 +#define ATL2_FW_HOST_INTERRUPT_HEARTBEAT 0x4000 + +#define ATL2_FW_LINK_RATE_INVALID 0 +#define ATL2_FW_LINK_RATE_10M 1 +#define ATL2_FW_LINK_RATE_100M 2 +#define ATL2_FW_LINK_RATE_1G 3 +#define ATL2_FW_LINK_RATE_2G5 4 +#define ATL2_FW_LINK_RATE_5G 5 +#define ATL2_FW_LINK_RATE_10G 6 + +#define ATL2_HOST_MODE_INVALID 0U +#define ATL2_HOST_MODE_ACTIVE 1U +#define ATL2_HOST_MODE_SLEEP_PROXY 2U +#define ATL2_HOST_MODE_LOW_POWER 3U +#define ATL2_HOST_MODE_SHUTDOWN 4U + +#define ATL2_MIF_SHARED_BUF_IN 0x12000 +#define ATL2_MIF_SHARED_BUF_OUT 0x13000 + +#define ATL2_MTU_IN_OFF 0x0 +#define ATL2_MAC_ADDR_IN_OFF 0x8 +#define ATL2_LINK_CTRL_IN_OFF 0x10 +#define ATL2_LINK_OPTS_IN_OFF 0x18 + +#define ATL2_FW_OUT_OFF 0x8 +#define ATL2_LINK_STS_OUT_OFF 0x14 + +#define ATL2_DELAY_10 10 +#define ATL2_DELAY_100 100 + +#endif diff --git a/src/drivers/net/marvell/atl_hw.c b/src/drivers/net/marvell/atl_hw.c new file mode 100644 index 000000000..e0843e6f4 --- /dev/null +++ b/src/drivers/net/marvell/atl_hw.c @@ -0,0 +1,313 @@ +/** @file + * + * Marvell AQtion family network card driver, hardware-specific functions. + * + * Copyright(C) 2017-2024 Marvell + * + * SPDX-License-Identifier: BSD-2-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO,THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +FILE_LICENCE ( BSD2 ); + +#include +#include +#include +#include +#include +#include "aqc1xx.h" +#include "atl_hw.h" +#include + + +int atl_hw_reset_flb_ ( struct atl_nic *nic ) { + uint32_t val; + int k = 0; + + ATL_WRITE_REG ( ATL_GLB_CTRL2_MBOX_ERR_UP_RUN_STALL, ATL_GLB_CTRL2 ); + mdelay ( ATL_DELAY_50_MNS ); + + /* Cleanup SPI */ + val = ATL_READ_REG ( ATL_GLB_NVR_PROV4 ); + ATL_WRITE_REG ( val | ATL_GBL_NVR_PROV4_RESET, ATL_GLB_NVR_PROV4 ); + + ATL_WRITE_REG( ( ATL_READ_REG ( ATL_GLB_STD_CTRL ) & + ~ATL_GLB_CTRL_RST_DIS ) | ATL_GLB_STD_CTRL_RESET, + ATL_GLB_STD_CTRL ); + + /* Kickstart MAC */ + ATL_WRITE_REG ( ATL_GLB_CTRL2_FW_RESET, ATL_GLB_CTRL2 ); + ATL_WRITE_REG ( ATL_MIF_PWR_GATING_EN_CTRL_RESET, + ATL_MIF_PWR_GATING_EN_CTRL ); + + ATL_WRITE_REG ( ATL_GEN_PROV9_ENABLE, ATL_GEN_PROV9 ); + + /* Reset SPI again because of possible interrupted SPI burst */ + val = ATL_READ_REG ( ATL_GLB_NVR_PROV4 ); + ATL_WRITE_REG ( val | ATL_GBL_NVR_PROV4_RESET, ATL_GLB_NVR_PROV4 ); + mdelay ( ATL_DELAY_10_MNS ); + /* Clear SPI reset state */ + ATL_WRITE_REG ( val & ~ATL_GBL_NVR_PROV4_RESET, ATL_GLB_NVR_PROV4 ); + + /* MAC Kickstart */ + ATL_WRITE_REG ( ATL_GLB_CTRL2_MAC_KICK_START, ATL_GLB_CTRL2 ); + + for (k = 0; k < 1000; k++) { + uint32_t flb_status = ATL_READ_REG ( ATL_MPI_DAISY_CHAIN_STS ); + + flb_status = flb_status & FLB_LOAD_STS; + if ( flb_status ) + break; + mdelay ( ATL_DELAY_10_MNS ); + } + if ( k == 1000 ) { + DBGC (nic, "MAC kickstart failed\n" ); + return -EIO; + } + + /* FW reset */ + ATL_WRITE_REG ( ATL_GLB_CTRL2_FW_RESET, ATL_GLB_CTRL2 ); + mdelay ( ATL_DELAY_50_MNS ); + + ATL_WRITE_REG ( ATL_GBL_MCP_SEM1_RELEASE, ATL_GLB_MCP_SEM1 ); + + /* Global software reset*/ + ATL_WRITE_REG ( ATL_READ_REG ( ATL_RX_CTRL ) & + ~ATL_RX_CTRL_RST_DIS, ATL_RX_CTRL ); + ATL_WRITE_REG ( ATL_READ_REG ( ATL_TX_CTRL ) & + ~ATL_TX_CTRL_RST_DIS, ATL_TX_CTRL ); + + ATL_WRITE_REG ( ATL_READ_REG ( ATL_MAC_PHY_CTRL ) & + ~ATL_MAC_PHY_CTRL_RST_DIS, ATL_MAC_PHY_CTRL ); + + ATL_WRITE_REG ( ( ATL_READ_REG ( ATL_GLB_STD_CTRL ) & + ~ATL_GLB_CTRL_RST_DIS ) | ATL_GLB_STD_CTRL_RESET, + ATL_GLB_STD_CTRL ); + + for (k = 0; k < 1000; k++) { + u32 fw_state = ATL_READ_REG ( ATL_FW_VER ); + + if ( fw_state ) + break; + mdelay ( ATL_DELAY_10_MNS ); + } + if ( k == 1000 ) { + DBGC ( nic, "FW kickstart failed\n" ); + return -EIO; + } + /* Old FW requires fixed delay after init */ + mdelay ( ATL_DELAY_15_MNS ); + + return 0; +} + +int atl_hw_reset_rbl_ ( struct atl_nic *nic ) { + uint32_t val, rbl_status; + int k; + + ATL_WRITE_REG ( ATL_GLB_CTRL2_MBOX_ERR_UP_RUN_STALL, ATL_GLB_CTRL2 ); + ATL_WRITE_REG ( ATL_GBL_MCP_SEM1_RELEASE, ATL_GLB_MCP_SEM1 ); + ATL_WRITE_REG ( ATL_MIF_PWR_GATING_EN_CTRL_RESET, + ATL_MIF_PWR_GATING_EN_CTRL ); + + /* Alter RBL status */ + ATL_WRITE_REG ( POISON_SIGN, ATL_MPI_BOOT_EXIT_CODE ); + + /* Cleanup SPI */ + val = ATL_READ_REG ( ATL_GLB_NVR_PROV4 ); + ATL_WRITE_REG ( val | ATL_GBL_NVR_PROV4_RESET, ATL_GLB_NVR_PROV4 ); + + /* Global software reset*/ + ATL_WRITE_REG ( ATL_READ_REG ( ATL_RX_CTRL ) & ~ATL_RX_CTRL_RST_DIS, + ATL_RX_CTRL ); + ATL_WRITE_REG ( ATL_READ_REG ( ATL_TX_CTRL ) & ~ATL_TX_CTRL_RST_DIS, + ATL_TX_CTRL ); + ATL_WRITE_REG ( ATL_READ_REG ( ATL_MAC_PHY_CTRL ) & + ~ATL_MAC_PHY_CTRL_RST_DIS, ATL_MAC_PHY_CTRL ); + + ATL_WRITE_REG ( ( ATL_READ_REG ( ATL_GLB_STD_CTRL ) & + ~ATL_GLB_CTRL_RST_DIS ) | ATL_GLB_STD_CTRL_RESET, + ATL_GLB_STD_CTRL ); + + ATL_WRITE_REG ( ATL_GLB_CTRL2_MBOX_ERR_UP_RUN_NORMAL, ATL_GLB_CTRL2 ); + + /* Wait for RBL boot */ + for ( k = 0; k < 1000; k++ ) { + rbl_status = ATL_READ_REG ( ATL_MPI_BOOT_EXIT_CODE ) & 0xFFFF; + if ( rbl_status && rbl_status != POISON_SIGN ) + break; + mdelay ( ATL_DELAY_10_MNS ); + } + if ( !rbl_status || rbl_status == POISON_SIGN ) { + DBGC ( nic, "RBL Restart failed\n" ); + return -EIO; + } + + if ( rbl_status == FW_NOT_SUPPORT ) + return -ENOTSUP; + + for ( k = 0; k < 1000; k++ ) { + u32 fw_state = ATL_READ_REG ( ATL_FW_VER ); + + if ( fw_state ) + break; + mdelay ( ATL_DELAY_10_MNS ); + } + if ( k == 1000 ) { + DBGC ( nic, "FW kickstart failed\n" ); + return -EIO; + } + /* Old FW requires fixed delay after init */ + mdelay ( ATL_DELAY_15_MNS ); + + return 0; +} + +int atl_hw_reset ( struct atl_nic *nic ) { + uint32_t boot_exit_code = 0; + uint32_t k; + int rbl_enabled; + uint32_t fw_ver; + uint32_t sem_timeout; + + for ( k = 0; k < 1000; ++k ) { + uint32_t flb_status = ATL_READ_REG ( ATL_MPI_DAISY_CHAIN_STS ); + boot_exit_code = ATL_READ_REG ( ATL_MPI_BOOT_EXIT_CODE ); + if ( flb_status != ATL_MPI_DAISY_CHAIN_STS_ERROR_STATUS || + boot_exit_code != 0 ) + break; + } + + if ( k == 1000 ) { + DBGC ( nic, "Neither RBL nor FLB firmware started\n" ); + return -ENOTSUP; + } + + rbl_enabled = ( boot_exit_code != 0 ); + + fw_ver = ATL_READ_REG ( ATL_FW_VER ); + if ( ( ( fw_ver >> 24 ) & 0xFF ) >= 4 ) { + sem_timeout = ATL_READ_REG ( ATL_SEM_TIMEOUT ); + if ( sem_timeout > ATL_SEM_MAX_TIMEOUT ) + sem_timeout = ATL_SEM_MAX_TIMEOUT; + + for ( k = 0; k < sem_timeout; ++k ) { + if ( ATL_READ_REG ( ATL_GLB_MCP_SEM4 ) ) + break; + + mdelay ( ATL_DELAY_1_MNS ); + } + for ( k = 0; k < sem_timeout; ++k ) { + if ( ATL_READ_REG ( ATL_GLB_MCP_SEM5 ) ) + break; + + mdelay ( ATL_DELAY_1_MNS ); + } + } + + + if ( rbl_enabled ) + return atl_hw_reset_rbl_ ( nic ); + else + return atl_hw_reset_flb_ ( nic ); +} + +int atl_hw_start ( struct atl_nic *nic ) { + ATL_WRITE_REG ( ATL_LINK_ADV_AUTONEG, ATL_LINK_ADV ); + return 0; +} + +int atl_hw_stop ( struct atl_nic *nic ) { + ATL_WRITE_REG ( ATL_SHUT_LINK, ATL_LINK_ADV ); + return 0; +} + +int atl_hw_get_link ( struct atl_nic *nic ) { + return ( ATL_READ_REG ( ATL_LINK_ST) & ATL_LINK_ADV_AUTONEG ) != 0; +} + +int atl_hw_read_mem ( struct atl_nic *nic, uint32_t addr, uint32_t *buffer, + uint32_t size ) { + uint32_t i; + + for ( i = 0; i < 100; ++i ) { + if ( ATL_READ_REG( ATL_SEM_RAM ) ) + break; + mdelay ( ATL_DELAY_1_MNS ); + } + if ( i == 100 ) { + DBGC ( nic, "Semaphore Register not set\n" ); + return -EIO; + } + + ATL_WRITE_REG ( addr, ATL_MBOX_CTRL3 ); + + for ( i = 0; i < size; ++i, addr += 4 ) { + uint32_t j; + + ATL_WRITE_REG ( ATL_MBOX_CTRL1_START_MBOX_OPT, ATL_MBOX_CTRL1 ); + for ( j = 0; j < 10000; ++j ) { + if ( ATL_READ_REG (ATL_MBOX_CTRL3 ) != addr ) + break; + udelay ( ATL_DELAY_10_MNS ); + } + if ( j == 10000 ) { + DBGC ( nic, "Reading from CTRL3 Register Failed\n" ); + return -EIO; + } + + buffer[i] = ATL_READ_REG ( ATL_MBOX_CTRL5 ); + } + + ATL_WRITE_REG( ATL_SEM_RAM_RESET, ATL_SEM_RAM ); + + return 0; +} + +int atl_hw_get_mac ( struct atl_nic *nic, uint8_t *mac ) { + uint32_t mac_addr[2] = {0}; + int err = 0; + uint32_t efuse_addr = ATL_READ_REG ( ATL_GLB_MCP_SP26 ); + + if ( efuse_addr != 0) { + uint32_t mac_efuse_addr = efuse_addr + 40 * sizeof ( uint32_t ); + err = atl_hw_read_mem ( nic, mac_efuse_addr, mac_addr, 2 ); + if ( err != 0 ) + return err; + + mac_addr[0] = cpu_to_be32 ( mac_addr[0] ); + mac_addr[1] = cpu_to_be32 ( mac_addr[1] ); + + memcpy ( mac, ( uint8_t * )mac_addr, ATL_MAC_ADDRESS_SIZE ); + } + return 0; +} + +struct atl_hw_ops atl_hw = { + .reset = atl_hw_reset, + .start = atl_hw_start, + .stop = atl_hw_stop, + .get_link = atl_hw_get_link, + .get_mac = atl_hw_get_mac, +}; diff --git a/src/drivers/net/marvell/atl_hw.h b/src/drivers/net/marvell/atl_hw.h new file mode 100644 index 000000000..efc9f86c1 --- /dev/null +++ b/src/drivers/net/marvell/atl_hw.h @@ -0,0 +1,83 @@ +/* + * Copyright(C) 2017-2024 Marvell + * + * SPDX-License-Identifier: BSD-2-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO,THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef __ATL_HW_H +#define __ATL_HW_H + +FILE_LICENCE ( BSD2 ); + +#define ATL_GLB_STD_CTRL 0x0 +#define ATL_GLB_CTRL_RST_DIS 0x4000 +#define ATL_FW_VER 0x18 + +#define ATL_MPI_DAISY_CHAIN_STS 0x704 +#define ATL_MPI_RX_DAISY_CHAIN_DATA 0x04000000 +#define ATL_MPI_RX_DAISY_CHAIN_SOF 0x02000000 +#define FLB_LOAD_STS 0x10 + +#define ATL_MPI_BOOT_EXIT_CODE 0x388 + +#define ATL_SEM_TIMEOUT 0x348 +#define ATL_SEM_MAX_TIMEOUT 3000 + +#define ATL_GLB_CTRL2 0x404 +#define ATL_GLB_MCP_SEM1 0x3A0 +#define ATL_GBL_MCP_SEM1_RELEASE 0x1 + +#define ATL_GLB_MCP_SEM4 0x3AC +#define ATL_GLB_MCP_SEM5 0x3B0 +#define ATL_GLB_MCP_SP26 0x364 +#define ATL_MIF_PWR_GATING_EN_CTRL 0x32A8 + +#define ATL_GLB_NVR_PROV4 0x53C +#define ATL_GBL_NVR_PROV4_RESET 0x10 + + +#define ATL_GEN_PROV9 0x520 + +#define ATL_MAC_PHY_CTRL 0x00004000U +#define ATL_MAC_PHY_CTRL_RST_DIS 0x20000000U + +#define ATL_MIF_PWR_GATING_EN_CTRL_RESET 0x0 +#define ATL_GEN_PROV9_ENABLE 0x1 +#define ATL_GLB_CTRL2_MAC_KICK_START 0x180e0 +#define ATL_GLB_CTRL2_FW_RESET 0x80e0 +#define ATL_GLB_CTRL2_MBOX_ERR_UP_RUN_STALL 0x40e1 +#define ATL_GLB_CTRL2_MBOX_ERR_UP_RUN_NORMAL 0x40e0 +#define ATL_GLB_STD_CTRL_RESET 0x8000 +#define ATL_MPI_DAISY_CHAIN_STS_ERROR_STATUS 0x06000000 + +#define ATL_DELAY_1_MNS 1 +#define ATL_DELAY_10_MNS 10 +#define ATL_DELAY_15_MNS 15 +#define ATL_DELAY_50_MNS 50 + +#define ATL_MAC_ADDRESS_SIZE 6 +#define POISON_SIGN 0xDEAD +#define FW_NOT_SUPPORT 0xF1A7 + +#endif diff --git a/src/include/ipxe/errfile.h b/src/include/ipxe/errfile.h index 7615075bc..42bc17789 100644 --- a/src/include/ipxe/errfile.h +++ b/src/include/ipxe/errfile.h @@ -225,6 +225,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define ERRFILE_pcibridge ( ERRFILE_DRIVER | 0x00d40000 ) #define ERRFILE_mnpnet ( ERRFILE_DRIVER | 0x00d50000 ) #define ERRFILE_gve ( ERRFILE_DRIVER | 0x00d60000 ) +#define ERRFILE_aqc1xx ( ERRFILE_DRIVER | 0x00d70000 ) +#define ERRFILE_atl_hw ( ERRFILE_DRIVER | 0x00d80000 ) +#define ERRFILE_atl2_hw ( ERRFILE_DRIVER | 0x00d90000 ) #define ERRFILE_aoe ( ERRFILE_NET | 0x00000000 ) #define ERRFILE_arp ( ERRFILE_NET | 0x00010000 ) -- cgit v1.2.3-55-g7522 From f88761ef491c16a33078e46ad9d49ebd8f36fd47 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 5 Sep 2024 14:01:19 +0100 Subject: [ena] Change reported operating system type to "iPXE" As described in commit 3b81a4e ("[ena] Provide a host information page"), we currently report an operating system type of "Linux" in order to work around broken versions of the ENA firmware that will fail to create a completion queue if we report the correct operating system type. As of September 2024, the ENA team at AWS assures us that the entire AWS fleet has been upgraded to fix this bug, and that we are now safe to report the correct operating system type value in the "type" field of struct ena_host_info. The ENA team has also clarified that at least some deployed versions of the ENA firmware still have the defect that requires us to report an operating system version number of 2 (regardless of operating system type), and so we continue to report ENA_HOST_INFO_VERSION_WTF in the "version" field of struct ena_host_info. Add an explicit warning on the previous known failure path, in case some deployed versions of the ENA firmware turn out to not have been upgraded as expected. Signed-off-by: Michael Brown --- src/drivers/net/ena.c | 7 +++++-- src/drivers/net/ena.h | 15 +++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/ena.c b/src/drivers/net/ena.c index 7ce5b9eb9..89483eae1 100644 --- a/src/drivers/net/ena.c +++ b/src/drivers/net/ena.c @@ -560,8 +560,11 @@ static int ena_create_cq ( struct ena_nic *ena, struct ena_cq *cq ) { req->create_cq.address = cpu_to_le64 ( virt_to_bus ( cq->cqe.raw ) ); /* Issue request */ - if ( ( rc = ena_admin ( ena, req, &rsp ) ) != 0 ) + if ( ( rc = ena_admin ( ena, req, &rsp ) ) != 0 ) { + DBGC ( ena, "ENA %p CQ%d creation failed (broken firmware?)\n", + ena, cq->id ); goto err_admin; + } /* Parse response */ cq->id = le16_to_cpu ( rsp->create_cq.id ); @@ -1163,7 +1166,7 @@ static int ena_probe ( struct pci_device *pci ) { } ena->info = info; memset ( info, 0, PAGE_SIZE ); - info->type = cpu_to_le32 ( ENA_HOST_INFO_TYPE_LINUX ); + info->type = cpu_to_le32 ( ENA_HOST_INFO_TYPE_IPXE ); snprintf ( info->dist_str, sizeof ( info->dist_str ), "%s", ( product_name[0] ? product_name : product_short_name ) ); snprintf ( info->kernel_str, sizeof ( info->kernel_str ), "%s", diff --git a/src/drivers/net/ena.h b/src/drivers/net/ena.h index 0f280c700..9fda9979f 100644 --- a/src/drivers/net/ena.h +++ b/src/drivers/net/ena.h @@ -191,14 +191,17 @@ struct ena_host_info { uint32_t features; } __attribute__ (( packed )); -/** Linux operating system type +/** Operating system type * - * There is a defined "iPXE" operating system type (with value 5). - * However, some very broken versions of the ENA firmware will refuse - * to allow a completion queue to be created if the "iPXE" type is - * used. + * Some very broken older versions of the ENA firmware will refuse to + * allow a completion queue to be created if "iPXE" (type 5) is used, + * and require us to pretend that we are "Linux" (type 1) instead. + * + * The ENA team at AWS assures us that the entire AWS fleet has been + * upgraded to fix this bug, and that we are now safe to use the + * correct operating system type value. */ -#define ENA_HOST_INFO_TYPE_LINUX 1 +#define ENA_HOST_INFO_TYPE_IPXE 5 /** Driver version * -- cgit v1.2.3-55-g7522 From 59d123658bfe25402c4e89bbaf6eea83140d3c1f Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 17 Sep 2024 13:11:43 +0100 Subject: [gve] Allocate all possible event counters The admin queue API requires us to tell the device how many event counters we have provided via the "configure device resources" admin queue command. There is, of course, absolutely no documentation indicating how many event counters actually need to be provided. We require only two event counters: one for the transmit queue, one for the receive queue. (The receive queue doesn't seem to actually make any use of its event counter, but the "create receive queue" admin queue command will fail if it doesn't have an available event counter to choose.) In the absence of any documentation, we currently make the assumption that allocating and configuring 16 counters (i.e. one whole cacheline) will be sufficient to allow for the use of two counters. This assumption turns out to be incorrect. On larger instance types (observed with a c3d-standard-16 instance in europe-west4-a), we find that creating the transmit or receive queues will each fail with a probability of around 50% with the "failed precondition" error code. Experimentation suggests that even though the device has accepted our "configure device resources" command indicating that we are providing only 16 event counters, it will attempt to choose any of its potential 32 event counters (and will then fail since the event counter that it unilaterally chose is outside of the agreed range). Work around this firmware bug by always allocating the maximum number of event counters supported by the device. (This requires deferring the allocation of the event counters until after issuing the "describe device" command.) Signed-off-by: Michael Brown --- src/drivers/net/gve.c | 115 +++++++++++++++++++++++++++++++++----------------- src/drivers/net/gve.h | 25 ----------- 2 files changed, 76 insertions(+), 64 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/gve.c b/src/drivers/net/gve.c index 0193e769f..df10a94c6 100644 --- a/src/drivers/net/gve.c +++ b/src/drivers/net/gve.c @@ -191,12 +191,8 @@ static int gve_reset ( struct gve_nic *gve ) { static int gve_admin_alloc ( struct gve_nic *gve ) { struct dma_device *dma = gve->dma; struct gve_admin *admin = &gve->admin; - struct gve_irqs *irqs = &gve->irqs; - struct gve_events *events = &gve->events; struct gve_scratch *scratch = &gve->scratch; size_t admin_len = ( GVE_ADMIN_COUNT * sizeof ( admin->cmd[0] ) ); - size_t irqs_len = ( GVE_IRQ_COUNT * sizeof ( irqs->irq[0] ) ); - size_t events_len = ( GVE_EVENT_MAX * sizeof ( events->event[0] ) ); size_t scratch_len = sizeof ( *scratch->buf ); int rc; @@ -207,20 +203,6 @@ static int gve_admin_alloc ( struct gve_nic *gve ) { goto err_admin; } - /* Allocate interrupt channels */ - irqs->irq = dma_alloc ( dma, &irqs->map, irqs_len, GVE_ALIGN ); - if ( ! irqs->irq ) { - rc = -ENOMEM; - goto err_irqs; - } - - /* Allocate event counters */ - events->event = dma_alloc ( dma, &events->map, events_len, GVE_ALIGN ); - if ( ! events->event ) { - rc = -ENOMEM; - goto err_events; - } - /* Allocate scratch buffer */ scratch->buf = dma_alloc ( dma, &scratch->map, scratch_len, GVE_ALIGN ); if ( ! scratch->buf ) { @@ -228,17 +210,15 @@ static int gve_admin_alloc ( struct gve_nic *gve ) { goto err_scratch; } - DBGC ( gve, "GVE %p AQ at [%08lx,%08lx)\n", + DBGC ( gve, "GVE %p AQ at [%08lx,%08lx) scratch [%08lx,%08lx)\n", gve, virt_to_phys ( admin->cmd ), - ( virt_to_phys ( admin->cmd ) + admin_len ) ); + ( virt_to_phys ( admin->cmd ) + admin_len ), + virt_to_phys ( scratch->buf ), + ( virt_to_phys ( scratch->buf ) + scratch_len ) ); return 0; dma_free ( &scratch->map, scratch->buf, scratch_len ); err_scratch: - dma_free ( &events->map, events->event, events_len ); - err_events: - dma_free ( &irqs->map, irqs->irq, irqs_len ); - err_irqs: dma_free ( &admin->map, admin->cmd, admin_len ); err_admin: return rc; @@ -251,23 +231,13 @@ static int gve_admin_alloc ( struct gve_nic *gve ) { */ static void gve_admin_free ( struct gve_nic *gve ) { struct gve_admin *admin = &gve->admin; - struct gve_irqs *irqs = &gve->irqs; - struct gve_events *events = &gve->events; struct gve_scratch *scratch = &gve->scratch; size_t admin_len = ( GVE_ADMIN_COUNT * sizeof ( admin->cmd[0] ) ); - size_t irqs_len = ( GVE_IRQ_COUNT * sizeof ( irqs->irq[0] ) ); - size_t events_len = ( GVE_EVENT_MAX * sizeof ( events->event[0] ) ); size_t scratch_len = sizeof ( *scratch->buf ); /* Free scratch buffer */ dma_free ( &scratch->map, scratch->buf, scratch_len ); - /* Free event counter */ - dma_free ( &events->map, events->event, events_len ); - - /* Free interrupt channels */ - dma_free ( &irqs->map, irqs->irq, irqs_len ); - /* Free admin queue */ dma_free ( &admin->map, admin->cmd, admin_len ); } @@ -467,13 +437,10 @@ static int gve_describe ( struct gve_nic *gve ) { /* Extract queue parameters */ gve->events.count = be16_to_cpu ( desc->counters ); - if ( gve->events.count > GVE_EVENT_MAX ) - gve->events.count = GVE_EVENT_MAX; gve->tx.count = be16_to_cpu ( desc->tx_count ); gve->rx.count = be16_to_cpu ( desc->rx_count ); - DBGC ( gve, "GVE %p using %d TX, %d RX, %d/%d events\n", - gve, gve->tx.count, gve->rx.count, gve->events.count, - be16_to_cpu ( desc->counters ) ); + DBGC ( gve, "GVE %p using %d TX, %d RX, %d events\n", + gve, gve->tx.count, gve->rx.count, gve->events.count ); /* Extract network parameters */ build_assert ( sizeof ( desc->mac ) == ETH_ALEN ); @@ -704,6 +671,67 @@ static int gve_destroy_queue ( struct gve_nic *gve, struct gve_queue *queue ) { ****************************************************************************** */ +/** + * Allocate shared queue resources + * + * @v gve GVE device + * @ret rc Return status code + */ +static int gve_alloc_shared ( struct gve_nic *gve ) { + struct dma_device *dma = gve->dma; + struct gve_irqs *irqs = &gve->irqs; + struct gve_events *events = &gve->events; + size_t irqs_len = ( GVE_IRQ_COUNT * sizeof ( irqs->irq[0] ) ); + size_t events_len = ( gve->events.count * sizeof ( events->event[0] ) ); + int rc; + + /* Allocate interrupt channels */ + irqs->irq = dma_alloc ( dma, &irqs->map, irqs_len, GVE_ALIGN ); + if ( ! irqs->irq ) { + rc = -ENOMEM; + goto err_irqs; + } + DBGC ( gve, "GVE %p IRQs at [%08lx,%08lx)\n", + gve, virt_to_phys ( irqs->irq ), + ( virt_to_phys ( irqs->irq ) + irqs_len ) ); + + /* Allocate event counters */ + events->event = dma_alloc ( dma, &events->map, events_len, GVE_ALIGN ); + if ( ! events->event ) { + rc = -ENOMEM; + goto err_events; + } + DBGC ( gve, "GVE %p events at [%08lx,%08lx)\n", + gve, virt_to_phys ( events->event ), + ( virt_to_phys ( events->event ) + events_len ) ); + + return 0; + + dma_free ( &events->map, events->event, events_len ); + err_events: + dma_free ( &irqs->map, irqs->irq, irqs_len ); + err_irqs: + return rc; +} + +/** + * Free shared queue resources + * + * @v gve GVE device + */ +static void gve_free_shared ( struct gve_nic *gve ) { + struct gve_irqs *irqs = &gve->irqs; + struct gve_events *events = &gve->events; + size_t irqs_len = ( GVE_IRQ_COUNT * sizeof ( irqs->irq[0] ) ); + size_t events_len = ( gve->events.count * sizeof ( events->event[0] ) ); + + /* Free event counters */ + dma_free ( &events->map, events->event, events_len ); + + /* Free interrupt channels */ + dma_free ( &irqs->map, irqs->irq, irqs_len ); +} + /** * Allocate queue page list * @@ -1117,6 +1145,10 @@ static int gve_open ( struct net_device *netdev ) { struct gve_queue *rx = &gve->rx; int rc; + /* Allocate shared queue resources */ + if ( ( rc = gve_alloc_shared ( gve ) ) != 0 ) + goto err_alloc_shared; + /* Allocate and prepopulate transmit queue */ if ( ( rc = gve_alloc_queue ( gve, tx ) ) != 0 ) goto err_alloc_tx; @@ -1137,6 +1169,8 @@ static int gve_open ( struct net_device *netdev ) { err_alloc_rx: gve_free_queue ( gve, tx ); err_alloc_tx: + gve_free_shared ( gve ); + err_alloc_shared: return rc; } @@ -1163,6 +1197,9 @@ static void gve_close ( struct net_device *netdev ) { /* Free queues */ gve_free_queue ( gve, rx ); gve_free_queue ( gve, tx ); + + /* Free shared queue resources */ + gve_free_shared ( gve ); } /** diff --git a/src/drivers/net/gve.h b/src/drivers/net/gve.h index 247d6e699..43517cc55 100644 --- a/src/drivers/net/gve.h +++ b/src/drivers/net/gve.h @@ -50,15 +50,6 @@ struct google_mac { */ #define GVE_ALIGN GVE_PAGE_SIZE -/** - * Length alignment - * - * All DMA data structure lengths seem to need to be aligned to a - * multiple of 64 bytes. (This is not documented anywhere, but is - * inferred from existing source code and experimentation.) - */ -#define GVE_LEN_ALIGN 64 - /** Configuration BAR */ #define GVE_CFG_BAR PCI_BASE_ADDRESS_0 @@ -350,22 +341,6 @@ struct gve_event { volatile uint32_t count; } __attribute__ (( packed )); -/** - * Maximum number of event counters - * - * We tell the device how many event counters we have provided via the - * "configure device resources" admin queue command. The device will - * accept being given only a single counter, but will subsequently - * fail to create a receive queue. - * - * There is, of course, no documentation indicating how may event - * counters actually need to be provided. In the absence of evidence - * to the contrary, assume that 16 counters (i.e. the smallest number - * we can allocate, given the length alignment constraint on - * allocations) will be sufficient. - */ -#define GVE_EVENT_MAX ( GVE_LEN_ALIGN / sizeof ( struct gve_event ) ) - /** Event counter array */ struct gve_events { /** Event counters */ -- cgit v1.2.3-55-g7522 From c219b5d8a9536cc87e9c53e8389e59c706ba3f8e Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 17 Oct 2024 14:05:25 +0100 Subject: [usb] Add "usbscan" command for iterating over USB devices Implement a "usbscan" command as a direct analogy of the existing "pciscan" command, allowing scripts to iterate over all detected USB devices. Signed-off-by: Michael Brown --- src/config/config.c | 3 ++ src/config/general.h | 1 + src/drivers/bus/usb.c | 75 +++++++++++++++++++++++++++- src/hci/commands/usb_cmd.c | 122 +++++++++++++++++++++++++++++++++++++++++++++ src/include/ipxe/errfile.h | 1 + src/include/ipxe/usb.h | 25 ++++++++++ 6 files changed, 225 insertions(+), 2 deletions(-) create mode 100644 src/hci/commands/usb_cmd.c (limited to 'src/drivers') diff --git a/src/config/config.c b/src/config/config.c index f532c1d2d..0f950eb9d 100644 --- a/src/config/config.c +++ b/src/config/config.c @@ -302,6 +302,9 @@ REQUIRE_OBJECT ( shim_cmd ); #ifdef IMAGE_CRYPT_CMD REQUIRE_OBJECT ( image_crypt_cmd ); #endif +#ifdef USB_CMD +REQUIRE_OBJECT ( usb_cmd ); +#endif /* * Drag in miscellaneous objects diff --git a/src/config/general.h b/src/config/general.h index b82e5602c..763a34aa0 100644 --- a/src/config/general.h +++ b/src/config/general.h @@ -171,6 +171,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); //#define IMAGE_MEM_CMD /* Read memory command */ #define IMAGE_ARCHIVE_CMD /* Archive image management commands */ #define SHIM_CMD /* EFI shim command (or dummy command) */ +//#define USB_CMD /* USB commands */ /* * ROM-specific options diff --git a/src/drivers/bus/usb.c b/src/drivers/bus/usb.c index 428ae26c1..e1e7d51f7 100644 --- a/src/drivers/bus/usb.c +++ b/src/drivers/bus/usb.c @@ -1323,7 +1323,8 @@ usb_probe_all ( struct usb_device *usb, func->name = func->dev.name; func->usb = usb; func->dev.desc.bus_type = BUS_TYPE_USB; - func->dev.desc.location = usb->address; + func->dev.desc.location = + USB_BUSDEV ( bus->address, usb->address ); func->dev.desc.vendor = le16_to_cpu ( usb->device.vendor ); func->dev.desc.device = le16_to_cpu ( usb->device.product ); snprintf ( func->dev.name, sizeof ( func->dev.name ), @@ -1725,6 +1726,25 @@ static void free_usb ( struct usb_device *usb ) { free ( usb ); } +/** + * Find USB device by address + * + * @v bus USB bus + * @v address Device address + * @ret usb USB device, or NULL if not found + */ +struct usb_device * find_usb ( struct usb_bus *bus, unsigned int address ) { + struct usb_device *usb; + + /* Search for a matching non-zero address */ + list_for_each_entry ( usb, &bus->devices, list ) { + if ( address && ( usb->address == address ) ) + return usb; + } + + return NULL; +} + /****************************************************************************** * * USB device hotplug event handling @@ -2115,6 +2135,11 @@ int register_usb_bus ( struct usb_bus *bus ) { /* Sanity checks */ assert ( bus->hub != NULL ); + /* Assign the first available bus address */ + bus->address = 0; + while ( find_usb_bus ( bus->address ) != NULL ) + bus->address++; + /* Open bus */ if ( ( rc = bus->host->open ( bus ) ) != 0 ) goto err_open; @@ -2187,6 +2212,23 @@ void free_usb_bus ( struct usb_bus *bus ) { free ( bus ); } +/** + * Find USB bus by address + * + * @v address Bus address + * @ret bus USB bus, or NULL + */ +struct usb_bus * find_usb_bus ( unsigned int address ) { + struct usb_bus *bus; + + for_each_usb_bus ( bus ) { + if ( bus->address == address ) + return bus; + } + + return NULL; +} + /** * Find USB bus by device location * @@ -2209,7 +2251,7 @@ struct usb_bus * find_usb_bus_by_location ( unsigned int bus_type, /****************************************************************************** * - * USB address assignment + * USB device addressing * ****************************************************************************** */ @@ -2250,6 +2292,35 @@ void usb_free_address ( struct usb_bus *bus, unsigned int address ) { bus->addresses &= ~( 1ULL << ( address - 1 ) ); } +/** + * Find next USB device + * + * @v usb USB device to fill in + * @v busdev Starting bus:dev address + * @ret busdev Bus:dev address of next USB device + * @ret rc Return status code + */ +int usb_find_next ( struct usb_device **usb, uint16_t *busdev ) { + struct usb_bus *bus; + + do { + /* Find USB bus, if any */ + bus = find_usb_bus ( USB_BUS ( *busdev ) ); + if ( ! bus ) { + *busdev |= ( USB_BUS ( 1 ) - 1 ); + continue; + } + + /* Find USB device, if any */ + *usb = find_usb ( bus, USB_DEV ( *busdev ) ); + if ( *usb ) + return 0; + + } while ( ++(*busdev) ); + + return -ENODEV; +} + /****************************************************************************** * * USB bus topology diff --git a/src/hci/commands/usb_cmd.c b/src/hci/commands/usb_cmd.c new file mode 100644 index 000000000..d1086fd7e --- /dev/null +++ b/src/hci/commands/usb_cmd.c @@ -0,0 +1,122 @@ +/* + * Copyright (C) 2024 Michael Brown . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + * + * You can also choose to distribute this program under the terms of + * the Unmodified Binary Distribution Licence (as given in the file + * COPYING.UBDL), provided that you have satisfied its requirements. + */ + +#include +#include +#include +#include +#include +#include + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +/** @file + * + * USB commands + * + */ + +/** "usbscan" options */ +struct usbscan_options {}; + +/** "usbscan" option list */ +static struct option_descriptor usbscan_opts[] = {}; + +/** "usbscan" command descriptor */ +static struct command_descriptor usbscan_cmd = + COMMAND_DESC ( struct usbscan_options, usbscan_opts, 1, 1, + "" ); + +/** + * "usbscan" command + * + * @v argc Argument count + * @v argv Argument list + * @ret rc Return status code + */ +static int usbscan_exec ( int argc, char **argv ) { + struct usbscan_options opts; + struct named_setting setting; + struct usb_device *usb; + unsigned long prev; + uint16_t busdev; + int len; + int rc; + + /* Parse options */ + if ( ( rc = parse_options ( argc, argv, &usbscan_cmd, &opts ) ) != 0 ) + goto err_parse_options; + + /* Parse setting name */ + if ( ( rc = parse_autovivified_setting ( argv[optind], + &setting ) ) != 0 ) + goto err_parse_setting; + + /* Determine starting bus:dev.fn address */ + if ( ( len = fetchn_setting ( setting.settings, &setting.setting, + NULL, &setting.setting, &prev ) ) < 0 ) { + /* Setting not yet defined: start searching from 00:00 */ + busdev = 0; + } else { + /* Setting is defined: start searching from next location */ + busdev = ( prev + 1 ); + if ( ! busdev ) { + rc = -ENOENT; + goto err_end; + } + } + + /* Find next existent USB device */ + if ( ( rc = usb_find_next ( &usb, &busdev ) ) != 0 ) + goto err_find_next; + + /* Apply default type if necessary. Use ":uint16" rather than + * ":hex" to allow for easy inclusion within a + * "${usb/${location}....}" constructed setting. + */ + if ( ! setting.setting.type ) + setting.setting.type = &setting_type_uint16; + + /* Store setting */ + if ( ( rc = storen_setting ( setting.settings, &setting.setting, + busdev ) ) != 0 ) { + printf ( "Could not store \"%s\": %s\n", + setting.setting.name, strerror ( rc ) ); + goto err_store; + } + + err_store: + err_end: + err_find_next: + err_parse_setting: + err_parse_options: + return rc; +} + +/** USB commands */ +struct command usb_commands[] __command = { + { + .name = "usbscan", + .exec = usbscan_exec, + }, +}; diff --git a/src/include/ipxe/errfile.h b/src/include/ipxe/errfile.h index 42bc17789..01a2be654 100644 --- a/src/include/ipxe/errfile.h +++ b/src/include/ipxe/errfile.h @@ -423,6 +423,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define ERRFILE_editstring ( ERRFILE_OTHER | 0x00610000 ) #define ERRFILE_widget_ui ( ERRFILE_OTHER | 0x00620000 ) #define ERRFILE_form_ui ( ERRFILE_OTHER | 0x00630000 ) +#define ERRFILE_usb_cmd ( ERRFILE_OTHER | 0x00640000 ) /** @} */ diff --git a/src/include/ipxe/usb.h b/src/include/ipxe/usb.h index 911247ede..d9891b757 100644 --- a/src/include/ipxe/usb.h +++ b/src/include/ipxe/usb.h @@ -54,6 +54,20 @@ enum usb_speed { USB_SPEED_SUPER = USB_SPEED ( 5, 3 ), }; +/** Define a USB bus:device address + * + * @v bus Bus address + * @v dev Device address + * @ret busdev Bus:device address + */ +#define USB_BUSDEV( bus, dev ) ( ( (bus) << 8 ) | (dev) ) + +/** Extract USB bus address */ +#define USB_BUS( busdev ) ( (busdev) >> 8 ) + +/** Extract USB device address */ +#define USB_DEV( busdev ) ( (busdev) & 0xff ) + /** USB packet IDs */ enum usb_pid { /** IN PID */ @@ -956,6 +970,12 @@ struct usb_bus { /** Host controller operations set */ struct usb_host_operations *op; + /** Bus address + * + * This is an internal index used only to allow a USB device + * to be identified via a nominal bus:device address. + */ + unsigned int address; /** Largest transfer allowed on the bus */ size_t mtu; /** Address in-use mask @@ -1269,6 +1289,9 @@ extern struct usb_endpoint_companion_descriptor * usb_endpoint_companion_descriptor ( struct usb_configuration_descriptor *config, struct usb_endpoint_descriptor *desc ); +extern struct usb_device * find_usb ( struct usb_bus *bus, + unsigned int address ); + extern struct usb_hub * alloc_usb_hub ( struct usb_bus *bus, struct usb_device *usb, unsigned int ports, @@ -1285,11 +1308,13 @@ extern struct usb_bus * alloc_usb_bus ( struct device *dev, extern int register_usb_bus ( struct usb_bus *bus ); extern void unregister_usb_bus ( struct usb_bus *bus ); extern void free_usb_bus ( struct usb_bus *bus ); +extern struct usb_bus * find_usb_bus ( unsigned int address ); extern struct usb_bus * find_usb_bus_by_location ( unsigned int bus_type, unsigned int location ); extern int usb_alloc_address ( struct usb_bus *bus ); extern void usb_free_address ( struct usb_bus *bus, unsigned int address ); +extern int usb_find_next ( struct usb_device **usb, uint16_t *busdev ); extern unsigned int usb_route_string ( struct usb_device *usb ); extern struct usb_port * usb_root_hub_port ( struct usb_device *usb ); extern struct usb_port * usb_transaction_translator ( struct usb_device *usb ); -- cgit v1.2.3-55-g7522 From c69f9589cc7543baba08dbabdb5c30104fadaa34 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 18 Oct 2024 13:13:28 +0100 Subject: [usb] Expose USB device descriptor and strings via settings Allow scripts to read basic information from USB device descriptors via the settings mechanism. For example: echo USB vendor ID: ${usb/${busloc}.8.2} echo USB device ID: ${usb/${busloc}.10.2} echo USB manufacturer name: ${usb/${busloc}.14.0} The general syntax is usb/.. where bus:dev is the USB bus:device address (as obtained via the "usbscan" command, or from e.g. ${net0/busloc} for a USB network device), and and select the required portion of the USB device descriptor. Following the usage of SMBIOS settings tags, a of zero may be used to indicate that the byte at contains a USB string descriptor index, and an of zero may be used to indicate that the contains a literal USB string descriptor index. Since the byte at offset zero can never contain a string index, and a literal string index can never be zero, the combination of both and being zero may be used to indicate that the entire device descriptor is to be read as a raw hex dump. Signed-off-by: Michael Brown --- src/config/config_usb.c | 8 ++ src/config/settings.h | 1 + src/drivers/bus/usb.c | 8 +- src/drivers/bus/usb_settings.c | 176 +++++++++++++++++++++++++++++++++++++++++ src/drivers/net/ecm.c | 3 +- src/include/ipxe/errfile.h | 1 + 6 files changed, 191 insertions(+), 6 deletions(-) create mode 100644 src/drivers/bus/usb_settings.c (limited to 'src/drivers') diff --git a/src/config/config_usb.c b/src/config/config_usb.c index b679aeb27..10dec221a 100644 --- a/src/config/config_usb.c +++ b/src/config/config_usb.c @@ -22,6 +22,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include /** @file * @@ -63,3 +64,10 @@ REQUIRE_OBJECT ( usbblk ); #ifdef USB_EFI REQUIRE_OBJECT ( efi_usb ); #endif + +/* + * Drag in USB settings mechanism + */ +#ifdef USB_SETTINGS +REQUIRE_OBJECT ( usb_settings ); +#endif diff --git a/src/config/settings.h b/src/config/settings.h index d7f787d38..7b4af4fdf 100644 --- a/src/config/settings.h +++ b/src/config/settings.h @@ -12,6 +12,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #define PCI_SETTINGS /* PCI device settings */ +#define USB_SETTINGS /* USB device settings */ //#define CPUID_SETTINGS /* CPUID settings */ //#define MEMMAP_SETTINGS /* Memory map settings */ //#define VMWARE_SETTINGS /* VMware GuestInfo settings */ diff --git a/src/drivers/bus/usb.c b/src/drivers/bus/usb.c index e1e7d51f7..b3b361b0d 100644 --- a/src/drivers/bus/usb.c +++ b/src/drivers/bus/usb.c @@ -914,10 +914,9 @@ static unsigned int usb_get_default_language ( struct usb_device *usb ) { */ int usb_get_string_descriptor ( struct usb_device *usb, unsigned int index, unsigned int language, char *buf, size_t len ) { - size_t max = ( len ? ( len - 1 /* NUL */ ) : 0 ); struct { struct usb_descriptor_header header; - uint16_t character[max]; + uint16_t character[len]; } __attribute__ (( packed )) *desc; unsigned int actual; unsigned int i; @@ -952,10 +951,9 @@ int usb_get_string_descriptor ( struct usb_device *usb, unsigned int index, sizeof ( desc->character[0] ) ); /* Copy to buffer */ - for ( i = 0 ; ( ( i < actual ) && ( i < max ) ) ; i++ ) + memset ( buf, 0, len ); + for ( i = 0 ; ( ( i < actual ) && ( i < len ) ) ; i++ ) buf[i] = le16_to_cpu ( desc->character[i] ); - if ( len ) - buf[i] = '\0'; /* Free buffer */ free ( desc ); diff --git a/src/drivers/bus/usb_settings.c b/src/drivers/bus/usb_settings.c new file mode 100644 index 000000000..db6f94d8a --- /dev/null +++ b/src/drivers/bus/usb_settings.c @@ -0,0 +1,176 @@ +/* + * Copyright (C) 2024 Michael Brown . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + * + * You can also choose to distribute this program under the terms of + * the Unmodified Binary Distribution Licence (as given in the file + * COPYING.UBDL), provided that you have satisfied its requirements. + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#include +#include +#include +#include +#include + +/** @file + * + * USB device settings + * + */ + +/** USB device settings scope */ +static const struct settings_scope usb_settings_scope; + +/** + * Check applicability of USB device setting + * + * @v settings Settings block + * @v setting Setting + * @ret applies Setting applies within this settings block + */ +static int usb_settings_applies ( struct settings *settings __unused, + const struct setting *setting ) { + + return ( setting->scope == &usb_settings_scope ); +} + +/** + * Fetch value of USB device setting + * + * @v settings Settings block + * @v setting Setting to fetch + * @v data Buffer to fill with setting data + * @v len Length of buffer + * @ret len Length of setting data, or negative error + */ +static int usb_settings_fetch ( struct settings *settings __unused, + struct setting *setting, + void *data, size_t len ) { + uint8_t *dst = data; + const uint8_t *src; + const uint8_t *desc; + struct usb_bus *bus; + struct usb_device *usb; + int tag_direction; + unsigned int tag_busdev; + unsigned int tag_offset; + unsigned int tag_len; + unsigned int index; + int rc; + + /* Extract parameters from tag */ + tag_direction = ( ( setting->tag & ( 1 << 31 ) ) ? +1 : -1 ); + tag_busdev = ( ( setting->tag >> 16 ) & 0x7fff ); + tag_offset = ( ( setting->tag >> 8 ) & 0xff ); + tag_len = ( ( setting->tag >> 0 ) & 0xff ); + + /* Locate USB device */ + bus = find_usb_bus ( USB_BUS ( tag_busdev ) ); + if ( ! bus ) + return -ENODEV; + usb = find_usb ( bus, USB_DEV ( tag_busdev ) ); + if ( ! usb ) + return -ENODEV; + desc = ( ( const uint8_t * ) &usb->device ); + + /* Following the usage of SMBIOS settings tags, a of + * zero indicates that the byte at contains a string + * index. An of zero indicates that the + * contains a literal string index. + * + * Since the byte at offset zero can never contain a string + * index, and a literal string index can never be zero, the + * combination of both and being zero + * indicates that the entire structure is to be read. + * + * By default we reverse the byte direction since USB values + * are little-endian and iPXE settings are big-endian. We + * invert this default when reading the entire structure. + */ + if ( ( tag_len == 0 ) && ( tag_offset == 0 ) ) { + tag_len = sizeof ( usb->device ); + tag_direction = -tag_direction; + } else if ( ( tag_len == 0 ) || ( tag_offset == 0 ) ) { + index = tag_len; + if ( ( ! index ) && ( tag_offset < sizeof ( usb->device ) ) ) + index = desc[tag_offset]; + if ( ( rc = usb_get_string_descriptor ( usb, index, 0, data, + len ) ) < 0 ) { + return rc; + } + if ( ! setting->type ) + setting->type = &setting_type_string; + return rc; + } + + /* Limit length */ + if ( tag_offset > sizeof ( usb->device ) ) { + tag_len = 0; + } else if ( ( tag_offset + tag_len ) > sizeof ( usb->device ) ) { + tag_len = ( sizeof ( usb->device ) - tag_offset ); + } + + /* Copy data, reversing endianness if applicable */ + dst = data; + src = ( desc + tag_offset ); + if ( tag_direction < 0 ) + src += ( tag_len - 1 ); + if ( len > tag_len ) + len = tag_len; + for ( ; len-- ; src += tag_direction, dst++ ) + *dst = *src; + + /* Set type to ":hexraw" if not already specified */ + if ( ! setting->type ) + setting->type = &setting_type_hexraw; + + return tag_len; +} + +/** USB device settings operations */ +static struct settings_operations usb_settings_operations = { + .applies = usb_settings_applies, + .fetch = usb_settings_fetch, +}; + +/** USB device settings */ +static struct settings usb_settings = { + .refcnt = NULL, + .siblings = LIST_HEAD_INIT ( usb_settings.siblings ), + .children = LIST_HEAD_INIT ( usb_settings.children ), + .op = &usb_settings_operations, + .default_scope = &usb_settings_scope, +}; + +/** Initialise USB device settings */ +static void usb_settings_init ( void ) { + int rc; + + if ( ( rc = register_settings ( &usb_settings, NULL, "usb" ) ) != 0 ) { + DBG ( "USB could not register settings: %s\n", + strerror ( rc ) ); + return; + } +} + +/** USB device settings initialiser */ +struct init_fn usb_settings_init_fn __init_fn ( INIT_NORMAL ) = { + .initialise = usb_settings_init, +}; diff --git a/src/drivers/net/ecm.c b/src/drivers/net/ecm.c index ab1f98370..7b3e92b9b 100644 --- a/src/drivers/net/ecm.c +++ b/src/drivers/net/ecm.c @@ -97,8 +97,9 @@ int ecm_fetch_mac ( struct usb_function *func, int rc; /* Fetch MAC address string */ + buf[ sizeof ( buf ) - 1 ] = '\0'; len = usb_get_string_descriptor ( usb, desc->mac, 0, buf, - sizeof ( buf ) ); + ( sizeof ( buf ) - 1 ) ); if ( len < 0 ) { rc = len; return rc; diff --git a/src/include/ipxe/errfile.h b/src/include/ipxe/errfile.h index 01a2be654..6183e5b7e 100644 --- a/src/include/ipxe/errfile.h +++ b/src/include/ipxe/errfile.h @@ -424,6 +424,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define ERRFILE_widget_ui ( ERRFILE_OTHER | 0x00620000 ) #define ERRFILE_form_ui ( ERRFILE_OTHER | 0x00630000 ) #define ERRFILE_usb_cmd ( ERRFILE_OTHER | 0x00640000 ) +#define ERRFILE_usb_settings ( ERRFILE_OTHER | 0x00650000 ) /** @} */ -- cgit v1.2.3-55-g7522 From cc45ca372c9e297c961ee40911753be89f38170a Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 25 Oct 2024 14:40:28 +0100 Subject: [pci] Drag in PCI settings mechanism only when PCI support is present Allow for the existence of platforms with no PCI bus by including the PCI settings mechanism only if PCI bus support is included. Signed-off-by: Michael Brown --- src/config/config.c | 3 --- src/config/config_pci.c | 36 ++++++++++++++++++++++++++++++++++++ src/drivers/bus/pci.c | 6 ++++++ 3 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 src/config/config_pci.c (limited to 'src/drivers') diff --git a/src/config/config.c b/src/config/config.c index 4cfa5dd41..254bff995 100644 --- a/src/config/config.c +++ b/src/config/config.c @@ -352,9 +352,6 @@ REQUIRE_OBJECT ( efi_bofm ); /* * Drag in relevant settings sources */ -#ifdef PCI_SETTINGS -REQUIRE_OBJECT ( pci_settings ); -#endif #ifdef VMWARE_SETTINGS REQUIRE_OBJECT ( guestinfo ); #endif diff --git a/src/config/config_pci.c b/src/config/config_pci.c new file mode 100644 index 000000000..cb8df712a --- /dev/null +++ b/src/config/config_pci.c @@ -0,0 +1,36 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + * + * You can also choose to distribute this program under the terms of + * the Unmodified Binary Distribution Licence (as given in the file + * COPYING.UBDL), provided that you have satisfied its requirements. + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#include + +/** @file + * + * PCI configuration options + * + */ + +PROVIDE_REQUIRING_SYMBOL(); + +#ifdef PCI_SETTINGS +REQUIRE_OBJECT ( pci_settings ); +#endif diff --git a/src/drivers/bus/pci.c b/src/drivers/bus/pci.c index 05c9a5c26..60740ac18 100644 --- a/src/drivers/bus/pci.c +++ b/src/drivers/bus/pci.c @@ -438,3 +438,9 @@ struct root_device pci_root_device __root_device = { .dev = { .name = "PCI" }, .driver = &pci_root_driver, }; + +/* Drag in objects via pcibus_probe() */ +REQUIRING_SYMBOL ( pcibus_probe ); + +/* Drag in PCI configuration */ +REQUIRE_OBJECT ( config_pci ); -- cgit v1.2.3-55-g7522 From 24db39fb2983ca83ab5c6ee37cb57a4f7f6f94e6 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 3 Dec 2024 13:55:18 +0000 Subject: [gve] Run startup process only while device is open The startup process is scheduled to run when the device is opened and terminated (if still running) when the device is closed. It assumes that the resource allocation performed in gve_open() has taken place, and that the admin and transmit/receive data structure pointers are therefore valid. The process initialisation in gve_probe() erroneously calls process_init() rather than process_init_stopped() and will therefore schedule the startup process immediately, before the relevant resources have been allocated. This bug is masked in the typical use case of a Google Cloud instance with a single NIC built with the config/cloud/gce.ipxe embedded script, since the embedded script will immediately open the NIC (and therefore allocate the required resources) before the scheduled process is allowed to run for the first time. In a multi-NIC instance, undefined behaviour will arise as soon as the startup process for the second NIC is allowed to run. Fix by using process_init_stopped() to avoid implicitly scheduling the startup process during gve_probe(). Originally-fixed-by: Kal Cutter Conley Signed-off-by: Michael Brown --- src/drivers/net/gve.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/drivers') diff --git a/src/drivers/net/gve.c b/src/drivers/net/gve.c index df10a94c6..efc38dd21 100644 --- a/src/drivers/net/gve.c +++ b/src/drivers/net/gve.c @@ -1543,7 +1543,8 @@ static int gve_probe ( struct pci_device *pci ) { gve->netdev = netdev; gve->tx.type = &gve_tx_type; gve->rx.type = &gve_rx_type; - process_init ( &gve->startup, &gve_startup_desc, &netdev->refcnt ); + process_init_stopped ( &gve->startup, &gve_startup_desc, + &netdev->refcnt ); timer_init ( &gve->watchdog, gve_watchdog, &netdev->refcnt ); /* Fix up PCI device */ -- cgit v1.2.3-55-g7522 From bd90abf487a6b0500f457193f86ff54fd2be3143 Mon Sep 17 00:00:00 2001 From: Joseph Wong Date: Wed, 22 Jan 2025 16:06:18 -0800 Subject: [bnxt] Allocate TX rings with firmware input Use queue_id value retrieved from firmware unconditionally when allocating TX rings. Signed-off by: Joseph Wong --- src/drivers/net/bnxt/bnxt.c | 2 +- src/drivers/net/bnxt/bnxt.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/bnxt/bnxt.c b/src/drivers/net/bnxt/bnxt.c index a127f6cef..5de8d094e 100644 --- a/src/drivers/net/bnxt/bnxt.c +++ b/src/drivers/net/bnxt/bnxt.c @@ -1840,7 +1840,7 @@ static int bnxt_hwrm_ring_alloc ( struct bnxt *bp, u8 type ) req->page_size = LM_PAGE_BITS ( 8 ); req->int_mode = RING_ALLOC_REQ_INT_MODE_POLL; req->length = ( u32 )bp->tx.ring_cnt; - req->queue_id = TX_RING_QID; + req->queue_id = ( u16 )bp->queue_id; req->stat_ctx_id = ( u32 )bp->stat_ctx_id; req->cmpl_ring_id = bp->cq_ring_id; req->page_tbl_addr = virt_to_bus ( bp->tx.bd_virt ); diff --git a/src/drivers/net/bnxt/bnxt.h b/src/drivers/net/bnxt/bnxt.h index 8c8a33282..782881964 100644 --- a/src/drivers/net/bnxt/bnxt.h +++ b/src/drivers/net/bnxt/bnxt.h @@ -178,7 +178,6 @@ union dma_addr64_t { RX_MASK_ACCEPT_MULTICAST) #define MAX_NQ_DESC_CNT 64 #define NQ_RING_BUFFER_SIZE (MAX_NQ_DESC_CNT * sizeof(struct cmpl_base)) -#define TX_RING_QID (FLAG_TEST(bp->flags, BNXT_FLAG_IS_CHIP_P5_PLUS) ? (u16)bp->queue_id : ((u16)bp->port_idx * 10)) #define RX_RING_QID (FLAG_TEST(bp->flags, BNXT_FLAG_IS_CHIP_P5_PLUS) ? bp->queue_id : 0) #define STAT_CTX_ID ((bp->vf || FLAG_TEST(bp->flags, BNXT_FLAG_IS_CHIP_P5_PLUS)) ? bp->stat_ctx_id : 0) #define TX_AVAIL(r) (r - 1) -- cgit v1.2.3-55-g7522 From 9dd30f11f74722a43ed590df9f525e038d155283 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sun, 23 Mar 2025 18:06:15 +0000 Subject: [efi] Use efi_open_by_driver() for all by-driver protocol opens Signed-off-by: Michael Brown --- src/drivers/net/efi/mnpnet.c | 20 +++++++------------- src/drivers/net/efi/nii.c | 16 ++++------------ src/drivers/net/efi/snpnet.c | 17 +++++------------ src/drivers/usb/usbio.c | 31 ++++++++----------------------- src/interface/efi/efi_file.c | 13 ++++--------- src/interface/efi/efi_pci.c | 18 +++++------------- src/interface/efi/efi_snp.c | 30 ++++++++++-------------------- 7 files changed, 43 insertions(+), 102 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/efi/mnpnet.c b/src/drivers/net/efi/mnpnet.c index eb4b129c7..ead8691ff 100644 --- a/src/drivers/net/efi/mnpnet.c +++ b/src/drivers/net/efi/mnpnet.c @@ -367,7 +367,6 @@ static struct net_device_operations mnpnet_operations = { * @ret rc Return status code */ int mnpnet_start ( struct efi_device *efidev ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE device = efidev->device; EFI_GUID *binding = &efi_managed_network_service_binding_protocol_guid; EFI_SIMPLE_NETWORK_MODE mode; @@ -408,13 +407,9 @@ int mnpnet_start ( struct efi_device *efidev ) { } /* Open MNP protocol */ - if ( ( efirc = bs->OpenProtocol ( efidev->child, - &efi_managed_network_protocol_guid, - &u.interface, efi_image_handle, - efidev->child, - ( EFI_OPEN_PROTOCOL_BY_DRIVER | - EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open_by_driver ( efidev->child, + &efi_managed_network_protocol_guid, + &u.interface ) ) != 0 ) { DBGC ( mnp, "MNP %s could not open MNP protocol: %s\n", efi_handle_name ( device ), strerror ( rc ) ); goto err_open; @@ -464,8 +459,8 @@ int mnpnet_start ( struct efi_device *efidev ) { err_ll_addr_len: err_hw_addr_len: err_mode: - bs->CloseProtocol ( efidev->child, &efi_managed_network_protocol_guid, - efi_image_handle, efidev->child ); + efi_close_by_driver ( efidev->child, + &efi_managed_network_protocol_guid ); err_open: efi_service_del ( device, binding, efidev->child ); err_service: @@ -482,7 +477,6 @@ int mnpnet_start ( struct efi_device *efidev ) { * @v efidev EFI device */ void mnpnet_stop ( struct efi_device *efidev ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_GUID *binding = &efi_managed_network_service_binding_protocol_guid; struct net_device *netdev = efidev_get_drvdata ( efidev ); struct mnp_nic *mnp = netdev->priv; @@ -491,8 +485,8 @@ void mnpnet_stop ( struct efi_device *efidev ) { unregister_netdev ( netdev ); /* Close MNP protocol */ - bs->CloseProtocol ( efidev->child, &efi_managed_network_protocol_guid, - efi_image_handle, efidev->child ); + efi_close_by_driver ( efidev->child, + &efi_managed_network_protocol_guid ); /* Remove MNP child (unless whole system shutdown is in progress) */ if ( ! efi_shutdown_in_progress ) diff --git a/src/drivers/net/efi/nii.c b/src/drivers/net/efi/nii.c index 16e9e10df..18b292e56 100644 --- a/src/drivers/net/efi/nii.c +++ b/src/drivers/net/efi/nii.c @@ -1270,12 +1270,10 @@ static struct net_device_operations nii_operations = { * @ret rc Return status code */ int nii_start ( struct efi_device *efidev ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE device = efidev->device; struct net_device *netdev; struct nii_nic *nii; void *interface; - EFI_STATUS efirc; int rc; /* Allocate and initialise structure */ @@ -1300,11 +1298,8 @@ int nii_start ( struct efi_device *efidev ) { netdev->dev = &nii->dev; /* Open NII protocol */ - if ( ( efirc = bs->OpenProtocol ( device, &efi_nii31_protocol_guid, - &interface, efi_image_handle, device, - ( EFI_OPEN_PROTOCOL_BY_DRIVER | - EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open_by_driver ( device, &efi_nii31_protocol_guid, + &interface ) ) != 0 ) { DBGC ( nii, "NII %s cannot open NII protocol: %s\n", nii->dev.name, strerror ( rc ) ); DBGC_EFI_OPENERS ( device, device, &efi_nii31_protocol_guid ); @@ -1373,8 +1368,7 @@ int nii_start ( struct efi_device *efidev ) { err_pci_open: err_hw_undi: err_no_undi: - bs->CloseProtocol ( device, &efi_nii31_protocol_guid, - efi_image_handle, device ); + efi_close_by_driver ( device, &efi_nii31_protocol_guid ); err_open_protocol: list_del ( &nii->dev.siblings ); netdev_nullify ( netdev ); @@ -1389,7 +1383,6 @@ int nii_start ( struct efi_device *efidev ) { * @v efidev EFI device */ void nii_stop ( struct efi_device *efidev ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; struct net_device *netdev = efidev_get_drvdata ( efidev ); struct nii_nic *nii = netdev->priv; EFI_HANDLE device = efidev->device; @@ -1404,8 +1397,7 @@ void nii_stop ( struct efi_device *efidev ) { nii_pci_close ( nii ); /* Close NII protocol */ - bs->CloseProtocol ( device, &efi_nii31_protocol_guid, - efi_image_handle, device ); + efi_close_by_driver ( device, &efi_nii31_protocol_guid ); /* Free network device */ list_del ( &nii->dev.siblings ); diff --git a/src/drivers/net/efi/snpnet.c b/src/drivers/net/efi/snpnet.c index 6ce731d78..fb071d8d3 100644 --- a/src/drivers/net/efi/snpnet.c +++ b/src/drivers/net/efi/snpnet.c @@ -539,7 +539,6 @@ int snpnet_supported ( EFI_HANDLE device, EFI_GUID *protocol ) { * @ret rc Return status code */ int snpnet_start ( struct efi_device *efidev ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE device = efidev->device; EFI_SIMPLE_NETWORK_MODE *mode; struct net_device *netdev; @@ -549,12 +548,9 @@ int snpnet_start ( struct efi_device *efidev ) { int rc; /* Open SNP protocol */ - if ( ( efirc = bs->OpenProtocol ( device, - &efi_simple_network_protocol_guid, - &interface, efi_image_handle, device, - ( EFI_OPEN_PROTOCOL_BY_DRIVER | - EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open_by_driver ( device, + &efi_simple_network_protocol_guid, + &interface ) ) != 0 ) { DBGC ( device, "SNP %s cannot open SNP protocol: %s\n", efi_handle_name ( device ), strerror ( rc ) ); DBGC_EFI_OPENERS ( device, device, @@ -644,8 +640,7 @@ int snpnet_start ( struct efi_device *efidev ) { netdev_nullify ( netdev ); netdev_put ( netdev ); err_alloc: - bs->CloseProtocol ( device, &efi_simple_network_protocol_guid, - efi_image_handle, device ); + efi_close_by_driver ( device, &efi_simple_network_protocol_guid ); err_open_protocol: return rc; } @@ -656,7 +651,6 @@ int snpnet_start ( struct efi_device *efidev ) { * @v efidev EFI device */ void snpnet_stop ( struct efi_device *efidev ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; struct net_device *netdev = efidev_get_drvdata ( efidev ); struct snp_nic *snp = netdev->priv; EFI_HANDLE device = efidev->device; @@ -681,6 +675,5 @@ void snpnet_stop ( struct efi_device *efidev ) { netdev_put ( netdev ); /* Close SNP protocol */ - bs->CloseProtocol ( device, &efi_simple_network_protocol_guid, - efi_image_handle, device ); + efi_close_by_driver ( device, &efi_simple_network_protocol_guid ); } diff --git a/src/drivers/usb/usbio.c b/src/drivers/usb/usbio.c index 278b43cd3..c5f245fc3 100644 --- a/src/drivers/usb/usbio.c +++ b/src/drivers/usb/usbio.c @@ -229,13 +229,9 @@ static int usbio_open ( struct usbio_device *usbio, unsigned int interface ) { } /* Open USB I/O protocol on this handle */ - if ( ( efirc = bs->OpenProtocol ( intf->handle, - &efi_usb_io_protocol_guid, - &u.interface, efi_image_handle, - intf->handle, - ( EFI_OPEN_PROTOCOL_BY_DRIVER | - EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open_by_driver ( intf->handle, + &efi_usb_io_protocol_guid, + &u.interface ) ) != 0 ) { DBGC ( usbio, "USBIO %s cannot open ", efi_handle_name ( handle ) ); DBGC ( usbio, "%s: %s\n", @@ -259,7 +255,6 @@ static int usbio_open ( struct usbio_device *usbio, unsigned int interface ) { * @v interface Interface number */ static void usbio_close ( struct usbio_device *usbio, unsigned int interface ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; struct usbio_interface *intf = &usbio->interface[interface]; /* Sanity checks */ @@ -274,8 +269,7 @@ static void usbio_close ( struct usbio_device *usbio, unsigned int interface ) { return; /* Close USB I/O protocol */ - bs->CloseProtocol ( intf->handle, &efi_usb_io_protocol_guid, - efi_image_handle, intf->handle ); + efi_close_by_driver ( intf->handle, &efi_usb_io_protocol_guid ); } /****************************************************************************** @@ -1608,7 +1602,6 @@ static int usbio_interfaces ( struct usbio_device *usbio ) { * @ret rc Return status code */ static int usbio_start ( struct efi_device *efidev ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE handle = efidev->device; struct usbio_device *usbio; struct usb_port *port; @@ -1616,7 +1609,6 @@ static int usbio_start ( struct efi_device *efidev ) { void *interface; EFI_USB_IO_PROTOCOL *io; } u; - EFI_STATUS efirc; int rc; /* Allocate and initialise structure */ @@ -1630,12 +1622,8 @@ static int usbio_start ( struct efi_device *efidev ) { INIT_LIST_HEAD ( &usbio->endpoints ); /* Open USB I/O protocol */ - if ( ( efirc = bs->OpenProtocol ( handle, &efi_usb_io_protocol_guid, - &u.interface, efi_image_handle, - handle, - ( EFI_OPEN_PROTOCOL_BY_DRIVER | - EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open_by_driver ( handle, &efi_usb_io_protocol_guid, + &u.interface ) ) != 0 ) { DBGC ( usbio, "USBIO %s cannot open USB I/O protocol: %s\n", efi_handle_name ( handle ), strerror ( rc ) ); DBGC_EFI_OPENERS ( usbio, handle, &efi_usb_io_protocol_guid ); @@ -1692,8 +1680,7 @@ static int usbio_start ( struct efi_device *efidev ) { free ( usbio->config ); err_config: list_del ( &usbio->dev.siblings ); - bs->CloseProtocol ( handle, &efi_usb_io_protocol_guid, - efi_image_handle, handle ); + efi_close_by_driver ( handle, &efi_usb_io_protocol_guid ); err_open_usbio: free ( usbio ); err_alloc: @@ -1706,7 +1693,6 @@ static int usbio_start ( struct efi_device *efidev ) { * @v efidev EFI device */ static void usbio_stop ( struct efi_device *efidev ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE handle = efidev->device; struct usbio_device *usbio = efidev_get_drvdata ( efidev ); @@ -1716,8 +1702,7 @@ static void usbio_stop ( struct efi_device *efidev ) { free ( usbio->path ); free ( usbio->config ); list_del ( &usbio->dev.siblings ); - bs->CloseProtocol ( handle, &efi_usb_io_protocol_guid, - efi_image_handle, handle ); + efi_close_by_driver ( handle, &efi_usb_io_protocol_guid ); free ( usbio ); } diff --git a/src/interface/efi/efi_file.c b/src/interface/efi/efi_file.c index 48fccdbe1..f31f2fe3b 100644 --- a/src/interface/efi/efi_file.c +++ b/src/interface/efi/efi_file.c @@ -1169,11 +1169,8 @@ int efi_file_install ( EFI_HANDLE handle ) { * of calls to our DRIVER_STOP method when starting the EFI * shell. I have no idea why this is. */ - if ( ( efirc = bs->OpenProtocol ( handle, &efi_disk_io_protocol_guid, - &diskio.interface, efi_image_handle, - handle, - EFI_OPEN_PROTOCOL_BY_DRIVER ) ) != 0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open_by_driver ( handle, &efi_disk_io_protocol_guid, + &diskio.interface ) ) != 0 ) { DBGC ( handle, "Could not open disk I/O protocol: %s\n", strerror ( rc ) ); DBGC_EFI_OPENERS ( handle, handle, &efi_disk_io_protocol_guid ); @@ -1199,8 +1196,7 @@ int efi_file_install ( EFI_HANDLE handle ) { efi_file_path_uninstall ( &efi_file_initrd ); err_initrd_install: err_initrd_claim: - bs->CloseProtocol ( handle, &efi_disk_io_protocol_guid, - efi_image_handle, handle ); + efi_close_by_driver ( handle, &efi_disk_io_protocol_guid ); err_open: bs->UninstallMultipleProtocolInterfaces ( handle, @@ -1228,8 +1224,7 @@ void efi_file_uninstall ( EFI_HANDLE handle ) { efi_file_path_uninstall ( &efi_file_initrd ); /* Close our own disk I/O protocol */ - bs->CloseProtocol ( handle, &efi_disk_io_protocol_guid, - efi_image_handle, handle ); + efi_close_by_driver ( handle, &efi_disk_io_protocol_guid ); /* We must install the file system protocol first, since * otherwise the EDK2 code will attempt to helpfully uninstall diff --git a/src/interface/efi/efi_pci.c b/src/interface/efi/efi_pci.c index d55cbe86c..b53a88d66 100644 --- a/src/interface/efi/efi_pci.c +++ b/src/interface/efi/efi_pci.c @@ -902,11 +902,9 @@ static int efipci_supported ( EFI_HANDLE device ) { * @ret rc Return status code */ static int efipci_start ( struct efi_device *efidev ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE device = efidev->device; struct efi_pci_device *efipci; void *pci_io; - EFI_STATUS efirc; int rc; /* Allocate PCI device */ @@ -920,12 +918,9 @@ static int efipci_start ( struct efi_device *efidev ) { if ( ( rc = efipci_info ( device, efipci ) ) != 0 ) goto err_info; - /* Open PCI device */ - if ( ( efirc = bs->OpenProtocol ( device, &efi_pci_io_protocol_guid, - &pci_io, efi_image_handle, device, - ( EFI_OPEN_PROTOCOL_BY_DRIVER | - EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){ - rc = -EEFI_PCI ( efirc ); + /* Open PCI I/O protocol */ + if ( ( rc = efi_open_by_driver ( device, &efi_pci_io_protocol_guid, + &pci_io ) ) != 0 ) { DBGC ( device, "EFIPCI %s could not open PCI device: %s\n", efi_handle_name ( device ), strerror ( rc ) ); DBGC_EFI_OPENERS ( device, device, &efi_pci_io_protocol_guid ); @@ -960,8 +955,7 @@ static int efipci_start ( struct efi_device *efidev ) { err_probe: list_del ( &efipci->pci.dev.siblings ); err_find_driver: - bs->CloseProtocol ( device, &efi_pci_io_protocol_guid, - efi_image_handle, device ); + efi_close_by_driver ( device, &efi_pci_io_protocol_guid ); err_open: err_info: free ( efipci ); @@ -976,15 +970,13 @@ static int efipci_start ( struct efi_device *efidev ) { */ static void efipci_stop ( struct efi_device *efidev ) { struct efi_pci_device *efipci = efidev_get_drvdata ( efidev ); - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE device = efidev->device; pci_remove ( &efipci->pci ); list_del ( &efipci->pci.dev.siblings ); assert ( efipci->pci.dma.mapped == 0 ); assert ( efipci->pci.dma.allocated == 0 ); - bs->CloseProtocol ( device, &efi_pci_io_protocol_guid, - efi_image_handle, device ); + efi_close_by_driver ( device, &efi_pci_io_protocol_guid ); free ( efipci ); } diff --git a/src/interface/efi/efi_snp.c b/src/interface/efi/efi_snp.c index d977802fd..b9706d5ab 100644 --- a/src/interface/efi/efi_snp.c +++ b/src/interface/efi/efi_snp.c @@ -1916,22 +1916,16 @@ static int efi_snp_probe ( struct net_device *netdev, void *priv __unused ) { * instances to prevent SnpDxe from attempting to bind to * them. */ - if ( ( efirc = bs->OpenProtocol ( snpdev->handle, - &efi_nii_protocol_guid, &interface, - efi_image_handle, snpdev->handle, - ( EFI_OPEN_PROTOCOL_BY_DRIVER | - EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open_by_driver ( snpdev->handle, + &efi_nii_protocol_guid, + &interface ) ) != 0 ) { DBGC ( snpdev, "SNPDEV %p could not open NII protocol: %s\n", snpdev, strerror ( rc ) ); goto err_open_nii; } - if ( ( efirc = bs->OpenProtocol ( snpdev->handle, - &efi_nii31_protocol_guid, &interface, - efi_image_handle, snpdev->handle, - ( EFI_OPEN_PROTOCOL_BY_DRIVER | - EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open_by_driver ( snpdev->handle, + &efi_nii31_protocol_guid, + &interface ) ) != 0 ) { DBGC ( snpdev, "SNPDEV %p could not open NII31 protocol: %s\n", snpdev, strerror ( rc ) ); goto err_open_nii31; @@ -1967,11 +1961,9 @@ static int efi_snp_probe ( struct net_device *netdev, void *priv __unused ) { leak |= efi_snp_hii_uninstall ( snpdev ); efi_child_del ( efidev->device, snpdev->handle ); err_efi_child_add: - bs->CloseProtocol ( snpdev->handle, &efi_nii31_protocol_guid, - efi_image_handle, snpdev->handle ); + efi_close_by_driver ( snpdev->handle, &efi_nii31_protocol_guid ); err_open_nii31: - bs->CloseProtocol ( snpdev->handle, &efi_nii_protocol_guid, - efi_image_handle, snpdev->handle ); + efi_close_by_driver ( snpdev->handle, &efi_nii_protocol_guid ); err_open_nii: if ( ( efirc = bs->UninstallMultipleProtocolInterfaces ( snpdev->handle, @@ -2060,10 +2052,8 @@ static void efi_snp_remove ( struct net_device *netdev, void *priv __unused ) { if ( snpdev->package_list ) leak |= efi_snp_hii_uninstall ( snpdev ); efi_child_del ( snpdev->efidev->device, snpdev->handle ); - bs->CloseProtocol ( snpdev->handle, &efi_nii_protocol_guid, - efi_image_handle, snpdev->handle ); - bs->CloseProtocol ( snpdev->handle, &efi_nii31_protocol_guid, - efi_image_handle, snpdev->handle ); + efi_close_by_driver ( snpdev->handle, &efi_nii_protocol_guid ); + efi_close_by_driver ( snpdev->handle, &efi_nii31_protocol_guid ); if ( ( ! efi_shutdown_in_progress ) && ( ( efirc = bs->UninstallMultipleProtocolInterfaces ( snpdev->handle, -- cgit v1.2.3-55-g7522 From 5a5e2a1dae525aecf97dffde2236b74710735c8d Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sun, 23 Mar 2025 19:38:14 +0000 Subject: [efi] Use efi_open_unsafe() for all explicitly unsafe protocol opens Signed-off-by: Michael Brown --- src/drivers/net/efi/nii.c | 21 ++++++++++----------- src/interface/efi/efi_bofm.c | 9 +++------ src/interface/efi/efi_console.c | 11 +++-------- src/interface/efi/efi_init.c | 15 +++++++++------ 4 files changed, 25 insertions(+), 31 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/efi/nii.c b/src/drivers/net/efi/nii.c index 18b292e56..126584eff 100644 --- a/src/drivers/net/efi/nii.c +++ b/src/drivers/net/efi/nii.c @@ -230,12 +230,14 @@ static int nii_pci_open ( struct nii_nic *nii ) { } nii->pci_device = pci_device; - /* Open PCI I/O protocol */ - if ( ( efirc = bs->OpenProtocol ( pci_device, &efi_pci_io_protocol_guid, - &pci_io.interface, efi_image_handle, - device, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + /* Open PCI I/O protocol + * + * We cannot open this safely as a by-driver open, since doing + * so would disconnect the underlying NII driver. We must + * therefore use an unsafe open. + */ + if ( ( rc = efi_open_unsafe ( pci_device, &efi_pci_io_protocol_guid, + &pci_io.interface ) ) != 0 ) { DBGC ( nii, "NII %s could not open PCI I/O protocol: %s\n", nii->dev.name, strerror ( rc ) ); goto err_open; @@ -280,8 +282,7 @@ static int nii_pci_open ( struct nii_nic *nii ) { return 0; err_get_bar_attributes: - bs->CloseProtocol ( pci_device, &efi_pci_io_protocol_guid, - efi_image_handle, device ); + efi_close_unsafe ( pci_device, &efi_pci_io_protocol_guid ); err_open: err_locate: return rc; @@ -294,7 +295,6 @@ static int nii_pci_open ( struct nii_nic *nii ) { * @ret rc Return status code */ static void nii_pci_close ( struct nii_nic *nii ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; struct nii_mapping *map; struct nii_mapping *tmp; @@ -308,8 +308,7 @@ static void nii_pci_close ( struct nii_nic *nii ) { } /* Close protocols */ - bs->CloseProtocol ( nii->pci_device, &efi_pci_io_protocol_guid, - efi_image_handle, nii->efidev->device ); + efi_close_unsafe ( nii->pci_device, &efi_pci_io_protocol_guid ); } /** diff --git a/src/interface/efi/efi_bofm.c b/src/interface/efi/efi_bofm.c index 1be68bf8b..6d97ff445 100644 --- a/src/interface/efi/efi_bofm.c +++ b/src/interface/efi/efi_bofm.c @@ -241,10 +241,8 @@ static int efi_bofm_start ( struct efi_device *efidev ) { } /* Open PCI I/O protocol */ - if ( ( efirc = bs->OpenProtocol ( device, &efi_pci_io_protocol_guid, - &pci_io, efi_image_handle, device, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open_unsafe ( device, &efi_pci_io_protocol_guid, + &pci_io ) ) != 0 ) { DBGC ( device, "EFIBOFM %s cannot open PCI device: %s\n", efi_handle_name ( device ), strerror ( rc ) ); goto err_open; @@ -326,8 +324,7 @@ static int efi_bofm_start ( struct efi_device *efidev ) { err_set_status: err_locate_bofm: - bs->CloseProtocol ( device, &efi_pci_io_protocol_guid, - efi_image_handle, device ); + efi_close_unsafe ( device, &efi_pci_io_protocol_guid ); err_open: err_info: return rc; diff --git a/src/interface/efi/efi_console.c b/src/interface/efi/efi_console.c index 04bbd9e0c..41c4dcf2c 100644 --- a/src/interface/efi/efi_console.c +++ b/src/interface/efi/efi_console.c @@ -415,13 +415,11 @@ struct console_driver efi_console __console_driver = { * */ static void efi_console_init ( void ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_CONSOLE_CONTROL_SCREEN_MODE mode; union { void *interface; EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *wtf; } u; - EFI_STATUS efirc; int rc; /* On some older EFI 1.10 implementations, we must use the @@ -441,15 +439,12 @@ static void efi_console_init ( void ) { * apparently the expected behaviour for all UEFI * applications. Don't ask. */ - if ( ( efirc = bs->OpenProtocol ( efi_systab->ConsoleInHandle, - &efi_simple_text_input_ex_protocol_guid, - &u.interface, efi_image_handle, - efi_systab->ConsoleInHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) == 0 ) { + if ( ( rc = efi_open_unsafe ( efi_systab->ConsoleInHandle, + &efi_simple_text_input_ex_protocol_guid, + &u.interface ) ) == 0 ) { efi_conin_ex = u.wtf; DBG ( "EFI using SimpleTextInputEx\n" ); } else { - rc = -EEFI ( efirc ); DBG ( "EFI has no SimpleTextInputEx: %s\n", strerror ( rc ) ); } } diff --git a/src/interface/efi/efi_init.c b/src/interface/efi/efi_init.c index d3c5042d7..a45ee66a4 100644 --- a/src/interface/efi/efi_init.c +++ b/src/interface/efi/efi_init.c @@ -241,14 +241,17 @@ EFI_STATUS efi_init ( EFI_HANDLE image_handle, } } - /* Get loaded image protocol */ - if ( ( efirc = bs->OpenProtocol ( image_handle, - &efi_loaded_image_protocol_guid, - &loaded_image, image_handle, NULL, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) { - rc = -EEFI ( efirc ); + /* Get loaded image protocol + * + * We assume that our loaded image protocol will not be + * uninstalled while our image code is still running. + */ + if ( ( rc = efi_open_unsafe ( image_handle, + &efi_loaded_image_protocol_guid, + &loaded_image ) ) != 0 ) { DBGC ( systab, "EFI could not get loaded image protocol: %s", strerror ( rc ) ); + efirc = EFIRC ( rc ); goto err_no_loaded_image; } efi_loaded_image = loaded_image; -- cgit v1.2.3-55-g7522 From bac318743905e55ce424104cafbc8418e0672a80 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sun, 23 Mar 2025 19:11:13 +0000 Subject: [efi] Use efi_open() for all ephemeral protocol opens Signed-off-by: Michael Brown --- src/drivers/net/efi/snpnet.c | 8 +--- src/drivers/net/efi/snponly.c | 33 ++++----------- src/drivers/usb/usbio.c | 68 +++++++----------------------- src/image/efi_image.c | 7 +--- src/interface/efi/efi_autoboot.c | 14 +------ src/interface/efi/efi_block.c | 67 +++++++----------------------- src/interface/efi/efi_cachedhcp.c | 33 ++++----------- src/interface/efi/efi_debug.c | 50 ++++++---------------- src/interface/efi/efi_driver.c | 27 ++++-------- src/interface/efi/efi_init.c | 9 ++-- src/interface/efi/efi_local.c | 22 +++------- src/interface/efi/efi_pci.c | 87 +++++++++------------------------------ src/interface/efi/efi_service.c | 36 ++++------------ src/interface/efi/efi_shim.c | 21 +++------- src/interface/efi/efi_utils.c | 13 +----- src/interface/efi/efi_veto.c | 64 ++++++---------------------- src/interface/efi/efi_wrap.c | 13 +----- 17 files changed, 130 insertions(+), 442 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/efi/snpnet.c b/src/drivers/net/efi/snpnet.c index fb071d8d3..93ed8cd95 100644 --- a/src/drivers/net/efi/snpnet.c +++ b/src/drivers/net/efi/snpnet.c @@ -493,9 +493,7 @@ static struct net_device_operations snpnet_operations = { * @ret rc Return status code */ int snpnet_supported ( EFI_HANDLE device, EFI_GUID *protocol ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE parent; - EFI_STATUS efirc; int rc; /* Check that this is not a device we are providing ourselves */ @@ -506,13 +504,11 @@ int snpnet_supported ( EFI_HANDLE device, EFI_GUID *protocol ) { } /* Test for presence of protocol */ - if ( ( efirc = bs->OpenProtocol ( device, protocol, - NULL, efi_image_handle, device, - EFI_OPEN_PROTOCOL_TEST_PROTOCOL))!=0){ + if ( ( rc = efi_open ( device, protocol, NULL ) ) != 0 ) { DBGCP ( device, "HANDLE %s is not a %s device\n", efi_handle_name ( device ), efi_guid_ntoa ( protocol ) ); - return -EEFI ( efirc ); + return rc; } /* Check that there are no instances of this protocol further diff --git a/src/drivers/net/efi/snponly.c b/src/drivers/net/efi/snponly.c index 2ae63fc06..80ddfe00d 100644 --- a/src/drivers/net/efi/snponly.c +++ b/src/drivers/net/efi/snponly.c @@ -86,13 +86,11 @@ static struct chained_protocol chained_mnp = { * @v chained Chainloaded protocol */ static void chained_locate ( struct chained_protocol *chained ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE device = efi_loaded_image->DeviceHandle; EFI_HANDLE handle; void *match = NULL; void *interface; unsigned int skip; - EFI_STATUS efirc; int rc; /* Identify target device handle */ @@ -111,11 +109,8 @@ static void chained_locate ( struct chained_protocol *chained ) { } /* Get protocol instance */ - if ( ( efirc = bs->OpenProtocol ( - handle, chained->protocol, &interface, - efi_image_handle, handle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL )) != 0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( handle, chained->protocol, + &interface ) ) != 0 ) { DBGC ( device, "CHAINED %s could not open %s on ", efi_handle_name ( device ), efi_guid_ntoa ( chained->protocol ) ); @@ -123,8 +118,6 @@ static void chained_locate ( struct chained_protocol *chained ) { efi_handle_name ( handle ), strerror ( rc ) ); break; } - bs->CloseProtocol ( handle, chained->protocol, - efi_image_handle, handle ); /* Stop if we reach a non-matching protocol instance */ if ( match && ( match != interface ) ) { @@ -154,20 +147,16 @@ static void chained_locate ( struct chained_protocol *chained ) { */ static int chained_supported ( EFI_HANDLE device, struct chained_protocol *chained ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; void *interface; - EFI_STATUS efirc; int rc; /* Get protocol */ - if ( ( efirc = bs->OpenProtocol ( device, chained->protocol, &interface, - efi_image_handle, device, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( device, chained->protocol, + &interface ) ) != 0 ) { DBGCP ( device, "CHAINED %s is not a %s device\n", efi_handle_name ( device ), efi_guid_ntoa ( chained->protocol ) ); - goto err_open_protocol; + return rc; } /* Ignore non-matching handles */ @@ -175,21 +164,13 @@ static int chained_supported ( EFI_HANDLE device, DBGC2 ( device, "CHAINED %s is not the chainloaded %s\n", efi_handle_name ( device ), efi_guid_ntoa ( chained->protocol ) ); - rc = -ENOTTY; - goto err_no_match; + return -ENOTTY; } - /* Success */ - rc = 0; DBGC ( device, "CHAINED %s is the chainloaded %s\n", efi_handle_name ( device ), efi_guid_ntoa ( chained->protocol ) ); - - err_no_match: - bs->CloseProtocol ( device, chained->protocol, efi_image_handle, - device ); - err_open_protocol: - return rc; + return 0; } /** diff --git a/src/drivers/usb/usbio.c b/src/drivers/usb/usbio.c index c5f245fc3..db3beff21 100644 --- a/src/drivers/usb/usbio.c +++ b/src/drivers/usb/usbio.c @@ -1291,7 +1291,6 @@ static struct usb_host_operations usbio_operations = { * @ret rc Return status code */ static int usbio_supported ( EFI_HANDLE handle ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_USB_DEVICE_DESCRIPTOR device; EFI_USB_INTERFACE_DESCRIPTOR interface; struct usb_function_descriptor desc; @@ -1305,14 +1304,11 @@ static int usbio_supported ( EFI_HANDLE handle ) { int rc; /* Get protocol */ - if ( ( efirc = bs->OpenProtocol ( handle, &efi_usb_io_protocol_guid, - &usb.interface, efi_image_handle, - handle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( handle, &efi_usb_io_protocol_guid, + &usb.interface ) ) != 0 ) { DBGCP ( handle, "USB %s is not a USB device\n", efi_handle_name ( handle ) ); - goto err_open_protocol; + return rc; } /* Get device descriptor */ @@ -1321,7 +1317,7 @@ static int usbio_supported ( EFI_HANDLE handle ) { rc = -EEFI ( efirc ); DBGC ( handle, "USB %s could not get device descriptor: " "%s\n", efi_handle_name ( handle ), strerror ( rc ) ); - goto err_get_device_descriptor; + return rc; } memset ( &desc, 0, sizeof ( desc ) ); desc.vendor = device.IdVendor; @@ -1333,7 +1329,7 @@ static int usbio_supported ( EFI_HANDLE handle ) { rc = -EEFI ( efirc ); DBGC ( handle, "USB %s could not get interface descriptor: " "%s\n", efi_handle_name ( handle ), strerror ( rc ) ); - goto err_get_interface_descriptor; + return rc; } desc.class.class.class = interface.InterfaceClass; desc.class.class.subclass = interface.InterfaceSubClass; @@ -1341,21 +1337,10 @@ static int usbio_supported ( EFI_HANDLE handle ) { /* Look for a driver for this interface */ driver = usb_find_driver ( &desc, &id ); - if ( ! driver ) { - rc = -ENOTSUP; - goto err_unsupported; - } - - /* Success */ - rc = 0; + if ( ! driver ) + return -ENOTSUP; - err_unsupported: - err_get_interface_descriptor: - err_get_device_descriptor: - bs->CloseProtocol ( handle, &efi_usb_io_protocol_guid, - efi_image_handle, handle ); - err_open_protocol: - return rc; + return 0; } /** @@ -1471,7 +1456,6 @@ static int usbio_config ( struct usbio_device *usbio ) { * @ret rc Return status code */ static int usbio_path ( struct usbio_device *usbio ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE handle = usbio->handle; EFI_DEVICE_PATH_PROTOCOL *path; EFI_DEVICE_PATH_PROTOCOL *end; @@ -1481,19 +1465,14 @@ static int usbio_path ( struct usbio_device *usbio ) { EFI_DEVICE_PATH_PROTOCOL *path; } u; size_t len; - EFI_STATUS efirc; int rc; /* Open device path protocol */ - if ( ( efirc = bs->OpenProtocol ( handle, - &efi_device_path_protocol_guid, - &u.interface, efi_image_handle, - handle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( handle, &efi_device_path_protocol_guid, + &u.interface ) ) != 0 ) { DBGC ( usbio, "USBIO %s cannot open device path protocol: " "%s\n", efi_handle_name ( handle ), strerror ( rc ) ); - goto err_open_protocol; + return rc; } path = u.interface; @@ -1502,8 +1481,7 @@ static int usbio_path ( struct usbio_device *usbio ) { if ( len < sizeof ( *usbpath ) ) { DBGC ( usbio, "USBIO %s underlength device path\n", efi_handle_name ( handle ) ); - rc = -EINVAL; - goto err_underlength; + return -EINVAL; } usbpath = ( ( ( void * ) path ) + len - sizeof ( *usbpath ) ); if ( ! ( ( usbpath->Header.Type == MESSAGING_DEVICE_PATH ) && @@ -1511,34 +1489,18 @@ static int usbio_path ( struct usbio_device *usbio ) { DBGC ( usbio, "USBIO %s not a USB device path: ", efi_handle_name ( handle ) ); DBGC ( usbio, "%s\n", efi_devpath_text ( path ) ); - rc = -EINVAL; - goto err_non_usb; + return -EINVAL; } /* Allocate copy of device path */ usbio->path = malloc ( len + sizeof ( *end ) ); - if ( ! usbio->path ) { - rc = -ENOMEM; - goto err_alloc; - } + if ( ! usbio->path ) + return -ENOMEM; memcpy ( usbio->path, path, ( len + sizeof ( *end ) ) ); usbio->usbpath = ( ( ( void * ) usbio->path ) + len - sizeof ( *usbpath ) ); - /* Close protocol */ - bs->CloseProtocol ( handle, &efi_device_path_protocol_guid, - efi_image_handle, handle ); - return 0; - - free ( usbio->path ); - err_alloc: - err_non_usb: - err_underlength: - bs->CloseProtocol ( handle, &efi_device_path_protocol_guid, - efi_image_handle, handle ); - err_open_protocol: - return rc; } /** diff --git a/src/image/efi_image.c b/src/image/efi_image.c index d2171e7de..ae9255ce5 100644 --- a/src/image/efi_image.c +++ b/src/image/efi_image.c @@ -234,12 +234,9 @@ static int efi_image_exec ( struct image *image ) { } /* Get the loaded image protocol for the newly loaded image */ - efirc = bs->OpenProtocol ( handle, &efi_loaded_image_protocol_guid, - &loaded.interface, efi_image_handle, - NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL ); - if ( efirc ) { + if ( ( rc = efi_open ( handle, &efi_loaded_image_protocol_guid, + &loaded.interface ) ) != 0 ) { /* Should never happen */ - rc = -EEFI ( efirc ); goto err_open_protocol; } diff --git a/src/interface/efi/efi_autoboot.c b/src/interface/efi/efi_autoboot.c index a103c2f19..528b84f1e 100644 --- a/src/interface/efi/efi_autoboot.c +++ b/src/interface/efi/efi_autoboot.c @@ -48,23 +48,17 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ int efi_set_autoboot_ll_addr ( EFI_HANDLE device, EFI_DEVICE_PATH_PROTOCOL *path ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; union { EFI_SIMPLE_NETWORK_PROTOCOL *snp; void *interface; } snp; EFI_SIMPLE_NETWORK_MODE *mode; - EFI_STATUS efirc; unsigned int vlan; int rc; /* Look for an SNP instance on the image's device handle */ - if ( ( efirc = bs->OpenProtocol ( device, - &efi_simple_network_protocol_guid, - &snp.interface, efi_image_handle, - NULL, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( device, &efi_simple_network_protocol_guid, + &snp.interface ) ) != 0 ) { DBGC ( device, "EFI %s has no SNP instance: %s\n", efi_handle_name ( device ), strerror ( rc ) ); return rc; @@ -90,9 +84,5 @@ int efi_set_autoboot_ll_addr ( EFI_HANDLE device, efi_handle_name ( device ), vlan ); } - /* Close protocol */ - bs->CloseProtocol ( device, &efi_simple_network_protocol_guid, - efi_image_handle, NULL ); - return 0; } diff --git a/src/interface/efi/efi_block.c b/src/interface/efi/efi_block.c index 6296953c5..34b73c265 100644 --- a/src/interface/efi/efi_block.c +++ b/src/interface/efi/efi_block.c @@ -518,8 +518,6 @@ static int efi_block_describe ( void ) { */ static int efi_block_root ( unsigned int drive, EFI_HANDLE handle, EFI_FILE_PROTOCOL **root ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; - EFI_GUID *protocol = &efi_simple_file_system_protocol_guid; union { EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *fs; void *interface; @@ -528,13 +526,11 @@ static int efi_block_root ( unsigned int drive, EFI_HANDLE handle, int rc; /* Open filesystem protocol */ - if ( ( efirc = bs->OpenProtocol ( handle, protocol, &u.interface, - efi_image_handle, handle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( handle, &efi_simple_file_system_protocol_guid, + &u.interface ) ) != 0 ) { DBGC ( drive, "EFIBLK %#02x could not open %s filesystem: %s\n", drive, efi_handle_name ( handle ), strerror ( rc ) ); - goto err_open; + return rc; } /* Open root volume */ @@ -542,16 +538,10 @@ static int efi_block_root ( unsigned int drive, EFI_HANDLE handle, rc = -EEFI ( efirc ); DBGC ( drive, "EFIBLK %#02x could not open %s root: %s\n", drive, efi_handle_name ( handle ), strerror ( rc ) ); - goto err_volume; + return rc; } - /* Success */ - rc = 0; - - err_volume: - bs->CloseProtocol ( handle, protocol, efi_image_handle, handle ); - err_open: - return rc; + return 0; } /** @@ -674,22 +664,17 @@ static int efi_block_match ( unsigned int drive, EFI_HANDLE handle, EFI_DEVICE_PATH_PROTOCOL *path, struct san_boot_config *config, EFI_DEVICE_PATH_PROTOCOL **fspath ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; - EFI_GUID *protocol = &efi_device_path_protocol_guid; union { EFI_DEVICE_PATH_PROTOCOL *path; void *interface; } u; EFI_FILE *root; union uuid guid; - EFI_STATUS efirc; int rc; /* Identify device path */ - if ( ( efirc = bs->OpenProtocol ( handle, protocol, &u.interface, - efi_image_handle, handle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( handle, &efi_device_path_protocol_guid, + &u.interface ) ) != 0 ) { DBGC ( drive, "EFIBLK %#02x could not open %s device path: " "%s\n", drive, efi_handle_name ( handle ), strerror ( rc ) ); @@ -758,7 +743,6 @@ static int efi_block_match ( unsigned int drive, EFI_HANDLE handle, err_wrong_guid: err_no_guid: err_not_child: - bs->CloseProtocol ( handle, protocol, efi_image_handle, handle ); err_open: return rc; } @@ -776,7 +760,6 @@ static int efi_block_scan ( unsigned int drive, EFI_HANDLE handle, struct san_boot_config *config, EFI_DEVICE_PATH_PROTOCOL **fspath ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; - EFI_GUID *protocol = &efi_device_path_protocol_guid; union { EFI_DEVICE_PATH_PROTOCOL *path; void *interface; @@ -791,10 +774,8 @@ static int efi_block_scan ( unsigned int drive, EFI_HANDLE handle, efi_block_connect ( drive, handle ); /* Identify device path */ - if ( ( efirc = bs->OpenProtocol ( handle, protocol, &u.interface, - efi_image_handle, handle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( handle, &efi_device_path_protocol_guid, + &u.interface ) ) != 0 ) { DBGC ( drive, "EFIBLK %#02x could not open device path: %s\n", drive, strerror ( rc ) ); goto err_open; @@ -824,7 +805,6 @@ static int efi_block_scan ( unsigned int drive, EFI_HANDLE handle, bs->FreePool ( handles ); err_locate: - bs->CloseProtocol ( handle, protocol, efi_image_handle, handle ); err_open: return rc; } @@ -921,52 +901,37 @@ static int efi_block_exec ( unsigned int drive, * equivalent functionality to BIOS drive numbers. */ static int efi_block_local ( EFI_HANDLE handle ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; - EFI_GUID *protocol = &efi_block_io_protocol_guid; struct san_device *sandev; struct efi_block_data *block; union { EFI_BLOCK_IO_PROTOCOL *blockio; void *interface; } u; - EFI_STATUS efirc; int rc; /* Check if handle belongs to a SAN device */ for_each_sandev ( sandev ) { block = sandev->priv; - if ( handle == block->handle ) { - rc = -ENOTTY; - goto err_sandev; - } + if ( handle == block->handle ) + return -ENOTTY; } /* Open block I/O protocol */ - if ( ( efirc = bs->OpenProtocol ( handle, protocol, &u.interface, - efi_image_handle, handle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( handle, &efi_block_io_protocol_guid, + &u.interface ) ) != 0 ) { DBGC ( handle, "EFIBLK %s could not open block I/O: %s\n", efi_handle_name ( handle ), strerror ( rc ) ); - goto err_open; + return rc; } /* Do not assign drive numbers for partitions */ if ( u.blockio->Media->LogicalPartition ) { - rc = -ENOTTY; DBGC2 ( handle, "EFLBLK %s is a partition\n", efi_handle_name ( handle ) ); - goto err_partition; + return -ENOTTY; } - /* Success */ - rc = 0; - - err_partition: - bs->CloseProtocol ( handle, protocol, efi_image_handle, handle ); - err_open: - err_sandev: - return rc; + return 0; } /** diff --git a/src/interface/efi/efi_cachedhcp.c b/src/interface/efi/efi_cachedhcp.c index b9e49cf48..68671d7c6 100644 --- a/src/interface/efi/efi_cachedhcp.c +++ b/src/interface/efi/efi_cachedhcp.c @@ -46,38 +46,31 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ int efi_cachedhcp_record ( EFI_HANDLE device, EFI_DEVICE_PATH_PROTOCOL *path ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; unsigned int vlan; union { EFI_PXE_BASE_CODE_PROTOCOL *pxe; void *interface; } pxe; EFI_PXE_BASE_CODE_MODE *mode; - EFI_STATUS efirc; int rc; /* Get VLAN tag, if any */ vlan = efi_path_vlan ( path ); /* Look for a PXE base code instance on the image's device handle */ - if ( ( efirc = bs->OpenProtocol ( device, - &efi_pxe_base_code_protocol_guid, - &pxe.interface, efi_image_handle, - NULL, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( device, &efi_pxe_base_code_protocol_guid, + &pxe.interface ) ) != 0 ) { DBGC ( device, "EFI %s has no PXE base code instance: %s\n", efi_handle_name ( device ), strerror ( rc ) ); - goto err_open; + return rc; } /* Do not attempt to cache IPv6 packets */ mode = pxe.pxe->Mode; if ( mode->UsingIpv6 ) { - rc = -ENOTSUP; DBGC ( device, "EFI %s has IPv6 PXE base code\n", efi_handle_name ( device ) ); - goto err_ipv6; + return -ENOTSUP; } /* Record DHCPACK, if present */ @@ -87,7 +80,7 @@ int efi_cachedhcp_record ( EFI_HANDLE device, sizeof ( mode->DhcpAck ) ) ) != 0 ) ) { DBGC ( device, "EFI %s could not record DHCPACK: %s\n", efi_handle_name ( device ), strerror ( rc ) ); - goto err_dhcpack; + return rc; } /* Record ProxyDHCPOFFER, if present */ @@ -97,7 +90,7 @@ int efi_cachedhcp_record ( EFI_HANDLE device, sizeof ( mode->ProxyOffer ) ) ) != 0)){ DBGC ( device, "EFI %s could not record ProxyDHCPOFFER: %s\n", efi_handle_name ( device ), strerror ( rc ) ); - goto err_proxydhcp; + return rc; } /* Record PxeBSACK, if present */ @@ -107,18 +100,8 @@ int efi_cachedhcp_record ( EFI_HANDLE device, sizeof ( mode->PxeReply ) ) ) != 0)){ DBGC ( device, "EFI %s could not record PXEBSACK: %s\n", efi_handle_name ( device ), strerror ( rc ) ); - goto err_pxebs; + return rc; } - /* Success */ - rc = 0; - - err_pxebs: - err_proxydhcp: - err_dhcpack: - err_ipv6: - bs->CloseProtocol ( device, &efi_pxe_base_code_protocol_guid, - efi_image_handle, NULL ); - err_open: - return rc; + return 0; } diff --git a/src/interface/efi/efi_debug.c b/src/interface/efi/efi_debug.c index 6f71949fb..ef650d989 100644 --- a/src/interface/efi/efi_debug.c +++ b/src/interface/efi/efi_debug.c @@ -328,14 +328,12 @@ static const char * efi_driver_name2 ( EFI_COMPONENT_NAME2_PROTOCOL *wtf ) { * @ret name Driver name, or NULL */ static const char * efi_binding_name ( EFI_DRIVER_BINDING_PROTOCOL *binding ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; union { EFI_COMPONENT_NAME_PROTOCOL *name; void *interface; } u; EFI_HANDLE image; - const char *name; - EFI_STATUS efirc; + int rc; /* Sanity check */ if ( ! binding ) { @@ -345,22 +343,14 @@ static const char * efi_binding_name ( EFI_DRIVER_BINDING_PROTOCOL *binding ) { /* Try to open component name protocol on image handle */ image = binding->ImageHandle; - if ( ( efirc = bs->OpenProtocol ( image, - &efi_component_name_protocol_guid, - &u.interface, efi_image_handle, image, - EFI_OPEN_PROTOCOL_GET_PROTOCOL)) !=0){ + if ( ( rc = efi_open ( image, &efi_component_name_protocol_guid, + &u.interface ) ) != 0 ) { DBG ( "[DriverBinding no ComponentName]" ); return NULL; } /* Try to get name from component name protocol */ - name = efi_driver_name ( u.name ); - - /* Close component name protocol */ - bs->CloseProtocol ( image, &efi_component_name_protocol_guid, - efi_image_handle, image ); - - return name; + return efi_driver_name ( u.name ); } /** @@ -370,14 +360,12 @@ static const char * efi_binding_name ( EFI_DRIVER_BINDING_PROTOCOL *binding ) { * @ret name Driver name, or NULL */ static const char * efi_binding_name2 ( EFI_DRIVER_BINDING_PROTOCOL *binding ){ - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE image; union { EFI_COMPONENT_NAME2_PROTOCOL *name2; void *interface; } u; - const char *name; - EFI_STATUS efirc; + int rc; /* Sanity check */ if ( ! binding ) { @@ -387,22 +375,14 @@ static const char * efi_binding_name2 ( EFI_DRIVER_BINDING_PROTOCOL *binding ){ /* Try to open component name protocol on image handle */ image = binding->ImageHandle; - if ( ( efirc = bs->OpenProtocol ( image, - &efi_component_name2_protocol_guid, - &u.interface, efi_image_handle, image, - EFI_OPEN_PROTOCOL_GET_PROTOCOL)) !=0){ + if ( ( rc = efi_open ( image, &efi_component_name2_protocol_guid, + &u.interface ) ) != 0 ) { DBG ( "[DriverBinding no ComponentName2]" ); return NULL; } /* Try to get name from component name protocol */ - name = efi_driver_name2 ( u.name2 ); - - /* Close component name protocol */ - bs->CloseProtocol ( image, &efi_component_name2_protocol_guid, - efi_image_handle, image ); - - return name; + return efi_driver_name2 ( u.name2 ); } /** @@ -669,6 +649,7 @@ const __attribute__ (( pure )) char * efi_handle_name ( EFI_HANDLE handle ) { void *interface; const char *name; EFI_STATUS efirc; + int rc; /* Fail immediately for NULL handles */ if ( ! handle ) @@ -681,10 +662,8 @@ const __attribute__ (( pure )) char * efi_handle_name ( EFI_HANDLE handle ) { DBG2 ( "<%d", i ); /* Try to open the applicable protocol */ - efirc = bs->OpenProtocol ( handle, type->protocol, &interface, - efi_image_handle, handle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ); - if ( efirc != 0 ) { + if ( ( rc = efi_open ( handle, type->protocol, + &interface ) ) != 0 ) { DBG2 ( ">" ); continue; } @@ -692,12 +671,7 @@ const __attribute__ (( pure )) char * efi_handle_name ( EFI_HANDLE handle ) { /* Try to get name from this protocol */ DBG2 ( "-" ); name = type->name ( interface ); - DBG2 ( "%c", ( name ? ( name[0] ? 'Y' : 'E' ) : 'N' ) ); - - /* Close protocol */ - bs->CloseProtocol ( handle, type->protocol, - efi_image_handle, handle ); - DBG2 ( ">" ); + DBG2 ( "%c>", ( name ? ( name[0] ? 'Y' : 'E' ) : 'N' ) ); /* Use this name, if possible */ if ( name && name[0] ) diff --git a/src/interface/efi/efi_driver.c b/src/interface/efi/efi_driver.c index fd9be5f51..d143249ca 100644 --- a/src/interface/efi/efi_driver.c +++ b/src/interface/efi/efi_driver.c @@ -68,7 +68,6 @@ static int efi_driver_disconnecting; * @ret efidev EFI device, or NULL on error */ struct efi_device * efidev_alloc ( EFI_HANDLE device ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; struct efi_device *efidev = NULL; union { EFI_DEVICE_PATH_PROTOCOL *path; @@ -76,26 +75,21 @@ struct efi_device * efidev_alloc ( EFI_HANDLE device ) { } path; EFI_DEVICE_PATH_PROTOCOL *path_end; size_t path_len; - EFI_STATUS efirc; int rc; /* Open device path */ - if ( ( efirc = bs->OpenProtocol ( device, - &efi_device_path_protocol_guid, - &path.interface, efi_image_handle, - device, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( device, &efi_device_path_protocol_guid, + &path.interface ) ) != 0 ) { DBGC ( device, "EFIDRV %s could not open device path: %s\n", efi_handle_name ( device ), strerror ( rc ) ); - goto err_open_path; + return NULL; } path_len = ( efi_path_len ( path.path ) + sizeof ( *path_end ) ); /* Allocate and initialise structure */ efidev = zalloc ( sizeof ( *efidev ) + path_len ); if ( ! efidev ) - goto err_alloc; + return NULL; efidev->device = device; efidev->dev.desc.bus_type = BUS_TYPE_EFI; efidev->path = ( ( ( void * ) efidev ) + sizeof ( *efidev ) ); @@ -103,10 +97,6 @@ struct efi_device * efidev_alloc ( EFI_HANDLE device ) { INIT_LIST_HEAD ( &efidev->dev.children ); list_add ( &efidev->dev.siblings, &efi_devices ); - err_alloc: - bs->CloseProtocol ( device, &efi_device_path_protocol_guid, - efi_image_handle, device ); - err_open_path: return efidev; } @@ -375,21 +365,18 @@ static EFI_STATUS EFIAPI efi_driver_controller_name ( EFI_COMPONENT_NAME2_PROTOCOL *wtf __unused, EFI_HANDLE device, EFI_HANDLE child, CHAR8 *language, CHAR16 **controller_name ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; union { EFI_COMPONENT_NAME2_PROTOCOL *name2; void *interface; } name2; - EFI_STATUS efirc; + int rc; /* Delegate to the EFI_COMPONENT_NAME2_PROTOCOL instance * installed on child handle, if present. */ if ( ( child != NULL ) && - ( ( efirc = bs->OpenProtocol ( - child, &efi_component_name2_protocol_guid, - &name2.interface, NULL, NULL, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) == 0 ) ) { + ( ( rc = efi_open ( child, &efi_component_name2_protocol_guid, + &name2.interface ) ) == 0 ) ) { return name2.name2->GetControllerName ( name2.name2, device, child, language, controller_name ); diff --git a/src/interface/efi/efi_init.c b/src/interface/efi/efi_init.c index a45ee66a4..03506ec5c 100644 --- a/src/interface/efi/efi_init.c +++ b/src/interface/efi/efi_init.c @@ -263,13 +263,12 @@ EFI_STATUS efi_init ( EFI_HANDLE image_handle, efi_cmdline_len = efi_loaded_image->LoadOptionsSize; /* Get loaded image's device handle's device path */ - if ( ( efirc = bs->OpenProtocol ( efi_loaded_image->DeviceHandle, - &efi_device_path_protocol_guid, - &device_path, image_handle, NULL, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) { - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( efi_loaded_image->DeviceHandle, + &efi_device_path_protocol_guid, + &device_path ) ) != 0 ) { DBGC ( systab, "EFI could not get loaded image's device path: " "%s", strerror ( rc ) ); + efirc = EFIRC ( rc ); goto err_no_device_path; } diff --git a/src/interface/efi/efi_local.c b/src/interface/efi/efi_local.c index ec6d93a1d..80cfb5a22 100644 --- a/src/interface/efi/efi_local.c +++ b/src/interface/efi/efi_local.c @@ -208,7 +208,6 @@ static int efi_local_check_volume_name ( struct efi_local *local, */ static int efi_local_open_root ( struct efi_local *local, EFI_HANDLE device, EFI_FILE_PROTOCOL **root ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; union { void *interface; EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *fs; @@ -217,15 +216,11 @@ static int efi_local_open_root ( struct efi_local *local, EFI_HANDLE device, int rc; /* Open file system protocol */ - if ( ( efirc = bs->OpenProtocol ( device, - &efi_simple_file_system_protocol_guid, - &u.interface, efi_image_handle, - device, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( device, &efi_simple_file_system_protocol_guid, + &u.interface ) ) != 0 ) { DBGC ( local, "LOCAL %p could not open filesystem on %s: %s\n", local, efi_handle_name ( device ), strerror ( rc ) ); - goto err_filesystem; + return rc; } /* Open root directory */ @@ -233,17 +228,10 @@ static int efi_local_open_root ( struct efi_local *local, EFI_HANDLE device, rc = -EEFI ( efirc ); DBGC ( local, "LOCAL %p could not open volume on %s: %s\n", local, efi_handle_name ( device ), strerror ( rc ) ); - goto err_volume; + return rc; } - /* Success */ - rc = 0; - - err_volume: - bs->CloseProtocol ( device, &efi_simple_file_system_protocol_guid, - efi_image_handle, device ); - err_filesystem: - return rc; + return 0; } /** diff --git a/src/interface/efi/efi_pci.c b/src/interface/efi/efi_pci.c index b53a88d66..003fa2f4a 100644 --- a/src/interface/efi/efi_pci.c +++ b/src/interface/efi/efi_pci.c @@ -72,7 +72,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ static int efipci_discover_one ( struct pci_device *pci, EFI_HANDLE handle, struct pci_range *range ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; union { void *interface; EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *root; @@ -94,15 +93,12 @@ static int efipci_discover_one ( struct pci_device *pci, EFI_HANDLE handle, range->count = 0; /* Open root bridge I/O protocol */ - if ( ( efirc = bs->OpenProtocol ( handle, - &efi_pci_root_bridge_io_protocol_guid, - &root.interface, efi_image_handle, handle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) { - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( handle, &efi_pci_root_bridge_io_protocol_guid, + &root.interface ) ) != 0 ) { DBGC ( pci, "EFIPCI " PCI_FMT " cannot open %s: %s\n", PCI_ARGS ( pci ), efi_handle_name ( handle ), strerror ( rc ) ); - goto err_open; + return rc; } /* Get ACPI resource descriptors */ @@ -112,7 +108,7 @@ static int efipci_discover_one ( struct pci_device *pci, EFI_HANDLE handle, DBGC ( pci, "EFIPCI " PCI_FMT " cannot get configuration for " "%s: %s\n", PCI_ARGS ( pci ), efi_handle_name ( handle ), strerror ( rc ) ); - goto err_config; + return rc; } /* Parse resource descriptors */ @@ -159,14 +155,7 @@ static int efipci_discover_one ( struct pci_device *pci, EFI_HANDLE handle, range->count = PCI_BUSDEVFN ( 0, 1, 0, 0 ); } - /* Success */ - rc = 0; - - err_config: - bs->CloseProtocol ( handle, &efi_pci_root_bridge_io_protocol_guid, - efi_image_handle, handle ); - err_open: - return rc; + return 0; } /** @@ -260,7 +249,7 @@ static void efipci_discover ( uint32_t busdevfn, struct pci_range *range ) { } /** - * Open EFI PCI root bridge I/O protocol + * Open EFI PCI root bridge I/O protocol for ephemeral use * * @v pci PCI device * @ret handle EFI PCI root bridge handle @@ -269,25 +258,20 @@ static void efipci_discover ( uint32_t busdevfn, struct pci_range *range ) { */ static int efipci_root_open ( struct pci_device *pci, EFI_HANDLE *handle, EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL **root ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; struct pci_range tmp; union { void *interface; EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *root; } u; - EFI_STATUS efirc; int rc; /* Find matching root bridge I/O protocol handle */ if ( ( rc = efipci_discover_any ( pci, &tmp, handle ) ) != 0 ) return rc; - /* (Re)open PCI root bridge I/O protocol */ - if ( ( efirc = bs->OpenProtocol ( *handle, - &efi_pci_root_bridge_io_protocol_guid, - &u.interface, efi_image_handle, *handle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) { - rc = -EEFI ( efirc ); + /* Open PCI root bridge I/O protocol */ + if ( ( rc = efi_open ( *handle, &efi_pci_root_bridge_io_protocol_guid, + &u.interface ) ) != 0 ) { DBGC ( pci, "EFIPCI " PCI_FMT " cannot open %s: %s\n", PCI_ARGS ( pci ), efi_handle_name ( *handle ), strerror ( rc ) ); @@ -300,19 +284,6 @@ static int efipci_root_open ( struct pci_device *pci, EFI_HANDLE *handle, return 0; } -/** - * Close EFI PCI root bridge I/O protocol - * - * @v handle EFI PCI root bridge handle - */ -static void efipci_root_close ( EFI_HANDLE handle ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; - - /* Close protocol */ - bs->CloseProtocol ( handle, &efi_pci_root_bridge_io_protocol_guid, - efi_image_handle, handle ); -} - /** * Calculate EFI PCI configuration space address * @@ -346,7 +317,7 @@ int efipci_read ( struct pci_device *pci, unsigned long location, /* Open root bridge */ if ( ( rc = efipci_root_open ( pci, &handle, &root ) ) != 0 ) - goto err_root; + return rc; /* Read from configuration space */ if ( ( efirc = root->Pci.Read ( root, EFIPCI_WIDTH ( location ), @@ -356,13 +327,10 @@ int efipci_read ( struct pci_device *pci, unsigned long location, DBGC ( pci, "EFIPCI " PCI_FMT " config read from offset %02lx " "failed: %s\n", PCI_ARGS ( pci ), EFIPCI_OFFSET ( location ), strerror ( rc ) ); - goto err_read; + return rc; } - err_read: - efipci_root_close ( handle ); - err_root: - return rc; + return 0; } /** @@ -382,7 +350,7 @@ int efipci_write ( struct pci_device *pci, unsigned long location, /* Open root bridge */ if ( ( rc = efipci_root_open ( pci, &handle, &root ) ) != 0 ) - goto err_root; + return rc; /* Read from configuration space */ if ( ( efirc = root->Pci.Write ( root, EFIPCI_WIDTH ( location ), @@ -392,13 +360,10 @@ int efipci_write ( struct pci_device *pci, unsigned long location, DBGC ( pci, "EFIPCI " PCI_FMT " config write to offset %02lx " "failed: %s\n", PCI_ARGS ( pci ), EFIPCI_OFFSET ( location ), strerror ( rc ) ); - goto err_write; + return rc; } - err_write: - efipci_root_close ( handle ); - err_root: - return rc; + return 0; } /** @@ -469,7 +434,6 @@ void * efipci_ioremap ( struct pci_device *pci, unsigned long bus_addr, } err_config: - efipci_root_close ( handle ); err_root: return ioremap ( bus_addr, len ); } @@ -778,7 +742,6 @@ static struct dma_operations efipci_dma_operations = { * @ret rc Return status code */ int efipci_info ( EFI_HANDLE device, struct efi_pci_device *efipci ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; union { EFI_PCI_IO_PROTOCOL *pci_io; void *interface; @@ -789,14 +752,11 @@ int efipci_info ( EFI_HANDLE device, struct efi_pci_device *efipci ) { int rc; /* See if device is a PCI device */ - if ( ( efirc = bs->OpenProtocol ( device, &efi_pci_io_protocol_guid, - &pci_io.interface, - efi_image_handle, device, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI_PCI ( efirc ); + if ( ( rc = efi_open ( device, &efi_pci_io_protocol_guid, + &pci_io.interface ) ) != 0 ) { DBGCP ( device, "EFIPCI %s cannot open PCI protocols: %s\n", efi_handle_name ( device ), strerror ( rc ) ); - goto err_open_protocol; + return rc; } efipci->io = pci_io.pci_io; @@ -807,7 +767,7 @@ int efipci_info ( EFI_HANDLE device, struct efi_pci_device *efipci ) { rc = -EEFI ( efirc ); DBGC ( device, "EFIPCI %s could not get PCI location: %s\n", efi_handle_name ( device ), strerror ( rc ) ); - goto err_get_location; + return rc; } busdevfn = PCI_BUSDEVFN ( pci_segment, pci_bus, pci_dev, pci_fn ); pci_init ( &efipci->pci, busdevfn ); @@ -836,17 +796,10 @@ int efipci_info ( EFI_HANDLE device, struct efi_pci_device *efipci ) { DBGC ( device, "EFIPCI " PCI_FMT " cannot read PCI " "configuration: %s\n", PCI_ARGS ( &efipci->pci ), strerror ( rc ) ); - goto err_pci_read_config; + return rc; } return 0; - - err_pci_read_config: - err_get_location: - bs->CloseProtocol ( device, &efi_pci_io_protocol_guid, - efi_image_handle, device ); - err_open_protocol: - return rc; } /****************************************************************************** diff --git a/src/interface/efi/efi_service.c b/src/interface/efi/efi_service.c index d4129c0d9..de7353652 100644 --- a/src/interface/efi/efi_service.c +++ b/src/interface/efi/efi_service.c @@ -45,7 +45,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ int efi_service_add ( EFI_HANDLE service, EFI_GUID *binding, EFI_HANDLE *handle ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; union { EFI_SERVICE_BINDING_PROTOCOL *sb; void *interface; @@ -54,14 +53,11 @@ int efi_service_add ( EFI_HANDLE service, EFI_GUID *binding, int rc; /* Open service binding protocol */ - if ( ( efirc = bs->OpenProtocol ( service, binding, &u.interface, - efi_image_handle, service, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( service, binding, &u.interface ) ) != 0 ) { DBGC ( service, "EFISVC %s cannot open %s binding: %s\n", efi_handle_name ( service ), efi_guid_ntoa ( binding ), strerror ( rc ) ); - goto err_open; + return rc; } /* Create child handle */ @@ -70,19 +66,13 @@ int efi_service_add ( EFI_HANDLE service, EFI_GUID *binding, DBGC ( service, "EFISVC %s could not create %s child: %s\n", efi_handle_name ( service ), efi_guid_ntoa ( binding ), strerror ( rc ) ); - goto err_create; + return rc; } - /* Success */ - rc = 0; DBGC ( service, "EFISVC %s created %s child ", efi_handle_name ( service ), efi_guid_ntoa ( binding ) ); DBGC ( service, "%s\n", efi_handle_name ( *handle ) ); - - err_create: - bs->CloseProtocol ( service, binding, efi_image_handle, service ); - err_open: - return rc; + return 0; } /** @@ -95,7 +85,6 @@ int efi_service_add ( EFI_HANDLE service, EFI_GUID *binding, */ int efi_service_del ( EFI_HANDLE service, EFI_GUID *binding, EFI_HANDLE handle ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; union { EFI_SERVICE_BINDING_PROTOCOL *sb; void *interface; @@ -108,14 +97,11 @@ int efi_service_del ( EFI_HANDLE service, EFI_GUID *binding, DBGC ( service, "%s\n", efi_handle_name ( handle ) ); /* Open service binding protocol */ - if ( ( efirc = bs->OpenProtocol ( service, binding, &u.interface, - efi_image_handle, service, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( service, binding, &u.interface ) ) != 0 ) { DBGC ( service, "EFISVC %s cannot open %s binding: %s\n", efi_handle_name ( service ), efi_guid_ntoa ( binding ), strerror ( rc ) ); - goto err_open; + return rc; } /* Destroy child handle */ @@ -125,14 +111,8 @@ int efi_service_del ( EFI_HANDLE service, EFI_GUID *binding, efi_handle_name ( service ), efi_guid_ntoa ( binding ) ); DBGC ( service, "%s: %s\n", efi_handle_name ( handle ), strerror ( rc ) ); - goto err_destroy; + return rc; } - /* Success */ - rc = 0; - - err_destroy: - bs->CloseProtocol ( service, binding, efi_image_handle, service ); - err_open: - return rc; + return 0; } diff --git a/src/interface/efi/efi_shim.c b/src/interface/efi/efi_shim.c index d5419512d..02bd0791f 100644 --- a/src/interface/efi/efi_shim.c +++ b/src/interface/efi/efi_shim.c @@ -272,7 +272,6 @@ static EFIAPI EFI_STATUS efi_shim_get_memory_map ( UINTN *len, * @ret rc Return status code */ static int efi_shim_inhibit_pxe ( EFI_HANDLE handle ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; union { EFI_PXE_BASE_CODE_PROTOCOL *pxe; void *interface; @@ -281,14 +280,11 @@ static int efi_shim_inhibit_pxe ( EFI_HANDLE handle ) { int rc; /* Locate PXE base code */ - if ( ( efirc = bs->OpenProtocol ( handle, - &efi_pxe_base_code_protocol_guid, - &u.interface, efi_image_handle, NULL, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( handle, &efi_pxe_base_code_protocol_guid, + &u.interface ) ) != 0 ) { DBGC ( &efi_shim, "SHIM could not open PXE base code: %s\n", strerror ( rc ) ); - goto err_no_base; + return rc; } /* Stop PXE base code */ @@ -296,18 +292,11 @@ static int efi_shim_inhibit_pxe ( EFI_HANDLE handle ) { rc = -EEFI ( efirc ); DBGC ( &efi_shim, "SHIM could not stop PXE base code: %s\n", strerror ( rc ) ); - goto err_stop; + return rc; } - /* Success */ - rc = 0; DBGC ( &efi_shim, "SHIM stopped PXE base code\n" ); - - err_stop: - bs->CloseProtocol ( handle, &efi_pxe_base_code_protocol_guid, - efi_image_handle, NULL ); - err_no_base: - return rc; + return 0; } /** diff --git a/src/interface/efi/efi_utils.c b/src/interface/efi/efi_utils.c index 928d8e53a..4f081b67f 100644 --- a/src/interface/efi/efi_utils.c +++ b/src/interface/efi/efi_utils.c @@ -56,12 +56,8 @@ int efi_locate_device ( EFI_HANDLE device, EFI_GUID *protocol, int rc; /* Get device path */ - if ( ( efirc = bs->OpenProtocol ( device, - &efi_device_path_protocol_guid, - &u.interface, - efi_image_handle, device, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( device, &efi_device_path_protocol_guid, + &u.interface ) ) != 0 ) { DBGC ( device, "EFIDEV %s cannot open device path: %s\n", efi_handle_name ( device ), strerror ( rc ) ); goto err_open_device_path; @@ -100,14 +96,9 @@ int efi_locate_device ( EFI_HANDLE device, EFI_GUID *protocol, efi_path_terminate ( end ); } - /* Success */ - rc = 0; - err_locate_protocol: free ( path ); err_alloc_path: - bs->CloseProtocol ( device, &efi_device_path_protocol_guid, - efi_image_handle, device ); err_open_device_path: return rc; } diff --git a/src/interface/efi/efi_veto.c b/src/interface/efi/efi_veto.c index 17bbf7af4..637eee016 100644 --- a/src/interface/efi/efi_veto.c +++ b/src/interface/efi/efi_veto.c @@ -161,21 +161,14 @@ static int efi_veto_uninstall ( struct efi_veto *veto ) { int rc; /* Open driver binding protocol */ - if ( ( efirc = bs->OpenProtocol ( - driver, &efi_driver_binding_protocol_guid, - &binding.interface, efi_image_handle, driver, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) { - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( driver, &efi_driver_binding_protocol_guid, + &binding.interface ) ) != 0 ) { DBGC ( driver, "EFIVETO %s could not open driver binding " "protocol: %s\n", efi_handle_name ( driver ), strerror ( rc ) ); return rc; } - /* Close driver binding protocol */ - bs->CloseProtocol ( driver, &efi_driver_binding_protocol_guid, - efi_image_handle, driver ); - /* Uninstall driver binding protocol */ if ( ( efirc = bs->UninstallMultipleProtocolInterfaces ( driver, &efi_driver_binding_protocol_guid, @@ -541,7 +534,6 @@ static struct efi_veto_candidate efi_vetoes[] = { */ static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer, struct efi_veto *veto ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; union { EFI_DRIVER_BINDING_PROTOCOL *binding; void *interface; @@ -568,47 +560,35 @@ static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer, memset ( veto, 0, sizeof ( *veto ) ); /* Open driver binding protocol */ - if ( ( efirc = bs->OpenProtocol ( - driver, &efi_driver_binding_protocol_guid, - &binding.interface, efi_image_handle, driver, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) { - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( driver, &efi_driver_binding_protocol_guid, + &binding.interface ) ) != 0 ) { DBGC ( driver, "EFIVETO %s could not open driver binding " "protocol: %s\n", efi_handle_name ( driver ), strerror ( rc ) ); - goto err_binding; + return rc; } image = binding.binding->ImageHandle; /* Open loaded image protocol */ - if ( ( efirc = bs->OpenProtocol ( - image, &efi_loaded_image_protocol_guid, - &loaded.interface, efi_image_handle, image, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) { - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( image, &efi_loaded_image_protocol_guid, + &loaded.interface ) ) != 0 ) { DBGC ( driver, "EFIVETO %s could not open", efi_handle_name ( driver ) ); DBGC ( driver, " %s loaded image protocol: %s\n", efi_handle_name ( image ), strerror ( rc ) ); - goto err_loaded; + return rc; } /* Open component name protocol, if present */ - if ( ( efirc = bs->OpenProtocol ( - image, &efi_component_name2_protocol_guid, - &wtf2.interface, efi_image_handle, image, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) { + if ( ( rc = efi_open ( image, &efi_component_name2_protocol_guid, + &wtf2.interface ) ) != 0 ) { /* Ignore failure; is not required to be present */ - wtf2.interface = NULL; } /* Open obsolete component name protocol, if present */ - if ( ( efirc = bs->OpenProtocol ( - image, &efi_component_name_protocol_guid, - &wtf.interface, efi_image_handle, image, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) { + if ( ( rc = efi_open ( image, &efi_component_name_protocol_guid, + &wtf.interface ) ) != 0 ) { /* Ignore failure; is not required to be present */ - wtf.interface = NULL; } /* Get driver name, if available */ @@ -643,25 +623,7 @@ static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer, } } - /* Success */ - rc = 0; - - /* Close protocols */ - if ( wtf.wtf ) { - bs->CloseProtocol ( image, &efi_component_name_protocol_guid, - efi_image_handle, image ); - } - if ( wtf2.wtf2 ) { - bs->CloseProtocol ( image, &efi_component_name2_protocol_guid, - efi_image_handle, image ); - } - bs->CloseProtocol ( image, &efi_loaded_image_protocol_guid, - efi_image_handle, image ); - err_loaded: - bs->CloseProtocol ( driver, &efi_driver_binding_protocol_guid, - efi_image_handle, driver ); - err_binding: - return rc; + return 0; } /** diff --git a/src/interface/efi/efi_wrap.c b/src/interface/efi/efi_wrap.c index 8891f464b..1cc37f3e3 100644 --- a/src/interface/efi/efi_wrap.c +++ b/src/interface/efi/efi_wrap.c @@ -248,20 +248,15 @@ static int efi_prescroll ( unsigned int lines ) { * @v handle Image handle */ static void efi_dump_image ( EFI_HANDLE handle ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; union { EFI_LOADED_IMAGE_PROTOCOL *image; void *intf; } loaded; - EFI_STATUS efirc; int rc; /* Open loaded image protocol */ - if ( ( efirc = bs->OpenProtocol ( handle, - &efi_loaded_image_protocol_guid, - &loaded.intf, efi_image_handle, NULL, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( handle, &efi_loaded_image_protocol_guid, + &loaded.intf ) ) != 0 ) { DBGC ( colour, "WRAP %s could not get loaded image protocol: " "%s\n", efi_handle_name ( handle ), strerror ( rc ) ); return; @@ -277,10 +272,6 @@ static void efi_dump_image ( EFI_HANDLE handle ) { DBGC ( colour, " %s\n", efi_handle_name ( loaded.image->DeviceHandle )); DBGC ( colour, "WRAP %s file", efi_handle_name ( handle ) ); DBGC ( colour, " %s\n", efi_devpath_text ( loaded.image->FilePath ) ); - - /* Close loaded image protocol */ - bs->CloseProtocol ( handle, &efi_loaded_image_protocol_guid, - efi_image_handle, NULL ); } /** -- cgit v1.2.3-55-g7522 From 32a9408217810498deeeae3d2564ab15468c9c39 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 24 Mar 2025 14:24:47 +0000 Subject: [efi] Allow use of typed pointers for efi_open() et al Provide wrapper macros to allow efi_open() and related functions to accept a pointer to any pointer type as the "interface" argument, in order to allow a substantial amount of type adjustment boilerplate to be removed. Signed-off-by: Michael Brown --- src/drivers/net/efi/mnpnet.c | 7 +--- src/drivers/net/efi/nii.c | 11 +---- src/drivers/net/efi/snpnet.c | 4 +- src/drivers/usb/usbio.c | 34 ++++----------- src/image/efi_image.c | 25 +++++------ src/include/ipxe/efi/efi.h | 87 +++++++++++++++++++++++++++++++++++---- src/interface/efi/efi_autoboot.c | 9 ++-- src/interface/efi/efi_block.c | 40 ++++++------------ src/interface/efi/efi_bofm.c | 3 +- src/interface/efi/efi_cachedhcp.c | 9 ++-- src/interface/efi/efi_console.c | 7 +--- src/interface/efi/efi_debug.c | 18 +++----- src/interface/efi/efi_driver.c | 23 ++++------- src/interface/efi/efi_file.c | 11 ++--- src/interface/efi/efi_init.c | 6 +-- src/interface/efi/efi_local.c | 9 ++-- src/interface/efi/efi_open.c | 15 +++---- src/interface/efi/efi_pci.c | 58 +++++++++----------------- src/interface/efi/efi_service.c | 18 +++----- src/interface/efi/efi_shim.c | 9 ++-- src/interface/efi/efi_utils.c | 13 +++--- src/interface/efi/efi_veto.c | 61 ++++++++++----------------- src/interface/efi/efi_wrap.c | 15 +++---- 23 files changed, 215 insertions(+), 277 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/efi/mnpnet.c b/src/drivers/net/efi/mnpnet.c index ead8691ff..902eb91f3 100644 --- a/src/drivers/net/efi/mnpnet.c +++ b/src/drivers/net/efi/mnpnet.c @@ -370,10 +370,6 @@ int mnpnet_start ( struct efi_device *efidev ) { EFI_HANDLE device = efidev->device; EFI_GUID *binding = &efi_managed_network_service_binding_protocol_guid; EFI_SIMPLE_NETWORK_MODE mode; - union { - EFI_MANAGED_NETWORK_PROTOCOL *mnp; - void *interface; - } u; struct net_device *netdev; struct mnp_nic *mnp; EFI_STATUS efirc; @@ -409,12 +405,11 @@ int mnpnet_start ( struct efi_device *efidev ) { /* Open MNP protocol */ if ( ( rc = efi_open_by_driver ( efidev->child, &efi_managed_network_protocol_guid, - &u.interface ) ) != 0 ) { + &mnp->mnp ) ) != 0 ) { DBGC ( mnp, "MNP %s could not open MNP protocol: %s\n", efi_handle_name ( device ), strerror ( rc ) ); goto err_open; } - mnp->mnp = u.mnp; /* Get configuration */ efirc = mnp->mnp->GetModeData ( mnp->mnp, NULL, &mode ); diff --git a/src/drivers/net/efi/nii.c b/src/drivers/net/efi/nii.c index 126584eff..81f1838a4 100644 --- a/src/drivers/net/efi/nii.c +++ b/src/drivers/net/efi/nii.c @@ -209,10 +209,6 @@ static int nii_pci_open ( struct nii_nic *nii ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE device = nii->efidev->device; EFI_HANDLE pci_device; - union { - EFI_PCI_IO_PROTOCOL *pci_io; - void *interface; - } pci_io; union { EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *acpi; void *resource; @@ -237,12 +233,11 @@ static int nii_pci_open ( struct nii_nic *nii ) { * therefore use an unsafe open. */ if ( ( rc = efi_open_unsafe ( pci_device, &efi_pci_io_protocol_guid, - &pci_io.interface ) ) != 0 ) { + &nii->pci_io ) ) != 0 ) { DBGC ( nii, "NII %s could not open PCI I/O protocol: %s\n", nii->dev.name, strerror ( rc ) ); goto err_open; } - nii->pci_io = pci_io.pci_io; /* Identify memory and I/O BARs */ nii->mem_bar = PCI_MAX_BAR; @@ -1272,7 +1267,6 @@ int nii_start ( struct efi_device *efidev ) { EFI_HANDLE device = efidev->device; struct net_device *netdev; struct nii_nic *nii; - void *interface; int rc; /* Allocate and initialise structure */ @@ -1298,13 +1292,12 @@ int nii_start ( struct efi_device *efidev ) { /* Open NII protocol */ if ( ( rc = efi_open_by_driver ( device, &efi_nii31_protocol_guid, - &interface ) ) != 0 ) { + &nii->nii ) ) != 0 ) { DBGC ( nii, "NII %s cannot open NII protocol: %s\n", nii->dev.name, strerror ( rc ) ); DBGC_EFI_OPENERS ( device, device, &efi_nii31_protocol_guid ); goto err_open_protocol; } - nii->nii = interface; /* Locate UNDI and entry point */ nii->undi = ( ( void * ) ( intptr_t ) nii->nii->Id ); diff --git a/src/drivers/net/efi/snpnet.c b/src/drivers/net/efi/snpnet.c index 93ed8cd95..c8e2f2f68 100644 --- a/src/drivers/net/efi/snpnet.c +++ b/src/drivers/net/efi/snpnet.c @@ -504,7 +504,7 @@ int snpnet_supported ( EFI_HANDLE device, EFI_GUID *protocol ) { } /* Test for presence of protocol */ - if ( ( rc = efi_open ( device, protocol, NULL ) ) != 0 ) { + if ( ( rc = efi_test ( device, protocol ) ) != 0 ) { DBGCP ( device, "HANDLE %s is not a %s device\n", efi_handle_name ( device ), efi_guid_ntoa ( protocol ) ); @@ -536,10 +536,10 @@ int snpnet_supported ( EFI_HANDLE device, EFI_GUID *protocol ) { */ int snpnet_start ( struct efi_device *efidev ) { EFI_HANDLE device = efidev->device; + EFI_SIMPLE_NETWORK_PROTOCOL *interface; EFI_SIMPLE_NETWORK_MODE *mode; struct net_device *netdev; struct snp_nic *snp; - void *interface; EFI_STATUS efirc; int rc; diff --git a/src/drivers/usb/usbio.c b/src/drivers/usb/usbio.c index db3beff21..73151c536 100644 --- a/src/drivers/usb/usbio.c +++ b/src/drivers/usb/usbio.c @@ -187,10 +187,6 @@ static int usbio_open ( struct usbio_device *usbio, unsigned int interface ) { EFI_DEVICE_PATH_PROTOCOL *path; EFI_DEVICE_PATH_PROTOCOL *end; USB_DEVICE_PATH *usbpath; - union { - void *interface; - EFI_USB_IO_PROTOCOL *io; - } u; EFI_STATUS efirc; int rc; @@ -231,7 +227,7 @@ static int usbio_open ( struct usbio_device *usbio, unsigned int interface ) { /* Open USB I/O protocol on this handle */ if ( ( rc = efi_open_by_driver ( intf->handle, &efi_usb_io_protocol_guid, - &u.interface ) ) != 0 ) { + &intf->io ) ) != 0 ) { DBGC ( usbio, "USBIO %s cannot open ", efi_handle_name ( handle ) ); DBGC ( usbio, "%s: %s\n", @@ -240,7 +236,6 @@ static int usbio_open ( struct usbio_device *usbio, unsigned int interface ) { &efi_usb_io_protocol_guid ); return rc; } - intf->io = u.io; /* Increment usage count */ intf->count++; @@ -1296,24 +1291,20 @@ static int usbio_supported ( EFI_HANDLE handle ) { struct usb_function_descriptor desc; struct usb_driver *driver; struct usb_device_id *id; - union { - void *interface; - EFI_USB_IO_PROTOCOL *io; - } usb; + EFI_USB_IO_PROTOCOL *io; EFI_STATUS efirc; int rc; /* Get protocol */ if ( ( rc = efi_open ( handle, &efi_usb_io_protocol_guid, - &usb.interface ) ) != 0 ) { + &io ) ) != 0 ) { DBGCP ( handle, "USB %s is not a USB device\n", efi_handle_name ( handle ) ); return rc; } /* Get device descriptor */ - if ( ( efirc = usb.io->UsbGetDeviceDescriptor ( usb.io, - &device ) ) != 0 ) { + if ( ( efirc = io->UsbGetDeviceDescriptor ( io, &device ) ) != 0 ) { rc = -EEFI ( efirc ); DBGC ( handle, "USB %s could not get device descriptor: " "%s\n", efi_handle_name ( handle ), strerror ( rc ) ); @@ -1324,8 +1315,7 @@ static int usbio_supported ( EFI_HANDLE handle ) { desc.product = device.IdProduct; /* Get interface descriptor */ - if ( ( efirc = usb.io->UsbGetInterfaceDescriptor ( usb.io, - &interface ) ) !=0){ + if ( ( efirc = io->UsbGetInterfaceDescriptor ( io, &interface ) ) != 0){ rc = -EEFI ( efirc ); DBGC ( handle, "USB %s could not get interface descriptor: " "%s\n", efi_handle_name ( handle ), strerror ( rc ) ); @@ -1460,21 +1450,16 @@ static int usbio_path ( struct usbio_device *usbio ) { EFI_DEVICE_PATH_PROTOCOL *path; EFI_DEVICE_PATH_PROTOCOL *end; USB_DEVICE_PATH *usbpath; - union { - void *interface; - EFI_DEVICE_PATH_PROTOCOL *path; - } u; size_t len; int rc; /* Open device path protocol */ if ( ( rc = efi_open ( handle, &efi_device_path_protocol_guid, - &u.interface ) ) != 0 ) { + &path ) ) != 0 ) { DBGC ( usbio, "USBIO %s cannot open device path protocol: " "%s\n", efi_handle_name ( handle ), strerror ( rc ) ); return rc; } - path = u.interface; /* Locate end of device path and sanity check */ len = efi_path_len ( path ); @@ -1567,10 +1552,6 @@ static int usbio_start ( struct efi_device *efidev ) { EFI_HANDLE handle = efidev->device; struct usbio_device *usbio; struct usb_port *port; - union { - void *interface; - EFI_USB_IO_PROTOCOL *io; - } u; int rc; /* Allocate and initialise structure */ @@ -1585,13 +1566,12 @@ static int usbio_start ( struct efi_device *efidev ) { /* Open USB I/O protocol */ if ( ( rc = efi_open_by_driver ( handle, &efi_usb_io_protocol_guid, - &u.interface ) ) != 0 ) { + &usbio->io ) ) != 0 ) { DBGC ( usbio, "USBIO %s cannot open USB I/O protocol: %s\n", efi_handle_name ( handle ), strerror ( rc ) ); DBGC_EFI_OPENERS ( usbio, handle, &efi_usb_io_protocol_guid ); goto err_open_usbio; } - usbio->io = u.io; /* Describe generic device */ efi_device_info ( handle, "USB", &usbio->dev ); diff --git a/src/image/efi_image.c b/src/image/efi_image.c index ae9255ce5..82101d484 100644 --- a/src/image/efi_image.c +++ b/src/image/efi_image.c @@ -132,10 +132,7 @@ static int efi_image_exec ( struct image *image ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; struct efi_snp_device *snpdev; EFI_DEVICE_PATH_PROTOCOL *path; - union { - EFI_LOADED_IMAGE_PROTOCOL *image; - void *interface; - } loaded; + EFI_LOADED_IMAGE_PROTOCOL *loaded; struct image *shim; struct image *exec; EFI_HANDLE handle; @@ -235,30 +232,30 @@ static int efi_image_exec ( struct image *image ) { /* Get the loaded image protocol for the newly loaded image */ if ( ( rc = efi_open ( handle, &efi_loaded_image_protocol_guid, - &loaded.interface ) ) != 0 ) { + &loaded ) ) != 0 ) { /* Should never happen */ goto err_open_protocol; } /* Some EFI 1.10 implementations seem not to fill in DeviceHandle */ - if ( loaded.image->DeviceHandle == NULL ) { + if ( loaded->DeviceHandle == NULL ) { DBGC ( image, "EFIIMAGE %s filling in missing DeviceHandle\n", image->name ); - loaded.image->DeviceHandle = snpdev->handle; + loaded->DeviceHandle = snpdev->handle; } /* Sanity checks */ - assert ( loaded.image->ParentHandle == efi_image_handle ); - assert ( loaded.image->DeviceHandle == snpdev->handle ); - assert ( loaded.image->LoadOptionsSize == 0 ); - assert ( loaded.image->LoadOptions == NULL ); + assert ( loaded->ParentHandle == efi_image_handle ); + assert ( loaded->DeviceHandle == snpdev->handle ); + assert ( loaded->LoadOptionsSize == 0 ); + assert ( loaded->LoadOptions == NULL ); /* Record image code type */ - type = loaded.image->ImageCodeType; + type = loaded->ImageCodeType; /* Set command line */ - loaded.image->LoadOptions = cmdline; - loaded.image->LoadOptionsSize = + loaded->LoadOptions = cmdline; + loaded->LoadOptionsSize = ( ( wcslen ( cmdline ) + 1 /* NUL */ ) * sizeof ( wchar_t ) ); /* Release network devices for use via SNP */ diff --git a/src/include/ipxe/efi/efi.h b/src/include/ipxe/efi/efi.h index 6126d3b87..5fae87731 100644 --- a/src/include/ipxe/efi/efi.h +++ b/src/include/ipxe/efi/efi.h @@ -389,17 +389,88 @@ extern EFI_STATUS efi_init ( EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab ); extern void efi_raise_tpl ( struct efi_saved_tpl *tpl ); extern void efi_restore_tpl ( struct efi_saved_tpl *tpl ); -extern int efi_open ( EFI_HANDLE handle, EFI_GUID *protocol, - void **interface ); -extern int efi_open_unsafe ( EFI_HANDLE handle, EFI_GUID *protocol, - void **interface ); +extern int efi_open_untyped ( EFI_HANDLE handle, EFI_GUID *protocol, + void **interface ); +extern int efi_open_unsafe_untyped ( EFI_HANDLE handle, EFI_GUID *protocol, + void **interface ); extern void efi_close_unsafe ( EFI_HANDLE handle, EFI_GUID *protocol ); -extern int efi_open_by_driver ( EFI_HANDLE handle, EFI_GUID *protocol, - void **interface ); +extern int efi_open_by_driver_untyped ( EFI_HANDLE handle, EFI_GUID *protocol, + void **interface ); extern void efi_close_by_driver ( EFI_HANDLE handle, EFI_GUID *protocol ); -extern int efi_open_by_child ( EFI_HANDLE handle, EFI_GUID *protocol, - EFI_HANDLE child, void **interface ); +extern int efi_open_by_child_untyped ( EFI_HANDLE handle, EFI_GUID *protocol, + EFI_HANDLE child, void **interface ); extern void efi_close_by_child ( EFI_HANDLE handle, EFI_GUID *protocol, EFI_HANDLE child ); +/** + * Test protocol existence + * + * @v handle EFI handle + * @v protocol Protocol GUID + * @ret rc Return status code + */ +#define efi_test( handle, protocol ) \ + efi_open_untyped ( (handle), (protocol), NULL ) + +/** + * Open protocol for ephemeral use + * + * @v handle EFI handle + * @v protocol Protocol GUID + * @v interface Protocol interface pointer to fill in + * @ret rc Return status code + */ +#define efi_open( handle, protocol, interface ) ( { \ + typeof ( *(interface) ) check_ptr_ptr = NULL; \ + efi_open_untyped ( (handle), (protocol), \ + ( ( void ) check_ptr_ptr, \ + ( void ** ) (interface) ) ); \ + } ) + +/** + * Open protocol for unsafe persistent use + * + * @v handle EFI handle + * @v protocol Protocol GUID + * @v interface Protocol interface pointer to fill in + * @ret rc Return status code + */ +#define efi_open_unsafe( handle, protocol, interface ) ( { \ + typeof ( *(interface) ) check_ptr_ptr = NULL; \ + efi_open_unsafe_untyped ( (handle), (protocol), \ + ( ( void ) check_ptr_ptr, \ + ( void ** ) (interface) ) ); \ + } ) + +/** + * Open protocol for persistent use by a driver + * + * @v handle EFI handle + * @v protocol Protocol GUID + * @v interface Protocol interface pointer to fill in + * @ret rc Return status code + */ +#define efi_open_by_driver( handle, protocol, interface ) ( { \ + typeof ( *(interface) ) check_ptr_ptr = NULL; \ + efi_open_by_driver_untyped ( (handle), (protocol), \ + ( ( void ) check_ptr_ptr, \ + ( void ** ) (interface) ) ); \ + } ) + +/** + * Open protocol for persistent use by a child controller + * + * @v handle EFI handle + * @v protocol Protocol GUID + * @v child Child controller handle + * @v interface Protocol interface pointer to fill in + * @ret rc Return status code + */ +#define efi_open_by_child( handle, protocol, child, interface ) ( { \ + typeof ( *(interface) ) check_ptr_ptr = NULL; \ + efi_open_by_child_untyped ( (handle), (protocol), (child), \ + ( ( void ) check_ptr_ptr, \ + ( void ** ) (interface) ) ); \ + } ) + #endif /* _IPXE_EFI_H */ diff --git a/src/interface/efi/efi_autoboot.c b/src/interface/efi/efi_autoboot.c index 528b84f1e..e52c857d8 100644 --- a/src/interface/efi/efi_autoboot.c +++ b/src/interface/efi/efi_autoboot.c @@ -48,24 +48,21 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ int efi_set_autoboot_ll_addr ( EFI_HANDLE device, EFI_DEVICE_PATH_PROTOCOL *path ) { - union { - EFI_SIMPLE_NETWORK_PROTOCOL *snp; - void *interface; - } snp; + EFI_SIMPLE_NETWORK_PROTOCOL *snp; EFI_SIMPLE_NETWORK_MODE *mode; unsigned int vlan; int rc; /* Look for an SNP instance on the image's device handle */ if ( ( rc = efi_open ( device, &efi_simple_network_protocol_guid, - &snp.interface ) ) != 0 ) { + &snp ) ) != 0 ) { DBGC ( device, "EFI %s has no SNP instance: %s\n", efi_handle_name ( device ), strerror ( rc ) ); return rc; } /* Record autoboot device */ - mode = snp.snp->Mode; + mode = snp->Mode; vlan = efi_path_vlan ( path ); set_autoboot_ll_addr ( &mode->CurrentAddress, mode->HwAddressSize, vlan ); diff --git a/src/interface/efi/efi_block.c b/src/interface/efi/efi_block.c index 34b73c265..5165bd804 100644 --- a/src/interface/efi/efi_block.c +++ b/src/interface/efi/efi_block.c @@ -518,23 +518,20 @@ static int efi_block_describe ( void ) { */ static int efi_block_root ( unsigned int drive, EFI_HANDLE handle, EFI_FILE_PROTOCOL **root ) { - union { - EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *fs; - void *interface; - } u; + EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *fs; EFI_STATUS efirc; int rc; /* Open filesystem protocol */ if ( ( rc = efi_open ( handle, &efi_simple_file_system_protocol_guid, - &u.interface ) ) != 0 ) { + &fs ) ) != 0 ) { DBGC ( drive, "EFIBLK %#02x could not open %s filesystem: %s\n", drive, efi_handle_name ( handle ), strerror ( rc ) ); return rc; } /* Open root volume */ - if ( ( efirc = u.fs->OpenVolume ( u.fs, root ) ) != 0 ) { + if ( ( efirc = fs->OpenVolume ( fs, root ) ) != 0 ) { rc = -EEFI ( efirc ); DBGC ( drive, "EFIBLK %#02x could not open %s root: %s\n", drive, efi_handle_name ( handle ), strerror ( rc ) ); @@ -664,26 +661,21 @@ static int efi_block_match ( unsigned int drive, EFI_HANDLE handle, EFI_DEVICE_PATH_PROTOCOL *path, struct san_boot_config *config, EFI_DEVICE_PATH_PROTOCOL **fspath ) { - union { - EFI_DEVICE_PATH_PROTOCOL *path; - void *interface; - } u; EFI_FILE *root; union uuid guid; int rc; /* Identify device path */ if ( ( rc = efi_open ( handle, &efi_device_path_protocol_guid, - &u.interface ) ) != 0 ) { + fspath ) ) != 0 ) { DBGC ( drive, "EFIBLK %#02x could not open %s device path: " "%s\n", drive, efi_handle_name ( handle ), strerror ( rc ) ); goto err_open; } - *fspath = u.path; /* Check if filesystem is a child of this block device */ - if ( memcmp ( u.path, path, efi_path_len ( path ) ) != 0 ) { + if ( memcmp ( *fspath, path, efi_path_len ( path ) ) != 0 ) { /* Not a child device */ rc = -ENOTTY; DBGC2 ( drive, "EFIBLK %#02x is not parent of %s\n", @@ -691,11 +683,11 @@ static int efi_block_match ( unsigned int drive, EFI_HANDLE handle, goto err_not_child; } DBGC ( drive, "EFIBLK %#02x contains filesystem %s\n", - drive, efi_devpath_text ( u.path ) ); + drive, efi_devpath_text ( *fspath ) ); /* Check if filesystem matches GUID, if applicable */ if ( config->uuid ) { - if ( ( rc = efi_path_guid ( u.path, &guid ) ) != 0 ) { + if ( ( rc = efi_path_guid ( *fspath, &guid ) ) != 0 ) { DBGC ( drive, "EFIBLK %#02x could not determine GUID: " "%s\n", drive, strerror ( rc ) ); goto err_no_guid; @@ -760,10 +752,7 @@ static int efi_block_scan ( unsigned int drive, EFI_HANDLE handle, struct san_boot_config *config, EFI_DEVICE_PATH_PROTOCOL **fspath ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; - union { - EFI_DEVICE_PATH_PROTOCOL *path; - void *interface; - } u; + EFI_DEVICE_PATH_PROTOCOL *path; EFI_HANDLE *handles; UINTN count; unsigned int i; @@ -775,7 +764,7 @@ static int efi_block_scan ( unsigned int drive, EFI_HANDLE handle, /* Identify device path */ if ( ( rc = efi_open ( handle, &efi_device_path_protocol_guid, - &u.interface ) ) != 0 ) { + &path ) ) != 0 ) { DBGC ( drive, "EFIBLK %#02x could not open device path: %s\n", drive, strerror ( rc ) ); goto err_open; @@ -796,7 +785,7 @@ static int efi_block_scan ( unsigned int drive, EFI_HANDLE handle, for ( i = 0 ; i < count ; i++ ) { /* Check for a matching filesystem */ - if ( ( rc = efi_block_match ( drive, handles[i], u.path, + if ( ( rc = efi_block_match ( drive, handles[i], path, config, fspath ) ) != 0 ) continue; @@ -903,10 +892,7 @@ static int efi_block_exec ( unsigned int drive, static int efi_block_local ( EFI_HANDLE handle ) { struct san_device *sandev; struct efi_block_data *block; - union { - EFI_BLOCK_IO_PROTOCOL *blockio; - void *interface; - } u; + EFI_BLOCK_IO_PROTOCOL *blockio; int rc; /* Check if handle belongs to a SAN device */ @@ -918,14 +904,14 @@ static int efi_block_local ( EFI_HANDLE handle ) { /* Open block I/O protocol */ if ( ( rc = efi_open ( handle, &efi_block_io_protocol_guid, - &u.interface ) ) != 0 ) { + &blockio ) ) != 0 ) { DBGC ( handle, "EFIBLK %s could not open block I/O: %s\n", efi_handle_name ( handle ), strerror ( rc ) ); return rc; } /* Do not assign drive numbers for partitions */ - if ( u.blockio->Media->LogicalPartition ) { + if ( blockio->Media->LogicalPartition ) { DBGC2 ( handle, "EFLBLK %s is a partition\n", efi_handle_name ( handle ) ); return -ENOTTY; diff --git a/src/interface/efi/efi_bofm.c b/src/interface/efi/efi_bofm.c index 6d97ff445..b64770d8a 100644 --- a/src/interface/efi/efi_bofm.c +++ b/src/interface/efi/efi_bofm.c @@ -228,7 +228,6 @@ static int efi_bofm_start ( struct efi_device *efidev ) { struct efi_pci_device efipci; IBM_BOFM_TABLE *bofmtab; IBM_BOFM_TABLE *bofmtab2; - void *pci_io; int bofmrc; EFI_STATUS efirc; int rc; @@ -242,7 +241,7 @@ static int efi_bofm_start ( struct efi_device *efidev ) { /* Open PCI I/O protocol */ if ( ( rc = efi_open_unsafe ( device, &efi_pci_io_protocol_guid, - &pci_io ) ) != 0 ) { + &efipci.io ) ) != 0 ) { DBGC ( device, "EFIBOFM %s cannot open PCI device: %s\n", efi_handle_name ( device ), strerror ( rc ) ); goto err_open; diff --git a/src/interface/efi/efi_cachedhcp.c b/src/interface/efi/efi_cachedhcp.c index 68671d7c6..eb41a8e43 100644 --- a/src/interface/efi/efi_cachedhcp.c +++ b/src/interface/efi/efi_cachedhcp.c @@ -47,10 +47,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); int efi_cachedhcp_record ( EFI_HANDLE device, EFI_DEVICE_PATH_PROTOCOL *path ) { unsigned int vlan; - union { - EFI_PXE_BASE_CODE_PROTOCOL *pxe; - void *interface; - } pxe; + EFI_PXE_BASE_CODE_PROTOCOL *pxe; EFI_PXE_BASE_CODE_MODE *mode; int rc; @@ -59,14 +56,14 @@ int efi_cachedhcp_record ( EFI_HANDLE device, /* Look for a PXE base code instance on the image's device handle */ if ( ( rc = efi_open ( device, &efi_pxe_base_code_protocol_guid, - &pxe.interface ) ) != 0 ) { + &pxe ) ) != 0 ) { DBGC ( device, "EFI %s has no PXE base code instance: %s\n", efi_handle_name ( device ), strerror ( rc ) ); return rc; } /* Do not attempt to cache IPv6 packets */ - mode = pxe.pxe->Mode; + mode = pxe->Mode; if ( mode->UsingIpv6 ) { DBGC ( device, "EFI %s has IPv6 PXE base code\n", efi_handle_name ( device ) ); diff --git a/src/interface/efi/efi_console.c b/src/interface/efi/efi_console.c index 41c4dcf2c..9fc3c65c0 100644 --- a/src/interface/efi/efi_console.c +++ b/src/interface/efi/efi_console.c @@ -416,10 +416,6 @@ struct console_driver efi_console __console_driver = { */ static void efi_console_init ( void ) { EFI_CONSOLE_CONTROL_SCREEN_MODE mode; - union { - void *interface; - EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *wtf; - } u; int rc; /* On some older EFI 1.10 implementations, we must use the @@ -441,8 +437,7 @@ static void efi_console_init ( void ) { */ if ( ( rc = efi_open_unsafe ( efi_systab->ConsoleInHandle, &efi_simple_text_input_ex_protocol_guid, - &u.interface ) ) == 0 ) { - efi_conin_ex = u.wtf; + &efi_conin_ex ) ) == 0 ) { DBG ( "EFI using SimpleTextInputEx\n" ); } else { DBG ( "EFI has no SimpleTextInputEx: %s\n", strerror ( rc ) ); diff --git a/src/interface/efi/efi_debug.c b/src/interface/efi/efi_debug.c index fd4997ccc..026adc25e 100644 --- a/src/interface/efi/efi_debug.c +++ b/src/interface/efi/efi_debug.c @@ -324,10 +324,7 @@ static const char * efi_driver_name2 ( EFI_COMPONENT_NAME2_PROTOCOL *wtf ) { * @ret name Driver name, or NULL */ static const char * efi_binding_name ( EFI_DRIVER_BINDING_PROTOCOL *binding ) { - union { - EFI_COMPONENT_NAME_PROTOCOL *name; - void *interface; - } u; + EFI_COMPONENT_NAME_PROTOCOL *name; EFI_HANDLE image; int rc; @@ -340,13 +337,13 @@ static const char * efi_binding_name ( EFI_DRIVER_BINDING_PROTOCOL *binding ) { /* Try to open component name protocol on image handle */ image = binding->ImageHandle; if ( ( rc = efi_open ( image, &efi_component_name_protocol_guid, - &u.interface ) ) != 0 ) { + &name ) ) != 0 ) { DBG ( "[DriverBinding no ComponentName]" ); return NULL; } /* Try to get name from component name protocol */ - return efi_driver_name ( u.name ); + return efi_driver_name ( name ); } /** @@ -357,10 +354,7 @@ static const char * efi_binding_name ( EFI_DRIVER_BINDING_PROTOCOL *binding ) { */ static const char * efi_binding_name2 ( EFI_DRIVER_BINDING_PROTOCOL *binding ){ EFI_HANDLE image; - union { - EFI_COMPONENT_NAME2_PROTOCOL *name2; - void *interface; - } u; + EFI_COMPONENT_NAME2_PROTOCOL *name2; int rc; /* Sanity check */ @@ -372,13 +366,13 @@ static const char * efi_binding_name2 ( EFI_DRIVER_BINDING_PROTOCOL *binding ){ /* Try to open component name protocol on image handle */ image = binding->ImageHandle; if ( ( rc = efi_open ( image, &efi_component_name2_protocol_guid, - &u.interface ) ) != 0 ) { + &name2 ) ) != 0 ) { DBG ( "[DriverBinding no ComponentName2]" ); return NULL; } /* Try to get name from component name protocol */ - return efi_driver_name2 ( u.name2 ); + return efi_driver_name2 ( name2 ); } /** diff --git a/src/interface/efi/efi_driver.c b/src/interface/efi/efi_driver.c index d143249ca..56918deba 100644 --- a/src/interface/efi/efi_driver.c +++ b/src/interface/efi/efi_driver.c @@ -69,22 +69,19 @@ static int efi_driver_disconnecting; */ struct efi_device * efidev_alloc ( EFI_HANDLE device ) { struct efi_device *efidev = NULL; - union { - EFI_DEVICE_PATH_PROTOCOL *path; - void *interface; - } path; + EFI_DEVICE_PATH_PROTOCOL *path; EFI_DEVICE_PATH_PROTOCOL *path_end; size_t path_len; int rc; /* Open device path */ if ( ( rc = efi_open ( device, &efi_device_path_protocol_guid, - &path.interface ) ) != 0 ) { + &path ) ) != 0 ) { DBGC ( device, "EFIDRV %s could not open device path: %s\n", efi_handle_name ( device ), strerror ( rc ) ); return NULL; } - path_len = ( efi_path_len ( path.path ) + sizeof ( *path_end ) ); + path_len = ( efi_path_len ( path ) + sizeof ( *path_end ) ); /* Allocate and initialise structure */ efidev = zalloc ( sizeof ( *efidev ) + path_len ); @@ -93,7 +90,7 @@ struct efi_device * efidev_alloc ( EFI_HANDLE device ) { efidev->device = device; efidev->dev.desc.bus_type = BUS_TYPE_EFI; efidev->path = ( ( ( void * ) efidev ) + sizeof ( *efidev ) ); - memcpy ( efidev->path, path.path, path_len ); + memcpy ( efidev->path, path, path_len ); INIT_LIST_HEAD ( &efidev->dev.children ); list_add ( &efidev->dev.siblings, &efi_devices ); @@ -365,10 +362,7 @@ static EFI_STATUS EFIAPI efi_driver_controller_name ( EFI_COMPONENT_NAME2_PROTOCOL *wtf __unused, EFI_HANDLE device, EFI_HANDLE child, CHAR8 *language, CHAR16 **controller_name ) { - union { - EFI_COMPONENT_NAME2_PROTOCOL *name2; - void *interface; - } name2; + EFI_COMPONENT_NAME2_PROTOCOL *name2; int rc; /* Delegate to the EFI_COMPONENT_NAME2_PROTOCOL instance @@ -376,10 +370,9 @@ efi_driver_controller_name ( EFI_COMPONENT_NAME2_PROTOCOL *wtf __unused, */ if ( ( child != NULL ) && ( ( rc = efi_open ( child, &efi_component_name2_protocol_guid, - &name2.interface ) ) == 0 ) ) { - return name2.name2->GetControllerName ( name2.name2, device, - child, language, - controller_name ); + &name2 ) ) == 0 ) ) { + return name2->GetControllerName ( name2, device, child, + language, controller_name ); } /* Otherwise, let EFI use the default Device Path Name */ diff --git a/src/interface/efi/efi_file.c b/src/interface/efi/efi_file.c index d8b9f819c..b7b97aee7 100644 --- a/src/interface/efi/efi_file.c +++ b/src/interface/efi/efi_file.c @@ -982,9 +982,9 @@ static EFI_DISK_IO_PROTOCOL efi_disk_io_protocol = { */ static int efi_file_path_claim ( struct efi_file_path *file ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; + EFI_DEVICE_PATH_PROTOCOL *old; EFI_DEVICE_PATH_PROTOCOL *end; EFI_HANDLE handle; - VOID *old; EFI_STATUS efirc; int rc; @@ -1116,10 +1116,7 @@ static void efi_file_path_uninstall ( struct efi_file_path *file ) { */ int efi_file_install ( EFI_HANDLE handle ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; - union { - EFI_DISK_IO_PROTOCOL *diskio; - void *interface; - } diskio; + EFI_DISK_IO_PROTOCOL *diskio; struct image *image; EFI_STATUS efirc; int rc; @@ -1168,13 +1165,13 @@ int efi_file_install ( EFI_HANDLE handle ) { * shell. I have no idea why this is. */ if ( ( rc = efi_open_by_driver ( handle, &efi_disk_io_protocol_guid, - &diskio.interface ) ) != 0 ) { + &diskio ) ) != 0 ) { DBGC ( handle, "Could not open disk I/O protocol: %s\n", strerror ( rc ) ); DBGC_EFI_OPENERS ( handle, handle, &efi_disk_io_protocol_guid ); goto err_open; } - assert ( diskio.diskio == &efi_disk_io_protocol ); + assert ( diskio == &efi_disk_io_protocol ); /* Claim Linux initrd fixed device path */ if ( ( rc = efi_file_path_claim ( &efi_file_initrd ) ) != 0 ) diff --git a/src/interface/efi/efi_init.c b/src/interface/efi/efi_init.c index 03506ec5c..1ba144ee7 100644 --- a/src/interface/efi/efi_init.c +++ b/src/interface/efi/efi_init.c @@ -173,8 +173,7 @@ EFI_STATUS efi_init ( EFI_HANDLE image_handle, EFI_BOOT_SERVICES *bs; struct efi_protocol *prot; struct efi_config_table *tab; - void *loaded_image; - void *device_path; + EFI_DEVICE_PATH_PROTOCOL *device_path; void *device_path_copy; size_t device_path_len; EFI_STATUS efirc; @@ -248,13 +247,12 @@ EFI_STATUS efi_init ( EFI_HANDLE image_handle, */ if ( ( rc = efi_open_unsafe ( image_handle, &efi_loaded_image_protocol_guid, - &loaded_image ) ) != 0 ) { + &efi_loaded_image ) ) != 0 ) { DBGC ( systab, "EFI could not get loaded image protocol: %s", strerror ( rc ) ); efirc = EFIRC ( rc ); goto err_no_loaded_image; } - efi_loaded_image = loaded_image; DBGC ( systab, "EFI image base address %p\n", efi_loaded_image->ImageBase ); diff --git a/src/interface/efi/efi_local.c b/src/interface/efi/efi_local.c index 80cfb5a22..4564470fc 100644 --- a/src/interface/efi/efi_local.c +++ b/src/interface/efi/efi_local.c @@ -208,23 +208,20 @@ static int efi_local_check_volume_name ( struct efi_local *local, */ static int efi_local_open_root ( struct efi_local *local, EFI_HANDLE device, EFI_FILE_PROTOCOL **root ) { - union { - void *interface; - EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *fs; - } u; + EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *fs; EFI_STATUS efirc; int rc; /* Open file system protocol */ if ( ( rc = efi_open ( device, &efi_simple_file_system_protocol_guid, - &u.interface ) ) != 0 ) { + &fs ) ) != 0 ) { DBGC ( local, "LOCAL %p could not open filesystem on %s: %s\n", local, efi_handle_name ( device ), strerror ( rc ) ); return rc; } /* Open root directory */ - if ( ( efirc = u.fs->OpenVolume ( u.fs, root ) ) != 0 ) { + if ( ( efirc = fs->OpenVolume ( fs, root ) ) != 0 ) { rc = -EEFI ( efirc ); DBGC ( local, "LOCAL %p could not open volume on %s: %s\n", local, efi_handle_name ( device ), strerror ( rc ) ); diff --git a/src/interface/efi/efi_open.c b/src/interface/efi/efi_open.c index c85c027e1..8f8af4ea0 100644 --- a/src/interface/efi/efi_open.c +++ b/src/interface/efi/efi_open.c @@ -93,7 +93,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * @v interface Protocol interface pointer to fill in (or NULL to test) * @ret rc Return status code */ -int efi_open ( EFI_HANDLE handle, EFI_GUID *protocol, void **interface ) { +int efi_open_untyped ( EFI_HANDLE handle, EFI_GUID *protocol, + void **interface ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE agent = efi_image_handle; EFI_HANDLE controller; @@ -176,8 +177,8 @@ int efi_open ( EFI_HANDLE handle, EFI_GUID *protocol, void **interface ) { * @v interface Protocol interface pointer to fill in * @ret rc Return status code */ -int efi_open_unsafe ( EFI_HANDLE handle, EFI_GUID *protocol, - void **interface ) { +int efi_open_unsafe_untyped ( EFI_HANDLE handle, EFI_GUID *protocol, + void **interface ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE agent = efi_image_handle; EFI_HANDLE controller; @@ -236,8 +237,8 @@ void efi_close_unsafe ( EFI_HANDLE handle, EFI_GUID *protocol ) { * @v interface Protocol interface pointer to fill in * @ret rc Return status code */ -int efi_open_by_driver ( EFI_HANDLE handle, EFI_GUID *protocol, - void **interface ) { +int efi_open_by_driver_untyped ( EFI_HANDLE handle, EFI_GUID *protocol, + void **interface ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE agent = efi_image_handle; EFI_HANDLE controller; @@ -297,8 +298,8 @@ void efi_close_by_driver ( EFI_HANDLE handle, EFI_GUID *protocol ) { * @v interface Protocol interface pointer to fill in * @ret rc Return status code */ -int efi_open_by_child ( EFI_HANDLE handle, EFI_GUID *protocol, - EFI_HANDLE child, void **interface ) { +int efi_open_by_child_untyped ( EFI_HANDLE handle, EFI_GUID *protocol, + EFI_HANDLE child, void **interface ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE agent = efi_image_handle; EFI_HANDLE controller; diff --git a/src/interface/efi/efi_pci.c b/src/interface/efi/efi_pci.c index 003fa2f4a..0662302d2 100644 --- a/src/interface/efi/efi_pci.c +++ b/src/interface/efi/efi_pci.c @@ -72,10 +72,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ static int efipci_discover_one ( struct pci_device *pci, EFI_HANDLE handle, struct pci_range *range ) { - union { - void *interface; - EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *root; - } root; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *root; union { union acpi_resource *res; void *raw; @@ -94,7 +91,7 @@ static int efipci_discover_one ( struct pci_device *pci, EFI_HANDLE handle, /* Open root bridge I/O protocol */ if ( ( rc = efi_open ( handle, &efi_pci_root_bridge_io_protocol_guid, - &root.interface ) ) != 0 ) { + &root ) ) != 0 ) { DBGC ( pci, "EFIPCI " PCI_FMT " cannot open %s: %s\n", PCI_ARGS ( pci ), efi_handle_name ( handle ), strerror ( rc ) ); @@ -102,8 +99,7 @@ static int efipci_discover_one ( struct pci_device *pci, EFI_HANDLE handle, } /* Get ACPI resource descriptors */ - if ( ( efirc = root.root->Configuration ( root.root, - &acpi.raw ) ) != 0 ) { + if ( ( efirc = root->Configuration ( root, &acpi.raw ) ) != 0 ) { rc = -EEFI ( efirc ); DBGC ( pci, "EFIPCI " PCI_FMT " cannot get configuration for " "%s: %s\n", PCI_ARGS ( pci ), @@ -123,13 +119,13 @@ static int efipci_discover_one ( struct pci_device *pci, EFI_HANDLE handle, continue; /* Get range for this descriptor */ - start = PCI_BUSDEVFN ( root.root->SegmentNumber, + start = PCI_BUSDEVFN ( root->SegmentNumber, le64_to_cpu ( acpi.res->qword.min ), 0, 0 ); count = PCI_BUSDEVFN ( 0, le64_to_cpu ( acpi.res->qword.len ), 0, 0 ); DBGC2 ( pci, "EFIPCI " PCI_FMT " found %04x:[%02x-%02x] via " - "%s\n", PCI_ARGS ( pci ), root.root->SegmentNumber, + "%s\n", PCI_ARGS ( pci ), root->SegmentNumber, PCI_BUS ( start ), PCI_BUS ( start + count - 1 ), efi_handle_name ( handle ) ); @@ -150,8 +146,7 @@ static int efipci_discover_one ( struct pci_device *pci, EFI_HANDLE handle, * bridge has a single bus. */ if ( ! range->count ) { - range->start = PCI_BUSDEVFN ( root.root->SegmentNumber, - 0, 0, 0 ); + range->start = PCI_BUSDEVFN ( root->SegmentNumber, 0, 0, 0 ); range->count = PCI_BUSDEVFN ( 0, 1, 0, 0 ); } @@ -259,10 +254,6 @@ static void efipci_discover ( uint32_t busdevfn, struct pci_range *range ) { static int efipci_root_open ( struct pci_device *pci, EFI_HANDLE *handle, EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL **root ) { struct pci_range tmp; - union { - void *interface; - EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *root; - } u; int rc; /* Find matching root bridge I/O protocol handle */ @@ -271,16 +262,13 @@ static int efipci_root_open ( struct pci_device *pci, EFI_HANDLE *handle, /* Open PCI root bridge I/O protocol */ if ( ( rc = efi_open ( *handle, &efi_pci_root_bridge_io_protocol_guid, - &u.interface ) ) != 0 ) { + root ) ) != 0 ) { DBGC ( pci, "EFIPCI " PCI_FMT " cannot open %s: %s\n", PCI_ARGS ( pci ), efi_handle_name ( *handle ), strerror ( rc ) ); return rc; } - /* Return opened protocol */ - *root = u.root; - return 0; } @@ -742,10 +730,7 @@ static struct dma_operations efipci_dma_operations = { * @ret rc Return status code */ int efipci_info ( EFI_HANDLE device, struct efi_pci_device *efipci ) { - union { - EFI_PCI_IO_PROTOCOL *pci_io; - void *interface; - } pci_io; + EFI_PCI_IO_PROTOCOL *pci_io; UINTN pci_segment, pci_bus, pci_dev, pci_fn; unsigned int busdevfn; EFI_STATUS efirc; @@ -753,17 +738,16 @@ int efipci_info ( EFI_HANDLE device, struct efi_pci_device *efipci ) { /* See if device is a PCI device */ if ( ( rc = efi_open ( device, &efi_pci_io_protocol_guid, - &pci_io.interface ) ) != 0 ) { + &pci_io ) ) != 0 ) { DBGCP ( device, "EFIPCI %s cannot open PCI protocols: %s\n", efi_handle_name ( device ), strerror ( rc ) ); return rc; } - efipci->io = pci_io.pci_io; + efipci->io = pci_io; /* Get PCI bus:dev.fn address */ - if ( ( efirc = pci_io.pci_io->GetLocation ( pci_io.pci_io, &pci_segment, - &pci_bus, &pci_dev, - &pci_fn ) ) != 0 ) { + if ( ( efirc = pci_io->GetLocation ( pci_io, &pci_segment, &pci_bus, + &pci_dev, &pci_fn ) ) != 0 ) { rc = -EEFI ( efirc ); DBGC ( device, "EFIPCI %s could not get PCI location: %s\n", efi_handle_name ( device ), strerror ( rc ) ); @@ -781,15 +765,12 @@ int efipci_info ( EFI_HANDLE device, struct efi_pci_device *efipci ) { * support I/O cycles). Work around any such platforms by * enabling bits individually and simply ignoring any errors. */ - pci_io.pci_io->Attributes ( pci_io.pci_io, - EfiPciIoAttributeOperationEnable, - EFI_PCI_IO_ATTRIBUTE_IO, NULL ); - pci_io.pci_io->Attributes ( pci_io.pci_io, - EfiPciIoAttributeOperationEnable, - EFI_PCI_IO_ATTRIBUTE_MEMORY, NULL ); - pci_io.pci_io->Attributes ( pci_io.pci_io, - EfiPciIoAttributeOperationEnable, - EFI_PCI_IO_ATTRIBUTE_BUS_MASTER, NULL ); + pci_io->Attributes ( pci_io, EfiPciIoAttributeOperationEnable, + EFI_PCI_IO_ATTRIBUTE_IO, NULL ); + pci_io->Attributes ( pci_io, EfiPciIoAttributeOperationEnable, + EFI_PCI_IO_ATTRIBUTE_MEMORY, NULL ); + pci_io->Attributes ( pci_io, EfiPciIoAttributeOperationEnable, + EFI_PCI_IO_ATTRIBUTE_BUS_MASTER, NULL ); /* Populate PCI device */ if ( ( rc = pci_read_config ( &efipci->pci ) ) != 0 ) { @@ -857,7 +838,6 @@ static int efipci_supported ( EFI_HANDLE device ) { static int efipci_start ( struct efi_device *efidev ) { EFI_HANDLE device = efidev->device; struct efi_pci_device *efipci; - void *pci_io; int rc; /* Allocate PCI device */ @@ -873,7 +853,7 @@ static int efipci_start ( struct efi_device *efidev ) { /* Open PCI I/O protocol */ if ( ( rc = efi_open_by_driver ( device, &efi_pci_io_protocol_guid, - &pci_io ) ) != 0 ) { + &efipci->io ) ) != 0 ) { DBGC ( device, "EFIPCI %s could not open PCI device: %s\n", efi_handle_name ( device ), strerror ( rc ) ); DBGC_EFI_OPENERS ( device, device, &efi_pci_io_protocol_guid ); diff --git a/src/interface/efi/efi_service.c b/src/interface/efi/efi_service.c index de7353652..f10733b24 100644 --- a/src/interface/efi/efi_service.c +++ b/src/interface/efi/efi_service.c @@ -45,15 +45,12 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ int efi_service_add ( EFI_HANDLE service, EFI_GUID *binding, EFI_HANDLE *handle ) { - union { - EFI_SERVICE_BINDING_PROTOCOL *sb; - void *interface; - } u; + EFI_SERVICE_BINDING_PROTOCOL *sb; EFI_STATUS efirc; int rc; /* Open service binding protocol */ - if ( ( rc = efi_open ( service, binding, &u.interface ) ) != 0 ) { + if ( ( rc = efi_open ( service, binding, &sb ) ) != 0 ) { DBGC ( service, "EFISVC %s cannot open %s binding: %s\n", efi_handle_name ( service ), efi_guid_ntoa ( binding ), strerror ( rc ) ); @@ -61,7 +58,7 @@ int efi_service_add ( EFI_HANDLE service, EFI_GUID *binding, } /* Create child handle */ - if ( ( efirc = u.sb->CreateChild ( u.sb, handle ) ) != 0 ) { + if ( ( efirc = sb->CreateChild ( sb, handle ) ) != 0 ) { rc = -EEFI ( efirc ); DBGC ( service, "EFISVC %s could not create %s child: %s\n", efi_handle_name ( service ), efi_guid_ntoa ( binding ), @@ -85,10 +82,7 @@ int efi_service_add ( EFI_HANDLE service, EFI_GUID *binding, */ int efi_service_del ( EFI_HANDLE service, EFI_GUID *binding, EFI_HANDLE handle ) { - union { - EFI_SERVICE_BINDING_PROTOCOL *sb; - void *interface; - } u; + EFI_SERVICE_BINDING_PROTOCOL *sb; EFI_STATUS efirc; int rc; @@ -97,7 +91,7 @@ int efi_service_del ( EFI_HANDLE service, EFI_GUID *binding, DBGC ( service, "%s\n", efi_handle_name ( handle ) ); /* Open service binding protocol */ - if ( ( rc = efi_open ( service, binding, &u.interface ) ) != 0 ) { + if ( ( rc = efi_open ( service, binding, &sb ) ) != 0 ) { DBGC ( service, "EFISVC %s cannot open %s binding: %s\n", efi_handle_name ( service ), efi_guid_ntoa ( binding ), strerror ( rc ) ); @@ -105,7 +99,7 @@ int efi_service_del ( EFI_HANDLE service, EFI_GUID *binding, } /* Destroy child handle */ - if ( ( efirc = u.sb->DestroyChild ( u.sb, handle ) ) != 0 ) { + if ( ( efirc = sb->DestroyChild ( sb, handle ) ) != 0 ) { rc = -EEFI ( efirc ); DBGC ( service, "EFISVC %s could not destroy %s child ", efi_handle_name ( service ), efi_guid_ntoa ( binding ) ); diff --git a/src/interface/efi/efi_shim.c b/src/interface/efi/efi_shim.c index 02bd0791f..4bb6df79f 100644 --- a/src/interface/efi/efi_shim.c +++ b/src/interface/efi/efi_shim.c @@ -272,23 +272,20 @@ static EFIAPI EFI_STATUS efi_shim_get_memory_map ( UINTN *len, * @ret rc Return status code */ static int efi_shim_inhibit_pxe ( EFI_HANDLE handle ) { - union { - EFI_PXE_BASE_CODE_PROTOCOL *pxe; - void *interface; - } u; + EFI_PXE_BASE_CODE_PROTOCOL *pxe; EFI_STATUS efirc; int rc; /* Locate PXE base code */ if ( ( rc = efi_open ( handle, &efi_pxe_base_code_protocol_guid, - &u.interface ) ) != 0 ) { + &pxe ) ) != 0 ) { DBGC ( &efi_shim, "SHIM could not open PXE base code: %s\n", strerror ( rc ) ); return rc; } /* Stop PXE base code */ - if ( ( efirc = u.pxe->Stop ( u.pxe ) ) != 0 ) { + if ( ( efirc = pxe->Stop ( pxe ) ) != 0 ) { rc = -EEFI ( efirc ); DBGC ( &efi_shim, "SHIM could not stop PXE base code: %s\n", strerror ( rc ) ); diff --git a/src/interface/efi/efi_utils.c b/src/interface/efi/efi_utils.c index 4f081b67f..51da06172 100644 --- a/src/interface/efi/efi_utils.c +++ b/src/interface/efi/efi_utils.c @@ -45,10 +45,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); int efi_locate_device ( EFI_HANDLE device, EFI_GUID *protocol, EFI_HANDLE *parent, unsigned int skip ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; - union { - EFI_DEVICE_PATH_PROTOCOL *path; - void *interface; - } u; + EFI_DEVICE_PATH_PROTOCOL *devpath; EFI_DEVICE_PATH_PROTOCOL *path; EFI_DEVICE_PATH_PROTOCOL *end; size_t len; @@ -57,20 +54,20 @@ int efi_locate_device ( EFI_HANDLE device, EFI_GUID *protocol, /* Get device path */ if ( ( rc = efi_open ( device, &efi_device_path_protocol_guid, - &u.interface ) ) != 0 ) { + &devpath ) ) != 0 ) { DBGC ( device, "EFIDEV %s cannot open device path: %s\n", efi_handle_name ( device ), strerror ( rc ) ); goto err_open_device_path; } /* Create modifiable copy of device path */ - len = ( efi_path_len ( u.path ) + sizeof ( EFI_DEVICE_PATH_PROTOCOL )); + len = ( efi_path_len ( devpath ) + sizeof ( *end ) ); path = malloc ( len ); if ( ! path ) { rc = -ENOMEM; goto err_alloc_path; } - memcpy ( path, u.path, len ); + memcpy ( path, devpath, len ); /* Locate parent device(s) */ while ( 1 ) { @@ -111,7 +108,7 @@ int efi_locate_device ( EFI_HANDLE device, EFI_GUID *protocol, * @ret rc Return status code */ int efi_child_add ( EFI_HANDLE parent, EFI_HANDLE child ) { - void *devpath; + EFI_DEVICE_PATH_PROTOCOL *devpath; int rc; /* Re-open the device path protocol */ diff --git a/src/interface/efi/efi_veto.c b/src/interface/efi/efi_veto.c index 637eee016..3f9c9940e 100644 --- a/src/interface/efi/efi_veto.c +++ b/src/interface/efi/efi_veto.c @@ -153,16 +153,13 @@ static int efi_veto_disconnect ( struct efi_veto *veto ) { static int efi_veto_uninstall ( struct efi_veto *veto ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE driver = veto->driver; - union { - EFI_DRIVER_BINDING_PROTOCOL *binding; - void *interface; - } binding; + EFI_DRIVER_BINDING_PROTOCOL *binding; EFI_STATUS efirc; int rc; /* Open driver binding protocol */ if ( ( rc = efi_open ( driver, &efi_driver_binding_protocol_guid, - &binding.interface ) ) != 0 ) { + &binding ) ) != 0 ) { DBGC ( driver, "EFIVETO %s could not open driver binding " "protocol: %s\n", efi_handle_name ( driver ), strerror ( rc ) ); @@ -172,7 +169,7 @@ static int efi_veto_uninstall ( struct efi_veto *veto ) { /* Uninstall driver binding protocol */ if ( ( efirc = bs->UninstallMultipleProtocolInterfaces ( driver, &efi_driver_binding_protocol_guid, - binding.binding, NULL ) ) != 0 ) { + binding, NULL ) ) != 0 ) { rc = -EEFI ( efirc ); DBGC ( driver, "EFIVETO %s could not uninstall driver " "binding protocol: %s\n", @@ -534,22 +531,10 @@ static struct efi_veto_candidate efi_vetoes[] = { */ static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer, struct efi_veto *veto ) { - union { - EFI_DRIVER_BINDING_PROTOCOL *binding; - void *interface; - } binding; - union { - EFI_LOADED_IMAGE_PROTOCOL *loaded; - void *interface; - } loaded; - union { - EFI_COMPONENT_NAME2_PROTOCOL *wtf2; - void *interface; - } wtf2; - union { - EFI_COMPONENT_NAME_PROTOCOL *wtf; - void *interface; - } wtf; + EFI_DRIVER_BINDING_PROTOCOL *binding; + EFI_LOADED_IMAGE_PROTOCOL *loaded; + EFI_COMPONENT_NAME2_PROTOCOL *wtf2; + EFI_COMPONENT_NAME_PROTOCOL *wtf; CHAR16 *name; unsigned int i; EFI_HANDLE image; @@ -561,17 +546,17 @@ static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer, /* Open driver binding protocol */ if ( ( rc = efi_open ( driver, &efi_driver_binding_protocol_guid, - &binding.interface ) ) != 0 ) { + &binding ) ) != 0 ) { DBGC ( driver, "EFIVETO %s could not open driver binding " "protocol: %s\n", efi_handle_name ( driver ), strerror ( rc ) ); return rc; } - image = binding.binding->ImageHandle; + image = binding->ImageHandle; /* Open loaded image protocol */ if ( ( rc = efi_open ( image, &efi_loaded_image_protocol_guid, - &loaded.interface ) ) != 0 ) { + &loaded ) ) != 0 ) { DBGC ( driver, "EFIVETO %s could not open", efi_handle_name ( driver ) ); DBGC ( driver, " %s loaded image protocol: %s\n", @@ -581,23 +566,21 @@ static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer, /* Open component name protocol, if present */ if ( ( rc = efi_open ( image, &efi_component_name2_protocol_guid, - &wtf2.interface ) ) != 0 ) { + &wtf2 ) ) != 0 ) { /* Ignore failure; is not required to be present */ } /* Open obsolete component name protocol, if present */ if ( ( rc = efi_open ( image, &efi_component_name_protocol_guid, - &wtf.interface ) ) != 0 ) { + &wtf ) ) != 0 ) { /* Ignore failure; is not required to be present */ } /* Get driver name, if available */ - if ( ( wtf2.wtf2 && - ( ( efirc = wtf2.wtf2->GetDriverName ( wtf2.wtf2, "en", - &name ) == 0 ) ) ) || - ( wtf.wtf && - ( ( efirc = wtf.wtf->GetDriverName ( wtf.wtf, "eng", - &name ) == 0 ) ) ) ) { + if ( ( wtf2 && ( ( efirc = wtf2->GetDriverName ( wtf2, "en", + &name ) == 0 ) ) ) || + ( wtf && ( ( efirc = wtf->GetDriverName ( wtf, "eng", + &name ) == 0 ) ) ) ) { /* Driver has a name */ } else { /* Ignore failure; name is not required to be present */ @@ -606,19 +589,19 @@ static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer, /* Check vetoes */ DBGC2 ( &efi_vetoes, "EFIVETO checking %s [%p,%p)\n", - efi_handle_name ( driver ), loaded.loaded->ImageBase, - ( loaded.loaded->ImageBase + loaded.loaded->ImageSize ) ); + efi_handle_name ( driver ), loaded->ImageBase, + ( loaded->ImageBase + loaded->ImageSize ) ); for ( i = 0 ; i < ( sizeof ( efi_vetoes ) / sizeof ( efi_vetoes[0] ) ) ; i++ ) { - if ( efi_vetoes[i].veto ( binding.binding, loaded.loaded, - manufacturer, name ) ) { + if ( efi_vetoes[i].veto ( binding, loaded, manufacturer, + name ) ) { DBGC ( driver, "EFIVETO %s is vetoed (%s)\n", efi_handle_name ( driver ), efi_vetoes[i].name ); veto->driver = driver; - veto->binding = binding.binding; + veto->binding = binding; veto->image = image; - veto->loaded = loaded.loaded; + veto->loaded = loaded; break; } } diff --git a/src/interface/efi/efi_wrap.c b/src/interface/efi/efi_wrap.c index 1cc37f3e3..a806a7c60 100644 --- a/src/interface/efi/efi_wrap.c +++ b/src/interface/efi/efi_wrap.c @@ -248,15 +248,12 @@ static int efi_prescroll ( unsigned int lines ) { * @v handle Image handle */ static void efi_dump_image ( EFI_HANDLE handle ) { - union { - EFI_LOADED_IMAGE_PROTOCOL *image; - void *intf; - } loaded; + EFI_LOADED_IMAGE_PROTOCOL *loaded; int rc; /* Open loaded image protocol */ if ( ( rc = efi_open ( handle, &efi_loaded_image_protocol_guid, - &loaded.intf ) ) != 0 ) { + &loaded ) ) != 0 ) { DBGC ( colour, "WRAP %s could not get loaded image protocol: " "%s\n", efi_handle_name ( handle ), strerror ( rc ) ); return; @@ -264,14 +261,14 @@ static void efi_dump_image ( EFI_HANDLE handle ) { /* Dump image information */ DBGC ( colour, "WRAP %s at base %p has protocols:\n", - efi_handle_name ( handle ), loaded.image->ImageBase ); + efi_handle_name ( handle ), loaded->ImageBase ); DBGC_EFI_PROTOCOLS ( colour, handle ); DBGC ( colour, "WRAP %s parent", efi_handle_name ( handle ) ); - DBGC ( colour, " %s\n", efi_handle_name ( loaded.image->ParentHandle )); + DBGC ( colour, " %s\n", efi_handle_name ( loaded->ParentHandle ) ); DBGC ( colour, "WRAP %s device", efi_handle_name ( handle ) ); - DBGC ( colour, " %s\n", efi_handle_name ( loaded.image->DeviceHandle )); + DBGC ( colour, " %s\n", efi_handle_name ( loaded->DeviceHandle ) ); DBGC ( colour, "WRAP %s file", efi_handle_name ( handle ) ); - DBGC ( colour, " %s\n", efi_devpath_text ( loaded.image->FilePath ) ); + DBGC ( colour, " %s\n", efi_devpath_text ( loaded->FilePath ) ); } /** -- cgit v1.2.3-55-g7522 From 2399c7998072f47a7f599ddd4d318bbc14adf39d Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 28 Mar 2025 12:42:30 +0000 Subject: [fdt] Allow for the existence of multiple device trees When running on a platform that uses FDT as its hardware description mechanism, we are likely to have multiple device tree structures. At a minimum, there will be the device tree passed to us from the previous boot stage (e.g. OpenSBI), and the device tree that we construct to be passed to the booted operating system. Update the internal FDT API to include an FDT pointer in all function parameter lists. Signed-off-by: Michael Brown --- src/arch/riscv/core/hart.c | 4 +- src/arch/riscv/core/zicntr.c | 4 +- src/arch/riscv/prefix/sbiprefix.S | 5 +- src/core/fdt.c | 186 +++++++++++++++++++------------------- src/drivers/net/smscusb.c | 6 +- src/include/ipxe/fdt.h | 20 ++-- src/interface/efi/efi_fdt.c | 6 +- 7 files changed, 121 insertions(+), 110 deletions(-) (limited to 'src/drivers') diff --git a/src/arch/riscv/core/hart.c b/src/arch/riscv/core/hart.c index c4f2bd0a5..d9cfb4e5d 100644 --- a/src/arch/riscv/core/hart.c +++ b/src/arch/riscv/core/hart.c @@ -55,7 +55,7 @@ static int hart_node ( unsigned int *offset ) { snprintf ( path, sizeof ( path ), "/cpus/cpu@%lx", boot_hart ); /* Find node */ - if ( ( rc = fdt_path ( path, offset ) ) != 0 ) { + if ( ( rc = fdt_path ( &sysfdt, path, offset ) ) != 0 ) { DBGC ( colour, "HART could not find %s: %s\n", path, strerror ( rc ) ); return rc; @@ -81,7 +81,7 @@ int hart_supported ( const char *ext ) { return rc; /* Get ISA description */ - isa = fdt_string ( offset, "riscv,isa" ); + isa = fdt_string ( &sysfdt, offset, "riscv,isa" ); if ( ! isa ) { DBGC ( colour, "HART could not identify ISA\n" ); return -ENOENT; diff --git a/src/arch/riscv/core/zicntr.c b/src/arch/riscv/core/zicntr.c index 826f31a68..7ea9f96ad 100644 --- a/src/arch/riscv/core/zicntr.c +++ b/src/arch/riscv/core/zicntr.c @@ -152,8 +152,8 @@ static int zicntr_probe ( void ) { } /* Get timer frequency */ - if ( ( ( rc = fdt_path ( "/cpus", &offset ) ) != 0 ) || - ( ( rc = fdt_u64 ( offset, "timebase-frequency", + if ( ( ( rc = fdt_path ( &sysfdt, "/cpus", &offset ) ) != 0 ) || + ( ( rc = fdt_u64 ( &sysfdt, offset, "timebase-frequency", &u.freq ) ) != 0 ) ) { DBGC ( colour, "ZICNTR could not determine frequency: %s\n", strerror ( rc ) ); diff --git a/src/arch/riscv/prefix/sbiprefix.S b/src/arch/riscv/prefix/sbiprefix.S index 0de001951..a39d37cb1 100644 --- a/src/arch/riscv/prefix/sbiprefix.S +++ b/src/arch/riscv/prefix/sbiprefix.S @@ -121,8 +121,9 @@ _sbi_start: STOREN s0, (t0) /* Register device tree */ - mv a0, s1 - call register_fdt + la a0, sysfdt + mv a1, s1 + call fdt_parse /* Call main program */ progress "\n\n" diff --git a/src/core/fdt.c b/src/core/fdt.c index ad83ed69a..e2ce055eb 100644 --- a/src/core/fdt.c +++ b/src/core/fdt.c @@ -38,7 +38,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ /** The system flattened device tree (if present) */ -static struct fdt fdt; +struct fdt sysfdt; /** The downloaded flattened device tree tag */ struct image_tag fdt_image __image_tag = { @@ -63,24 +63,16 @@ struct fdt_descriptor { size_t len; }; -/** - * Check if device tree exists - * - * @v has_fdt Device tree exists - */ -static inline __attribute__ (( always_inline )) int fdt_exists ( void ) { - - return ( fdt.hdr != NULL ); -} - /** * Traverse device tree * + * @v fdt Device tree * @v pos Position within device tree * @v desc Lexical descriptor to fill in * @ret rc Return status code */ -static int fdt_traverse ( struct fdt_cursor *pos, +static int fdt_traverse ( struct fdt *fdt, + struct fdt_cursor *pos, struct fdt_descriptor *desc ) { const fdt_token_t *token; const void *data; @@ -90,17 +82,17 @@ static int fdt_traverse ( struct fdt_cursor *pos, size_t len; /* Sanity checks */ - assert ( pos->offset < fdt.len ); + assert ( pos->offset < fdt->len ); assert ( ( pos->offset & ( FDT_STRUCTURE_ALIGN - 1 ) ) == 0 ); /* Clear descriptor */ memset ( desc, 0, sizeof ( *desc ) ); /* Locate token and calculate remaining space */ - token = ( fdt.raw + fdt.structure + pos->offset ); - remaining = ( fdt.len - pos->offset ); + token = ( fdt->raw + fdt->structure + pos->offset ); + remaining = ( fdt->len - pos->offset ); if ( remaining < sizeof ( *token ) ) { - DBGC ( &fdt, "FDT truncated tree at +%#04x\n", pos->offset ); + DBGC ( fdt, "FDT truncated tree at +%#04x\n", pos->offset ); return -EINVAL; } remaining -= sizeof ( *token ); @@ -116,7 +108,7 @@ static int fdt_traverse ( struct fdt_cursor *pos, desc->name = data; len = ( strnlen ( desc->name, remaining ) + 1 /* NUL */ ); if ( remaining < len ) { - DBGC ( &fdt, "FDT unterminated node name at +%#04x\n", + DBGC ( fdt, "FDT unterminated node name at +%#04x\n", pos->offset ); return -EINVAL; } @@ -127,7 +119,7 @@ static int fdt_traverse ( struct fdt_cursor *pos, /* End of node */ if ( pos->depth < 0 ) { - DBGC ( &fdt, "FDT spurious node end at +%#04x\n", + DBGC ( fdt, "FDT spurious node end at +%#04x\n", pos->offset ); return -EINVAL; } @@ -143,7 +135,7 @@ static int fdt_traverse ( struct fdt_cursor *pos, /* Property */ prop = data; if ( remaining < sizeof ( *prop ) ) { - DBGC ( &fdt, "FDT truncated property at +%#04x\n", + DBGC ( fdt, "FDT truncated property at +%#04x\n", pos->offset ); return -EINVAL; } @@ -151,17 +143,17 @@ static int fdt_traverse ( struct fdt_cursor *pos, desc->len = be32_to_cpu ( prop->len ); len = ( sizeof ( *prop ) + desc->len ); if ( remaining < len ) { - DBGC ( &fdt, "FDT overlength property at +%#04x\n", + DBGC ( fdt, "FDT overlength property at +%#04x\n", pos->offset ); return -EINVAL; } name_off = be32_to_cpu ( prop->name_off ); - if ( name_off > fdt.strings_len ) { - DBGC ( &fdt, "FDT property name outside strings " + if ( name_off > fdt->strings_len ) { + DBGC ( fdt, "FDT property name outside strings " "block at +%#04x\n", pos->offset ); return -EINVAL; } - desc->name = ( fdt.raw + fdt.strings + name_off ); + desc->name = ( fdt->raw + fdt->strings + name_off ); break; case cpu_to_be32 ( FDT_NOP ): @@ -172,7 +164,7 @@ static int fdt_traverse ( struct fdt_cursor *pos, default: /* Unrecognised or unexpected token */ - DBGC ( &fdt, "FDT unexpected token %#08x at +%#04x\n", + DBGC ( fdt, "FDT unexpected token %#08x at +%#04x\n", be32_to_cpu ( *token ), pos->offset ); return -EINVAL; } @@ -183,7 +175,7 @@ static int fdt_traverse ( struct fdt_cursor *pos, pos->offset += ( sizeof ( *token ) + len ); /* Sanity checks */ - assert ( pos->offset <= fdt.len ); + assert ( pos->offset <= fdt->len ); return 0; } @@ -191,12 +183,13 @@ static int fdt_traverse ( struct fdt_cursor *pos, /** * Find child node * + * @v fdt Device tree * @v offset Starting node offset * @v name Node name * @v child Child node offset to fill in * @ret rc Return status code */ -static int fdt_child ( unsigned int offset, const char *name, +static int fdt_child ( struct fdt *fdt, unsigned int offset, const char *name, unsigned int *child ) { struct fdt_cursor pos; struct fdt_descriptor desc; @@ -217,18 +210,18 @@ static int fdt_child ( unsigned int offset, const char *name, *child = pos.offset; /* Traverse tree */ - if ( ( rc = fdt_traverse ( &pos, &desc ) ) != 0 ) { - DBGC ( &fdt, "FDT +%#04x has no child node \"%s\": " + if ( ( rc = fdt_traverse ( fdt, &pos, &desc ) ) != 0 ) { + DBGC ( fdt, "FDT +%#04x has no child node \"%s\": " "%s\n", orig_offset, name, strerror ( rc ) ); return rc; } /* Check for matching immediate child node */ if ( ( pos.depth == 1 ) && desc.name && ( ! desc.data ) ) { - DBGC2 ( &fdt, "FDT +%#04x has child node \"%s\"\n", + DBGC2 ( fdt, "FDT +%#04x has child node \"%s\"\n", orig_offset, desc.name ); if ( strcmp ( name, desc.name ) == 0 ) { - DBGC2 ( &fdt, "FDT +%#04x found child node " + DBGC2 ( fdt, "FDT +%#04x found child node " "\"%s\" at +%#04x\n", orig_offset, desc.name, *child ); return 0; @@ -240,11 +233,12 @@ static int fdt_child ( unsigned int offset, const char *name, /** * Find node by path * + * @v fdt Device tree * @v path Node path * @v offset Offset to fill in * @ret rc Return status code */ -int fdt_path ( const char *path, unsigned int *offset ) { +int fdt_path ( struct fdt *fdt, const char *path, unsigned int *offset ) { char *tmp = ( ( char * ) path ); char *del; int rc; @@ -265,7 +259,7 @@ int fdt_path ( const char *path, unsigned int *offset ) { *del = '\0'; /* Find child and restore delimiter */ - rc = fdt_child ( *offset, tmp, offset ); + rc = fdt_child ( fdt, *offset, tmp, offset ); if ( del ) *del = '/'; if ( rc != 0 ) @@ -276,32 +270,33 @@ int fdt_path ( const char *path, unsigned int *offset ) { tmp++; } - DBGC2 ( &fdt, "FDT found path \"%s\" at +%#04x\n", path, *offset ); + DBGC2 ( fdt, "FDT found path \"%s\" at +%#04x\n", path, *offset ); return 0; } /** * Find node by alias * + * @v fdt Device tree * @v name Alias name * @v offset Offset to fill in * @ret rc Return status code */ -int fdt_alias ( const char *name, unsigned int *offset ) { +int fdt_alias ( struct fdt *fdt, const char *name, unsigned int *offset ) { const char *alias; int rc; /* Locate "/aliases" node */ - if ( ( rc = fdt_child ( 0, "aliases", offset ) ) != 0 ) + if ( ( rc = fdt_child ( fdt, 0, "aliases", offset ) ) != 0 ) return rc; /* Locate alias property */ - if ( ( alias = fdt_string ( *offset, name ) ) == NULL ) + if ( ( alias = fdt_string ( fdt, *offset, name ) ) == NULL ) return -ENOENT; - DBGC ( &fdt, "FDT alias \"%s\" is \"%s\"\n", name, alias ); + DBGC ( fdt, "FDT alias \"%s\" is \"%s\"\n", name, alias ); /* Locate aliased node */ - if ( ( rc = fdt_path ( alias, offset ) ) != 0 ) + if ( ( rc = fdt_path ( fdt, alias, offset ) ) != 0 ) return rc; return 0; @@ -310,13 +305,14 @@ int fdt_alias ( const char *name, unsigned int *offset ) { /** * Find property * + * @v fdt Device tree * @v offset Starting node offset * @v name Property name * @v desc Lexical descriptor to fill in * @ret rc Return status code */ -static int fdt_property ( unsigned int offset, const char *name, - struct fdt_descriptor *desc ) { +static int fdt_property ( struct fdt *fdt, unsigned int offset, + const char *name, struct fdt_descriptor *desc ) { struct fdt_cursor pos; int rc; @@ -328,20 +324,20 @@ static int fdt_property ( unsigned int offset, const char *name, while ( 1 ) { /* Traverse tree */ - if ( ( rc = fdt_traverse ( &pos, desc ) ) != 0 ) { - DBGC ( &fdt, "FDT +%#04x has no property \"%s\": %s\n", + if ( ( rc = fdt_traverse ( fdt, &pos, desc ) ) != 0 ) { + DBGC ( fdt, "FDT +%#04x has no property \"%s\": %s\n", offset, name, strerror ( rc ) ); return rc; } /* Check for matching immediate child property */ if ( ( pos.depth == 0 ) && desc->data ) { - DBGC2 ( &fdt, "FDT +%#04x has property \"%s\" len " + DBGC2 ( fdt, "FDT +%#04x has property \"%s\" len " "%#zx\n", offset, desc->name, desc->len ); if ( strcmp ( name, desc->name ) == 0 ) { - DBGC2 ( &fdt, "FDT +%#04x found property " + DBGC2 ( fdt, "FDT +%#04x found property " "\"%s\"\n", offset, desc->name ); - DBGC2_HDA ( &fdt, 0, desc->data, desc->len ); + DBGC2_HDA ( fdt, 0, desc->data, desc->len ); return 0; } } @@ -351,21 +347,23 @@ static int fdt_property ( unsigned int offset, const char *name, /** * Find string property * + * @v fdt Device tree * @v offset Starting node offset * @v name Property name * @ret string String property, or NULL on error */ -const char * fdt_string ( unsigned int offset, const char *name ) { +const char * fdt_string ( struct fdt *fdt, unsigned int offset, + const char *name ) { struct fdt_descriptor desc; int rc; /* Find property */ - if ( ( rc = fdt_property ( offset, name, &desc ) ) != 0 ) + if ( ( rc = fdt_property ( fdt, offset, name, &desc ) ) != 0 ) return NULL; /* Check NUL termination */ if ( strnlen ( desc.data, desc.len ) == desc.len ) { - DBGC ( &fdt, "FDT unterminated string property \"%s\"\n", + DBGC ( fdt, "FDT unterminated string property \"%s\"\n", name ); return NULL; } @@ -376,12 +374,14 @@ const char * fdt_string ( unsigned int offset, const char *name ) { /** * Find integer property * + * @v fdt Device tree * @v offset Starting node offset * @v name Property name * @v value Integer value to fill in * @ret rc Return status code */ -int fdt_u64 ( unsigned int offset, const char *name, uint64_t *value ) { +int fdt_u64 ( struct fdt *fdt, unsigned int offset, const char *name, + uint64_t *value ) { struct fdt_descriptor desc; const uint8_t *data; size_t remaining; @@ -391,12 +391,12 @@ int fdt_u64 ( unsigned int offset, const char *name, uint64_t *value ) { *value = 0; /* Find property */ - if ( ( rc = fdt_property ( offset, name, &desc ) ) != 0 ) + if ( ( rc = fdt_property ( fdt, offset, name, &desc ) ) != 0 ) return rc; /* Check range */ if ( desc.len > sizeof ( *value ) ) { - DBGC ( &fdt, "FDT oversized integer property \"%s\"\n", name ); + DBGC ( fdt, "FDT oversized integer property \"%s\"\n", name ); return -ERANGE; } @@ -414,18 +414,21 @@ int fdt_u64 ( unsigned int offset, const char *name, uint64_t *value ) { /** * Get MAC address from property * + * @v fdt Device tree * @v offset Starting node offset * @v netdev Network device * @ret rc Return status code */ -int fdt_mac ( unsigned int offset, struct net_device *netdev ) { +int fdt_mac ( struct fdt *fdt, unsigned int offset, + struct net_device *netdev ) { struct fdt_descriptor desc; size_t len; int rc; /* Find applicable MAC address property */ - if ( ( ( rc = fdt_property ( offset, "mac-address", &desc ) ) != 0 ) && - ( ( rc = fdt_property ( offset, "local-mac-address", + if ( ( ( rc = fdt_property ( fdt, offset, "mac-address", + &desc ) ) != 0 ) && + ( ( rc = fdt_property ( fdt, offset, "local-mac-address", &desc ) ) != 0 ) ) { return rc; } @@ -433,9 +436,9 @@ int fdt_mac ( unsigned int offset, struct net_device *netdev ) { /* Check length */ len = netdev->ll_protocol->hw_addr_len; if ( len != desc.len ) { - DBGC ( &fdt, "FDT malformed MAC address \"%s\":\n", + DBGC ( fdt, "FDT malformed MAC address \"%s\":\n", desc.name ); - DBGC_HDA ( &fdt, 0, desc.data, desc.len ); + DBGC_HDA ( fdt, 0, desc.data, desc.len ); return -ERANGE; } @@ -446,85 +449,86 @@ int fdt_mac ( unsigned int offset, struct net_device *netdev ) { } /** - * Register device tree + * Parse device tree * - * @v fdt Device tree header + * @v fdt Device tree + * @v hdr Device tree header * @ret rc Return status code */ -int register_fdt ( const struct fdt_header *hdr ) { +int fdt_parse ( struct fdt *fdt, const struct fdt_header *hdr ) { const uint8_t *end; /* Record device tree location */ - fdt.hdr = hdr; - fdt.len = be32_to_cpu ( hdr->totalsize ); - DBGC ( &fdt, "FDT version %d at %p+%#04zx\n", - be32_to_cpu ( hdr->version ), fdt.hdr, fdt.len ); + fdt->hdr = hdr; + fdt->len = be32_to_cpu ( hdr->totalsize ); + DBGC ( fdt, "FDT version %d at %p+%#04zx\n", + be32_to_cpu ( hdr->version ), fdt->hdr, fdt->len ); /* Check signature */ if ( hdr->magic != cpu_to_be32 ( FDT_MAGIC ) ) { - DBGC ( &fdt, "FDT has invalid magic value %#08x\n", + DBGC ( fdt, "FDT has invalid magic value %#08x\n", be32_to_cpu ( hdr->magic ) ); goto err; } /* Check version */ if ( hdr->last_comp_version != cpu_to_be32 ( FDT_VERSION ) ) { - DBGC ( &fdt, "FDT unsupported version %d\n", + DBGC ( fdt, "FDT unsupported version %d\n", be32_to_cpu ( hdr->last_comp_version ) ); goto err; } /* Record structure block location */ - fdt.structure = be32_to_cpu ( hdr->off_dt_struct ); - fdt.structure_len = be32_to_cpu ( hdr->size_dt_struct ); - DBGC ( &fdt, "FDT structure block at +[%#04x,%#04zx)\n", - fdt.structure, ( fdt.structure + fdt.structure_len ) ); - if ( ( fdt.structure > fdt.len ) || - ( fdt.structure_len > ( fdt.len - fdt.structure ) ) ) { - DBGC ( &fdt, "FDT structure block exceeds table\n" ); + fdt->structure = be32_to_cpu ( hdr->off_dt_struct ); + fdt->structure_len = be32_to_cpu ( hdr->size_dt_struct ); + DBGC ( fdt, "FDT structure block at +[%#04x,%#04zx)\n", + fdt->structure, ( fdt->structure + fdt->structure_len ) ); + if ( ( fdt->structure > fdt->len ) || + ( fdt->structure_len > ( fdt->len - fdt->structure ) ) ) { + DBGC ( fdt, "FDT structure block exceeds table\n" ); goto err; } - if ( ( fdt.structure | fdt.structure_len ) & + if ( ( fdt->structure | fdt->structure_len ) & ( FDT_STRUCTURE_ALIGN - 1 ) ) { - DBGC ( &fdt, "FDT structure block is misaligned\n" ); + DBGC ( fdt, "FDT structure block is misaligned\n" ); goto err; } /* Record strings block location */ - fdt.strings = be32_to_cpu ( hdr->off_dt_strings ); - fdt.strings_len = be32_to_cpu ( hdr->size_dt_strings ); - DBGC ( &fdt, "FDT strings block at +[%#04x,%#04zx)\n", - fdt.strings, ( fdt.strings + fdt.strings_len ) ); - if ( ( fdt.strings > fdt.len ) || - ( fdt.strings_len > ( fdt.len - fdt.strings ) ) ) { - DBGC ( &fdt, "FDT strings block exceeds table\n" ); + fdt->strings = be32_to_cpu ( hdr->off_dt_strings ); + fdt->strings_len = be32_to_cpu ( hdr->size_dt_strings ); + DBGC ( fdt, "FDT strings block at +[%#04x,%#04zx)\n", + fdt->strings, ( fdt->strings + fdt->strings_len ) ); + if ( ( fdt->strings > fdt->len ) || + ( fdt->strings_len > ( fdt->len - fdt->strings ) ) ) { + DBGC ( fdt, "FDT strings block exceeds table\n" ); goto err; } /* Shrink strings block to ensure NUL termination safety */ - end = ( fdt.raw + fdt.strings + fdt.strings_len ); - for ( ; fdt.strings_len ; fdt.strings_len-- ) { + end = ( fdt->raw + fdt->strings + fdt->strings_len ); + for ( ; fdt->strings_len ; fdt->strings_len-- ) { if ( *(--end) == '\0' ) break; } - if ( fdt.strings_len != be32_to_cpu ( hdr->size_dt_strings ) ) { - DBGC ( &fdt, "FDT strings block shrunk to +[%#04x,%#04zx)\n", - fdt.strings, ( fdt.strings + fdt.strings_len ) ); + if ( fdt->strings_len != be32_to_cpu ( hdr->size_dt_strings ) ) { + DBGC ( fdt, "FDT strings block shrunk to +[%#04x,%#04zx)\n", + fdt->strings, ( fdt->strings + fdt->strings_len ) ); } /* Print model name (for debugging) */ - DBGC ( &fdt, "FDT model is \"%s\"\n", fdt_string ( 0, "model" ) ); + DBGC ( fdt, "FDT model is \"%s\"\n", fdt_string ( fdt, 0, "model" ) ); return 0; err: - DBGC_HDA ( &fdt, 0, hdr, sizeof ( *hdr ) ); - fdt.hdr = NULL; + DBGC_HDA ( fdt, 0, hdr, sizeof ( *hdr ) ); + memset ( fdt, 0, sizeof ( *fdt ) ); return -EINVAL; } -/* Drag in objects via register_fdt */ -REQUIRING_SYMBOL ( register_fdt ); +/* Drag in objects via fdt_traverse() */ +REQUIRING_SYMBOL ( fdt_traverse ); /* Drag in device tree configuration */ REQUIRE_OBJECT ( config_fdt ); diff --git a/src/drivers/net/smscusb.c b/src/drivers/net/smscusb.c index c639c58c1..93007e386 100644 --- a/src/drivers/net/smscusb.c +++ b/src/drivers/net/smscusb.c @@ -459,13 +459,13 @@ int smscusb_fdt_fetch_mac ( struct smscusb_device *smscusb ) { int rc; /* Look for "ethernet[0]" alias */ - if ( ( rc = fdt_alias ( "ethernet", &offset ) != 0 ) && - ( rc = fdt_alias ( "ethernet0", &offset ) != 0 ) ) { + if ( ( rc = fdt_alias ( &sysfdt, "ethernet", &offset ) != 0 ) && + ( rc = fdt_alias ( &sysfdt, "ethernet0", &offset ) != 0 ) ) { return rc; } /* Fetch MAC address */ - if ( ( rc = fdt_mac ( offset, netdev ) ) != 0 ) + if ( ( rc = fdt_mac ( &sysfdt, offset, netdev ) ) != 0 ) return rc; DBGC ( smscusb, "SMSCUSB %p using FDT MAC %s\n", diff --git a/src/include/ipxe/fdt.h b/src/include/ipxe/fdt.h index 995975ed8..04201ce9b 100644 --- a/src/include/ipxe/fdt.h +++ b/src/include/ipxe/fdt.h @@ -95,12 +95,18 @@ struct fdt { }; extern struct image_tag fdt_image __image_tag; - -extern int fdt_path ( const char *path, unsigned int *offset ); -extern int fdt_alias ( const char *name, unsigned int *offset ); -extern const char * fdt_string ( unsigned int offset, const char *name ); -extern int fdt_u64 ( unsigned int offset, const char *name, uint64_t *value ); -extern int fdt_mac ( unsigned int offset, struct net_device *netdev ); -extern int register_fdt ( const struct fdt_header *hdr ); +extern struct fdt sysfdt; + +extern int fdt_path ( struct fdt *fdt, const char *path, + unsigned int *offset ); +extern int fdt_alias ( struct fdt *fdt, const char *name, + unsigned int *offset ); +extern const char * fdt_string ( struct fdt *fdt, unsigned int offset, + const char *name ); +extern int fdt_u64 ( struct fdt *fdt, unsigned int offset, const char *name, + uint64_t *value ); +extern int fdt_mac ( struct fdt *fdt, unsigned int offset, + struct net_device *netdev ); +extern int fdt_parse ( struct fdt *fdt, const struct fdt_header *hdr ); #endif /* _IPXE_FDT_H */ diff --git a/src/interface/efi/efi_fdt.c b/src/interface/efi/efi_fdt.c index dd9f4cf18..f81e6ad63 100644 --- a/src/interface/efi/efi_fdt.c +++ b/src/interface/efi/efi_fdt.c @@ -53,9 +53,9 @@ static void efi_fdt_init ( void ) { } DBGC ( &efi_fdt, "EFIFDT configuration table at %p\n", efi_fdt ); - /* Register device tree */ - if ( ( rc = register_fdt ( efi_fdt ) ) != 0 ) { - DBGC ( &efi_fdt, "EFIFDT could not register: %s\n", + /* Parse as system device tree */ + if ( ( rc = fdt_parse ( &sysfdt, efi_fdt ) ) != 0 ) { + DBGC ( &efi_fdt, "EFIFDT could not parse: %s\n", strerror ( rc ) ); return; } -- cgit v1.2.3-55-g7522 From 7737fec5c63077aa8407f559dea0e3666d9abf70 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sat, 29 Mar 2025 15:28:19 +0000 Subject: [efi] Define an attachment priority order for EFI drivers Define an ordering for internal EFI drivers on the basis of how close the driver is to the hardware, and attempt to start drivers in this order. Signed-off-by: Michael Brown --- src/drivers/net/efi/mnp.c | 2 +- src/drivers/net/efi/snp.c | 4 ++-- src/drivers/net/efi/snponly.c | 6 +++--- src/drivers/usb/usbio.c | 2 +- src/include/ipxe/efi/efi_driver.h | 6 ++++-- src/interface/efi/efi_pci.c | 2 +- 6 files changed, 12 insertions(+), 10 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/efi/mnp.c b/src/drivers/net/efi/mnp.c index 33218fb10..3c839d968 100644 --- a/src/drivers/net/efi/mnp.c +++ b/src/drivers/net/efi/mnp.c @@ -48,7 +48,7 @@ static int mnp_supported ( EFI_HANDLE device ) { } /** EFI MNP driver */ -struct efi_driver mnp_driver __efi_driver ( EFI_DRIVER_NORMAL ) = { +struct efi_driver mnp_driver __efi_driver ( EFI_DRIVER_MNP ) = { .name = "MNP", .supported = mnp_supported, .start = mnpnet_start, diff --git a/src/drivers/net/efi/snp.c b/src/drivers/net/efi/snp.c index cac8b38e2..58b5ad546 100644 --- a/src/drivers/net/efi/snp.c +++ b/src/drivers/net/efi/snp.c @@ -57,7 +57,7 @@ static int nii_supported ( EFI_HANDLE device ) { } /** EFI SNP driver */ -struct efi_driver snp_driver __efi_driver ( EFI_DRIVER_NORMAL ) = { +struct efi_driver snp_driver __efi_driver ( EFI_DRIVER_SNP ) = { .name = "SNP", .supported = snp_supported, .start = snpnet_start, @@ -65,7 +65,7 @@ struct efi_driver snp_driver __efi_driver ( EFI_DRIVER_NORMAL ) = { }; /** EFI NII driver */ -struct efi_driver nii_driver __efi_driver ( EFI_DRIVER_NORMAL ) = { +struct efi_driver nii_driver __efi_driver ( EFI_DRIVER_NII ) = { .name = "NII", .supported = nii_supported, .start = nii_start, diff --git a/src/drivers/net/efi/snponly.c b/src/drivers/net/efi/snponly.c index 80ddfe00d..e40451885 100644 --- a/src/drivers/net/efi/snponly.c +++ b/src/drivers/net/efi/snponly.c @@ -207,7 +207,7 @@ static int mnponly_supported ( EFI_HANDLE device ) { } /** EFI SNP chainloading-device-only driver */ -struct efi_driver snponly_driver __efi_driver ( EFI_DRIVER_NORMAL ) = { +struct efi_driver snponly_driver __efi_driver ( EFI_DRIVER_SNP ) = { .name = "SNPONLY", .supported = snponly_supported, .start = snpnet_start, @@ -215,7 +215,7 @@ struct efi_driver snponly_driver __efi_driver ( EFI_DRIVER_NORMAL ) = { }; /** EFI NII chainloading-device-only driver */ -struct efi_driver niionly_driver __efi_driver ( EFI_DRIVER_NORMAL ) = { +struct efi_driver niionly_driver __efi_driver ( EFI_DRIVER_NII ) = { .name = "NIIONLY", .supported = niionly_supported, .start = nii_start, @@ -223,7 +223,7 @@ struct efi_driver niionly_driver __efi_driver ( EFI_DRIVER_NORMAL ) = { }; /** EFI MNP chainloading-device-only driver */ -struct efi_driver mnponly_driver __efi_driver ( EFI_DRIVER_NORMAL ) = { +struct efi_driver mnponly_driver __efi_driver ( EFI_DRIVER_MNP ) = { .name = "MNPONLY", .supported = mnponly_supported, .start = mnpnet_start, diff --git a/src/drivers/usb/usbio.c b/src/drivers/usb/usbio.c index 73151c536..e4dca7e87 100644 --- a/src/drivers/usb/usbio.c +++ b/src/drivers/usb/usbio.c @@ -1649,7 +1649,7 @@ static void usbio_stop ( struct efi_device *efidev ) { } /** EFI USB I/O driver */ -struct efi_driver usbio_driver __efi_driver ( EFI_DRIVER_NORMAL ) = { +struct efi_driver usbio_driver __efi_driver ( EFI_DRIVER_HARDWARE ) = { .name = "USBIO", .supported = usbio_supported, .start = usbio_start, diff --git a/src/include/ipxe/efi/efi_driver.h b/src/include/ipxe/efi/efi_driver.h index 7b64e1e0b..e07bfd49d 100644 --- a/src/include/ipxe/efi/efi_driver.h +++ b/src/include/ipxe/efi/efi_driver.h @@ -62,8 +62,10 @@ struct efi_driver { #define __efi_driver( order ) __table_entry ( EFI_DRIVERS, order ) #define EFI_DRIVER_EARLY 01 /**< Early drivers */ -#define EFI_DRIVER_NORMAL 02 /**< Normal drivers */ -#define EFI_DRIVER_LATE 03 /**< Late drivers */ +#define EFI_DRIVER_HARDWARE 02 /**< Hardware drivers */ +#define EFI_DRIVER_NII 03 /**< NII protocol drivers */ +#define EFI_DRIVER_SNP 04 /**< SNP protocol drivers */ +#define EFI_DRIVER_MNP 05 /**< MNP protocol drivers */ /** * Set EFI driver-private data diff --git a/src/interface/efi/efi_pci.c b/src/interface/efi/efi_pci.c index 0662302d2..6bdc2d575 100644 --- a/src/interface/efi/efi_pci.c +++ b/src/interface/efi/efi_pci.c @@ -914,7 +914,7 @@ static void efipci_stop ( struct efi_device *efidev ) { } /** EFI PCI driver */ -struct efi_driver efipci_driver __efi_driver ( EFI_DRIVER_NORMAL ) = { +struct efi_driver efipci_driver __efi_driver ( EFI_DRIVER_HARDWARE ) = { .name = "PCI", .supported = efipci_supported, .start = efipci_start, -- cgit v1.2.3-55-g7522 From 4bcaa3d380d2110445ac6501bf382d81a2ea49d0 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sat, 29 Mar 2025 14:57:16 +0000 Subject: [efi] Disconnect existing drivers on a per-protocol basis UEFI does not provide a direct method to disconnect the existing driver of a specific protocol from a handle. We currently use DisconnectController() to remove all drivers from a handle that we want to drive ourselves, and then rely on recursion in the call to ConnectController() to reconnect any drivers that did not need to be disconnected in the first place. Experience shows that OEMs tend not to ever test the disconnection code paths in their UEFI drivers, and it is common to find drivers that refuse to disconnect, fail to close opened handles, fail to function correctly after reconnection, or lock up the entire system. Implement a more selective form of disconnection, in which we use OpenProtocolInformation() to identify the driver associated with a specific protocol, and then disconnect only that driver. Perform disconnections in reverse order of attachment priority, since this is the order likely to minimise the number of cascaded implicit disconnections. This allows our MNP driver to avoid performing any disconnections at all, since it does not require exclusive access to the MNP protocol. It also avoids performing unnecessary disconnections and reconnections of unrelated drivers such as the "UEFI WiFi Connection Manager" that attaches to wireless network interfaces in order to manage wireless network associations. Signed-off-by: Michael Brown --- src/drivers/net/efi/snp.c | 2 + src/drivers/net/efi/snponly.c | 2 + src/drivers/usb/usbio.c | 1 + src/include/ipxe/efi/efi_driver.h | 2 + src/interface/efi/efi_driver.c | 85 +++++++++++++++++++++++++++++++++++---- src/interface/efi/efi_pci.c | 1 + 6 files changed, 86 insertions(+), 7 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/efi/snp.c b/src/drivers/net/efi/snp.c index 58b5ad546..7c4123677 100644 --- a/src/drivers/net/efi/snp.c +++ b/src/drivers/net/efi/snp.c @@ -59,6 +59,7 @@ static int nii_supported ( EFI_HANDLE device ) { /** EFI SNP driver */ struct efi_driver snp_driver __efi_driver ( EFI_DRIVER_SNP ) = { .name = "SNP", + .exclude = &efi_simple_network_protocol_guid, .supported = snp_supported, .start = snpnet_start, .stop = snpnet_stop, @@ -67,6 +68,7 @@ struct efi_driver snp_driver __efi_driver ( EFI_DRIVER_SNP ) = { /** EFI NII driver */ struct efi_driver nii_driver __efi_driver ( EFI_DRIVER_NII ) = { .name = "NII", + .exclude = &efi_nii31_protocol_guid, .supported = nii_supported, .start = nii_start, .stop = nii_stop, diff --git a/src/drivers/net/efi/snponly.c b/src/drivers/net/efi/snponly.c index e40451885..267572e34 100644 --- a/src/drivers/net/efi/snponly.c +++ b/src/drivers/net/efi/snponly.c @@ -209,6 +209,7 @@ static int mnponly_supported ( EFI_HANDLE device ) { /** EFI SNP chainloading-device-only driver */ struct efi_driver snponly_driver __efi_driver ( EFI_DRIVER_SNP ) = { .name = "SNPONLY", + .exclude = &efi_simple_network_protocol_guid, .supported = snponly_supported, .start = snpnet_start, .stop = snpnet_stop, @@ -217,6 +218,7 @@ struct efi_driver snponly_driver __efi_driver ( EFI_DRIVER_SNP ) = { /** EFI NII chainloading-device-only driver */ struct efi_driver niionly_driver __efi_driver ( EFI_DRIVER_NII ) = { .name = "NIIONLY", + .exclude = &efi_nii31_protocol_guid, .supported = niionly_supported, .start = nii_start, .stop = nii_stop, diff --git a/src/drivers/usb/usbio.c b/src/drivers/usb/usbio.c index e4dca7e87..991b290ad 100644 --- a/src/drivers/usb/usbio.c +++ b/src/drivers/usb/usbio.c @@ -1651,6 +1651,7 @@ static void usbio_stop ( struct efi_device *efidev ) { /** EFI USB I/O driver */ struct efi_driver usbio_driver __efi_driver ( EFI_DRIVER_HARDWARE ) = { .name = "USBIO", + .exclude = &efi_usb_io_protocol_guid, .supported = usbio_supported, .start = usbio_start, .stop = usbio_stop, diff --git a/src/include/ipxe/efi/efi_driver.h b/src/include/ipxe/efi/efi_driver.h index e07bfd49d..4c2148919 100644 --- a/src/include/ipxe/efi/efi_driver.h +++ b/src/include/ipxe/efi/efi_driver.h @@ -33,6 +33,8 @@ struct efi_device { struct efi_driver { /** Name */ const char *name; + /** Protocol to which exclusive access is required, if any */ + EFI_GUID *exclude; /** * Check if driver supports device * diff --git a/src/interface/efi/efi_driver.c b/src/interface/efi/efi_driver.c index 9f2f08846..8c5e00bfb 100644 --- a/src/interface/efi/efi_driver.c +++ b/src/interface/efi/efi_driver.c @@ -441,6 +441,68 @@ void efi_driver_uninstall ( void ) { &efi_component_name2_protocol_guid, &efi_wtf, NULL ); } +/** + * Try to disconnect an existing EFI driver + * + * @v device EFI device + * @v protocol Protocol GUID + * @ret rc Return status code + */ +static int efi_driver_exclude ( EFI_HANDLE device, EFI_GUID *protocol ) { + EFI_BOOT_SERVICES *bs = efi_systab->BootServices; + EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *openers; + EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *opener; + EFI_HANDLE driver; + UINTN count; + unsigned int i; + EFI_STATUS efirc; + int rc; + + /* Retrieve list of openers */ + if ( ( efirc = bs->OpenProtocolInformation ( device, protocol, &openers, + &count ) ) != 0 ) { + rc = -EEFI ( efirc ); + DBGC ( device, "EFIDRV %s could not list %s openers: %s\n", + efi_handle_name ( device ), efi_guid_ntoa ( protocol ), + strerror ( rc ) ); + goto err_list; + } + + /* Identify BY_DRIVER opener */ + driver = NULL; + for ( i = 0 ; i < count ; i++ ) { + opener = &openers[i]; + if ( opener->Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER ) { + driver = opener->AgentHandle; + break; + } + } + + /* Try to disconnect driver */ + if ( driver ) { + DBGC ( device, "EFIDRV %s disconnecting %s driver ", + efi_handle_name ( device ), efi_guid_ntoa ( protocol ) ); + DBGC ( device, "%s\n", efi_handle_name ( driver ) ); + if ( ( efirc = bs->DisconnectController ( device, driver, + NULL ) ) != 0 ) { + rc = -EEFI ( efirc ); + DBGC ( device, "EFIDRV %s could not disconnect ", + efi_handle_name ( device ) ); + DBGC ( device, "%s: %s\n", + efi_handle_name ( driver ), strerror ( rc ) ); + goto err_disconnect; + } + } + + /* Success */ + rc = 0; + + err_disconnect: + bs->FreePool ( openers ); + err_list: + return rc; +} + /** * Try to connect EFI driver * @@ -451,6 +513,8 @@ static int efi_driver_connect ( EFI_HANDLE device ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE drivers[2] = { efi_driver_binding.DriverBindingHandle, NULL }; + struct efi_driver *efidrv; + EFI_GUID *exclude; EFI_STATUS efirc; int rc; @@ -468,13 +532,20 @@ static int efi_driver_connect ( EFI_HANDLE device ) { DBGC ( device, "EFIDRV %s disconnecting existing drivers\n", efi_handle_name ( device ) ); efi_driver_disconnecting = 1; - if ( ( efirc = bs->DisconnectController ( device, NULL, - NULL ) ) != 0 ) { - rc = -EEFI ( efirc ); - DBGC ( device, "EFIDRV %s could not disconnect existing " - "drivers: %s\n", efi_handle_name ( device ), - strerror ( rc ) ); - /* Ignore the error and attempt to connect our drivers */ + for_each_table_entry_reverse ( efidrv, EFI_DRIVERS ) { + exclude = efidrv->exclude; + if ( ! exclude ) + continue; + if ( ( rc = efidrv->supported ( device ) ) != 0 ) + continue; + DBGC ( device, "EFIDRV %s disconnecting %s drivers\n", + efi_handle_name ( device ), efi_guid_ntoa ( exclude ) ); + if ( ( rc = efi_driver_exclude ( device, exclude ) ) != 0 ) { + DBGC ( device, "EFIDRV %s could not disconnect %s " + "drivers: %s\n", efi_handle_name ( device ), + efi_guid_ntoa ( exclude ), strerror ( rc ) ); + /* Ignore the error and attempt to connect anyway */ + } } efi_driver_disconnecting = 0; DBGC2 ( device, "EFIDRV %s after disconnecting:\n", diff --git a/src/interface/efi/efi_pci.c b/src/interface/efi/efi_pci.c index 6bdc2d575..f98794c27 100644 --- a/src/interface/efi/efi_pci.c +++ b/src/interface/efi/efi_pci.c @@ -916,6 +916,7 @@ static void efipci_stop ( struct efi_device *efidev ) { /** EFI PCI driver */ struct efi_driver efipci_driver __efi_driver ( EFI_DRIVER_HARDWARE ) = { .name = "PCI", + .exclude = &efi_pci_io_protocol_guid, .supported = efipci_supported, .start = efipci_start, .stop = efipci_stop, -- cgit v1.2.3-55-g7522 From 37e9f785ba6573a5298cf6aea2b04bf4ad674b2f Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 14 Apr 2025 11:34:20 +0100 Subject: [dt] Add basic concept of a devicetree bus Add a basic model for devices instantiated by parsing the system flattened device tree, with drivers matched via the "compatible" property for any non-root node. Signed-off-by: Michael Brown --- src/drivers/bus/devtree.c | 297 +++++++++++++++++++++++++++++++++++++++++++++ src/include/ipxe/device.h | 3 + src/include/ipxe/devtree.h | 76 ++++++++++++ src/include/ipxe/errfile.h | 1 + 4 files changed, 377 insertions(+) create mode 100644 src/drivers/bus/devtree.c create mode 100644 src/include/ipxe/devtree.h (limited to 'src/drivers') diff --git a/src/drivers/bus/devtree.c b/src/drivers/bus/devtree.c new file mode 100644 index 000000000..35bd35c52 --- /dev/null +++ b/src/drivers/bus/devtree.c @@ -0,0 +1,297 @@ +/* + * Copyright (C) 2025 Michael Brown . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + * + * You can also choose to distribute this program under the terms of + * the Unmodified Binary Distribution Licence (as given in the file + * COPYING.UBDL), provided that you have satisfied its requirements. + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +/** @file + * + * Devicetree bus + * + */ + +#include +#include +#include +#include +#include +#include + +static struct dt_driver dt_node_driver __dt_driver; +struct root_device dt_root_device __root_device; + +static void dt_remove_children ( struct dt_device *parent ); + +/** + * Find devicetree driver + * + * @v dt Devicetree device + * @v offset Starting node offset + * @ret driver Driver, or NULL + */ +static struct dt_driver * dt_find_driver ( struct dt_device *dt, + unsigned int offset ) { + struct dt_driver *driver; + const char *ids; + const char *id; + unsigned int count; + unsigned int i; + + /* Read compatible programming model identifiers */ + ids = fdt_strings ( &sysfdt, offset, "compatible", &count ); + + /* Look for a compatible driver */ + for ( id = ids ; count-- ; id += ( strlen ( id ) + 1 ) ) { + DBGC2 ( &sysfdt, "DT %s is compatible with %s\n", + dt->path, id ); + for_each_table_entry ( driver, DT_DRIVERS ) { + for ( i = 0 ; i < driver->id_count ; i++ ) { + if ( strcmp ( id, driver->ids[i] ) == 0 ) { + DBGC ( dt, "DT %s has %s driver %s\n", + dt->path, id, driver->name ); + return driver; + } + } + } + } + + return NULL; +} + +/** + * Probe devicetree device + * + * @v dt Devicetree device + * @v offset Starting node offset + * @ret rc Return status code + */ +static int dt_probe ( struct dt_device *dt, unsigned int offset ) { + struct dt_driver *driver = NULL; + int rc; + + /* Identify driver. Use the generic node driver if no other + * driver matches, or if this is the root device (which has no + * valid devicetree parent). + */ + if ( offset > 0 ) + driver = dt_find_driver ( dt, offset ); + if ( ! driver ) + driver = &dt_node_driver; + + /* Record driver */ + dt->driver = driver; + dt->dev.driver_name = driver->name; + + /* Probe device */ + if ( ( rc = driver->probe ( dt, offset ) ) != 0 ) { + if ( driver != &dt_node_driver ) { + DBGC ( dt, "DT %s could not probe: %s\n", + dt->path, strerror ( rc ) ); + } + return rc; + } + + return 0; +} + +/** + * Remove devicetree device + * + * @v dt Devicetree device + */ +static void dt_remove ( struct dt_device *dt ) { + + /* Remove device */ + dt->driver->remove ( dt ); +} + +/** + * Probe devicetree node + * + * @v parent Parent device, or NULL for root of tree + * @v offset Starting node offset + * @v name Node name + * @ret rc Return status code + */ +static int dt_probe_node ( struct dt_device *parent, unsigned int offset, + const char *name ) { + struct dt_device *dt; + const char *ppath; + size_t path_len; + void *path; + int rc; + + /* Allocate and initialise device */ + ppath = ( ( parent && parent->path[1] ) ? parent->path : "" ); + path_len = ( strlen ( ppath ) + 1 /* "/" */ + + strlen ( name ) + 1 /* NUL */ ); + dt = zalloc ( sizeof ( *dt ) + path_len ); + if ( ! dt ) { + rc = -ENOMEM; + goto err_alloc; + } + path = ( ( ( void * ) dt ) + sizeof ( *dt ) ); + sprintf ( path, "%s/%s", ppath, name ); + dt->path = path; + snprintf ( dt->dev.name, sizeof ( dt->dev.name ), "%s", name ); + dt->dev.desc.bus_type = BUS_TYPE_DT; + dt->dev.parent = ( parent ? &parent->dev : &dt_root_device.dev ); + INIT_LIST_HEAD ( &dt->dev.children ); + list_add_tail ( &dt->dev.siblings, &dt->dev.parent->children ); + + /* Probe device */ + if ( ( rc = dt_probe ( dt, offset ) ) != 0 ) + goto err_probe; + + return 0; + + dt_remove ( dt ); + err_probe: + list_del ( &dt->dev.siblings ); + free ( dt ); + err_alloc: + return rc; +} + +/** + * Remove devicetree node + * + * @v dt Devicetree device + */ +static void dt_remove_node ( struct dt_device *dt ) { + + /* Remove driver */ + dt_remove ( dt ); + + /* Delete and free device */ + list_del ( &dt->dev.siblings ); + free ( dt ); +} + +/** + * Probe devicetree children + * + * @v parent Parent device + * @v offset Starting node offset + * @ret rc Return status code + */ +static int dt_probe_children ( struct dt_device *parent, + unsigned int offset ) { + struct fdt_descriptor desc; + int depth; + int rc; + + /* Probe any immediate child nodes */ + for ( depth = -1 ; ; depth += desc.depth, offset = desc.next ) { + + /* Describe token */ + if ( ( rc = fdt_describe ( &sysfdt, offset, &desc ) ) != 0 ) { + DBGC ( &sysfdt, "DT %s has malformed node: %s\n", + parent->path, strerror ( rc ) ); + goto err_describe; + } + + /* Terminate when we exit this node */ + if ( ( depth == 0 ) && ( desc.depth < 0 ) ) + break; + + /* Probe child node, if applicable */ + if ( ( depth == 0 ) && desc.name && ( ! desc.data ) ) + dt_probe_node ( parent, desc.offset, desc.name ); + } + + /* Fail if we have no children (so that this device will be freed) */ + if ( list_empty ( &parent->dev.children ) ) { + rc = -ENODEV; + goto err_no_children; + } + + return 0; + + err_no_children: + err_describe: + dt_remove_children ( parent ); + return rc; +} + +/** + * Remove devicetree children + * + * @v parent Parent device + */ +static void dt_remove_children ( struct dt_device *parent ) { + struct dt_device *dt; + struct dt_device *tmp; + + /* Remove all child nodes */ + list_for_each_entry_safe ( dt, tmp, &parent->dev.children, + dev.siblings ) { + dt_remove_node ( dt ); + } + assert ( list_empty ( &parent->dev.children ) ); +} + +/** Generic node driver */ +static struct dt_driver dt_node_driver __dt_driver = { + .name = "node", + .probe = dt_probe_children, + .remove = dt_remove_children, +}; + +/** + * Probe devicetree bus + * + * @v rootdev Devicetree root device + * @ret rc Return status code + */ +static int dt_probe_all ( struct root_device *rootdev __unused ) { + + /* Probe root node */ + return dt_probe_node ( NULL, 0, "" ); +} + +/** + * Remove devicetree bus + * + * @v rootdev Devicetree root device + */ +static void dt_remove_all ( struct root_device *rootdev ) { + struct dt_device *dt; + + /* Remove root node */ + dt = list_first_entry ( &rootdev->dev.children, struct dt_device, + dev.siblings ); + assert ( dt != NULL ); + dt_remove_node ( dt ); +} + +/** Devicetree bus root device driver */ +static struct root_driver dt_root_driver = { + .probe = dt_probe_all, + .remove = dt_remove_all, +}; + +/** Devicetree bus root device */ +struct root_device dt_root_device __root_device = { + .dev = { .name = "DT" }, + .driver = &dt_root_driver, +}; diff --git a/src/include/ipxe/device.h b/src/include/ipxe/device.h index d4ba001b0..89e6e4f31 100644 --- a/src/include/ipxe/device.h +++ b/src/include/ipxe/device.h @@ -69,6 +69,9 @@ struct device_description { /** USB bus type */ #define BUS_TYPE_USB 10 +/** Devicetree bus type */ +#define BUS_TYPE_DT 11 + /** A hardware device */ struct device { /** Name */ diff --git a/src/include/ipxe/devtree.h b/src/include/ipxe/devtree.h new file mode 100644 index 000000000..f31ddbd5b --- /dev/null +++ b/src/include/ipxe/devtree.h @@ -0,0 +1,76 @@ +#ifndef _IPXE_DEVTREE_H +#define _IPXE_DEVTREE_H + +/** @file + * + * Devicetree bus + * + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#include + +/** A devicetree device */ +struct dt_device { + /** Generic device */ + struct device dev; + /** Device path */ + const char *path; + /** Driver for this device */ + struct dt_driver *driver; + /** Driver-private data */ + void *priv; +}; + +/** A devicetree driver */ +struct dt_driver { + /** Driver name */ + const char *name; + /** Compatible programming model identifiers */ + const char **ids; + /** Number of compatible programming model identifiers */ + unsigned int id_count; + /** + * Probe device + * + * @v dt Devicetree device + * @v offset Starting node offset + * @ret rc Return status code + */ + int ( * probe ) ( struct dt_device *dt, unsigned int offset ); + /** + * Remove device + * + * @v dt Devicetree device + */ + void ( * remove ) ( struct dt_device *dt ); +}; + +/** Devicetree driver table */ +#define DT_DRIVERS __table ( struct dt_driver, "dt_drivers" ) + +/** Declare a devicetree driver */ +#define __dt_driver __table_entry ( DT_DRIVERS, 01 ) + +/** + * Set devicetree driver-private data + * + * @v dt Devicetree device + * @v priv Private data + */ +static inline void dt_set_drvdata ( struct dt_device *dt, void *priv ) { + dt->priv = priv; +} + +/** + * Get devicetree driver-private data + * + * @v dt Devicetree device + * @ret priv Private data + */ +static inline void * dt_get_drvdata ( struct dt_device *dt ) { + return dt->priv; +} + +#endif /* _IPXE_DEVTREE_H */ diff --git a/src/include/ipxe/errfile.h b/src/include/ipxe/errfile.h index a64104a22..2b8806706 100644 --- a/src/include/ipxe/errfile.h +++ b/src/include/ipxe/errfile.h @@ -231,6 +231,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define ERRFILE_aqc1xx ( ERRFILE_DRIVER | 0x00d70000 ) #define ERRFILE_atl_hw ( ERRFILE_DRIVER | 0x00d80000 ) #define ERRFILE_atl2_hw ( ERRFILE_DRIVER | 0x00d90000 ) +#define ERRFILE_devtree ( ERRFILE_DRIVER | 0x00da0000 ) #define ERRFILE_aoe ( ERRFILE_NET | 0x00000000 ) #define ERRFILE_arp ( ERRFILE_NET | 0x00010000 ) -- cgit v1.2.3-55-g7522 From eeec6442d9d422cbc7473f8dd9229c1acdc4084b Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 15 Apr 2025 20:19:17 +0100 Subject: [dt] Provide dt_ioremap() to map device registers Devicetree devices encode register address ranges within the "reg" property, with the number of cells used for addresses and for sizes determined by the #address-cells and #size-cells properties of the immediate parent device. Record the number of address and size cells for each device, and provide a dt_ioremap() function to allow drivers to map a specified range without having to directly handle the "reg" property. Signed-off-by: Michael Brown --- src/drivers/bus/devtree.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++ src/include/ipxe/devtree.h | 14 +++++++++ 2 files changed, 89 insertions(+) (limited to 'src/drivers') diff --git a/src/drivers/bus/devtree.c b/src/drivers/bus/devtree.c index 35bd35c52..cbd8ea8fa 100644 --- a/src/drivers/bus/devtree.c +++ b/src/drivers/bus/devtree.c @@ -34,6 +34,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include static struct dt_driver dt_node_driver __dt_driver; @@ -41,6 +42,70 @@ struct root_device dt_root_device __root_device; static void dt_remove_children ( struct dt_device *parent ); +/** + * Map devicetree range + * + * @v dt Devicetree device + * @v offset Starting node offset + * @v index Region index + * @v len Length to map, or 0 to map whole region + * @ret io_addr I/O address, or NULL on error + */ +void * dt_ioremap ( struct dt_device *dt, unsigned int offset, + unsigned int index, size_t len ) { + struct dt_device *parent = + container_of ( dt->dev.parent, struct dt_device, dev ); + uint64_t address; + uint64_t size; + unsigned int cell; + void *io_addr; + int rc; + + /* Read address */ + cell = ( index * ( parent->address_cells + parent->size_cells ) ); + if ( ( rc = fdt_cells ( &sysfdt, offset, "reg", cell, + parent->address_cells, &address ) ) != 0 ) { + DBGC ( dt, "DT %s could not read region %d address: %s\n", + dt->path, index, strerror ( rc ) ); + return NULL; + } + cell += parent->address_cells; + + /* Read size (or assume sufficient, if tree specifies no sizes) */ + size = len; + if ( parent->size_cells && + ( rc = fdt_cells ( &sysfdt, offset, "reg", cell, + parent->size_cells, &size ) ) != 0 ) { + DBGC ( dt, "DT %s could not read region %d size: %s\n", + dt->path, index, strerror ( rc ) ); + return NULL; + } + + /* Use region size as length if not specified */ + if ( ! len ) + len = size; + DBGC ( dt, "DT %s region %d at %#08llx+%#04llx\n", + dt->path, index, ( ( unsigned long long ) address ), + ( ( unsigned long long ) size ) ); + + /* Verify size */ + if ( len > size ) { + DBGC ( dt, "DT %s region %d is too small (%#llx/%#zx bytes)\n", + dt->path, index, ( ( unsigned long long ) size ), len ); + return NULL; + } + + /* Map region */ + io_addr = ioremap ( address, len ); + if ( ! io_addr ) { + DBGC ( dt, "DT %s could not map region %d\n", + dt->path, index ); + return NULL; + } + + return io_addr; +} + /** * Find devicetree driver * @@ -158,6 +223,16 @@ static int dt_probe_node ( struct dt_device *parent, unsigned int offset, INIT_LIST_HEAD ( &dt->dev.children ); list_add_tail ( &dt->dev.siblings, &dt->dev.parent->children ); + /* Read #address-cells and #size-cells, if present */ + if ( ( rc = fdt_u32 ( &sysfdt, offset, "#address-cells", + &dt->address_cells ) ) != 0 ) { + dt->address_cells = DT_DEFAULT_ADDRESS_CELLS; + } + if ( ( rc = fdt_u32 ( &sysfdt, offset, "#size-cells", + &dt->size_cells ) ) != 0 ) { + dt->size_cells = DT_DEFAULT_SIZE_CELLS; + } + /* Probe device */ if ( ( rc = dt_probe ( dt, offset ) ) != 0 ) goto err_probe; diff --git a/src/include/ipxe/devtree.h b/src/include/ipxe/devtree.h index f31ddbd5b..911e7ad15 100644 --- a/src/include/ipxe/devtree.h +++ b/src/include/ipxe/devtree.h @@ -21,8 +21,19 @@ struct dt_device { struct dt_driver *driver; /** Driver-private data */ void *priv; + + /** Number of address cells for child devices */ + uint32_t address_cells; + /** Number of size cells for child devices */ + uint32_t size_cells; }; +/** Default number of address cells, if not specified */ +#define DT_DEFAULT_ADDRESS_CELLS 2 + +/** Default number of size cells, if not specified */ +#define DT_DEFAULT_SIZE_CELLS 1 + /** A devicetree driver */ struct dt_driver { /** Driver name */ @@ -73,4 +84,7 @@ static inline void * dt_get_drvdata ( struct dt_device *dt ) { return dt->priv; } +extern void * dt_ioremap ( struct dt_device *dt, unsigned int offset, + unsigned int index, size_t len ); + #endif /* _IPXE_DEVTREE_H */ -- cgit v1.2.3-55-g7522 From c88ebf2ac6291f396112b813e6ac71cff4732a34 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 16 Apr 2025 21:26:45 +0100 Subject: [efi] Allow for custom methods for disconnecting existing drivers Allow for greater control over the process used to disconnect existing drivers from a device handle, by converting the "exclude" field from a simple protocol GUID to a per-driver method. Signed-off-by: Michael Brown --- src/drivers/net/efi/nii.c | 20 ++++++++++++++++++++ src/drivers/net/efi/nii.h | 1 + src/drivers/net/efi/snp.c | 4 ++-- src/drivers/net/efi/snpnet.c | 20 ++++++++++++++++++++ src/drivers/net/efi/snpnet.h | 1 + src/drivers/net/efi/snponly.c | 4 ++-- src/drivers/usb/usbio.c | 22 +++++++++++++++++++++- src/include/ipxe/efi/efi_driver.h | 10 ++++++++-- src/interface/efi/efi_driver.c | 16 +++++++--------- src/interface/efi/efi_pci.c | 22 +++++++++++++++++++++- 10 files changed, 103 insertions(+), 17 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/efi/nii.c b/src/drivers/net/efi/nii.c index 81f1838a4..6381fb2dd 100644 --- a/src/drivers/net/efi/nii.c +++ b/src/drivers/net/efi/nii.c @@ -1257,6 +1257,26 @@ static struct net_device_operations nii_operations = { .poll = nii_poll, }; +/** + * Exclude existing drivers + * + * @v device EFI device handle + * @ret rc Return status code + */ +int nii_exclude ( EFI_HANDLE device ) { + EFI_GUID *protocol = &efi_nii31_protocol_guid; + int rc; + + /* Exclude existing NII protocol drivers */ + if ( ( rc = efi_driver_exclude ( device, protocol ) ) != 0 ) { + DBGC ( device, "NII %s could not exclude drivers: %s\n", + efi_handle_name ( device ), strerror ( rc ) ); + return rc; + } + + return 0; +} + /** * Attach driver to device * diff --git a/src/drivers/net/efi/nii.h b/src/drivers/net/efi/nii.h index c10be9db5..df7ab7dbe 100644 --- a/src/drivers/net/efi/nii.h +++ b/src/drivers/net/efi/nii.h @@ -11,6 +11,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); struct efi_device; +extern int nii_exclude ( EFI_HANDLE device ); extern int nii_start ( struct efi_device *efidev ); extern void nii_stop ( struct efi_device *efidev ); diff --git a/src/drivers/net/efi/snp.c b/src/drivers/net/efi/snp.c index 7c4123677..2e0d9df3a 100644 --- a/src/drivers/net/efi/snp.c +++ b/src/drivers/net/efi/snp.c @@ -59,8 +59,8 @@ static int nii_supported ( EFI_HANDLE device ) { /** EFI SNP driver */ struct efi_driver snp_driver __efi_driver ( EFI_DRIVER_SNP ) = { .name = "SNP", - .exclude = &efi_simple_network_protocol_guid, .supported = snp_supported, + .exclude = snpnet_exclude, .start = snpnet_start, .stop = snpnet_stop, }; @@ -68,8 +68,8 @@ struct efi_driver snp_driver __efi_driver ( EFI_DRIVER_SNP ) = { /** EFI NII driver */ struct efi_driver nii_driver __efi_driver ( EFI_DRIVER_NII ) = { .name = "NII", - .exclude = &efi_nii31_protocol_guid, .supported = nii_supported, + .exclude = nii_exclude, .start = nii_start, .stop = nii_stop, }; diff --git a/src/drivers/net/efi/snpnet.c b/src/drivers/net/efi/snpnet.c index c8e2f2f68..c4062a5a7 100644 --- a/src/drivers/net/efi/snpnet.c +++ b/src/drivers/net/efi/snpnet.c @@ -528,6 +528,26 @@ int snpnet_supported ( EFI_HANDLE device, EFI_GUID *protocol ) { return 0; } +/** + * Exclude existing drivers + * + * @v device EFI device handle + * @ret rc Return status code + */ +int snpnet_exclude ( EFI_HANDLE device ) { + EFI_GUID *protocol = &efi_simple_network_protocol_guid; + int rc; + + /* Exclude existing SNP drivers */ + if ( ( rc = efi_driver_exclude ( device, protocol ) ) != 0 ) { + DBGC ( device, "SNP %s could not exclude drivers: %s\n", + efi_handle_name ( device ), strerror ( rc ) ); + return rc; + } + + return 0; +} + /** * Attach driver to device * diff --git a/src/drivers/net/efi/snpnet.h b/src/drivers/net/efi/snpnet.h index 4699c7892..d3602a589 100644 --- a/src/drivers/net/efi/snpnet.h +++ b/src/drivers/net/efi/snpnet.h @@ -12,6 +12,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); struct efi_device; extern int snpnet_supported ( EFI_HANDLE device, EFI_GUID *protocol ); +extern int snpnet_exclude ( EFI_HANDLE device ); extern int snpnet_start ( struct efi_device *efidev ); extern void snpnet_stop ( struct efi_device *efidev ); diff --git a/src/drivers/net/efi/snponly.c b/src/drivers/net/efi/snponly.c index 267572e34..88c74ed42 100644 --- a/src/drivers/net/efi/snponly.c +++ b/src/drivers/net/efi/snponly.c @@ -209,8 +209,8 @@ static int mnponly_supported ( EFI_HANDLE device ) { /** EFI SNP chainloading-device-only driver */ struct efi_driver snponly_driver __efi_driver ( EFI_DRIVER_SNP ) = { .name = "SNPONLY", - .exclude = &efi_simple_network_protocol_guid, .supported = snponly_supported, + .exclude = snpnet_exclude, .start = snpnet_start, .stop = snpnet_stop, }; @@ -218,8 +218,8 @@ struct efi_driver snponly_driver __efi_driver ( EFI_DRIVER_SNP ) = { /** EFI NII chainloading-device-only driver */ struct efi_driver niionly_driver __efi_driver ( EFI_DRIVER_NII ) = { .name = "NIIONLY", - .exclude = &efi_nii31_protocol_guid, .supported = niionly_supported, + .exclude = nii_exclude, .start = nii_start, .stop = nii_stop, }; diff --git a/src/drivers/usb/usbio.c b/src/drivers/usb/usbio.c index 991b290ad..97860a281 100644 --- a/src/drivers/usb/usbio.c +++ b/src/drivers/usb/usbio.c @@ -1542,6 +1542,26 @@ static int usbio_interfaces ( struct usbio_device *usbio ) { return rc; } +/** + * Exclude existing drivers + * + * @v device EFI device handle + * @ret rc Return status code + */ +static int usbio_exclude ( EFI_HANDLE device ) { + EFI_GUID *protocol = &efi_usb_io_protocol_guid; + int rc; + + /* Exclude existing USB I/O protocol drivers */ + if ( ( rc = efi_driver_exclude ( device, protocol ) ) != 0 ) { + DBGC ( device, "USBIO %s could not exclude drivers: %s\n", + efi_handle_name ( device ), strerror ( rc ) ); + return rc; + } + + return 0; +} + /** * Attach driver to device * @@ -1651,8 +1671,8 @@ static void usbio_stop ( struct efi_device *efidev ) { /** EFI USB I/O driver */ struct efi_driver usbio_driver __efi_driver ( EFI_DRIVER_HARDWARE ) = { .name = "USBIO", - .exclude = &efi_usb_io_protocol_guid, .supported = usbio_supported, + .exclude = usbio_exclude, .start = usbio_start, .stop = usbio_stop, }; diff --git a/src/include/ipxe/efi/efi_driver.h b/src/include/ipxe/efi/efi_driver.h index 4c2148919..5ab2d011a 100644 --- a/src/include/ipxe/efi/efi_driver.h +++ b/src/include/ipxe/efi/efi_driver.h @@ -33,8 +33,13 @@ struct efi_device { struct efi_driver { /** Name */ const char *name; - /** Protocol to which exclusive access is required, if any */ - EFI_GUID *exclude; + /** + * Exclude existing drivers + * + * @v device EFI device handle + * @ret rc Return status code + */ + int ( * exclude ) ( EFI_HANDLE device ); /** * Check if driver supports device * @@ -95,6 +100,7 @@ extern void efidev_free ( struct efi_device *efidev ); extern struct efi_device * efidev_parent ( struct device *dev ); extern int efi_driver_install ( void ); extern void efi_driver_uninstall ( void ); +extern int efi_driver_exclude ( EFI_HANDLE device, EFI_GUID *protocol ); extern int efi_driver_connect_all ( void ); extern void efi_driver_disconnect_all ( void ); extern void efi_driver_reconnect_all ( void ); diff --git a/src/interface/efi/efi_driver.c b/src/interface/efi/efi_driver.c index 8c5e00bfb..ce1db228d 100644 --- a/src/interface/efi/efi_driver.c +++ b/src/interface/efi/efi_driver.c @@ -448,7 +448,7 @@ void efi_driver_uninstall ( void ) { * @v protocol Protocol GUID * @ret rc Return status code */ -static int efi_driver_exclude ( EFI_HANDLE device, EFI_GUID *protocol ) { +int efi_driver_exclude ( EFI_HANDLE device, EFI_GUID *protocol ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *openers; EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *opener; @@ -479,6 +479,8 @@ static int efi_driver_exclude ( EFI_HANDLE device, EFI_GUID *protocol ) { } /* Try to disconnect driver */ + DBGC ( device, "EFIDRV %s disconnecting %s drivers\n", + efi_handle_name ( device ), efi_guid_ntoa ( protocol ) ); if ( driver ) { DBGC ( device, "EFIDRV %s disconnecting %s driver ", efi_handle_name ( device ), efi_guid_ntoa ( protocol ) ); @@ -514,7 +516,6 @@ static int efi_driver_connect ( EFI_HANDLE device ) { EFI_HANDLE drivers[2] = { efi_driver_binding.DriverBindingHandle, NULL }; struct efi_driver *efidrv; - EFI_GUID *exclude; EFI_STATUS efirc; int rc; @@ -533,17 +534,14 @@ static int efi_driver_connect ( EFI_HANDLE device ) { efi_handle_name ( device ) ); efi_driver_disconnecting = 1; for_each_table_entry_reverse ( efidrv, EFI_DRIVERS ) { - exclude = efidrv->exclude; - if ( ! exclude ) + if ( ! efidrv->exclude ) continue; if ( ( rc = efidrv->supported ( device ) ) != 0 ) continue; - DBGC ( device, "EFIDRV %s disconnecting %s drivers\n", - efi_handle_name ( device ), efi_guid_ntoa ( exclude ) ); - if ( ( rc = efi_driver_exclude ( device, exclude ) ) != 0 ) { - DBGC ( device, "EFIDRV %s could not disconnect %s " + if ( ( rc = efidrv->exclude ( device ) ) != 0 ) { + DBGC ( device, "EFIDRV %s could not disconnect " "drivers: %s\n", efi_handle_name ( device ), - efi_guid_ntoa ( exclude ), strerror ( rc ) ); + strerror ( rc ) ); /* Ignore the error and attempt to connect anyway */ } } diff --git a/src/interface/efi/efi_pci.c b/src/interface/efi/efi_pci.c index f98794c27..dd11dd342 100644 --- a/src/interface/efi/efi_pci.c +++ b/src/interface/efi/efi_pci.c @@ -829,6 +829,26 @@ static int efipci_supported ( EFI_HANDLE device ) { return 0; } +/** + * Exclude existing drivers + * + * @v device EFI device handle + * @ret rc Return status code + */ +static int efipci_exclude ( EFI_HANDLE device ) { + EFI_GUID *protocol = &efi_pci_io_protocol_guid; + int rc; + + /* Exclude existing PCI I/O protocol drivers */ + if ( ( rc = efi_driver_exclude ( device, protocol ) ) != 0 ) { + DBGC ( device, "EFIPCI %s could not exclude drivers: %s\n", + efi_handle_name ( device ), strerror ( rc ) ); + return rc; + } + + return 0; +} + /** * Attach driver to device * @@ -916,8 +936,8 @@ static void efipci_stop ( struct efi_device *efidev ) { /** EFI PCI driver */ struct efi_driver efipci_driver __efi_driver ( EFI_DRIVER_HARDWARE ) = { .name = "PCI", - .exclude = &efi_pci_io_protocol_guid, .supported = efipci_supported, + .exclude = efipci_exclude, .start = efipci_start, .stop = efipci_stop, }; -- cgit v1.2.3-55-g7522 From 758a50486005b5e612c15d680fa1a8477473fdf2 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 17 Apr 2025 00:29:41 +0100 Subject: [efi] Inhibit calls to Shutdown() for wireless SNP devices The UEFI model for wireless network configuration is somewhat underdefined. At the time of writing, the EDK2 "UEFI WiFi Connection Manager" driver provides only one way to configure wireless network credentials, which is to enter them interactively via an HII form. Credentials are not stored (or exposed via any protocol interface), and so any temporary disconnection from the wireless network will inevitably leave the interface in an unusable state that cannot be recovered without user intervention. Experimentation shows that at least some wireless network drivers (observed with an HP Elitebook 840 G10) will disconnect from the wireless network when the SNP Shutdown() method is called, or if the device is not polled sufficiently frequently to maintain its association to the network. We therefore inhibit calls to Shutdown() and Stop() for any such SNP protocol interfaces, and mark our network device as insomniac so that it will be polled even when closed. Note that we need to inhibit not only our own calls to Shutdown() and Stop(), but also those that will be attempted by MnpDxe when we disconnect it from the SNP handle. We do this by patching the installed SNP protocol interface structure to modify the Shutdown() and Stop() method pointers, which is ugly but unavoidable. Signed-off-by: Michael Brown --- src/drivers/net/efi/snpnet.c | 185 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 174 insertions(+), 11 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/efi/snpnet.c b/src/drivers/net/efi/snpnet.c index c4062a5a7..109eecf01 100644 --- a/src/drivers/net/efi/snpnet.c +++ b/src/drivers/net/efi/snpnet.c @@ -86,6 +86,14 @@ struct snp_nic { */ #define SNP_RX_PAD 8 +/** An SNP interface patch to inhibit shutdown for insomniac devices */ +struct snp_insomniac_patch { + /** Original Shutdown() method */ + EFI_SIMPLE_NETWORK_SHUTDOWN shutdown; + /** Original Stop() method */ + EFI_SIMPLE_NETWORK_STOP stop; +}; + /** * Format SNP MAC address (for debugging) * @@ -387,9 +395,10 @@ static int snpnet_open ( struct net_device *netdev ) { /* Initialise NIC, retrying multiple times if link stays down */ for ( retry = 0 ; ; ) { - /* Initialise NIC */ - if ( ( efirc = snp->snp->Initialize ( snp->snp, - 0, 0 ) ) != 0 ) { + /* Initialise NIC, if not already initialised */ + if ( ( mode->State != EfiSimpleNetworkInitialized ) && + ( ( efirc = snp->snp->Initialize ( snp->snp, + 0, 0 ) ) != 0 ) ) { rc = -EEFI ( efirc ); snpnet_dump_mode ( netdev ); DBGC ( snp, "SNP %s could not initialise: %s\n", @@ -413,11 +422,13 @@ static int snpnet_open ( struct net_device *netdev ) { /* Delay to allow time for link to establish */ mdelay ( SNP_INITIALIZE_RETRY_DELAY_MS ); - /* Shut down and retry; this is sometimes necessary in - * order to persuade the underlying SNP driver to - * actually update the link state. + /* Shut down and retry (unless device is insomniac); + * this is sometimes necessary in order to persuade + * the underlying SNP driver to actually update the + * link state. */ - if ( ( efirc = snp->snp->Shutdown ( snp->snp ) ) != 0 ) { + if ( ( ! netdev_insomniac ( netdev ) ) && + ( ( efirc = snp->snp->Shutdown ( snp->snp ) ) != 0 ) ) { rc = -EEFI ( efirc ); snpnet_dump_mode ( netdev ); DBGC ( snp, "SNP %s could not shut down: %s\n", @@ -455,8 +466,11 @@ static void snpnet_close ( struct net_device *netdev ) { EFI_STATUS efirc; int rc; - /* Shut down NIC (unless whole system shutdown is in progress) */ + /* Shut down NIC (unless whole system shutdown is in progress, + * or device is insomniac). + */ if ( ( ! efi_shutdown_in_progress ) && + ( ! netdev_insomniac ( netdev ) ) && ( ( efirc = snp->snp->Shutdown ( snp->snp ) ) != 0 ) ) { rc = -EEFI ( efirc ); DBGC ( snp, "SNP %s could not shut down: %s\n", @@ -528,6 +542,135 @@ int snpnet_supported ( EFI_HANDLE device, EFI_GUID *protocol ) { return 0; } +/** + * Check if device must be insomniac + * + * @v device EFI device handle + * @v is_insomniac Device must be insomniac + */ +static int snpnet_is_insomniac ( EFI_HANDLE device ) { + int rc; + + /* Check for wireless devices + * + * The UEFI model for wireless network configuration is + * somewhat underdefined. At the time of writing, the EDK2 + * "UEFI WiFi Connection Manager" driver provides only one way + * to configure wireless network credentials, which is to + * enter them interactively via an HII form. Credentials are + * not stored (or exposed via any protocol interface), and so + * any temporary disconnection from the wireless network will + * inevitably leave the interface in an unusable state that + * cannot be recovered without user intervention. + * + * Experimentation shows that at least some wireless network + * drivers will disconnect from the wireless network when the + * SNP Shutdown() method is called, or if the device is not + * polled sufficiently frequently to maintain its association + * to the network. We therefore inhibit calls to Shutdown() + * and Stop() for any such SNP protocol interfaces, and mark + * our network device as insomniac so that it will be polled + * even when closed. + */ + if ( ( rc = efi_test ( device, &efi_wifi2_protocol_guid ) ) == 0 ) { + DBGC ( device, "SNP %s is wireless: assuming insomniac\n", + efi_handle_name ( device ) ); + return 1; + } + + return 0; +} + +/** + * Ignore shutdown attempt + * + * @v snp SNP interface + * @ret efirc EFI status code + */ +static EFI_STATUS EFIAPI +snpnet_do_nothing ( EFI_SIMPLE_NETWORK_PROTOCOL *snp __unused ) { + + return 0; +} + +/** + * Patch SNP protocol interface to prevent shutdown + * + * @v device EFI device handle + * @v patch Interface patch + * @ret rc Return status code + */ +static int snpnet_insomniac_patch ( EFI_HANDLE device, + struct snp_insomniac_patch *patch ) { + EFI_SIMPLE_NETWORK_PROTOCOL *interface; + int rc; + + /* Open interface for ephemeral use */ + if ( ( rc = efi_open ( device, &efi_simple_network_protocol_guid, + &interface ) ) != 0 ) { + DBGC ( device, "SNP %s cannot open SNP protocol for patching: " + "%s\n", efi_handle_name ( device ), strerror ( rc ) ); + return rc; + } + + /* Record original Shutdown() and Stop() methods */ + patch->shutdown = interface->Shutdown; + patch->stop = interface->Stop; + + /* Inhibit other UEFI drivers' calls to Shutdown() and Stop() + * + * This is necessary since disconnecting the MnpDxe driver + * will attempt to shut down the SNP device, which would leave + * us with an unusable device. + */ + interface->Shutdown = snpnet_do_nothing; + interface->Stop = snpnet_do_nothing; + DBGC ( device, "SNP %s patched to inhibit shutdown\n", + efi_handle_name ( device ) ); + + return 0; +} + +/** + * Restore patched SNP protocol interface + * + * @v device EFI device handle + * @v patch Interface patch to fill in + * @ret rc Return status code + */ +static int snpnet_insomniac_restore ( EFI_HANDLE device, + struct snp_insomniac_patch *patch ) { + EFI_SIMPLE_NETWORK_PROTOCOL *interface; + int rc; + + /* Avoid returning uninitialised data on error */ + memset ( patch, 0, sizeof ( *patch ) ); + + /* Open interface for ephemeral use */ + if ( ( rc = efi_open ( device, &efi_simple_network_protocol_guid, + &interface ) ) != 0 ) { + DBGC ( device, "SNP %s cannot open patched SNP protocol: %s\n", + efi_handle_name ( device ), strerror ( rc ) ); + return rc; + } + + /* Restore original Shutdown() and Stop() methods, if possible */ + if ( interface->Shutdown == snpnet_do_nothing ) + interface->Shutdown = patch->shutdown; + if ( interface->Stop == snpnet_do_nothing ) + interface->Stop = patch->stop; + + /* Check that original methods were restored (by us or others) */ + if ( ( interface->Shutdown != patch->shutdown ) || + ( interface->Stop != patch->stop ) ) { + DBGC ( device, "SNP %s could not restore patched SNP " + "protocol\n", efi_handle_name ( device ) ); + return -EBUSY; + } + + return 0; +} + /** * Exclude existing drivers * @@ -536,16 +679,31 @@ int snpnet_supported ( EFI_HANDLE device, EFI_GUID *protocol ) { */ int snpnet_exclude ( EFI_HANDLE device ) { EFI_GUID *protocol = &efi_simple_network_protocol_guid; + struct snp_insomniac_patch patch; + int insomniac; int rc; + /* Check if this is a device that must not ever be shut down */ + insomniac = snpnet_is_insomniac ( device ); + + /* Inhibit calls to Shutdown() and Stop(), if applicable */ + if ( insomniac && + ( ( rc = snpnet_insomniac_patch ( device, &patch ) ) != 0 ) ) { + goto err_patch; + } + /* Exclude existing SNP drivers */ if ( ( rc = efi_driver_exclude ( device, protocol ) ) != 0 ) { DBGC ( device, "SNP %s could not exclude drivers: %s\n", efi_handle_name ( device ), strerror ( rc ) ); - return rc; + goto err_exclude; } - return 0; + err_exclude: + if ( insomniac ) + snpnet_insomniac_restore ( device, &patch ); + err_patch: + return rc; } /** @@ -595,7 +753,11 @@ int snpnet_start ( struct efi_device *efidev ) { INIT_LIST_HEAD ( &snp->dev.children ); netdev->dev = &snp->dev; - /* Bring to the Started state */ + /* Check if device is insomniac */ + if ( snpnet_is_insomniac ( device ) ) + netdev->state |= NETDEV_INSOMNIAC; + + /* Bring to the correct state for a closed interface */ if ( ( mode->State == EfiSimpleNetworkStopped ) && ( ( efirc = snp->snp->Start ( snp->snp ) ) != 0 ) ) { rc = -EEFI ( efirc ); @@ -604,6 +766,7 @@ int snpnet_start ( struct efi_device *efidev ) { goto err_start; } if ( ( mode->State == EfiSimpleNetworkInitialized ) && + ( ! netdev_insomniac ( netdev ) ) && ( ( efirc = snp->snp->Shutdown ( snp->snp ) ) != 0 ) ) { rc = -EEFI ( efirc ); DBGC ( device, "SNP %s could not shut down: %s\n", -- cgit v1.2.3-55-g7522 From 1291dc39fd09807f6b864c6433444d97be2a0c8a Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sat, 19 Apr 2025 11:54:08 +0100 Subject: [cgem] Add a driver for the Cadence GEM NIC Add a basic driver for the Cadence GEM network interface as emulated by QEMU when using the RISC-V "sifive_u" machine type. Signed-off-by: Michael Brown --- src/drivers/net/cgem.c | 711 +++++++++++++++++++++++++++++++++++++++++++++ src/drivers/net/cgem.h | 189 ++++++++++++ src/include/ipxe/devtree.h | 3 + src/include/ipxe/errfile.h | 1 + 4 files changed, 904 insertions(+) create mode 100644 src/drivers/net/cgem.c create mode 100644 src/drivers/net/cgem.h (limited to 'src/drivers') diff --git a/src/drivers/net/cgem.c b/src/drivers/net/cgem.c new file mode 100644 index 000000000..c935c8024 --- /dev/null +++ b/src/drivers/net/cgem.c @@ -0,0 +1,711 @@ +/* + * Copyright (C) 2025 Michael Brown . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + * + * You can also choose to distribute this program under the terms of + * the Unmodified Binary Distribution Licence (as given in the file + * COPYING.UBDL), provided that you have satisfied its requirements. + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "cgem.h" + +/** @file + * + * Cadence Gigabit Ethernet MAC (GEM) network driver + * + * Based primarily on the Zynq 7000 SoC Technical Reference Manual, + * available at the time of writing from: + * + * https://docs.amd.com/r/en-US/ug585-zynq-7000-SoC-TRM + * + */ + +/****************************************************************************** + * + * Device reset + * + ****************************************************************************** + */ + +/** + * Reset hardware + * + * @v cgem Cadence GEM device + * @ret rc Return status code + */ +static int cgem_reset ( struct cgem_nic *cgem ) { + + /* There is no software-driven reset capability in the + * hardware. Instead we have to write the expected reset + * values to the various registers. + */ + + /* Disable all interrupts */ + writel ( CGEM_IDR_ALL, ( cgem->regs + CGEM_IDR ) ); + + /* Clear network control register */ + writel ( 0, ( cgem->regs + CGEM_NWCTRL ) ); + + /* Clear statistics registers now that TX and RX are stopped */ + writel ( CGEM_NWCTRL_STATCLR, ( cgem->regs + CGEM_NWCTRL ) ); + + /* Clear TX queue base address */ + writel ( 0, ( cgem->regs + CGEM_TXQBASE ) ); + + /* Clear RX queue base address */ + writel ( 0, ( cgem->regs + CGEM_RXQBASE ) ); + + /* Configure DMA */ + writel ( ( CGEM_DMACR_RXBUF ( CGEM_RX_LEN ) | CGEM_DMACR_TXSIZE_MAX | + CGEM_DMACR_RXSIZE_MAX | CGEM_DMACR_BLENGTH_MAX ), + ( cgem->regs + CGEM_DMACR ) ); + + /* Enable MII interface */ + writel ( CGEM_NWCTRL_MDEN, ( cgem->regs + CGEM_NWCTRL ) ); + + return 0; +} + +/****************************************************************************** + * + * PHY access + * + ****************************************************************************** + */ + +/** + * Wait for MII operation to complete + * + * @v cgem Cadence GEM device + * @ret rc Return status code + */ +static int cgem_mii_wait ( struct cgem_nic *cgem ) { + uint32_t nwsr; + unsigned int i; + + /* Wait for MII interface to become idle */ + for ( i = 0 ; i < CGEM_MII_MAX_WAIT_US ; i++ ) { + + /* Check if MII interface is idle */ + nwsr = readl ( cgem->regs + CGEM_NWSR ); + if ( nwsr & CGEM_NWSR_MII_IDLE ) + return 0; + + /* Delay */ + udelay ( 1 ); + } + + DBGC ( cgem, "CGEM %s timed out waiting for MII\n", cgem->name ); + return -ETIMEDOUT; +} + +/** + * Read from MII register + * + * @v mdio MII interface + * @v phy PHY address + * @v reg Register address + * @ret data Data read, or negative error + */ +static int cgem_mii_read ( struct mii_interface *mdio, unsigned int phy, + unsigned int reg ) { + struct cgem_nic *cgem = container_of ( mdio, struct cgem_nic, mdio ); + unsigned int data; + int rc; + + /* Initiate read */ + writel ( ( CGEM_PHYMNTNC_CLAUSE22 | CGEM_PHYMNTNC_OP_READ | + CGEM_PHYMNTNC_ADDR ( phy ) | CGEM_PHYMNTNC_REG ( reg ) | + CGEM_PHYMNTNC_FIXED ), + ( cgem->regs + CGEM_PHYMNTNC ) ); + + /* Wait for read to complete */ + if ( ( rc = cgem_mii_wait ( cgem ) ) != 0 ) + return rc; + + /* Read data */ + data = ( readl ( cgem->regs + CGEM_PHYMNTNC ) & + CGEM_PHYMNTNC_DATA_MASK ); + + return data; +} + +/** + * Write to MII register + * + * @v mdio MII interface + * @v phy PHY address + * @v reg Register address + * @v data Data to write + * @ret rc Return status code + */ +static int cgem_mii_write ( struct mii_interface *mdio, unsigned int phy, + unsigned int reg, unsigned int data ) { + struct cgem_nic *cgem = container_of ( mdio, struct cgem_nic, mdio ); + int rc; + + /* Initiate write */ + writel ( ( CGEM_PHYMNTNC_CLAUSE22 | CGEM_PHYMNTNC_OP_READ | + CGEM_PHYMNTNC_ADDR ( phy ) | CGEM_PHYMNTNC_REG ( reg ) | + CGEM_PHYMNTNC_FIXED | data ), + ( cgem->regs + CGEM_PHYMNTNC ) ); + + /* Wait for write to complete */ + if ( ( rc = cgem_mii_wait ( cgem ) ) != 0 ) + return rc; + + return 0; +} + +/** MII operations */ +static struct mii_operations cgem_mii_operations = { + .read = cgem_mii_read, + .write = cgem_mii_write, +}; + +/****************************************************************************** + * + * Link state + * + ****************************************************************************** + */ + +/** + * Initialise PHY + * + * @v cgem Cadence GEM device + * @ret rc Return status code + */ +static int cgem_init_phy ( struct cgem_nic *cgem ) { + int rc; + + /* Find PHY address */ + if ( ( rc = mii_find ( &cgem->mii ) ) != 0 ) { + DBGC ( cgem, "CGEM %s could not find PHY address: %s\n", + cgem->name, strerror ( rc ) ); + return rc; + } + + /* Reset PHY */ + if ( ( rc = mii_reset ( &cgem->mii ) ) != 0 ) { + DBGC ( cgem, "CGEM %s could not reset PHY: %s\n", + cgem->name, strerror ( rc ) ); + return rc; + } + + return 0; +} + +/** + * Check link state + * + * @v netdev Network device + */ +static int cgem_check_link ( struct net_device *netdev ) { + struct cgem_nic *cgem = netdev->priv; + int rc; + + /* Check link state */ + if ( ( rc = mii_check_link ( &cgem->mii, netdev ) ) != 0 ) { + DBGC ( cgem, "CGEM %s could not check link: %s\n", + cgem->name, strerror ( rc ) ); + return rc; + } + + return 0; +} + +/** + * Check link state periodically + * + * @v retry Link state check timer + * @v over Failure indicator + */ +static void cgem_expired ( struct retry_timer *timer, int over __unused ) { + struct cgem_nic *cgem = container_of ( timer, struct cgem_nic, timer ); + struct net_device *netdev = cgem->netdev; + + /* Restart timer */ + start_timer_fixed ( timer, CGEM_LINK_INTERVAL ); + + /* Check link state */ + cgem_check_link ( netdev ); +} + +/****************************************************************************** + * + * Network device interface + * + ****************************************************************************** + */ + +/** + * Create descriptor ring + * + * @v cgem Cadence GEM device + * @v ring Descriptor ring + * @ret rc Return status code + */ +static int cgem_create_ring ( struct cgem_nic *cgem, struct cgem_ring *ring ) { + struct cgem_descriptor *desc; + unsigned int i; + + /* Allocate descriptor ring (on its own size) */ + ring->desc = dma_alloc ( cgem->dma, &ring->map, ring->len, ring->len ); + if ( ! ring->desc ) + return -ENOMEM; + + /* Initialise descriptor ring */ + for ( i = 0 ; i < ring->count ; i++ ) { + desc = &ring->desc[i]; + desc->addr = cpu_to_le32 ( CGEM_RX_ADDR_OWNED ); + desc->flags = cpu_to_le32 ( CGEM_TX_FL_OWNED ); + } + desc = &ring->desc[ ring->count - 1 ]; + desc->addr |= cpu_to_le32 ( CGEM_RX_ADDR_WRAP ); + desc->flags |= cpu_to_le32 ( CGEM_TX_FL_WRAP ); + + /* Program ring address */ + writel ( dma ( &ring->map, ring->desc ), + ( cgem->regs + ring->qbase ) ); + + DBGC ( cgem, "CGEM %s ring %02x is at [%08lx,%08lx)\n", + cgem->name, ring->qbase, virt_to_phys ( ring->desc ), + ( virt_to_phys ( ring->desc ) + ring->len ) ); + return 0; +} + +/** + * Destroy descriptor ring + * + * @v cgem Cadence GEM device + * @v ring Descriptor ring + */ +static void cgem_destroy_ring ( struct cgem_nic *cgem, + struct cgem_ring *ring ) { + + /* Clear ring address */ + writel ( 0, ( cgem->regs + ring->qbase ) ); + + /* Free descriptor ring */ + dma_free ( &ring->map, ring->desc, ring->len ); + ring->desc = NULL; + ring->prod = 0; + ring->cons = 0; +} + +/** + * Refill receive descriptor ring + * + * @v cgem Cadence GEM device + */ +static void cgem_refill_rx ( struct cgem_nic *cgem ) { + struct cgem_descriptor *rx; + struct io_buffer *iobuf; + unsigned int rx_idx; + uint32_t addr; + + /* Refill ring */ + while ( ( cgem->rx.prod - cgem->rx.cons ) != CGEM_NUM_RX_DESC ) { + + /* Allocate I/O buffer */ + iobuf = alloc_rx_iob ( CGEM_RX_LEN, cgem->dma ); + if ( ! iobuf ) { + /* Wait for next refill */ + break; + } + + /* Get next receive descriptor */ + rx_idx = ( cgem->rx.prod++ % CGEM_NUM_RX_DESC ); + rx = &cgem->rx.desc[rx_idx]; + + /* Populate receive descriptor */ + rx->flags = 0; + addr = 0; + if ( ( cgem->rx.prod % CGEM_NUM_RX_DESC ) == 0 ) + addr |= CGEM_RX_ADDR_WRAP; + rx->addr = cpu_to_le32 ( addr | iob_dma ( iobuf ) ); + + /* Record I/O buffer */ + assert ( cgem->rx_iobuf[rx_idx] == NULL ); + cgem->rx_iobuf[rx_idx] = iobuf; + + DBGC2 ( cgem, "CGEM %s RX %d is [%08lx,%08lx)\n", + cgem->name, rx_idx, virt_to_phys ( iobuf->data ), + ( virt_to_phys ( iobuf->data ) + CGEM_RX_LEN ) ); + } +} + +/** + * Open network device + * + * @v netdev Network device + * @ret rc Return status code + */ +static int cgem_open ( struct net_device *netdev ) { + struct cgem_nic *cgem = netdev->priv; + union cgem_mac mac; + int rc; + + /* Create transmit descriptor ring */ + if ( ( rc = cgem_create_ring ( cgem, &cgem->tx ) ) != 0 ) + goto err_create_tx; + + /* Create receive descriptor ring */ + if ( ( rc = cgem_create_ring ( cgem, &cgem->rx ) ) != 0 ) + goto err_create_rx; + + /* Set MAC address */ + memcpy ( mac.raw, netdev->ll_addr, ETH_ALEN ); + writel ( mac.reg.low, ( cgem->regs + CGEM_LADDRL ) ); + writel ( mac.reg.high, ( cgem->regs + CGEM_LADDRH ) ); + + /* Enable transmit and receive */ + writel ( CGEM_NWCTRL_NORMAL, ( cgem->regs + CGEM_NWCTRL ) ); + + /* Refill receive descriptor ring */ + cgem_refill_rx ( cgem ); + + /* Update link state */ + cgem_check_link ( netdev ); + + /* Start link state timer */ + start_timer_fixed ( &cgem->timer, CGEM_LINK_INTERVAL ); + + return 0; + + cgem_destroy_ring ( cgem, &cgem->rx ); + err_create_rx: + cgem_destroy_ring ( cgem, &cgem->tx ); + err_create_tx: + return rc; +} + +/** + * Close network device + * + * @v netdev Network device + */ +static void cgem_close ( struct net_device *netdev ) { + struct cgem_nic *cgem = netdev->priv; + unsigned int i; + + /* Stop link state timer */ + stop_timer ( &cgem->timer ); + + /* Reset NIC */ + cgem_reset ( cgem ); + + /* Discard unused receive buffers */ + for ( i = 0 ; i < CGEM_NUM_RX_DESC ; i++ ) { + if ( cgem->rx_iobuf[i] ) + free_rx_iob ( cgem->rx_iobuf[i] ); + cgem->rx_iobuf[i] = NULL; + } + + /* Destroy receive descriptor ring */ + cgem_destroy_ring ( cgem, &cgem->rx ); + + /* Destroy transmit descriptor ring */ + cgem_destroy_ring ( cgem, &cgem->tx ); +} + +/** + * Transmit packet + * + * @v netdev Network device + * @v iobuf I/O buffer + * @ret rc Return status code + */ +static int cgem_transmit ( struct net_device *netdev, + struct io_buffer *iobuf ) { + struct cgem_nic *cgem = netdev->priv; + struct cgem_descriptor *tx; + unsigned int tx_idx; + uint32_t flags; + int rc; + + /* Get next transmit descriptor */ + if ( ( cgem->tx.prod - cgem->tx.cons ) >= CGEM_NUM_TX_DESC ) { + DBGC ( cgem, "CGEM %s out of transmit descriptors\n", + cgem->name ); + return -ENOBUFS; + } + tx_idx = ( cgem->tx.prod % CGEM_NUM_TX_DESC ); + tx = &cgem->tx.desc[tx_idx]; + + /* Pad to minimum length */ + iob_pad ( iobuf, ETH_ZLEN ); + + /* Map I/O buffer */ + if ( ( rc = iob_map_tx ( iobuf, cgem->dma ) ) != 0 ) + return rc; + + /* Update producer index */ + cgem->tx.prod++; + + /* Populate transmit descriptor */ + flags = CGEM_TX_FL_LAST; + if ( ( cgem->tx.prod % CGEM_NUM_TX_DESC ) == 0 ) + flags |= CGEM_TX_FL_WRAP; + tx->addr = cpu_to_le32 ( iob_dma ( iobuf ) ); + wmb(); + tx->flags = cpu_to_le32 ( flags | iob_len ( iobuf ) ); + wmb(); + + /* Initiate transmission */ + writel ( ( CGEM_NWCTRL_NORMAL | CGEM_NWCTRL_STARTTX ), + ( cgem->regs + CGEM_NWCTRL ) ); + + DBGC2 ( cgem, "CGEM %s TX %d is [%08lx,%08lx)\n", + cgem->name, tx_idx, virt_to_phys ( iobuf->data ), + ( virt_to_phys ( iobuf->data ) + iob_len ( iobuf ) ) ); + return 0; +} + +/** + * Poll for completed packets + * + * @V netdev Network device + */ +static void cgem_poll_tx ( struct net_device *netdev ) { + struct cgem_nic *cgem = netdev->priv; + struct cgem_descriptor *tx; + unsigned int tx_idx; + + /* Check for completed packets */ + while ( cgem->tx.cons != cgem->tx.prod ) { + + /* Get next transmit descriptor */ + tx_idx = ( cgem->tx.cons % CGEM_NUM_TX_DESC ); + tx = &cgem->tx.desc[tx_idx]; + + /* Stop if descriptor is still owned by hardware */ + if ( ! ( tx->flags & cpu_to_le32 ( CGEM_TX_FL_OWNED ) ) ) + return; + DBGC2 ( cgem, "CGEM %s TX %d complete\n", + cgem->name, tx_idx ); + + /* Complete transmit descriptor */ + netdev_tx_complete_next ( netdev ); + cgem->tx.cons++; + } +} + +/** + * Poll for received packets + * + * @v netdev Network device + */ +static void cgem_poll_rx ( struct net_device *netdev ) { + struct cgem_nic *cgem = netdev->priv; + struct cgem_descriptor *rx; + struct io_buffer *iobuf; + unsigned int rx_idx; + uint32_t flags; + size_t len; + + /* Check for received packets */ + while ( cgem->rx.cons != cgem->rx.prod ) { + + /* Get next receive descriptor */ + rx_idx = ( cgem->rx.cons % CGEM_NUM_RX_DESC ); + rx = &cgem->rx.desc[rx_idx]; + + /* Stop if descriptor is still in use */ + if ( ! ( rx->addr & cpu_to_le32 ( CGEM_RX_ADDR_OWNED ) ) ) + return; + + /* Populate I/O buffer */ + iobuf = cgem->rx_iobuf[rx_idx]; + cgem->rx_iobuf[rx_idx] = NULL; + flags = le32_to_cpu ( rx->flags ); + len = CGEM_RX_FL_LEN ( flags ); + iob_put ( iobuf, len ); + DBGC2 ( cgem, "CGEM %s RX %d complete (length %zd)\n", + cgem->name, rx_idx, len ); + + /* Hand off to network stack */ + netdev_rx ( netdev, iobuf ); + cgem->rx.cons++; + } +} + +/** + * Poll for completed and received packets + * + * @v netdev Network device + */ +static void cgem_poll ( struct net_device *netdev ) { + struct cgem_nic *cgem = netdev->priv; + + /* Poll for TX competions */ + cgem_poll_tx ( netdev ); + + /* Poll for RX completions */ + cgem_poll_rx ( netdev ); + + /* Refill RX ring */ + cgem_refill_rx ( cgem ); +} + +/** Cadence GEM network device operations */ +static struct net_device_operations cgem_operations = { + .open = cgem_open, + .close = cgem_close, + .transmit = cgem_transmit, + .poll = cgem_poll, +}; + +/****************************************************************************** + * + * Devicetree interface + * + ****************************************************************************** + */ + +/** + * Probe devicetree device + * + * @v dt Devicetree device + * @v offset Starting node offset + * @ret rc Return status code + */ +static int cgem_probe ( struct dt_device *dt, unsigned int offset ) { + struct net_device *netdev; + struct cgem_nic *cgem; + union cgem_mac mac; + int rc; + + /* Allocate and initialise net device */ + netdev = alloc_etherdev ( sizeof ( *cgem ) ); + if ( ! netdev ) { + rc = -ENOMEM; + goto err_alloc; + } + netdev_init ( netdev, &cgem_operations ); + cgem = netdev->priv; + dt_set_drvdata ( dt, netdev ); + netdev->dev = &dt->dev; + memset ( cgem, 0, sizeof ( *cgem ) ); + cgem->dma = &dt->dma; + cgem->netdev = netdev; + cgem->name = netdev->dev->name; + mdio_init ( &cgem->mdio, &cgem_mii_operations ); + mii_init ( &cgem->mii, &cgem->mdio, 0 ); + timer_init ( &cgem->timer, cgem_expired, &netdev->refcnt ); + cgem_init_ring ( &cgem->tx, CGEM_NUM_TX_DESC, CGEM_TXQBASE ); + cgem_init_ring ( &cgem->rx, CGEM_NUM_RX_DESC, CGEM_RXQBASE ); + + /* Map registers */ + cgem->regs = dt_ioremap ( dt, offset, CGEM_REG_IDX, CGEM_REG_LEN ); + if ( ! cgem->regs ) { + rc = -ENODEV; + goto err_ioremap; + } + + /* Reset the NIC */ + if ( ( rc = cgem_reset ( cgem ) ) != 0 ) + goto err_reset; + + /* Initialise the PHY */ + if ( ( rc = cgem_init_phy ( cgem ) ) != 0 ) + goto err_init_phy; + + /* Fetch devicetree MAC address */ + if ( ( rc = fdt_mac ( &sysfdt, offset, netdev ) ) != 0 ) { + DBGC ( cgem, "CGEM %s could not fetch MAC: %s\n", + cgem->name, strerror ( rc ) ); + goto err_mac; + } + + /* Fetch current MAC address, if set */ + mac.reg.low = readl ( cgem->regs + CGEM_LADDRL ); + mac.reg.high = readl ( cgem->regs + CGEM_LADDRH ); + memcpy ( netdev->ll_addr, mac.raw, ETH_ALEN ); + + /* Register network device */ + if ( ( rc = register_netdev ( netdev ) ) != 0 ) + goto err_register_netdev; + + /* Set initial link state */ + cgem_check_link ( netdev ); + + return 0; + + unregister_netdev ( netdev ); + err_register_netdev: + err_mac: + err_init_phy: + cgem_reset ( cgem ); + err_reset: + iounmap ( cgem->regs ); + err_ioremap: + netdev_nullify ( netdev ); + netdev_put ( netdev ); + err_alloc: + return rc; +} + +/** + * Remove devicetree device + * + * @v dt Devicetree device + */ +static void cgem_remove ( struct dt_device *dt ) { + struct net_device *netdev = dt_get_drvdata ( dt ); + struct cgem_nic *cgem = netdev->priv; + + /* Unregister network device */ + unregister_netdev ( netdev ); + + /* Reset card */ + cgem_reset ( cgem ); + + /* Free network device */ + iounmap ( cgem->regs ); + netdev_nullify ( netdev ); + netdev_put ( netdev ); +} + +/** Cadence GEM compatible model identifiers */ +static const char * cgem_ids[] = { + "sifive,fu540-c000-gem", +}; + +/** Cadence GEM devicetree driver */ +struct dt_driver cgem_driver __dt_driver = { + .name = "cgem", + .ids = cgem_ids, + .id_count = ( sizeof ( cgem_ids ) / sizeof ( cgem_ids[0] ) ), + .probe = cgem_probe, + .remove = cgem_remove, +}; diff --git a/src/drivers/net/cgem.h b/src/drivers/net/cgem.h new file mode 100644 index 000000000..c91e3677d --- /dev/null +++ b/src/drivers/net/cgem.h @@ -0,0 +1,189 @@ +#ifndef _CGEM_H +#define _CGEM_H + +/** @file + * + * Cadence Gigabit Ethernet MAC (GEM) network driver + * + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#include +#include +#include +#include + +/** I/O region index */ +#define CGEM_REG_IDX 0 + +/** I/O region length */ +#define CGEM_REG_LEN 0x800 + +/** Network control register */ +#define CGEM_NWCTRL 0x000 +#define CGEM_NWCTRL_STARTTX 0x00000200 /**< Start transmission */ +#define CGEM_NWCTRL_STATCLR 0x00000020 /**< Clear statistics */ +#define CGEM_NWCTRL_MDEN 0x00000010 /**< MII interface enable */ +#define CGEM_NWCTRL_TXEN 0x00000008 /**< Transmit enable */ +#define CGEM_NWCTRL_RXEN 0x00000004 /**< Receive enable */ + +/** Normal value for network control register while up and running */ +#define CGEM_NWCTRL_NORMAL \ + ( CGEM_NWCTRL_MDEN | CGEM_NWCTRL_TXEN | CGEM_NWCTRL_RXEN ) + +/** Network configuration register */ +#define CGEM_NWCFG 0x004 + +/** Network status register */ +#define CGEM_NWSR 0x008 +#define CGEM_NWSR_MII_IDLE 0x00000004 /**< MII interface is idle */ + +/** DMA configuration register */ +#define CGEM_DMACR 0x010 +#define CGEM_DMACR_RXBUF( x ) ( ( (x) / 64 ) << 16 ) /**< RX buffer size */ +#define CGEM_DMACR_TXSIZE( x ) ( (x) << 10 ) /**< TX memory size */ +#define CGEM_DMACR_TXSIZE_MAX \ + CGEM_DMACR_TXSIZE ( 0x1 ) /**< Max TX memory size */ +#define CGEM_DMACR_RXSIZE( x ) ( (x) << 8 ) /**< RX memory size */ +#define CGEM_DMACR_RXSIZE_MAX \ + CGEM_DMACR_RXSIZE ( 0x3 ) /**< Max RX memory size */ +#define CGEM_DMACR_BLENGTH( x ) ( (x) << 0 ) /**< DMA burst length */ +#define CGEM_DMACR_BLENGTH_MAX \ + CGEM_DMACR_BLENGTH ( 0x10 ) /**< Max DMA burst length */ + +/** RX queue base address register */ +#define CGEM_RXQBASE 0x018 + +/** TX queue base address register */ +#define CGEM_TXQBASE 0x01c + +/** Interrupt disable register */ +#define CGEM_IDR 0x02c +#define CGEM_IDR_ALL 0xffffffff /**< Disable all interrupts */ + +/** PHY maintenance register */ +#define CGEM_PHYMNTNC 0x034 +#define CGEM_PHYMNTNC_CLAUSE22 0x40000000 /**< Clause 22 operation */ +#define CGEM_PHYMNTNC_OP_WRITE 0x10000000 /**< Write to PHY register */ +#define CGEM_PHYMNTNC_OP_READ 0x20000000 /**< Read from PHY register */ +#define CGEM_PHYMNTNC_ADDR( x ) ( (x) << 23 ) /**< PHY address */ +#define CGEM_PHYMNTNC_REG( x ) ( (x) << 18 ) /**< Register address */ +#define CGEM_PHYMNTNC_FIXED 0x00020000 /**< Fixed value to write */ +#define CGEM_PHYMNTNC_DATA_MASK 0x0000ffff /**< Data mask */ + +/** Maximum time to wait for PHY access, in microseconds */ +#define CGEM_MII_MAX_WAIT_US 500 + +/** Link state check interval */ +#define CGEM_LINK_INTERVAL ( 2 * TICKS_PER_SEC ) + +/** Local MAC address (low half) register */ +#define CGEM_LADDRL 0x088 + +/** Local MAC address (high half) register */ +#define CGEM_LADDRH 0x08c + +/** A Cadence GEM descriptor */ +struct cgem_descriptor { + /** Buffer address */ + uint32_t addr; + /** Flags */ + uint32_t flags; +} __attribute__ (( packed )); + +/** Transmit flags */ +#define CGEM_TX_FL_OWNED 0x80000000 /**< Owned by software */ +#define CGEM_TX_FL_WRAP 0x40000000 /**< End of descriptor ring */ +#define CGEM_TX_FL_LAST 0x00008000 /**< Last buffer in frame */ + +/** Transmit ring length */ +#define CGEM_NUM_TX_DESC 8 + +/** Receive flags (in buffer address) */ +#define CGEM_RX_ADDR_OWNED 0x00000001 /**< Owned by software */ +#define CGEM_RX_ADDR_WRAP 0x00000002 /**< End of descriptor ring */ + +/** Receive flags */ +#define CGEM_RX_FL_LEN( x ) ( (x) & 0x1fff ) /**< RX packet length */ + +/** Receive ring length */ +#define CGEM_NUM_RX_DESC 8 + +/** Length of receive buffers + * + * Must be a multiple of 64. + */ +#define CGEM_RX_LEN 1536 + +/** A Cadence GEM MAC address */ +union cgem_mac { + struct { + uint32_t low; + uint32_t high; + } __attribute__ (( packed )) reg; + uint8_t raw[ETH_ALEN]; +}; + +/** A Cadence GEM descriptor ring */ +struct cgem_ring { + /** Descriptors */ + struct cgem_descriptor *desc; + /** Descriptor ring DMA mapping */ + struct dma_mapping map; + /** Producer index */ + unsigned int prod; + /** Consumer index */ + unsigned int cons; + + /** Queue base address register */ + uint8_t qbase; + /** Number of descriptors */ + uint8_t count; + /** Length of descriptors */ + uint16_t len; +}; + +/** + * Initialise descriptor ring + * + * @v ring Descriptor ring + * @v count Number of descriptors + * @v qbase Queue base address register + */ +static inline __attribute__ (( always_inline )) void +cgem_init_ring ( struct cgem_ring *ring, unsigned int count, + unsigned int qbase ) { + + ring->qbase = qbase; + ring->count = count; + ring->len = ( count * sizeof ( ring->desc[0] ) ); +} + +/** A Cadence GEM network card */ +struct cgem_nic { + /** Registers */ + void *regs; + /** DMA device */ + struct dma_device *dma; + /** Network device */ + struct net_device *netdev; + /** Device name (for debugging) */ + const char *name; + + /** PHY interface */ + struct mii_interface mdio; + /** PHY device */ + struct mii_device mii; + /** Link state timer */ + struct retry_timer timer; + + /** Transmit ring */ + struct cgem_ring tx; + /** Receive ring */ + struct cgem_ring rx; + /** Receive I/O buffers */ + struct io_buffer *rx_iobuf[CGEM_NUM_RX_DESC]; +}; + +#endif /* _CGEM_H */ diff --git a/src/include/ipxe/devtree.h b/src/include/ipxe/devtree.h index 911e7ad15..04414f370 100644 --- a/src/include/ipxe/devtree.h +++ b/src/include/ipxe/devtree.h @@ -10,11 +10,14 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include /** A devicetree device */ struct dt_device { /** Generic device */ struct device dev; + /** DMA device */ + struct dma_device dma; /** Device path */ const char *path; /** Driver for this device */ diff --git a/src/include/ipxe/errfile.h b/src/include/ipxe/errfile.h index 2b8806706..37e36c720 100644 --- a/src/include/ipxe/errfile.h +++ b/src/include/ipxe/errfile.h @@ -232,6 +232,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define ERRFILE_atl_hw ( ERRFILE_DRIVER | 0x00d80000 ) #define ERRFILE_atl2_hw ( ERRFILE_DRIVER | 0x00d90000 ) #define ERRFILE_devtree ( ERRFILE_DRIVER | 0x00da0000 ) +#define ERRFILE_cgem ( ERRFILE_DRIVER | 0x00db0000 ) #define ERRFILE_aoe ( ERRFILE_NET | 0x00000000 ) #define ERRFILE_arp ( ERRFILE_NET | 0x00010000 ) -- cgit v1.2.3-55-g7522 From 71174e19d8c93dc99221c5fe32db6a78c6a7ffb3 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sun, 20 Apr 2025 13:39:32 +0100 Subject: [uaccess] Add explicit casts to and from userptr_t where needed Allow for the possibility of userptr_t becoming a pointer type by adding explicit casts where necessary. Signed-off-by: Michael Brown --- src/arch/x86/include/librm.h | 6 +++--- src/arch/x86/interface/pcbios/memtop_umalloc.c | 2 +- src/drivers/infiniband/golan.c | 2 +- src/include/ipxe/linux/linux_uaccess.h | 4 ++-- src/include/ipxe/uaccess.h | 4 ++-- src/interface/efi/efi_umalloc.c | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/drivers') diff --git a/src/arch/x86/include/librm.h b/src/arch/x86/include/librm.h index c664bff2c..23ca4650f 100644 --- a/src/arch/x86/include/librm.h +++ b/src/arch/x86/include/librm.h @@ -96,10 +96,10 @@ UACCESS_INLINE ( librm, phys_to_user ) ( unsigned long phys_addr ) { * identity-mapped. */ if ( sizeof ( physaddr_t ) > sizeof ( uint32_t ) ) - return phys_addr; + return ( ( userptr_t ) phys_addr ); /* In a 32-bit build, subtract virt_offset */ - return ( phys_addr - virt_offset ); + return ( ( userptr_t ) ( phys_addr - virt_offset ) ); } /** @@ -111,7 +111,7 @@ UACCESS_INLINE ( librm, phys_to_user ) ( unsigned long phys_addr ) { */ static inline __always_inline unsigned long UACCESS_INLINE ( librm, user_to_phys ) ( userptr_t userptr, off_t offset ) { - unsigned long addr = ( userptr + offset ); + unsigned long addr = ( ( unsigned long ) ( userptr + offset ) ); /* In a 64-bit build, any virtual address in the low 4GB is * directly usable as a physical address, since the low 4GB is diff --git a/src/arch/x86/interface/pcbios/memtop_umalloc.c b/src/arch/x86/interface/pcbios/memtop_umalloc.c index 1d3f40a1c..1cc3aff91 100644 --- a/src/arch/x86/interface/pcbios/memtop_umalloc.c +++ b/src/arch/x86/interface/pcbios/memtop_umalloc.c @@ -45,7 +45,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define EM_ALIGN ( 4 * 1024 ) /** Equivalent of NOWHERE for user pointers */ -#define UNOWHERE ( ~UNULL ) +#define UNOWHERE ( ( userptr_t ) ~( ( intptr_t ) 0 ) ) /** An external memory block */ struct external_memory { diff --git a/src/drivers/infiniband/golan.c b/src/drivers/infiniband/golan.c index 68a7c4f5d..81fc6c0f0 100755 --- a/src/drivers/infiniband/golan.c +++ b/src/drivers/infiniband/golan.c @@ -487,7 +487,7 @@ static inline int golan_provide_pages ( struct golan *golan , uint32_t pages next_page_addr += GOLAN_PAGE_SIZE ) { addr = next_page_addr; if (GOLAN_PAGE_MASK & user_to_phys(addr, 0)) { - DBGC (golan ,"Addr not Page alligned [%lx %lx]\n", user_to_phys(addr, 0), addr); + DBGC (golan ,"Addr not Page alligned [%lx]\n", user_to_phys(addr, 0)); } mailbox->mblock.data[j] = USR_2_BE64_BUS(addr); } diff --git a/src/include/ipxe/linux/linux_uaccess.h b/src/include/ipxe/linux/linux_uaccess.h index b29aa14bd..1e31afd9c 100644 --- a/src/include/ipxe/linux/linux_uaccess.h +++ b/src/include/ipxe/linux/linux_uaccess.h @@ -43,7 +43,7 @@ UACCESS_INLINE ( linux, user_to_phys ) ( userptr_t userptr, off_t offset ) { * virtual address will suffice for the purpose of determining * alignment. */ - return ( userptr + offset ); + return ( ( unsigned long ) ( userptr + offset ) ); } /** @@ -56,7 +56,7 @@ static inline __always_inline userptr_t UACCESS_INLINE ( linux, phys_to_user ) ( physaddr_t phys_addr ) { /* For symmetry with the stub user_to_phys() */ - return phys_addr; + return ( ( userptr_t ) phys_addr ); } static inline __always_inline userptr_t diff --git a/src/include/ipxe/uaccess.h b/src/include/ipxe/uaccess.h index 2575faca5..d8c57adeb 100644 --- a/src/include/ipxe/uaccess.h +++ b/src/include/ipxe/uaccess.h @@ -224,12 +224,12 @@ trivial_memchr_user ( userptr_t buffer, off_t offset, int c, size_t len ) { static inline __always_inline userptr_t UACCESS_INLINE ( flat, phys_to_user ) ( unsigned long phys_addr ) { - return phys_addr; + return ( ( userptr_t ) phys_addr ); } static inline __always_inline unsigned long UACCESS_INLINE ( flat, user_to_phys ) ( userptr_t userptr, off_t offset ) { - return ( userptr + offset ); + return ( ( unsigned long ) ( userptr + offset ) ); } static inline __always_inline userptr_t diff --git a/src/interface/efi/efi_umalloc.c b/src/interface/efi/efi_umalloc.c index e3f1dacc2..175ae367e 100644 --- a/src/interface/efi/efi_umalloc.c +++ b/src/interface/efi/efi_umalloc.c @@ -36,7 +36,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ /** Equivalent of NOWHERE for user pointers */ -#define UNOWHERE ( ~UNULL ) +#define UNOWHERE ( ( userptr_t ) ~( ( intptr_t ) 0 ) ) /** * Reallocate external memory -- cgit v1.2.3-55-g7522 From ef038491858cb51f8aa17b1f6e50444d2e627413 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sun, 20 Apr 2025 18:45:55 +0100 Subject: [uaccess] Remove redundant userptr_add() and userptr_diff() The userptr_add() and userptr_diff() functions are now just straightforward wrappers around addition and subtraction. Remove these redundant wrappers. Signed-off-by: Michael Brown --- src/arch/x86/image/bzimage.c | 12 +++--- src/arch/x86/image/initrd.c | 25 ++++++------ src/arch/x86/image/nbi.c | 4 +- src/arch/x86/include/librm.h | 11 ------ src/arch/x86/interface/pcbios/memtop_umalloc.c | 10 ++--- src/arch/x86/transitions/librm_mgmt.c | 1 - src/core/sanboot.c | 2 +- src/core/uaccess.c | 1 - src/drivers/net/gve.c | 2 +- src/image/gzip.c | 2 +- src/include/ipxe/linux/linux_uaccess.h | 11 ------ src/include/ipxe/uaccess.h | 53 -------------------------- src/interface/linux/linux_uaccess.c | 1 - 13 files changed, 27 insertions(+), 108 deletions(-) (limited to 'src/drivers') diff --git a/src/arch/x86/image/bzimage.c b/src/arch/x86/image/bzimage.c index b4a78cdfc..d00b9f155 100644 --- a/src/arch/x86/image/bzimage.c +++ b/src/arch/x86/image/bzimage.c @@ -431,7 +431,7 @@ static int bzimage_check_initrds ( struct image *image, } /* Calculate lowest usable address */ - bottom = userptr_add ( bzimg->pm_kernel, bzimg->pm_sz ); + bottom = ( bzimg->pm_kernel + bzimg->pm_sz ); /* Check that total length fits within space available for * reshuffling. This is a conservative check, since CPIO @@ -471,14 +471,12 @@ static void bzimage_load_initrds ( struct image *image, size_t len; /* Reshuffle initrds into desired order */ - initrd_reshuffle ( userptr_add ( bzimg->pm_kernel, bzimg->pm_sz ) ); + initrd_reshuffle ( bzimg->pm_kernel + bzimg->pm_sz ); /* Find highest initrd */ for_each_image ( initrd ) { - if ( ( highest == NULL ) || - ( userptr_diff ( initrd->data, highest->data ) > 0 ) ) { + if ( ( highest == NULL ) || ( initrd->data > highest->data ) ) highest = initrd; - } } /* Do nothing if there are no initrds */ @@ -486,7 +484,7 @@ static void bzimage_load_initrds ( struct image *image, return; /* Find highest usable address */ - top = userptr_add ( highest->data, bzimage_align ( highest->len ) ); + top = ( highest->data + bzimage_align ( highest->len ) ); if ( user_to_phys ( top, -1 ) > bzimg->mem_limit ) { top = phys_to_user ( ( bzimg->mem_limit + 1 ) & ~( INITRD_ALIGN - 1 ) ); @@ -509,7 +507,7 @@ static void bzimage_load_initrds ( struct image *image, } /* Load initrd at this address */ - dest = userptr_add ( top, -offset ); + dest = ( top - offset ); len = bzimage_load_initrd ( image, initrd, dest ); /* Record initrd location */ diff --git a/src/arch/x86/image/initrd.c b/src/arch/x86/image/initrd.c index c0a56b7f6..e32e40341 100644 --- a/src/arch/x86/image/initrd.c +++ b/src/arch/x86/image/initrd.c @@ -61,10 +61,9 @@ static userptr_t initrd_squash_high ( userptr_t top ) { /* Find the highest image not yet in its final position */ highest = NULL; for_each_image ( initrd ) { - if ( ( userptr_diff ( initrd->data, current ) < 0 ) && + if ( ( initrd->data < current ) && ( ( highest == NULL ) || - ( userptr_diff ( initrd->data, - highest->data ) > 0 ) ) ) { + ( initrd->data > highest->data ) ) ) { highest = initrd; } } @@ -74,7 +73,7 @@ static userptr_t initrd_squash_high ( userptr_t top ) { /* Move this image to its final position */ len = ( ( highest->len + INITRD_ALIGN - 1 ) & ~( INITRD_ALIGN - 1 ) ); - current = userptr_add ( current, -len ); + current -= len; DBGC ( &images, "INITRD squashing %s [%#08lx,%#08lx)->" "[%#08lx,%#08lx)\n", highest->name, user_to_phys ( highest->data, 0 ), @@ -87,10 +86,10 @@ static userptr_t initrd_squash_high ( userptr_t top ) { /* Copy any remaining initrds (e.g. embedded images) to the region */ for_each_image ( initrd ) { - if ( userptr_diff ( initrd->data, top ) >= 0 ) { + if ( initrd->data >= top ) { len = ( ( initrd->len + INITRD_ALIGN - 1 ) & ~( INITRD_ALIGN - 1 ) ); - current = userptr_add ( current, -len ); + current -= len; DBGC ( &images, "INITRD copying %s [%#08lx,%#08lx)->" "[%#08lx,%#08lx)\n", initrd->name, user_to_phys ( initrd->data, 0 ), @@ -149,7 +148,7 @@ static void initrd_swap ( struct image *low, struct image *high, /* Adjust data pointers */ high->data = low->data; - low->data = userptr_add ( low->data, len ); + low->data += len; } /** @@ -171,7 +170,7 @@ static int initrd_swap_any ( userptr_t free, size_t free_len ) { /* Calculate location of adjacent image (if any) */ padded_len = ( ( low->len + INITRD_ALIGN - 1 ) & ~( INITRD_ALIGN - 1 ) ); - adjacent = userptr_add ( low->data, padded_len ); + adjacent = ( low->data + padded_len ); /* Search for adjacent image */ for_each_image ( high ) { @@ -235,7 +234,7 @@ void initrd_reshuffle ( userptr_t bottom ) { /* Calculate limits of available space for initrds */ top = initrd_top; - if ( userptr_diff ( initrd_bottom, bottom ) > 0 ) + if ( initrd_bottom > bottom ) bottom = initrd_bottom; /* Debug */ @@ -248,7 +247,7 @@ void initrd_reshuffle ( userptr_t bottom ) { /* Calculate available free space */ free = bottom; - free_len = userptr_diff ( used, free ); + free_len = ( used - free ); /* Bubble-sort initrds into desired order */ while ( initrd_swap_any ( free, free_len ) ) {} @@ -270,9 +269,9 @@ int initrd_reshuffle_check ( size_t len, userptr_t bottom ) { /* Calculate limits of available space for initrds */ top = initrd_top; - if ( userptr_diff ( initrd_bottom, bottom ) > 0 ) + if ( initrd_bottom > bottom ) bottom = initrd_bottom; - available = userptr_diff ( top, bottom ); + available = ( top - bottom ); /* Allow for a sensible minimum amount of free space */ len += INITRD_MIN_FREE_LEN; @@ -296,7 +295,7 @@ static void initrd_startup ( void ) { * can safely reuse when rearranging). */ len = largest_memblock ( &initrd_bottom ); - initrd_top = userptr_add ( initrd_bottom, len ); + initrd_top = ( initrd_bottom + len ); } /** initrd startup function */ diff --git a/src/arch/x86/image/nbi.c b/src/arch/x86/image/nbi.c index b691bee20..2f0d3164a 100644 --- a/src/arch/x86/image/nbi.c +++ b/src/arch/x86/image/nbi.c @@ -184,10 +184,10 @@ static int nbi_process_segments ( struct image *image, dest = phys_to_user ( sh.loadaddr ); break; case NBI_LOADADDR_AFTER: - dest = userptr_add ( dest, memsz + sh.loadaddr ); + dest = ( dest + memsz + sh.loadaddr ); break; case NBI_LOADADDR_BEFORE: - dest = userptr_add ( dest, -sh.loadaddr ); + dest = ( dest - sh.loadaddr ); break; case NBI_LOADADDR_END: /* Not correct according to the spec, but diff --git a/src/arch/x86/include/librm.h b/src/arch/x86/include/librm.h index 23ca4650f..c0d910287 100644 --- a/src/arch/x86/include/librm.h +++ b/src/arch/x86/include/librm.h @@ -137,17 +137,6 @@ UACCESS_INLINE ( librm, user_to_virt ) ( userptr_t userptr, off_t offset ) { return trivial_user_to_virt ( userptr, offset ); } -static inline __always_inline userptr_t -UACCESS_INLINE ( librm, userptr_add ) ( userptr_t userptr, off_t offset ) { - return trivial_userptr_add ( userptr, offset ); -} - -static inline __always_inline off_t -UACCESS_INLINE ( librm, userptr_diff ) ( userptr_t userptr, - userptr_t subtrahend ) { - return trivial_userptr_diff ( userptr, subtrahend ); -} - static inline __always_inline void UACCESS_INLINE ( librm, memcpy_user ) ( userptr_t dest, off_t dest_off, userptr_t src, off_t src_off, diff --git a/src/arch/x86/interface/pcbios/memtop_umalloc.c b/src/arch/x86/interface/pcbios/memtop_umalloc.c index 1cc3aff91..e76b3df93 100644 --- a/src/arch/x86/interface/pcbios/memtop_umalloc.c +++ b/src/arch/x86/interface/pcbios/memtop_umalloc.c @@ -122,7 +122,7 @@ static void init_eheap ( void ) { userptr_t base; heap_size = largest_memblock ( &base ); - bottom = top = userptr_add ( base, heap_size ); + bottom = top = ( base + heap_size ); DBG ( "External heap grows downwards from %lx (size %zx)\n", user_to_phys ( top, 0 ), heap_size ); } @@ -144,7 +144,7 @@ static void ecollect_free ( void ) { DBG ( "EXTMEM freeing [%lx,%lx)\n", user_to_phys ( bottom, 0 ), user_to_phys ( bottom, extmem.size ) ); len = ( extmem.size + sizeof ( extmem ) ); - bottom = userptr_add ( bottom, len ); + bottom += len; heap_size += len; } } @@ -179,7 +179,7 @@ static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) { DBG ( "EXTMEM out of space\n" ); return UNULL; } - ptr = bottom = userptr_add ( bottom, -sizeof ( extmem ) ); + ptr = bottom = ( bottom - sizeof ( extmem ) ); heap_size -= sizeof ( extmem ); DBG ( "EXTMEM allocating [%lx,%lx)\n", user_to_phys ( ptr, 0 ), user_to_phys ( ptr, 0 ) ); @@ -190,10 +190,10 @@ static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) { /* Expand/shrink block if possible */ if ( ptr == bottom ) { /* Update block */ - new = userptr_add ( ptr, - ( new_size - extmem.size ) ); + new = ( ptr - ( new_size - extmem.size ) ); align = ( user_to_phys ( new, 0 ) & ( EM_ALIGN - 1 ) ); new_size += align; - new = userptr_add ( new, -align ); + new -= align; if ( new_size > ( heap_size + extmem.size ) ) { DBG ( "EXTMEM out of space\n" ); return UNULL; diff --git a/src/arch/x86/transitions/librm_mgmt.c b/src/arch/x86/transitions/librm_mgmt.c index b3820589c..ec31fceb1 100644 --- a/src/arch/x86/transitions/librm_mgmt.c +++ b/src/arch/x86/transitions/librm_mgmt.c @@ -432,7 +432,6 @@ PROVIDE_UACCESS_INLINE ( librm, phys_to_user ); PROVIDE_UACCESS_INLINE ( librm, user_to_phys ); PROVIDE_UACCESS_INLINE ( librm, virt_to_user ); PROVIDE_UACCESS_INLINE ( librm, user_to_virt ); -PROVIDE_UACCESS_INLINE ( librm, userptr_add ); PROVIDE_UACCESS_INLINE ( librm, memcpy_user ); PROVIDE_UACCESS_INLINE ( librm, memmove_user ); PROVIDE_UACCESS_INLINE ( librm, memset_user ); diff --git a/src/core/sanboot.c b/src/core/sanboot.c index e49a3f92d..4facf86b8 100644 --- a/src/core/sanboot.c +++ b/src/core/sanboot.c @@ -625,7 +625,7 @@ static int sandev_rw ( struct san_device *sandev, uint64_t lba, /* Move to next fragment */ frag_len = ( sandev->capacity.blksize * params.rw.count ); - params.rw.buffer = userptr_add ( params.rw.buffer, frag_len ); + params.rw.buffer += frag_len; params.rw.lba += params.rw.count; remaining -= params.rw.count; } diff --git a/src/core/uaccess.c b/src/core/uaccess.c index d3a9ca17d..ad17a58ab 100644 --- a/src/core/uaccess.c +++ b/src/core/uaccess.c @@ -36,7 +36,6 @@ PROVIDE_UACCESS_INLINE ( flat, phys_to_user ); PROVIDE_UACCESS_INLINE ( flat, user_to_phys ); PROVIDE_UACCESS_INLINE ( flat, virt_to_user ); PROVIDE_UACCESS_INLINE ( flat, user_to_virt ); -PROVIDE_UACCESS_INLINE ( flat, userptr_add ); PROVIDE_UACCESS_INLINE ( flat, memcpy_user ); PROVIDE_UACCESS_INLINE ( flat, memmove_user ); PROVIDE_UACCESS_INLINE ( flat, memset_user ); diff --git a/src/drivers/net/gve.c b/src/drivers/net/gve.c index efc38dd21..805feee3d 100644 --- a/src/drivers/net/gve.c +++ b/src/drivers/net/gve.c @@ -807,7 +807,7 @@ static inline __attribute__ (( always_inline )) userptr_t gve_buffer ( struct gve_queue *queue, unsigned int index ) { /* Pages are currently allocated as a single contiguous block */ - return userptr_add ( queue->qpl.data, gve_address ( queue, index ) ); + return ( queue->qpl.data + gve_address ( queue, index ) ); } /** diff --git a/src/image/gzip.c b/src/image/gzip.c index 98376e113..116d912d7 100644 --- a/src/image/gzip.c +++ b/src/image/gzip.c @@ -111,7 +111,7 @@ static int gzip_extract ( struct image *image, struct image *extracted ) { } /* Initialise input chunk */ - deflate_chunk_init ( &in, userptr_add ( image->data, offset ), 0, len ); + deflate_chunk_init ( &in, ( image->data + offset ), 0, len ); /* Presize extracted image */ if ( ( rc = image_set_len ( extracted, diff --git a/src/include/ipxe/linux/linux_uaccess.h b/src/include/ipxe/linux/linux_uaccess.h index 1e31afd9c..790c75123 100644 --- a/src/include/ipxe/linux/linux_uaccess.h +++ b/src/include/ipxe/linux/linux_uaccess.h @@ -69,17 +69,6 @@ UACCESS_INLINE ( linux, user_to_virt ) ( userptr_t userptr, off_t offset ) { return trivial_user_to_virt ( userptr, offset ); } -static inline __always_inline userptr_t -UACCESS_INLINE ( linux, userptr_add ) ( userptr_t userptr, off_t offset ) { - return trivial_userptr_add ( userptr, offset ); -} - -static inline __always_inline off_t -UACCESS_INLINE ( linux, userptr_diff ) ( userptr_t userptr, - userptr_t subtrahend ) { - return trivial_userptr_diff ( userptr, subtrahend ); -} - static inline __always_inline void UACCESS_INLINE ( linux, memcpy_user ) ( userptr_t dest, off_t dest_off, userptr_t src, off_t src_off, diff --git a/src/include/ipxe/uaccess.h b/src/include/ipxe/uaccess.h index 1790e4066..93dc60d62 100644 --- a/src/include/ipxe/uaccess.h +++ b/src/include/ipxe/uaccess.h @@ -65,30 +65,6 @@ trivial_user_to_virt ( userptr_t userptr, off_t offset ) { return ( ( void * ) userptr + offset ); } -/** - * Add offset to user pointer - * - * @v userptr User pointer - * @v offset Offset - * @ret userptr New pointer value - */ -static inline __always_inline userptr_t -trivial_userptr_add ( userptr_t userptr, off_t offset ) { - return ( userptr + offset ); -} - -/** - * Subtract user pointers - * - * @v userptr User pointer - * @v subtrahend User pointer to be subtracted - * @ret offset Offset - */ -static inline __always_inline off_t -trivial_userptr_diff ( userptr_t userptr, userptr_t subtrahend ) { - return ( userptr - subtrahend ); -} - /** * Copy data between user buffers * @@ -231,17 +207,6 @@ UACCESS_INLINE ( flat, user_to_virt ) ( userptr_t userptr, off_t offset ) { return trivial_user_to_virt ( userptr, offset ); } -static inline __always_inline userptr_t -UACCESS_INLINE ( flat, userptr_add ) ( userptr_t userptr, off_t offset ) { - return trivial_userptr_add ( userptr, offset ); -} - -static inline __always_inline off_t -UACCESS_INLINE ( flat, userptr_diff ) ( userptr_t userptr, - userptr_t subtrahend ) { - return trivial_userptr_diff ( userptr, subtrahend ); -} - static inline __always_inline void UACCESS_INLINE ( flat, memcpy_user ) ( userptr_t dest, off_t dest_off, userptr_t src, off_t src_off, @@ -322,24 +287,6 @@ userptr_t virt_to_user ( volatile const void *addr ); */ void * user_to_virt ( userptr_t userptr, off_t offset ); -/** - * Add offset to user pointer - * - * @v userptr User pointer - * @v offset Offset - * @ret userptr New pointer value - */ -userptr_t userptr_add ( userptr_t userptr, off_t offset ); - -/** - * Subtract user pointers - * - * @v userptr User pointer - * @v subtrahend User pointer to be subtracted - * @ret offset Offset - */ -off_t userptr_diff ( userptr_t userptr, userptr_t subtrahend ); - /** * Convert virtual address to a physical address * diff --git a/src/interface/linux/linux_uaccess.c b/src/interface/linux/linux_uaccess.c index ea2d8057c..9fc99c5e2 100644 --- a/src/interface/linux/linux_uaccess.c +++ b/src/interface/linux/linux_uaccess.c @@ -30,7 +30,6 @@ FILE_LICENCE(GPL2_OR_LATER); PROVIDE_UACCESS_INLINE(linux, user_to_phys); PROVIDE_UACCESS_INLINE(linux, virt_to_user); PROVIDE_UACCESS_INLINE(linux, user_to_virt); -PROVIDE_UACCESS_INLINE(linux, userptr_add); PROVIDE_UACCESS_INLINE(linux, memcpy_user); PROVIDE_UACCESS_INLINE(linux, memmove_user); PROVIDE_UACCESS_INLINE(linux, memset_user); -- cgit v1.2.3-55-g7522 From 89fe7886897be76ed902317e311d60ae654057aa Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sun, 20 Apr 2025 18:29:48 +0100 Subject: [uaccess] Remove redundant memcpy_user() and related string functions The memcpy_user(), memmove_user(), memcmp_user(), memset_user(), and strlen_user() functions are now just straightforward wrappers around the corresponding standard library functions. Remove these redundant wrappers. Signed-off-by: Michael Brown --- src/arch/x86/core/runtime.c | 2 +- src/arch/x86/image/bzimage.c | 13 +- src/arch/x86/image/com32.c | 2 +- src/arch/x86/image/comboot.c | 4 +- src/arch/x86/image/initrd.c | 12 +- src/arch/x86/image/multiboot.c | 6 +- src/arch/x86/image/nbi.c | 2 +- src/arch/x86/image/pxe_image.c | 2 +- src/arch/x86/image/sdi.c | 4 +- src/arch/x86/image/ucode.c | 2 +- src/arch/x86/include/librm.h | 32 ----- src/arch/x86/interface/pcbios/memtop_umalloc.c | 4 +- src/arch/x86/interface/pxe/pxe_file.c | 6 +- src/arch/x86/interface/syslinux/com32_call.c | 20 ++- src/arch/x86/interface/syslinux/comboot_call.c | 20 +-- src/arch/x86/transitions/librm_mgmt.c | 8 +- src/core/fbcon.c | 24 ++-- src/core/image.c | 2 +- src/core/uaccess.c | 4 - src/crypto/deflate.c | 4 +- src/drivers/net/exanic.c | 2 +- src/drivers/net/gve.c | 2 +- src/drivers/usb/xhci.c | 2 +- src/image/elf.c | 2 +- src/image/segment.c | 2 +- src/include/ipxe/linux/linux_uaccess.h | 32 ----- src/include/ipxe/uaccess.h | 166 +------------------------ src/interface/efi/efi_fbcon.c | 4 +- src/interface/efi/efi_umalloc.c | 4 +- src/interface/linux/linux_uaccess.c | 4 - src/interface/smbios/smbios.c | 2 +- src/tests/cms_test.c | 4 +- src/tests/gzip_test.c | 5 +- src/tests/pixbuf_test.c | 5 +- src/tests/zlib_test.c | 5 +- 35 files changed, 83 insertions(+), 331 deletions(-) (limited to 'src/drivers') diff --git a/src/arch/x86/core/runtime.c b/src/arch/x86/core/runtime.c index 02072b5bf..2b803f772 100644 --- a/src/arch/x86/core/runtime.c +++ b/src/arch/x86/core/runtime.c @@ -125,7 +125,7 @@ static int cmdline_init ( void ) { return 0; } cmdline_user = phys_to_user ( cmdline_phys ); - len = ( strlen_user ( cmdline_user, 0 ) + 1 /* NUL */ ); + len = ( strlen ( cmdline_user ) + 1 /* NUL */ ); /* Allocate and copy command line */ cmdline_copy = malloc ( len ); diff --git a/src/arch/x86/image/bzimage.c b/src/arch/x86/image/bzimage.c index d00b9f155..29ebeb507 100644 --- a/src/arch/x86/image/bzimage.c +++ b/src/arch/x86/image/bzimage.c @@ -369,8 +369,8 @@ static size_t bzimage_load_initrd ( struct image *image, /* Copy in initrd image body and construct any cpio headers */ if ( address ) { - memmove_user ( address, len, initrd->data, 0, initrd->len ); - memset_user ( address, 0, 0, len ); + memmove ( ( address + len ), initrd->data, initrd->len ); + memset ( address, 0, len ); offset = 0; for ( i = 0 ; ( cpio_len = cpio_header ( initrd, i, &cpio ) ) ; i++ ) { @@ -395,7 +395,7 @@ static size_t bzimage_load_initrd ( struct image *image, /* Zero-pad to next INITRD_ALIGN boundary */ pad_len = ( ( -len ) & ( INITRD_ALIGN - 1 ) ); if ( address ) - memset_user ( address, len, 0, pad_len ); + memset ( ( address + len ), 0, pad_len ); return len; } @@ -562,10 +562,9 @@ static int bzimage_exec ( struct image *image ) { unregister_image ( image_get ( image ) ); /* Load segments */ - memcpy_user ( bzimg.rm_kernel, 0, image->data, - 0, bzimg.rm_filesz ); - memcpy_user ( bzimg.pm_kernel, 0, image->data, - bzimg.rm_filesz, bzimg.pm_sz ); + memcpy ( bzimg.rm_kernel, image->data, bzimg.rm_filesz ); + memcpy ( bzimg.pm_kernel, ( image->data + bzimg.rm_filesz ), + bzimg.pm_sz ); /* Store command line */ bzimage_set_cmdline ( image, &bzimg ); diff --git a/src/arch/x86/image/com32.c b/src/arch/x86/image/com32.c index 6f0e66041..3e38215cb 100644 --- a/src/arch/x86/image/com32.c +++ b/src/arch/x86/image/com32.c @@ -219,7 +219,7 @@ static int com32_load_image ( struct image *image ) { } /* Copy image to segment */ - memcpy_user ( buffer, 0, image->data, 0, filesz ); + memcpy ( buffer, image->data, filesz ); return 0; } diff --git a/src/arch/x86/image/comboot.c b/src/arch/x86/image/comboot.c index 9a847f0ff..8609eb0f7 100644 --- a/src/arch/x86/image/comboot.c +++ b/src/arch/x86/image/comboot.c @@ -267,10 +267,10 @@ static int comboot_prepare_segment ( struct image *image ) } /* Zero PSP */ - memset_user ( seg_userptr, 0, 0, 0x100 ); + memset ( seg_userptr, 0, 0x100 ); /* Copy image to segment:0100 */ - memcpy_user ( seg_userptr, 0x100, image->data, 0, image->len ); + memcpy ( ( seg_userptr + 0x100 ), image->data, image->len ); return 0; } diff --git a/src/arch/x86/image/initrd.c b/src/arch/x86/image/initrd.c index e32e40341..95f12d804 100644 --- a/src/arch/x86/image/initrd.c +++ b/src/arch/x86/image/initrd.c @@ -80,7 +80,7 @@ static userptr_t initrd_squash_high ( userptr_t top ) { user_to_phys ( highest->data, highest->len ), user_to_phys ( current, 0 ), user_to_phys ( current, highest->len ) ); - memmove_user ( current, 0, highest->data, 0, highest->len ); + memmove ( current, highest->data, highest->len ); highest->data = current; } @@ -96,8 +96,7 @@ static userptr_t initrd_squash_high ( userptr_t top ) { user_to_phys ( initrd->data, initrd->len ), user_to_phys ( current, 0 ), user_to_phys ( current, initrd->len ) ); - memcpy_user ( current, 0, initrd->data, 0, - initrd->len ); + memcpy ( current, initrd->data, initrd->len ); initrd->data = current; } } @@ -140,9 +139,10 @@ static void initrd_swap ( struct image *low, struct image *high, ~( INITRD_ALIGN - 1 ) ); /* Swap fragments */ - memcpy_user ( free, 0, high->data, len, frag_len ); - memmove_user ( low->data, new_len, low->data, len, low->len ); - memcpy_user ( low->data, len, free, 0, frag_len ); + memcpy ( free, ( high->data + len ), frag_len ); + memmove ( ( low->data + new_len ), ( low->data + len ), + low->len ); + memcpy ( ( low->data + len ), free, frag_len ); len = new_len; } diff --git a/src/arch/x86/image/multiboot.c b/src/arch/x86/image/multiboot.c index cada021ab..fe21f1f1a 100644 --- a/src/arch/x86/image/multiboot.c +++ b/src/arch/x86/image/multiboot.c @@ -222,8 +222,8 @@ static int multiboot_add_modules ( struct image *image, physaddr_t start, } /* Copy module */ - memcpy_user ( phys_to_user ( start ), 0, - module_image->data, 0, module_image->len ); + memcpy ( phys_to_user ( start ), module_image->data, + module_image->len ); /* Add module to list */ module = &modules[mbinfo->mods_count++]; @@ -350,7 +350,7 @@ static int multiboot_load_raw ( struct image *image, } /* Copy image to segment */ - memcpy_user ( buffer, 0, image->data, offset, filesz ); + memcpy ( buffer, ( image->data + offset ), filesz ); /* Record execution entry point and maximum used address */ *entry = hdr->mb.entry_addr; diff --git a/src/arch/x86/image/nbi.c b/src/arch/x86/image/nbi.c index 2f0d3164a..0b02a8985 100644 --- a/src/arch/x86/image/nbi.c +++ b/src/arch/x86/image/nbi.c @@ -131,7 +131,7 @@ static int nbi_prepare_segment ( struct image *image, size_t offset __unused, static int nbi_load_segment ( struct image *image, size_t offset, userptr_t dest, size_t filesz, size_t memsz __unused ) { - memcpy_user ( dest, 0, image->data, offset, filesz ); + memcpy ( dest, ( image->data + offset ), filesz ); return 0; } diff --git a/src/arch/x86/image/pxe_image.c b/src/arch/x86/image/pxe_image.c index b6bcb18b4..bdce165ca 100644 --- a/src/arch/x86/image/pxe_image.c +++ b/src/arch/x86/image/pxe_image.c @@ -66,7 +66,7 @@ static int pxe_exec ( struct image *image ) { } /* Copy image to segment */ - memcpy_user ( buffer, 0, image->data, 0, image->len ); + memcpy ( buffer, image->data, image->len ); /* Arbitrarily pick the most recently opened network device */ if ( ( netdev = last_opened_netdev() ) == NULL ) { diff --git a/src/arch/x86/image/sdi.c b/src/arch/x86/image/sdi.c index fa2d0b73f..5bb5a7569 100644 --- a/src/arch/x86/image/sdi.c +++ b/src/arch/x86/image/sdi.c @@ -97,8 +97,8 @@ static int sdi_exec ( struct image *image ) { user_to_phys ( image->data, sdi.boot_offset ), sdi.boot_size ); /* Copy boot code */ - memcpy_user ( real_to_user ( SDI_BOOT_SEG, SDI_BOOT_OFF ), 0, - image->data, sdi.boot_offset, sdi.boot_size ); + memcpy ( real_to_user ( SDI_BOOT_SEG, SDI_BOOT_OFF ), + ( image->data + sdi.boot_offset ), sdi.boot_size ); /* Jump to boot code */ sdiptr = ( user_to_phys ( image->data, 0 ) | SDI_WTF ); diff --git a/src/arch/x86/image/ucode.c b/src/arch/x86/image/ucode.c index 499c0a940..9b6b5067a 100644 --- a/src/arch/x86/image/ucode.c +++ b/src/arch/x86/image/ucode.c @@ -256,7 +256,7 @@ static int ucode_update_all ( struct image *image, rc = -ENOMEM; goto err_alloc; } - memset_user ( status, 0, 0, len ); + memset ( status, 0, len ); /* Construct control structure */ memset ( &control, 0, sizeof ( control ) ); diff --git a/src/arch/x86/include/librm.h b/src/arch/x86/include/librm.h index c0d910287..c117a8b5c 100644 --- a/src/arch/x86/include/librm.h +++ b/src/arch/x86/include/librm.h @@ -137,38 +137,6 @@ UACCESS_INLINE ( librm, user_to_virt ) ( userptr_t userptr, off_t offset ) { return trivial_user_to_virt ( userptr, offset ); } -static inline __always_inline void -UACCESS_INLINE ( librm, memcpy_user ) ( userptr_t dest, off_t dest_off, - userptr_t src, off_t src_off, - size_t len ) { - trivial_memcpy_user ( dest, dest_off, src, src_off, len ); -} - -static inline __always_inline void -UACCESS_INLINE ( librm, memmove_user ) ( userptr_t dest, off_t dest_off, - userptr_t src, off_t src_off, - size_t len ) { - trivial_memmove_user ( dest, dest_off, src, src_off, len ); -} - -static inline __always_inline int -UACCESS_INLINE ( librm, memcmp_user ) ( userptr_t first, off_t first_off, - userptr_t second, off_t second_off, - size_t len ) { - return trivial_memcmp_user ( first, first_off, second, second_off, len); -} - -static inline __always_inline void -UACCESS_INLINE ( librm, memset_user ) ( userptr_t buffer, off_t offset, - int c, size_t len ) { - trivial_memset_user ( buffer, offset, c, len ); -} - -static inline __always_inline size_t -UACCESS_INLINE ( librm, strlen_user ) ( userptr_t buffer, off_t offset ) { - return trivial_strlen_user ( buffer, offset ); -} - static inline __always_inline off_t UACCESS_INLINE ( librm, memchr_user ) ( userptr_t buffer, off_t offset, int c, size_t len ) { diff --git a/src/arch/x86/interface/pcbios/memtop_umalloc.c b/src/arch/x86/interface/pcbios/memtop_umalloc.c index e76b3df93..8239b23b8 100644 --- a/src/arch/x86/interface/pcbios/memtop_umalloc.c +++ b/src/arch/x86/interface/pcbios/memtop_umalloc.c @@ -203,8 +203,8 @@ static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) { user_to_phys ( ptr, extmem.size ), user_to_phys ( new, 0 ), user_to_phys ( new, new_size )); - memmove_user ( new, 0, ptr, 0, ( ( extmem.size < new_size ) ? - extmem.size : new_size ) ); + memmove ( new, ptr, ( ( extmem.size < new_size ) ? + extmem.size : new_size ) ); bottom = new; heap_size -= ( new_size - extmem.size ); extmem.size = new_size; diff --git a/src/arch/x86/interface/pxe/pxe_file.c b/src/arch/x86/interface/pxe/pxe_file.c index 456ffb5fd..1235520de 100644 --- a/src/arch/x86/interface/pxe/pxe_file.c +++ b/src/arch/x86/interface/pxe/pxe_file.c @@ -61,8 +61,8 @@ static PXENV_EXIT_t pxenv_file_open ( struct s_PXENV_FILE_OPEN *file_open ) { /* Copy name from external program, and open it */ filename = real_to_user ( file_open->FileName.segment, - file_open->FileName.offset ); - filename_len = strlen_user ( filename, 0 ); + file_open->FileName.offset ); + filename_len = strlen ( filename ); { char uri_string[ filename_len + 1 ]; @@ -219,7 +219,7 @@ static PXENV_EXIT_t pxenv_file_exec ( struct s_PXENV_FILE_EXEC *file_exec ) { /* Copy name from external program, and exec it */ command = real_to_user ( file_exec->Command.segment, file_exec->Command.offset ); - command_len = strlen_user ( command, 0 ); + command_len = strlen ( command ); { char command_string[ command_len + 1 ]; diff --git a/src/arch/x86/interface/syslinux/com32_call.c b/src/arch/x86/interface/syslinux/com32_call.c index 19fdbaff9..da9d6491a 100644 --- a/src/arch/x86/interface/syslinux/com32_call.c +++ b/src/arch/x86/interface/syslinux/com32_call.c @@ -49,9 +49,8 @@ void __asmcall com32_intcall ( uint8_t interrupt, physaddr_t inregs_phys, physad DBGC ( &com32_regs, "COM32 INT%x in %#08lx out %#08lx\n", interrupt, inregs_phys, outregs_phys ); - memcpy_user ( virt_to_user( &com32_regs ), 0, - phys_to_user ( inregs_phys ), 0, - sizeof(com32sys_t) ); + memcpy ( virt_to_user( &com32_regs ), phys_to_user ( inregs_phys ), + sizeof ( com32sys_t ) ); com32_int_vector = interrupt; @@ -108,9 +107,8 @@ void __asmcall com32_intcall ( uint8_t interrupt, physaddr_t inregs_phys, physad : : ); if ( outregs_phys ) { - memcpy_user ( phys_to_user ( outregs_phys ), 0, - virt_to_user( &com32_regs ), 0, - sizeof(com32sys_t) ); + memcpy ( phys_to_user ( outregs_phys ), + virt_to_user ( &com32_regs ), sizeof ( com32sys_t ) ); } } @@ -122,9 +120,8 @@ void __asmcall com32_farcall ( uint32_t proc, physaddr_t inregs_phys, physaddr_t DBGC ( &com32_regs, "COM32 farcall %04x:%04x in %#08lx out %#08lx\n", ( proc >> 16 ), ( proc & 0xffff ), inregs_phys, outregs_phys ); - memcpy_user ( virt_to_user( &com32_regs ), 0, - phys_to_user ( inregs_phys ), 0, - sizeof(com32sys_t) ); + memcpy ( virt_to_user( &com32_regs ), phys_to_user ( inregs_phys ), + sizeof ( com32sys_t ) ); com32_farcall_proc = proc; @@ -170,9 +167,8 @@ void __asmcall com32_farcall ( uint32_t proc, physaddr_t inregs_phys, physaddr_t : : ); if ( outregs_phys ) { - memcpy_user ( phys_to_user ( outregs_phys ), 0, - virt_to_user( &com32_regs ), 0, - sizeof(com32sys_t) ); + memcpy ( phys_to_user ( outregs_phys ), + virt_to_user ( &com32_regs ), sizeof ( com32sys_t ) ); } } diff --git a/src/arch/x86/interface/syslinux/comboot_call.c b/src/arch/x86/interface/syslinux/comboot_call.c index b75e8ef7c..f26fcad0a 100644 --- a/src/arch/x86/interface/syslinux/comboot_call.c +++ b/src/arch/x86/interface/syslinux/comboot_call.c @@ -119,7 +119,7 @@ static void shuffle ( unsigned int list_segment, unsigned int list_offset, unsig if ( shuf[ i ].src == 0xFFFFFFFF ) { /* Fill with 0 instead of copying */ - memset_user ( dest_u, 0, 0, shuf[ i ].len ); + memset ( dest_u, 0, shuf[ i ].len ); } else if ( shuf[ i ].dest == 0xFFFFFFFF ) { /* Copy new list of descriptors */ count = shuf[ i ].len / sizeof( comboot_shuffle_descriptor ); @@ -128,7 +128,7 @@ static void shuffle ( unsigned int list_segment, unsigned int list_offset, unsig i = -1; } else { /* Regular copy */ - memmove_user ( dest_u, 0, src_u, 0, shuf[ i ].len ); + memmove ( dest_u, src_u, shuf[ i ].len ); } } } @@ -347,7 +347,7 @@ static __asmcall __used void int22 ( struct i386_all_regs *ix86 ) { case 0x0003: /* Run command */ { userptr_t cmd_u = real_to_user ( ix86->segs.es, ix86->regs.bx ); - int len = strlen_user ( cmd_u, 0 ); + int len = strlen ( cmd_u ); char cmd[len + 1]; copy_from_user ( cmd, cmd_u, 0, len + 1 ); DBG ( "COMBOOT: executing command '%s'\n", cmd ); @@ -371,7 +371,7 @@ static __asmcall __used void int22 ( struct i386_all_regs *ix86 ) { { int fd; userptr_t file_u = real_to_user ( ix86->segs.es, ix86->regs.si ); - int len = strlen_user ( file_u, 0 ); + int len = strlen ( file_u ); char file[len + 1]; copy_from_user ( file, file_u, 0, len + 1 ); @@ -484,7 +484,7 @@ static __asmcall __used void int22 ( struct i386_all_regs *ix86 ) { case 0x0010: /* Resolve hostname */ { userptr_t hostname_u = real_to_user ( ix86->segs.es, ix86->regs.bx ); - int len = strlen_user ( hostname_u, 0 ); + int len = strlen ( hostname_u ); char hostname[len]; struct in_addr addr; @@ -551,8 +551,8 @@ static __asmcall __used void int22 ( struct i386_all_regs *ix86 ) { { userptr_t file_u = real_to_user ( ix86->segs.ds, ix86->regs.si ); userptr_t cmd_u = real_to_user ( ix86->segs.es, ix86->regs.bx ); - int file_len = strlen_user ( file_u, 0 ); - int cmd_len = strlen_user ( cmd_u, 0 ); + int file_len = strlen ( file_u ); + int cmd_len = strlen ( cmd_u ); char file[file_len + 1]; char cmd[cmd_len + 1]; @@ -595,9 +595,9 @@ static __asmcall __used void int22 ( struct i386_all_regs *ix86 ) { shuffle ( ix86->segs.es, ix86->regs.di, ix86->regs.cx ); /* Copy initial register values to .text16 */ - memcpy_user ( real_to_user ( rm_cs, (unsigned) __from_text16 ( &comboot_initial_regs ) ), 0, - real_to_user ( ix86->segs.ds, ix86->regs.si ), 0, - sizeof(syslinux_rm_regs) ); + memcpy ( real_to_user ( rm_cs, (unsigned) __from_text16 ( &comboot_initial_regs ) ), + real_to_user ( ix86->segs.ds, ix86->regs.si ), + sizeof(syslinux_rm_regs) ); /* Load initial register values */ __asm__ __volatile__ ( diff --git a/src/arch/x86/transitions/librm_mgmt.c b/src/arch/x86/transitions/librm_mgmt.c index ec31fceb1..7ebf62137 100644 --- a/src/arch/x86/transitions/librm_mgmt.c +++ b/src/arch/x86/transitions/librm_mgmt.c @@ -69,7 +69,7 @@ uint16_t copy_user_to_rm_stack ( userptr_t data, size_t size ) { userptr_t rm_stack; rm_sp -= size; rm_stack = real_to_user ( rm_ss, rm_sp ); - memcpy_user ( rm_stack, 0, data, 0, size ); + memcpy ( rm_stack, data, size ); return rm_sp; }; @@ -83,7 +83,7 @@ uint16_t copy_user_to_rm_stack ( userptr_t data, size_t size ) { void remove_user_from_rm_stack ( userptr_t data, size_t size ) { if ( data ) { userptr_t rm_stack = real_to_user ( rm_ss, rm_sp ); - memcpy_user ( rm_stack, 0, data, 0, size ); + memcpy ( rm_stack, data, size ); } rm_sp += size; }; @@ -432,10 +432,6 @@ PROVIDE_UACCESS_INLINE ( librm, phys_to_user ); PROVIDE_UACCESS_INLINE ( librm, user_to_phys ); PROVIDE_UACCESS_INLINE ( librm, virt_to_user ); PROVIDE_UACCESS_INLINE ( librm, user_to_virt ); -PROVIDE_UACCESS_INLINE ( librm, memcpy_user ); -PROVIDE_UACCESS_INLINE ( librm, memmove_user ); -PROVIDE_UACCESS_INLINE ( librm, memset_user ); -PROVIDE_UACCESS_INLINE ( librm, strlen_user ); PROVIDE_UACCESS_INLINE ( librm, memchr_user ); PROVIDE_IOMAP_INLINE ( pages, io_to_bus ); PROVIDE_IOMAP ( pages, ioremap, ioremap_pages ); diff --git a/src/core/fbcon.c b/src/core/fbcon.c index ff3132ac7..8d05484e2 100644 --- a/src/core/fbcon.c +++ b/src/core/fbcon.c @@ -185,12 +185,12 @@ static void fbcon_draw ( struct fbcon *fbcon, struct fbcon_text_cell *cell, /* Draw background picture, if applicable */ if ( transparent ) { if ( fbcon->picture.start ) { - memcpy_user ( fbcon->start, offset, - fbcon->picture.start, offset, - fbcon->character.len ); + memcpy ( ( fbcon->start + offset ), + ( fbcon->picture.start + offset ), + fbcon->character.len ); } else { - memset_user ( fbcon->start, offset, 0, - fbcon->character.len ); + memset ( ( fbcon->start + offset ), 0, + fbcon->character.len ); } } @@ -247,8 +247,8 @@ static void fbcon_scroll ( struct fbcon *fbcon ) { /* Scroll up character array */ row_len = ( fbcon->character.width * sizeof ( struct fbcon_text_cell )); - memmove_user ( fbcon->text.start, 0, fbcon->text.start, row_len, - ( row_len * ( fbcon->character.height - 1 ) ) ); + memmove ( fbcon->text.start, ( fbcon->text.start + row_len ), + ( row_len * ( fbcon->character.height - 1 ) ) ); fbcon_clear ( fbcon, ( fbcon->character.height - 1 ) ); /* Update cursor position */ @@ -552,7 +552,7 @@ static int fbcon_picture_init ( struct fbcon *fbcon, ( ygap + pixbuf->height ) ); /* Convert to frame buffer raw format */ - memset_user ( picture->start, 0, 0, len ); + memset ( picture->start, 0, len ); for ( y = 0 ; y < height ; y++ ) { offset = ( indent + ( y * pixel->stride ) ); pixbuf_offset = ( pixbuf_indent + ( y * pixbuf_stride ) ); @@ -684,7 +684,7 @@ int fbcon_init ( struct fbcon *fbcon, userptr_t start, fbcon_clear ( fbcon, 0 ); /* Set framebuffer to all black (including margins) */ - memset_user ( fbcon->start, 0, 0, fbcon->len ); + memset ( fbcon->start, 0, fbcon->len ); /* Generate pixel buffer from background image, if applicable */ if ( config->pixbuf && @@ -692,10 +692,8 @@ int fbcon_init ( struct fbcon *fbcon, userptr_t start, goto err_picture; /* Draw background picture (including margins), if applicable */ - if ( fbcon->picture.start ) { - memcpy_user ( fbcon->start, 0, fbcon->picture.start, 0, - fbcon->len ); - } + if ( fbcon->picture.start ) + memcpy ( fbcon->start, fbcon->picture.start, fbcon->len ); /* Update console width and height */ console_set_size ( fbcon->character.width, fbcon->character.height ); diff --git a/src/core/image.c b/src/core/image.c index c69c05c93..709d0da9c 100644 --- a/src/core/image.c +++ b/src/core/image.c @@ -246,7 +246,7 @@ int image_set_data ( struct image *image, userptr_t data, size_t len ) { return rc; /* Copy in new image data */ - memcpy_user ( image->data, 0, data, 0, len ); + memcpy ( image->data, data, len ); return 0; } diff --git a/src/core/uaccess.c b/src/core/uaccess.c index ad17a58ab..01089e6fa 100644 --- a/src/core/uaccess.c +++ b/src/core/uaccess.c @@ -36,8 +36,4 @@ PROVIDE_UACCESS_INLINE ( flat, phys_to_user ); PROVIDE_UACCESS_INLINE ( flat, user_to_phys ); PROVIDE_UACCESS_INLINE ( flat, virt_to_user ); PROVIDE_UACCESS_INLINE ( flat, user_to_virt ); -PROVIDE_UACCESS_INLINE ( flat, memcpy_user ); -PROVIDE_UACCESS_INLINE ( flat, memmove_user ); -PROVIDE_UACCESS_INLINE ( flat, memset_user ); -PROVIDE_UACCESS_INLINE ( flat, strlen_user ); PROVIDE_UACCESS_INLINE ( flat, memchr_user ); diff --git a/src/crypto/deflate.c b/src/crypto/deflate.c index 7ad39ec1b..c6cce7516 100644 --- a/src/crypto/deflate.c +++ b/src/crypto/deflate.c @@ -464,8 +464,8 @@ static void deflate_copy ( struct deflate_chunk *out, if ( copy_len > len ) copy_len = len; while ( copy_len-- ) { - memcpy_user ( out->data, out_offset++, - start, offset++, 1 ); + memcpy ( ( out->data + out_offset++ ), + ( start + offset++ ), 1 ); } } out->offset += len; diff --git a/src/drivers/net/exanic.c b/src/drivers/net/exanic.c index aaa6a28a1..14a17df47 100644 --- a/src/drivers/net/exanic.c +++ b/src/drivers/net/exanic.c @@ -395,7 +395,7 @@ static int exanic_open ( struct net_device *netdev ) { } /* Reset receive region contents */ - memset_user ( port->rx, 0, 0xff, EXANIC_RX_LEN ); + memset ( port->rx, 0xff, EXANIC_RX_LEN ); /* Reset transmit feedback region */ *(port->txf) = 0; diff --git a/src/drivers/net/gve.c b/src/drivers/net/gve.c index 805feee3d..2cbc401f5 100644 --- a/src/drivers/net/gve.c +++ b/src/drivers/net/gve.c @@ -980,7 +980,7 @@ static int gve_start ( struct gve_nic *gve ) { } /* Invalidate receive completions */ - memset_user ( rx->cmplt, 0, 0, ( rx->count * rx->type->cmplt_len ) ); + memset ( rx->cmplt, 0, ( rx->count * rx->type->cmplt_len ) ); /* Reset receive sequence */ gve->seq = gve_next ( 0 ); diff --git a/src/drivers/usb/xhci.c b/src/drivers/usb/xhci.c index 3247ee69c..f244086ce 100644 --- a/src/drivers/usb/xhci.c +++ b/src/drivers/usb/xhci.c @@ -1000,7 +1000,7 @@ static int xhci_scratchpad_alloc ( struct xhci_device *xhci ) { rc = -ENOMEM; goto err_alloc; } - memset_user ( scratch->buffer, 0, 0, buffer_len ); + memset ( scratch->buffer, 0, buffer_len ); /* Allocate scratchpad array */ array_len = ( scratch->count * sizeof ( scratch->array[0] ) ); diff --git a/src/image/elf.c b/src/image/elf.c index 5c2f9db25..46c9fe8eb 100644 --- a/src/image/elf.c +++ b/src/image/elf.c @@ -66,7 +66,7 @@ static int elf_load_segment ( struct image *image, Elf_Phdr *phdr, } /* Copy image to segment */ - memcpy_user ( buffer, 0, image->data, phdr->p_offset, phdr->p_filesz ); + memcpy ( buffer, ( image->data + phdr->p_offset ), phdr->p_filesz ); return 0; } diff --git a/src/image/segment.c b/src/image/segment.c index 2d0f2f0fc..b7f8ef56c 100644 --- a/src/image/segment.c +++ b/src/image/segment.c @@ -83,7 +83,7 @@ int prep_segment ( userptr_t segment, size_t filesz, size_t memsz ) { if ( ( start >= memmap.regions[i].start ) && ( end <= memmap.regions[i].end ) ) { /* Found valid region: zero bss and return */ - memset_user ( segment, filesz, 0, ( memsz - filesz ) ); + memset ( ( segment + filesz ), 0, ( memsz - filesz ) ); return 0; } } diff --git a/src/include/ipxe/linux/linux_uaccess.h b/src/include/ipxe/linux/linux_uaccess.h index 790c75123..0c680c08f 100644 --- a/src/include/ipxe/linux/linux_uaccess.h +++ b/src/include/ipxe/linux/linux_uaccess.h @@ -69,38 +69,6 @@ UACCESS_INLINE ( linux, user_to_virt ) ( userptr_t userptr, off_t offset ) { return trivial_user_to_virt ( userptr, offset ); } -static inline __always_inline void -UACCESS_INLINE ( linux, memcpy_user ) ( userptr_t dest, off_t dest_off, - userptr_t src, off_t src_off, - size_t len ) { - trivial_memcpy_user ( dest, dest_off, src, src_off, len ); -} - -static inline __always_inline void -UACCESS_INLINE ( linux, memmove_user ) ( userptr_t dest, off_t dest_off, - userptr_t src, off_t src_off, - size_t len ) { - trivial_memmove_user ( dest, dest_off, src, src_off, len ); -} - -static inline __always_inline int -UACCESS_INLINE ( linux, memcmp_user ) ( userptr_t first, off_t first_off, - userptr_t second, off_t second_off, - size_t len ) { - return trivial_memcmp_user ( first, first_off, second, second_off, len); -} - -static inline __always_inline void -UACCESS_INLINE ( linux, memset_user ) ( userptr_t buffer, off_t offset, - int c, size_t len ) { - trivial_memset_user ( buffer, offset, c, len ); -} - -static inline __always_inline size_t -UACCESS_INLINE ( linux, strlen_user ) ( userptr_t buffer, off_t offset ) { - return trivial_strlen_user ( buffer, offset ); -} - static inline __always_inline off_t UACCESS_INLINE ( linux, memchr_user ) ( userptr_t buffer, off_t offset, int c, size_t len ) { diff --git a/src/include/ipxe/uaccess.h b/src/include/ipxe/uaccess.h index 93dc60d62..e84ca3eae 100644 --- a/src/include/ipxe/uaccess.h +++ b/src/include/ipxe/uaccess.h @@ -65,80 +65,6 @@ trivial_user_to_virt ( userptr_t userptr, off_t offset ) { return ( ( void * ) userptr + offset ); } -/** - * Copy data between user buffers - * - * @v dest Destination - * @v dest_off Destination offset - * @v src Source - * @v src_off Source offset - * @v len Length - */ -static inline __always_inline void -trivial_memcpy_user ( userptr_t dest, off_t dest_off, - userptr_t src, off_t src_off, size_t len ) { - memcpy ( ( ( void * ) dest + dest_off ), - ( ( void * ) src + src_off ), len ); -} - -/** - * Copy data between user buffers, allowing for overlap - * - * @v dest Destination - * @v dest_off Destination offset - * @v src Source - * @v src_off Source offset - * @v len Length - */ -static inline __always_inline void -trivial_memmove_user ( userptr_t dest, off_t dest_off, - userptr_t src, off_t src_off, size_t len ) { - memmove ( ( ( void * ) dest + dest_off ), - ( ( void * ) src + src_off ), len ); -} - -/** - * Compare data between user buffers - * - * @v first First buffer - * @v first_off First buffer offset - * @v second Second buffer - * @v second_off Second buffer offset - * @v len Length - * @ret diff Difference - */ -static inline __always_inline int -trivial_memcmp_user ( userptr_t first, off_t first_off, - userptr_t second, off_t second_off, size_t len ) { - return memcmp ( ( ( void * ) first + first_off ), - ( ( void * ) second + second_off ), len ); -} - -/** - * Fill user buffer with a constant byte - * - * @v buffer User buffer - * @v offset Offset within buffer - * @v c Constant byte with which to fill - * @v len Length - */ -static inline __always_inline void -trivial_memset_user ( userptr_t buffer, off_t offset, int c, size_t len ) { - memset ( ( ( void * ) buffer + offset ), c, len ); -} - -/** - * Find length of NUL-terminated string in user buffer - * - * @v buffer User buffer - * @v offset Offset within buffer - * @ret len Length of string (excluding NUL) - */ -static inline __always_inline size_t -trivial_strlen_user ( userptr_t buffer, off_t offset ) { - return strlen ( ( void * ) buffer + offset ); -} - /** * Find character in user buffer * @@ -207,38 +133,6 @@ UACCESS_INLINE ( flat, user_to_virt ) ( userptr_t userptr, off_t offset ) { return trivial_user_to_virt ( userptr, offset ); } -static inline __always_inline void -UACCESS_INLINE ( flat, memcpy_user ) ( userptr_t dest, off_t dest_off, - userptr_t src, off_t src_off, - size_t len ) { - trivial_memcpy_user ( dest, dest_off, src, src_off, len ); -} - -static inline __always_inline void -UACCESS_INLINE ( flat, memmove_user ) ( userptr_t dest, off_t dest_off, - userptr_t src, off_t src_off, - size_t len ) { - trivial_memmove_user ( dest, dest_off, src, src_off, len ); -} - -static inline __always_inline int -UACCESS_INLINE ( flat, memcmp_user ) ( userptr_t first, off_t first_off, - userptr_t second, off_t second_off, - size_t len ) { - return trivial_memcmp_user ( first, first_off, second, second_off, len); -} - -static inline __always_inline void -UACCESS_INLINE ( flat, memset_user ) ( userptr_t buffer, off_t offset, - int c, size_t len ) { - trivial_memset_user ( buffer, offset, c, len ); -} - -static inline __always_inline size_t -UACCESS_INLINE ( flat, strlen_user ) ( userptr_t buffer, off_t offset ) { - return trivial_strlen_user ( buffer, offset ); -} - static inline __always_inline off_t UACCESS_INLINE ( flat, memchr_user ) ( userptr_t buffer, off_t offset, int c, size_t len ) { @@ -310,18 +204,6 @@ static inline __always_inline void * phys_to_virt ( unsigned long phys_addr ) { return user_to_virt ( phys_to_user ( phys_addr ), 0 ); } -/** - * Copy data between user buffers - * - * @v dest Destination - * @v dest_off Destination offset - * @v src Source - * @v src_off Source offset - * @v len Length - */ -void memcpy_user ( userptr_t dest, off_t dest_off, - userptr_t src, off_t src_off, size_t len ); - /** * Copy data to user buffer * @@ -332,7 +214,7 @@ void memcpy_user ( userptr_t dest, off_t dest_off, */ static inline __always_inline void copy_to_user ( userptr_t dest, off_t dest_off, const void *src, size_t len ) { - memcpy_user ( dest, dest_off, virt_to_user ( src ), 0, len ); + memcpy ( ( dest + dest_off ), src, len ); } /** @@ -345,53 +227,9 @@ copy_to_user ( userptr_t dest, off_t dest_off, const void *src, size_t len ) { */ static inline __always_inline void copy_from_user ( void *dest, userptr_t src, off_t src_off, size_t len ) { - memcpy_user ( virt_to_user ( dest ), 0, src, src_off, len ); + memcpy ( dest, ( src + src_off ), len ); } -/** - * Copy data between user buffers, allowing for overlap - * - * @v dest Destination - * @v dest_off Destination offset - * @v src Source - * @v src_off Source offset - * @v len Length - */ -void memmove_user ( userptr_t dest, off_t dest_off, - userptr_t src, off_t src_off, size_t len ); - -/** - * Compare data between user buffers - * - * @v first First buffer - * @v first_off First buffer offset - * @v second Second buffer - * @v second_off Second buffer offset - * @v len Length - * @ret diff Difference - */ -int memcmp_user ( userptr_t first, off_t first_off, - userptr_t second, off_t second_off, size_t len ); - -/** - * Fill user buffer with a constant byte - * - * @v userptr User buffer - * @v offset Offset within buffer - * @v c Constant byte with which to fill - * @v len Length - */ -void memset_user ( userptr_t userptr, off_t offset, int c, size_t len ); - -/** - * Find length of NUL-terminated string in user buffer - * - * @v userptr User buffer - * @v offset Offset within buffer - * @ret len Length of string (excluding NUL) - */ -size_t strlen_user ( userptr_t userptr, off_t offset ); - /** * Find character in user buffer * diff --git a/src/interface/efi/efi_fbcon.c b/src/interface/efi/efi_fbcon.c index d388e0317..659ebd37e 100644 --- a/src/interface/efi/efi_fbcon.c +++ b/src/interface/efi/efi_fbcon.c @@ -124,7 +124,7 @@ static int efifb_draw ( unsigned int character, unsigned int index, /* Clear existing glyph */ offset = ( index * efifb.font.height ); - memset_user ( efifb.glyphs, offset, 0, efifb.font.height ); + memset ( ( efifb.glyphs + offset ), 0, efifb.font.height ); /* Get glyph */ blt = NULL; @@ -296,7 +296,7 @@ static int efifb_glyphs ( void ) { rc = -ENOMEM; goto err_alloc; } - memset_user ( efifb.glyphs, 0, 0, len ); + memset ( efifb.glyphs, 0, len ); /* Get font data */ for ( character = 0 ; character < EFIFB_ASCII ; character++ ) { diff --git a/src/interface/efi/efi_umalloc.c b/src/interface/efi/efi_umalloc.c index 175ae367e..488c53f3d 100644 --- a/src/interface/efi/efi_umalloc.c +++ b/src/interface/efi/efi_umalloc.c @@ -87,8 +87,8 @@ static userptr_t efi_urealloc ( userptr_t old_ptr, size_t new_size ) { if ( old_ptr && ( old_ptr != UNOWHERE ) ) { copy_from_user ( &old_size, old_ptr, -EFI_PAGE_SIZE, sizeof ( old_size ) ); - memcpy_user ( new_ptr, 0, old_ptr, 0, - ( (old_size < new_size) ? old_size : new_size )); + memcpy ( new_ptr, old_ptr, + ( (old_size < new_size) ? old_size : new_size ) ); old_pages = ( EFI_SIZE_TO_PAGES ( old_size ) + 1 ); phys_addr = user_to_phys ( old_ptr, -EFI_PAGE_SIZE ); if ( ( efirc = bs->FreePages ( phys_addr, old_pages ) ) != 0 ){ diff --git a/src/interface/linux/linux_uaccess.c b/src/interface/linux/linux_uaccess.c index 9fc99c5e2..d777bf3dd 100644 --- a/src/interface/linux/linux_uaccess.c +++ b/src/interface/linux/linux_uaccess.c @@ -30,8 +30,4 @@ FILE_LICENCE(GPL2_OR_LATER); PROVIDE_UACCESS_INLINE(linux, user_to_phys); PROVIDE_UACCESS_INLINE(linux, virt_to_user); PROVIDE_UACCESS_INLINE(linux, user_to_virt); -PROVIDE_UACCESS_INLINE(linux, memcpy_user); -PROVIDE_UACCESS_INLINE(linux, memmove_user); -PROVIDE_UACCESS_INLINE(linux, memset_user); -PROVIDE_UACCESS_INLINE(linux, strlen_user); PROVIDE_UACCESS_INLINE(linux, memchr_user); diff --git a/src/interface/smbios/smbios.c b/src/interface/smbios/smbios.c index fdd14499f..3e69a0c15 100644 --- a/src/interface/smbios/smbios.c +++ b/src/interface/smbios/smbios.c @@ -277,7 +277,7 @@ int read_smbios_string ( struct smbios_structure *structure, * smbios_strings struct is constructed so as to * always end on a string boundary. */ - string_len = strlen_user ( smbios.address, offset ); + string_len = strlen ( smbios.address + offset ); if ( --index == 0 ) { /* Copy string, truncating as necessary. */ if ( len > string_len ) diff --git a/src/tests/cms_test.c b/src/tests/cms_test.c index fc4f6bd19..debbfeee7 100644 --- a/src/tests/cms_test.c +++ b/src/tests/cms_test.c @@ -1773,8 +1773,8 @@ static void cms_decrypt_okx ( struct cms_test_image *img, /* Check decrypted image matches expected plaintext */ okx ( img->image.len == expected->image.len, file, line ); - okx ( memcmp_user ( img->image.data, 0, expected->image.data, 0, - expected->image.len ) == 0, file, line ); + okx ( memcmp ( img->image.data, expected->image.data, + expected->image.len ) == 0, file, line ); } #define cms_decrypt_ok( data, envelope, keypair, expected ) \ cms_decrypt_okx ( data, envelope, keypair, expected, \ diff --git a/src/tests/gzip_test.c b/src/tests/gzip_test.c index fa76edc53..9226b4c26 100644 --- a/src/tests/gzip_test.c +++ b/src/tests/gzip_test.c @@ -128,9 +128,8 @@ static void gzip_okx ( struct gzip_test *test, const char *file, /* Verify extracted image content */ okx ( extracted->len == test->expected_len, file, line ); - okx ( memcmp_user ( extracted->data, 0, - virt_to_user ( test->expected ), 0, - test->expected_len ) == 0, file, line ); + okx ( memcmp ( extracted->data, virt_to_user ( test->expected ), + test->expected_len ) == 0, file, line ); /* Verify extracted image name */ okx ( strcmp ( extracted->name, test->expected_name ) == 0, diff --git a/src/tests/pixbuf_test.c b/src/tests/pixbuf_test.c index aaa516bb2..1f82e0018 100644 --- a/src/tests/pixbuf_test.c +++ b/src/tests/pixbuf_test.c @@ -71,9 +71,8 @@ void pixbuf_okx ( struct pixel_buffer_test *test, const char *file, /* Check pixel buffer data */ okx ( pixbuf->len == test->len, file, line ); - okx ( memcmp_user ( pixbuf->data, 0, - virt_to_user ( test->data ), 0, - test->len ) == 0, file, line ); + okx ( memcmp ( pixbuf->data, virt_to_user ( test->data ), + test->len ) == 0, file, line ); pixbuf_put ( pixbuf ); } diff --git a/src/tests/zlib_test.c b/src/tests/zlib_test.c index df52d09ac..2efdcbad8 100644 --- a/src/tests/zlib_test.c +++ b/src/tests/zlib_test.c @@ -103,9 +103,8 @@ static void zlib_okx ( struct zlib_test *test, const char *file, /* Verify extracted image content */ okx ( extracted->len == test->expected_len, file, line ); - okx ( memcmp_user ( extracted->data, 0, - virt_to_user ( test->expected ), 0, - test->expected_len ) == 0, file, line ); + okx ( memcmp ( extracted->data, virt_to_user ( test->expected ), + test->expected_len ) == 0, file, line ); /* Verify extracted image name */ okx ( strcmp ( extracted->name, test->expected_name ) == 0, -- cgit v1.2.3-55-g7522 From 8c31270a21a85cc87bce0e07e19e2041d2510a4c Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 21 Apr 2025 16:16:01 +0100 Subject: [uaccess] Remove user_to_phys() and phys_to_user() Remove the intermediate concept of a user pointer from physical address conversions, leaving virt_to_phys() and phys_to_virt() as the directly implemented functions. Signed-off-by: Michael Brown --- src/arch/x86/core/runtime.c | 4 +-- src/arch/x86/core/vram_settings.c | 2 +- src/arch/x86/image/bzimage.c | 36 ++++++++++---------- src/arch/x86/image/com32.c | 2 +- src/arch/x86/image/initrd.c | 32 +++++++++--------- src/arch/x86/image/multiboot.c | 6 ++-- src/arch/x86/image/nbi.c | 4 +-- src/arch/x86/image/sdi.c | 9 ++--- src/arch/x86/image/ucode.c | 11 +++--- src/arch/x86/include/librm.h | 25 +++++++------- src/arch/x86/include/realmode.h | 2 +- src/arch/x86/interface/pcbios/bios_cachedhcp.c | 2 +- src/arch/x86/interface/pcbios/bios_smbios.c | 4 +-- src/arch/x86/interface/pcbios/int13.c | 6 ++-- src/arch/x86/interface/pcbios/memtop_umalloc.c | 30 ++++++++-------- src/arch/x86/interface/pcbios/rsdp.c | 8 ++--- src/arch/x86/interface/pcbios/vesafb.c | 2 +- src/arch/x86/interface/pxe/pxe_tftp.c | 2 +- src/arch/x86/interface/syslinux/com32_call.c | 10 +++--- src/arch/x86/interface/syslinux/comboot_call.c | 4 +-- src/arch/x86/transitions/librm_mgmt.c | 4 +-- src/core/acpi.c | 24 ++++++------- src/core/blocktrans.c | 2 +- src/core/cachedhcp.c | 2 +- src/core/fbcon.c | 4 +-- src/core/image.c | 4 +-- src/core/uaccess.c | 4 +-- src/drivers/block/srp.c | 4 +-- src/drivers/infiniband/arbel.c | 4 +-- src/drivers/infiniband/golan.c | 4 +-- src/drivers/infiniband/golan.h | 4 +-- src/drivers/infiniband/hermon.c | 4 +-- src/drivers/net/exanic.c | 6 ++-- src/drivers/net/gve.c | 27 +++++++-------- src/drivers/net/thunderx.c | 21 ++++++------ src/drivers/usb/xhci.c | 7 ++-- src/hci/commands/image_mem_cmd.c | 2 +- src/image/elf.c | 2 +- src/image/segment.c | 6 ++-- src/include/ipxe/linux/linux_uaccess.h | 34 +++++++++---------- src/include/ipxe/uaccess.h | 47 +++++++------------------- src/interface/efi/efi_acpi.c | 2 +- src/interface/efi/efi_fbcon.c | 2 +- src/interface/efi/efi_smbios.c | 8 ++--- src/interface/efi/efi_umalloc.c | 4 +-- src/interface/hyperv/vmbus.c | 2 +- src/interface/linux/linux_uaccess.c | 3 +- src/interface/smbios/smbios.c | 8 ++--- 48 files changed, 211 insertions(+), 235 deletions(-) (limited to 'src/drivers') diff --git a/src/arch/x86/core/runtime.c b/src/arch/x86/core/runtime.c index 2b803f772..2d2a10674 100644 --- a/src/arch/x86/core/runtime.c +++ b/src/arch/x86/core/runtime.c @@ -124,7 +124,7 @@ static int cmdline_init ( void ) { DBGC ( colour, "RUNTIME found no command line\n" ); return 0; } - cmdline_user = phys_to_user ( cmdline_phys ); + cmdline_user = phys_to_virt ( cmdline_phys ); len = ( strlen ( cmdline_user ) + 1 /* NUL */ ); /* Allocate and copy command line */ @@ -193,7 +193,7 @@ static int initrd_init ( void ) { initrd_phys, ( initrd_phys + initrd_len ) ); /* Create initrd image */ - image = image_memory ( "", phys_to_user ( initrd_phys ), + image = image_memory ( "", phys_to_virt ( initrd_phys ), initrd_len ); if ( ! image ) { DBGC ( colour, "RUNTIME could not create initrd image\n" ); diff --git a/src/arch/x86/core/vram_settings.c b/src/arch/x86/core/vram_settings.c index 9c169b40c..ceeada467 100644 --- a/src/arch/x86/core/vram_settings.c +++ b/src/arch/x86/core/vram_settings.c @@ -47,7 +47,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * @ret len Length of setting data, or negative error */ static int vram_fetch ( void *data, size_t len ) { - userptr_t vram = phys_to_user ( VRAM_BASE ); + userptr_t vram = phys_to_virt ( VRAM_BASE ); /* Copy video RAM */ if ( len > VRAM_LEN ) diff --git a/src/arch/x86/image/bzimage.c b/src/arch/x86/image/bzimage.c index 32598525f..0f373c1c8 100644 --- a/src/arch/x86/image/bzimage.c +++ b/src/arch/x86/image/bzimage.c @@ -169,7 +169,7 @@ static int bzimage_parse_header ( struct image *image, bzimg->rm_memsz += BZI_CMDLINE_SIZE; /* Calculate load address of protected-mode portion */ - bzimg->pm_kernel = phys_to_user ( is_bzimage ? BZI_LOAD_HIGH_ADDR + bzimg->pm_kernel = phys_to_virt ( is_bzimage ? BZI_LOAD_HIGH_ADDR : BZI_LOAD_LOW_ADDR ); /* Extract video mode */ @@ -185,8 +185,8 @@ static int bzimage_parse_header ( struct image *image, DBGC ( image, "bzImage %p version %04x RM %#lx+%#zx PM %#lx+%#zx " "cmdlen %zd\n", image, bzimg->version, - user_to_phys ( bzimg->rm_kernel, 0 ), bzimg->rm_filesz, - user_to_phys ( bzimg->pm_kernel, 0 ), bzimg->pm_sz, + virt_to_phys ( bzimg->rm_kernel ), bzimg->rm_filesz, + virt_to_phys ( bzimg->pm_kernel ), bzimg->pm_sz, bzimg->cmdline_size ); return 0; @@ -215,8 +215,8 @@ static void bzimage_update_header ( struct image *image, /* Set command line */ if ( bzimg->version >= 0x0202 ) { - bzimg->bzhdr.cmd_line_ptr = user_to_phys ( bzimg->rm_kernel, - bzimg->rm_cmdline ); + bzimg->bzhdr.cmd_line_ptr = ( virt_to_phys ( bzimg->rm_kernel ) + + bzimg->rm_cmdline ); } else { bzimg->cmdline_magic.magic = BZI_CMDLINE_MAGIC; bzimg->cmdline_magic.offset = bzimg->rm_cmdline; @@ -383,11 +383,11 @@ static size_t bzimage_load_initrd ( struct image *image, } assert ( offset == len ); DBGC ( image, "bzImage %p initrd %p [%#08lx,%#08lx,%#08lx)" - "%s%s\n", image, initrd, user_to_phys ( address, 0 ), - user_to_phys ( address, offset ), - user_to_phys ( address, ( offset + initrd->len ) ), + "%s%s\n", image, initrd, virt_to_phys ( address ), + ( virt_to_phys ( address ) + offset ), + ( virt_to_phys ( address ) + offset + initrd->len ), ( filename ? " " : "" ), ( filename ? filename : "" ) ); - DBGC2_MD5A ( image, user_to_phys ( address, offset ), + DBGC2_MD5A ( image, ( virt_to_phys ( address ) + offset ), ( address + offset ), initrd->len ); } len += initrd->len; @@ -422,11 +422,11 @@ static int bzimage_check_initrds ( struct image *image, len = bzimage_align ( len ); DBGC ( image, "bzImage %p initrd %p from [%#08lx,%#08lx)%s%s\n", - image, initrd, user_to_phys ( initrd->data, 0 ), - user_to_phys ( initrd->data, initrd->len ), + image, initrd, virt_to_phys ( initrd->data ), + ( virt_to_phys ( initrd->data ) + initrd->len ), ( initrd->cmdline ? " " : "" ), ( initrd->cmdline ? initrd->cmdline : "" ) ); - DBGC2_MD5A ( image, user_to_phys ( initrd->data, 0 ), + DBGC2_MD5A ( image, virt_to_phys ( initrd->data ), initrd->data, initrd->len ); } @@ -445,7 +445,7 @@ static int bzimage_check_initrds ( struct image *image, } /* Check that total length fits within kernel's memory limit */ - if ( user_to_phys ( bottom, len ) > bzimg->mem_limit ) { + if ( ( virt_to_phys ( bottom ) + len ) > bzimg->mem_limit ) { DBGC ( image, "bzImage %p not enough space for initrds\n", image ); return -ENOBUFS; @@ -485,12 +485,12 @@ static void bzimage_load_initrds ( struct image *image, /* Find highest usable address */ top = ( highest->data + bzimage_align ( highest->len ) ); - if ( user_to_phys ( top, -1 ) > bzimg->mem_limit ) { - top = phys_to_user ( ( bzimg->mem_limit + 1 ) & + if ( ( virt_to_phys ( top ) - 1UL ) > bzimg->mem_limit ) { + top = phys_to_virt ( ( bzimg->mem_limit + 1 ) & ~( INITRD_ALIGN - 1 ) ); } DBGC ( image, "bzImage %p loading initrds from %#08lx downwards\n", - image, user_to_phys ( top, -1 ) ); + image, ( virt_to_phys ( top ) - 1UL ) ); /* Load initrds in order */ for_each_image ( initrd ) { @@ -512,8 +512,8 @@ static void bzimage_load_initrds ( struct image *image, /* Record initrd location */ if ( ! bzimg->ramdisk_image ) - bzimg->ramdisk_image = user_to_phys ( dest, 0 ); - bzimg->ramdisk_size = ( user_to_phys ( dest, len ) - + bzimg->ramdisk_image = virt_to_phys ( dest ); + bzimg->ramdisk_size = ( virt_to_phys ( dest ) + len - bzimg->ramdisk_image ); } DBGC ( image, "bzImage %p initrds at [%#08lx,%#08lx)\n", diff --git a/src/arch/x86/image/com32.c b/src/arch/x86/image/com32.c index 3e38215cb..a2b60987d 100644 --- a/src/arch/x86/image/com32.c +++ b/src/arch/x86/image/com32.c @@ -211,7 +211,7 @@ static int com32_load_image ( struct image *image ) { filesz = image->len; memsz = filesz; - buffer = phys_to_user ( COM32_START_PHYS ); + buffer = phys_to_virt ( COM32_START_PHYS ); if ( ( rc = prep_segment ( buffer, filesz, memsz ) ) != 0 ) { DBGC ( image, "COM32 %p: could not prepare segment: %s\n", image, strerror ( rc ) ); diff --git a/src/arch/x86/image/initrd.c b/src/arch/x86/image/initrd.c index bcf95deef..fff40dd14 100644 --- a/src/arch/x86/image/initrd.c +++ b/src/arch/x86/image/initrd.c @@ -76,10 +76,10 @@ static userptr_t initrd_squash_high ( userptr_t top ) { current -= len; DBGC ( &images, "INITRD squashing %s [%#08lx,%#08lx)->" "[%#08lx,%#08lx)\n", highest->name, - user_to_phys ( highest->data, 0 ), - user_to_phys ( highest->data, highest->len ), - user_to_phys ( current, 0 ), - user_to_phys ( current, highest->len ) ); + virt_to_phys ( highest->data ), + ( virt_to_phys ( highest->data ) + highest->len ), + virt_to_phys ( current ), + ( virt_to_phys ( current ) + highest->len ) ); memmove ( current, highest->data, highest->len ); highest->data = current; } @@ -92,10 +92,10 @@ static userptr_t initrd_squash_high ( userptr_t top ) { current -= len; DBGC ( &images, "INITRD copying %s [%#08lx,%#08lx)->" "[%#08lx,%#08lx)\n", initrd->name, - user_to_phys ( initrd->data, 0 ), - user_to_phys ( initrd->data, initrd->len ), - user_to_phys ( current, 0 ), - user_to_phys ( current, initrd->len ) ); + virt_to_phys ( initrd->data ), + ( virt_to_phys ( initrd->data ) + initrd->len ), + virt_to_phys ( current ), + ( virt_to_phys ( current ) + initrd->len ) ); memcpy ( current, initrd->data, initrd->len ); initrd->data = current; } @@ -119,10 +119,10 @@ static void initrd_swap ( struct image *low, struct image *high, size_t new_len; DBGC ( &images, "INITRD swapping %s [%#08lx,%#08lx)<->[%#08lx,%#08lx) " - "%s\n", low->name, user_to_phys ( low->data, 0 ), - user_to_phys ( low->data, low->len ), - user_to_phys ( high->data, 0 ), - user_to_phys ( high->data, high->len ), high->name ); + "%s\n", low->name, virt_to_phys ( low->data ), + ( virt_to_phys ( low->data ) + low->len ), + virt_to_phys ( high->data ), + ( virt_to_phys ( high->data ) + high->len ), high->name ); /* Round down length of free space */ free_len &= ~( INITRD_ALIGN - 1 ); @@ -208,9 +208,9 @@ static void initrd_dump ( void ) { /* Dump initrd locations */ for_each_image ( initrd ) { DBGC ( &images, "INITRD %s at [%#08lx,%#08lx)\n", - initrd->name, user_to_phys ( initrd->data, 0 ), - user_to_phys ( initrd->data, initrd->len ) ); - DBGC2_MD5A ( &images, user_to_phys ( initrd->data, 0 ), + initrd->name, virt_to_phys ( initrd->data ), + ( virt_to_phys ( initrd->data ) + initrd->len ) ); + DBGC2_MD5A ( &images, virt_to_phys ( initrd->data ), initrd->data, initrd->len ); } } @@ -239,7 +239,7 @@ void initrd_reshuffle ( userptr_t bottom ) { /* Debug */ DBGC ( &images, "INITRD region [%#08lx,%#08lx)\n", - user_to_phys ( bottom, 0 ), user_to_phys ( top, 0 ) ); + virt_to_phys ( bottom ), virt_to_phys ( top ) ); initrd_dump(); /* Squash initrds as high as possible in memory */ diff --git a/src/arch/x86/image/multiboot.c b/src/arch/x86/image/multiboot.c index fe21f1f1a..24f67e02f 100644 --- a/src/arch/x86/image/multiboot.c +++ b/src/arch/x86/image/multiboot.c @@ -212,7 +212,7 @@ static int multiboot_add_modules ( struct image *image, physaddr_t start, start = ( ( start + 0xfff ) & ~0xfff ); /* Prepare segment */ - if ( ( rc = prep_segment ( phys_to_user ( start ), + if ( ( rc = prep_segment ( phys_to_virt ( start ), module_image->len, module_image->len ) ) != 0 ) { DBGC ( image, "MULTIBOOT %p could not prepare module " @@ -222,7 +222,7 @@ static int multiboot_add_modules ( struct image *image, physaddr_t start, } /* Copy module */ - memcpy ( phys_to_user ( start ), module_image->data, + memcpy ( phys_to_virt ( start ), module_image->data, module_image->len ); /* Add module to list */ @@ -342,7 +342,7 @@ static int multiboot_load_raw ( struct image *image, ( image->len - offset ) ); memsz = ( hdr->mb.bss_end_addr ? ( hdr->mb.bss_end_addr - hdr->mb.load_addr ) : filesz ); - buffer = phys_to_user ( hdr->mb.load_addr ); + buffer = phys_to_virt ( hdr->mb.load_addr ); if ( ( rc = prep_segment ( buffer, filesz, memsz ) ) != 0 ) { DBGC ( image, "MULTIBOOT %p could not prepare segment: %s\n", image, strerror ( rc ) ); diff --git a/src/arch/x86/image/nbi.c b/src/arch/x86/image/nbi.c index 0b02a8985..1f72c1287 100644 --- a/src/arch/x86/image/nbi.c +++ b/src/arch/x86/image/nbi.c @@ -181,7 +181,7 @@ static int nbi_process_segments ( struct image *image, /* Calculate segment load address */ switch ( NBI_LOADADDR_FLAGS ( sh.flags ) ) { case NBI_LOADADDR_ABS: - dest = phys_to_user ( sh.loadaddr ); + dest = phys_to_virt ( sh.loadaddr ); break; case NBI_LOADADDR_AFTER: dest = ( dest + memsz + sh.loadaddr ); @@ -194,7 +194,7 @@ static int nbi_process_segments ( struct image *image, * maintains backwards compatibility with * previous versions of Etherboot. */ - dest = phys_to_user ( ( extmemsize() + 1024 ) * 1024 + dest = phys_to_virt ( ( extmemsize() + 1024 ) * 1024 - sh.loadaddr ); break; default: diff --git a/src/arch/x86/image/sdi.c b/src/arch/x86/image/sdi.c index 5bb5a7569..5e22daeb3 100644 --- a/src/arch/x86/image/sdi.c +++ b/src/arch/x86/image/sdi.c @@ -92,16 +92,17 @@ static int sdi_exec ( struct image *image ) { return -ENOTTY; } DBGC ( image, "SDI %p image at %08lx+%08zx\n", - image, user_to_phys ( image->data, 0 ), image->len ); - DBGC ( image, "SDI %p boot code at %08lx+%llx\n", image, - user_to_phys ( image->data, sdi.boot_offset ), sdi.boot_size ); + image, virt_to_phys ( image->data ), image->len ); + DBGC ( image, "SDI %p boot code at %08llx+%llx\n", image, + ( virt_to_phys ( image->data ) + sdi.boot_offset ), + sdi.boot_size ); /* Copy boot code */ memcpy ( real_to_user ( SDI_BOOT_SEG, SDI_BOOT_OFF ), ( image->data + sdi.boot_offset ), sdi.boot_size ); /* Jump to boot code */ - sdiptr = ( user_to_phys ( image->data, 0 ) | SDI_WTF ); + sdiptr = ( virt_to_phys ( image->data ) | SDI_WTF ); __asm__ __volatile__ ( REAL_CODE ( "ljmp %0, %1\n\t" ) : : "i" ( SDI_BOOT_SEG ), "i" ( SDI_BOOT_OFF ), diff --git a/src/arch/x86/image/ucode.c b/src/arch/x86/image/ucode.c index 9b6b5067a..a9fa8b8c4 100644 --- a/src/arch/x86/image/ucode.c +++ b/src/arch/x86/image/ucode.c @@ -165,7 +165,7 @@ static int ucode_status ( struct ucode_update *update, assert ( id <= control->apic_max ); /* Read status report */ - copy_from_user ( &status, phys_to_user ( control->status ), + copy_from_user ( &status, phys_to_virt ( control->status ), ( id * sizeof ( status ) ), sizeof ( status ) ); /* Ignore empty optional status reports */ @@ -261,7 +261,7 @@ static int ucode_update_all ( struct image *image, /* Construct control structure */ memset ( &control, 0, sizeof ( control ) ); control.desc = virt_to_phys ( update->desc ); - control.status = user_to_phys ( status, 0 ); + control.status = virt_to_phys ( status ); vendor = update->vendor; if ( vendor ) { control.ver_clear = vendor->ver_clear; @@ -446,8 +446,8 @@ static int ucode_parse_intel ( struct image *image, size_t start, /* Populate descriptor */ desc.signature = hdr.signature; desc.version = hdr.version; - desc.address = user_to_phys ( image->data, - ( start + sizeof ( hdr ) ) ); + desc.address = ( virt_to_phys ( image->data ) + + start + sizeof ( hdr ) ); /* Add non-extended descriptor, if applicable */ ucode_describe ( image, start, &ucode_intel, &desc, hdr.platforms, @@ -589,7 +589,8 @@ static int ucode_parse_amd ( struct image *image, size_t start, copy_from_user ( &patch, image->data, ( start + offset ), sizeof ( patch ) ); desc.version = patch.version; - desc.address = user_to_phys ( image->data, ( start + offset ) ); + desc.address = ( virt_to_phys ( image->data ) + + start + offset ); offset += phdr.len; /* Parse equivalence table to find matching signatures */ diff --git a/src/arch/x86/include/librm.h b/src/arch/x86/include/librm.h index 9ed91022e..7755abdcf 100644 --- a/src/arch/x86/include/librm.h +++ b/src/arch/x86/include/librm.h @@ -85,33 +85,32 @@ extern const unsigned long virt_offset; /** * Convert physical address to user pointer * - * @v phys_addr Physical address - * @ret userptr User pointer + * @v phys Physical address + * @ret virt Virtual address */ -static inline __always_inline userptr_t -UACCESS_INLINE ( librm, phys_to_user ) ( unsigned long phys_addr ) { +static inline __always_inline void * +UACCESS_INLINE ( librm, phys_to_virt ) ( unsigned long phys ) { /* In a 64-bit build, any valid physical address is directly * usable as a virtual address, since the low 4GB is * identity-mapped. */ if ( sizeof ( physaddr_t ) > sizeof ( uint32_t ) ) - return ( ( userptr_t ) phys_addr ); + return ( ( void * ) phys ); /* In a 32-bit build, subtract virt_offset */ - return ( ( userptr_t ) ( phys_addr - virt_offset ) ); + return ( ( void * ) ( phys - virt_offset ) ); } /** - * Convert user buffer to physical address + * Convert virtual address to physical address * - * @v userptr User pointer - * @v offset Offset from user pointer - * @ret phys_addr Physical address + * @v virt Virtual address + * @ret phys Physical address */ -static inline __always_inline unsigned long -UACCESS_INLINE ( librm, user_to_phys ) ( userptr_t userptr, off_t offset ) { - unsigned long addr = ( ( unsigned long ) ( userptr + offset ) ); +static inline __always_inline physaddr_t +UACCESS_INLINE ( librm, virt_to_phys ) ( volatile const void *virt ) { + physaddr_t addr = ( ( physaddr_t ) virt ); /* In a 64-bit build, any virtual address in the low 4GB is * directly usable as a physical address, since the low 4GB is diff --git a/src/arch/x86/include/realmode.h b/src/arch/x86/include/realmode.h index 4defd3b97..616db5eb9 100644 --- a/src/arch/x86/include/realmode.h +++ b/src/arch/x86/include/realmode.h @@ -73,7 +73,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ static inline __always_inline userptr_t real_to_user ( unsigned int segment, unsigned int offset ) { - return ( phys_to_user ( ( segment << 4 ) + offset ) ); + return ( phys_to_virt ( ( segment << 4 ) + offset ) ); } /** diff --git a/src/arch/x86/interface/pcbios/bios_cachedhcp.c b/src/arch/x86/interface/pcbios/bios_cachedhcp.c index bea803d6e..05d89b3b7 100644 --- a/src/arch/x86/interface/pcbios/bios_cachedhcp.c +++ b/src/arch/x86/interface/pcbios/bios_cachedhcp.c @@ -60,7 +60,7 @@ static void cachedhcp_init ( void ) { /* Record cached DHCPACK */ if ( ( rc = cachedhcp_record ( &cached_dhcpack, 0, - phys_to_user ( cached_dhcpack_phys ), + phys_to_virt ( cached_dhcpack_phys ), sizeof ( BOOTPLAYER_t ) ) ) != 0 ) { DBGC ( colour, "CACHEDHCP could not record DHCPACK: %s\n", strerror ( rc ) ); diff --git a/src/arch/x86/interface/pcbios/bios_smbios.c b/src/arch/x86/interface/pcbios/bios_smbios.c index 366679d36..ab53d424b 100644 --- a/src/arch/x86/interface/pcbios/bios_smbios.c +++ b/src/arch/x86/interface/pcbios/bios_smbios.c @@ -54,7 +54,7 @@ static int bios_find_smbios2 ( struct smbios *smbios ) { return rc; /* Fill in entry point descriptor structure */ - smbios->address = phys_to_user ( entry.smbios_address ); + smbios->address = phys_to_virt ( entry.smbios_address ); smbios->len = entry.smbios_len; smbios->count = entry.smbios_count; smbios->version = SMBIOS_VERSION ( entry.major, entry.minor ); @@ -85,7 +85,7 @@ static int bios_find_smbios3 ( struct smbios *smbios ) { } /* Fill in entry point descriptor structure */ - smbios->address = phys_to_user ( entry.smbios_address ); + smbios->address = phys_to_virt ( entry.smbios_address ); smbios->len = entry.smbios_len; smbios->count = 0; smbios->version = SMBIOS_VERSION ( entry.major, entry.minor ); diff --git a/src/arch/x86/interface/pcbios/int13.c b/src/arch/x86/interface/pcbios/int13.c index 372d40ba3..d60f7c7cc 100644 --- a/src/arch/x86/interface/pcbios/int13.c +++ b/src/arch/x86/interface/pcbios/int13.c @@ -743,7 +743,7 @@ static int int13_extended_rw ( struct san_device *sandev, if ( ( addr.count == 0xff ) || ( ( addr.buffer.segment == 0xffff ) && ( addr.buffer.offset == 0xffff ) ) ) { - buffer = phys_to_user ( addr.buffer_phys ); + buffer = phys_to_virt ( addr.buffer_phys ); DBGC2 ( sandev->drive, "%08llx", ( ( unsigned long long ) addr.buffer_phys ) ); } else { @@ -1058,7 +1058,7 @@ static int int13_cdrom_read_boot_catalog ( struct san_device *sandev, /* Read from boot catalog */ if ( ( rc = sandev_read ( sandev, start, command.count, - phys_to_user ( command.buffer ) ) ) != 0 ) { + phys_to_virt ( command.buffer ) ) ) != 0 ) { DBGC ( sandev->drive, "INT13 drive %02x could not read boot " "catalog: %s\n", sandev->drive, strerror ( rc ) ); return -INT13_STATUS_READ_ERROR; @@ -1455,7 +1455,7 @@ static int int13_load_eltorito ( unsigned int drive, struct segoff *address ) { "catalog (status %04x)\n", drive, status ); return -EIO; } - copy_from_user ( &catalog, phys_to_user ( eltorito_cmd.buffer ), 0, + copy_from_user ( &catalog, phys_to_virt ( eltorito_cmd.buffer ), 0, sizeof ( catalog ) ); /* Sanity checks */ diff --git a/src/arch/x86/interface/pcbios/memtop_umalloc.c b/src/arch/x86/interface/pcbios/memtop_umalloc.c index 8239b23b8..b87d22516 100644 --- a/src/arch/x86/interface/pcbios/memtop_umalloc.c +++ b/src/arch/x86/interface/pcbios/memtop_umalloc.c @@ -106,7 +106,7 @@ size_t largest_memblock ( userptr_t *start ) { /* Use largest block */ if ( region_len > len ) { DBG ( "...new best block found\n" ); - *start = phys_to_user ( region_start ); + *start = phys_to_virt ( region_start ); len = region_len; } } @@ -124,7 +124,7 @@ static void init_eheap ( void ) { heap_size = largest_memblock ( &base ); bottom = top = ( base + heap_size ); DBG ( "External heap grows downwards from %lx (size %zx)\n", - user_to_phys ( top, 0 ), heap_size ); + virt_to_phys ( top ), heap_size ); } /** @@ -141,8 +141,8 @@ static void ecollect_free ( void ) { sizeof ( extmem ) ); if ( extmem.used ) break; - DBG ( "EXTMEM freeing [%lx,%lx)\n", user_to_phys ( bottom, 0 ), - user_to_phys ( bottom, extmem.size ) ); + DBG ( "EXTMEM freeing [%lx,%lx)\n", virt_to_phys ( bottom ), + ( virt_to_phys ( bottom ) + extmem.size ) ); len = ( extmem.size + sizeof ( extmem ) ); bottom += len; heap_size += len; @@ -182,7 +182,7 @@ static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) { ptr = bottom = ( bottom - sizeof ( extmem ) ); heap_size -= sizeof ( extmem ); DBG ( "EXTMEM allocating [%lx,%lx)\n", - user_to_phys ( ptr, 0 ), user_to_phys ( ptr, 0 ) ); + virt_to_phys ( ptr ), virt_to_phys ( ptr ) ); extmem.size = 0; } extmem.used = ( new_size > 0 ); @@ -191,7 +191,7 @@ static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) { if ( ptr == bottom ) { /* Update block */ new = ( ptr - ( new_size - extmem.size ) ); - align = ( user_to_phys ( new, 0 ) & ( EM_ALIGN - 1 ) ); + align = ( virt_to_phys ( new ) & ( EM_ALIGN - 1 ) ); new_size += align; new -= align; if ( new_size > ( heap_size + extmem.size ) ) { @@ -199,10 +199,10 @@ static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) { return UNULL; } DBG ( "EXTMEM expanding [%lx,%lx) to [%lx,%lx)\n", - user_to_phys ( ptr, 0 ), - user_to_phys ( ptr, extmem.size ), - user_to_phys ( new, 0 ), - user_to_phys ( new, new_size )); + virt_to_phys ( ptr ), + ( virt_to_phys ( ptr ) + extmem.size ), + virt_to_phys ( new ), + ( virt_to_phys ( new ) + new_size ) ); memmove ( new, ptr, ( ( extmem.size < new_size ) ? extmem.size : new_size ) ); bottom = new; @@ -213,8 +213,8 @@ static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) { if ( new_size > extmem.size ) { /* Refuse to expand */ DBG ( "EXTMEM cannot expand [%lx,%lx)\n", - user_to_phys ( ptr, 0 ), - user_to_phys ( ptr, extmem.size ) ); + virt_to_phys ( ptr ), + ( virt_to_phys ( ptr ) + extmem.size ) ); return UNULL; } } @@ -225,9 +225,9 @@ static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) { /* Collect any free blocks and update hidden memory region */ ecollect_free(); - hide_umalloc ( user_to_phys ( bottom, ( ( bottom == top ) ? - 0 : -sizeof ( extmem ) ) ), - user_to_phys ( top, 0 ) ); + hide_umalloc ( ( virt_to_phys ( bottom ) - + ( ( bottom == top ) ? 0 : sizeof ( extmem ) ) ), + virt_to_phys ( top ) ); return ( new_size ? new : UNOWHERE ); } diff --git a/src/arch/x86/interface/pcbios/rsdp.c b/src/arch/x86/interface/pcbios/rsdp.c index 3c67b7525..02c58c780 100644 --- a/src/arch/x86/interface/pcbios/rsdp.c +++ b/src/arch/x86/interface/pcbios/rsdp.c @@ -78,10 +78,10 @@ static userptr_t rsdp_find_rsdt_range ( userptr_t start, size_t len ) { continue; /* Extract RSDT */ - rsdt = phys_to_user ( le32_to_cpu ( rsdp.rsdt ) ); + rsdt = phys_to_virt ( le32_to_cpu ( rsdp.rsdt ) ); DBGC ( rsdt, "RSDT %#08lx found via RSDP %#08lx\n", - user_to_phys ( rsdt, 0 ), - user_to_phys ( start, offset ) ); + virt_to_phys ( rsdt ), + ( virt_to_phys ( start ) + offset ) ); return rsdt; } @@ -114,7 +114,7 @@ static userptr_t rsdp_find_rsdt ( void ) { } /* Search fixed BIOS area */ - rsdt = rsdp_find_rsdt_range ( phys_to_user ( RSDP_BIOS_START ), + rsdt = rsdp_find_rsdt_range ( phys_to_virt ( RSDP_BIOS_START ), RSDP_BIOS_LEN ); if ( rsdt ) return rsdt; diff --git a/src/arch/x86/interface/pcbios/vesafb.c b/src/arch/x86/interface/pcbios/vesafb.c index 86edbda42..61609fa8c 100644 --- a/src/arch/x86/interface/pcbios/vesafb.c +++ b/src/arch/x86/interface/pcbios/vesafb.c @@ -473,7 +473,7 @@ static int vesafb_init ( struct console_configuration *config ) { vesafb_font(); /* Initialise frame buffer console */ - if ( ( rc = fbcon_init ( &vesafb.fbcon, phys_to_user ( vesafb.start ), + if ( ( rc = fbcon_init ( &vesafb.fbcon, phys_to_virt ( vesafb.start ), &vesafb.pixel, &vesafb.map, &vesafb.font, config ) ) != 0 ) goto err_fbcon_init; diff --git a/src/arch/x86/interface/pxe/pxe_tftp.c b/src/arch/x86/interface/pxe/pxe_tftp.c index 3b4c6d847..2c2eccca4 100644 --- a/src/arch/x86/interface/pxe/pxe_tftp.c +++ b/src/arch/x86/interface/pxe/pxe_tftp.c @@ -492,7 +492,7 @@ PXENV_EXIT_t pxenv_tftp_read_file ( struct s_PXENV_TFTP_READ_FILE } /* Read entire file */ - pxe_tftp.buffer = phys_to_user ( tftp_read_file->Buffer ); + pxe_tftp.buffer = phys_to_virt ( tftp_read_file->Buffer ); pxe_tftp.size = tftp_read_file->BufferSize; while ( ( rc = pxe_tftp.rc ) == -EINPROGRESS ) step(); diff --git a/src/arch/x86/interface/syslinux/com32_call.c b/src/arch/x86/interface/syslinux/com32_call.c index da9d6491a..47be69f9f 100644 --- a/src/arch/x86/interface/syslinux/com32_call.c +++ b/src/arch/x86/interface/syslinux/com32_call.c @@ -49,7 +49,7 @@ void __asmcall com32_intcall ( uint8_t interrupt, physaddr_t inregs_phys, physad DBGC ( &com32_regs, "COM32 INT%x in %#08lx out %#08lx\n", interrupt, inregs_phys, outregs_phys ); - memcpy ( virt_to_user( &com32_regs ), phys_to_user ( inregs_phys ), + memcpy ( virt_to_user( &com32_regs ), phys_to_virt ( inregs_phys ), sizeof ( com32sys_t ) ); com32_int_vector = interrupt; @@ -107,7 +107,7 @@ void __asmcall com32_intcall ( uint8_t interrupt, physaddr_t inregs_phys, physad : : ); if ( outregs_phys ) { - memcpy ( phys_to_user ( outregs_phys ), + memcpy ( phys_to_virt ( outregs_phys ), virt_to_user ( &com32_regs ), sizeof ( com32sys_t ) ); } } @@ -120,7 +120,7 @@ void __asmcall com32_farcall ( uint32_t proc, physaddr_t inregs_phys, physaddr_t DBGC ( &com32_regs, "COM32 farcall %04x:%04x in %#08lx out %#08lx\n", ( proc >> 16 ), ( proc & 0xffff ), inregs_phys, outregs_phys ); - memcpy ( virt_to_user( &com32_regs ), phys_to_user ( inregs_phys ), + memcpy ( virt_to_user( &com32_regs ), phys_to_virt ( inregs_phys ), sizeof ( com32sys_t ) ); com32_farcall_proc = proc; @@ -167,7 +167,7 @@ void __asmcall com32_farcall ( uint32_t proc, physaddr_t inregs_phys, physaddr_t : : ); if ( outregs_phys ) { - memcpy ( phys_to_user ( outregs_phys ), + memcpy ( phys_to_virt ( outregs_phys ), virt_to_user ( &com32_regs ), sizeof ( com32sys_t ) ); } } @@ -181,7 +181,7 @@ int __asmcall com32_cfarcall ( uint32_t proc, physaddr_t stack, size_t stacksz ) DBGC ( &com32_regs, "COM32 cfarcall %04x:%04x params %#08lx+%#zx\n", ( proc >> 16 ), ( proc & 0xffff ), stack, stacksz ); - copy_user_to_rm_stack ( phys_to_user ( stack ), stacksz ); + copy_user_to_rm_stack ( phys_to_virt ( stack ), stacksz ); com32_farcall_proc = proc; __asm__ __volatile__ ( diff --git a/src/arch/x86/interface/syslinux/comboot_call.c b/src/arch/x86/interface/syslinux/comboot_call.c index f26fcad0a..d7e923b70 100644 --- a/src/arch/x86/interface/syslinux/comboot_call.c +++ b/src/arch/x86/interface/syslinux/comboot_call.c @@ -114,8 +114,8 @@ static void shuffle ( unsigned int list_segment, unsigned int list_offset, unsig /* Do the copies */ for ( i = 0; i < count; i++ ) { - userptr_t src_u = phys_to_user ( shuf[ i ].src ); - userptr_t dest_u = phys_to_user ( shuf[ i ].dest ); + userptr_t src_u = phys_to_virt ( shuf[ i ].src ); + userptr_t dest_u = phys_to_virt ( shuf[ i ].dest ); if ( shuf[ i ].src == 0xFFFFFFFF ) { /* Fill with 0 instead of copying */ diff --git a/src/arch/x86/transitions/librm_mgmt.c b/src/arch/x86/transitions/librm_mgmt.c index 82e8eab39..fbc653969 100644 --- a/src/arch/x86/transitions/librm_mgmt.c +++ b/src/arch/x86/transitions/librm_mgmt.c @@ -428,8 +428,8 @@ void setup_sipi ( unsigned int vector, uint32_t handler, copy_to_real ( ( vector << 8 ), 0, sipi, ( ( size_t ) sipi_len ) ); } -PROVIDE_UACCESS_INLINE ( librm, phys_to_user ); -PROVIDE_UACCESS_INLINE ( librm, user_to_phys ); +PROVIDE_UACCESS_INLINE ( librm, phys_to_virt ); +PROVIDE_UACCESS_INLINE ( librm, virt_to_phys ); PROVIDE_UACCESS_INLINE ( librm, virt_to_user ); PROVIDE_UACCESS_INLINE ( librm, memchr_user ); PROVIDE_IOMAP_INLINE ( pages, io_to_bus ); diff --git a/src/core/acpi.c b/src/core/acpi.c index 526bf8555..d7da0ccc1 100644 --- a/src/core/acpi.c +++ b/src/core/acpi.c @@ -128,16 +128,16 @@ userptr_t acpi_find_via_rsdt ( uint32_t signature, unsigned int index ) { copy_from_user ( &acpi, rsdt, 0, sizeof ( acpi ) ); if ( acpi.signature != cpu_to_le32 ( RSDT_SIGNATURE ) ) { DBGC ( colour, "RSDT %#08lx has invalid signature:\n", - user_to_phys ( rsdt, 0 ) ); - DBGC_HDA ( colour, user_to_phys ( rsdt, 0 ), &acpi, + virt_to_phys ( rsdt ) ); + DBGC_HDA ( colour, virt_to_phys ( rsdt ), &acpi, sizeof ( acpi ) ); return UNULL; } len = le32_to_cpu ( acpi.length ); if ( len < sizeof ( rsdtab->acpi ) ) { DBGC ( colour, "RSDT %#08lx has invalid length:\n", - user_to_phys ( rsdt, 0 ) ); - DBGC_HDA ( colour, user_to_phys ( rsdt, 0 ), &acpi, + virt_to_phys ( rsdt ) ); + DBGC_HDA ( colour, virt_to_phys ( rsdt ), &acpi, sizeof ( acpi ) ); return UNULL; } @@ -154,7 +154,7 @@ userptr_t acpi_find_via_rsdt ( uint32_t signature, unsigned int index ) { sizeof ( entry ) ); /* Read table header */ - table = phys_to_user ( entry ); + table = phys_to_virt ( entry ); copy_from_user ( &acpi.signature, table, 0, sizeof ( acpi.signature ) ); @@ -169,20 +169,20 @@ userptr_t acpi_find_via_rsdt ( uint32_t signature, unsigned int index ) { /* Check table integrity */ if ( acpi_checksum ( table ) != 0 ) { DBGC ( colour, "RSDT %#08lx found %s with bad " - "checksum at %08lx\n", user_to_phys ( rsdt, 0 ), + "checksum at %08lx\n", virt_to_phys ( rsdt ), acpi_name ( signature ), - user_to_phys ( table, 0 ) ); + virt_to_phys ( table ) ); break; } DBGC ( colour, "RSDT %#08lx found %s at %08lx\n", - user_to_phys ( rsdt, 0 ), acpi_name ( signature ), - user_to_phys ( table, 0 ) ); + virt_to_phys ( rsdt ), acpi_name ( signature ), + virt_to_phys ( table ) ); return table; } DBGC ( colour, "RSDT %#08lx could not find %s\n", - user_to_phys ( rsdt, 0 ), acpi_name ( signature ) ); + virt_to_phys ( rsdt ), acpi_name ( signature ) ); return UNULL; } @@ -218,7 +218,7 @@ static int acpi_zsdt ( userptr_t zsdt, uint32_t signature, void *data, if ( buf != cpu_to_le32 ( signature ) ) continue; DBGC ( zsdt, "DSDT/SSDT %#08lx found %s at offset %#zx\n", - user_to_phys ( zsdt, 0 ), acpi_name ( signature ), + virt_to_phys ( zsdt ), acpi_name ( signature ), offset ); /* Attempt to extract data */ @@ -251,7 +251,7 @@ int acpi_extract ( uint32_t signature, void *data, fadt = acpi_table ( FADT_SIGNATURE, 0 ); if ( fadt ) { copy_from_user ( &fadtab, fadt, 0, sizeof ( fadtab ) ); - dsdt = phys_to_user ( fadtab.dsdt ); + dsdt = phys_to_virt ( fadtab.dsdt ); if ( ( rc = acpi_zsdt ( dsdt, signature, data, extract ) ) == 0 ) return 0; diff --git a/src/core/blocktrans.c b/src/core/blocktrans.c index f9dcb95d2..f3be2ba2b 100644 --- a/src/core/blocktrans.c +++ b/src/core/blocktrans.c @@ -248,7 +248,7 @@ int block_translate ( struct interface *block, userptr_t buffer, size_t size ) { DBGC2 ( blktrans, "BLKTRANS %p created", blktrans ); if ( buffer ) { DBGC2 ( blktrans, " for %#lx+%#zx", - user_to_phys ( buffer, 0 ), size ); + virt_to_phys ( buffer ), size ); } DBGC2 ( blktrans, "\n" ); return 0; diff --git a/src/core/cachedhcp.c b/src/core/cachedhcp.c index 04945e646..07589f0b8 100644 --- a/src/core/cachedhcp.c +++ b/src/core/cachedhcp.c @@ -251,7 +251,7 @@ int cachedhcp_record ( struct cached_dhcp_packet *cache, unsigned int vlan, /* Store as cached packet */ DBGC ( colour, "CACHEDHCP %s at %#08lx+%#zx/%#zx\n", cache->name, - user_to_phys ( data, 0 ), len, max_len ); + virt_to_phys ( data ), len, max_len ); cache->dhcppkt = dhcppkt; cache->vlan = vlan; diff --git a/src/core/fbcon.c b/src/core/fbcon.c index 8d05484e2..6d08ac419 100644 --- a/src/core/fbcon.c +++ b/src/core/fbcon.c @@ -613,8 +613,8 @@ int fbcon_init ( struct fbcon *fbcon, userptr_t start, /* Derive overall length */ fbcon->len = ( pixel->height * pixel->stride ); DBGC ( fbcon, "FBCON %p at [%08lx,%08lx)\n", fbcon, - user_to_phys ( fbcon->start, 0 ), - user_to_phys ( fbcon->start, fbcon->len ) ); + virt_to_phys ( fbcon->start ), + ( virt_to_phys ( fbcon->start ) + fbcon->len ) ); /* Calculate margin. If the actual screen size is larger than * the requested screen size, then update the margins so that diff --git a/src/core/image.c b/src/core/image.c index 709d0da9c..e90d82ffb 100644 --- a/src/core/image.c +++ b/src/core/image.c @@ -300,8 +300,8 @@ int register_image ( struct image *image ) { image->flags |= IMAGE_REGISTERED; list_add_tail ( &image->list, &images ); DBGC ( image, "IMAGE %s at [%lx,%lx) registered\n", - image->name, user_to_phys ( image->data, 0 ), - user_to_phys ( image->data, image->len ) ); + image->name, virt_to_phys ( image->data ), + ( virt_to_phys ( image->data ) + image->len ) ); /* Try to detect image type, if applicable. Ignore failures, * since we expect to handle some unrecognised images diff --git a/src/core/uaccess.c b/src/core/uaccess.c index 1c33c10b8..32bd1ac38 100644 --- a/src/core/uaccess.c +++ b/src/core/uaccess.c @@ -32,7 +32,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ /* Flat address space user access API */ -PROVIDE_UACCESS_INLINE ( flat, phys_to_user ); -PROVIDE_UACCESS_INLINE ( flat, user_to_phys ); +PROVIDE_UACCESS_INLINE ( flat, phys_to_virt ); +PROVIDE_UACCESS_INLINE ( flat, virt_to_phys ); PROVIDE_UACCESS_INLINE ( flat, virt_to_user ); PROVIDE_UACCESS_INLINE ( flat, memchr_user ); diff --git a/src/drivers/block/srp.c b/src/drivers/block/srp.c index ab4812519..c12f230f7 100644 --- a/src/drivers/block/srp.c +++ b/src/drivers/block/srp.c @@ -428,7 +428,7 @@ static int srp_cmd ( struct srp_device *srpdev, cmd->data_buffer_formats |= SRP_CMD_DO_FMT_DIRECT; data_out = iob_put ( iobuf, sizeof ( *data_out ) ); data_out->address = - cpu_to_be64 ( user_to_phys ( command->data_out, 0 ) ); + cpu_to_be64 ( virt_to_phys ( command->data_out ) ); data_out->handle = ntohl ( srpdev->memory_handle ); data_out->len = ntohl ( command->data_out_len ); } @@ -438,7 +438,7 @@ static int srp_cmd ( struct srp_device *srpdev, cmd->data_buffer_formats |= SRP_CMD_DI_FMT_DIRECT; data_in = iob_put ( iobuf, sizeof ( *data_in ) ); data_in->address = - cpu_to_be64 ( user_to_phys ( command->data_in, 0 ) ); + cpu_to_be64 ( virt_to_phys ( command->data_in ) ); data_in->handle = ntohl ( srpdev->memory_handle ); data_in->len = ntohl ( command->data_in_len ); } diff --git a/src/drivers/infiniband/arbel.c b/src/drivers/infiniband/arbel.c index 8be06d93d..4cb4167e0 100644 --- a/src/drivers/infiniband/arbel.c +++ b/src/drivers/infiniband/arbel.c @@ -2079,7 +2079,7 @@ static int arbel_start_firmware ( struct arbel *arbel ) { } else { assert ( arbel->firmware_len == fw_len ); } - fw_base = user_to_phys ( arbel->firmware_area, 0 ); + fw_base = virt_to_phys ( arbel->firmware_area ); DBGC ( arbel, "Arbel %p firmware area at [%08lx,%08lx)\n", arbel, fw_base, ( fw_base + fw_len ) ); if ( ( rc = arbel_map_vpm ( arbel, arbel_cmd_map_fa, @@ -2452,7 +2452,7 @@ static int arbel_alloc_icm ( struct arbel *arbel, assert ( arbel->icm_len == icm_len ); assert ( arbel->icm_aux_len == icm_aux_len ); } - icm_phys = user_to_phys ( arbel->icm, 0 ); + icm_phys = virt_to_phys ( arbel->icm ); /* Allocate doorbell UAR */ arbel->db_rec = malloc_phys ( ARBEL_PAGE_SIZE, ARBEL_PAGE_SIZE ); diff --git a/src/drivers/infiniband/golan.c b/src/drivers/infiniband/golan.c index 81fc6c0f0..a33bad9ff 100755 --- a/src/drivers/infiniband/golan.c +++ b/src/drivers/infiniband/golan.c @@ -486,8 +486,8 @@ static inline int golan_provide_pages ( struct golan *golan , uint32_t pages for ( i = 0 , j = MANAGE_PAGES_PSA_OFFSET; i < pas_num; ++i ,++j, next_page_addr += GOLAN_PAGE_SIZE ) { addr = next_page_addr; - if (GOLAN_PAGE_MASK & user_to_phys(addr, 0)) { - DBGC (golan ,"Addr not Page alligned [%lx]\n", user_to_phys(addr, 0)); + if (GOLAN_PAGE_MASK & virt_to_phys(addr)) { + DBGC (golan ,"Addr not Page alligned [%lx]\n", virt_to_phys(addr)); } mailbox->mblock.data[j] = USR_2_BE64_BUS(addr); } diff --git a/src/drivers/infiniband/golan.h b/src/drivers/infiniband/golan.h index 2fd06ecf0..f7da1e960 100755 --- a/src/drivers/infiniband/golan.h +++ b/src/drivers/infiniband/golan.h @@ -69,8 +69,8 @@ FILE_LICENCE ( GPL2_OR_LATER ); #define VIRT_2_BE64_BUS( addr ) cpu_to_be64(((unsigned long long )virt_to_bus(addr))) #define BE64_BUS_2_VIRT( addr ) bus_to_virt(be64_to_cpu(addr)) -#define USR_2_BE64_BUS( addr ) cpu_to_be64(((unsigned long long )user_to_phys(addr, 0))) -#define BE64_BUS_2_USR( addr ) be64_to_cpu(phys_to_user(addr)) +#define USR_2_BE64_BUS( addr ) cpu_to_be64(((unsigned long long )virt_to_phys(addr))) +#define BE64_BUS_2_USR( addr ) be64_to_cpu(phys_to_virt(addr)) #define GET_INBOX(golan, idx) (&(((struct mbox *)(golan->mboxes.inbox))[idx])) #define GET_OUTBOX(golan, idx) (&(((struct mbox *)(golan->mboxes.outbox))[idx])) diff --git a/src/drivers/infiniband/hermon.c b/src/drivers/infiniband/hermon.c index e5c3544fa..3138d8bfb 100644 --- a/src/drivers/infiniband/hermon.c +++ b/src/drivers/infiniband/hermon.c @@ -2382,7 +2382,7 @@ static int hermon_start_firmware ( struct hermon *hermon ) { } else { assert ( hermon->firmware_len == fw_len ); } - fw_base = user_to_phys ( hermon->firmware_area, 0 ); + fw_base = virt_to_phys ( hermon->firmware_area ); DBGC ( hermon, "Hermon %p firmware area at physical [%08lx,%08lx)\n", hermon, fw_base, ( fw_base + fw_len ) ); if ( ( rc = hermon_map_vpm ( hermon, hermon_cmd_map_fa, @@ -2752,7 +2752,7 @@ static int hermon_map_icm ( struct hermon *hermon, assert ( hermon->icm_len == icm_len ); assert ( hermon->icm_aux_len == icm_aux_len ); } - icm_phys = user_to_phys ( hermon->icm, 0 ); + icm_phys = virt_to_phys ( hermon->icm ); /* Map ICM auxiliary area */ DBGC ( hermon, "Hermon %p mapping ICM AUX => %08lx\n", diff --git a/src/drivers/net/exanic.c b/src/drivers/net/exanic.c index 14a17df47..b3148e090 100644 --- a/src/drivers/net/exanic.c +++ b/src/drivers/net/exanic.c @@ -406,7 +406,7 @@ static int exanic_open ( struct net_device *netdev ) { port->rx_cons = 0; /* Map receive region */ - exanic_write_base ( phys_to_bus ( user_to_phys ( port->rx, 0 ) ), + exanic_write_base ( phys_to_bus ( virt_to_phys ( port->rx ) ), ( port->regs + EXANIC_PORT_RX_BASE ) ); /* Enable promiscuous mode */ @@ -729,8 +729,8 @@ static int exanic_probe_port ( struct exanic *exanic, struct device *dev, DBGC ( port, "EXANIC %s port %d TX [%#05zx,%#05zx) TXF %#02x RX " "[%#lx,%#lx)\n", netdev->name, index, port->tx_offset, ( port->tx_offset + tx_len ), port->txf_slot, - user_to_phys ( port->rx, 0 ), - user_to_phys ( port->rx, EXANIC_RX_LEN ) ); + virt_to_phys ( port->rx ), + ( virt_to_phys ( port->rx ) + EXANIC_RX_LEN ) ); /* Set initial link state */ exanic_check_link ( netdev ); diff --git a/src/drivers/net/gve.c b/src/drivers/net/gve.c index 2cbc401f5..f9ec388a4 100644 --- a/src/drivers/net/gve.c +++ b/src/drivers/net/gve.c @@ -521,14 +521,14 @@ static int gve_deconfigure ( struct gve_nic *gve ) { static int gve_register ( struct gve_nic *gve, struct gve_qpl *qpl ) { struct gve_pages *pages = &gve->scratch.buf->pages; union gve_admin_command *cmd; - physaddr_t addr; + void *addr; unsigned int i; int rc; /* Build page address list */ for ( i = 0 ; i < qpl->count ; i++ ) { - addr = user_to_phys ( qpl->data, ( i * GVE_PAGE_SIZE ) ); - pages->addr[i] = cpu_to_be64 ( dma_phys ( &qpl->map, addr ) ); + addr = ( qpl->data + ( i * GVE_PAGE_SIZE ) ); + pages->addr[i] = cpu_to_be64 ( dma ( &qpl->map, addr ) ); } /* Construct request */ @@ -575,11 +575,10 @@ static void gve_create_tx_param ( struct gve_queue *queue, union gve_admin_command *cmd ) { struct gve_admin_create_tx *create = &cmd->create_tx; const struct gve_queue_type *type = queue->type; - physaddr_t desc = user_to_phys ( queue->desc, 0 ); /* Construct request parameters */ create->res = cpu_to_be64 ( dma ( &queue->res_map, queue->res ) ); - create->desc = cpu_to_be64 ( dma_phys ( &queue->desc_map, desc ) ); + create->desc = cpu_to_be64 ( dma ( &queue->desc_map, queue->desc ) ); create->qpl_id = cpu_to_be32 ( type->qpl ); create->notify_id = cpu_to_be32 ( type->irq ); } @@ -594,14 +593,12 @@ static void gve_create_rx_param ( struct gve_queue *queue, union gve_admin_command *cmd ) { struct gve_admin_create_rx *create = &cmd->create_rx; const struct gve_queue_type *type = queue->type; - physaddr_t desc = user_to_phys ( queue->desc, 0 ); - physaddr_t cmplt = user_to_phys ( queue->cmplt, 0 ); /* Construct request parameters */ create->notify_id = cpu_to_be32 ( type->irq ); create->res = cpu_to_be64 ( dma ( &queue->res_map, queue->res ) ); - create->desc = cpu_to_be64 ( dma_phys ( &queue->desc_map, desc ) ); - create->cmplt = cpu_to_be64 ( dma_phys ( &queue->cmplt_map, cmplt ) ); + create->desc = cpu_to_be64 ( dma ( &queue->desc_map, queue->desc ) ); + create->cmplt = cpu_to_be64 ( dma ( &queue->cmplt_map, queue->cmplt )); create->qpl_id = cpu_to_be32 ( type->qpl ); create->bufsz = cpu_to_be16 ( GVE_BUF_SIZE ); } @@ -760,8 +757,8 @@ static int gve_alloc_qpl ( struct gve_nic *gve, struct gve_qpl *qpl, return -ENOMEM; DBGC ( gve, "GVE %p QPL %#08x at [%08lx,%08lx)\n", - gve, qpl->id, user_to_phys ( qpl->data, 0 ), - user_to_phys ( qpl->data, len ) ); + gve, qpl->id, virt_to_phys ( qpl->data ), + ( virt_to_phys ( qpl->data ) + len ) ); return 0; } @@ -883,8 +880,8 @@ static int gve_alloc_queue ( struct gve_nic *gve, struct gve_queue *queue ) { goto err_desc; } DBGC ( gve, "GVE %p %s descriptors at [%08lx,%08lx)\n", - gve, type->name, user_to_phys ( queue->desc, 0 ), - user_to_phys ( queue->desc, desc_len ) ); + gve, type->name, virt_to_phys ( queue->desc ), + ( virt_to_phys ( queue->desc ) + desc_len ) ); /* Allocate completions */ if ( cmplt_len ) { @@ -895,8 +892,8 @@ static int gve_alloc_queue ( struct gve_nic *gve, struct gve_queue *queue ) { goto err_cmplt; } DBGC ( gve, "GVE %p %s completions at [%08lx,%08lx)\n", - gve, type->name, user_to_phys ( queue->cmplt, 0 ), - user_to_phys ( queue->cmplt, cmplt_len ) ); + gve, type->name, virt_to_phys ( queue->cmplt ), + ( virt_to_phys ( queue->cmplt ) + cmplt_len ) ); } /* Allocate queue resources */ diff --git a/src/drivers/net/thunderx.c b/src/drivers/net/thunderx.c index 1865a9b91..3d213b167 100644 --- a/src/drivers/net/thunderx.c +++ b/src/drivers/net/thunderx.c @@ -118,14 +118,14 @@ static int txnic_create_sq ( struct txnic *vnic ) { writeq ( TXNIC_QS_SQ_CFG_RESET, ( vnic->regs + TXNIC_QS_SQ_CFG(0) ) ); /* Configure and enable send queue */ - writeq ( user_to_phys ( vnic->sq.sqe, 0 ), + writeq ( virt_to_phys ( vnic->sq.sqe ), ( vnic->regs + TXNIC_QS_SQ_BASE(0) ) ); writeq ( ( TXNIC_QS_SQ_CFG_ENA | TXNIC_QS_SQ_CFG_QSIZE_1K ), ( vnic->regs + TXNIC_QS_SQ_CFG(0) ) ); DBGC ( vnic, "TXNIC %s SQ at [%08lx,%08lx)\n", - vnic->name, user_to_phys ( vnic->sq.sqe, 0 ), - user_to_phys ( vnic->sq.sqe, TXNIC_SQ_SIZE ) ); + vnic->name, virt_to_phys ( vnic->sq.sqe ), + ( virt_to_phys ( vnic->sq.sqe ) + TXNIC_SQ_SIZE ) ); return 0; } @@ -277,7 +277,7 @@ static int txnic_create_rq ( struct txnic *vnic ) { ( vnic->regs + TXNIC_QS_RBDR_CFG(0) ) ); /* Configure and enable receive buffer descriptor ring */ - writeq ( user_to_phys ( vnic->rq.rqe, 0 ), + writeq ( virt_to_phys ( vnic->rq.rqe ), ( vnic->regs + TXNIC_QS_RBDR_BASE(0) ) ); writeq ( ( TXNIC_QS_RBDR_CFG_ENA | TXNIC_QS_RBDR_CFG_QSIZE_8K | TXNIC_QS_RBDR_CFG_LINES ( TXNIC_RQE_SIZE / @@ -288,8 +288,8 @@ static int txnic_create_rq ( struct txnic *vnic ) { writeq ( TXNIC_QS_RQ_CFG_ENA, ( vnic->regs + TXNIC_QS_RQ_CFG(0) ) ); DBGC ( vnic, "TXNIC %s RQ at [%08lx,%08lx)\n", - vnic->name, user_to_phys ( vnic->rq.rqe, 0 ), - user_to_phys ( vnic->rq.rqe, TXNIC_RQ_SIZE ) ); + vnic->name, virt_to_phys ( vnic->rq.rqe ), + ( virt_to_phys ( vnic->rq.rqe ) + TXNIC_RQ_SIZE ) ); return 0; } @@ -463,14 +463,14 @@ static int txnic_create_cq ( struct txnic *vnic ) { writeq ( TXNIC_QS_CQ_CFG_RESET, ( vnic->regs + TXNIC_QS_CQ_CFG(0) ) ); /* Configure and enable completion queue */ - writeq ( user_to_phys ( vnic->cq.cqe, 0 ), + writeq ( virt_to_phys ( vnic->cq.cqe ), ( vnic->regs + TXNIC_QS_CQ_BASE(0) ) ); writeq ( ( TXNIC_QS_CQ_CFG_ENA | TXNIC_QS_CQ_CFG_QSIZE_256 ), ( vnic->regs + TXNIC_QS_CQ_CFG(0) ) ); DBGC ( vnic, "TXNIC %s CQ at [%08lx,%08lx)\n", - vnic->name, user_to_phys ( vnic->cq.cqe, 0 ), - user_to_phys ( vnic->cq.cqe, TXNIC_CQ_SIZE ) ); + vnic->name, virt_to_phys ( vnic->cq.cqe ), + ( virt_to_phys ( vnic->cq.cqe ) + TXNIC_CQ_SIZE ) ); return 0; } @@ -559,7 +559,8 @@ static void txnic_poll_cq ( struct txnic *vnic ) { default: DBGC ( vnic, "TXNIC %s unknown completion type %d\n", vnic->name, cqe.common.cqe_type ); - DBGC_HDA ( vnic, user_to_phys ( vnic->cq.cqe, offset ), + DBGC_HDA ( vnic, + ( virt_to_phys ( vnic->cq.cqe ) + offset ), &cqe, sizeof ( cqe ) ); break; } diff --git a/src/drivers/usb/xhci.c b/src/drivers/usb/xhci.c index f244086ce..30ee09bbb 100644 --- a/src/drivers/usb/xhci.c +++ b/src/drivers/usb/xhci.c @@ -1014,8 +1014,7 @@ static int xhci_scratchpad_alloc ( struct xhci_device *xhci ) { } /* Populate scratchpad array */ - addr = dma_phys ( &scratch->buffer_map, - user_to_phys ( scratch->buffer, 0 ) ); + addr = dma ( &scratch->buffer_map, scratch->buffer ); for ( i = 0 ; i < scratch->count ; i++ ) { scratch->array[i] = cpu_to_le64 ( addr ); addr += xhci->pagesize; @@ -1027,8 +1026,8 @@ static int xhci_scratchpad_alloc ( struct xhci_device *xhci ) { scratch->array ) ); DBGC2 ( xhci, "XHCI %s scratchpad [%08lx,%08lx) array [%08lx,%08lx)\n", - xhci->name, user_to_phys ( scratch->buffer, 0 ), - user_to_phys ( scratch->buffer, buffer_len ), + xhci->name, virt_to_phys ( scratch->buffer ), + ( virt_to_phys ( scratch->buffer ) + buffer_len ), virt_to_phys ( scratch->array ), ( virt_to_phys ( scratch->array ) + array_len ) ); return 0; diff --git a/src/hci/commands/image_mem_cmd.c b/src/hci/commands/image_mem_cmd.c index c8bfab1ad..5f8363461 100644 --- a/src/hci/commands/image_mem_cmd.c +++ b/src/hci/commands/image_mem_cmd.c @@ -81,7 +81,7 @@ static int imgmem_exec ( int argc, char **argv ) { return rc; /* Create image */ - if ( ( rc = imgmem ( opts.name, phys_to_user ( data ), len ) ) != 0 ) + if ( ( rc = imgmem ( opts.name, phys_to_virt ( data ), len ) ) != 0 ) return rc; return 0; diff --git a/src/image/elf.c b/src/image/elf.c index 46c9fe8eb..fa714b15f 100644 --- a/src/image/elf.c +++ b/src/image/elf.c @@ -50,7 +50,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ static int elf_load_segment ( struct image *image, Elf_Phdr *phdr, physaddr_t dest ) { - userptr_t buffer = phys_to_user ( dest ); + userptr_t buffer = phys_to_virt ( dest ); int rc; DBGC ( image, "ELF %p loading segment [%x,%x) to [%lx,%lx,%lx)\n", diff --git a/src/image/segment.c b/src/image/segment.c index b7f8ef56c..ebc2b703d 100644 --- a/src/image/segment.c +++ b/src/image/segment.c @@ -59,9 +59,9 @@ struct errortab segment_errors[] __errortab = { */ int prep_segment ( userptr_t segment, size_t filesz, size_t memsz ) { struct memory_map memmap; - physaddr_t start = user_to_phys ( segment, 0 ); - physaddr_t mid = user_to_phys ( segment, filesz ); - physaddr_t end = user_to_phys ( segment, memsz ); + physaddr_t start = virt_to_phys ( segment ); + physaddr_t mid = ( start + filesz ); + physaddr_t end = ( start + memsz ); unsigned int i; DBG ( "Preparing segment [%lx,%lx,%lx)\n", start, mid, end ); diff --git a/src/include/ipxe/linux/linux_uaccess.h b/src/include/ipxe/linux/linux_uaccess.h index 4b1257b1e..b4f7e2fc6 100644 --- a/src/include/ipxe/linux/linux_uaccess.h +++ b/src/include/ipxe/linux/linux_uaccess.h @@ -10,10 +10,9 @@ * * We have no concept of the underlying physical addresses, since * these are not exposed to userspace. We provide a stub - * implementation of user_to_phys() since this is required by - * alloc_memblock(). We provide no implementation of phys_to_user(); - * any code attempting to access physical addresses will therefore - * (correctly) fail to link. + * implementation of virt_to_phys() since this is required by + * alloc_memblock(). We provide a matching stub implementation of + * phys_to_virt(). */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); @@ -25,14 +24,13 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #endif /** - * Convert user pointer to physical address + * Convert virtual address to physical address * - * @v userptr User pointer - * @v offset Offset from user pointer - * @ret phys_addr Physical address + * @v virt Virtual address + * @ret phys Physical address */ -static inline __always_inline unsigned long -UACCESS_INLINE ( linux, user_to_phys ) ( userptr_t userptr, off_t offset ) { +static inline __always_inline physaddr_t +UACCESS_INLINE ( linux, virt_to_phys ) ( volatile const void *virt ) { /* We do not know the real underlying physical address. We * provide this stub implementation only because it is @@ -43,20 +41,20 @@ UACCESS_INLINE ( linux, user_to_phys ) ( userptr_t userptr, off_t offset ) { * virtual address will suffice for the purpose of determining * alignment. */ - return ( ( unsigned long ) ( userptr + offset ) ); + return ( ( physaddr_t ) virt ); } /** - * Convert physical address to user pointer + * Convert physical address to virtual address * - * @v phys_addr Physical address - * @ret userptr User pointer + * @v phys Physical address + * @ret virt Virtual address */ -static inline __always_inline userptr_t -UACCESS_INLINE ( linux, phys_to_user ) ( physaddr_t phys_addr ) { +static inline __always_inline void * +UACCESS_INLINE ( linux, phys_to_virt ) ( physaddr_t phys ) { - /* For symmetry with the stub user_to_phys() */ - return ( ( userptr_t ) phys_addr ); + /* For symmetry with the stub virt_to_phys() */ + return ( ( void * ) phys ); } static inline __always_inline userptr_t diff --git a/src/include/ipxe/uaccess.h b/src/include/ipxe/uaccess.h index 4b3524bab..62030dd8a 100644 --- a/src/include/ipxe/uaccess.h +++ b/src/include/ipxe/uaccess.h @@ -99,14 +99,14 @@ trivial_memchr_user ( userptr_t buffer, off_t offset, int c, size_t len ) { #define PROVIDE_UACCESS_INLINE( _subsys, _api_func ) \ PROVIDE_SINGLE_API_INLINE ( UACCESS_PREFIX_ ## _subsys, _api_func ) -static inline __always_inline userptr_t -UACCESS_INLINE ( flat, phys_to_user ) ( unsigned long phys_addr ) { - return ( ( userptr_t ) phys_addr ); +static inline __always_inline void * +UACCESS_INLINE ( flat, phys_to_virt ) ( physaddr_t phys ) { + return ( ( void * ) phys ); } -static inline __always_inline unsigned long -UACCESS_INLINE ( flat, user_to_phys ) ( userptr_t userptr, off_t offset ) { - return ( ( unsigned long ) ( userptr + offset ) ); +static inline __always_inline physaddr_t +UACCESS_INLINE ( flat, virt_to_phys ) ( volatile const void *virt ) { + return ( ( physaddr_t ) virt ); } static inline __always_inline userptr_t @@ -126,23 +126,6 @@ UACCESS_INLINE ( flat, memchr_user ) ( userptr_t buffer, off_t offset, /* Include all architecture-dependent user access API headers */ #include -/** - * Convert physical address to user pointer - * - * @v phys_addr Physical address - * @ret userptr User pointer - */ -userptr_t phys_to_user ( unsigned long phys_addr ); - -/** - * Convert user pointer to physical address - * - * @v userptr User pointer - * @v offset Offset from user pointer - * @ret phys_addr Physical address - */ -unsigned long user_to_phys ( userptr_t userptr, off_t offset ); - /** * Convert virtual address to user pointer * @@ -154,25 +137,21 @@ userptr_t virt_to_user ( volatile const void *addr ); /** * Convert virtual address to a physical address * - * @v addr Virtual address - * @ret phys_addr Physical address + * @v virt Virtual address + * @ret phys Physical address */ -static inline __always_inline unsigned long -virt_to_phys ( volatile const void *addr ) { - return user_to_phys ( virt_to_user ( addr ), 0 ); -} +physaddr_t __attribute__ (( const )) +virt_to_phys ( volatile const void *virt ); /** * Convert physical address to a virtual address * - * @v addr Virtual address - * @ret phys_addr Physical address + * @v phys Physical address + * @ret virt Virtual address * * This operation is not available under all memory models. */ -static inline __always_inline void * phys_to_virt ( unsigned long phys_addr ) { - return ( phys_to_user ( phys_addr ) ); -} +void * __attribute__ (( const )) phys_to_virt ( physaddr_t phys ); /** * Copy data to user buffer diff --git a/src/interface/efi/efi_acpi.c b/src/interface/efi/efi_acpi.c index 07a225632..c1046c01a 100644 --- a/src/interface/efi/efi_acpi.c +++ b/src/interface/efi/efi_acpi.c @@ -48,7 +48,7 @@ static userptr_t efi_find_rsdt ( void ) { /* Locate RSDT via ACPI configuration table, if available */ if ( rsdp ) - return phys_to_user ( rsdp->RsdtAddress ); + return phys_to_virt ( rsdp->RsdtAddress ); return UNULL; } diff --git a/src/interface/efi/efi_fbcon.c b/src/interface/efi/efi_fbcon.c index 659ebd37e..09cfde4c2 100644 --- a/src/interface/efi/efi_fbcon.c +++ b/src/interface/efi/efi_fbcon.c @@ -583,7 +583,7 @@ static int efifb_init ( struct console_configuration *config ) { mode, efifb.pixel.width, efifb.pixel.height, bpp, efifb.start ); /* Initialise frame buffer console */ - if ( ( rc = fbcon_init ( &efifb.fbcon, phys_to_user ( efifb.start ), + if ( ( rc = fbcon_init ( &efifb.fbcon, phys_to_virt ( efifb.start ), &efifb.pixel, &efifb.map, &efifb.font, config ) ) != 0 ) goto err_fbcon_init; diff --git a/src/interface/efi/efi_smbios.c b/src/interface/efi/efi_smbios.c index d7877b0aa..3c1b77bdc 100644 --- a/src/interface/efi/efi_smbios.c +++ b/src/interface/efi/efi_smbios.c @@ -48,27 +48,27 @@ static int efi_find_smbios ( struct smbios *smbios ) { /* Use 64-bit table if present */ if ( smbios3_entry && ( smbios3_entry->signature == SMBIOS3_SIGNATURE ) ) { - smbios->address = phys_to_user ( smbios3_entry->smbios_address ); + smbios->address = phys_to_virt ( smbios3_entry->smbios_address ); smbios->len = smbios3_entry->smbios_len; smbios->count = 0; smbios->version = SMBIOS_VERSION ( smbios3_entry->major, smbios3_entry->minor ); DBG ( "Found 64-bit SMBIOS v%d.%d entry point at %p (%lx+%zx)\n", smbios3_entry->major, smbios3_entry->minor, smbios3_entry, - user_to_phys ( smbios->address, 0 ), smbios->len ); + virt_to_phys ( smbios->address ), smbios->len ); return 0; } /* Otherwise, use 32-bit table if present */ if ( smbios_entry && ( smbios_entry->signature == SMBIOS_SIGNATURE ) ) { - smbios->address = phys_to_user ( smbios_entry->smbios_address ); + smbios->address = phys_to_virt ( smbios_entry->smbios_address ); smbios->len = smbios_entry->smbios_len; smbios->count = smbios_entry->smbios_count; smbios->version = SMBIOS_VERSION ( smbios_entry->major, smbios_entry->minor ); DBG ( "Found 32-bit SMBIOS v%d.%d entry point at %p (%lx+%zx)\n", smbios_entry->major, smbios_entry->minor, smbios_entry, - user_to_phys ( smbios->address, 0 ), smbios->len ); + virt_to_phys ( smbios->address ), smbios->len ); return 0; } diff --git a/src/interface/efi/efi_umalloc.c b/src/interface/efi/efi_umalloc.c index 488c53f3d..0636cb7fd 100644 --- a/src/interface/efi/efi_umalloc.c +++ b/src/interface/efi/efi_umalloc.c @@ -72,7 +72,7 @@ static userptr_t efi_urealloc ( userptr_t old_ptr, size_t new_size ) { return UNULL; } assert ( phys_addr != 0 ); - new_ptr = phys_to_user ( phys_addr + EFI_PAGE_SIZE ); + new_ptr = phys_to_virt ( phys_addr + EFI_PAGE_SIZE ); copy_to_user ( new_ptr, -EFI_PAGE_SIZE, &new_size, sizeof ( new_size ) ); DBG ( "EFI allocated %d pages at %llx\n", @@ -90,7 +90,7 @@ static userptr_t efi_urealloc ( userptr_t old_ptr, size_t new_size ) { memcpy ( new_ptr, old_ptr, ( (old_size < new_size) ? old_size : new_size ) ); old_pages = ( EFI_SIZE_TO_PAGES ( old_size ) + 1 ); - phys_addr = user_to_phys ( old_ptr, -EFI_PAGE_SIZE ); + phys_addr = virt_to_phys ( old_ptr - EFI_PAGE_SIZE ); if ( ( efirc = bs->FreePages ( phys_addr, old_pages ) ) != 0 ){ rc = -EEFI ( efirc ); DBG ( "EFI could not free %d pages at %llx: %s\n", diff --git a/src/interface/hyperv/vmbus.c b/src/interface/hyperv/vmbus.c index 86d2a08d7..49ccf69c8 100644 --- a/src/interface/hyperv/vmbus.c +++ b/src/interface/hyperv/vmbus.c @@ -277,7 +277,7 @@ int vmbus_establish_gpadl ( struct vmbus_device *vmdev, userptr_t data, size_t len ) { struct hv_hypervisor *hv = vmdev->hv; struct vmbus *vmbus = hv->vmbus; - physaddr_t addr = user_to_phys ( data, 0 ); + physaddr_t addr = virt_to_phys ( data ); unsigned int pfn_count = hv_pfn_count ( addr, len ); struct { struct vmbus_gpadl_header gpadlhdr; diff --git a/src/interface/linux/linux_uaccess.c b/src/interface/linux/linux_uaccess.c index e5c394365..4fdd8c03a 100644 --- a/src/interface/linux/linux_uaccess.c +++ b/src/interface/linux/linux_uaccess.c @@ -27,6 +27,7 @@ FILE_LICENCE(GPL2_OR_LATER); * */ -PROVIDE_UACCESS_INLINE(linux, user_to_phys); +PROVIDE_UACCESS_INLINE(linux, phys_to_virt); +PROVIDE_UACCESS_INLINE(linux, virt_to_phys); PROVIDE_UACCESS_INLINE(linux, virt_to_user); PROVIDE_UACCESS_INLINE(linux, memchr_user); diff --git a/src/interface/smbios/smbios.c b/src/interface/smbios/smbios.c index 3e69a0c15..89fa4d7ca 100644 --- a/src/interface/smbios/smbios.c +++ b/src/interface/smbios/smbios.c @@ -86,14 +86,14 @@ int find_smbios_entry ( userptr_t start, size_t len, if ( ( sum = smbios_checksum ( start, offset, entry->len ) ) != 0 ) { DBG ( "SMBIOS at %08lx has bad checksum %02x\n", - user_to_phys ( start, offset ), sum ); + virt_to_phys ( start + offset ), sum ); continue; } /* Fill result structure */ DBG ( "Found SMBIOS v%d.%d entry point at %08lx\n", entry->major, entry->minor, - user_to_phys ( start, offset ) ); + virt_to_phys ( start + offset ) ); return 0; } @@ -126,14 +126,14 @@ int find_smbios3_entry ( userptr_t start, size_t len, if ( ( sum = smbios_checksum ( start, offset, entry->len ) ) != 0 ) { DBG ( "SMBIOS3 at %08lx has bad checksum %02x\n", - user_to_phys ( start, offset ), sum ); + virt_to_phys ( start + offset ), sum ); continue; } /* Fill result structure */ DBG ( "Found SMBIOS3 v%d.%d entry point at %08lx\n", entry->major, entry->minor, - user_to_phys ( start, offset ) ); + virt_to_phys ( start + offset ) ); return 0; } -- cgit v1.2.3-55-g7522 From 3f8937d2f3a82371022303c2e70369ce7a05f89e Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 21 Apr 2025 22:40:59 +0100 Subject: [crypto] Remove userptr_t from ASN.1 parsers Simplify the ASN.1 code by assuming that all objects are fully accessible via pointer dereferences. This allows the concept of "additional data beyond the end of the cursor" to be removed, and simplifies parsing of all ASN.1 image formats. Signed-off-by: Michael Brown --- src/crypto/asn1.c | 46 ++++++++-------------------------- src/drivers/net/iphone.c | 2 +- src/image/der.c | 24 ++++++------------ src/image/efi_siglist.c | 51 +++++++++++++++++++------------------- src/image/pem.c | 24 ++++++++---------- src/include/ipxe/asn1.h | 2 -- src/include/ipxe/der.h | 2 +- src/include/ipxe/efi/efi_siglist.h | 3 +-- src/include/ipxe/pem.h | 3 +-- src/interface/efi/efi_cacert.c | 4 +-- 10 files changed, 61 insertions(+), 100 deletions(-) (limited to 'src/drivers') diff --git a/src/crypto/asn1.c b/src/crypto/asn1.c index aa57c6a8b..7b84f6fc3 100644 --- a/src/crypto/asn1.c +++ b/src/crypto/asn1.c @@ -88,7 +88,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * * @v cursor ASN.1 object cursor * @v type Expected type, or ASN1_ANY - * @v extra Additional length not present within partial cursor * @ret len Length of object body, or negative error * * The object cursor will be updated to point to the start of the @@ -100,8 +99,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * modified. If any other error occurs, the object cursor will be * invalidated. */ -static int asn1_start ( struct asn1_cursor *cursor, unsigned int type, - size_t extra ) { +static int asn1_start ( struct asn1_cursor *cursor, unsigned int type ) { unsigned int len_len; unsigned int len; @@ -145,9 +143,9 @@ static int asn1_start ( struct asn1_cursor *cursor, unsigned int type, cursor->data++; cursor->len--; } - if ( ( cursor->len + extra ) < len ) { + if ( cursor->len < len ) { DBGC ( cursor, "ASN1 %p bad length %d (max %zd)\n", - cursor, len, ( cursor->len + extra ) ); + cursor, len, cursor->len ); asn1_invalidate_cursor ( cursor ); return -EINVAL_ASN1_LEN; } @@ -156,58 +154,36 @@ static int asn1_start ( struct asn1_cursor *cursor, unsigned int type, } /** - * Enter ASN.1 partial object + * Enter ASN.1 object * * @v cursor ASN.1 object cursor * @v type Expected type, or ASN1_ANY - * @v extra Additional length beyond partial object * @ret rc Return status code * - * The object cursor and additional length will be updated to point to - * the body of the current ASN.1 object. + * The object cursor will be updated to point to the body of the + * current ASN.1 object. * * If any error occurs, the object cursor will be invalidated. */ -int asn1_enter_partial ( struct asn1_cursor *cursor, unsigned int type, - size_t *extra ) { +int asn1_enter ( struct asn1_cursor *cursor, unsigned int type ) { int len; /* Parse current object */ - len = asn1_start ( cursor, type, *extra ); + len = asn1_start ( cursor, type ); if ( len < 0 ) { asn1_invalidate_cursor ( cursor ); return len; } - /* Update cursor and additional length */ + /* Update cursor */ if ( ( ( size_t ) len ) <= cursor->len ) cursor->len = len; - assert ( ( len - cursor->len ) <= *extra ); - *extra = ( len - cursor->len ); DBGC ( cursor, "ASN1 %p entered object type %02x (len %x)\n", cursor, type, len ); return 0; } -/** - * Enter ASN.1 object - * - * @v cursor ASN.1 object cursor - * @v type Expected type, or ASN1_ANY - * @ret rc Return status code - * - * The object cursor will be updated to point to the body of the - * current ASN.1 object. - * - * If any error occurs, the object cursor will be invalidated. - */ -int asn1_enter ( struct asn1_cursor *cursor, unsigned int type ) { - static size_t no_extra = 0; - - return asn1_enter_partial ( cursor, type, &no_extra ); -} - /** * Skip ASN.1 object if present * @@ -226,7 +202,7 @@ int asn1_skip_if_exists ( struct asn1_cursor *cursor, unsigned int type ) { int len; /* Parse current object */ - len = asn1_start ( cursor, type, 0 ); + len = asn1_start ( cursor, type ); if ( len < 0 ) return len; @@ -281,7 +257,7 @@ int asn1_shrink ( struct asn1_cursor *cursor, unsigned int type ) { /* Find end of object */ memcpy ( &temp, cursor, sizeof ( temp ) ); - len = asn1_start ( &temp, type, 0 ); + len = asn1_start ( &temp, type ); if ( len < 0 ) { asn1_invalidate_cursor ( cursor ); return len; diff --git a/src/drivers/net/iphone.c b/src/drivers/net/iphone.c index 08459a6e2..bcc9949fe 100644 --- a/src/drivers/net/iphone.c +++ b/src/drivers/net/iphone.c @@ -1476,7 +1476,7 @@ static int ipair_rx_pubkey ( struct ipair *ipair, char *msg ) { } /* Decode inner layer of Base64 */ - next = pem_asn1 ( virt_to_user ( decoded ), len, 0, &key ); + next = pem_asn1 ( decoded, len, 0, &key ); if ( next < 0 ) { rc = next; DBGC ( ipair, "IPAIR %p invalid inner public key:\n%s\n", diff --git a/src/image/der.c b/src/image/der.c index ac4992336..600e163c9 100644 --- a/src/image/der.c +++ b/src/image/der.c @@ -28,7 +28,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include #include /** @file @@ -49,7 +48,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * The caller is responsible for eventually calling free() on the * allocated ASN.1 cursor. */ -int der_asn1 ( userptr_t data, size_t len, size_t offset, +int der_asn1 ( const void *data, size_t len, size_t offset, struct asn1_cursor **cursor ) { size_t remaining; void *raw; @@ -67,7 +66,7 @@ int der_asn1 ( userptr_t data, size_t len, size_t offset, /* Populate cursor and data buffer */ (*cursor)->data = raw; (*cursor)->len = remaining; - copy_from_user ( raw, data, offset, remaining ); + memcpy ( raw, ( data + offset ), remaining ); /* Shrink cursor */ asn1_shrink_any ( *cursor ); @@ -83,30 +82,21 @@ int der_asn1 ( userptr_t data, size_t len, size_t offset, */ static int der_image_probe ( struct image *image ) { struct asn1_cursor cursor; - uint8_t buf[8]; - size_t extra; int rc; - /* Sanity check: no realistic DER image can be smaller than this */ - if ( image->len < sizeof ( buf ) ) - return -ENOEXEC; - - /* Prepare partial cursor */ - cursor.data = buf; - cursor.len = sizeof ( buf ); - copy_from_user ( buf, image->data, 0, sizeof ( buf ) ); - extra = ( image->len - sizeof ( buf ) ); + /* Prepare cursor */ + cursor.data = image->data; + cursor.len = image->len; /* Check that image begins with an ASN.1 sequence object */ - if ( ( rc = asn1_enter_partial ( &cursor, ASN1_SEQUENCE, - &extra ) ) != 0 ) { + if ( ( rc = asn1_skip ( &cursor, ASN1_SEQUENCE ) ) != 0 ) { DBGC ( image, "DER %s is not valid ASN.1: %s\n", image->name, strerror ( rc ) ); return rc; } /* Check that image comprises a single well-formed ASN.1 object */ - if ( extra != ( image->len - sizeof ( buf ) ) ) { + if ( cursor.len ) { DBGC ( image, "DER %s is not single ASN.1\n", image->name ); return -ENOEXEC; } diff --git a/src/image/efi_siglist.c b/src/image/efi_siglist.c index 56c8493d6..2bd273dbd 100644 --- a/src/image/efi_siglist.c +++ b/src/image/efi_siglist.c @@ -49,8 +49,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * @v dhdr Signature data header to fill in * @ret rc Return status code */ -static int efisig_find ( userptr_t data, size_t len, size_t *start, - EFI_SIGNATURE_LIST *lhdr, EFI_SIGNATURE_DATA *dhdr ) { +static int efisig_find ( const void *data, size_t len, size_t *start, + const EFI_SIGNATURE_LIST **lhdr, + const EFI_SIGNATURE_DATA **dhdr ) { size_t offset; size_t remaining; size_t skip; @@ -63,38 +64,38 @@ static int efisig_find ( userptr_t data, size_t len, size_t *start, /* Read list header */ assert ( offset <= len ); remaining = ( len - offset ); - if ( remaining < sizeof ( *lhdr ) ) { + if ( remaining < sizeof ( **lhdr ) ) { DBGC ( data, "EFISIG [%#zx,%#zx) truncated header " "at +%#zx\n", *start, len, offset ); return -EINVAL; } - copy_from_user ( lhdr, data, offset, sizeof ( *lhdr ) ); + *lhdr = ( data + offset ); /* Get length of this signature list */ - if ( remaining < lhdr->SignatureListSize ) { + if ( remaining < (*lhdr)->SignatureListSize ) { DBGC ( data, "EFISIG [%#zx,%#zx) truncated list at " "+%#zx\n", *start, len, offset ); return -EINVAL; } - remaining = lhdr->SignatureListSize; + remaining = (*lhdr)->SignatureListSize; /* Get length of each signature in list */ - dlen = lhdr->SignatureSize; - if ( dlen < sizeof ( *dhdr ) ) { + dlen = (*lhdr)->SignatureSize; + if ( dlen < sizeof ( **dhdr ) ) { DBGC ( data, "EFISIG [%#zx,%#zx) underlength " "signatures at +%#zx\n", *start, len, offset ); return -EINVAL; } /* Strip list header (including variable portion) */ - if ( ( remaining < sizeof ( *lhdr ) ) || - ( ( remaining - sizeof ( *lhdr ) ) < - lhdr->SignatureHeaderSize ) ) { + if ( ( remaining < sizeof ( **lhdr ) ) || + ( ( remaining - sizeof ( **lhdr ) ) < + (*lhdr)->SignatureHeaderSize ) ) { DBGC ( data, "EFISIG [%#zx,%#zx) malformed header at " "+%#zx\n", *start, len, offset ); return -EINVAL; } - skip = ( sizeof ( *lhdr ) + lhdr->SignatureHeaderSize ); + skip = ( sizeof ( **lhdr ) + (*lhdr)->SignatureHeaderSize ); offset += skip; remaining -= skip; @@ -113,12 +114,12 @@ static int efisig_find ( userptr_t data, size_t len, size_t *start, continue; /* Read data header */ - copy_from_user ( dhdr, data, offset, sizeof ( *dhdr )); + *dhdr = ( data + offset ); DBGC2 ( data, "EFISIG [%#zx,%#zx) %s ", offset, ( offset + dlen ), - efi_guid_ntoa ( &lhdr->SignatureType ) ); + efi_guid_ntoa ( &(*lhdr)->SignatureType ) ); DBGC2 ( data, "owner %s\n", - efi_guid_ntoa ( &dhdr->SignatureOwner ) ); + efi_guid_ntoa ( &(*dhdr)->SignatureOwner ) ); *start = offset; return 0; } @@ -137,23 +138,23 @@ static int efisig_find ( userptr_t data, size_t len, size_t *start, * The caller is responsible for eventually calling free() on the * allocated ASN.1 cursor. */ -int efisig_asn1 ( userptr_t data, size_t len, size_t offset, +int efisig_asn1 ( const void *data, size_t len, size_t offset, struct asn1_cursor **cursor ) { - EFI_SIGNATURE_LIST lhdr; - EFI_SIGNATURE_DATA dhdr; - int ( * asn1 ) ( userptr_t data, size_t len, size_t offset, + const EFI_SIGNATURE_LIST *lhdr; + const EFI_SIGNATURE_DATA *dhdr; + int ( * asn1 ) ( const void *data, size_t len, size_t offset, struct asn1_cursor **cursor ); - size_t skip = offsetof ( typeof ( dhdr ), SignatureData ); + size_t skip = offsetof ( typeof ( *dhdr ), SignatureData ); int next; int rc; /* Locate signature list entry */ if ( ( rc = efisig_find ( data, len, &offset, &lhdr, &dhdr ) ) != 0 ) goto err_entry; - len = ( offset + lhdr.SignatureSize ); + len = ( offset + lhdr->SignatureSize ); /* Parse as PEM or DER based on first character */ - asn1 = ( ( dhdr.SignatureData[0] == ASN1_SEQUENCE ) ? + asn1 = ( ( dhdr->SignatureData[0] == ASN1_SEQUENCE ) ? der_asn1 : pem_asn1 ); DBGC2 ( data, "EFISIG [%#zx,%#zx) extracting %s\n", offset, len, ( ( asn1 == der_asn1 ) ? "DER" : "PEM" ) ); @@ -189,8 +190,8 @@ int efisig_asn1 ( userptr_t data, size_t len, size_t offset, * @ret rc Return status code */ static int efisig_image_probe ( struct image *image ) { - EFI_SIGNATURE_LIST lhdr; - EFI_SIGNATURE_DATA dhdr; + const EFI_SIGNATURE_LIST *lhdr; + const EFI_SIGNATURE_DATA *dhdr; size_t offset = 0; unsigned int count = 0; int rc; @@ -205,7 +206,7 @@ static int efisig_image_probe ( struct image *image ) { } /* Skip this entry */ - offset += lhdr.SignatureSize; + offset += lhdr->SignatureSize; count++; /* Check if we have reached end of the image */ diff --git a/src/image/pem.c b/src/image/pem.c index 2dcc36442..caff822ad 100644 --- a/src/image/pem.c +++ b/src/image/pem.c @@ -28,7 +28,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include #include #include @@ -46,14 +45,14 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * @v offset Starting offset * @ret next Offset to next line */ -static size_t pem_next ( userptr_t data, size_t len, size_t offset ) { - off_t eol; +static size_t pem_next ( const void *data, size_t len, size_t offset ) { + const void *sep; /* Find and skip next newline character, if any */ - eol = memchr_user ( data, offset, '\n', ( len - offset ) ); - if ( eol < 0 ) + sep = memchr ( ( data + offset ), '\n', ( len - offset ) ); + if ( ! sep ) return len; - return ( eol + 1 ); + return ( ( sep - data ) + 1 ); } /** @@ -65,9 +64,9 @@ static size_t pem_next ( userptr_t data, size_t len, size_t offset ) { * @v marker Boundary marker * @ret offset Offset to boundary marker line, or negative error */ -static int pem_marker ( userptr_t data, size_t len, size_t offset, +static int pem_marker ( const void *data, size_t len, size_t offset, const char *marker ) { - char buf[ strlen ( marker ) ]; + size_t marker_len = strlen ( marker ); /* Sanity check */ assert ( offset <= len ); @@ -76,10 +75,9 @@ static int pem_marker ( userptr_t data, size_t len, size_t offset, while ( offset < len ) { /* Check for marker */ - if ( ( len - offset ) < sizeof ( buf ) ) + if ( ( len - offset ) < marker_len ) break; - copy_from_user ( buf, data, offset, sizeof ( buf ) ); - if ( memcmp ( buf, marker, sizeof ( buf ) ) == 0 ) + if ( memcmp ( ( data + offset ), marker, marker_len ) == 0 ) return offset; /* Move to next line */ @@ -102,7 +100,7 @@ static int pem_marker ( userptr_t data, size_t len, size_t offset, * The caller is responsible for eventually calling free() on the * allocated ASN.1 cursor. */ -int pem_asn1 ( userptr_t data, size_t len, size_t offset, +int pem_asn1 ( const void *data, size_t len, size_t offset, struct asn1_cursor **cursor ) { size_t encoded_len; size_t decoded_max_len; @@ -140,7 +138,7 @@ int pem_asn1 ( userptr_t data, size_t len, size_t offset, rc = -ENOMEM; goto err_alloc_encoded; } - copy_from_user ( encoded, data, begin, encoded_len ); + memcpy ( encoded, ( data + begin ), encoded_len ); encoded[encoded_len] = '\0'; /* Allocate cursor and data buffer */ diff --git a/src/include/ipxe/asn1.h b/src/include/ipxe/asn1.h index 8a7461cd3..9528c40f5 100644 --- a/src/include/ipxe/asn1.h +++ b/src/include/ipxe/asn1.h @@ -481,8 +481,6 @@ asn1_built ( struct asn1_builder *builder ) { return &u->cursor; } -extern int asn1_enter_partial ( struct asn1_cursor *cursor, unsigned int type, - size_t *extra ); extern int asn1_enter ( struct asn1_cursor *cursor, unsigned int type ); extern int asn1_skip_if_exists ( struct asn1_cursor *cursor, unsigned int type ); diff --git a/src/include/ipxe/der.h b/src/include/ipxe/der.h index 983aeb23c..512bc0853 100644 --- a/src/include/ipxe/der.h +++ b/src/include/ipxe/der.h @@ -13,7 +13,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include -extern int der_asn1 ( userptr_t data, size_t len, size_t offset, +extern int der_asn1 ( const void *data, size_t len, size_t offset, struct asn1_cursor **cursor ); extern struct image_type der_image_type __image_type ( PROBE_NORMAL ); diff --git a/src/include/ipxe/efi/efi_siglist.h b/src/include/ipxe/efi/efi_siglist.h index 177f28b00..cbc835dc0 100644 --- a/src/include/ipxe/efi/efi_siglist.h +++ b/src/include/ipxe/efi/efi_siglist.h @@ -10,11 +10,10 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include -#include #include #include -extern int efisig_asn1 ( userptr_t data, size_t len, size_t offset, +extern int efisig_asn1 ( const void *data, size_t len, size_t offset, struct asn1_cursor **cursor ); extern struct image_type efisig_image_type __image_type ( PROBE_NORMAL ); diff --git a/src/include/ipxe/pem.h b/src/include/ipxe/pem.h index d88ec5b6f..d9ca017d5 100644 --- a/src/include/ipxe/pem.h +++ b/src/include/ipxe/pem.h @@ -10,7 +10,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include -#include #include #include @@ -20,7 +19,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /** Post-encapsulation boundary marker */ #define PEM_END "-----END" -extern int pem_asn1 ( userptr_t data, size_t len, size_t offset, +extern int pem_asn1 ( const void *data, size_t len, size_t offset, struct asn1_cursor **cursor ); extern struct image_type pem_image_type __image_type ( PROBE_NORMAL ); diff --git a/src/interface/efi/efi_cacert.c b/src/interface/efi/efi_cacert.c index 5cc268b0e..2b6c5c343 100644 --- a/src/interface/efi/efi_cacert.c +++ b/src/interface/efi/efi_cacert.c @@ -54,14 +54,14 @@ static struct x509_chain efi_cacerts = { * @v offset Offset within data * @v next Next offset, or negative error */ -static int efi_cacert ( void *data, size_t len, size_t offset ) { +static int efi_cacert ( const void *data, size_t len, size_t offset ) { struct asn1_cursor *cursor; struct x509_certificate *cert; int next; int rc; /* Extract ASN.1 object */ - next = efisig_asn1 ( virt_to_user ( data ), len, offset, &cursor ); + next = efisig_asn1 ( data, len, offset, &cursor ); if ( next < 0 ) { rc = next; DBGC ( &efi_cacerts, "EFICA could not parse at +%#zx: %s\n", -- cgit v1.2.3-55-g7522 From 0b3fc48fefd311b17b666fecf3a34688717727e8 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 22 Apr 2025 14:13:45 +0100 Subject: [acpi] Remove userptr_t from ACPI table parsing Simplify the ACPI table parsing code by assuming that all table content is fully accessible via pointer dereferences. Signed-off-by: Michael Brown --- src/arch/x86/include/ipxe/rsdp.h | 4 +- src/arch/x86/interface/pcbios/acpi_timer.c | 9 +-- src/arch/x86/interface/pcbios/acpipwr.c | 18 ++--- src/arch/x86/interface/pcbios/rsdp.c | 33 ++++---- src/core/acpi.c | 116 +++++++++++++---------------- src/core/acpi_settings.c | 21 +++--- src/core/acpimac.c | 17 +++-- src/drivers/bus/ecam.c | 34 ++++----- src/include/ipxe/acpi.h | 24 +++--- src/include/ipxe/efi/efi_acpi.h | 4 +- src/include/ipxe/null_acpi.h | 6 +- src/interface/efi/efi_acpi.c | 7 +- src/interface/linux/linux_acpi.c | 9 ++- src/tests/acpi_test.c | 12 +-- 14 files changed, 152 insertions(+), 162 deletions(-) (limited to 'src/drivers') diff --git a/src/arch/x86/include/ipxe/rsdp.h b/src/arch/x86/include/ipxe/rsdp.h index 14afcd774..daaa43077 100644 --- a/src/arch/x86/include/ipxe/rsdp.h +++ b/src/arch/x86/include/ipxe/rsdp.h @@ -20,9 +20,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * * @v signature Requested table signature * @v index Requested index of table with this signature - * @ret table Table, or UNULL if not found + * @ret table Table, or NULL if not found */ -static inline __attribute__ (( always_inline )) userptr_t +static inline __attribute__ (( always_inline )) const struct acpi_header * ACPI_INLINE ( rsdp, acpi_find ) ( uint32_t signature, unsigned int index ) { return acpi_find_via_rsdt ( signature, index ); diff --git a/src/arch/x86/interface/pcbios/acpi_timer.c b/src/arch/x86/interface/pcbios/acpi_timer.c index 2e4047e38..e1523578b 100644 --- a/src/arch/x86/interface/pcbios/acpi_timer.c +++ b/src/arch/x86/interface/pcbios/acpi_timer.c @@ -102,20 +102,19 @@ static void acpi_udelay ( unsigned long usecs ) { * @ret rc Return status code */ static int acpi_timer_probe ( void ) { - struct acpi_fadt fadtab; - userptr_t fadt; + const struct acpi_fadt *fadt; unsigned int pm_tmr_blk; /* Locate FADT */ - fadt = acpi_table ( FADT_SIGNATURE, 0 ); + fadt = container_of ( acpi_table ( FADT_SIGNATURE, 0 ), + struct acpi_fadt, acpi ); if ( ! fadt ) { DBGC ( &acpi_timer, "ACPI could not find FADT\n" ); return -ENOENT; } /* Read FADT */ - copy_from_user ( &fadtab, fadt, 0, sizeof ( fadtab ) ); - pm_tmr_blk = le32_to_cpu ( fadtab.pm_tmr_blk ); + pm_tmr_blk = le32_to_cpu ( fadt->pm_tmr_blk ); if ( ! pm_tmr_blk ) { DBGC ( &acpi_timer, "ACPI has no timer\n" ); return -ENOENT; diff --git a/src/arch/x86/interface/pcbios/acpipwr.c b/src/arch/x86/interface/pcbios/acpipwr.c index f08b4af25..bff53806b 100644 --- a/src/arch/x86/interface/pcbios/acpipwr.c +++ b/src/arch/x86/interface/pcbios/acpipwr.c @@ -62,8 +62,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * uglier hacks I have ever implemented, but it's still prettier than * the ACPI specification itself. */ -static int acpi_extract_sx ( userptr_t zsdt, size_t len, size_t offset, - void *data ) { +static int acpi_extract_sx ( const struct acpi_header *zsdt, size_t len, + size_t offset, void *data ) { unsigned int *sx = data; uint8_t bytes[4]; uint8_t *byte; @@ -77,7 +77,8 @@ static int acpi_extract_sx ( userptr_t zsdt, size_t len, size_t offset, } /* Read first four bytes of value */ - copy_from_user ( bytes, zsdt, offset, sizeof ( bytes ) ); + memcpy ( bytes, ( ( ( const void * ) zsdt ) + offset ), + sizeof ( bytes ) ); DBGC ( colour, "ACPI found \\_Sx containing %02x:%02x:%02x:%02x\n", bytes[0], bytes[1], bytes[2], bytes[3] ); @@ -111,8 +112,7 @@ static int acpi_extract_sx ( userptr_t zsdt, size_t len, size_t offset, * @ret rc Return status code */ int acpi_poweroff ( void ) { - struct acpi_fadt fadtab; - userptr_t fadt; + const struct acpi_fadt *fadt; unsigned int pm1a_cnt_blk; unsigned int pm1b_cnt_blk; unsigned int pm1a_cnt; @@ -123,16 +123,16 @@ int acpi_poweroff ( void ) { int rc; /* Locate FADT */ - fadt = acpi_table ( FADT_SIGNATURE, 0 ); + fadt = container_of ( acpi_table ( FADT_SIGNATURE, 0 ), + struct acpi_fadt, acpi ); if ( ! fadt ) { DBGC ( colour, "ACPI could not find FADT\n" ); return -ENOENT; } /* Read FADT */ - copy_from_user ( &fadtab, fadt, 0, sizeof ( fadtab ) ); - pm1a_cnt_blk = le32_to_cpu ( fadtab.pm1a_cnt_blk ); - pm1b_cnt_blk = le32_to_cpu ( fadtab.pm1b_cnt_blk ); + pm1a_cnt_blk = le32_to_cpu ( fadt->pm1a_cnt_blk ); + pm1b_cnt_blk = le32_to_cpu ( fadt->pm1b_cnt_blk ); pm1a_cnt = ( pm1a_cnt_blk + ACPI_PM1_CNT ); pm1b_cnt = ( pm1b_cnt_blk + ACPI_PM1_CNT ); diff --git a/src/arch/x86/interface/pcbios/rsdp.c b/src/arch/x86/interface/pcbios/rsdp.c index c2534c7f6..6bcf19b18 100644 --- a/src/arch/x86/interface/pcbios/rsdp.c +++ b/src/arch/x86/interface/pcbios/rsdp.c @@ -53,50 +53,51 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * * @v start Start address to search * @v len Length to search - * @ret rsdt ACPI root system description table, or UNULL + * @ret rsdt ACPI root system description table, or NULL */ -static userptr_t rsdp_find_rsdt_range ( userptr_t start, size_t len ) { +static const struct acpi_rsdt * rsdp_find_rsdt_range ( const void *start, + size_t len ) { static const char signature[8] = RSDP_SIGNATURE; - struct acpi_rsdp rsdp; - userptr_t rsdt; + const struct acpi_rsdp *rsdp; + const struct acpi_rsdt *rsdt; size_t offset; uint8_t sum; unsigned int i; /* Search for RSDP */ - for ( offset = 0 ; ( ( offset + sizeof ( rsdp ) ) < len ) ; + for ( offset = 0 ; ( ( offset + sizeof ( *rsdp ) ) < len ) ; offset += RSDP_STRIDE ) { /* Check signature and checksum */ - copy_from_user ( &rsdp, start, offset, sizeof ( rsdp ) ); - if ( memcmp ( rsdp.signature, signature, + rsdp = ( start + offset ); + if ( memcmp ( rsdp->signature, signature, sizeof ( signature ) ) != 0 ) continue; - for ( sum = 0, i = 0 ; i < sizeof ( rsdp ) ; i++ ) - sum += *( ( ( uint8_t * ) &rsdp ) + i ); + for ( sum = 0, i = 0 ; i < sizeof ( *rsdp ) ; i++ ) + sum += *( ( ( uint8_t * ) rsdp ) + i ); if ( sum != 0 ) continue; /* Extract RSDT */ - rsdt = phys_to_virt ( le32_to_cpu ( rsdp.rsdt ) ); + rsdt = phys_to_virt ( le32_to_cpu ( rsdp->rsdt ) ); DBGC ( rsdt, "RSDT %#08lx found via RSDP %#08lx\n", virt_to_phys ( rsdt ), ( virt_to_phys ( start ) + offset ) ); return rsdt; } - return UNULL; + return NULL; } /** * Locate ACPI root system description table * - * @ret rsdt ACPI root system description table, or UNULL + * @ret rsdt ACPI root system description table, or NULL */ -static userptr_t rsdp_find_rsdt ( void ) { - static userptr_t rsdt; +static const struct acpi_rsdt * rsdp_find_rsdt ( void ) { + static const struct acpi_rsdt *rsdt; + const void *ebda; uint16_t ebda_seg; - userptr_t ebda; size_t ebda_len; /* Return existing RSDT if already found */ @@ -119,7 +120,7 @@ static userptr_t rsdp_find_rsdt ( void ) { if ( rsdt ) return rsdt; - return UNULL; + return NULL; } PROVIDE_ACPI ( rsdp, acpi_find_rsdt, rsdp_find_rsdt ); diff --git a/src/core/acpi.c b/src/core/acpi.c index d7da0ccc1..6c5d1e079 100644 --- a/src/core/acpi.c +++ b/src/core/acpi.c @@ -23,6 +23,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +#include #include #include #include @@ -54,25 +55,17 @@ typeof ( acpi_find ) *acpi_finder __attribute__ (( weak )) = acpi_find; /** * Compute ACPI table checksum * - * @v table Any ACPI table + * @v acpi Any ACPI table header * @ret checksum 0 if checksum is good */ -static uint8_t acpi_checksum ( userptr_t table ) { - struct acpi_header acpi; +static uint8_t acpi_checksum ( const struct acpi_header *acpi ) { + const uint8_t *byte = ( ( const void * ) acpi ); + size_t len = le32_to_cpu ( acpi->length ); uint8_t sum = 0; - uint8_t data = 0; - unsigned int i; - - /* Read table length */ - copy_from_user ( &acpi.length, table, - offsetof ( typeof ( acpi ), length ), - sizeof ( acpi.length ) ); /* Compute checksum */ - for ( i = 0 ; i < le32_to_cpu ( acpi.length ) ; i++ ) { - copy_from_user ( &data, table, i, sizeof ( data ) ); - sum += data; - } + while ( len-- ) + sum += *(byte++); return sum; } @@ -85,7 +78,7 @@ static uint8_t acpi_checksum ( userptr_t table ) { void acpi_fix_checksum ( struct acpi_header *acpi ) { /* Update checksum */ - acpi->checksum -= acpi_checksum ( virt_to_user ( acpi ) ); + acpi->checksum -= acpi_checksum ( acpi ); } /** @@ -93,9 +86,10 @@ void acpi_fix_checksum ( struct acpi_header *acpi ) { * * @v signature Requested table signature * @v index Requested index of table with this signature - * @ret table Table, or UNULL if not found + * @ret table Table, or NULL if not found */ -userptr_t acpi_table ( uint32_t signature, unsigned int index ) { +const struct acpi_header * acpi_table ( uint32_t signature, + unsigned int index ) { return ( *acpi_finder ) ( signature, index ); } @@ -105,14 +99,12 @@ userptr_t acpi_table ( uint32_t signature, unsigned int index ) { * * @v signature Requested table signature * @v index Requested index of table with this signature - * @ret table Table, or UNULL if not found + * @ret table Table, or NULL if not found */ -userptr_t acpi_find_via_rsdt ( uint32_t signature, unsigned int index ) { - struct acpi_header acpi; - struct acpi_rsdt *rsdtab; - typeof ( rsdtab->entry[0] ) entry; - userptr_t rsdt; - userptr_t table; +const struct acpi_header * acpi_find_via_rsdt ( uint32_t signature, + unsigned int index ) { + const struct acpi_rsdt *rsdt; + const struct acpi_header *table; size_t len; unsigned int count; unsigned int i; @@ -121,45 +113,38 @@ userptr_t acpi_find_via_rsdt ( uint32_t signature, unsigned int index ) { rsdt = acpi_find_rsdt(); if ( ! rsdt ) { DBG ( "RSDT not found\n" ); - return UNULL; + return NULL; } /* Read RSDT header */ - copy_from_user ( &acpi, rsdt, 0, sizeof ( acpi ) ); - if ( acpi.signature != cpu_to_le32 ( RSDT_SIGNATURE ) ) { + if ( rsdt->acpi.signature != cpu_to_le32 ( RSDT_SIGNATURE ) ) { DBGC ( colour, "RSDT %#08lx has invalid signature:\n", virt_to_phys ( rsdt ) ); - DBGC_HDA ( colour, virt_to_phys ( rsdt ), &acpi, - sizeof ( acpi ) ); - return UNULL; + DBGC_HDA ( colour, virt_to_phys ( rsdt ), &rsdt->acpi, + sizeof ( rsdt->acpi ) ); + return NULL; } - len = le32_to_cpu ( acpi.length ); - if ( len < sizeof ( rsdtab->acpi ) ) { + len = le32_to_cpu ( rsdt->acpi.length ); + if ( len < sizeof ( rsdt->acpi ) ) { DBGC ( colour, "RSDT %#08lx has invalid length:\n", virt_to_phys ( rsdt ) ); - DBGC_HDA ( colour, virt_to_phys ( rsdt ), &acpi, - sizeof ( acpi ) ); - return UNULL; + DBGC_HDA ( colour, virt_to_phys ( rsdt ), &rsdt->acpi, + sizeof ( rsdt->acpi ) ); + return NULL; } /* Calculate number of entries */ - count = ( ( len - sizeof ( rsdtab->acpi ) ) / sizeof ( entry ) ); + count = ( ( len - sizeof ( rsdt->acpi ) ) / + sizeof ( rsdt->entry[0] ) ); /* Search through entries */ for ( i = 0 ; i < count ; i++ ) { - /* Get table address */ - copy_from_user ( &entry, rsdt, - offsetof ( typeof ( *rsdtab ), entry[i] ), - sizeof ( entry ) ); - /* Read table header */ - table = phys_to_virt ( entry ); - copy_from_user ( &acpi.signature, table, 0, - sizeof ( acpi.signature ) ); + table = phys_to_virt ( rsdt->entry[i] ); /* Check table signature */ - if ( acpi.signature != cpu_to_le32 ( signature ) ) + if ( table->signature != cpu_to_le32 ( signature ) ) continue; /* Check index */ @@ -169,13 +154,13 @@ userptr_t acpi_find_via_rsdt ( uint32_t signature, unsigned int index ) { /* Check table integrity */ if ( acpi_checksum ( table ) != 0 ) { DBGC ( colour, "RSDT %#08lx found %s with bad " - "checksum at %08lx\n", virt_to_phys ( rsdt ), + "checksum at %#08lx\n", virt_to_phys ( rsdt ), acpi_name ( signature ), virt_to_phys ( table ) ); break; } - DBGC ( colour, "RSDT %#08lx found %s at %08lx\n", + DBGC ( colour, "RSDT %#08lx found %s at %#08lx\n", virt_to_phys ( rsdt ), acpi_name ( signature ), virt_to_phys ( table ) ); return table; @@ -183,7 +168,7 @@ userptr_t acpi_find_via_rsdt ( uint32_t signature, unsigned int index ) { DBGC ( colour, "RSDT %#08lx could not find %s\n", virt_to_phys ( rsdt ), acpi_name ( signature ) ); - return UNULL; + return NULL; } /** @@ -195,26 +180,27 @@ userptr_t acpi_find_via_rsdt ( uint32_t signature, unsigned int index ) { * @v extract Extraction method * @ret rc Return status code */ -static int acpi_zsdt ( userptr_t zsdt, uint32_t signature, void *data, - int ( * extract ) ( userptr_t zsdt, size_t len, - size_t offset, void *data ) ) { - struct acpi_header acpi; +static int acpi_zsdt ( const struct acpi_header *zsdt, + uint32_t signature, void *data, + int ( * extract ) ( const struct acpi_header *zsdt, + size_t len, size_t offset, + void *data ) ) { uint32_t buf; size_t offset; size_t len; int rc; /* Read table header */ - copy_from_user ( &acpi, zsdt, 0, sizeof ( acpi ) ); - len = le32_to_cpu ( acpi.length ); + len = le32_to_cpu ( zsdt->length ); /* Locate signature */ - for ( offset = sizeof ( acpi ) ; + for ( offset = sizeof ( *zsdt ) ; ( ( offset + sizeof ( buf ) /* signature */ ) < len ) ; offset++ ) { /* Check signature */ - copy_from_user ( &buf, zsdt, offset, sizeof ( buf ) ); + memcpy ( &buf, ( ( ( const void * ) zsdt ) + offset ), + sizeof ( buf ) ); if ( buf != cpu_to_le32 ( signature ) ) continue; DBGC ( zsdt, "DSDT/SSDT %#08lx found %s at offset %#zx\n", @@ -238,20 +224,20 @@ static int acpi_zsdt ( userptr_t zsdt, uint32_t signature, void *data, * @ret rc Return status code */ int acpi_extract ( uint32_t signature, void *data, - int ( * extract ) ( userptr_t zsdt, size_t len, - size_t offset, void *data ) ) { - struct acpi_fadt fadtab; - userptr_t fadt; - userptr_t dsdt; - userptr_t ssdt; + int ( * extract ) ( const struct acpi_header *zsdt, + size_t len, size_t offset, + void *data ) ) { + const struct acpi_fadt *fadt; + const struct acpi_header *dsdt; + const struct acpi_header *ssdt; unsigned int i; int rc; /* Try DSDT first */ - fadt = acpi_table ( FADT_SIGNATURE, 0 ); + fadt = container_of ( acpi_table ( FADT_SIGNATURE, 0 ), + struct acpi_fadt, acpi ); if ( fadt ) { - copy_from_user ( &fadtab, fadt, 0, sizeof ( fadtab ) ); - dsdt = phys_to_virt ( fadtab.dsdt ); + dsdt = phys_to_virt ( fadt->dsdt ); if ( ( rc = acpi_zsdt ( dsdt, signature, data, extract ) ) == 0 ) return 0; diff --git a/src/core/acpi_settings.c b/src/core/acpi_settings.c index b9e2b7f61..cdee1f865 100644 --- a/src/core/acpi_settings.c +++ b/src/core/acpi_settings.c @@ -64,14 +64,15 @@ static int acpi_settings_applies ( struct settings *settings __unused, static int acpi_settings_fetch ( struct settings *settings, struct setting *setting, void *data, size_t len ) { - struct acpi_header acpi; + const struct acpi_header *acpi; + const uint8_t *src; + uint8_t *dst; uint32_t tag_high; uint32_t tag_low; uint32_t tag_signature; unsigned int tag_index; size_t tag_offset; size_t tag_len; - userptr_t table; size_t offset; size_t max_len; int delta; @@ -88,15 +89,12 @@ static int acpi_settings_fetch ( struct settings *settings, acpi_name ( tag_signature ), tag_index, tag_offset, tag_len ); /* Locate ACPI table */ - table = acpi_table ( tag_signature, tag_index ); - if ( ! table ) + acpi = acpi_table ( tag_signature, tag_index ); + if ( ! acpi ) return -ENOENT; - /* Read table header */ - copy_from_user ( &acpi, table, 0, sizeof ( acpi ) ); - /* Calculate starting offset and maximum available length */ - max_len = le32_to_cpu ( acpi.length ); + max_len = le32_to_cpu ( acpi->length ); if ( tag_offset > max_len ) return -ENOENT; offset = tag_offset; @@ -115,10 +113,11 @@ static int acpi_settings_fetch ( struct settings *settings, } /* Read data */ + src = ( ( ( const void * ) acpi ) + offset ); + dst = data; for ( i = 0 ; ( ( i < max_len ) && ( i < len ) ) ; i++ ) { - copy_from_user ( data, table, offset, 1 ); - data++; - offset += delta; + *(dst++) = *src; + src += delta; } /* Set type if not already specified */ diff --git a/src/core/acpimac.c b/src/core/acpimac.c index e0074ba43..11ac3243e 100644 --- a/src/core/acpimac.c +++ b/src/core/acpimac.c @@ -142,8 +142,9 @@ static struct acpimac_extractor acpimac_rtxmac = { * string that appears shortly after an "AMAC" or "MACA" signature. * This should work for most implementations encountered in practice. */ -static int acpimac_extract ( userptr_t zsdt, size_t len, size_t offset, - void *data, struct acpimac_extractor *extractor ){ +static int acpimac_extract ( const struct acpi_header *zsdt, size_t len, + size_t offset, void *data, + struct acpimac_extractor *extractor ) { size_t prefix_len = strlen ( extractor->prefix ); uint8_t *hw_addr = data; size_t skip = 0; @@ -161,8 +162,8 @@ static int acpimac_extract ( userptr_t zsdt, size_t len, size_t offset, skip++ ) { /* Read value */ - copy_from_user ( buf, zsdt, ( offset + skip ), - sizeof ( buf ) ); + memcpy ( buf, ( ( ( const void * ) zsdt ) + offset + skip ), + sizeof ( buf ) ); /* Check for expected format */ if ( memcmp ( buf, extractor->prefix, prefix_len ) != 0 ) @@ -203,8 +204,8 @@ static int acpimac_extract ( userptr_t zsdt, size_t len, size_t offset, * @v data Data buffer * @ret rc Return status code */ -static int acpimac_extract_auxmac ( userptr_t zsdt, size_t len, size_t offset, - void *data ) { +static int acpimac_extract_auxmac ( const struct acpi_header *zsdt, + size_t len, size_t offset, void *data ) { return acpimac_extract ( zsdt, len, offset, data, &acpimac_auxmac ); } @@ -218,8 +219,8 @@ static int acpimac_extract_auxmac ( userptr_t zsdt, size_t len, size_t offset, * @v data Data buffer * @ret rc Return status code */ -static int acpimac_extract_rtxmac ( userptr_t zsdt, size_t len, size_t offset, - void *data ) { +static int acpimac_extract_rtxmac ( const struct acpi_header *zsdt, + size_t len, size_t offset, void *data ) { return acpimac_extract ( zsdt, len, offset, data, &acpimac_rtxmac ); } diff --git a/src/drivers/bus/ecam.c b/src/drivers/bus/ecam.c index cde5952b8..58d513e88 100644 --- a/src/drivers/bus/ecam.c +++ b/src/drivers/bus/ecam.c @@ -46,49 +46,43 @@ static struct ecam_mapping ecam; */ static int ecam_find ( uint32_t busdevfn, struct pci_range *range, struct ecam_allocation *alloc ) { - struct ecam_allocation tmp; + struct ecam_table *mcfg; + struct ecam_allocation *tmp; unsigned int best = 0; - unsigned int offset; unsigned int count; unsigned int index; - userptr_t mcfg; - uint32_t length; + unsigned int i; uint32_t start; /* Return empty range on error */ range->count = 0; /* Locate MCFG table */ - mcfg = acpi_table ( ECAM_SIGNATURE, 0 ); + mcfg = container_of ( acpi_table ( ECAM_SIGNATURE, 0 ), + struct ecam_table, acpi ); if ( ! mcfg ) { DBGC ( &ecam, "ECAM found no MCFG table\n" ); return -ENOTSUP; } - /* Get length of table */ - copy_from_user ( &length, mcfg, - offsetof ( struct ecam_table, acpi.length ), - sizeof ( length ) ); - /* Iterate over allocations */ - for ( offset = offsetof ( struct ecam_table, alloc ) ; - ( offset + sizeof ( tmp ) ) <= le32_to_cpu ( length ) ; - offset += sizeof ( tmp ) ) { + for ( i = 0 ; ( offsetof ( typeof ( *mcfg ), alloc[ i + 1 ] ) <= + le32_to_cpu ( mcfg->acpi.length ) ) ; i++ ) { /* Read allocation */ - copy_from_user ( &tmp, mcfg, offset, sizeof ( tmp ) ); + tmp = &mcfg->alloc[i]; DBGC2 ( &ecam, "ECAM %04x:[%02x-%02x] has base %08llx\n", - le16_to_cpu ( tmp.segment ), tmp.start, tmp.end, - ( ( unsigned long long ) le64_to_cpu ( tmp.base ) ) ); - start = PCI_BUSDEVFN ( le16_to_cpu ( tmp.segment ), - tmp.start, 0, 0 ); - count = PCI_BUSDEVFN ( 0, ( tmp.end - tmp.start + 1 ), 0, 0 ); + le16_to_cpu ( tmp->segment ), tmp->start, tmp->end, + ( ( unsigned long long ) le64_to_cpu ( tmp->base ) ) ); + start = PCI_BUSDEVFN ( le16_to_cpu ( tmp->segment ), + tmp->start, 0, 0 ); + count = PCI_BUSDEVFN ( 0, ( tmp->end - tmp->start + 1 ), 0, 0 ); /* Check for a matching or new closest allocation */ index = ( busdevfn - start ); if ( ( index < count ) || ( index > best ) ) { if ( alloc ) - memcpy ( alloc, &tmp, sizeof ( *alloc ) ); + memcpy ( alloc, tmp, sizeof ( *alloc ) ); range->start = start; range->count = count; best = index; diff --git a/src/include/ipxe/acpi.h b/src/include/ipxe/acpi.h index c34681238..40a44cffc 100644 --- a/src/include/ipxe/acpi.h +++ b/src/include/ipxe/acpi.h @@ -14,7 +14,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include #include #include #include @@ -355,7 +354,8 @@ struct acpi_model { #define PROVIDE_ACPI_INLINE( _subsys, _api_func ) \ PROVIDE_SINGLE_API_INLINE ( ACPI_PREFIX_ ## _subsys, _api_func ) -extern userptr_t acpi_find_via_rsdt ( uint32_t signature, unsigned int index ); +extern const struct acpi_header * acpi_find_via_rsdt ( uint32_t signature, + unsigned int index ); /* Include all architecture-independent ACPI API headers */ #include @@ -368,31 +368,35 @@ extern userptr_t acpi_find_via_rsdt ( uint32_t signature, unsigned int index ); /** * Locate ACPI root system description table * - * @ret rsdt ACPI root system description table, or UNULL + * @ret rsdt ACPI root system description table, or NULL */ -userptr_t acpi_find_rsdt ( void ); +const struct acpi_rsdt * acpi_find_rsdt ( void ); /** * Locate ACPI table * * @v signature Requested table signature * @v index Requested index of table with this signature - * @ret table Table, or UNULL if not found + * @ret table Table, or NULL if not found */ -userptr_t acpi_find ( uint32_t signature, unsigned int index ); +const struct acpi_header * acpi_find ( uint32_t signature, + unsigned int index ); extern struct acpi_descriptor * acpi_describe ( struct interface *interface ); #define acpi_describe_TYPE( object_type ) \ typeof ( struct acpi_descriptor * ( object_type ) ) -extern userptr_t ( * acpi_finder ) ( uint32_t signature, unsigned int index ); +extern const struct acpi_header * ( * acpi_finder ) ( uint32_t signature, + unsigned int index ); extern void acpi_fix_checksum ( struct acpi_header *acpi ); -extern userptr_t acpi_table ( uint32_t signature, unsigned int index ); +extern const struct acpi_header * acpi_table ( uint32_t signature, + unsigned int index ); extern int acpi_extract ( uint32_t signature, void *data, - int ( * extract ) ( userptr_t zsdt, size_t len, - size_t offset, void *data ) ); + int ( * extract ) ( const struct acpi_header *zsdt, + size_t len, size_t offset, + void *data ) ); extern void acpi_add ( struct acpi_descriptor *desc ); extern void acpi_del ( struct acpi_descriptor *desc ); extern int acpi_install ( int ( * install ) ( struct acpi_header *acpi ) ); diff --git a/src/include/ipxe/efi/efi_acpi.h b/src/include/ipxe/efi/efi_acpi.h index a698863a6..68f9c5be7 100644 --- a/src/include/ipxe/efi/efi_acpi.h +++ b/src/include/ipxe/efi/efi_acpi.h @@ -20,9 +20,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * * @v signature Requested table signature * @v index Requested index of table with this signature - * @ret table Table, or UNULL if not found + * @ret table Table, or NULL if not found */ -static inline __attribute__ (( always_inline )) userptr_t +static inline __attribute__ (( always_inline )) const struct acpi_header * ACPI_INLINE ( efi, acpi_find ) ( uint32_t signature, unsigned int index ) { return acpi_find_via_rsdt ( signature, index ); diff --git a/src/include/ipxe/null_acpi.h b/src/include/ipxe/null_acpi.h index cedb02839..18f059964 100644 --- a/src/include/ipxe/null_acpi.h +++ b/src/include/ipxe/null_acpi.h @@ -9,17 +9,19 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +#include + #ifdef ACPI_NULL #define ACPI_PREFIX_null #else #define ACPI_PREFIX_null __null_ #endif -static inline __attribute__ (( always_inline )) userptr_t +static inline __attribute__ (( always_inline )) const struct acpi_header * ACPI_INLINE ( null, acpi_find ) ( uint32_t signature __unused, unsigned int index __unused ) { - return UNULL; + return NULL; } #endif /* _IPXE_NULL_ACPI_H */ diff --git a/src/interface/efi/efi_acpi.c b/src/interface/efi/efi_acpi.c index c1046c01a..a2021a4f6 100644 --- a/src/interface/efi/efi_acpi.c +++ b/src/interface/efi/efi_acpi.c @@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ #include +#include #include #include #include @@ -42,15 +43,15 @@ EFI_USE_TABLE ( ACPI_10_TABLE, &rsdp, 0 ); /** * Locate ACPI root system description table * - * @ret rsdt ACPI root system description table, or UNULL + * @ret rsdt ACPI root system description table, or NULL */ -static userptr_t efi_find_rsdt ( void ) { +static const struct acpi_rsdt * efi_find_rsdt ( void ) { /* Locate RSDT via ACPI configuration table, if available */ if ( rsdp ) return phys_to_virt ( rsdp->RsdtAddress ); - return UNULL; + return NULL; } PROVIDE_ACPI ( efi, acpi_find_rsdt, efi_find_rsdt ); diff --git a/src/interface/linux/linux_acpi.c b/src/interface/linux/linux_acpi.c index 846db2f1f..a2a8bf12e 100644 --- a/src/interface/linux/linux_acpi.c +++ b/src/interface/linux/linux_acpi.c @@ -42,7 +42,7 @@ struct linux_acpi_table { /** Index */ unsigned int index; /** Cached data */ - userptr_t data; + void *data; }; /** List of cached ACPI tables */ @@ -53,9 +53,10 @@ static LIST_HEAD ( linux_acpi_tables ); * * @v signature Requested table signature * @v index Requested index of table with this signature - * @ret table Table, or UNULL if not found + * @ret table Table, or NULL if not found */ -static userptr_t linux_acpi_find ( uint32_t signature, unsigned int index ) { +static const struct acpi_header * linux_acpi_find ( uint32_t signature, + unsigned int index ) { struct linux_acpi_table *table; struct acpi_header *header; union { @@ -121,7 +122,7 @@ static userptr_t linux_acpi_find ( uint32_t signature, unsigned int index ) { err_read: free ( table ); err_alloc: - return UNULL; + return NULL; } /** diff --git a/src/tests/acpi_test.c b/src/tests/acpi_test.c index 1ca5befaf..6e8840217 100644 --- a/src/tests/acpi_test.c +++ b/src/tests/acpi_test.c @@ -32,6 +32,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /* Forcibly enable assertions */ #undef NDEBUG +#include #include #include #include @@ -185,26 +186,27 @@ static struct acpi_test_tables *acpi_test_tables; * * @v signature Requested table signature * @v index Requested index of table with this signature - * @ret table Table, or UNULL if not found + * @ret table Table, or NULL if not found */ -static userptr_t acpi_test_find ( uint32_t signature, unsigned int index ) { +static const struct acpi_header * acpi_test_find ( uint32_t signature, + unsigned int index ) { struct acpi_test_table *table; unsigned int i; /* Fail if no test tables are installed */ if ( ! acpi_test_tables ) - return UNULL; + return NULL; /* Scan through test tables */ for ( i = 0 ; i < acpi_test_tables->count ; i++ ) { table = acpi_test_tables->table[i]; if ( ( signature == le32_to_cpu ( table->signature.raw ) ) && ( index-- == 0 ) ) { - return virt_to_user ( table->data ); + return table->data; } } - return UNULL; + return NULL; } /** Override ACPI table finder */ -- cgit v1.2.3-55-g7522 From 0bf0f8716a3c7f85455707d8c2d727d130ee1024 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 23 Apr 2025 09:53:38 +0100 Subject: [smbios] Remove userptr_t from SMBIOS structure parsing Simplify the SMBIOS structure parsing code by assuming that all structure content is fully accessible via pointer dereferences. In particular, this allows the convoluted find_smbios_structure() and read_smbios_structure() to be combined into a single function smbios_structure() that just returns a direct pointer to the SMBIOS structure, with smbios_string() similarly now returning a direct pointer to the relevant string. Signed-off-by: Michael Brown --- src/arch/x86/interface/pcbios/bios_smbios.c | 36 ++-- src/drivers/net/smsc95xx.c | 93 ++++------- src/include/ipxe/smbios.h | 32 +--- src/interface/efi/efi_smbios.c | 1 + src/interface/linux/linux_smbios.c | 6 +- src/interface/smbios/smbios.c | 249 +++++++++++++--------------- src/interface/smbios/smbios_settings.c | 152 +++++++++-------- 7 files changed, 256 insertions(+), 313 deletions(-) (limited to 'src/drivers') diff --git a/src/arch/x86/interface/pcbios/bios_smbios.c b/src/arch/x86/interface/pcbios/bios_smbios.c index e43c74bad..aaec1eea1 100644 --- a/src/arch/x86/interface/pcbios/bios_smbios.c +++ b/src/arch/x86/interface/pcbios/bios_smbios.c @@ -45,19 +45,18 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * @ret rc Return status code */ static int bios_find_smbios2 ( struct smbios *smbios ) { - struct smbios_entry entry; - int rc; + const struct smbios_entry *entry; /* Scan through BIOS segment to find SMBIOS 32-bit entry point */ - if ( ( rc = find_smbios_entry ( real_to_virt ( BIOS_SEG, 0 ), 0x10000, - &entry ) ) != 0 ) - return rc; + entry = find_smbios_entry ( real_to_virt ( BIOS_SEG, 0 ), 0x10000 ); + if ( ! entry ) + return -ENOENT; /* Fill in entry point descriptor structure */ - smbios->address = phys_to_virt ( entry.smbios_address ); - smbios->len = entry.smbios_len; - smbios->count = entry.smbios_count; - smbios->version = SMBIOS_VERSION ( entry.major, entry.minor ); + smbios->address = phys_to_virt ( entry->smbios_address ); + smbios->len = entry->smbios_len; + smbios->count = entry->smbios_count; + smbios->version = SMBIOS_VERSION ( entry->major, entry->minor ); return 0; } @@ -69,26 +68,25 @@ static int bios_find_smbios2 ( struct smbios *smbios ) { * @ret rc Return status code */ static int bios_find_smbios3 ( struct smbios *smbios ) { - struct smbios3_entry entry; - int rc; + const struct smbios3_entry *entry; /* Scan through BIOS segment to find SMBIOS 64-bit entry point */ - if ( ( rc = find_smbios3_entry ( real_to_virt ( BIOS_SEG, 0 ), 0x10000, - &entry ) ) != 0 ) - return rc; + entry = find_smbios3_entry ( real_to_virt ( BIOS_SEG, 0 ), 0x10000 ); + if ( ! entry ) + return -ENOENT; /* Check that address is accessible */ - if ( entry.smbios_address > ~( ( physaddr_t ) 0 ) ) { + if ( entry->smbios_address > ~( ( physaddr_t ) 0 ) ) { DBG ( "SMBIOS3 at %08llx is inaccessible\n", - ( ( unsigned long long ) entry.smbios_address ) ); + ( ( unsigned long long ) entry->smbios_address ) ); return -ENOTSUP; } /* Fill in entry point descriptor structure */ - smbios->address = phys_to_virt ( entry.smbios_address ); - smbios->len = entry.smbios_len; + smbios->address = phys_to_virt ( entry->smbios_address ); + smbios->len = entry->smbios_len; smbios->count = 0; - smbios->version = SMBIOS_VERSION ( entry.major, entry.minor ); + smbios->version = SMBIOS_VERSION ( entry->major, entry->minor ); return 0; } diff --git a/src/drivers/net/smsc95xx.c b/src/drivers/net/smsc95xx.c index 3ec49584d..0210e9240 100644 --- a/src/drivers/net/smsc95xx.c +++ b/src/drivers/net/smsc95xx.c @@ -64,92 +64,67 @@ static struct profiler smsc95xx_out_profiler __profiler = */ static int smsc95xx_vm3_fetch_mac ( struct smscusb_device *smscusb ) { struct net_device *netdev = smscusb->netdev; - struct smbios_structure structure; - struct smbios_system_information system; - struct { - char manufacturer[ 10 /* "Honeywell" + NUL */ ]; - char product[ 4 /* "VM3" + NUL */ ]; - char mac[ base16_encoded_len ( ETH_ALEN ) + 1 /* NUL */ ]; - } strings; + const struct smbios_header *structure; + const struct smbios_system_information *system; + const char *manufacturer; + const char *product; + const char *mac; int len; int rc; /* Find system information */ - if ( ( rc = find_smbios_structure ( SMBIOS_TYPE_SYSTEM_INFORMATION, 0, - &structure ) ) != 0 ) { + structure = smbios_structure ( SMBIOS_TYPE_SYSTEM_INFORMATION, 0 ); + if ( ! structure ) { DBGC ( smscusb, "SMSC95XX %p could not find system " - "information: %s\n", smscusb, strerror ( rc ) ); - return rc; - } - - /* Read system information */ - if ( ( rc = read_smbios_structure ( &structure, &system, - sizeof ( system ) ) ) != 0 ) { - DBGC ( smscusb, "SMSC95XX %p could not read system " - "information: %s\n", smscusb, strerror ( rc ) ); - return rc; + "information\n", smscusb ); + return -ENOENT; } - - /* NUL-terminate all strings to be fetched */ - memset ( &strings, 0, sizeof ( strings ) ); + system = container_of ( structure, struct smbios_system_information, + header ); /* Fetch system manufacturer name */ - len = read_smbios_string ( &structure, system.manufacturer, - strings.manufacturer, - ( sizeof ( strings.manufacturer ) - 1 ) ); - if ( len < 0 ) { - rc = len; + manufacturer = smbios_string ( structure, system->manufacturer ); + if ( ! manufacturer ) { DBGC ( smscusb, "SMSC95XX %p could not read manufacturer " - "name: %s\n", smscusb, strerror ( rc ) ); - return rc; + "name\n", smscusb ); + return -ENOENT; } /* Fetch system product name */ - len = read_smbios_string ( &structure, system.product, strings.product, - ( sizeof ( strings.product ) - 1 ) ); - if ( len < 0 ) { - rc = len; - DBGC ( smscusb, "SMSC95XX %p could not read product name: " - "%s\n", smscusb, strerror ( rc ) ); - return rc; + product = smbios_string ( structure, system->product ); + if ( ! product ) { + DBGC ( smscusb, "SMSC95XX %p could not read product name\n", + smscusb ); + return -ENOENT; } /* Ignore non-VM3 devices */ - if ( ( strcmp ( strings.manufacturer, "Honeywell" ) != 0 ) || - ( strcmp ( strings.product, "VM3" ) != 0 ) ) + if ( ( strcmp ( manufacturer, "Honeywell" ) != 0 ) || + ( strcmp ( product, "VM3" ) != 0 ) ) return -ENOTTY; /* Find OEM strings */ - if ( ( rc = find_smbios_structure ( SMBIOS_TYPE_OEM_STRINGS, 0, - &structure ) ) != 0 ) { - DBGC ( smscusb, "SMSC95XX %p could not find OEM strings: %s\n", - smscusb, strerror ( rc ) ); - return rc; + structure = smbios_structure ( SMBIOS_TYPE_OEM_STRINGS, 0 ); + if ( ! structure ) { + DBGC ( smscusb, "SMSC95XX %p could not find OEM strings\n", + smscusb ); + return -ENOENT; } /* Fetch MAC address */ - len = read_smbios_string ( &structure, SMSC95XX_VM3_OEM_STRING_MAC, - strings.mac, ( sizeof ( strings.mac ) - 1 )); - if ( len < 0 ) { - rc = len; - DBGC ( smscusb, "SMSC95XX %p could not read OEM string: %s\n", - smscusb, strerror ( rc ) ); - return rc; - } - - /* Sanity check */ - if ( len != ( ( int ) ( sizeof ( strings.mac ) - 1 ) ) ) { - DBGC ( smscusb, "SMSC95XX %p invalid MAC address \"%s\"\n", - smscusb, strings.mac ); - return -EINVAL; + mac = smbios_string ( structure, SMSC95XX_VM3_OEM_STRING_MAC ); + if ( ! mac ) { + DBGC ( smscusb, "SMSC95XX %p could not read OEM string\n", + smscusb ); + return -ENOENT; } /* Decode MAC address */ - len = base16_decode ( strings.mac, netdev->hw_addr, ETH_ALEN ); + len = base16_decode ( mac, netdev->hw_addr, ETH_ALEN ); if ( len < 0 ) { rc = len; DBGC ( smscusb, "SMSC95XX %p invalid MAC address \"%s\"\n", - smscusb, strings.mac ); + smscusb, mac ); return rc; } diff --git a/src/include/ipxe/smbios.h b/src/include/ipxe/smbios.h index f36a5ad40..d9e2c38ed 100644 --- a/src/include/ipxe/smbios.h +++ b/src/include/ipxe/smbios.h @@ -12,7 +12,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include /** * Provide an SMBIOS API implementation @@ -126,16 +125,6 @@ struct smbios_header { uint16_t handle; } __attribute__ (( packed )); -/** SMBIOS structure descriptor */ -struct smbios_structure { - /** Copy of SMBIOS structure header */ - struct smbios_header header; - /** Offset of structure within SMBIOS */ - size_t offset; - /** Length of strings section */ - size_t strings_len; -}; - /** SMBIOS system information structure */ struct smbios_system_information { /** SMBIOS structure header */ @@ -207,7 +196,7 @@ struct smbios_enclosure_information { */ struct smbios { /** Start of SMBIOS structures */ - userptr_t address; + const void *address; /** Length of SMBIOS structures */ size_t len; /** Number of SMBIOS structures */ @@ -226,17 +215,14 @@ struct smbios { #define SMBIOS_VERSION( major, minor ) ( ( (major) << 8 ) | (minor) ) extern int find_smbios ( struct smbios *smbios ); -extern int find_smbios_entry ( userptr_t start, size_t len, - struct smbios_entry *entry ); -extern int find_smbios3_entry ( userptr_t start, size_t len, - struct smbios3_entry *entry ); -extern int find_smbios_structure ( unsigned int type, unsigned int instance, - struct smbios_structure *structure ); -extern int read_smbios_structure ( struct smbios_structure *structure, - void *data, size_t len ); -extern int read_smbios_string ( struct smbios_structure *structure, - unsigned int index, - void *data, size_t len ); +extern const struct smbios_entry * find_smbios_entry ( const void *start, + size_t len ); +extern const struct smbios3_entry * find_smbios3_entry ( const void *start, + size_t len ); +extern const struct smbios_header * smbios_structure ( unsigned int type, + unsigned int instance ); +extern const char * smbios_string ( const struct smbios_header *header, + unsigned int index ); extern int smbios_version ( void ); extern void smbios_clear ( void ); diff --git a/src/interface/efi/efi_smbios.c b/src/interface/efi/efi_smbios.c index 3c1b77bdc..5d0e69d6b 100644 --- a/src/interface/efi/efi_smbios.c +++ b/src/interface/efi/efi_smbios.c @@ -20,6 +20,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include +#include #include #include #include diff --git a/src/interface/linux/linux_smbios.c b/src/interface/linux/linux_smbios.c index abe1b19d7..a12c936ed 100644 --- a/src/interface/linux/linux_smbios.c +++ b/src/interface/linux/linux_smbios.c @@ -35,7 +35,7 @@ static const char smbios_entry_filename[] = static const char smbios_filename[] = "/sys/firmware/dmi/tables/DMI"; /** Cache SMBIOS data */ -static userptr_t smbios_data; +static void *smbios_data; /** * Find SMBIOS @@ -46,7 +46,7 @@ static userptr_t smbios_data; static int linux_find_smbios ( struct smbios *smbios ) { struct smbios3_entry *smbios3_entry; struct smbios_entry *smbios_entry; - userptr_t entry; + void *entry; void *data; int len; int rc; @@ -98,6 +98,7 @@ static int linux_find_smbios ( struct smbios *smbios ) { return 0; ufree ( smbios_data ); + smbios_data = NULL; err_read: err_version: ufree ( entry ); @@ -116,6 +117,7 @@ static void linux_smbios_shutdown ( int booting __unused ) { /* Free SMBIOS data */ ufree ( smbios_data ); + smbios_data = NULL; } /** SMBIOS shutdown function */ diff --git a/src/interface/smbios/smbios.c b/src/interface/smbios/smbios.c index 89fa4d7ca..3a1a98b17 100644 --- a/src/interface/smbios/smbios.c +++ b/src/interface/smbios/smbios.c @@ -38,26 +38,24 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /** SMBIOS entry point descriptor */ static struct smbios smbios = { - .address = UNULL, + .address = NULL, }; /** * Calculate SMBIOS entry point structure checksum * * @v start Start address of region - * @v offset Offset of SMBIOS entry point structure * @v len Length of entry point structure * @ret sum Byte checksum */ -static uint8_t smbios_checksum ( userptr_t start, size_t offset, size_t len ) { - size_t end = ( offset + len ); - uint8_t sum; - uint8_t byte; +static uint8_t smbios_checksum ( const void *start, size_t len ) { + const uint8_t *byte = start; + uint8_t sum = 0; + + /* Compute checksum */ + while ( len-- ) + sum += *(byte++); - for ( sum = 0 ; offset < end ; offset++ ) { - copy_from_user ( &byte, start, offset, sizeof ( byte ) ); - sum += byte; - } return sum; } @@ -66,39 +64,45 @@ static uint8_t smbios_checksum ( userptr_t start, size_t offset, size_t len ) { * * @v start Start address of region to scan * @v len Length of region to scan - * @v entry SMBIOS entry point structure to fill in - * @ret rc Return status code + * @ret entry SMBIOS entry point structure, or NULL if not found */ -int find_smbios_entry ( userptr_t start, size_t len, - struct smbios_entry *entry ) { +const struct smbios_entry * find_smbios_entry ( const void *start, + size_t len ) { static size_t offset = 0; /* Avoid repeated attempts to locate SMBIOS */ + const struct smbios_entry *entry; uint8_t sum; /* Try to find SMBIOS */ for ( ; ( offset + sizeof ( *entry ) ) <= len ; offset += 0x10 ) { - /* Read start of header and verify signature */ - copy_from_user ( entry, start, offset, sizeof ( *entry ) ); + /* Verify signature */ + entry = ( start + offset ); if ( entry->signature != SMBIOS_SIGNATURE ) continue; + /* Verify length */ + if ( ( entry->len < sizeof ( *entry ) ) || + ( ( offset + entry->len ) > len ) ) { + DBGC ( &smbios, "SMBIOS at %#08lx has bad length " + "%#02x\n", virt_to_phys ( entry ), entry->len ); + continue; + } + /* Verify checksum */ - if ( ( sum = smbios_checksum ( start, offset, - entry->len ) ) != 0 ) { - DBG ( "SMBIOS at %08lx has bad checksum %02x\n", - virt_to_phys ( start + offset ), sum ); + if ( ( sum = smbios_checksum ( entry, entry->len ) ) != 0 ) { + DBGC ( &smbios, "SMBIOS at %#08lx has bad checksum " + "%#02x\n", virt_to_phys ( entry ), sum ); continue; } /* Fill result structure */ - DBG ( "Found SMBIOS v%d.%d entry point at %08lx\n", - entry->major, entry->minor, - virt_to_phys ( start + offset ) ); - return 0; + DBGC ( &smbios, "Found SMBIOS v%d.%d entry point at %#08lx\n", + entry->major, entry->minor, virt_to_phys ( entry ) ); + return entry; } - DBG ( "No SMBIOS found\n" ); - return -ENODEV; + DBGC ( &smbios, "No SMBIOS found\n" ); + return NULL; } /** @@ -106,39 +110,45 @@ int find_smbios_entry ( userptr_t start, size_t len, * * @v start Start address of region to scan * @v len Length of region to scan - * @v entry SMBIOS entry point structure to fill in - * @ret rc Return status code + * @ret entry SMBIOS entry point structure, or NULL if not found */ -int find_smbios3_entry ( userptr_t start, size_t len, - struct smbios3_entry *entry ) { +const struct smbios3_entry * find_smbios3_entry ( const void *start, + size_t len ) { static size_t offset = 0; /* Avoid repeated attempts to locate SMBIOS */ + const struct smbios3_entry *entry; uint8_t sum; /* Try to find SMBIOS */ for ( ; ( offset + sizeof ( *entry ) ) <= len ; offset += 0x10 ) { - /* Read start of header and verify signature */ - copy_from_user ( entry, start, offset, sizeof ( *entry ) ); + /* Verify signature */ + entry = ( start + offset ); if ( entry->signature != SMBIOS3_SIGNATURE ) continue; + /* Verify length */ + if ( ( entry->len < sizeof ( *entry ) ) || + ( ( offset + entry->len ) > len ) ) { + DBGC ( &smbios, "SMBIOS at %#08lx has bad length " + "%#02x\n", virt_to_phys ( entry ), entry->len ); + continue; + } + /* Verify checksum */ - if ( ( sum = smbios_checksum ( start, offset, - entry->len ) ) != 0 ) { - DBG ( "SMBIOS3 at %08lx has bad checksum %02x\n", - virt_to_phys ( start + offset ), sum ); + if ( ( sum = smbios_checksum ( entry, entry->len ) ) != 0 ) { + DBGC ( &smbios, "SMBIOS3 at %#08lx has bad checksum " + "%#02x\n", virt_to_phys ( entry ), sum ); continue; } /* Fill result structure */ - DBG ( "Found SMBIOS3 v%d.%d entry point at %08lx\n", - entry->major, entry->minor, - virt_to_phys ( start + offset ) ); - return 0; + DBGC ( &smbios, "Found SMBIOS3 v%d.%d entry point at %#08lx\n", + entry->major, entry->minor, virt_to_phys ( entry ) ); + return entry; } - DBG ( "No SMBIOS3 found\n" ); - return -ENODEV; + DBGC ( &smbios, "No SMBIOS3 found\n" ); + return NULL; } /** @@ -148,12 +158,15 @@ int find_smbios3_entry ( userptr_t start, size_t len, * @ret offset Offset to strings terminator, or 0 if not found */ static size_t find_strings_terminator ( size_t offset ) { - size_t max_offset = ( smbios.len - 2 ); - uint16_t nulnul; + const uint16_t *nulnul __attribute__ (( aligned ( 1 ) )); - for ( ; offset <= max_offset ; offset++ ) { - copy_from_user ( &nulnul, smbios.address, offset, 2 ); - if ( nulnul == 0 ) + /* Sanity checks */ + assert ( smbios.address != NULL ); + + /* Check for presence of terminating empty string */ + for ( ; ( offset + sizeof ( *nulnul ) ) <= smbios.len ; offset++ ) { + nulnul = ( smbios.address + offset ); + if ( *nulnul == 0 ) return ( offset + 1 ); } return 0; @@ -164,61 +177,59 @@ static size_t find_strings_terminator ( size_t offset ) { * * @v type Structure type to search for * @v instance Instance of this type of structure - * @v structure SMBIOS structure descriptor to fill in - * @ret rc Return status code + * @ret structure SMBIOS structure header, or NULL if not found */ -int find_smbios_structure ( unsigned int type, unsigned int instance, - struct smbios_structure *structure ) { +const struct smbios_header * smbios_structure ( unsigned int type, + unsigned int instance ) { + const struct smbios_header *structure; unsigned int count = 0; size_t offset = 0; size_t strings_offset; size_t terminator_offset; + size_t strings_len; int rc; /* Find SMBIOS */ - if ( ( smbios.address == UNULL ) && + if ( ( smbios.address == NULL ) && ( ( rc = find_smbios ( &smbios ) ) != 0 ) ) - return rc; - assert ( smbios.address != UNULL ); + return NULL; + assert ( smbios.address != NULL ); /* Scan through list of structures */ - while ( ( ( offset + sizeof ( structure->header ) ) < smbios.len ) && + while ( ( ( offset + sizeof ( *structure ) ) < smbios.len ) && ( ( smbios.count == 0 ) || ( count < smbios.count ) ) ) { - /* Read next SMBIOS structure header */ - copy_from_user ( &structure->header, smbios.address, offset, - sizeof ( structure->header ) ); + /* Access next SMBIOS structure header */ + structure = ( smbios.address + offset ); /* Determine start and extent of strings block */ - strings_offset = ( offset + structure->header.len ); + strings_offset = ( offset + structure->len ); if ( strings_offset > smbios.len ) { - DBG ( "SMBIOS structure at offset %zx with length " - "%x extends beyond SMBIOS\n", offset, - structure->header.len ); - return -ENOENT; + DBGC ( &smbios, "SMBIOS structure at offset %#zx " + "with length %#x extends beyond SMBIOS\n", + offset, structure->len ); + return NULL; } terminator_offset = find_strings_terminator ( strings_offset ); if ( ! terminator_offset ) { - DBG ( "SMBIOS structure at offset %zx has " - "unterminated strings section\n", offset ); - return -ENOENT; + DBGC ( &smbios, "SMBIOS structure at offset %#zx has " + "unterminated strings section\n", offset ); + return NULL; } - structure->strings_len = ( terminator_offset - strings_offset); - - DBG ( "SMBIOS structure at offset %zx has type %d, length %x, " - "strings length %zx\n", offset, structure->header.type, - structure->header.len, structure->strings_len ); + strings_len = ( terminator_offset - strings_offset); + DBGC ( &smbios, "SMBIOS structure at offset %#zx has type %d, " + "length %#x, strings length %#zx\n", offset, + structure->type, structure->len, strings_len ); /* Stop if we have reached an end-of-table marker */ if ( ( smbios.count == 0 ) && - ( structure->header.type == SMBIOS_TYPE_END ) ) + ( structure->type == SMBIOS_TYPE_END ) ) break; /* If this is the structure we want, return */ - if ( ( structure->header.type == type ) && + if ( ( structure->type == type ) && ( instance-- == 0 ) ) { - structure->offset = offset; - return 0; + return structure; } /* Move to next SMBIOS structure */ @@ -226,69 +237,43 @@ int find_smbios_structure ( unsigned int type, unsigned int instance, count++; } - DBG ( "SMBIOS structure type %d not found\n", type ); - return -ENOENT; + DBGC ( &smbios, "SMBIOS structure type %d not found\n", type ); + return NULL; } /** - * Copy SMBIOS structure + * Get indexed string within SMBIOS structure * - * @v structure SMBIOS structure descriptor - * @v data Buffer to hold SMBIOS structure - * @v len Length of buffer - * @ret rc Return status code - */ -int read_smbios_structure ( struct smbios_structure *structure, - void *data, size_t len ) { - - assert ( smbios.address != UNULL ); - - if ( len > structure->header.len ) - len = structure->header.len; - copy_from_user ( data, smbios.address, structure->offset, len ); - return 0; -} - -/** - * Find indexed string within SMBIOS structure - * - * @v structure SMBIOS structure descriptor + * @v structure SMBIOS structure header * @v index String index - * @v data Buffer for string - * @v len Length of string buffer - * @ret rc Length of string, or negative error + * @ret string SMBIOS string, or NULL if not fond */ -int read_smbios_string ( struct smbios_structure *structure, - unsigned int index, void *data, size_t len ) { - size_t strings_start = ( structure->offset + structure->header.len ); - size_t strings_end = ( strings_start + structure->strings_len ); - size_t offset; - size_t string_len; - - assert ( smbios.address != UNULL ); - - /* String numbers start at 1 (0 is used to indicate "no string") */ - if ( ! index ) - return -ENOENT; - - for ( offset = strings_start ; offset < strings_end ; - offset += ( string_len + 1 ) ) { - /* Get string length. This is known safe, since the - * smbios_strings struct is constructed so as to - * always end on a string boundary. +const char * smbios_string ( const struct smbios_header *structure, + unsigned int index ) { + const char *string; + unsigned int i; + size_t len; + + /* Sanity check */ + assert ( smbios.address != NULL ); + + /* Step through strings */ + string = ( ( ( const void * ) structure ) + structure->len ); + for ( i = index ; i-- ; ) { + /* Get string length. This is known safe, since we + * check for the empty-string terminator in + * smbios_structure(). */ - string_len = strlen ( smbios.address + offset ); - if ( --index == 0 ) { - /* Copy string, truncating as necessary. */ - if ( len > string_len ) - len = string_len; - copy_from_user ( data, smbios.address, offset, len ); - return string_len; - } + len = strlen ( string ); + if ( ! len ) + break; + if ( i == 0 ) + return string; + string += ( len + 1 /* NUL */ ); } - DBG ( "SMBIOS string index %d not found\n", index ); - return -ENOENT; + DBGC ( &smbios, "SMBIOS string index %d not found\n", index ); + return NULL; } /** @@ -300,10 +285,10 @@ int smbios_version ( void ) { int rc; /* Find SMBIOS */ - if ( ( smbios.address == UNULL ) && + if ( ( smbios.address == NULL ) && ( ( rc = find_smbios ( &smbios ) ) != 0 ) ) return rc; - assert ( smbios.address != UNULL ); + assert ( smbios.address != NULL ); return smbios.version; } @@ -315,5 +300,5 @@ int smbios_version ( void ) { void smbios_clear ( void ) { /* Clear address */ - smbios.address = UNULL; + smbios.address = NULL; } diff --git a/src/interface/smbios/smbios_settings.c b/src/interface/smbios/smbios_settings.c index 095c35d37..1fe545f38 100644 --- a/src/interface/smbios/smbios_settings.c +++ b/src/interface/smbios/smbios_settings.c @@ -81,15 +81,17 @@ static int smbios_applies ( struct settings *settings __unused, * @v len Length of buffer * @ret len Length of setting data, or negative error */ -static int smbios_fetch ( struct settings *settings __unused, - struct setting *setting, +static int smbios_fetch ( struct settings *settings, struct setting *setting, void *data, size_t len ) { - struct smbios_structure structure; + const struct smbios_header *structure; unsigned int tag_instance; unsigned int tag_type; unsigned int tag_offset; unsigned int tag_len; - int rc; + const void *src; + size_t src_len; + unsigned int string; + union uuid uuid; /* Split tag into instance, type, offset and length */ tag_instance = ( ( setting->tag >> 24 ) & 0xff ); @@ -98,81 +100,75 @@ static int smbios_fetch ( struct settings *settings __unused, tag_len = ( setting->tag & 0xff ); /* Find SMBIOS structure */ - if ( ( rc = find_smbios_structure ( tag_type, tag_instance, - &structure ) ) != 0 ) - return rc; - - { - uint8_t buf[structure.header.len]; - const void *raw; - union uuid uuid; - unsigned int index; - - /* Read SMBIOS structure */ - if ( ( rc = read_smbios_structure ( &structure, buf, - sizeof ( buf ) ) ) != 0 ) - return rc; + structure = smbios_structure ( tag_type, tag_instance ); + if ( ! structure ) + return -ENOENT; + src = structure; + src_len = structure->len; + string = 0; - /* A of zero indicates that the byte at - * contains a string index. An of - * zero indicates that the contains a literal - * string index. - * - * Since the byte at offset zero can never contain a - * string index, and a literal string index can never - * be zero, the combination of both and - * being zero indicates that the entire - * structure is to be read. - */ - if ( ( tag_len == 0 ) && ( tag_offset == 0 ) ) { - tag_len = sizeof ( buf ); - } else if ( ( tag_len == 0 ) || ( tag_offset == 0 ) ) { - index = ( ( tag_offset == 0 ) ? - tag_len : buf[tag_offset] ); - if ( ( rc = read_smbios_string ( &structure, index, - data, len ) ) < 0 ) { - return rc; - } - if ( ! setting->type ) - setting->type = &setting_type_string; - return rc; - } + /* A of zero indicates that the byte at + * contains a string index. An of zero indicates + * that the contains a literal string index. + * + * Since the byte at offset zero can never contain a string + * index, and a literal string index can never be zero, the + * combination of both and being zero + * indicates that the entire structure is to be read. + */ + if ( ( tag_len == 0 ) && ( tag_offset == 0 ) ) { + /* Read whole structure */ + } else if ( ( tag_len == 0 ) || ( tag_offset == 0 ) ) { + /* Read string */ + string = tag_len; + if ( ( string == 0 ) && ( tag_offset < src_len ) ) + string = *( ( uint8_t * ) src + tag_offset ); + src = smbios_string ( structure, string ); + if ( ! src ) + return -ENOENT; + assert ( string > 0 ); + src_len = strlen ( src ); + } else if ( tag_offset > src_len ) { + /* Empty read beyond end of structure */ + src_len = 0; + } else { + /* Read partial structure */ + src += tag_offset; + src_len -= tag_offset; + if ( src_len > tag_len ) + src_len = tag_len; + } - /* Limit length */ - if ( tag_offset > sizeof ( buf ) ) { - tag_len = 0; - } else if ( ( tag_offset + tag_len ) > sizeof ( buf ) ) { - tag_len = ( sizeof ( buf ) - tag_offset ); - } + /* Mangle UUIDs if necessary. iPXE treats UUIDs as being in + * network byte order (big-endian). SMBIOS specification + * version 2.6 states that UUIDs are stored with little-endian + * values in the first three fields; earlier versions did not + * specify an endianness. dmidecode assumes that the byte + * order is little-endian if and only if the SMBIOS version is + * 2.6 or higher; we match this behaviour. + */ + if ( ( ( setting->type == &setting_type_uuid ) || + ( setting->type == &setting_type_guid ) ) && + ( src_len == sizeof ( uuid ) ) && + ( smbios_version() >= SMBIOS_VERSION ( 2, 6 ) ) ) { + DBGC ( settings, "SMBIOS detected mangled UUID\n" ); + memcpy ( &uuid, src, sizeof ( uuid ) ); + uuid_mangle ( &uuid ); + src = &uuid; + } - /* Mangle UUIDs if necessary. iPXE treats UUIDs as - * being in network byte order (big-endian). SMBIOS - * specification version 2.6 states that UUIDs are - * stored with little-endian values in the first three - * fields; earlier versions did not specify an - * endianness. dmidecode assumes that the byte order - * is little-endian if and only if the SMBIOS version - * is 2.6 or higher; we match this behaviour. - */ - raw = &buf[tag_offset]; - if ( ( ( setting->type == &setting_type_uuid ) || - ( setting->type == &setting_type_guid ) ) && - ( tag_len == sizeof ( uuid ) ) && - ( smbios_version() >= SMBIOS_VERSION ( 2, 6 ) ) ) { - DBG ( "SMBIOS detected mangled UUID\n" ); - memcpy ( &uuid, &buf[tag_offset], sizeof ( uuid ) ); - uuid_mangle ( &uuid ); - raw = &uuid; - } + /* Return data */ + if ( len > src_len ) + len = src_len; + memcpy ( data, src, len ); - /* Return data */ - if ( len > tag_len ) - len = tag_len; - memcpy ( data, raw, len ); - if ( ! setting->type ) - setting->type = &setting_type_hex; - return tag_len; + /* Set default type */ + if ( ! setting->type ) { + setting->type = ( string ? &setting_type_string : + &setting_type_hex ); } + + return src_len; } /** SMBIOS settings operations */ @@ -192,12 +188,12 @@ static struct settings smbios_settings = { /** Initialise SMBIOS settings */ static void smbios_init ( void ) { + struct settings *settings = &smbios_settings; int rc; - if ( ( rc = register_settings ( &smbios_settings, NULL, - "smbios" ) ) != 0 ) { - DBG ( "SMBIOS could not register settings: %s\n", - strerror ( rc ) ); + if ( ( rc = register_settings ( settings, NULL, "smbios" ) ) != 0 ) { + DBGC ( settings, "SMBIOS could not register settings: %s\n", + strerror ( rc ) ); return; } } -- cgit v1.2.3-55-g7522 From 945df9b429fb3a7aa9fb48859fb4bb3751a38eef Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 23 Apr 2025 18:24:18 +0100 Subject: [gve] Replace uses of userptr_t with direct pointer dereferences Signed-off-by: Michael Brown --- src/drivers/net/gve.c | 112 +++++++++++++++++++++++--------------------------- src/drivers/net/gve.h | 19 +++++++-- 2 files changed, 67 insertions(+), 64 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/gve.c b/src/drivers/net/gve.c index f9ec388a4..20ea6b97b 100644 --- a/src/drivers/net/gve.c +++ b/src/drivers/net/gve.c @@ -578,7 +578,8 @@ static void gve_create_tx_param ( struct gve_queue *queue, /* Construct request parameters */ create->res = cpu_to_be64 ( dma ( &queue->res_map, queue->res ) ); - create->desc = cpu_to_be64 ( dma ( &queue->desc_map, queue->desc ) ); + create->desc = + cpu_to_be64 ( dma ( &queue->desc_map, queue->desc.tx ) ); create->qpl_id = cpu_to_be32 ( type->qpl ); create->notify_id = cpu_to_be32 ( type->irq ); } @@ -597,8 +598,10 @@ static void gve_create_rx_param ( struct gve_queue *queue, /* Construct request parameters */ create->notify_id = cpu_to_be32 ( type->irq ); create->res = cpu_to_be64 ( dma ( &queue->res_map, queue->res ) ); - create->desc = cpu_to_be64 ( dma ( &queue->desc_map, queue->desc ) ); - create->cmplt = cpu_to_be64 ( dma ( &queue->cmplt_map, queue->cmplt )); + create->desc = + cpu_to_be64 ( dma ( &queue->desc_map, queue->desc.rx ) ); + create->cmplt = + cpu_to_be64 ( dma ( &queue->cmplt_map, queue->cmplt.rx ) ); create->qpl_id = cpu_to_be32 ( type->qpl ); create->bufsz = cpu_to_be16 ( GVE_BUF_SIZE ); } @@ -800,7 +803,7 @@ gve_address ( struct gve_queue *queue, unsigned int index ) { * @v index Buffer index * @ret addr Buffer address */ -static inline __attribute__ (( always_inline )) userptr_t +static inline __attribute__ (( always_inline )) void * gve_buffer ( struct gve_queue *queue, unsigned int index ) { /* Pages are currently allocated as a single contiguous block */ @@ -845,8 +848,7 @@ static int gve_alloc_queue ( struct gve_nic *gve, struct gve_queue *queue ) { size_t desc_len = ( queue->count * type->desc_len ); size_t cmplt_len = ( queue->count * type->cmplt_len ); size_t res_len = sizeof ( *queue->res ); - struct gve_buffer buf; - size_t offset; + struct gve_buffer *buf; unsigned int i; int rc; @@ -873,27 +875,27 @@ static int gve_alloc_queue ( struct gve_nic *gve, struct gve_queue *queue ) { goto err_qpl; /* Allocate descriptors */ - queue->desc = dma_umalloc ( dma, &queue->desc_map, desc_len, - GVE_ALIGN ); - if ( ! queue->desc ) { + queue->desc.raw = dma_umalloc ( dma, &queue->desc_map, desc_len, + GVE_ALIGN ); + if ( ! queue->desc.raw ) { rc = -ENOMEM; goto err_desc; } DBGC ( gve, "GVE %p %s descriptors at [%08lx,%08lx)\n", - gve, type->name, virt_to_phys ( queue->desc ), - ( virt_to_phys ( queue->desc ) + desc_len ) ); + gve, type->name, virt_to_phys ( queue->desc.raw ), + ( virt_to_phys ( queue->desc.raw ) + desc_len ) ); /* Allocate completions */ if ( cmplt_len ) { - queue->cmplt = dma_umalloc ( dma, &queue->cmplt_map, cmplt_len, - GVE_ALIGN ); - if ( ! queue->cmplt ) { + queue->cmplt.raw = dma_umalloc ( dma, &queue->cmplt_map, + cmplt_len, GVE_ALIGN ); + if ( ! queue->cmplt.raw ) { rc = -ENOMEM; goto err_cmplt; } DBGC ( gve, "GVE %p %s completions at [%08lx,%08lx)\n", - gve, type->name, virt_to_phys ( queue->cmplt ), - ( virt_to_phys ( queue->cmplt ) + cmplt_len ) ); + gve, type->name, virt_to_phys ( queue->cmplt.raw ), + ( virt_to_phys ( queue->cmplt.raw ) + cmplt_len ) ); } /* Allocate queue resources */ @@ -905,11 +907,10 @@ static int gve_alloc_queue ( struct gve_nic *gve, struct gve_queue *queue ) { memset ( queue->res, 0, res_len ); /* Populate descriptor offsets */ - offset = ( type->desc_len - sizeof ( buf ) ); + buf = ( queue->desc.raw + type->desc_len - sizeof ( *buf ) ); for ( i = 0 ; i < queue->count ; i++ ) { - buf.addr = cpu_to_be64 ( gve_address ( queue, i ) ); - copy_to_user ( queue->desc, offset, &buf, sizeof ( buf ) ); - offset += type->desc_len; + buf->addr = cpu_to_be64 ( gve_address ( queue, i ) ); + buf = ( ( ( void * ) buf ) + type->desc_len ); } return 0; @@ -917,9 +918,9 @@ static int gve_alloc_queue ( struct gve_nic *gve, struct gve_queue *queue ) { dma_free ( &queue->res_map, queue->res, res_len ); err_res: if ( cmplt_len ) - dma_ufree ( &queue->cmplt_map, queue->cmplt, cmplt_len ); + dma_ufree ( &queue->cmplt_map, queue->cmplt.raw, cmplt_len ); err_cmplt: - dma_ufree ( &queue->desc_map, queue->desc, desc_len ); + dma_ufree ( &queue->desc_map, queue->desc.raw, desc_len ); err_desc: gve_free_qpl ( gve, &queue->qpl ); err_qpl: @@ -944,10 +945,10 @@ static void gve_free_queue ( struct gve_nic *gve, struct gve_queue *queue ) { /* Free completions, if applicable */ if ( cmplt_len ) - dma_ufree ( &queue->cmplt_map, queue->cmplt, cmplt_len ); + dma_ufree ( &queue->cmplt_map, queue->cmplt.raw, cmplt_len ); /* Free descriptors */ - dma_ufree ( &queue->desc_map, queue->desc, desc_len ); + dma_ufree ( &queue->desc_map, queue->desc.raw, desc_len ); /* Free queue page list */ gve_free_qpl ( gve, &queue->qpl ); @@ -977,7 +978,7 @@ static int gve_start ( struct gve_nic *gve ) { } /* Invalidate receive completions */ - memset ( rx->cmplt, 0, ( rx->count * rx->type->cmplt_len ) ); + memset ( rx->cmplt.raw, 0, ( rx->count * rx->type->cmplt_len ) ); /* Reset receive sequence */ gve->seq = gve_next ( 0 ); @@ -1209,7 +1210,7 @@ static void gve_close ( struct net_device *netdev ) { static int gve_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) { struct gve_nic *gve = netdev->priv; struct gve_queue *tx = &gve->tx; - struct gve_tx_descriptor desc; + struct gve_tx_descriptor *desc; unsigned int count; unsigned int index; size_t frag_len; @@ -1238,26 +1239,25 @@ static int gve_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) { frag_len = ( len - offset ); if ( frag_len > GVE_BUF_SIZE ) frag_len = GVE_BUF_SIZE; - copy_to_user ( gve_buffer ( tx, tx->prod ), 0, - ( iobuf->data + offset ), frag_len ); + memcpy ( gve_buffer ( tx, tx->prod ), + ( iobuf->data + offset ), frag_len ); /* Populate descriptor */ index = ( tx->prod++ & ( tx->count - 1 ) ); - memset ( &desc.pkt, 0, sizeof ( desc.pkt ) ); + desc = &tx->desc.tx[index]; + memset ( &desc->pkt, 0, sizeof ( desc->pkt ) ); if ( offset ) { - desc.pkt.type = GVE_TX_TYPE_CONT; + desc->pkt.type = GVE_TX_TYPE_CONT; } else { - desc.pkt.type = GVE_TX_TYPE_START; - desc.pkt.count = count; - desc.pkt.total = cpu_to_be16 ( len ); + desc->pkt.type = GVE_TX_TYPE_START; + desc->pkt.count = count; + desc->pkt.total = cpu_to_be16 ( len ); } - desc.pkt.len = cpu_to_be16 ( frag_len ); - copy_to_user ( tx->desc, ( index * sizeof ( desc ) ), &desc, - sizeof ( desc.pkt ) ); + desc->pkt.len = cpu_to_be16 ( frag_len ); DBGC2 ( gve, "GVE %p TX %#04x %#02x:%#02x len %#04x/%#04x at " - "%#08zx\n", gve, index, desc.pkt.type, desc.pkt.count, - be16_to_cpu ( desc.pkt.len ), - be16_to_cpu ( desc.pkt.total ), + "%#08zx\n", gve, index, desc->pkt.type, + desc->pkt.count, be16_to_cpu ( desc->pkt.len ), + be16_to_cpu ( desc->pkt.total ), gve_address ( tx, index ) ); } assert ( ( tx->prod - tx->cons ) <= tx->fill ); @@ -1305,12 +1305,11 @@ static void gve_poll_tx ( struct net_device *netdev ) { static void gve_poll_rx ( struct net_device *netdev ) { struct gve_nic *gve = netdev->priv; struct gve_queue *rx = &gve->rx; - struct gve_rx_completion cmplt; + struct gve_rx_completion *cmplt; struct io_buffer *iobuf; unsigned int index; unsigned int seq; uint32_t cons; - size_t offset; size_t total; size_t len; int rc; @@ -1323,28 +1322,25 @@ static void gve_poll_rx ( struct net_device *netdev ) { /* Read next possible completion */ index = ( cons++ & ( rx->count - 1 ) ); - offset = ( ( index * sizeof ( cmplt ) ) + - offsetof ( typeof ( cmplt ), pkt ) ); - copy_from_user ( &cmplt.pkt, rx->cmplt, offset, - sizeof ( cmplt.pkt ) ); + cmplt = &rx->cmplt.rx[index]; /* Check sequence number */ - if ( ( cmplt.pkt.seq & GVE_RX_SEQ_MASK ) != seq ) + if ( ( cmplt->pkt.seq & GVE_RX_SEQ_MASK ) != seq ) break; seq = gve_next ( seq ); /* Parse completion */ - len = be16_to_cpu ( cmplt.pkt.len ); + len = be16_to_cpu ( cmplt->pkt.len ); DBGC2 ( gve, "GVE %p RX %#04x %#02x:%#02x len %#04zx at " - "%#08zx\n", gve, index, cmplt.pkt.seq, cmplt.pkt.flags, - len, gve_address ( rx, index ) ); + "%#08zx\n", gve, index, cmplt->pkt.seq, + cmplt->pkt.flags, len, gve_address ( rx, index ) ); /* Accumulate a complete packet */ - if ( cmplt.pkt.flags & GVE_RXF_ERROR ) { + if ( cmplt->pkt.flags & GVE_RXF_ERROR ) { total = 0; } else { total += len; - if ( cmplt.pkt.flags & GVE_RXF_MORE ) + if ( cmplt->pkt.flags & GVE_RXF_MORE ) continue; } gve->seq = seq; @@ -1355,17 +1351,13 @@ static void gve_poll_rx ( struct net_device *netdev ) { /* Re-read completion length */ index = ( rx->cons & ( rx->count - 1 ) ); - offset = ( ( index * sizeof ( cmplt ) ) + - offsetof ( typeof ( cmplt ), pkt.len ) ); - copy_from_user ( &cmplt.pkt, rx->cmplt, offset, - sizeof ( cmplt.pkt.len ) ); + cmplt = &rx->cmplt.rx[index]; /* Copy data */ if ( iobuf ) { - len = be16_to_cpu ( cmplt.pkt.len ); - copy_from_user ( iob_put ( iobuf, len ), - gve_buffer ( rx, rx->cons ), - 0, len ); + len = be16_to_cpu ( cmplt->pkt.len ); + memcpy ( iob_put ( iobuf, len ), + gve_buffer ( rx, rx->cons ), len ); } } assert ( ( iobuf == NULL ) || ( iob_len ( iobuf ) == total ) ); @@ -1376,7 +1368,7 @@ static void gve_poll_rx ( struct net_device *netdev ) { iob_pull ( iobuf, GVE_RX_PAD ); netdev_rx ( netdev, iobuf ); } else { - rc = ( ( cmplt.pkt.flags & GVE_RXF_ERROR ) ? + rc = ( ( cmplt->pkt.flags & GVE_RXF_ERROR ) ? -EIO : -ENOMEM ); netdev_rx_err ( netdev, NULL, rc ); } diff --git a/src/drivers/net/gve.h b/src/drivers/net/gve.h index 43517cc55..881c25fe2 100644 --- a/src/drivers/net/gve.h +++ b/src/drivers/net/gve.h @@ -17,7 +17,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include #include #include @@ -459,7 +458,7 @@ struct gve_resources { */ struct gve_qpl { /** Page addresses */ - userptr_t data; + void *data; /** Page mapping */ struct dma_mapping map; /** Number of pages */ @@ -569,9 +568,21 @@ struct gve_rx_completion { /** A descriptor queue */ struct gve_queue { /** Descriptor ring */ - userptr_t desc; + union { + /** Transmit descriptors */ + struct gve_tx_descriptor *tx; + /** Receive descriptors */ + struct gve_rx_descriptor *rx; + /** Raw data */ + void *raw; + } desc; /** Completion ring */ - userptr_t cmplt; + union { + /** Receive completions */ + struct gve_rx_completion *rx; + /** Raw data */ + void *raw; + } cmplt; /** Queue resources */ struct gve_resources *res; -- cgit v1.2.3-55-g7522 From e8ffe2cd644000c1cca51c40ba14edb546ca769b Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 24 Apr 2025 01:30:50 +0100 Subject: [uaccess] Remove trivial uses of userptr_t Signed-off-by: Michael Brown --- src/arch/x86/core/vram_settings.c | 5 +++-- src/arch/x86/image/pxe_image.c | 2 +- src/arch/x86/include/realmode.h | 4 ++-- src/arch/x86/interface/pxe/pxe_preboot.c | 5 ++--- src/arch/x86/interface/pxe/pxe_tftp.c | 12 +++++------- src/arch/x86/interface/pxe/pxe_udp.c | 9 ++++----- src/core/cachedhcp.c | 4 ++-- src/core/dma.c | 2 +- src/core/fdt.c | 6 +++--- src/drivers/infiniband/arbel.c | 2 +- src/drivers/infiniband/arbel.h | 5 ++--- src/drivers/infiniband/golan.c | 12 ++++++------ src/drivers/infiniband/golan.h | 2 +- src/drivers/infiniband/hermon.c | 2 +- src/drivers/infiniband/hermon.h | 5 ++--- src/drivers/net/efi/nii.c | 2 +- src/drivers/net/netvsc.c | 2 +- src/drivers/net/netvsc.h | 2 +- src/drivers/usb/xhci.h | 3 +-- src/image/segment.c | 2 +- src/include/ipxe/cachedhcp.h | 3 +-- src/include/ipxe/linux_sysfs.h | 4 +--- src/include/ipxe/memblock.h | 3 +-- src/include/ipxe/segment.h | 4 ++-- src/include/ipxe/vmbus.h | 3 +-- src/interface/efi/efi_block.c | 3 +-- src/interface/efi/efi_bofm.c | 3 +-- src/interface/efi/efi_cachedhcp.c | 10 ++++------ src/interface/efi/efi_file.c | 17 +++++++---------- src/interface/hyperv/vmbus.c | 4 ++-- src/interface/linux/linux_acpi.c | 1 + src/interface/linux/linux_smbios.c | 1 + src/interface/linux/linux_sysfs.c | 6 +++--- src/tests/bofm_test.c | 5 ++--- 34 files changed, 69 insertions(+), 86 deletions(-) (limited to 'src/drivers') diff --git a/src/arch/x86/core/vram_settings.c b/src/arch/x86/core/vram_settings.c index ceeada467..a97a463fe 100644 --- a/src/arch/x86/core/vram_settings.c +++ b/src/arch/x86/core/vram_settings.c @@ -23,6 +23,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +#include #include #include @@ -47,12 +48,12 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * @ret len Length of setting data, or negative error */ static int vram_fetch ( void *data, size_t len ) { - userptr_t vram = phys_to_virt ( VRAM_BASE ); + const void *vram = phys_to_virt ( VRAM_BASE ); /* Copy video RAM */ if ( len > VRAM_LEN ) len = VRAM_LEN; - copy_from_user ( data, vram, 0, len ); + memcpy ( data, vram, len ); return VRAM_LEN; } diff --git a/src/arch/x86/image/pxe_image.c b/src/arch/x86/image/pxe_image.c index 5472ea594..9f8044fa1 100644 --- a/src/arch/x86/image/pxe_image.c +++ b/src/arch/x86/image/pxe_image.c @@ -54,7 +54,7 @@ const char *pxe_cmdline; * @ret rc Return status code */ static int pxe_exec ( struct image *image ) { - userptr_t buffer = real_to_virt ( 0, 0x7c00 ); + void *buffer = real_to_virt ( 0, 0x7c00 ); struct net_device *netdev; int rc; diff --git a/src/arch/x86/include/realmode.h b/src/arch/x86/include/realmode.h index 0017b42c0..75f7d16e7 100644 --- a/src/arch/x86/include/realmode.h +++ b/src/arch/x86/include/realmode.h @@ -87,7 +87,7 @@ real_to_virt ( unsigned int segment, unsigned int offset ) { static inline __always_inline void copy_to_real ( unsigned int dest_seg, unsigned int dest_off, void *src, size_t n ) { - copy_to_user ( real_to_virt ( dest_seg, dest_off ), 0, src, n ); + memcpy ( real_to_virt ( dest_seg, dest_off ), src, n ); } /** @@ -101,7 +101,7 @@ copy_to_real ( unsigned int dest_seg, unsigned int dest_off, static inline __always_inline void copy_from_real ( void *dest, unsigned int src_seg, unsigned int src_off, size_t n ) { - copy_from_user ( dest, real_to_virt ( src_seg, src_off ), 0, n ); + memcpy ( dest, real_to_virt ( src_seg, src_off ), n ); } /** diff --git a/src/arch/x86/interface/pxe/pxe_preboot.c b/src/arch/x86/interface/pxe/pxe_preboot.c index 727d8e1ea..77dcf66e7 100644 --- a/src/arch/x86/interface/pxe/pxe_preboot.c +++ b/src/arch/x86/interface/pxe/pxe_preboot.c @@ -33,7 +33,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include #include #include #include @@ -184,7 +183,7 @@ pxenv_get_cached_info ( struct s_PXENV_GET_CACHED_INFO *get_cached_info ) { union pxe_cached_info *info; unsigned int idx; size_t len; - userptr_t buffer; + void *buffer; DBGC ( &pxe_netdev, "PXENV_GET_CACHED_INFO %s to %04x:%04x+%x", pxenv_get_cached_info_name ( get_cached_info->PacketType ), @@ -245,7 +244,7 @@ pxenv_get_cached_info ( struct s_PXENV_GET_CACHED_INFO *get_cached_info ) { DBGC ( &pxe_netdev, " buffer may be too short" ); buffer = real_to_virt ( get_cached_info->Buffer.segment, get_cached_info->Buffer.offset ); - copy_to_user ( buffer, 0, info, len ); + memcpy ( buffer, info, len ); get_cached_info->BufferSize = len; } diff --git a/src/arch/x86/interface/pxe/pxe_tftp.c b/src/arch/x86/interface/pxe/pxe_tftp.c index 073414dce..aa675fd13 100644 --- a/src/arch/x86/interface/pxe/pxe_tftp.c +++ b/src/arch/x86/interface/pxe/pxe_tftp.c @@ -33,7 +33,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include #include #include #include @@ -49,7 +48,7 @@ struct pxe_tftp_connection { /** Data transfer interface */ struct interface xfer; /** Data buffer */ - userptr_t buffer; + void *buffer; /** Size of data buffer */ size_t size; /** Starting offset of data buffer */ @@ -121,9 +120,8 @@ static int pxe_tftp_xfer_deliver ( struct pxe_tftp_connection *pxe_tftp, ( pxe_tftp->start + pxe_tftp->size ) ); rc = -ENOBUFS; } else { - copy_to_user ( pxe_tftp->buffer, - ( pxe_tftp->offset - pxe_tftp->start ), - iobuf->data, len ); + memcpy ( ( pxe_tftp->buffer + pxe_tftp->offset - + pxe_tftp->start ), iobuf->data, len ); } /* Calculate new buffer position */ @@ -385,7 +383,7 @@ static PXENV_EXIT_t pxenv_tftp_read ( struct s_PXENV_TFTP_READ *tftp_read ) { while ( ( ( rc = pxe_tftp.rc ) == -EINPROGRESS ) && ( pxe_tftp.offset == pxe_tftp.start ) ) step(); - pxe_tftp.buffer = UNULL; + pxe_tftp.buffer = NULL; tftp_read->BufferSize = ( pxe_tftp.offset - pxe_tftp.start ); tftp_read->PacketNumber = ++pxe_tftp.blkidx; @@ -496,7 +494,7 @@ PXENV_EXIT_t pxenv_tftp_read_file ( struct s_PXENV_TFTP_READ_FILE pxe_tftp.size = tftp_read_file->BufferSize; while ( ( rc = pxe_tftp.rc ) == -EINPROGRESS ) step(); - pxe_tftp.buffer = UNULL; + pxe_tftp.buffer = NULL; tftp_read_file->BufferSize = pxe_tftp.max_offset; /* Close TFTP file */ diff --git a/src/arch/x86/interface/pxe/pxe_udp.c b/src/arch/x86/interface/pxe/pxe_udp.c index 47abb7df4..61c858dde 100644 --- a/src/arch/x86/interface/pxe/pxe_udp.c +++ b/src/arch/x86/interface/pxe/pxe_udp.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -296,7 +295,7 @@ pxenv_udp_write ( struct s_PXENV_UDP_WRITE *pxenv_udp_write ) { }; size_t len; struct io_buffer *iobuf; - userptr_t buffer; + const void *buffer; int rc; DBG ( "PXENV_UDP_WRITE" ); @@ -330,7 +329,7 @@ pxenv_udp_write ( struct s_PXENV_UDP_WRITE *pxenv_udp_write ) { } buffer = real_to_virt ( pxenv_udp_write->buffer.segment, pxenv_udp_write->buffer.offset ); - copy_from_user ( iob_put ( iobuf, len ), buffer, 0, len ); + memcpy ( iob_put ( iobuf, len ), buffer, len ); DBG ( " %04x:%04x+%x %d->%s:%d\n", pxenv_udp_write->buffer.segment, pxenv_udp_write->buffer.offset, pxenv_udp_write->buffer_size, @@ -400,7 +399,7 @@ static PXENV_EXIT_t pxenv_udp_read ( struct s_PXENV_UDP_READ *pxenv_udp_read ) { struct pxe_udp_pseudo_header *pshdr; uint16_t d_port_wanted = pxenv_udp_read->d_port; uint16_t d_port; - userptr_t buffer; + void *buffer; size_t len; /* Try receiving a packet, if the queue is empty */ @@ -443,7 +442,7 @@ static PXENV_EXIT_t pxenv_udp_read ( struct s_PXENV_UDP_READ *pxenv_udp_read ) { len = iob_len ( iobuf ); if ( len > pxenv_udp_read->buffer_size ) len = pxenv_udp_read->buffer_size; - copy_to_user ( buffer, 0, iobuf->data, len ); + memcpy ( buffer, iobuf->data, len ); pxenv_udp_read->buffer_size = len; /* Fill in source/dest information */ diff --git a/src/core/cachedhcp.c b/src/core/cachedhcp.c index 07589f0b8..0d400db16 100644 --- a/src/core/cachedhcp.c +++ b/src/core/cachedhcp.c @@ -198,7 +198,7 @@ static int cachedhcp_apply ( struct cached_dhcp_packet *cache, * @ret rc Return status code */ int cachedhcp_record ( struct cached_dhcp_packet *cache, unsigned int vlan, - userptr_t data, size_t max_len ) { + const void *data, size_t max_len ) { struct dhcp_packet *dhcppkt; struct dhcp_packet *tmp; struct dhcphdr *dhcphdr; @@ -216,7 +216,7 @@ int cachedhcp_record ( struct cached_dhcp_packet *cache, unsigned int vlan, return -ENOMEM; } dhcphdr = ( ( ( void * ) dhcppkt ) + sizeof ( *dhcppkt ) ); - copy_from_user ( dhcphdr, data, 0, max_len ); + memcpy ( dhcphdr, data, max_len ); dhcppkt_init ( dhcppkt, dhcphdr, max_len ); /* Shrink packet to required length. If reallocation fails, diff --git a/src/core/dma.c b/src/core/dma.c index 1f3c1d8a6..cf4b20379 100644 --- a/src/core/dma.c +++ b/src/core/dma.c @@ -136,7 +136,7 @@ static void * dma_op_umalloc ( struct dma_device *dma, struct dma_operations *op = dma->op; if ( ! op ) - return UNULL; + return NULL; return op->umalloc ( dma, map, len, align ); } diff --git a/src/core/fdt.c b/src/core/fdt.c index 4c709b342..7c7127aed 100644 --- a/src/core/fdt.c +++ b/src/core/fdt.c @@ -1037,7 +1037,7 @@ static int fdt_urealloc ( struct fdt *fdt, size_t len ) { assert ( len >= fdt->used ); /* Attempt reallocation */ - new = urealloc ( virt_to_user ( fdt->raw ), len ); + new = urealloc ( fdt->raw, len ); if ( ! new ) { DBGC ( fdt, "FDT could not reallocate from +%#04zx to " "+%#04zx\n", fdt->len, len ); @@ -1129,7 +1129,7 @@ int fdt_create ( struct fdt_header **hdr, const char *cmdline ) { return 0; err_bootargs: - ufree ( virt_to_user ( fdt.raw ) ); + ufree ( fdt.raw ); err_alloc: err_image: return rc; @@ -1143,7 +1143,7 @@ int fdt_create ( struct fdt_header **hdr, const char *cmdline ) { void fdt_remove ( struct fdt_header *hdr ) { /* Free modifiable copy */ - ufree ( virt_to_user ( hdr ) ); + ufree ( hdr ); } /* Drag in objects via fdt_describe() */ diff --git a/src/drivers/infiniband/arbel.c b/src/drivers/infiniband/arbel.c index 4cb4167e0..0789ea593 100644 --- a/src/drivers/infiniband/arbel.c +++ b/src/drivers/infiniband/arbel.c @@ -2119,7 +2119,7 @@ static void arbel_stop_firmware ( struct arbel *arbel ) { DBGC ( arbel, "Arbel %p FATAL could not stop firmware: %s\n", arbel, strerror ( rc ) ); /* Leak memory and return; at least we avoid corruption */ - arbel->firmware_area = UNULL; + arbel->firmware_area = NULL; return; } } diff --git a/src/drivers/infiniband/arbel.h b/src/drivers/infiniband/arbel.h index 8a5a996a3..a31e59934 100644 --- a/src/drivers/infiniband/arbel.h +++ b/src/drivers/infiniband/arbel.h @@ -10,7 +10,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include -#include #include #include "mlx_bitops.h" #include "MT25218_PRM.h" @@ -492,7 +491,7 @@ struct arbel { * final teardown, in order to avoid memory map changes at * runtime. */ - userptr_t firmware_area; + void *firmware_area; /** ICM size */ size_t icm_len; /** ICM AUX size */ @@ -503,7 +502,7 @@ struct arbel { * final teardown, in order to avoid memory map changes at * runtime. */ - userptr_t icm; + void *icm; /** Offset within ICM of doorbell records */ size_t db_rec_offset; /** Doorbell records */ diff --git a/src/drivers/infiniband/golan.c b/src/drivers/infiniband/golan.c index a33bad9ff..ffa78fabf 100755 --- a/src/drivers/infiniband/golan.c +++ b/src/drivers/infiniband/golan.c @@ -52,7 +52,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); struct golan_page { struct list_head list; - userptr_t addr; + void *addr; }; static void golan_free_fw_areas ( struct golan *golan ) { @@ -61,7 +61,7 @@ static void golan_free_fw_areas ( struct golan *golan ) { for (i = 0; i < GOLAN_FW_AREAS_NUM; i++) { if ( golan->fw_areas[i].area ) { ufree ( golan->fw_areas[i].area ); - golan->fw_areas[i].area = UNULL; + golan->fw_areas[i].area = NULL; } } } @@ -75,7 +75,7 @@ static int golan_init_fw_areas ( struct golan *golan ) { } for (i = 0; i < GOLAN_FW_AREAS_NUM; i++) - golan->fw_areas[i].area = UNULL; + golan->fw_areas[i].area = NULL; return rc; @@ -448,12 +448,12 @@ static inline int golan_provide_pages ( struct golan *golan , uint32_t pages int size_ibox = 0; int size_obox = 0; int rc = 0; - userptr_t next_page_addr = UNULL; + void *next_page_addr = NULL; DBGC(golan, "%s\n", __FUNCTION__); if ( ! fw_area->area ) { fw_area->area = umalloc ( GOLAN_PAGE_SIZE * pages ); - if ( fw_area->area == UNULL ) { + if ( fw_area->area == NULL ) { rc = -ENOMEM; DBGC (golan ,"Failed to allocated %d pages \n",pages); goto err_golan_alloc_fw_area; @@ -467,7 +467,7 @@ static inline int golan_provide_pages ( struct golan *golan , uint32_t pages unsigned i, j; struct golan_cmd_layout *cmd; struct golan_manage_pages_inbox *in; - userptr_t addr = 0; + void *addr = NULL; mailbox = GET_INBOX(golan, MEM_MBOX); size_ibox = sizeof(struct golan_manage_pages_inbox) + (pas_num * GOLAN_PAS_SIZE); diff --git a/src/drivers/infiniband/golan.h b/src/drivers/infiniband/golan.h index f7da1e960..8122f8d38 100755 --- a/src/drivers/infiniband/golan.h +++ b/src/drivers/infiniband/golan.h @@ -121,7 +121,7 @@ struct golan_firmware_area { * final teardown, in order to avoid memory map changes at * runtime. */ - userptr_t area; + void *area; }; /* Queue Pair */ #define GOLAN_SEND_WQE_BB_SIZE 64 diff --git a/src/drivers/infiniband/hermon.c b/src/drivers/infiniband/hermon.c index 3138d8bfb..d25f4f011 100644 --- a/src/drivers/infiniband/hermon.c +++ b/src/drivers/infiniband/hermon.c @@ -2422,7 +2422,7 @@ static void hermon_stop_firmware ( struct hermon *hermon ) { DBGC ( hermon, "Hermon %p FATAL could not stop firmware: %s\n", hermon, strerror ( rc ) ); /* Leak memory and return; at least we avoid corruption */ - hermon->firmware_area = UNULL; + hermon->firmware_area = NULL; return; } } diff --git a/src/drivers/infiniband/hermon.h b/src/drivers/infiniband/hermon.h index a952bbd81..be79ff9d0 100644 --- a/src/drivers/infiniband/hermon.h +++ b/src/drivers/infiniband/hermon.h @@ -10,7 +10,6 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include -#include #include #include #include @@ -887,7 +886,7 @@ struct hermon { * final teardown, in order to avoid memory map changes at * runtime. */ - userptr_t firmware_area; + void *firmware_area; /** ICM map */ struct hermon_icm_map icm_map[HERMON_ICM_NUM_REGIONS]; /** ICM size */ @@ -900,7 +899,7 @@ struct hermon { * final teardown, in order to avoid memory map changes at * runtime. */ - userptr_t icm; + void *icm; /** Event queue */ struct hermon_event_queue eq; diff --git a/src/drivers/net/efi/nii.c b/src/drivers/net/efi/nii.c index 6381fb2dd..c60d4ca18 100644 --- a/src/drivers/net/efi/nii.c +++ b/src/drivers/net/efi/nii.c @@ -177,7 +177,7 @@ struct nii_nic { size_t mtu; /** Hardware transmit/receive buffer */ - userptr_t buffer; + void *buffer; /** Hardware transmit/receive buffer length */ size_t buffer_len; diff --git a/src/drivers/net/netvsc.c b/src/drivers/net/netvsc.c index 5be52fb8e..4bdf7b517 100644 --- a/src/drivers/net/netvsc.c +++ b/src/drivers/net/netvsc.c @@ -622,7 +622,7 @@ static int netvsc_buffer_copy ( struct vmbus_xfer_pages *pages, void *data, return -ERANGE; /* Copy data from buffer */ - copy_from_user ( data, buffer->data, offset, len ); + memcpy ( data, ( buffer->data + offset ), len ); return 0; } diff --git a/src/drivers/net/netvsc.h b/src/drivers/net/netvsc.h index 93192357f..41db49af7 100644 --- a/src/drivers/net/netvsc.h +++ b/src/drivers/net/netvsc.h @@ -305,7 +305,7 @@ struct netvsc_buffer { /** Buffer length */ size_t len; /** Buffer */ - userptr_t data; + void *data; /** GPADL ID */ unsigned int gpadl; }; diff --git a/src/drivers/usb/xhci.h b/src/drivers/usb/xhci.h index a3c8888af..22bc115c2 100644 --- a/src/drivers/usb/xhci.h +++ b/src/drivers/usb/xhci.h @@ -11,7 +11,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include -#include #include /** Minimum alignment required for data structures @@ -1054,7 +1053,7 @@ struct xhci_scratchpad { /** Number of page-sized scratchpad buffers */ unsigned int count; /** Scratchpad buffer area */ - userptr_t buffer; + void *buffer; /** Buffer DMA mapping */ struct dma_mapping buffer_map; /** Scratchpad array */ diff --git a/src/image/segment.c b/src/image/segment.c index ebc2b703d..2cb637dc2 100644 --- a/src/image/segment.c +++ b/src/image/segment.c @@ -57,7 +57,7 @@ struct errortab segment_errors[] __errortab = { * @v memsz Size of the segment * @ret rc Return status code */ -int prep_segment ( userptr_t segment, size_t filesz, size_t memsz ) { +int prep_segment ( void *segment, size_t filesz, size_t memsz ) { struct memory_map memmap; physaddr_t start = virt_to_phys ( segment ); physaddr_t mid = ( start + filesz ); diff --git a/src/include/ipxe/cachedhcp.h b/src/include/ipxe/cachedhcp.h index 8ebee3b7b..5b19bc59e 100644 --- a/src/include/ipxe/cachedhcp.h +++ b/src/include/ipxe/cachedhcp.h @@ -10,7 +10,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include -#include struct net_device; struct cached_dhcp_packet; @@ -20,7 +19,7 @@ extern struct cached_dhcp_packet cached_proxydhcp; extern struct cached_dhcp_packet cached_pxebs; extern int cachedhcp_record ( struct cached_dhcp_packet *cache, - unsigned int vlan, userptr_t data, + unsigned int vlan, const void *data, size_t max_len ); extern void cachedhcp_recycle ( struct net_device *netdev ); diff --git a/src/include/ipxe/linux_sysfs.h b/src/include/ipxe/linux_sysfs.h index d97b649c0..fbe1e6e8a 100644 --- a/src/include/ipxe/linux_sysfs.h +++ b/src/include/ipxe/linux_sysfs.h @@ -9,8 +9,6 @@ FILE_LICENCE ( GPL2_OR_LATER ); -#include - -extern int linux_sysfs_read ( const char *filename, userptr_t *data ); +extern int linux_sysfs_read ( const char *filename, void **data ); #endif /* _IPXE_LINUX_SYSFS_H */ diff --git a/src/include/ipxe/memblock.h b/src/include/ipxe/memblock.h index 2bb38c460..4b6c64156 100644 --- a/src/include/ipxe/memblock.h +++ b/src/include/ipxe/memblock.h @@ -10,8 +10,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include -#include -extern size_t largest_memblock ( userptr_t *start ); +extern size_t largest_memblock ( void **start ); #endif /* _IPXE_MEMBLOCK_H */ diff --git a/src/include/ipxe/segment.h b/src/include/ipxe/segment.h index 9d5ecbd9b..b37c93c93 100644 --- a/src/include/ipxe/segment.h +++ b/src/include/ipxe/segment.h @@ -10,8 +10,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); -#include +#include -extern int prep_segment ( userptr_t segment, size_t filesz, size_t memsz ); +extern int prep_segment ( void *segment, size_t filesz, size_t memsz ); #endif /* _IPXE_SEGMENT_H */ diff --git a/src/include/ipxe/vmbus.h b/src/include/ipxe/vmbus.h index 682441857..5eee230fe 100644 --- a/src/include/ipxe/vmbus.h +++ b/src/include/ipxe/vmbus.h @@ -13,7 +13,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include #include #include @@ -634,7 +633,7 @@ vmbus_gpadl_is_obsolete ( unsigned int gpadl ) { return ( gpadl <= vmbus_obsolete_gpadl ); } -extern int vmbus_establish_gpadl ( struct vmbus_device *vmdev, userptr_t data, +extern int vmbus_establish_gpadl ( struct vmbus_device *vmdev, void *data, size_t len ); extern int vmbus_gpadl_teardown ( struct vmbus_device *vmdev, unsigned int gpadl ); diff --git a/src/interface/efi/efi_block.c b/src/interface/efi/efi_block.c index 5165bd804..94e2aae06 100644 --- a/src/interface/efi/efi_block.c +++ b/src/interface/efi/efi_block.c @@ -110,8 +110,7 @@ static int efi_block_rw ( struct san_device *sandev, uint64_t lba, } /* Read from / write to block device */ - if ( ( rc = sandev_rw ( sandev, lba, count, - virt_to_user ( data ) ) ) != 0 ) { + if ( ( rc = sandev_rw ( sandev, lba, count, data ) ) != 0 ) { DBGC ( sandev->drive, "EFIBLK %#02x I/O failed: %s\n", sandev->drive, strerror ( rc ) ); return rc; diff --git a/src/interface/efi/efi_bofm.c b/src/interface/efi/efi_bofm.c index b64770d8a..7d1d3619f 100644 --- a/src/interface/efi/efi_bofm.c +++ b/src/interface/efi/efi_bofm.c @@ -284,8 +284,7 @@ static int efi_bofm_start ( struct efi_device *efidev ) { efi_handle_name ( device ) ); DBGC2_HD ( device, bofmtab2, bofmtab2->Parameters.Length ); } - bofmrc = bofm ( virt_to_user ( bofmtab2 ? bofmtab2 : bofmtab ), - &efipci.pci ); + bofmrc = bofm ( ( bofmtab2 ? bofmtab2 : bofmtab ), &efipci.pci ); DBGC ( device, "EFIBOFM %s status %08x\n", efi_handle_name ( device ), bofmrc ); DBGC2 ( device, "EFIBOFM %s version 1 after processing:\n", diff --git a/src/interface/efi/efi_cachedhcp.c b/src/interface/efi/efi_cachedhcp.c index eb41a8e43..6bba4173a 100644 --- a/src/interface/efi/efi_cachedhcp.c +++ b/src/interface/efi/efi_cachedhcp.c @@ -72,8 +72,7 @@ int efi_cachedhcp_record ( EFI_HANDLE device, /* Record DHCPACK, if present */ if ( mode->DhcpAckReceived && - ( ( rc = cachedhcp_record ( &cached_dhcpack, vlan, - virt_to_user ( &mode->DhcpAck ), + ( ( rc = cachedhcp_record ( &cached_dhcpack, vlan, &mode->DhcpAck, sizeof ( mode->DhcpAck ) ) ) != 0 ) ) { DBGC ( device, "EFI %s could not record DHCPACK: %s\n", efi_handle_name ( device ), strerror ( rc ) ); @@ -83,7 +82,7 @@ int efi_cachedhcp_record ( EFI_HANDLE device, /* Record ProxyDHCPOFFER, if present */ if ( mode->ProxyOfferReceived && ( ( rc = cachedhcp_record ( &cached_proxydhcp, vlan, - virt_to_user ( &mode->ProxyOffer ), + &mode->ProxyOffer, sizeof ( mode->ProxyOffer ) ) ) != 0)){ DBGC ( device, "EFI %s could not record ProxyDHCPOFFER: %s\n", efi_handle_name ( device ), strerror ( rc ) ); @@ -92,9 +91,8 @@ int efi_cachedhcp_record ( EFI_HANDLE device, /* Record PxeBSACK, if present */ if ( mode->PxeReplyReceived && - ( ( rc = cachedhcp_record ( &cached_pxebs, vlan, - virt_to_user ( &mode->PxeReply ), - sizeof ( mode->PxeReply ) ) ) != 0)){ + ( ( rc = cachedhcp_record ( &cached_pxebs, vlan, &mode->PxeReply, + sizeof ( mode->PxeReply ) ) ) != 0 )){ DBGC ( device, "EFI %s could not record PXEBSACK: %s\n", efi_handle_name ( device ), strerror ( rc ) ); return rc; diff --git a/src/interface/efi/efi_file.c b/src/interface/efi/efi_file.c index b7b97aee7..79330641d 100644 --- a/src/interface/efi/efi_file.c +++ b/src/interface/efi/efi_file.c @@ -177,12 +177,12 @@ static size_t efi_file_len ( struct efi_file *file ) { * Read chunk of EFI file * * @v reader EFI file reader - * @v data Input data, or UNULL to zero-fill + * @v data Input data, or NULL to zero-fill * @v len Length of input data * @ret len Length of output data */ static size_t efi_file_read_chunk ( struct efi_file_reader *reader, - userptr_t data, size_t len ) { + const void *data, size_t len ) { struct efi_file *file = reader->file; size_t offset; @@ -203,7 +203,7 @@ static size_t efi_file_read_chunk ( struct efi_file_reader *reader, /* Copy or zero output data */ if ( data ) { - copy_from_user ( reader->data, data, offset, len ); + memcpy ( reader->data, ( data + offset ), len ); } else { memset ( reader->data, 0, len ); } @@ -262,7 +262,7 @@ static size_t efi_file_read_initrd ( struct efi_file_reader *reader ) { efi_file_name ( file ), reader->pos, ( reader->pos + pad_len ) ); } - len += efi_file_read_chunk ( reader, UNULL, pad_len ); + len += efi_file_read_chunk ( reader, NULL, pad_len ); /* Read CPIO header(s), if applicable */ name = cpio_name ( image ); @@ -274,13 +274,10 @@ static size_t efi_file_read_initrd ( struct efi_file_reader *reader ) { efi_file_name ( file ), reader->pos, ( reader->pos + cpio_len + pad_len ), image->name ); - len += efi_file_read_chunk ( reader, - virt_to_user ( &cpio ), + len += efi_file_read_chunk ( reader, &cpio, sizeof ( cpio ) ); - len += efi_file_read_chunk ( reader, - virt_to_user ( name ), - name_len ); - len += efi_file_read_chunk ( reader, UNULL, pad_len ); + len += efi_file_read_chunk ( reader, name, name_len ); + len += efi_file_read_chunk ( reader, NULL, pad_len ); } /* Read file data */ diff --git a/src/interface/hyperv/vmbus.c b/src/interface/hyperv/vmbus.c index 49ccf69c8..1c44cab5e 100644 --- a/src/interface/hyperv/vmbus.c +++ b/src/interface/hyperv/vmbus.c @@ -273,7 +273,7 @@ static int vmbus_negotiate_version ( struct hv_hypervisor *hv ) { * @v len Length of data buffer * @ret gpadl GPADL ID, or negative error */ -int vmbus_establish_gpadl ( struct vmbus_device *vmdev, userptr_t data, +int vmbus_establish_gpadl ( struct vmbus_device *vmdev, void *data, size_t len ) { struct hv_hypervisor *hv = vmdev->hv; struct vmbus *vmbus = hv->vmbus; @@ -442,7 +442,7 @@ int vmbus_open ( struct vmbus_device *vmdev, memset ( ring, 0, len ); /* Establish GPADL for ring buffer */ - gpadl = vmbus_establish_gpadl ( vmdev, virt_to_user ( ring ), len ); + gpadl = vmbus_establish_gpadl ( vmdev, ring, len ); if ( gpadl < 0 ) { rc = gpadl; goto err_establish; diff --git a/src/interface/linux/linux_acpi.c b/src/interface/linux/linux_acpi.c index a2a8bf12e..21a2e27cc 100644 --- a/src/interface/linux/linux_acpi.c +++ b/src/interface/linux/linux_acpi.c @@ -21,6 +21,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include #include +#include #include #include #include diff --git a/src/interface/linux/linux_smbios.c b/src/interface/linux/linux_smbios.c index a12c936ed..1450fcf1b 100644 --- a/src/interface/linux/linux_smbios.c +++ b/src/interface/linux/linux_smbios.c @@ -19,6 +19,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); +#include #include #include #include diff --git a/src/interface/linux/linux_sysfs.c b/src/interface/linux/linux_sysfs.c index cbb23d81d..321824ba9 100644 --- a/src/interface/linux/linux_sysfs.c +++ b/src/interface/linux/linux_sysfs.c @@ -42,8 +42,8 @@ FILE_LICENCE ( GPL2_OR_LATER ); * @v data Data to fill in * @ret len Length read, or negative error */ -int linux_sysfs_read ( const char *filename, userptr_t *data ) { - userptr_t tmp; +int linux_sysfs_read ( const char *filename, void **data ) { + void *tmp; ssize_t read; size_t len; int fd; @@ -59,7 +59,7 @@ int linux_sysfs_read ( const char *filename, userptr_t *data ) { } /* Read file */ - for ( *data = UNULL, len = 0 ; ; len += read ) { + for ( *data = NULL, len = 0 ; ; len += read ) { /* (Re)allocate space */ tmp = urealloc ( *data, ( len + LINUX_SYSFS_BLKSIZE ) ); diff --git a/src/tests/bofm_test.c b/src/tests/bofm_test.c index 829924887..dbef1eb90 100644 --- a/src/tests/bofm_test.c +++ b/src/tests/bofm_test.c @@ -26,7 +26,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include #include #include #include @@ -111,7 +110,7 @@ void bofm_test ( struct pci_device *pci ) { printf ( "BOFMTEST performing harvest\n" ); bofmtab_harvest.en.busdevfn = pci->busdevfn; DBG_HDA ( 0, &bofmtab_harvest, sizeof ( bofmtab_harvest ) ); - bofmrc = bofm ( virt_to_user ( &bofmtab_harvest ), pci ); + bofmrc = bofm ( &bofmtab_harvest, pci ); printf ( "BOFMTEST harvest result %08x\n", bofmrc ); if ( bofmtab_harvest.en.options & BOFM_EN_HVST ) { printf ( "BOFMTEST harvested MAC address %s\n", @@ -125,7 +124,7 @@ void bofm_test ( struct pci_device *pci ) { printf ( "BOFMTEST performing update\n" ); bofmtab_update.en.busdevfn = pci->busdevfn; DBG_HDA ( 0, &bofmtab_update, sizeof ( bofmtab_update ) ); - bofmrc = bofm ( virt_to_user ( &bofmtab_update ), pci ); + bofmrc = bofm ( &bofmtab_update, pci ); printf ( "BOFMTEST update result %08x\n", bofmrc ); if ( bofmtab_update.en.options & BOFM_EN_CSM_SUCCESS ) { printf ( "BOFMTEST updated MAC address to %s\n", -- cgit v1.2.3-55-g7522 From 8ac03b4a73d1d21a233ec3a210967a818f0fd19e Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 24 Apr 2025 10:56:21 +0100 Subject: [exanic] Replace uses of userptr_t with direct pointer dereferences Signed-off-by: Michael Brown --- src/drivers/net/exanic.c | 33 ++++++++++++--------------------- src/drivers/net/exanic.h | 6 ++++-- 2 files changed, 16 insertions(+), 23 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/exanic.c b/src/drivers/net/exanic.c index b3148e090..a36f7a774 100644 --- a/src/drivers/net/exanic.c +++ b/src/drivers/net/exanic.c @@ -540,26 +540,23 @@ static void exanic_poll_tx ( struct net_device *netdev ) { static void exanic_poll_rx ( struct net_device *netdev ) { struct exanic_port *port = netdev->priv; struct exanic_rx_chunk *rx; - struct exanic_rx_descriptor desc; + unsigned int index; uint8_t current; uint8_t previous; - size_t offset; size_t len; for ( ; ; port->rx_cons++ ) { /* Fetch descriptor */ - offset = ( ( port->rx_cons * sizeof ( *rx ) ) % EXANIC_RX_LEN ); - copy_from_user ( &desc, port->rx, - ( offset + offsetof ( typeof ( *rx ), desc ) ), - sizeof ( desc ) ); + index = ( port->rx_cons % EXANIC_RX_COUNT ); + rx = &port->rx[index]; /* Calculate generation */ - current = ( port->rx_cons / ( EXANIC_RX_LEN / sizeof ( *rx ) )); + current = ( port->rx_cons / EXANIC_RX_COUNT ); previous = ( current - 1 ); /* Do nothing if no chunk is ready */ - if ( desc.generation == previous ) + if ( rx->desc.generation == previous ) break; /* Allocate I/O buffer if needed */ @@ -573,14 +570,12 @@ static void exanic_poll_rx ( struct net_device *netdev ) { } /* Calculate chunk length */ - len = ( desc.len ? desc.len : sizeof ( rx->data ) ); + len = ( rx->desc.len ? rx->desc.len : sizeof ( rx->data ) ); /* Append data to I/O buffer */ if ( len <= iob_tailroom ( port->rx_iobuf ) ) { - copy_from_user ( iob_put ( port->rx_iobuf, len ), - port->rx, - ( offset + offsetof ( typeof ( *rx ), - data ) ), len ); + memcpy ( iob_put ( port->rx_iobuf, len ), + rx->data, len ); } else { DBGC ( port, "EXANIC %s RX too large\n", netdev->name ); @@ -589,23 +584,19 @@ static void exanic_poll_rx ( struct net_device *netdev ) { /* Check for overrun */ rmb(); - copy_from_user ( &desc.generation, port->rx, - ( offset + offsetof ( typeof ( *rx ), - desc.generation ) ), - sizeof ( desc.generation ) ); - if ( desc.generation != current ) { + if ( rx->desc.generation != current ) { DBGC ( port, "EXANIC %s RX overrun\n", netdev->name ); port->rx_rc = -ENOBUFS; continue; } /* Wait for end of packet */ - if ( ! desc.len ) + if ( ! rx->desc.len ) continue; /* Check for receive errors */ - if ( desc.status & EXANIC_STATUS_ERROR_MASK ) { - port->rx_rc = -EIO_STATUS ( desc.status ); + if ( rx->desc.status & EXANIC_STATUS_ERROR_MASK ) { + port->rx_rc = -EIO_STATUS ( rx->desc.status ); DBGC ( port, "EXANIC %s RX %04x error: %s\n", netdev->name, port->rx_cons, strerror ( port->rx_rc ) ); diff --git a/src/drivers/net/exanic.h b/src/drivers/net/exanic.h index 041b9e21a..7c59612e0 100644 --- a/src/drivers/net/exanic.h +++ b/src/drivers/net/exanic.h @@ -12,7 +12,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include #include #include #include @@ -158,6 +157,9 @@ struct exanic_rx_chunk { /** Receive status error mask */ #define EXANIC_STATUS_ERROR_MASK 0x0f +/** Number of receive chunks */ +#define EXANIC_RX_COUNT ( EXANIC_RX_LEN / sizeof ( struct exanic_rx_chunk ) ) + /** An ExaNIC I2C bus configuration */ struct exanic_i2c_config { /** GPIO bit for pulling SCL low */ @@ -194,7 +196,7 @@ struct exanic_port { uint16_t *txf; /** Receive region */ - userptr_t rx; + struct exanic_rx_chunk *rx; /** Receive consumer counter */ unsigned int rx_cons; /** Receive I/O buffer (if any) */ -- cgit v1.2.3-55-g7522 From f18c1472e36095b7d71c1b8ff3c6c731362cd058 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 24 Apr 2025 13:01:03 +0100 Subject: [thunderx] Replace uses of userptr_t with direct pointer dereferences Signed-off-by: Michael Brown --- src/drivers/net/thunderx.c | 53 +++++++++++++++++++--------------------------- src/drivers/net/thunderx.h | 11 +++++----- 2 files changed, 28 insertions(+), 36 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/thunderx.c b/src/drivers/net/thunderx.c index 3d213b167..482474152 100644 --- a/src/drivers/net/thunderx.c +++ b/src/drivers/net/thunderx.c @@ -89,7 +89,7 @@ static __attribute__ (( unused )) void txnic_diag ( struct txnic *vnic ) { ( ( vnic->rq.cons % TXNIC_RQES ) * TXNIC_RQ_STRIDE ), readq ( vnic->regs + TXNIC_QS_RBDR_HEAD(0) ), readq ( vnic->regs + TXNIC_QS_RBDR_STATUS0(0) ) ); - DBGC ( vnic, "TXNIC %s CQ xxxxx(%05llx)/%05x(%05llx) %08llx:%08llx\n", + DBGC ( vnic, "TXNIC %s CQ xxxxx(%05llx)/%05zx(%05llx) %08llx:%08llx\n", vnic->name, readq ( vnic->regs + TXNIC_QS_CQ_TAIL(0) ), ( ( vnic->cq.cons % TXNIC_CQES ) * TXNIC_CQ_STRIDE ), readq ( vnic->regs + TXNIC_QS_CQ_HEAD(0) ), @@ -184,9 +184,8 @@ static void txnic_destroy_sq ( struct txnic *vnic ) { * @ret rc Return status code */ static int txnic_send ( struct txnic *vnic, struct io_buffer *iobuf ) { - struct txnic_sqe sqe; + struct txnic_sqe *sqe; unsigned int sq_idx; - size_t offset; size_t len; /* Get next send queue entry */ @@ -196,24 +195,21 @@ static int txnic_send ( struct txnic *vnic, struct io_buffer *iobuf ) { return -ENOBUFS; } sq_idx = ( vnic->sq.prod++ % TXNIC_SQES ); - offset = ( sq_idx * TXNIC_SQ_STRIDE ); + sqe = &vnic->sq.sqe[sq_idx]; /* Populate send descriptor */ len = iob_len ( iobuf ); - memset ( &sqe, 0, sizeof ( sqe ) ); - sqe.hdr.total = cpu_to_le32 ( ( len >= ETH_ZLEN ) ? len : ETH_ZLEN ); - sqe.hdr.subdcnt = ( TXNIC_SQE_SUBDESCS - 1 ); - sqe.hdr.flags = TXNIC_SEND_HDR_FLAGS; - sqe.gather.size = cpu_to_le16 ( len ); - sqe.gather.flags = TXNIC_SEND_GATHER_FLAGS; - sqe.gather.addr = cpu_to_le64 ( virt_to_bus ( iobuf->data ) ); + memset ( sqe, 0, sizeof ( *sqe ) ); + sqe->hdr.total = cpu_to_le32 ( ( len >= ETH_ZLEN ) ? len : ETH_ZLEN ); + sqe->hdr.subdcnt = ( TXNIC_SQE_SUBDESCS - 1 ); + sqe->hdr.flags = TXNIC_SEND_HDR_FLAGS; + sqe->gather.size = cpu_to_le16 ( len ); + sqe->gather.flags = TXNIC_SEND_GATHER_FLAGS; + sqe->gather.addr = cpu_to_le64 ( virt_to_bus ( iobuf->data ) ); DBGC2 ( vnic, "TXNIC %s SQE %#03x is [%08lx,%08lx)\n", vnic->name, sq_idx, virt_to_bus ( iobuf->data ), ( virt_to_bus ( iobuf->data ) + len ) ); - /* Copy send descriptor to ring */ - copy_to_user ( vnic->sq.sqe, offset, &sqe, sizeof ( sqe ) ); - /* Ring doorbell */ wmb(); writeq ( TXNIC_SQE_SUBDESCS, ( vnic->regs + TXNIC_QS_SQ_DOOR(0) ) ); @@ -359,11 +355,10 @@ static void txnic_destroy_rq ( struct txnic *vnic ) { */ static void txnic_refill_rq ( struct txnic *vnic ) { struct io_buffer *iobuf; - struct txnic_rqe rqe; + struct txnic_rqe *rqe; unsigned int rq_idx; unsigned int rq_iobuf_idx; unsigned int refilled = 0; - size_t offset; /* Refill ring */ while ( ( vnic->rq.prod - vnic->rq.cons ) < TXNIC_RQ_FILL ) { @@ -377,16 +372,15 @@ static void txnic_refill_rq ( struct txnic *vnic ) { /* Get next receive descriptor */ rq_idx = ( vnic->rq.prod++ % TXNIC_RQES ); - offset = ( rq_idx * TXNIC_RQ_STRIDE ); + rqe = &vnic->rq.rqe[rq_idx]; /* Populate receive descriptor */ - rqe.rbdre.addr = cpu_to_le64 ( virt_to_bus ( iobuf->data ) ); + rqe->rbdre.addr = cpu_to_le64 ( virt_to_bus ( iobuf->data ) ); DBGC2 ( vnic, "TXNIC %s RQE %#03x is [%08lx,%08lx)\n", vnic->name, rq_idx, virt_to_bus ( iobuf->data ), ( virt_to_bus ( iobuf->data ) + TXNIC_RQE_SIZE ) ); - /* Copy receive descriptor to ring */ - copy_to_user ( vnic->rq.rqe, offset, &rqe, sizeof ( rqe ) ); + /* Record number of refills for doorbell */ refilled++; /* Record I/O buffer */ @@ -527,9 +521,8 @@ static void txnic_destroy_cq ( struct txnic *vnic ) { * @v vnic Virtual NIC */ static void txnic_poll_cq ( struct txnic *vnic ) { - union txnic_cqe cqe; + union txnic_cqe *cqe; uint64_t status; - size_t offset; unsigned int qcount; unsigned int cq_idx; unsigned int i; @@ -545,23 +538,21 @@ static void txnic_poll_cq ( struct txnic *vnic ) { /* Get completion queue entry */ cq_idx = ( vnic->cq.cons++ % TXNIC_CQES ); - offset = ( cq_idx * TXNIC_CQ_STRIDE ); - copy_from_user ( &cqe, vnic->cq.cqe, offset, sizeof ( cqe ) ); + cqe = &vnic->cq.cqe[cq_idx]; /* Process completion queue entry */ - switch ( cqe.common.cqe_type ) { + switch ( cqe->common.cqe_type ) { case TXNIC_CQE_TYPE_SEND: - txnic_complete_sqe ( vnic, &cqe.send ); + txnic_complete_sqe ( vnic, &cqe->send ); break; case TXNIC_CQE_TYPE_RX: - txnic_complete_rqe ( vnic, &cqe.rx ); + txnic_complete_rqe ( vnic, &cqe->rx ); break; default: DBGC ( vnic, "TXNIC %s unknown completion type %d\n", - vnic->name, cqe.common.cqe_type ); - DBGC_HDA ( vnic, - ( virt_to_phys ( vnic->cq.cqe ) + offset ), - &cqe, sizeof ( cqe ) ); + vnic->name, cqe->common.cqe_type ); + DBGC_HDA ( vnic, virt_to_phys ( cqe ), cqe, + sizeof ( *cqe ) ); break; } } diff --git a/src/drivers/net/thunderx.h b/src/drivers/net/thunderx.h index 410daf6e2..2d04c1271 100644 --- a/src/drivers/net/thunderx.h +++ b/src/drivers/net/thunderx.h @@ -12,7 +12,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include /****************************************************************************** * @@ -188,7 +187,7 @@ struct txnic_sq { /** Consumer counter */ unsigned int cons; /** Send queue entries */ - userptr_t sqe; + struct txnic_sqe *sqe; }; /****************************************************************************** @@ -280,7 +279,7 @@ struct txnic_rq { /** Consumer counter */ unsigned int cons; /** Receive queue entries */ - userptr_t rqe; + struct txnic_rqe *rqe; /** I/O buffers */ struct io_buffer *iobuf[TXNIC_RQ_FILL]; }; @@ -381,6 +380,8 @@ union txnic_cqe { struct txnic_cqe_send send; /** Receive completion */ struct txnic_cqe_rx rx; + /** Padding */ + uint8_t pad[512]; }; /** Number of completion queue entries @@ -393,7 +394,7 @@ union txnic_cqe { #define TXNIC_CQ_ALIGN 512 /** Completion queue stride */ -#define TXNIC_CQ_STRIDE 512 +#define TXNIC_CQ_STRIDE sizeof ( union txnic_cqe ) /** Completion queue size */ #define TXNIC_CQ_SIZE ( TXNIC_CQES * TXNIC_CQ_STRIDE ) @@ -403,7 +404,7 @@ struct txnic_cq { /** Consumer counter */ unsigned int cons; /** Completion queue entries */ - userptr_t cqe; + union txnic_cqe *cqe; }; /****************************************************************************** -- cgit v1.2.3-55-g7522 From 2f11f466e6b6cb47ac3b703b145e01f87bf8092e Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 24 Apr 2025 17:11:30 +0100 Subject: [block] Remove userptr_t from block device abstraction Simplify the block device code by assuming that all read/write buffers are directly accessible via pointer dereferences. Signed-off-by: Michael Brown --- src/arch/x86/interface/pcbios/int13.c | 17 ++++++++--------- src/core/blockdev.c | 8 ++++---- src/core/blocktrans.c | 8 ++++---- src/core/dummy_sanboot.c | 1 + src/core/sanboot.c | 23 ++++++++++++----------- src/drivers/block/ata.c | 30 +++++++++++++++--------------- src/drivers/block/scsi.c | 16 ++++++++-------- src/drivers/usb/usbblk.c | 10 +++++----- src/include/ipxe/ata.h | 5 ++--- src/include/ipxe/blockdev.h | 13 ++++++------- src/include/ipxe/blocktrans.h | 7 +++---- src/include/ipxe/sanboot.h | 4 ++-- src/include/ipxe/scsi.h | 5 ++--- src/interface/efi/efi_block.c | 5 +++-- src/net/aoe.c | 7 ++----- src/net/fcp.c | 6 +++--- src/net/tcp/httpblock.c | 5 ++--- src/net/tcp/httpcore.c | 2 +- src/net/tcp/iscsi.c | 7 +++---- 19 files changed, 86 insertions(+), 93 deletions(-) (limited to 'src/drivers') diff --git a/src/arch/x86/interface/pcbios/int13.c b/src/arch/x86/interface/pcbios/int13.c index 498676b70..73fdfebd3 100644 --- a/src/arch/x86/interface/pcbios/int13.c +++ b/src/arch/x86/interface/pcbios/int13.c @@ -181,8 +181,7 @@ static int int13_parse_eltorito ( struct san_device *sandev, void *scratch ) { int rc; /* Read boot record volume descriptor */ - if ( ( rc = sandev_read ( sandev, ELTORITO_LBA, 1, - virt_to_user ( boot ) ) ) != 0 ) { + if ( ( rc = sandev_read ( sandev, ELTORITO_LBA, 1, boot ) ) != 0 ) { DBGC ( sandev->drive, "INT13 drive %02x could not read El " "Torito boot record volume descriptor: %s\n", sandev->drive, strerror ( rc ) ); @@ -228,7 +227,7 @@ static int int13_guess_geometry_hdd ( struct san_device *sandev, void *scratch, int rc; /* Read partition table */ - if ( ( rc = sandev_read ( sandev, 0, 1, virt_to_user ( mbr ) ) ) != 0 ) { + if ( ( rc = sandev_read ( sandev, 0, 1, mbr ) ) != 0 ) { DBGC ( sandev->drive, "INT13 drive %02x could not read " "partition table to guess geometry: %s\n", sandev->drive, strerror ( rc ) ); @@ -517,12 +516,12 @@ static int int13_rw_sectors ( struct san_device *sandev, int ( * sandev_rw ) ( struct san_device *sandev, uint64_t lba, unsigned int count, - userptr_t buffer ) ) { + void *buffer ) ) { struct int13_data *int13 = sandev->priv; unsigned int cylinder, head, sector; unsigned long lba; unsigned int count; - userptr_t buffer; + void *buffer; int rc; /* Validate blocksize */ @@ -710,12 +709,12 @@ static int int13_extended_rw ( struct san_device *sandev, int ( * sandev_rw ) ( struct san_device *sandev, uint64_t lba, unsigned int count, - userptr_t buffer ) ) { + void *buffer ) ) { struct int13_disk_address addr; uint8_t bufsize; uint64_t lba; unsigned long count; - userptr_t buffer; + void *buffer; int rc; /* Extended reads are not allowed on floppy drives. @@ -1455,8 +1454,8 @@ static int int13_load_eltorito ( unsigned int drive, struct segoff *address ) { "catalog (status %04x)\n", drive, status ); return -EIO; } - copy_from_user ( &catalog, phys_to_virt ( eltorito_cmd.buffer ), 0, - sizeof ( catalog ) ); + memcpy ( &catalog, phys_to_virt ( eltorito_cmd.buffer ), + sizeof ( catalog ) ); /* Sanity checks */ if ( catalog.valid.platform_id != ELTORITO_PLATFORM_X86 ) { diff --git a/src/core/blockdev.c b/src/core/blockdev.c index c219d9673..3513caafa 100644 --- a/src/core/blockdev.c +++ b/src/core/blockdev.c @@ -45,8 +45,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * @ret rc Return status code */ int block_read ( struct interface *control, struct interface *data, - uint64_t lba, unsigned int count, - userptr_t buffer, size_t len ) { + uint64_t lba, unsigned int count, void *buffer, + size_t len ) { struct interface *dest; block_read_TYPE ( void * ) *op = intf_get_dest_op ( control, block_read, &dest ); @@ -76,8 +76,8 @@ int block_read ( struct interface *control, struct interface *data, * @ret rc Return status code */ int block_write ( struct interface *control, struct interface *data, - uint64_t lba, unsigned int count, - userptr_t buffer, size_t len ) { + uint64_t lba, unsigned int count, void *buffer, + size_t len ) { struct interface *dest; block_write_TYPE ( void * ) *op = intf_get_dest_op ( control, block_write, &dest ); diff --git a/src/core/blocktrans.c b/src/core/blocktrans.c index f3be2ba2b..ba70462f2 100644 --- a/src/core/blocktrans.c +++ b/src/core/blocktrans.c @@ -81,7 +81,7 @@ static void blktrans_xferbuf_write ( struct xfer_buffer *xferbuf, size_t offset, if ( blktrans->buffer ) { /* Write data to buffer */ - copy_to_user ( blktrans->buffer, offset, data, len ); + memcpy ( ( blktrans->buffer + offset ), data, len ); } else { @@ -107,7 +107,7 @@ static void blktrans_xferbuf_read ( struct xfer_buffer *xferbuf, size_t offset, if ( blktrans->buffer ) { /* Read data from buffer */ - copy_from_user ( data, blktrans->buffer, offset, len ); + memcpy ( data, ( blktrans->buffer + offset ), len ); } else { @@ -216,11 +216,11 @@ static struct interface_descriptor blktrans_xfer_desc = * Insert block device translator * * @v block Block device interface - * @v buffer Data buffer (or UNULL) + * @v buffer Data buffer (or NULL) * @v size Length of data buffer, or block size * @ret rc Return status code */ -int block_translate ( struct interface *block, userptr_t buffer, size_t size ) { +int block_translate ( struct interface *block, void *buffer, size_t size ) { struct block_translator *blktrans; int rc; diff --git a/src/core/dummy_sanboot.c b/src/core/dummy_sanboot.c index e22998da5..5ca120aac 100644 --- a/src/core/dummy_sanboot.c +++ b/src/core/dummy_sanboot.c @@ -29,6 +29,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * */ +#include #include #include diff --git a/src/core/sanboot.c b/src/core/sanboot.c index 4facf86b8..bdac813ff 100644 --- a/src/core/sanboot.c +++ b/src/core/sanboot.c @@ -424,10 +424,10 @@ int sandev_reopen ( struct san_device *sandev ) { struct san_command_rw_params { /** SAN device read/write operation */ int ( * block_rw ) ( struct interface *control, struct interface *data, - uint64_t lba, unsigned int count, - userptr_t buffer, size_t len ); + uint64_t lba, unsigned int count, void *buffer, + size_t len ); /** Data buffer */ - userptr_t buffer; + void *buffer; /** Starting LBA */ uint64_t lba; /** Block count */ @@ -594,11 +594,11 @@ int sandev_reset ( struct san_device *sandev ) { * @ret rc Return status code */ static int sandev_rw ( struct san_device *sandev, uint64_t lba, - unsigned int count, userptr_t buffer, + unsigned int count, void *buffer, int ( * block_rw ) ( struct interface *control, struct interface *data, uint64_t lba, unsigned int count, - userptr_t buffer, size_t len ) ) { + void *buffer, size_t len ) ) { union san_command_params params; unsigned int remaining; size_t frag_len; @@ -643,11 +643,12 @@ static int sandev_rw ( struct san_device *sandev, uint64_t lba, * @ret rc Return status code */ int sandev_read ( struct san_device *sandev, uint64_t lba, - unsigned int count, userptr_t buffer ) { + unsigned int count, void *buffer ) { int rc; /* Read from device */ - if ( ( rc = sandev_rw ( sandev, lba, count, buffer, block_read ) ) != 0 ) + if ( ( rc = sandev_rw ( sandev, lba, count, buffer, + block_read ) ) != 0 ) return rc; return 0; @@ -663,11 +664,12 @@ int sandev_read ( struct san_device *sandev, uint64_t lba, * @ret rc Return status code */ int sandev_write ( struct san_device *sandev, uint64_t lba, - unsigned int count, userptr_t buffer ) { + unsigned int count, void *buffer ) { int rc; /* Write to device */ - if ( ( rc = sandev_rw ( sandev, lba, count, buffer, block_write ) ) != 0 ) + if ( ( rc = sandev_rw ( sandev, lba, count, buffer, + block_write ) ) != 0 ) return rc; /* Quiesce system. This is a heuristic designed to ensure @@ -799,8 +801,7 @@ static int sandev_parse_iso9660 ( struct san_device *sandev ) { } /* Read primary volume descriptor */ - if ( ( rc = sandev_read ( sandev, lba, count, - virt_to_user ( scratch ) ) ) != 0 ) { + if ( ( rc = sandev_read ( sandev, lba, count, scratch ) ) != 0 ) { DBGC ( sandev->drive, "SAN %#02x could not read ISO9660 " "primary volume descriptor: %s\n", sandev->drive, strerror ( rc ) ); diff --git a/src/drivers/block/ata.c b/src/drivers/block/ata.c index b1c6855a0..cf98d7c9f 100644 --- a/src/drivers/block/ata.c +++ b/src/drivers/block/ata.c @@ -147,8 +147,8 @@ struct ata_command_type { * @ret data_in Data-in buffer * @ret data_in_len Data-in buffer length */ - void ( * data_in ) ( struct ata_command *atacmd, userptr_t buffer, - size_t len, userptr_t *data_in, + void ( * data_in ) ( struct ata_command *atacmd, void *buffer, + size_t len, void **data_in, size_t *data_in_len ); /** * Calculate data-out buffer @@ -160,8 +160,8 @@ struct ata_command_type { * @ret data_out Data-out buffer * @ret data_out_len Data-out buffer length */ - void ( * data_out ) ( struct ata_command *atacmd, userptr_t buffer, - size_t len, userptr_t *data_out, + void ( * data_out ) ( struct ata_command *atacmd, void *buffer, + size_t len, void **data_out, size_t *data_out_len ); /** * Handle ATA command completion @@ -285,8 +285,8 @@ static void atacmd_done ( struct ata_command *atacmd, int rc ) { * @ret data_len Data buffer length */ static void atacmd_data_buffer ( struct ata_command *atacmd __unused, - userptr_t buffer, size_t len, - userptr_t *data, size_t *data_len ) { + void *buffer, size_t len, + void **data, size_t *data_len ) { *data = buffer; *data_len = len; } @@ -301,8 +301,8 @@ static void atacmd_data_buffer ( struct ata_command *atacmd __unused, * @ret data_len Data buffer length */ static void atacmd_data_none ( struct ata_command *atacmd __unused, - userptr_t buffer __unused, size_t len __unused, - userptr_t *data __unused, + void *buffer __unused, size_t len __unused, + void **data __unused, size_t *data_len __unused ) { /* Nothing to do */ } @@ -317,9 +317,9 @@ static void atacmd_data_none ( struct ata_command *atacmd __unused, * @ret data_len Data buffer length */ static void atacmd_data_priv ( struct ata_command *atacmd, - userptr_t buffer __unused, size_t len __unused, - userptr_t *data, size_t *data_len ) { - *data = virt_to_user ( atacmd_priv ( atacmd ) ); + void *buffer __unused, size_t len __unused, + void **data, size_t *data_len ) { + *data = atacmd_priv ( atacmd ); *data_len = atacmd->type->priv_len; } @@ -455,7 +455,7 @@ static int atadev_command ( struct ata_device *atadev, struct interface *block, struct ata_command_type *type, uint64_t lba, unsigned int count, - userptr_t buffer, size_t len ) { + void *buffer, size_t len ) { struct ata_command *atacmd; struct ata_cmd command; int tag; @@ -543,7 +543,7 @@ static int atadev_command ( struct ata_device *atadev, static int atadev_read ( struct ata_device *atadev, struct interface *block, uint64_t lba, unsigned int count, - userptr_t buffer, size_t len ) { + void *buffer, size_t len ) { return atadev_command ( atadev, block, &atacmd_read, lba, count, buffer, len ); } @@ -562,7 +562,7 @@ static int atadev_read ( struct ata_device *atadev, static int atadev_write ( struct ata_device *atadev, struct interface *block, uint64_t lba, unsigned int count, - userptr_t buffer, size_t len ) { + void *buffer, size_t len ) { return atadev_command ( atadev, block, &atacmd_write, lba, count, buffer, len ); } @@ -581,7 +581,7 @@ static int atadev_read_capacity ( struct ata_device *atadev, assert ( atacmd_identify.priv_len == sizeof ( *identity ) ); assert ( atacmd_identify.priv_len == ATA_SECTOR_SIZE ); return atadev_command ( atadev, block, &atacmd_identify, - 0, 1, UNULL, ATA_SECTOR_SIZE ); + 0, 1, NULL, ATA_SECTOR_SIZE ); } /** diff --git a/src/drivers/block/scsi.c b/src/drivers/block/scsi.c index ff415f5c6..251210d4f 100644 --- a/src/drivers/block/scsi.c +++ b/src/drivers/block/scsi.c @@ -279,7 +279,7 @@ struct scsi_command { /** Number of blocks */ unsigned int count; /** Data buffer */ - userptr_t buffer; + void *buffer; /** Length of data buffer */ size_t len; /** Command tag */ @@ -591,12 +591,12 @@ static void scsicmd_read_capacity_cmd ( struct scsi_command *scsicmd, readcap16->service_action = SCSI_SERVICE_ACTION_READ_CAPACITY_16; readcap16->len = cpu_to_be32 ( sizeof ( *capacity16 ) ); - command->data_in = virt_to_user ( capacity16 ); + command->data_in = capacity16; command->data_in_len = sizeof ( *capacity16 ); } else { /* Use READ CAPACITY (10) */ readcap10->opcode = SCSI_OPCODE_READ_CAPACITY_10; - command->data_in = virt_to_user ( capacity10 ); + command->data_in = capacity10; command->data_in_len = sizeof ( *capacity10 ); } } @@ -721,7 +721,7 @@ static int scsidev_command ( struct scsi_device *scsidev, struct interface *block, struct scsi_command_type *type, uint64_t lba, unsigned int count, - userptr_t buffer, size_t len ) { + void *buffer, size_t len ) { struct scsi_command *scsicmd; int rc; @@ -773,7 +773,7 @@ static int scsidev_command ( struct scsi_device *scsidev, static int scsidev_read ( struct scsi_device *scsidev, struct interface *block, uint64_t lba, unsigned int count, - userptr_t buffer, size_t len ) { + void *buffer, size_t len ) { return scsidev_command ( scsidev, block, &scsicmd_read, lba, count, buffer, len ); } @@ -792,7 +792,7 @@ static int scsidev_read ( struct scsi_device *scsidev, static int scsidev_write ( struct scsi_device *scsidev, struct interface *block, uint64_t lba, unsigned int count, - userptr_t buffer, size_t len ) { + void *buffer, size_t len ) { return scsidev_command ( scsidev, block, &scsicmd_write, lba, count, buffer, len ); } @@ -807,7 +807,7 @@ static int scsidev_write ( struct scsi_device *scsidev, static int scsidev_read_capacity ( struct scsi_device *scsidev, struct interface *block ) { return scsidev_command ( scsidev, block, &scsicmd_read_capacity, - 0, 0, UNULL, 0 ); + 0, 0, NULL, 0 ); } /** @@ -820,7 +820,7 @@ static int scsidev_read_capacity ( struct scsi_device *scsidev, static int scsidev_test_unit_ready ( struct scsi_device *scsidev, struct interface *block ) { return scsidev_command ( scsidev, block, &scsicmd_test_unit_ready, - 0, 0, UNULL, 0 ); + 0, 0, NULL, 0 ); } /** diff --git a/src/drivers/usb/usbblk.c b/src/drivers/usb/usbblk.c index 5a086d3f8..39adc012f 100644 --- a/src/drivers/usb/usbblk.c +++ b/src/drivers/usb/usbblk.c @@ -205,7 +205,7 @@ static int usbblk_out_data ( struct usbblk_device *usbblk ) { /* Calculate length */ assert ( cmd->tag ); - assert ( cmd->scsi.data_out != UNULL ); + assert ( cmd->scsi.data_out != NULL ); assert ( cmd->offset < cmd->scsi.data_out_len ); len = ( cmd->scsi.data_out_len - cmd->offset ); if ( len > USBBLK_MAX_LEN ) @@ -220,8 +220,8 @@ static int usbblk_out_data ( struct usbblk_device *usbblk ) { } /* Populate I/O buffer */ - copy_from_user ( iob_put ( iobuf, len ), cmd->scsi.data_out, - cmd->offset, len ); + memcpy ( iob_put ( iobuf, len ), + ( cmd->scsi.data_out + cmd->offset ), len ); /* Send data */ if ( ( rc = usb_stream ( &usbblk->out, iobuf, 0 ) ) != 0 ) { @@ -332,12 +332,12 @@ static int usbblk_in_data ( struct usbblk_device *usbblk, const void *data, /* Sanity checks */ assert ( cmd->tag ); - assert ( cmd->scsi.data_in != UNULL ); + assert ( cmd->scsi.data_in != NULL ); assert ( cmd->offset <= cmd->scsi.data_in_len ); assert ( len <= ( cmd->scsi.data_in_len - cmd->offset ) ); /* Store data */ - copy_to_user ( cmd->scsi.data_in, cmd->offset, data, len ); + memcpy ( ( cmd->scsi.data_in + cmd->offset ), data, len ); cmd->offset += len; return 0; diff --git a/src/include/ipxe/ata.h b/src/include/ipxe/ata.h index a10cfafcc..cd78cd795 100644 --- a/src/include/ipxe/ata.h +++ b/src/include/ipxe/ata.h @@ -2,7 +2,6 @@ #define _IPXE_ATA_H #include -#include #include /** @file @@ -173,7 +172,7 @@ struct ata_cmd { * If non-NULL, this buffer must be ata_command::cb::count * sectors in size. */ - userptr_t data_out; + void *data_out; /** Data-out buffer length * * Must be zero if @c data_out is NULL @@ -184,7 +183,7 @@ struct ata_cmd { * If non-NULL, this buffer must be ata_command::cb::count * sectors in size. */ - userptr_t data_in; + void *data_in; /** Data-in buffer length * * Must be zero if @c data_in is NULL diff --git a/src/include/ipxe/blockdev.h b/src/include/ipxe/blockdev.h index 418c43004..ef6fc8d5a 100644 --- a/src/include/ipxe/blockdev.h +++ b/src/include/ipxe/blockdev.h @@ -11,7 +11,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include -#include #include /** Block device capacity */ @@ -25,20 +24,20 @@ struct block_device_capacity { }; extern int block_read ( struct interface *control, struct interface *data, - uint64_t lba, unsigned int count, - userptr_t buffer, size_t len ); + uint64_t lba, unsigned int count, void *buffer, + size_t len ); #define block_read_TYPE( object_type ) \ typeof ( int ( object_type, struct interface *data, \ uint64_t lba, unsigned int count, \ - userptr_t buffer, size_t len ) ) + void *buffer, size_t len ) ) extern int block_write ( struct interface *control, struct interface *data, - uint64_t lba, unsigned int count, - userptr_t buffer, size_t len ); + uint64_t lba, unsigned int count, void *buffer, + size_t len ); #define block_write_TYPE( object_type ) \ typeof ( int ( object_type, struct interface *data, \ uint64_t lba, unsigned int count, \ - userptr_t buffer, size_t len ) ) + void *buffer, size_t len ) ) extern int block_read_capacity ( struct interface *control, struct interface *data ); diff --git a/src/include/ipxe/blocktrans.h b/src/include/ipxe/blocktrans.h index fee71b96c..1167a256e 100644 --- a/src/include/ipxe/blocktrans.h +++ b/src/include/ipxe/blocktrans.h @@ -13,7 +13,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include /** A block device translator */ struct block_translator { @@ -27,12 +26,12 @@ struct block_translator { /** Data transfer buffer */ struct xfer_buffer xferbuf; /** Data buffer */ - userptr_t buffer; + void *buffer; /** Block size */ size_t blksize; }; -extern int block_translate ( struct interface *block, - userptr_t buffer, size_t size ); +extern int block_translate ( struct interface *block, void *buffer, + size_t size ); #endif /* _IPXE_BLOCKTRANS_H */ diff --git a/src/include/ipxe/sanboot.h b/src/include/ipxe/sanboot.h index e44367cdb..9d5fceee0 100644 --- a/src/include/ipxe/sanboot.h +++ b/src/include/ipxe/sanboot.h @@ -261,9 +261,9 @@ extern struct san_device * sandev_next ( unsigned int drive ); extern int sandev_reopen ( struct san_device *sandev ); extern int sandev_reset ( struct san_device *sandev ); extern int sandev_read ( struct san_device *sandev, uint64_t lba, - unsigned int count, userptr_t buffer ); + unsigned int count, void *buffer ); extern int sandev_write ( struct san_device *sandev, uint64_t lba, - unsigned int count, userptr_t buffer ); + unsigned int count, void *buffer ); extern struct san_device * alloc_sandev ( struct uri **uris, unsigned int count, size_t priv_size ); extern int register_sandev ( struct san_device *sandev, unsigned int drive, diff --git a/src/include/ipxe/scsi.h b/src/include/ipxe/scsi.h index 28b55b2d5..9bb38a059 100644 --- a/src/include/ipxe/scsi.h +++ b/src/include/ipxe/scsi.h @@ -2,7 +2,6 @@ #define _IPXE_SCSI_H #include -#include #include /** @file @@ -252,14 +251,14 @@ struct scsi_cmd { /** CDB for this command */ union scsi_cdb cdb; /** Data-out buffer (may be NULL) */ - userptr_t data_out; + void *data_out; /** Data-out buffer length * * Must be zero if @c data_out is NULL */ size_t data_out_len; /** Data-in buffer (may be NULL) */ - userptr_t data_in; + void *data_in; /** Data-in buffer length * * Must be zero if @c data_in is NULL diff --git a/src/interface/efi/efi_block.c b/src/interface/efi/efi_block.c index 94e2aae06..aa5ec4e0f 100644 --- a/src/interface/efi/efi_block.c +++ b/src/interface/efi/efi_block.c @@ -95,8 +95,9 @@ struct efi_block_data { static int efi_block_rw ( struct san_device *sandev, uint64_t lba, void *data, size_t len, int ( * sandev_rw ) ( struct san_device *sandev, - uint64_t lba, unsigned int count, - userptr_t buffer ) ) { + uint64_t lba, + unsigned int count, + void *buffer ) ) { struct efi_block_data *block = sandev->priv; unsigned int count; int rc; diff --git a/src/net/aoe.c b/src/net/aoe.c index dba4f51b5..b484bdd33 100644 --- a/src/net/aoe.c +++ b/src/net/aoe.c @@ -33,7 +33,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include #include #include #include @@ -391,8 +390,7 @@ static void aoecmd_ata_cmd ( struct aoe_command *aoecmd, if ( ! command->cb.lba48 ) aoeata->lba.bytes[3] |= ( command->cb.device & ATA_DEV_MASK ); - copy_from_user ( aoeata->data, command->data_out, 0, - command->data_out_len ); + memcpy ( aoeata->data, command->data_out, command->data_out_len ); DBGC2 ( aoedev, "AoE %s/%08x ATA cmd %02x:%02x:%02x:%02x:%08llx", aoedev_name ( aoedev ), aoecmd->tag, aoeata->aflags, @@ -452,8 +450,7 @@ static int aoecmd_ata_rsp ( struct aoe_command *aoecmd, const void *data, } /* Copy out data payload */ - copy_to_user ( command->data_in, 0, aoeata->data, - command->data_in_len ); + memcpy ( command->data_in, aoeata->data, command->data_in_len ); return 0; } diff --git a/src/net/fcp.c b/src/net/fcp.c index f78f7bd9b..9701b5d54 100644 --- a/src/net/fcp.c +++ b/src/net/fcp.c @@ -413,7 +413,7 @@ static int fcpcmd_recv_rddata ( struct fcp_command *fcpcmd, fcpdev, fcpcmd->xchg_id, offset, ( offset + len ) ); /* Copy to user buffer */ - copy_to_user ( command->data_in, offset, iobuf->data, len ); + memcpy ( ( command->data_in + offset ), iobuf->data, len ); fcpcmd->offset += len; assert ( fcpcmd->offset <= command->data_in_len ); @@ -464,8 +464,8 @@ static int fcpcmd_send_wrdata ( struct fcp_command *fcpcmd ) { } /* Construct data IU frame */ - copy_from_user ( iob_put ( iobuf, len ), command->data_out, - fcpcmd->offset, len ); + memcpy ( iob_put ( iobuf, len ), + ( command->data_out + fcpcmd->offset ), len ); memset ( &meta, 0, sizeof ( meta ) ); meta.flags = ( XFER_FL_RESPONSE | XFER_FL_ABS_OFFSET ); meta.offset = fcpcmd->offset; diff --git a/src/net/tcp/httpblock.c b/src/net/tcp/httpblock.c index 1abd6b34d..156f11e47 100644 --- a/src/net/tcp/httpblock.c +++ b/src/net/tcp/httpblock.c @@ -31,7 +31,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ #include -#include #include #include #include @@ -52,7 +51,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * @ret rc Return status code */ int http_block_read ( struct http_transaction *http, struct interface *data, - uint64_t lba, unsigned int count, userptr_t buffer, + uint64_t lba, unsigned int count, void *buffer, size_t len ) { struct http_request_range range; int rc; @@ -101,7 +100,7 @@ int http_block_read_capacity ( struct http_transaction *http, goto err_open; /* Insert block device translator */ - if ( ( rc = block_translate ( data, UNULL, HTTP_BLKSIZE ) ) != 0 ) { + if ( ( rc = block_translate ( data, NULL, HTTP_BLKSIZE ) ) != 0 ) { DBGC ( http, "HTTP %p could not insert block translator: %s\n", http, strerror ( rc ) ); goto err_translate; diff --git a/src/net/tcp/httpcore.c b/src/net/tcp/httpcore.c index 7052bbbad..57c31ac26 100644 --- a/src/net/tcp/httpcore.c +++ b/src/net/tcp/httpcore.c @@ -503,7 +503,7 @@ http_content_buffer ( struct http_transaction *http ) { __weak int http_block_read ( struct http_transaction *http __unused, struct interface *data __unused, uint64_t lba __unused, unsigned int count __unused, - userptr_t buffer __unused, size_t len __unused ) { + void *buffer __unused, size_t len __unused ) { return -ENOTSUP; } diff --git a/src/net/tcp/iscsi.c b/src/net/tcp/iscsi.c index dd20849ce..b7b33a51a 100644 --- a/src/net/tcp/iscsi.c +++ b/src/net/tcp/iscsi.c @@ -39,7 +39,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include #include #include #include @@ -478,7 +477,7 @@ static int iscsi_rx_data_in ( struct iscsi_session *iscsi, assert ( iscsi->command != NULL ); assert ( iscsi->command->data_in ); assert ( ( offset + len ) <= iscsi->command->data_in_len ); - copy_to_user ( iscsi->command->data_in, offset, data, len ); + memcpy ( ( iscsi->command->data_in + offset ), data, len ); /* Wait for whole SCSI response to arrive */ if ( remaining ) @@ -598,8 +597,8 @@ static int iscsi_tx_data_out ( struct iscsi_session *iscsi ) { if ( ! iobuf ) return -ENOMEM; - copy_from_user ( iob_put ( iobuf, len ), - iscsi->command->data_out, offset, len ); + memcpy ( iob_put ( iobuf, len ), + ( iscsi->command->data_out + offset ), len ); memset ( iob_put ( iobuf, pad_len ), 0, pad_len ); return xfer_deliver_iob ( &iscsi->socket, iobuf ); -- cgit v1.2.3-55-g7522 From b816b816aba624bc4fcfdf45f90807cd29f7f53b Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sun, 27 Apr 2025 17:36:52 +0100 Subject: [build] Fix old-style function definition Signed-off-by: Michael Brown --- src/drivers/net/3c595.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/3c595.c b/src/drivers/net/3c595.c index c69831005..1fab56aa9 100644 --- a/src/drivers/net/3c595.c +++ b/src/drivers/net/3c595.c @@ -342,8 +342,7 @@ eeprom_rdy() * before */ static int -get_e(offset) -int offset; +get_e(int offset) { if (!eeprom_rdy()) return (0xffff); -- cgit v1.2.3-55-g7522 From 7741756afc003ad042f0b13b30aed38e0ca9b94c Mon Sep 17 00:00:00 2001 From: Miao Wang Date: Sun, 27 Apr 2025 17:30:49 +0100 Subject: [build] Prevent the use of reserved words in C23 GCC 15 defaults to C23, which reserves bool, true, and false as keywords. Avoid using these as parameter or variable names. Modified-by: Michael Brown Signed-off-by: Michael Brown --- src/drivers/infiniband/mlx_utils/src/public/mlx_pci_gw.c | 4 ++-- src/drivers/net/igbvf/igbvf_osdep.h | 7 ++----- src/interface/efi/efi_hii.c | 12 ++++++------ 3 files changed, 10 insertions(+), 13 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/infiniband/mlx_utils/src/public/mlx_pci_gw.c b/src/drivers/infiniband/mlx_utils/src/public/mlx_pci_gw.c index 30c1e644e..0b257ed22 100644 --- a/src/drivers/infiniband/mlx_utils/src/public/mlx_pci_gw.c +++ b/src/drivers/infiniband/mlx_utils/src/public/mlx_pci_gw.c @@ -32,7 +32,7 @@ mlx_status mlx_pci_gw_check_capability_id( IN mlx_utils *utils, IN mlx_uint8 cap_pointer, - OUT mlx_boolean *bool + OUT mlx_boolean *result ) { mlx_status status = MLX_SUCCESS; @@ -41,7 +41,7 @@ mlx_pci_gw_check_capability_id( status = mlx_pci_read(utils, MlxPciWidthUint8, offset, 1, &id); MLX_CHECK_STATUS(utils, status, read_err,"failed to read capability id"); - *bool = ( id == PCI_GW_CAPABILITY_ID ); + *result = ( id == PCI_GW_CAPABILITY_ID ); read_err: return status; } diff --git a/src/drivers/net/igbvf/igbvf_osdep.h b/src/drivers/net/igbvf/igbvf_osdep.h index 8ac179de0..dc65da6c1 100644 --- a/src/drivers/net/igbvf/igbvf_osdep.h +++ b/src/drivers/net/igbvf/igbvf_osdep.h @@ -35,8 +35,9 @@ FILE_LICENCE ( GPL2_ONLY ); #ifndef _IGBVF_OSDEP_H_ #define _IGBVF_OSDEP_H_ +#include + #define u8 unsigned char -#define bool boolean_t #define dma_addr_t unsigned long #define __le16 uint16_t #define __le32 uint32_t @@ -51,10 +52,6 @@ FILE_LICENCE ( GPL2_ONLY ); #define ETH_FCS_LEN 4 typedef int spinlock_t; -typedef enum { - false = 0, - true = 1 -} boolean_t; #define usec_delay(x) udelay(x) #define msec_delay(x) mdelay(x) diff --git a/src/interface/efi/efi_hii.c b/src/interface/efi/efi_hii.c index 506fc8869..66f58affe 100644 --- a/src/interface/efi/efi_hii.c +++ b/src/interface/efi/efi_hii.c @@ -147,13 +147,13 @@ void efi_ifr_end_op ( struct efi_ifr_builder *ifr ) { */ void efi_ifr_false_op ( struct efi_ifr_builder *ifr ) { size_t dispaddr = ifr->ops_len; - EFI_IFR_FALSE *false; + EFI_IFR_FALSE *op; /* Add opcode */ - false = efi_ifr_op ( ifr, EFI_IFR_FALSE_OP, sizeof ( *false ) ); + op = efi_ifr_op ( ifr, EFI_IFR_FALSE_OP, sizeof ( *op ) ); DBGC ( ifr, "IFR %p false\n", ifr ); - DBGC2_HDA ( ifr, dispaddr, false, sizeof ( *false ) ); + DBGC2_HDA ( ifr, dispaddr, op, sizeof ( *op ) ); } /** @@ -462,13 +462,13 @@ void efi_ifr_text_op ( struct efi_ifr_builder *ifr, unsigned int prompt_id, */ void efi_ifr_true_op ( struct efi_ifr_builder *ifr ) { size_t dispaddr = ifr->ops_len; - EFI_IFR_TRUE *true; + EFI_IFR_TRUE *op; /* Add opcode */ - true = efi_ifr_op ( ifr, EFI_IFR_TRUE_OP, sizeof ( *true ) ); + op = efi_ifr_op ( ifr, EFI_IFR_TRUE_OP, sizeof ( *op ) ); DBGC ( ifr, "IFR %p true\n", ifr ); - DBGC2_HDA ( ifr, dispaddr, true, sizeof ( *true ) ); + DBGC2_HDA ( ifr, dispaddr, op, sizeof ( *op ) ); } /** -- cgit v1.2.3-55-g7522 From 15c1111c78c0a0ca7159ecb64c90fb6a249c6ad4 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sun, 27 Apr 2025 17:37:44 +0100 Subject: [build] Remove unsafe disable function wrapper from legacy NIC drivers The legacy NIC drivers do not consistently take a second parameter in their disable function. We currently use an unsafe function wrapper that declares no parameters, and rely on the ABI allowing a second parameter to be silently ignored if not expected by the caller. As of GCC 15, this hack results in an incompatible pointer type warning. Fix by removing the hack, and instead updating all relevant legacy NIC drivers to take an unused second parameter in their disable function. Signed-off-by: Michael Brown --- src/drivers/net/3c595.c | 2 +- src/drivers/net/amd8111e.c | 2 +- src/drivers/net/bnx2.c | 8 +++++++- src/drivers/net/davicom.c | 4 ++-- src/drivers/net/depca.c | 2 +- src/drivers/net/dmfe.c | 2 +- src/drivers/net/epic100.c | 4 ++-- src/drivers/net/ns8390.c | 2 +- src/drivers/net/prism2_pci.c | 2 +- src/drivers/net/prism2_plx.c | 2 +- src/drivers/net/sis900.c | 4 ++-- src/drivers/net/sundance.c | 2 +- src/drivers/net/tlan.c | 2 +- src/drivers/net/tulip.c | 4 ++-- src/drivers/net/w89c840.c | 2 +- src/include/nic.h | 3 +-- 16 files changed, 26 insertions(+), 21 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/3c595.c b/src/drivers/net/3c595.c index 1fab56aa9..7792c17d6 100644 --- a/src/drivers/net/3c595.c +++ b/src/drivers/net/3c595.c @@ -443,7 +443,7 @@ vxsetlink(void) GO_WINDOW(1); } -static void t595_disable ( struct nic *nic ) { +static void t595_disable ( struct nic *nic, void *hwdev __unused ) { t595_reset(nic); diff --git a/src/drivers/net/amd8111e.c b/src/drivers/net/amd8111e.c index babd12d3c..213c4f44b 100644 --- a/src/drivers/net/amd8111e.c +++ b/src/drivers/net/amd8111e.c @@ -609,7 +609,7 @@ static int amd8111e_poll(struct nic *nic, int retrieve) return pkt_ok; } -static void amd8111e_disable(struct nic *nic) +static void amd8111e_disable(struct nic *nic, void *hwdev __unused) { struct amd8111e_priv *lp = nic->priv_data; diff --git a/src/drivers/net/bnx2.c b/src/drivers/net/bnx2.c index d5783ff99..186cc17d4 100644 --- a/src/drivers/net/bnx2.c +++ b/src/drivers/net/bnx2.c @@ -2671,6 +2671,12 @@ err_out_disable: return 0; } +static void +bnx2_remove(struct nic *nic, void *hwdev __unused) +{ + bnx2_disable(nic); +} + static struct pci_device_id bnx2_nics[] = { PCI_ROM(0x14e4, 0x164a, "bnx2-5706", "Broadcom NetXtreme II BCM5706", 0), PCI_ROM(0x14e4, 0x164c, "bnx2-5708", "Broadcom NetXtreme II BCM5708", 0), @@ -2680,7 +2686,7 @@ static struct pci_device_id bnx2_nics[] = { PCI_DRIVER ( bnx2_driver, bnx2_nics, PCI_NO_CLASS ); -DRIVER ( "BNX2", nic_driver, pci_driver, bnx2_driver, bnx2_probe, bnx2_disable ); +DRIVER ( "BNX2", nic_driver, pci_driver, bnx2_driver, bnx2_probe, bnx2_remove ); /* static struct pci_driver bnx2_driver __pci_driver = { diff --git a/src/drivers/net/davicom.c b/src/drivers/net/davicom.c index 0c96796df..307ae9811 100644 --- a/src/drivers/net/davicom.c +++ b/src/drivers/net/davicom.c @@ -159,7 +159,7 @@ static void davicom_reset(struct nic *nic); static void davicom_transmit(struct nic *nic, const char *d, unsigned int t, unsigned int s, const char *p); static int davicom_poll(struct nic *nic, int retrieve); -static void davicom_disable(struct nic *nic); +static void davicom_disable(struct nic *nic, void *hwdev); static void davicom_wait(unsigned int nticks); static int phy_read(int); static void phy_write(int, u16); @@ -601,7 +601,7 @@ static int davicom_poll(struct nic *nic, int retrieve) /*********************************************************************/ /* eth_disable - Disable the interface */ /*********************************************************************/ -static void davicom_disable ( struct nic *nic ) { +static void davicom_disable ( struct nic *nic, void *hwdev __unused ) { whereami("davicom_disable\n"); diff --git a/src/drivers/net/depca.c b/src/drivers/net/depca.c index 016f28bb2..30e2fcb0a 100644 --- a/src/drivers/net/depca.c +++ b/src/drivers/net/depca.c @@ -644,7 +644,7 @@ static void depca_transmit( /************************************************************************** DISABLE - Turn off ethernet interface ***************************************************************************/ -static void depca_disable ( struct nic *nic ) { +static void depca_disable ( struct nic *nic, void *hwdev __unused ) { depca_reset(nic); STOP_DEPCA(nic->ioaddr); diff --git a/src/drivers/net/dmfe.c b/src/drivers/net/dmfe.c index 53b05815b..a76dd792d 100644 --- a/src/drivers/net/dmfe.c +++ b/src/drivers/net/dmfe.c @@ -435,7 +435,7 @@ static void dmfe_transmit(struct nic *nic, /************************************************************************** DISABLE - Turn off ethernet interface ***************************************************************************/ -static void dmfe_disable ( struct nic *nic __unused ) { +static void dmfe_disable ( struct nic *nic __unused, void *hwdev __unused ) { /* Reset & stop DM910X board */ outl(DM910X_RESET, BASE + DCR0); udelay(5); diff --git a/src/drivers/net/epic100.c b/src/drivers/net/epic100.c index 8e31a3bfa..01c0c43c9 100644 --- a/src/drivers/net/epic100.c +++ b/src/drivers/net/epic100.c @@ -51,7 +51,7 @@ struct epic_tx_desc { static void epic100_open(void); static void epic100_init_ring(void); -static void epic100_disable(struct nic *nic); +static void epic100_disable(struct nic *nic, void *hwdev); static int epic100_poll(struct nic *nic, int retrieve); static void epic100_transmit(struct nic *nic, const char *destaddr, unsigned int type, unsigned int len, const char *data); @@ -419,7 +419,7 @@ epic100_poll(struct nic *nic, int retrieve) } -static void epic100_disable ( struct nic *nic __unused ) { +static void epic100_disable ( struct nic *nic __unused, void *hwdev __unused ) { /* Soft reset the chip. */ outl(GC_SOFT_RESET, genctl); } diff --git a/src/drivers/net/ns8390.c b/src/drivers/net/ns8390.c index 8e8d8500f..a81ec6eea 100644 --- a/src/drivers/net/ns8390.c +++ b/src/drivers/net/ns8390.c @@ -597,7 +597,7 @@ static int ns8390_poll(struct nic *nic, int retrieve) /************************************************************************** NS8390_DISABLE - Turn off adapter **************************************************************************/ -static void ns8390_disable ( struct nic *nic ) { +static void ns8390_disable ( struct nic *nic, void *hwdev __unused ) { ns8390_reset(nic); } diff --git a/src/drivers/net/prism2_pci.c b/src/drivers/net/prism2_pci.c index 2feb69522..9940f76a7 100644 --- a/src/drivers/net/prism2_pci.c +++ b/src/drivers/net/prism2_pci.c @@ -44,7 +44,7 @@ static int prism2_pci_probe ( struct nic *nic, struct pci_device *pci ) { return prism2_probe ( nic, hw ); } -static void prism2_pci_disable ( struct nic *nic ) { +static void prism2_pci_disable ( struct nic *nic, void *hwdev __unused ) { prism2_disable ( nic ); } diff --git a/src/drivers/net/prism2_plx.c b/src/drivers/net/prism2_plx.c index 770cf3288..f3200e89c 100644 --- a/src/drivers/net/prism2_plx.c +++ b/src/drivers/net/prism2_plx.c @@ -99,7 +99,7 @@ static int prism2_plx_probe ( struct nic *nic, struct pci_device *pci ) { return prism2_probe ( nic, hw ); } -static void prism2_plx_disable ( struct nic *nic ) { +static void prism2_plx_disable ( struct nic *nic, void *hwdev __unused ) { prism2_disable ( nic ); } diff --git a/src/drivers/net/sis900.c b/src/drivers/net/sis900.c index 8a3ac01bc..c8fd3e9b5 100644 --- a/src/drivers/net/sis900.c +++ b/src/drivers/net/sis900.c @@ -164,7 +164,7 @@ static void sis900_transmit(struct nic *nic, const char *d, unsigned int t, unsigned int s, const char *p); static int sis900_poll(struct nic *nic, int retrieve); -static void sis900_disable(struct nic *nic); +static void sis900_disable(struct nic *nic, void *hwdev); static void sis900_irq(struct nic *nic, irq_action_t action); @@ -1238,7 +1238,7 @@ sis900_poll(struct nic *nic, int retrieve) */ static void -sis900_disable ( struct nic *nic ) { +sis900_disable ( struct nic *nic, void *hwdev __unused ) { sis900_init(nic); diff --git a/src/drivers/net/sundance.c b/src/drivers/net/sundance.c index 8eb09b988..0439c983f 100644 --- a/src/drivers/net/sundance.c +++ b/src/drivers/net/sundance.c @@ -536,7 +536,7 @@ static void sundance_transmit(struct nic *nic, const char *d, /* Destination */ /************************************************************************** DISABLE - Turn off ethernet interface ***************************************************************************/ -static void sundance_disable ( struct nic *nic __unused ) { +static void sundance_disable ( struct nic *nic __unused, void *hwdev __unused) { /* put the card in its initial state */ /* This function serves 3 purposes. * This disables DMA and interrupts so we don't receive diff --git a/src/drivers/net/tlan.c b/src/drivers/net/tlan.c index 93533b438..245766a87 100644 --- a/src/drivers/net/tlan.c +++ b/src/drivers/net/tlan.c @@ -717,7 +717,7 @@ static void tlan_transmit(struct nic *nic, const char *d, /* Destination */ /************************************************************************** DISABLE - Turn off ethernet interface ***************************************************************************/ -static void tlan_disable ( struct nic *nic __unused ) { +static void tlan_disable ( struct nic *nic __unused, void *hwdev __unused ) { /* put the card in its initial state */ /* This function serves 3 purposes. * This disables DMA and interrupts so we don't receive diff --git a/src/drivers/net/tulip.c b/src/drivers/net/tulip.c index fddebfe5b..c01bc208e 100644 --- a/src/drivers/net/tulip.c +++ b/src/drivers/net/tulip.c @@ -494,7 +494,7 @@ static void tulip_reset(struct nic *nic); static void tulip_transmit(struct nic *nic, const char *d, unsigned int t, unsigned int s, const char *p); static int tulip_poll(struct nic *nic, int retrieve); -static void tulip_disable(struct nic *nic); +static void tulip_disable(struct nic *nic, void *hwdev); static void nway_start(struct nic *nic); static void pnic_do_nway(struct nic *nic); static void select_media(struct nic *nic, int startup); @@ -1128,7 +1128,7 @@ static int tulip_poll(struct nic *nic, int retrieve) /*********************************************************************/ /* eth_disable - Disable the interface */ /*********************************************************************/ -static void tulip_disable ( struct nic *nic ) { +static void tulip_disable ( struct nic *nic, void *hwdev __unused ) { whereami("tulip_disable\n"); diff --git a/src/drivers/net/w89c840.c b/src/drivers/net/w89c840.c index 72ccf3a28..0c222214e 100644 --- a/src/drivers/net/w89c840.c +++ b/src/drivers/net/w89c840.c @@ -579,7 +579,7 @@ static void w89c840_transmit( /************************************************************************** w89c840_disable - Turn off ethernet interface ***************************************************************************/ -static void w89c840_disable ( struct nic *nic ) { +static void w89c840_disable ( struct nic *nic, void *hwdev __unused ) { w89c840_reset(nic); diff --git a/src/include/nic.h b/src/include/nic.h index 8b06e88f4..8e928beb4 100644 --- a/src/include/nic.h +++ b/src/include/nic.h @@ -217,8 +217,7 @@ static inline void * legacy_isa_get_drvdata ( void *hwdev ) { } \ static inline void \ _name ## _disable ( struct nic *nic, void *hwdev ) { \ - void ( * _unsafe_disable ) () = _disable; \ - _unsafe_disable ( nic, hwdev ); \ + _disable ( nic, hwdev ); \ } \ static inline int \ _name ## _pci_legacy_probe ( struct pci_device *pci ) { \ -- cgit v1.2.3-55-g7522 From b6f9e4bab082c3b7a9b587ef64109069fba59baa Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 30 Apr 2025 15:18:34 +0100 Subject: [uaccess] Remove redundant copy_from_user() and copy_to_user() Remove the now-redundant copy_from_user() and copy_to_user() wrapper functions. Signed-off-by: Michael Brown --- src/arch/x86/core/runtime.c | 1 + src/arch/x86/drivers/xen/hvm.c | 1 + src/arch/x86/image/elfboot.c | 1 + src/arch/x86/image/initrd.c | 1 + src/arch/x86/image/multiboot.c | 1 + src/arch/x86/image/nbi.c | 1 + src/arch/x86/image/pxe_image.c | 1 + src/arch/x86/image/ucode.c | 1 + src/arch/x86/include/realmode.h | 1 + src/arch/x86/interface/pcbios/acpipwr.c | 1 + src/arch/x86/interface/pcbios/bios_cachedhcp.c | 1 + src/arch/x86/interface/pcbios/bios_reboot.c | 1 + src/arch/x86/interface/pcbios/biosint.c | 1 + src/arch/x86/interface/pcbios/hidemem.c | 1 + src/arch/x86/interface/pcbios/int13.c | 1 + src/arch/x86/interface/pcbios/memmap.c | 1 + src/arch/x86/interface/pcbios/memtop_umalloc.c | 1 + src/arch/x86/interface/pcbios/rsdp.c | 1 + src/core/blocktrans.c | 1 + src/core/cachedhcp.c | 1 + src/core/downloader.c | 1 + src/core/pixbuf.c | 1 + src/core/sanboot.c | 1 + src/drivers/bus/devtree.c | 1 + src/drivers/bus/ecam.c | 1 + src/drivers/bus/pci_settings.c | 1 + src/drivers/bus/usb_settings.c | 1 + src/drivers/infiniband/flexboot_nodnic.c | 1 + src/drivers/infiniband/linda.c | 1 + .../mlx_utils_flexboot/src/mlx_memory_priv.c | 1 + src/drivers/infiniband/qib7322.c | 1 + src/drivers/linux/slirp.c | 1 + src/drivers/net/ath/ath.h | 1 + src/drivers/net/ath/ath5k/ath5k.h | 1 + src/drivers/net/b44.c | 1 + src/drivers/net/bnxt/bnxt.c | 1 + src/drivers/net/eepro100.c | 1 + src/drivers/net/etherfabric.c | 1 + src/drivers/net/marvell/atl2_hw.c | 1 + src/drivers/net/marvell/atl_hw.c | 1 + src/drivers/net/myri10ge.c | 2 +- src/drivers/net/netvsc.c | 1 + src/drivers/net/rtl818x/rtl818x.c | 1 + src/drivers/net/sfc/efx_hunt.c | 1 + src/drivers/net/sfc/sfc_hunt.c | 1 + src/drivers/net/skge.c | 1 + src/drivers/net/sky2.c | 1 + src/drivers/net/tg3/tg3.c | 1 + src/drivers/net/tg3/tg3_hw.c | 1 + src/drivers/net/tg3/tg3_phy.c | 1 + src/drivers/net/vmxnet3.c | 1 + src/drivers/net/vxge/vxge_config.c | 1 + src/drivers/net/vxge/vxge_traffic.c | 1 + src/drivers/nvs/nvsvpd.c | 1 + src/drivers/usb/usbblk.c | 1 + src/hci/commands/cert_cmd.c | 1 + src/hci/commands/image_cmd.c | 1 + src/hci/commands/image_crypt_cmd.c | 1 + src/hci/commands/image_trust_cmd.c | 1 + src/hci/commands/pci_cmd.c | 1 + src/hci/commands/usb_cmd.c | 1 + src/image/der.c | 1 + src/image/efi_image.c | 1 + src/image/efi_siglist.c | 1 + src/image/elf.c | 1 + src/image/pnm.c | 1 + src/image/segment.c | 1 + src/include/ipxe/dummy_pio.h | 2 ++ src/include/ipxe/iomap_virt.h | 2 ++ src/include/ipxe/uaccess.h | 27 ---------------------- src/interface/efi/efi_bofm.c | 1 + src/interface/efi/efi_cmdline.c | 1 + src/interface/efi/efi_pci.c | 1 + src/interface/xen/xenbus.c | 1 + src/net/eapol.c | 1 + src/net/fcoe.c | 1 + src/net/lldp.c | 1 + src/net/peerblk.c | 1 + src/net/peermux.c | 1 + src/net/tcp/httpblock.c | 1 + src/net/tcp/syslogs.c | 1 + src/net/udp/syslog.c | 1 + src/tests/asn1_test.c | 1 + src/tests/cpio_test.c | 1 + src/tests/pixbuf_test.c | 1 + src/tests/test.c | 1 + src/usr/imgarchive.c | 1 + src/usr/imgmgmt.c | 1 + src/usr/imgtrust.c | 1 + 89 files changed, 90 insertions(+), 28 deletions(-) (limited to 'src/drivers') diff --git a/src/arch/x86/core/runtime.c b/src/arch/x86/core/runtime.c index 1fdf80497..461188d04 100644 --- a/src/arch/x86/core/runtime.c +++ b/src/arch/x86/core/runtime.c @@ -32,6 +32,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include #include #include diff --git a/src/arch/x86/drivers/xen/hvm.c b/src/arch/x86/drivers/xen/hvm.c index b77cdd14c..cf41cc955 100644 --- a/src/arch/x86/drivers/xen/hvm.c +++ b/src/arch/x86/drivers/xen/hvm.c @@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/arch/x86/image/elfboot.c b/src/arch/x86/image/elfboot.c index 63a3460d3..f662e366f 100644 --- a/src/arch/x86/image/elfboot.c +++ b/src/arch/x86/image/elfboot.c @@ -23,6 +23,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +#include #include #include #include diff --git a/src/arch/x86/image/initrd.c b/src/arch/x86/image/initrd.c index 8acdd95f7..cb4879036 100644 --- a/src/arch/x86/image/initrd.c +++ b/src/arch/x86/image/initrd.c @@ -23,6 +23,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +#include #include #include #include diff --git a/src/arch/x86/image/multiboot.c b/src/arch/x86/image/multiboot.c index 7c8963475..9444c4047 100644 --- a/src/arch/x86/image/multiboot.c +++ b/src/arch/x86/image/multiboot.c @@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ #include +#include #include #include #include diff --git a/src/arch/x86/image/nbi.c b/src/arch/x86/image/nbi.c index 0a60283fb..0f57bdfcd 100644 --- a/src/arch/x86/image/nbi.c +++ b/src/arch/x86/image/nbi.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/src/arch/x86/image/pxe_image.c b/src/arch/x86/image/pxe_image.c index d7acd0084..3e6cf7268 100644 --- a/src/arch/x86/image/pxe_image.c +++ b/src/arch/x86/image/pxe_image.c @@ -30,6 +30,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * */ +#include #include #include #include diff --git a/src/arch/x86/image/ucode.c b/src/arch/x86/image/ucode.c index 0ae3863cb..fd4689e00 100644 --- a/src/arch/x86/image/ucode.c +++ b/src/arch/x86/image/ucode.c @@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/arch/x86/include/realmode.h b/src/arch/x86/include/realmode.h index 75f7d16e7..5cf644a23 100644 --- a/src/arch/x86/include/realmode.h +++ b/src/arch/x86/include/realmode.h @@ -2,6 +2,7 @@ #define REALMODE_H #include +#include #include #include diff --git a/src/arch/x86/interface/pcbios/acpipwr.c b/src/arch/x86/interface/pcbios/acpipwr.c index bff53806b..cb82ef1b4 100644 --- a/src/arch/x86/interface/pcbios/acpipwr.c +++ b/src/arch/x86/interface/pcbios/acpipwr.c @@ -23,6 +23,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +#include #include #include #include diff --git a/src/arch/x86/interface/pcbios/bios_cachedhcp.c b/src/arch/x86/interface/pcbios/bios_cachedhcp.c index 05d89b3b7..897858143 100644 --- a/src/arch/x86/interface/pcbios/bios_cachedhcp.c +++ b/src/arch/x86/interface/pcbios/bios_cachedhcp.c @@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include #include #include #include diff --git a/src/arch/x86/interface/pcbios/bios_reboot.c b/src/arch/x86/interface/pcbios/bios_reboot.c index 463470245..c7f25405f 100644 --- a/src/arch/x86/interface/pcbios/bios_reboot.c +++ b/src/arch/x86/interface/pcbios/bios_reboot.c @@ -29,6 +29,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * */ +#include #include #include #include diff --git a/src/arch/x86/interface/pcbios/biosint.c b/src/arch/x86/interface/pcbios/biosint.c index 667e9ed81..f5e54ede8 100644 --- a/src/arch/x86/interface/pcbios/biosint.c +++ b/src/arch/x86/interface/pcbios/biosint.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/src/arch/x86/interface/pcbios/hidemem.c b/src/arch/x86/interface/pcbios/hidemem.c index 1a3022c5d..6983c1f4a 100644 --- a/src/arch/x86/interface/pcbios/hidemem.c +++ b/src/arch/x86/interface/pcbios/hidemem.c @@ -22,6 +22,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +#include #include #include #include diff --git a/src/arch/x86/interface/pcbios/int13.c b/src/arch/x86/interface/pcbios/int13.c index 73fdfebd3..045d78e8d 100644 --- a/src/arch/x86/interface/pcbios/int13.c +++ b/src/arch/x86/interface/pcbios/int13.c @@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/arch/x86/interface/pcbios/memmap.c b/src/arch/x86/interface/pcbios/memmap.c index daae382b8..3bc1229aa 100644 --- a/src/arch/x86/interface/pcbios/memmap.c +++ b/src/arch/x86/interface/pcbios/memmap.c @@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include #include #include #include diff --git a/src/arch/x86/interface/pcbios/memtop_umalloc.c b/src/arch/x86/interface/pcbios/memtop_umalloc.c index d4489fb01..bfaffc4bb 100644 --- a/src/arch/x86/interface/pcbios/memtop_umalloc.c +++ b/src/arch/x86/interface/pcbios/memtop_umalloc.c @@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ #include +#include #include #include #include diff --git a/src/arch/x86/interface/pcbios/rsdp.c b/src/arch/x86/interface/pcbios/rsdp.c index 6bcf19b18..6913be552 100644 --- a/src/arch/x86/interface/pcbios/rsdp.c +++ b/src/arch/x86/interface/pcbios/rsdp.c @@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ #include +#include #include #include #include diff --git a/src/core/blocktrans.c b/src/core/blocktrans.c index 362721747..b793185fe 100644 --- a/src/core/blocktrans.c +++ b/src/core/blocktrans.c @@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ #include +#include #include #include #include diff --git a/src/core/cachedhcp.c b/src/core/cachedhcp.c index 0d400db16..1510f3321 100644 --- a/src/core/cachedhcp.c +++ b/src/core/cachedhcp.c @@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/core/downloader.c b/src/core/downloader.c index 449761836..9950fe5e4 100644 --- a/src/core/downloader.c +++ b/src/core/downloader.c @@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include #include #include #include diff --git a/src/core/pixbuf.c b/src/core/pixbuf.c index d0b80b2a9..506a28c38 100644 --- a/src/core/pixbuf.c +++ b/src/core/pixbuf.c @@ -30,6 +30,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ #include +#include #include #include #include diff --git a/src/core/sanboot.c b/src/core/sanboot.c index bdac813ff..e90c5ef1d 100644 --- a/src/core/sanboot.c +++ b/src/core/sanboot.c @@ -32,6 +32,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/drivers/bus/devtree.c b/src/drivers/bus/devtree.c index cbd8ea8fa..654f8d14f 100644 --- a/src/drivers/bus/devtree.c +++ b/src/drivers/bus/devtree.c @@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/drivers/bus/ecam.c b/src/drivers/bus/ecam.c index 58d513e88..35556a8d9 100644 --- a/src/drivers/bus/ecam.c +++ b/src/drivers/bus/ecam.c @@ -23,6 +23,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +#include #include #include #include diff --git a/src/drivers/bus/pci_settings.c b/src/drivers/bus/pci_settings.c index 98005559d..84aa76827 100644 --- a/src/drivers/bus/pci_settings.c +++ b/src/drivers/bus/pci_settings.c @@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include #include #include #include diff --git a/src/drivers/bus/usb_settings.c b/src/drivers/bus/usb_settings.c index db6f94d8a..4fd190d83 100644 --- a/src/drivers/bus/usb_settings.c +++ b/src/drivers/bus/usb_settings.c @@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include #include #include #include diff --git a/src/drivers/infiniband/flexboot_nodnic.c b/src/drivers/infiniband/flexboot_nodnic.c index c6e19b955..a9e6fdd71 100644 --- a/src/drivers/infiniband/flexboot_nodnic.c +++ b/src/drivers/infiniband/flexboot_nodnic.c @@ -20,6 +20,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include +#include #include #include #include diff --git a/src/drivers/infiniband/linda.c b/src/drivers/infiniband/linda.c index 0c8a043a1..2e2b469e4 100644 --- a/src/drivers/infiniband/linda.c +++ b/src/drivers/infiniband/linda.c @@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/drivers/infiniband/mlx_utils_flexboot/src/mlx_memory_priv.c b/src/drivers/infiniband/mlx_utils_flexboot/src/mlx_memory_priv.c index e368d459b..b35c30dee 100644 --- a/src/drivers/infiniband/mlx_utils_flexboot/src/mlx_memory_priv.c +++ b/src/drivers/infiniband/mlx_utils_flexboot/src/mlx_memory_priv.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include "../../mlx_utils/include/private/mlx_memory_priv.h" diff --git a/src/drivers/infiniband/qib7322.c b/src/drivers/infiniband/qib7322.c index a011dafc1..a9e4566dc 100644 --- a/src/drivers/infiniband/qib7322.c +++ b/src/drivers/infiniband/qib7322.c @@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/drivers/linux/slirp.c b/src/drivers/linux/slirp.c index 8341c9676..d7ab6419e 100644 --- a/src/drivers/linux/slirp.c +++ b/src/drivers/linux/slirp.c @@ -18,6 +18,7 @@ */ #include +#include #include #include #include diff --git a/src/drivers/net/ath/ath.h b/src/drivers/net/ath/ath.h index 589bb5634..21f795b70 100644 --- a/src/drivers/net/ath/ath.h +++ b/src/drivers/net/ath/ath.h @@ -23,6 +23,7 @@ FILE_LICENCE ( BSD2 ); #include +#include #include /* This block of functions are from kernel.h v3.0.1 */ diff --git a/src/drivers/net/ath/ath5k/ath5k.h b/src/drivers/net/ath/ath5k/ath5k.h index fa62e8ce5..727d41279 100644 --- a/src/drivers/net/ath/ath5k/ath5k.h +++ b/src/drivers/net/ath/ath5k/ath5k.h @@ -24,6 +24,7 @@ FILE_LICENCE ( MIT ); #include +#include #include #include #include diff --git a/src/drivers/net/b44.c b/src/drivers/net/b44.c index 30ece5574..c6ca99865 100644 --- a/src/drivers/net/b44.c +++ b/src/drivers/net/b44.c @@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); +#include #include #include #include diff --git a/src/drivers/net/bnxt/bnxt.c b/src/drivers/net/bnxt/bnxt.c index 5de8d094e..402439eef 100644 --- a/src/drivers/net/bnxt/bnxt.c +++ b/src/drivers/net/bnxt/bnxt.c @@ -3,6 +3,7 @@ FILE_LICENCE ( GPL2_ONLY ); #include #include +#include #include #include #include diff --git a/src/drivers/net/eepro100.c b/src/drivers/net/eepro100.c index 49b00d443..318db1883 100644 --- a/src/drivers/net/eepro100.c +++ b/src/drivers/net/eepro100.c @@ -101,6 +101,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); */ #include +#include #include #include #include diff --git a/src/drivers/net/etherfabric.c b/src/drivers/net/etherfabric.c index be30b71f7..a58b71568 100644 --- a/src/drivers/net/etherfabric.c +++ b/src/drivers/net/etherfabric.c @@ -21,6 +21,7 @@ FILE_LICENCE ( GPL_ANY ); #include #include #include +#include #include #include #include diff --git a/src/drivers/net/marvell/atl2_hw.c b/src/drivers/net/marvell/atl2_hw.c index 805820709..07822a9c2 100644 --- a/src/drivers/net/marvell/atl2_hw.c +++ b/src/drivers/net/marvell/atl2_hw.c @@ -31,6 +31,7 @@ FILE_LICENCE ( BSD2 ); +#include #include #include #include diff --git a/src/drivers/net/marvell/atl_hw.c b/src/drivers/net/marvell/atl_hw.c index e0843e6f4..fa7f2a9b8 100644 --- a/src/drivers/net/marvell/atl_hw.c +++ b/src/drivers/net/marvell/atl_hw.c @@ -31,6 +31,7 @@ FILE_LICENCE ( BSD2 ); +#include #include #include #include diff --git a/src/drivers/net/myri10ge.c b/src/drivers/net/myri10ge.c index 6d0f723f2..fb9dc01b2 100644 --- a/src/drivers/net/myri10ge.c +++ b/src/drivers/net/myri10ge.c @@ -74,7 +74,7 @@ FILE_LICENCE ( GPL2_ONLY ); */ #include - +#include #include #include #include diff --git a/src/drivers/net/netvsc.c b/src/drivers/net/netvsc.c index 4bdf7b517..9b6ee88b4 100644 --- a/src/drivers/net/netvsc.c +++ b/src/drivers/net/netvsc.c @@ -32,6 +32,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * bus (VMBus). It provides a transport layer for RNDIS packets. */ +#include #include #include #include diff --git a/src/drivers/net/rtl818x/rtl818x.c b/src/drivers/net/rtl818x/rtl818x.c index 599d36fad..3bae8a797 100644 --- a/src/drivers/net/rtl818x/rtl818x.c +++ b/src/drivers/net/rtl818x/rtl818x.c @@ -20,6 +20,7 @@ FILE_LICENCE(GPL2_ONLY); #include +#include #include #include #include diff --git a/src/drivers/net/sfc/efx_hunt.c b/src/drivers/net/sfc/efx_hunt.c index abe3e8320..92c0fda62 100644 --- a/src/drivers/net/sfc/efx_hunt.c +++ b/src/drivers/net/sfc/efx_hunt.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include diff --git a/src/drivers/net/sfc/sfc_hunt.c b/src/drivers/net/sfc/sfc_hunt.c index 43ac229ab..f763fc9d0 100644 --- a/src/drivers/net/sfc/sfc_hunt.c +++ b/src/drivers/net/sfc/sfc_hunt.c @@ -19,6 +19,7 @@ ***************************************************************************/ #include #include +#include #include #include #include diff --git a/src/drivers/net/skge.c b/src/drivers/net/skge.c index cc7f0b91b..828a2a4c9 100755 --- a/src/drivers/net/skge.c +++ b/src/drivers/net/skge.c @@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_ONLY ); #include +#include #include #include #include diff --git a/src/drivers/net/sky2.c b/src/drivers/net/sky2.c index 4f8ec3e42..db3f6aaa1 100644 --- a/src/drivers/net/sky2.c +++ b/src/drivers/net/sky2.c @@ -28,6 +28,7 @@ FILE_LICENCE ( GPL2_ONLY ); #include +#include #include #include #include diff --git a/src/drivers/net/tg3/tg3.c b/src/drivers/net/tg3/tg3.c index 05af22d61..a6736305c 100644 --- a/src/drivers/net/tg3/tg3.c +++ b/src/drivers/net/tg3/tg3.c @@ -3,6 +3,7 @@ FILE_LICENCE ( GPL2_ONLY ); #include #include +#include #include #include #include diff --git a/src/drivers/net/tg3/tg3_hw.c b/src/drivers/net/tg3/tg3_hw.c index 9a70413b6..5c9506dce 100644 --- a/src/drivers/net/tg3/tg3_hw.c +++ b/src/drivers/net/tg3/tg3_hw.c @@ -18,6 +18,7 @@ FILE_LICENCE ( GPL2_ONLY ); #include +#include #include #include #include diff --git a/src/drivers/net/tg3/tg3_phy.c b/src/drivers/net/tg3/tg3_phy.c index e88b0be0f..a2322329e 100644 --- a/src/drivers/net/tg3/tg3_phy.c +++ b/src/drivers/net/tg3/tg3_phy.c @@ -1,6 +1,7 @@ #include #include +#include #include #include #include diff --git a/src/drivers/net/vmxnet3.c b/src/drivers/net/vmxnet3.c index 3800d6b72..2cc6738f2 100644 --- a/src/drivers/net/vmxnet3.c +++ b/src/drivers/net/vmxnet3.c @@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include #include #include #include diff --git a/src/drivers/net/vxge/vxge_config.c b/src/drivers/net/vxge/vxge_config.c index f4d217097..8c6ee9e96 100644 --- a/src/drivers/net/vxge/vxge_config.c +++ b/src/drivers/net/vxge/vxge_config.c @@ -16,6 +16,7 @@ FILE_LICENCE(GPL2_ONLY); #include #include +#include #include #include #include diff --git a/src/drivers/net/vxge/vxge_traffic.c b/src/drivers/net/vxge/vxge_traffic.c index dbd799015..0adaea2aa 100644 --- a/src/drivers/net/vxge/vxge_traffic.c +++ b/src/drivers/net/vxge/vxge_traffic.c @@ -15,6 +15,7 @@ FILE_LICENCE(GPL2_ONLY); #include +#include #include #include "vxge_traffic.h" diff --git a/src/drivers/nvs/nvsvpd.c b/src/drivers/nvs/nvsvpd.c index 3e88531c7..195973319 100644 --- a/src/drivers/nvs/nvsvpd.c +++ b/src/drivers/nvs/nvsvpd.c @@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include #include #include #include diff --git a/src/drivers/usb/usbblk.c b/src/drivers/usb/usbblk.c index 39adc012f..cb377efb0 100644 --- a/src/drivers/usb/usbblk.c +++ b/src/drivers/usb/usbblk.c @@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/hci/commands/cert_cmd.c b/src/hci/commands/cert_cmd.c index 24b18bf5c..75d2ccbed 100644 --- a/src/hci/commands/cert_cmd.c +++ b/src/hci/commands/cert_cmd.c @@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include #include #include #include diff --git a/src/hci/commands/image_cmd.c b/src/hci/commands/image_cmd.c index bf97b4deb..4b42695c4 100644 --- a/src/hci/commands/image_cmd.c +++ b/src/hci/commands/image_cmd.c @@ -26,6 +26,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include #include #include diff --git a/src/hci/commands/image_crypt_cmd.c b/src/hci/commands/image_crypt_cmd.c index 26e9d79f8..4dfb5b131 100644 --- a/src/hci/commands/image_crypt_cmd.c +++ b/src/hci/commands/image_crypt_cmd.c @@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/hci/commands/image_trust_cmd.c b/src/hci/commands/image_trust_cmd.c index b34378f93..9b9e3f859 100644 --- a/src/hci/commands/image_trust_cmd.c +++ b/src/hci/commands/image_trust_cmd.c @@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/hci/commands/pci_cmd.c b/src/hci/commands/pci_cmd.c index 5bae66fbe..fa1fa5ece 100644 --- a/src/hci/commands/pci_cmd.c +++ b/src/hci/commands/pci_cmd.c @@ -22,6 +22,7 @@ */ #include +#include #include #include #include diff --git a/src/hci/commands/usb_cmd.c b/src/hci/commands/usb_cmd.c index d1086fd7e..4ee2f2ddb 100644 --- a/src/hci/commands/usb_cmd.c +++ b/src/hci/commands/usb_cmd.c @@ -22,6 +22,7 @@ */ #include +#include #include #include #include diff --git a/src/image/der.c b/src/image/der.c index 600e163c9..67117d43b 100644 --- a/src/image/der.c +++ b/src/image/der.c @@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include #include #include #include diff --git a/src/image/efi_image.c b/src/image/efi_image.c index f71630f4a..f7ee7ff50 100644 --- a/src/image/efi_image.c +++ b/src/image/efi_image.c @@ -21,6 +21,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include #include +#include #include #include #include diff --git a/src/image/efi_siglist.c b/src/image/efi_siglist.c index 2bd273dbd..b264ac558 100644 --- a/src/image/efi_siglist.c +++ b/src/image/efi_siglist.c @@ -30,6 +30,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ #include +#include #include #include #include diff --git a/src/image/elf.c b/src/image/elf.c index 83712c3b0..97e07f37f 100644 --- a/src/image/elf.c +++ b/src/image/elf.c @@ -33,6 +33,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * common ELF-related functionality. */ +#include #include #include #include diff --git a/src/image/pnm.c b/src/image/pnm.c index 4b5020b64..489a43304 100644 --- a/src/image/pnm.c +++ b/src/image/pnm.c @@ -30,6 +30,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ #include +#include #include #include #include diff --git a/src/image/segment.c b/src/image/segment.c index 2cb637dc2..52272170a 100644 --- a/src/image/segment.c +++ b/src/image/segment.c @@ -30,6 +30,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * */ +#include #include #include #include diff --git a/src/include/ipxe/dummy_pio.h b/src/include/ipxe/dummy_pio.h index 1cdabba14..e7a4cabef 100644 --- a/src/include/ipxe/dummy_pio.h +++ b/src/include/ipxe/dummy_pio.h @@ -13,6 +13,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +#include + #define DUMMY_INX( _prefix, _suffix, _type ) \ static inline __always_inline _type \ IOAPI_INLINE ( _prefix, in ## _suffix ) ( volatile _type *io_addr __unused) { \ diff --git a/src/include/ipxe/iomap_virt.h b/src/include/ipxe/iomap_virt.h index 4962b7c37..731d083d5 100644 --- a/src/include/ipxe/iomap_virt.h +++ b/src/include/ipxe/iomap_virt.h @@ -9,6 +9,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +#include + #ifdef IOMAP_VIRT #define IOMAP_PREFIX_virt #else diff --git a/src/include/ipxe/uaccess.h b/src/include/ipxe/uaccess.h index 948ef1fa2..82f29f793 100644 --- a/src/include/ipxe/uaccess.h +++ b/src/include/ipxe/uaccess.h @@ -11,7 +11,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include -#include #include #include @@ -127,30 +126,4 @@ virt_to_phys ( volatile const void *virt ); */ void * __attribute__ (( const )) phys_to_virt ( physaddr_t phys ); -/** - * Copy data to user buffer - * - * @v dest Destination - * @v dest_off Destination offset - * @v src Source - * @v len Length - */ -static inline __always_inline void -copy_to_user ( userptr_t dest, off_t dest_off, const void *src, size_t len ) { - memcpy ( ( dest + dest_off ), src, len ); -} - -/** - * Copy data from user buffer - * - * @v dest Destination - * @v src Source - * @v src_off Source offset - * @v len Length - */ -static inline __always_inline void -copy_from_user ( void *dest, userptr_t src, off_t src_off, size_t len ) { - memcpy ( dest, ( src + src_off ), len ); -} - #endif /* _IPXE_UACCESS_H */ diff --git a/src/interface/efi/efi_bofm.c b/src/interface/efi/efi_bofm.c index 7d1d3619f..3d956800e 100644 --- a/src/interface/efi/efi_bofm.c +++ b/src/interface/efi/efi_bofm.c @@ -23,6 +23,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +#include #include #include #include diff --git a/src/interface/efi/efi_cmdline.c b/src/interface/efi/efi_cmdline.c index b33bebd8c..13ad0fc35 100644 --- a/src/interface/efi/efi_cmdline.c +++ b/src/interface/efi/efi_cmdline.c @@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/interface/efi/efi_pci.c b/src/interface/efi/efi_pci.c index b8c7df38d..1b1f05816 100644 --- a/src/interface/efi/efi_pci.c +++ b/src/interface/efi/efi_pci.c @@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include #include #include #include diff --git a/src/interface/xen/xenbus.c b/src/interface/xen/xenbus.c index 5dd01dfa3..8b5ee0a0d 100644 --- a/src/interface/xen/xenbus.c +++ b/src/interface/xen/xenbus.c @@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include #include #include #include diff --git a/src/net/eapol.c b/src/net/eapol.c index 8b09ca231..0c573d198 100644 --- a/src/net/eapol.c +++ b/src/net/eapol.c @@ -23,6 +23,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +#include #include #include #include diff --git a/src/net/fcoe.c b/src/net/fcoe.c index 9f3ddf88b..d54f1d431 100644 --- a/src/net/fcoe.c +++ b/src/net/fcoe.c @@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/net/lldp.c b/src/net/lldp.c index a854d0ace..2b707c874 100644 --- a/src/net/lldp.c +++ b/src/net/lldp.c @@ -30,6 +30,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ #include +#include #include #include #include diff --git a/src/net/peerblk.c b/src/net/peerblk.c index bbd5f16ed..58b185102 100644 --- a/src/net/peerblk.c +++ b/src/net/peerblk.c @@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/net/peermux.c b/src/net/peermux.c index 431ca76e0..5c814b03e 100644 --- a/src/net/peermux.c +++ b/src/net/peermux.c @@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/net/tcp/httpblock.c b/src/net/tcp/httpblock.c index 156f11e47..8eff1942c 100644 --- a/src/net/tcp/httpblock.c +++ b/src/net/tcp/httpblock.c @@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ #include +#include #include #include #include diff --git a/src/net/tcp/syslogs.c b/src/net/tcp/syslogs.c index f1f70d59e..5676f3e3e 100644 --- a/src/net/tcp/syslogs.c +++ b/src/net/tcp/syslogs.c @@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/net/udp/syslog.c b/src/net/udp/syslog.c index a45fc459d..198c86ef7 100644 --- a/src/net/udp/syslog.c +++ b/src/net/udp/syslog.c @@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/tests/asn1_test.c b/src/tests/asn1_test.c index df3f01b63..b522b85d7 100644 --- a/src/tests/asn1_test.c +++ b/src/tests/asn1_test.c @@ -33,6 +33,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #undef NDEBUG #include +#include #include #include #include diff --git a/src/tests/cpio_test.c b/src/tests/cpio_test.c index 7eb8b2c74..24baf947b 100644 --- a/src/tests/cpio_test.c +++ b/src/tests/cpio_test.c @@ -33,6 +33,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #undef NDEBUG #include +#include #include #include diff --git a/src/tests/pixbuf_test.c b/src/tests/pixbuf_test.c index 1f82e0018..a8ea1151e 100644 --- a/src/tests/pixbuf_test.c +++ b/src/tests/pixbuf_test.c @@ -32,6 +32,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /* Forcibly enable assertions */ #undef NDEBUG +#include #include #include #include diff --git a/src/tests/test.c b/src/tests/test.c index 4c49d4c16..1ec4b21ef 100644 --- a/src/tests/test.c +++ b/src/tests/test.c @@ -34,6 +34,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/usr/imgarchive.c b/src/usr/imgarchive.c index 6849dd510..91600760e 100644 --- a/src/usr/imgarchive.c +++ b/src/usr/imgarchive.c @@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include #include #include diff --git a/src/usr/imgmgmt.c b/src/usr/imgmgmt.c index 054137696..65b52fd3a 100644 --- a/src/usr/imgmgmt.c +++ b/src/usr/imgmgmt.c @@ -26,6 +26,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include #include #include diff --git a/src/usr/imgtrust.c b/src/usr/imgtrust.c index 7f7e7ed14..4eb631e79 100644 --- a/src/usr/imgtrust.c +++ b/src/usr/imgtrust.c @@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include #include #include #include -- cgit v1.2.3-55-g7522 From a169d73593f6c471857a694edc22809608c7d9c0 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 30 Apr 2025 14:33:57 +0100 Subject: [uaccess] Reduce scope of included uaccess.h header The uaccess.h header is no longer required for any code that touches external ("user") memory, since such memory accesses are now performed through pointer dereferences. Reduce the number of files including this header. Signed-off-by: Michael Brown --- src/arch/x86/image/elfboot.c | 1 + src/arch/x86/image/pxe_image.c | 1 - src/arch/x86/interface/pxe/pxe_file.c | 1 - src/core/cachedhcp.c | 1 + src/core/downloader.c | 1 - src/core/fbcon.c | 1 + src/core/image.c | 1 + src/drivers/bus/ecam.c | 1 - src/hci/commands/image_mem_cmd.c | 1 + src/image/elf.c | 1 + src/include/ipxe/dhcp.h | 1 - src/include/ipxe/image.h | 1 - src/include/ipxe/iomap.h | 1 - src/include/ipxe/iomap_virt.h | 1 + src/include/ipxe/xen.h | 1 - src/interface/efi/efi_cmdline.c | 1 + src/net/pccrc.c | 1 - src/usr/imgtrust.c | 1 - 18 files changed, 8 insertions(+), 10 deletions(-) (limited to 'src/drivers') diff --git a/src/arch/x86/image/elfboot.c b/src/arch/x86/image/elfboot.c index f662e366f..7f89e8b65 100644 --- a/src/arch/x86/image/elfboot.c +++ b/src/arch/x86/image/elfboot.c @@ -30,6 +30,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include /** * @file diff --git a/src/arch/x86/image/pxe_image.c b/src/arch/x86/image/pxe_image.c index 3e6cf7268..ccb3a7d9d 100644 --- a/src/arch/x86/image/pxe_image.c +++ b/src/arch/x86/image/pxe_image.c @@ -34,7 +34,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include #include #include #include diff --git a/src/arch/x86/interface/pxe/pxe_file.c b/src/arch/x86/interface/pxe/pxe_file.c index b934e8fef..997667ccf 100644 --- a/src/arch/x86/interface/pxe/pxe_file.c +++ b/src/arch/x86/interface/pxe/pxe_file.c @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include diff --git a/src/core/cachedhcp.c b/src/core/cachedhcp.c index 1510f3321..eeb2fca58 100644 --- a/src/core/cachedhcp.c +++ b/src/core/cachedhcp.c @@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include /** @file diff --git a/src/core/downloader.c b/src/core/downloader.c index 9950fe5e4..1c638f502 100644 --- a/src/core/downloader.c +++ b/src/core/downloader.c @@ -31,7 +31,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include #include #include #include diff --git a/src/core/fbcon.c b/src/core/fbcon.c index 43f73fbac..ef158aec7 100644 --- a/src/core/fbcon.c +++ b/src/core/fbcon.c @@ -36,6 +36,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include #include #include diff --git a/src/core/image.c b/src/core/image.c index a06466b72..b2bd0956b 100644 --- a/src/core/image.c +++ b/src/core/image.c @@ -33,6 +33,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include #include #include diff --git a/src/drivers/bus/ecam.c b/src/drivers/bus/ecam.c index 35556a8d9..976254c18 100644 --- a/src/drivers/bus/ecam.c +++ b/src/drivers/bus/ecam.c @@ -25,7 +25,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include -#include #include /** @file diff --git a/src/hci/commands/image_mem_cmd.c b/src/hci/commands/image_mem_cmd.c index 5f8363461..fcd766627 100644 --- a/src/hci/commands/image_mem_cmd.c +++ b/src/hci/commands/image_mem_cmd.c @@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include #include #include #include diff --git a/src/image/elf.c b/src/image/elf.c index 97e07f37f..8cbb610a6 100644 --- a/src/image/elf.c +++ b/src/image/elf.c @@ -38,6 +38,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include /** diff --git a/src/include/ipxe/dhcp.h b/src/include/ipxe/dhcp.h index 51349efd9..4d68d3ca5 100644 --- a/src/include/ipxe/dhcp.h +++ b/src/include/ipxe/dhcp.h @@ -17,7 +17,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include struct interface; struct dhcp_options; diff --git a/src/include/ipxe/image.h b/src/include/ipxe/image.h index fbf2b63b9..e0e70f360 100644 --- a/src/include/ipxe/image.h +++ b/src/include/ipxe/image.h @@ -12,7 +12,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include -#include #include struct uri; diff --git a/src/include/ipxe/iomap.h b/src/include/ipxe/iomap.h index b8ded38ef..7d1547d9c 100644 --- a/src/include/ipxe/iomap.h +++ b/src/include/ipxe/iomap.h @@ -14,7 +14,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include /** * Calculate static inline I/O mapping API function name diff --git a/src/include/ipxe/iomap_virt.h b/src/include/ipxe/iomap_virt.h index 731d083d5..3dd66bd75 100644 --- a/src/include/ipxe/iomap_virt.h +++ b/src/include/ipxe/iomap_virt.h @@ -10,6 +10,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include #ifdef IOMAP_VIRT #define IOMAP_PREFIX_virt diff --git a/src/include/ipxe/xen.h b/src/include/ipxe/xen.h index 0fb8b7625..382901ff3 100644 --- a/src/include/ipxe/xen.h +++ b/src/include/ipxe/xen.h @@ -14,7 +14,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include -#include #include #include diff --git a/src/interface/efi/efi_cmdline.c b/src/interface/efi/efi_cmdline.c index d5ec6cee3..8b9d8efde 100644 --- a/src/interface/efi/efi_cmdline.c +++ b/src/interface/efi/efi_cmdline.c @@ -37,6 +37,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include #include diff --git a/src/net/pccrc.c b/src/net/pccrc.c index 29adc4b16..0db6e3cb5 100644 --- a/src/net/pccrc.c +++ b/src/net/pccrc.c @@ -25,7 +25,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include -#include #include #include #include diff --git a/src/usr/imgtrust.c b/src/usr/imgtrust.c index 4eb631e79..e60854c9f 100644 --- a/src/usr/imgtrust.c +++ b/src/usr/imgtrust.c @@ -28,7 +28,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include #include #include #include -- cgit v1.2.3-55-g7522 From f988ec09e01b54d21d1b1fa0e2b3121d926ed7df Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 9 May 2025 16:26:41 +0100 Subject: [fdt] Generalise access to "reg" property The "reg" property is also used by non-device nodes, such as the nodes describing the system memory map. Provide generalised functionality for parsing the "#address-cells", "#size-cells", and "reg" properties. Signed-off-by: Michael Brown --- src/core/fdt.c | 105 +++++++++++++++++++++++++++++++++++++++++++++ src/drivers/bus/devtree.c | 23 +++------- src/include/ipxe/devtree.h | 13 ++---- src/include/ipxe/fdt.h | 26 +++++++++++ 4 files changed, 141 insertions(+), 26 deletions(-) (limited to 'src/drivers') diff --git a/src/core/fdt.c b/src/core/fdt.c index 744e0e705..eee5b47b5 100644 --- a/src/core/fdt.c +++ b/src/core/fdt.c @@ -563,6 +563,111 @@ int fdt_u32 ( struct fdt *fdt, unsigned int offset, const char *name, return 0; } +/** + * Get region cell size specification + * + * @v fdt Device tree + * @v offset Starting (parent) node offset + * @v regs Region cell size specification to fill in + * + * Note that #address-cells and #size-cells are defined on the + * immediate parent node, rather than on the node with the "reg" + * property itself. + */ +void fdt_reg_cells ( struct fdt *fdt, unsigned int offset, + struct fdt_reg_cells *regs ) { + int rc; + + /* Read #address-cells, if present */ + if ( ( rc = fdt_u32 ( fdt, offset, "#address-cells", + ®s->address_cells ) ) != 0 ) { + regs->address_cells = FDT_DEFAULT_ADDRESS_CELLS; + } + + /* Read #size-cells, if present */ + if ( ( rc = fdt_u32 ( fdt, offset, "#size-cells", + ®s->size_cells ) ) != 0 ) { + regs->size_cells = FDT_DEFAULT_SIZE_CELLS; + } + + /* Calculate stride */ + regs->stride = ( regs->address_cells + regs->size_cells ); +} + +/** + * Get number of regions + * + * @v fdt Device tree + * @v offset Starting node offset + * @v regs Region cell size specification + * @ret count Number of regions, or negative error + */ +int fdt_reg_count ( struct fdt *fdt, unsigned int offset, + struct fdt_reg_cells *regs ) { + struct fdt_descriptor desc; + const uint32_t *cell; + unsigned int count; + int rc; + + /* Find property */ + if ( ( rc = fdt_property ( fdt, offset, "reg", &desc ) ) != 0 ) + return rc; + + /* Determine number of regions */ + count = ( desc.len / ( regs->stride * sizeof ( *cell ) ) ); + return count; +} + +/** + * Get region address + * + * @v fdt Device tree + * @v offset Starting node offset + * @v regs Region cell size specification + * @v index Region index + * @v address Region starting address to fill in + * @ret rc Return status code + */ +int fdt_reg_address ( struct fdt *fdt, unsigned int offset, + struct fdt_reg_cells *regs, unsigned int index, + uint64_t *address ) { + unsigned int cell = ( index * regs->stride ); + int rc; + + /* Read relevant portion of region array */ + if ( ( rc = fdt_cells ( fdt, offset, "reg", cell, regs->address_cells, + address ) ) != 0 ) { + return rc; + } + + return 0; +} + +/** + * Get region size + * + * @v fdt Device tree + * @v offset Starting node offset + * @v regs Region cell size specification + * @v index Region index + * @v size Region size to fill in + * @ret rc Return status code + */ +int fdt_reg_size ( struct fdt *fdt, unsigned int offset, + struct fdt_reg_cells *regs, unsigned int index, + uint64_t *size ) { + unsigned int cell = ( ( index * regs->stride ) + regs->address_cells ); + int rc; + + /* Read relevant portion of region array */ + if ( ( rc = fdt_cells ( fdt, offset, "reg", cell, regs->size_cells, + size ) ) != 0 ) { + return rc; + } + + return 0; +} + /** * Get MAC address from property * diff --git a/src/drivers/bus/devtree.c b/src/drivers/bus/devtree.c index 654f8d14f..55f68ee33 100644 --- a/src/drivers/bus/devtree.c +++ b/src/drivers/bus/devtree.c @@ -56,27 +56,25 @@ void * dt_ioremap ( struct dt_device *dt, unsigned int offset, unsigned int index, size_t len ) { struct dt_device *parent = container_of ( dt->dev.parent, struct dt_device, dev ); + struct fdt_reg_cells *regs = &parent->regs; uint64_t address; uint64_t size; - unsigned int cell; void *io_addr; int rc; /* Read address */ - cell = ( index * ( parent->address_cells + parent->size_cells ) ); - if ( ( rc = fdt_cells ( &sysfdt, offset, "reg", cell, - parent->address_cells, &address ) ) != 0 ) { + if ( ( rc = fdt_reg_address ( &sysfdt, offset, regs, index, + &address ) ) != 0 ) { DBGC ( dt, "DT %s could not read region %d address: %s\n", dt->path, index, strerror ( rc ) ); return NULL; } - cell += parent->address_cells; /* Read size (or assume sufficient, if tree specifies no sizes) */ size = len; - if ( parent->size_cells && - ( rc = fdt_cells ( &sysfdt, offset, "reg", cell, - parent->size_cells, &size ) ) != 0 ) { + if ( regs->size_cells && + ( ( rc = fdt_reg_size ( &sysfdt, offset, regs, index, + &size ) ) != 0 ) ) { DBGC ( dt, "DT %s could not read region %d size: %s\n", dt->path, index, strerror ( rc ) ); return NULL; @@ -225,14 +223,7 @@ static int dt_probe_node ( struct dt_device *parent, unsigned int offset, list_add_tail ( &dt->dev.siblings, &dt->dev.parent->children ); /* Read #address-cells and #size-cells, if present */ - if ( ( rc = fdt_u32 ( &sysfdt, offset, "#address-cells", - &dt->address_cells ) ) != 0 ) { - dt->address_cells = DT_DEFAULT_ADDRESS_CELLS; - } - if ( ( rc = fdt_u32 ( &sysfdt, offset, "#size-cells", - &dt->size_cells ) ) != 0 ) { - dt->size_cells = DT_DEFAULT_SIZE_CELLS; - } + fdt_reg_cells ( &sysfdt, offset, &dt->regs ); /* Probe device */ if ( ( rc = dt_probe ( dt, offset ) ) != 0 ) diff --git a/src/include/ipxe/devtree.h b/src/include/ipxe/devtree.h index 04414f370..6e9286af4 100644 --- a/src/include/ipxe/devtree.h +++ b/src/include/ipxe/devtree.h @@ -11,6 +11,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include /** A devicetree device */ struct dt_device { @@ -25,18 +26,10 @@ struct dt_device { /** Driver-private data */ void *priv; - /** Number of address cells for child devices */ - uint32_t address_cells; - /** Number of size cells for child devices */ - uint32_t size_cells; + /** Register cell size specification */ + struct fdt_reg_cells regs; }; -/** Default number of address cells, if not specified */ -#define DT_DEFAULT_ADDRESS_CELLS 2 - -/** Default number of size cells, if not specified */ -#define DT_DEFAULT_SIZE_CELLS 1 - /** A devicetree driver */ struct dt_driver { /** Driver name */ diff --git a/src/include/ipxe/fdt.h b/src/include/ipxe/fdt.h index fb0ae7752..6c58f5687 100644 --- a/src/include/ipxe/fdt.h +++ b/src/include/ipxe/fdt.h @@ -124,6 +124,22 @@ struct fdt_descriptor { int depth; }; +/** A device tree region cell size specification */ +struct fdt_reg_cells { + /** Number of address cells */ + uint32_t address_cells; + /** Number of size cells */ + uint32_t size_cells; + /** Number of address cells plus number of size cells */ + unsigned int stride; +}; + +/** Default number of address cells, if not specified */ +#define FDT_DEFAULT_ADDRESS_CELLS 2 + +/** Default number of size cells, if not specified */ +#define FDT_DEFAULT_SIZE_CELLS 1 + extern struct image_tag fdt_image __image_tag; extern struct fdt sysfdt; @@ -144,6 +160,16 @@ extern int fdt_u64 ( struct fdt *fdt, unsigned int offset, const char *name, uint64_t *value ); extern int fdt_u32 ( struct fdt *fdt, unsigned int offset, const char *name, uint32_t *value ); +extern void fdt_reg_cells ( struct fdt *fdt, unsigned int offset, + struct fdt_reg_cells *regs ); +extern int fdt_reg_count ( struct fdt *fdt, unsigned int offset, + struct fdt_reg_cells *regs ); +extern int fdt_reg_address ( struct fdt *fdt, unsigned int offset, + struct fdt_reg_cells *regs, unsigned int index, + uint64_t *address ); +extern int fdt_reg_size ( struct fdt *fdt, unsigned int offset, + struct fdt_reg_cells *regs, unsigned int index, + uint64_t *size ); extern int fdt_mac ( struct fdt *fdt, unsigned int offset, struct net_device *netdev ); extern int fdt_parse ( struct fdt *fdt, struct fdt_header *hdr, -- cgit v1.2.3-55-g7522 From 08edad7ca346d066062c4256a4f0f5b7276eb881 Mon Sep 17 00:00:00 2001 From: Joseph Wong Date: Wed, 14 May 2025 14:08:27 +0100 Subject: [bnxt] Return proper error codes in probe Return the proper error codes in bnxt_init_one, to indicate the correct return status upon completion. Failure paths could incorrectly indicate a success. Correct assertion condition to check for non-NULL pointer. Signed-off-by: Joseph Wong --- src/drivers/net/bnxt/bnxt.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/bnxt/bnxt.c b/src/drivers/net/bnxt/bnxt.c index 402439eef..4f3c8b709 100644 --- a/src/drivers/net/bnxt/bnxt.c +++ b/src/drivers/net/bnxt/bnxt.c @@ -525,7 +525,7 @@ void bnxt_rx_process ( struct net_device *dev, struct bnxt *bp, u8 drop; dump_rx_bd ( rx_cmp, rx_cmp_hi, desc_idx ); - assert ( !iob ); + assert ( iob ); drop = bnxt_rx_drop ( bp, iob, rx_cmp, rx_cmp_hi, rx_cmp->len ); dbg_rxp ( iob->data, rx_cmp->len, drop ); if ( drop ) @@ -2375,7 +2375,7 @@ static int bnxt_init_one ( struct pci_device *pci ) bnxt_get_pci_info ( bp ); /* Allocate and Initialise device specific parameters */ - if ( bnxt_alloc_mem ( bp ) != 0 ) { + if ( ( err = bnxt_alloc_mem ( bp ) ) != 0 ) { DBGP ( "- %s ( ): bnxt_alloc_mem Failed\n", __func__ ); goto err_down_pci; } @@ -2383,17 +2383,20 @@ static int bnxt_init_one ( struct pci_device *pci ) /* Get device specific information */ if ( bnxt_up_chip ( bp ) != 0 ) { DBGP ( "- %s ( ): bnxt_up_chip Failed\n", __func__ ); + err = -ENODEV; goto err_down_chip; } /* Register Network device */ - if ( register_netdev ( netdev ) != 0 ) { + if ( ( err = register_netdev ( netdev ) ) != 0 ) { DBGP ( "- %s ( ): register_netdev Failed\n", __func__ ); goto err_down_chip; } return 0; + unregister_netdev ( netdev ); + err_down_chip: bnxt_down_chip (bp); bnxt_free_mem ( bp ); -- cgit v1.2.3-55-g7522 From 1dd9ac13fd61db46eba2cd0279f2439a9f04f081 Mon Sep 17 00:00:00 2001 From: Joseph Wong Date: Wed, 14 May 2025 14:21:02 +0100 Subject: [bnxt] Use updated DMA APIs Replace malloc_phys with dma_alloc, free_phys with dma_free, alloc_iob with alloc_rx_iob, free_iob with free_rx_iob, virt_to_bus with dma or iob_dma. Replace dma_addr_t with physaddr_t. Signed-off-by: Joseph Wong --- src/drivers/net/bnxt/bnxt.c | 189 +++++++++++++++++++++++--------------------- src/drivers/net/bnxt/bnxt.h | 30 ++++--- 2 files changed, 118 insertions(+), 101 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/bnxt/bnxt.c b/src/drivers/net/bnxt/bnxt.c index 4f3c8b709..5a547703c 100644 --- a/src/drivers/net/bnxt/bnxt.c +++ b/src/drivers/net/bnxt/bnxt.c @@ -9,6 +9,7 @@ FILE_LICENCE ( GPL2_ONLY ); #include #include #include +#include #include #include #include @@ -340,7 +341,7 @@ static inline u32 bnxt_tx_avail ( struct bnxt *bp ) return ( avail-use ); } -void bnxt_set_txq ( struct bnxt *bp, int entry, dma_addr_t mapping, int len ) +void bnxt_set_txq ( struct bnxt *bp, int entry, physaddr_t mapping, int len ) { struct tx_bd_short *prod_bd; @@ -355,7 +356,7 @@ void bnxt_set_txq ( struct bnxt *bp, int entry, dma_addr_t mapping, int len ) else prod_bd->flags_type = TX_BD_SHORT_FLAGS_LHINT_GTE2K; prod_bd->flags_type |= TX_BD_FLAGS; - prod_bd->dma.addr = mapping; + prod_bd->dma = mapping; prod_bd->len = len; prod_bd->opaque = ( u32 )entry; } @@ -383,7 +384,7 @@ int bnxt_free_rx_iob ( struct bnxt *bp ) for ( i = 0; i < bp->rx.buf_cnt; i++ ) { if ( bp->rx.iob[i] ) { - free_iob ( bp->rx.iob[i] ); + free_rx_iob ( bp->rx.iob[i] ); bp->rx.iob[i] = NULL; } } @@ -403,14 +404,14 @@ static void bnxt_set_rx_desc ( u8 *buf, struct io_buffer *iob, desc->flags_type = RX_PROD_PKT_BD_TYPE_RX_PROD_PKT; desc->len = MAX_ETHERNET_PACKET_BUFFER_SIZE; desc->opaque = idx; - desc->dma.addr = virt_to_bus ( iob->data ); + desc->dma = iob_dma ( iob ); } static int bnxt_alloc_rx_iob ( struct bnxt *bp, u16 cons_id, u16 iob_idx ) { struct io_buffer *iob; - iob = alloc_iob ( BNXT_RX_STD_DMA_SZ ); + iob = alloc_rx_iob ( BNXT_RX_STD_DMA_SZ, bp->dma ); if ( !iob ) { DBGP ( "- %s ( ): alloc_iob Failed\n", __func__ ); return -ENOMEM; @@ -549,7 +550,7 @@ static int bnxt_rx_complete ( struct net_device *dev, u8 cmpl_bit = bp->cq.completion_bit; if ( bp->cq.cons_id == ( bp->cq.ring_cnt - 1 ) ) { - rx_cmp_hi = ( struct rx_pkt_cmpl_hi * )bp->cq.bd_virt; + rx_cmp_hi = ( struct rx_pkt_cmpl_hi * ) CQ_DMA_ADDR ( bp ); cmpl_bit ^= 0x1; /* Ring has wrapped. */ } else rx_cmp_hi = ( struct rx_pkt_cmpl_hi * ) ( rx_cmp+1 ); @@ -567,9 +568,11 @@ void bnxt_mm_init ( struct bnxt *bp, const char *func ) memset ( bp->hwrm_addr_req, 0, REQ_BUFFER_SIZE ); memset ( bp->hwrm_addr_resp, 0, RESP_BUFFER_SIZE ); memset ( bp->hwrm_addr_dma, 0, DMA_BUFFER_SIZE ); - bp->req_addr_mapping = virt_to_bus ( bp->hwrm_addr_req ); - bp->resp_addr_mapping = virt_to_bus ( bp->hwrm_addr_resp ); - bp->dma_addr_mapping = virt_to_bus ( bp->hwrm_addr_dma ); + memset ( bp->tx.bd_virt, 0, TX_RING_BUFFER_SIZE ); + memset ( bp->rx.bd_virt, 0, RX_RING_BUFFER_SIZE ); + memset ( bp->cq.bd_virt, 0, CQ_RING_BUFFER_SIZE ); + memset ( bp->nq.bd_virt, 0, NQ_RING_BUFFER_SIZE ); + bp->link_status = STATUS_LINK_DOWN; bp->wait_link_timeout = LINK_DEFAULT_TIMEOUT; bp->mtu = MAX_ETHERNET_PACKET_BUFFER_SIZE; @@ -618,40 +621,37 @@ void bnxt_free_mem ( struct bnxt *bp ) { DBGP ( "%s\n", __func__ ); if ( bp->nq.bd_virt ) { - free_phys ( bp->nq.bd_virt, NQ_RING_BUFFER_SIZE ); + dma_free ( &bp->nq_mapping, bp->nq.bd_virt, NQ_RING_BUFFER_SIZE ); bp->nq.bd_virt = NULL; } if ( bp->cq.bd_virt ) { - free_phys ( bp->cq.bd_virt, CQ_RING_BUFFER_SIZE ); + dma_free ( &bp->cq_mapping, bp->cq.bd_virt, CQ_RING_BUFFER_SIZE ); bp->cq.bd_virt = NULL; } if ( bp->rx.bd_virt ) { - free_phys ( bp->rx.bd_virt, RX_RING_BUFFER_SIZE ); + dma_free ( &bp->rx_mapping, bp->rx.bd_virt, RX_RING_BUFFER_SIZE ); bp->rx.bd_virt = NULL; } if ( bp->tx.bd_virt ) { - free_phys ( bp->tx.bd_virt, TX_RING_BUFFER_SIZE ); + dma_free ( &bp->tx_mapping, bp->tx.bd_virt, TX_RING_BUFFER_SIZE ); bp->tx.bd_virt = NULL; } if ( bp->hwrm_addr_dma ) { - free_phys ( bp->hwrm_addr_dma, DMA_BUFFER_SIZE ); - bp->dma_addr_mapping = 0; + dma_free ( &bp->dma_mapped, bp->hwrm_addr_dma, DMA_BUFFER_SIZE ); bp->hwrm_addr_dma = NULL; } if ( bp->hwrm_addr_resp ) { - free_phys ( bp->hwrm_addr_resp, RESP_BUFFER_SIZE ); - bp->resp_addr_mapping = 0; + dma_free ( &bp->resp_mapping, bp->hwrm_addr_resp, RESP_BUFFER_SIZE ); bp->hwrm_addr_resp = NULL; } if ( bp->hwrm_addr_req ) { - free_phys ( bp->hwrm_addr_req, REQ_BUFFER_SIZE ); - bp->req_addr_mapping = 0; + dma_free ( &bp->req_mapping, bp->hwrm_addr_req, REQ_BUFFER_SIZE ); bp->hwrm_addr_req = NULL; } DBGP ( "- %s ( ): - Done\n", __func__ ); @@ -660,14 +660,20 @@ void bnxt_free_mem ( struct bnxt *bp ) int bnxt_alloc_mem ( struct bnxt *bp ) { DBGP ( "%s\n", __func__ ); - bp->hwrm_addr_req = malloc_phys ( REQ_BUFFER_SIZE, BNXT_DMA_ALIGNMENT ); - bp->hwrm_addr_resp = malloc_phys ( RESP_BUFFER_SIZE, - BNXT_DMA_ALIGNMENT ); - bp->hwrm_addr_dma = malloc_phys ( DMA_BUFFER_SIZE, BNXT_DMA_ALIGNMENT ); - bp->tx.bd_virt = malloc_phys ( TX_RING_BUFFER_SIZE, DMA_ALIGN_4K ); - bp->rx.bd_virt = malloc_phys ( RX_RING_BUFFER_SIZE, DMA_ALIGN_4K ); - bp->cq.bd_virt = malloc_phys ( CQ_RING_BUFFER_SIZE, BNXT_DMA_ALIGNMENT ); - bp->nq.bd_virt = malloc_phys ( NQ_RING_BUFFER_SIZE, BNXT_DMA_ALIGNMENT ); + bp->hwrm_addr_req = dma_alloc ( bp->dma, &bp->req_mapping, + REQ_BUFFER_SIZE, REQ_BUFFER_SIZE ); + bp->hwrm_addr_resp = dma_alloc ( bp->dma, &bp->resp_mapping, + RESP_BUFFER_SIZE, RESP_BUFFER_SIZE ); + bp->hwrm_addr_dma = dma_alloc ( bp->dma, &bp->dma_mapped, + DMA_BUFFER_SIZE, DMA_BUFFER_SIZE); + bp->tx.bd_virt = dma_alloc ( bp->dma, &bp->tx_mapping, + TX_RING_BUFFER_SIZE, DMA_ALIGN_4K ); + bp->rx.bd_virt = dma_alloc ( bp->dma, &bp->rx_mapping, + RX_RING_BUFFER_SIZE, DMA_ALIGN_4K ); + bp->cq.bd_virt = dma_alloc ( bp->dma, &bp->cq_mapping, + CQ_RING_BUFFER_SIZE, BNXT_DMA_ALIGNMENT ); + bp->nq.bd_virt = dma_alloc ( bp->dma, &bp->nq_mapping, + NQ_RING_BUFFER_SIZE, BNXT_DMA_ALIGNMENT ); test_if ( bp->hwrm_addr_req && bp->hwrm_addr_resp && bp->hwrm_addr_dma && @@ -690,7 +696,7 @@ static void hwrm_init ( struct bnxt *bp, struct input *req, u16 cmd, u16 len ) req->req_type = cmd; req->cmpl_ring = ( u16 )HWRM_NA_SIGNATURE; req->target_id = ( u16 )HWRM_NA_SIGNATURE; - req->resp_addr = bp->resp_addr_mapping; + req->resp_addr = RESP_DMA_ADDR ( bp ); req->seq_id = bp->seq_id++; } @@ -710,10 +716,10 @@ static void short_hwrm_cmd_req ( struct bnxt *bp, u16 len ) struct hwrm_short_input sreq; memset ( &sreq, 0, sizeof ( struct hwrm_short_input ) ); - sreq.req_type = ( u16 ) ( ( struct input * )bp->hwrm_addr_req )->req_type; + sreq.req_type = ( u16 ) ( ( struct input * ) REQ_DMA_ADDR (bp ) )->req_type; sreq.signature = SHORT_REQ_SIGNATURE_SHORT_CMD; sreq.size = len; - sreq.req_addr = bp->req_addr_mapping; + sreq.req_addr = REQ_DMA_ADDR ( bp ); mdelay ( 100 ); dbg_short_cmd ( ( u8 * )&sreq, __func__, sizeof ( struct hwrm_short_input ) ); @@ -722,8 +728,8 @@ static void short_hwrm_cmd_req ( struct bnxt *bp, u16 len ) static int wait_resp ( struct bnxt *bp, u32 tmo, u16 len, const char *func ) { - struct input *req = ( struct input * )bp->hwrm_addr_req; - struct output *resp = ( struct output * )bp->hwrm_addr_resp; + struct input *req = ( struct input * ) REQ_DMA_ADDR ( bp ); + struct output *resp = ( struct output * ) RESP_DMA_ADDR ( bp ); u8 *ptr = ( u8 * )resp; u32 idx; u32 wait_cnt = HWRM_CMD_DEFAULT_MULTIPLAYER ( ( u32 )tmo ); @@ -758,8 +764,8 @@ static int bnxt_hwrm_ver_get ( struct bnxt *bp ) int rc; DBGP ( "%s\n", __func__ ); - req = ( struct hwrm_ver_get_input * )bp->hwrm_addr_req; - resp = ( struct hwrm_ver_get_output * )bp->hwrm_addr_resp; + req = ( struct hwrm_ver_get_input * ) REQ_DMA_ADDR ( bp ); + resp = ( struct hwrm_ver_get_output * ) RESP_DMA_ADDR ( bp ); hwrm_init ( bp, ( void * )req, ( u16 )HWRM_VER_GET, cmd_len ); req->hwrm_intf_maj = HWRM_VERSION_MAJOR; req->hwrm_intf_min = HWRM_VERSION_MINOR; @@ -809,8 +815,8 @@ static int bnxt_hwrm_func_resource_qcaps ( struct bnxt *bp ) int rc; DBGP ( "%s\n", __func__ ); - req = ( struct hwrm_func_resource_qcaps_input * )bp->hwrm_addr_req; - resp = ( struct hwrm_func_resource_qcaps_output * )bp->hwrm_addr_resp; + req = ( struct hwrm_func_resource_qcaps_input * ) REQ_DMA_ADDR ( bp ); + resp = ( struct hwrm_func_resource_qcaps_output * ) RESP_DMA_ADDR ( bp ); hwrm_init ( bp, ( void * )req, ( u16 )HWRM_FUNC_RESOURCE_QCAPS, cmd_len ); req->fid = ( u16 )HWRM_NA_SIGNATURE; @@ -908,7 +914,7 @@ static void bnxt_hwrm_assign_resources ( struct bnxt *bp ) if ( FLAG_TEST ( bp->flags, BNXT_FLAG_RESOURCE_QCAPS_SUPPORT ) ) enables = bnxt_set_ring_info ( bp ); - req = ( struct hwrm_func_cfg_input * )bp->hwrm_addr_req; + req = ( struct hwrm_func_cfg_input * ) REQ_DMA_ADDR ( bp ); req->num_cmpl_rings = bp->num_cmpl_rings; req->num_tx_rings = bp->num_tx_rings; req->num_rx_rings = bp->num_rx_rings; @@ -928,8 +934,8 @@ static int bnxt_hwrm_func_qcaps_req ( struct bnxt *bp ) if ( bp->vf ) return STATUS_SUCCESS; - req = ( struct hwrm_func_qcaps_input * )bp->hwrm_addr_req; - resp = ( struct hwrm_func_qcaps_output * )bp->hwrm_addr_resp; + req = ( struct hwrm_func_qcaps_input * ) REQ_DMA_ADDR ( bp ); + resp = ( struct hwrm_func_qcaps_output * ) RESP_DMA_ADDR ( bp ); hwrm_init ( bp, ( void * )req, ( u16 )HWRM_FUNC_QCAPS, cmd_len ); req->fid = ( u16 )HWRM_NA_SIGNATURE; rc = wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ ); @@ -955,8 +961,8 @@ static int bnxt_hwrm_func_qcfg_req ( struct bnxt *bp ) int rc; DBGP ( "%s\n", __func__ ); - req = ( struct hwrm_func_qcfg_input * )bp->hwrm_addr_req; - resp = ( struct hwrm_func_qcfg_output * )bp->hwrm_addr_resp; + req = ( struct hwrm_func_qcfg_input * ) REQ_DMA_ADDR ( bp ); + resp = ( struct hwrm_func_qcfg_output * ) RESP_DMA_ADDR ( bp ); hwrm_init ( bp, ( void * )req, ( u16 )HWRM_FUNC_QCFG, cmd_len ); req->fid = ( u16 )HWRM_NA_SIGNATURE; rc = wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ ); @@ -997,8 +1003,8 @@ static int bnxt_hwrm_port_phy_qcaps_req ( struct bnxt *bp ) DBGP ( "%s\n", __func__ ); - req = ( struct hwrm_port_phy_qcaps_input * )bp->hwrm_addr_req; - resp = ( struct hwrm_port_phy_qcaps_output * )bp->hwrm_addr_resp; + req = ( struct hwrm_port_phy_qcaps_input * ) REQ_DMA_ADDR ( bp ); + resp = ( struct hwrm_port_phy_qcaps_output * ) RESP_DMA_ADDR ( bp ); hwrm_init ( bp, ( void * )req, ( u16 )HWRM_PORT_PHY_QCAPS, cmd_len ); rc = wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ ); if ( rc ) { @@ -1018,7 +1024,7 @@ static int bnxt_hwrm_func_reset_req ( struct bnxt *bp ) struct hwrm_func_reset_input *req; DBGP ( "%s\n", __func__ ); - req = ( struct hwrm_func_reset_input * )bp->hwrm_addr_req; + req = ( struct hwrm_func_reset_input * ) REQ_DMA_ADDR ( bp ); hwrm_init ( bp, ( void * )req, ( u16 )HWRM_FUNC_RESET, cmd_len ); if ( !bp->vf ) req->func_reset_level = FUNC_RESET_REQ_FUNC_RESET_LEVEL_RESETME; @@ -1035,7 +1041,7 @@ static int bnxt_hwrm_func_cfg_req ( struct bnxt *bp ) if ( bp->vf ) return STATUS_SUCCESS; - req = ( struct hwrm_func_cfg_input * )bp->hwrm_addr_req; + req = ( struct hwrm_func_cfg_input * ) REQ_DMA_ADDR ( bp ); hwrm_init ( bp, ( void * )req, ( u16 )HWRM_FUNC_CFG, cmd_len ); req->fid = ( u16 )HWRM_NA_SIGNATURE; bnxt_hwrm_assign_resources ( bp ); @@ -1057,7 +1063,7 @@ static int bnxt_hwrm_func_drv_rgtr ( struct bnxt *bp ) int rc; DBGP ( "%s\n", __func__ ); - req = ( struct hwrm_func_drv_rgtr_input * )bp->hwrm_addr_req; + req = ( struct hwrm_func_drv_rgtr_input * ) REQ_DMA_ADDR ( bp ); hwrm_init ( bp, ( void * )req, ( u16 )HWRM_FUNC_DRV_RGTR, cmd_len ); /* Register with HWRM */ @@ -1089,7 +1095,7 @@ static int bnxt_hwrm_func_drv_unrgtr ( struct bnxt *bp ) if ( ! ( FLAG_TEST ( bp->flag_hwrm, VALID_DRIVER_REG ) ) ) return STATUS_SUCCESS; - req = ( struct hwrm_func_drv_unrgtr_input * )bp->hwrm_addr_req; + req = ( struct hwrm_func_drv_unrgtr_input * ) REQ_DMA_ADDR ( bp ); hwrm_init ( bp, ( void * )req, ( u16 )HWRM_FUNC_DRV_UNRGTR, cmd_len ); req->flags = FUNC_DRV_UNRGTR_REQ_FLAGS_PREPARE_FOR_SHUTDOWN; rc = wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ ); @@ -1114,7 +1120,7 @@ static int bnxt_hwrm_set_async_event ( struct bnxt *bp ) u16 cmd_len = ( u16 )sizeof ( struct hwrm_func_vf_cfg_input ); struct hwrm_func_vf_cfg_input *req; - req = ( struct hwrm_func_vf_cfg_input * )bp->hwrm_addr_req; + req = ( struct hwrm_func_vf_cfg_input * ) REQ_DMA_ADDR ( bp ); hwrm_init ( bp, ( void * )req, ( u16 )HWRM_FUNC_VF_CFG, cmd_len ); req->enables = VF_CFG_ENABLE_FLAGS; @@ -1128,7 +1134,7 @@ static int bnxt_hwrm_set_async_event ( struct bnxt *bp ) u16 cmd_len = ( u16 )sizeof ( struct hwrm_func_cfg_input ); struct hwrm_func_cfg_input *req; - req = ( struct hwrm_func_cfg_input * )bp->hwrm_addr_req; + req = ( struct hwrm_func_cfg_input * ) REQ_DMA_ADDR ( bp ); hwrm_init ( bp, ( void * )req, ( u16 )HWRM_FUNC_CFG, cmd_len ); req->fid = ( u16 )HWRM_NA_SIGNATURE; req->enables = FUNC_CFG_REQ_ENABLES_ASYNC_EVENT_CR; @@ -1148,8 +1154,8 @@ static int bnxt_hwrm_cfa_l2_filter_alloc ( struct bnxt *bp ) u32 enables; DBGP ( "%s\n", __func__ ); - req = ( struct hwrm_cfa_l2_filter_alloc_input * )bp->hwrm_addr_req; - resp = ( struct hwrm_cfa_l2_filter_alloc_output * )bp->hwrm_addr_resp; + req = ( struct hwrm_cfa_l2_filter_alloc_input * ) REQ_DMA_ADDR ( bp ); + resp = ( struct hwrm_cfa_l2_filter_alloc_output * ) RESP_DMA_ADDR ( bp ); if ( bp->vf ) flags |= CFA_L2_FILTER_ALLOC_REQ_FLAGS_OUTERMOST; enables = CFA_L2_FILTER_ALLOC_REQ_ENABLES_DST_ID | @@ -1189,7 +1195,7 @@ static int bnxt_hwrm_cfa_l2_filter_free ( struct bnxt *bp ) if ( ! ( FLAG_TEST ( bp->flag_hwrm, VALID_L2_FILTER ) ) ) return STATUS_SUCCESS; - req = ( struct hwrm_cfa_l2_filter_free_input * )bp->hwrm_addr_req; + req = ( struct hwrm_cfa_l2_filter_free_input * ) REQ_DMA_ADDR ( bp ); hwrm_init ( bp, ( void * )req, ( u16 )HWRM_CFA_L2_FILTER_FREE, cmd_len ); req->l2_filter_id = bp->l2_filter_id; @@ -1228,7 +1234,7 @@ static int bnxt_hwrm_set_rx_mask ( struct bnxt *bp, u32 rx_mask ) struct hwrm_cfa_l2_set_rx_mask_input *req; u32 mask = set_rx_mask ( rx_mask ); - req = ( struct hwrm_cfa_l2_set_rx_mask_input * )bp->hwrm_addr_req; + req = ( struct hwrm_cfa_l2_set_rx_mask_input * ) REQ_DMA_ADDR ( bp ); hwrm_init ( bp, ( void * )req, ( u16 )HWRM_CFA_L2_SET_RX_MASK, cmd_len ); req->vnic_id = bp->vnic_id; @@ -1245,8 +1251,8 @@ static int bnxt_hwrm_port_phy_qcfg ( struct bnxt *bp, u16 idx ) int rc; DBGP ( "%s\n", __func__ ); - req = ( struct hwrm_port_phy_qcfg_input * )bp->hwrm_addr_req; - resp = ( struct hwrm_port_phy_qcfg_output * )bp->hwrm_addr_resp; + req = ( struct hwrm_port_phy_qcfg_input * ) REQ_DMA_ADDR ( bp ); + resp = ( struct hwrm_port_phy_qcfg_output * ) RESP_DMA_ADDR ( bp ); hwrm_init ( bp, ( void * )req, ( u16 )HWRM_PORT_PHY_QCFG, cmd_len ); rc = wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ ); if ( rc ) { @@ -1283,9 +1289,9 @@ static int bnxt_hwrm_nvm_get_variable_req ( struct bnxt *bp, struct hwrm_nvm_get_variable_input *req; DBGP ( "%s\n", __func__ ); - req = ( struct hwrm_nvm_get_variable_input * )bp->hwrm_addr_req; + req = ( struct hwrm_nvm_get_variable_input * ) REQ_DMA_ADDR ( bp ); hwrm_init ( bp, ( void * )req, ( u16 )HWRM_NVM_GET_VARIABLE, cmd_len ); - req->dest_data_addr = bp->dma_addr_mapping; + req->dest_data_addr = DMA_DMA_ADDR ( bp ); req->data_len = data_len; req->option_num = option_num; req->dimensions = dimensions; @@ -1297,7 +1303,7 @@ static int bnxt_hwrm_nvm_get_variable_req ( struct bnxt *bp, static int bnxt_get_link_speed ( struct bnxt *bp ) { - u32 *ptr32 = ( u32 * )bp->hwrm_addr_dma; + u32 *ptr32 = ( u32 * ) DMA_DMA_ADDR ( bp ); DBGP ( "%s\n", __func__ ); if ( ! ( FLAG_TEST (bp->flags, BNXT_FLAG_IS_CHIP_P7 ) ) ) { @@ -1382,7 +1388,7 @@ static int bnxt_get_link_speed ( struct bnxt *bp ) static int bnxt_get_vlan ( struct bnxt *bp ) { - u32 *ptr32 = ( u32 * )bp->hwrm_addr_dma; + u32 *ptr32 = ( u32 * ) DMA_DMA_ADDR ( bp ); /* If VF is set to TRUE, Do not issue this command */ if ( bp->vf ) @@ -1423,7 +1429,7 @@ static int bnxt_hwrm_backing_store_qcfg ( struct bnxt *bp ) if ( ! ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P5_PLUS ) ) ) return STATUS_SUCCESS; - req = ( struct hwrm_func_backing_store_qcfg_input * )bp->hwrm_addr_req; + req = ( struct hwrm_func_backing_store_qcfg_input * ) REQ_DMA_ADDR ( bp ); hwrm_init ( bp, ( void * )req, ( u16 )HWRM_FUNC_BACKING_STORE_QCFG, cmd_len ); return wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ ); @@ -1438,7 +1444,7 @@ static int bnxt_hwrm_backing_store_cfg ( struct bnxt *bp ) if ( ! ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P5_PLUS ) ) ) return STATUS_SUCCESS; - req = ( struct hwrm_func_backing_store_cfg_input * )bp->hwrm_addr_req; + req = ( struct hwrm_func_backing_store_cfg_input * ) REQ_DMA_ADDR ( bp ); hwrm_init ( bp, ( void * )req, ( u16 )HWRM_FUNC_BACKING_STORE_CFG, cmd_len ); req->flags = FUNC_BACKING_STORE_CFG_REQ_FLAGS_PREBOOT_MODE; @@ -1457,8 +1463,8 @@ static int bnxt_hwrm_queue_qportcfg ( struct bnxt *bp ) if ( ! ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P5_PLUS ) ) ) return STATUS_SUCCESS; - req = ( struct hwrm_queue_qportcfg_input * )bp->hwrm_addr_req; - resp = ( struct hwrm_queue_qportcfg_output * )bp->hwrm_addr_resp; + req = ( struct hwrm_queue_qportcfg_input * ) REQ_DMA_ADDR ( bp ); + resp = ( struct hwrm_queue_qportcfg_output * ) RESP_DMA_ADDR ( bp ); hwrm_init ( bp, ( void * )req, ( u16 )HWRM_QUEUE_QPORTCFG, cmd_len ); req->flags = 0; req->port_id = 0; @@ -1481,7 +1487,7 @@ static int bnxt_hwrm_port_mac_cfg ( struct bnxt *bp ) if ( bp->vf ) return STATUS_SUCCESS; - req = ( struct hwrm_port_mac_cfg_input * )bp->hwrm_addr_req; + req = ( struct hwrm_port_mac_cfg_input * ) REQ_DMA_ADDR ( bp ); hwrm_init ( bp, ( void * )req, ( u16 )HWRM_PORT_MAC_CFG, cmd_len ); req->lpbk = PORT_MAC_CFG_REQ_LPBK_NONE; return wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ ); @@ -1503,7 +1509,7 @@ static int bnxt_hwrm_port_phy_cfg ( struct bnxt *bp ) u8 auto_duplex = 0; DBGP ( "%s\n", __func__ ); - req = ( struct hwrm_port_phy_cfg_input * )bp->hwrm_addr_req; + req = ( struct hwrm_port_phy_cfg_input * ) REQ_DMA_ADDR ( bp ); flags = PORT_PHY_CFG_REQ_FLAGS_FORCE | PORT_PHY_CFG_REQ_FLAGS_RESET_PHY; @@ -1702,8 +1708,8 @@ static int bnxt_hwrm_stat_ctx_alloc ( struct bnxt *bp ) int rc; DBGP ( "%s\n", __func__ ); - req = ( struct hwrm_stat_ctx_alloc_input * )bp->hwrm_addr_req; - resp = ( struct hwrm_stat_ctx_alloc_output * )bp->hwrm_addr_resp; + req = ( struct hwrm_stat_ctx_alloc_input * ) REQ_DMA_ADDR ( bp ); + resp = ( struct hwrm_stat_ctx_alloc_output * ) RESP_DMA_ADDR ( bp ); hwrm_init ( bp, ( void * )req, ( u16 )HWRM_STAT_CTX_ALLOC, cmd_len ); rc = wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ ); if ( rc ) { @@ -1726,7 +1732,7 @@ static int bnxt_hwrm_stat_ctx_free ( struct bnxt *bp ) if ( ! ( FLAG_TEST ( bp->flag_hwrm, VALID_STAT_CTX ) ) ) return STATUS_SUCCESS; - req = ( struct hwrm_stat_ctx_free_input * )bp->hwrm_addr_req; + req = ( struct hwrm_stat_ctx_free_input * ) REQ_DMA_ADDR ( bp ); hwrm_init ( bp, ( void * )req, ( u16 )HWRM_STAT_CTX_FREE, cmd_len ); req->stat_ctx_id = ( u32 )bp->stat_ctx_id; rc = wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ ); @@ -1749,7 +1755,7 @@ static int bnxt_hwrm_ring_free_grp ( struct bnxt *bp ) if ( ! ( FLAG_TEST ( bp->flag_hwrm, VALID_RING_GRP ) ) ) return STATUS_SUCCESS; - req = ( struct hwrm_ring_grp_free_input * )bp->hwrm_addr_req; + req = ( struct hwrm_ring_grp_free_input * ) REQ_DMA_ADDR ( bp ); hwrm_init ( bp, ( void * )req, ( u16 )HWRM_RING_GRP_FREE, cmd_len ); req->ring_group_id = ( u32 )bp->ring_grp_id; rc = wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ ); @@ -1773,8 +1779,8 @@ static int bnxt_hwrm_ring_alloc_grp ( struct bnxt *bp ) if ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P5_PLUS ) ) return STATUS_SUCCESS; - req = ( struct hwrm_ring_grp_alloc_input * )bp->hwrm_addr_req; - resp = ( struct hwrm_ring_grp_alloc_output * )bp->hwrm_addr_resp; + req = ( struct hwrm_ring_grp_alloc_input * ) REQ_DMA_ADDR ( bp ); + resp = ( struct hwrm_ring_grp_alloc_output * ) RESP_DMA_ADDR ( bp ); hwrm_init ( bp, ( void * )req, ( u16 )HWRM_RING_GRP_ALLOC, cmd_len ); req->cr = bp->cq_ring_id; req->rr = bp->rx_ring_id; @@ -1799,7 +1805,7 @@ int bnxt_hwrm_ring_free ( struct bnxt *bp, u16 ring_id, u8 ring_type ) struct hwrm_ring_free_input *req; DBGP ( "%s\n", __func__ ); - req = ( struct hwrm_ring_free_input * )bp->hwrm_addr_req; + req = ( struct hwrm_ring_free_input * ) REQ_DMA_ADDR ( bp ); hwrm_init ( bp, ( void * )req, ( u16 )HWRM_RING_FREE, cmd_len ); req->ring_type = ring_type; req->ring_id = ring_id; @@ -1814,8 +1820,8 @@ static int bnxt_hwrm_ring_alloc ( struct bnxt *bp, u8 type ) int rc; DBGP ( "%s\n", __func__ ); - req = ( struct hwrm_ring_alloc_input * )bp->hwrm_addr_req; - resp = ( struct hwrm_ring_alloc_output * )bp->hwrm_addr_resp; + req = ( struct hwrm_ring_alloc_input * ) REQ_DMA_ADDR ( bp ); + resp = ( struct hwrm_ring_alloc_output * ) RESP_DMA_ADDR ( bp ); hwrm_init ( bp, ( void * )req, ( u16 )HWRM_RING_ALLOC, cmd_len ); req->ring_type = type; switch ( type ) { @@ -1824,13 +1830,13 @@ static int bnxt_hwrm_ring_alloc ( struct bnxt *bp, u8 type ) req->int_mode = BNXT_CQ_INTR_MODE ( ( (FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P7) ) || bp->vf ) ); req->length = ( u32 )bp->nq.ring_cnt; req->logical_id = 0xFFFF; // Required value for Thor FW? - req->page_tbl_addr = virt_to_bus ( bp->nq.bd_virt ); + req->page_tbl_addr = NQ_DMA_ADDR ( bp ); break; case RING_ALLOC_REQ_RING_TYPE_L2_CMPL: req->page_size = LM_PAGE_BITS ( 8 ); req->int_mode = BNXT_CQ_INTR_MODE ( bp->vf ); req->length = ( u32 )bp->cq.ring_cnt; - req->page_tbl_addr = virt_to_bus ( bp->cq.bd_virt ); + req->page_tbl_addr = CQ_DMA_ADDR ( bp ); if ( ! ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P5_PLUS ) ) ) break; req->enables = RING_ALLOC_REQ_ENABLES_NQ_RING_ID_VALID; @@ -1844,7 +1850,7 @@ static int bnxt_hwrm_ring_alloc ( struct bnxt *bp, u8 type ) req->queue_id = ( u16 )bp->queue_id; req->stat_ctx_id = ( u32 )bp->stat_ctx_id; req->cmpl_ring_id = bp->cq_ring_id; - req->page_tbl_addr = virt_to_bus ( bp->tx.bd_virt ); + req->page_tbl_addr = TX_DMA_ADDR ( bp ); break; case RING_ALLOC_REQ_RING_TYPE_RX: req->page_size = LM_PAGE_BITS ( 8 ); @@ -1852,7 +1858,7 @@ static int bnxt_hwrm_ring_alloc ( struct bnxt *bp, u8 type ) req->length = ( u32 )bp->rx.ring_cnt; req->stat_ctx_id = ( u32 )STAT_CTX_ID; req->cmpl_ring_id = bp->cq_ring_id; - req->page_tbl_addr = virt_to_bus ( bp->rx.bd_virt ); + req->page_tbl_addr = RX_DMA_ADDR ( bp ); if ( ! ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P5_PLUS ) ) ) break; req->queue_id = ( u16 )RX_RING_QID; @@ -1980,8 +1986,8 @@ static int bnxt_hwrm_vnic_alloc ( struct bnxt *bp ) int rc; DBGP ( "%s\n", __func__ ); - req = ( struct hwrm_vnic_alloc_input * )bp->hwrm_addr_req; - resp = ( struct hwrm_vnic_alloc_output * )bp->hwrm_addr_resp; + req = ( struct hwrm_vnic_alloc_input * ) REQ_DMA_ADDR ( bp ); + resp = ( struct hwrm_vnic_alloc_output * ) RESP_DMA_ADDR ( bp ); hwrm_init ( bp, ( void * )req, ( u16 )HWRM_VNIC_ALLOC, cmd_len ); req->flags = VNIC_ALLOC_REQ_FLAGS_DEFAULT; rc = wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ ); @@ -2005,7 +2011,7 @@ static int bnxt_hwrm_vnic_free ( struct bnxt *bp ) if ( ! ( FLAG_TEST ( bp->flag_hwrm, VALID_VNIC_ID ) ) ) return STATUS_SUCCESS; - req = ( struct hwrm_vnic_free_input * )bp->hwrm_addr_req; + req = ( struct hwrm_vnic_free_input * ) REQ_DMA_ADDR ( bp ); hwrm_init ( bp, ( void * )req, ( u16 )HWRM_VNIC_FREE, cmd_len ); req->vnic_id = bp->vnic_id; rc = wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ ); @@ -2024,7 +2030,7 @@ static int bnxt_hwrm_vnic_cfg ( struct bnxt *bp ) struct hwrm_vnic_cfg_input *req; DBGP ( "%s\n", __func__ ); - req = ( struct hwrm_vnic_cfg_input * )bp->hwrm_addr_req; + req = ( struct hwrm_vnic_cfg_input * ) REQ_DMA_ADDR ( bp ); hwrm_init ( bp, ( void * )req, ( u16 )HWRM_VNIC_CFG, cmd_len ); req->enables = VNIC_CFG_REQ_ENABLES_MRU; req->mru = bp->mtu; @@ -2117,8 +2123,8 @@ int bnxt_hwrm_run ( hwrm_func_t cmds[], struct bnxt *bp ) int ret; for ( ptr = cmds; *ptr; ++ptr ) { - memset ( bp->hwrm_addr_req, 0, REQ_BUFFER_SIZE ); - memset ( bp->hwrm_addr_resp, 0, RESP_BUFFER_SIZE ); + memset ( ( void * ) REQ_DMA_ADDR ( bp ), 0, REQ_BUFFER_SIZE ); + memset ( ( void * ) RESP_DMA_ADDR ( bp ), 0, RESP_BUFFER_SIZE ); ret = ( *ptr ) ( bp ); if ( ret ) { DBGP ( "- %s ( ): Failed\n", __func__ ); @@ -2162,16 +2168,16 @@ static int bnxt_tx ( struct net_device *dev, struct io_buffer *iob ) { struct bnxt *bp = dev->priv; u16 len, entry; - dma_addr_t mapping; + physaddr_t mapping; if ( bnxt_tx_avail ( bp ) < 1 ) { DBGP ( "- %s ( ): Failed no bd's available\n", __func__ ); return -ENOBUFS; } + mapping = iob_dma ( iob ); bnxt_tx_adjust_pkt ( bp, iob ); entry = bp->tx.prod_id; - mapping = virt_to_bus ( iob->data ); len = iob_len ( iob ); bp->tx.iob[entry] = iob; bnxt_set_txq ( bp, entry, mapping, len ); @@ -2229,7 +2235,7 @@ static void bnxt_service_cq ( struct net_device *dev ) u32 cq_type; while ( done == SERVICE_NEXT_CQ_BD ) { - cmp = ( struct cmpl_base * )BD_NOW ( bp->cq.bd_virt, + cmp = ( struct cmpl_base * )BD_NOW ( CQ_DMA_ADDR ( bp ), bp->cq.cons_id, sizeof ( struct cmpl_base ) ); @@ -2280,8 +2286,9 @@ static void bnxt_service_nq ( struct net_device *dev ) return; while ( done == SERVICE_NEXT_NQ_BD ) { - nqp = ( struct nq_base * )BD_NOW ( bp->nq.bd_virt, - bp->nq.cons_id, sizeof ( struct nq_base ) ); + nqp = ( struct nq_base * )BD_NOW ( NQ_DMA_ADDR ( bp ), + bp->nq.cons_id, + sizeof ( struct nq_base ) ); if ( ( nqp->v & NQ_CN_V ) ^ bp->nq.completion_bit ) break; nq_type = ( nqp->type & NQ_CN_TYPE_MASK ); @@ -2368,6 +2375,10 @@ static int bnxt_init_one ( struct pci_device *pci ) bp->dev = netdev; netdev->dev = &pci->dev; + /* Configure DMA */ + bp->dma = &pci->dma; + netdev->dma = bp->dma; + /* Enable PCI device */ adjust_pci_device ( pci ); diff --git a/src/drivers/net/bnxt/bnxt.h b/src/drivers/net/bnxt/bnxt.h index 782881964..1d5fc8df1 100644 --- a/src/drivers/net/bnxt/bnxt.h +++ b/src/drivers/net/bnxt/bnxt.h @@ -25,13 +25,6 @@ #define __be32 u32 #define __be64 u64 -#define dma_addr_t unsigned long - -union dma_addr64_t { - dma_addr_t addr; - u64 as_u64; -}; - #include "bnxt_hsi.h" #define DRV_MODULE_NAME "bnxt" @@ -182,6 +175,13 @@ union dma_addr64_t { #define STAT_CTX_ID ((bp->vf || FLAG_TEST(bp->flags, BNXT_FLAG_IS_CHIP_P5_PLUS)) ? bp->stat_ctx_id : 0) #define TX_AVAIL(r) (r - 1) #define TX_IN_USE(a, b, c) ((a - b) & (c - 1)) +#define NQ_DMA_ADDR(bp) ( dma ( &bp->nq_mapping, bp->nq.bd_virt ) ) +#define CQ_DMA_ADDR(bp) ( dma ( &bp->cq_mapping, bp->cq.bd_virt ) ) +#define TX_DMA_ADDR(bp) ( dma ( &bp->tx_mapping, bp->tx.bd_virt ) ) +#define RX_DMA_ADDR(bp) ( dma ( &bp->rx_mapping, bp->rx.bd_virt ) ) +#define REQ_DMA_ADDR(bp) ( dma ( &bp->req_mapping, bp->hwrm_addr_req ) ) +#define RESP_DMA_ADDR(bp) ( dma ( &bp->resp_mapping, bp->hwrm_addr_resp ) ) +#define DMA_DMA_ADDR(bp) ( dma ( &bp->dma_mapped, bp->hwrm_addr_dma ) ) #define NO_MORE_NQ_BD_TO_SERVICE 1 #define SERVICE_NEXT_NQ_BD 0 #define NO_MORE_CQ_BD_TO_SERVICE 1 @@ -472,7 +472,7 @@ struct tx_bd_short { #define TX_BD_SHORT_FLAGS_COAL_NOW 0x8000UL u16 len; u32 opaque; - union dma_addr64_t dma; + physaddr_t dma; }; struct tx_cmpl { @@ -879,7 +879,7 @@ struct rx_prod_pkt_bd { #define RX_PROD_PKT_BD_FLAGS_BUFFERS_SFT 8 u16 len; u32 opaque; - union dma_addr64_t dma; + physaddr_t dma; }; struct rx_info { @@ -933,9 +933,15 @@ struct bnxt { void *hwrm_addr_req; void *hwrm_addr_resp; void *hwrm_addr_dma; - dma_addr_t req_addr_mapping; - dma_addr_t resp_addr_mapping; - dma_addr_t dma_addr_mapping; + struct dma_device *dma; + struct dma_mapping req_mapping; + struct dma_mapping resp_mapping; + struct dma_mapping dma_mapped; + struct dma_mapping tx_mapping; + struct dma_mapping rx_mapping; + struct dma_mapping cq_mapping; + struct dma_mapping nq_mapping; + struct tx_info tx; /* Tx info. */ struct rx_info rx; /* Rx info. */ struct cmp_info cq; /* completion info. */ -- cgit v1.2.3-55-g7522 From bb2011241fcf15de4edd962fe9656e513ad19174 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 30 May 2025 16:39:10 +0100 Subject: [dt] Locate parent node at point of use in dt_ioremap() We currently rely on the recursive nature of devicetree bus probing to obtain the region cell size specification from the parent device. This blocks the possibility of creating a standalone console device based on /chosen/stdout-path before probing the whole bus. Fix by using fdt_parent() to locate the parent device at the point of use within dt_ioremap(). Signed-off-by: Michael Brown --- src/drivers/bus/devtree.c | 24 +++++++++++++++--------- src/include/ipxe/devtree.h | 3 --- 2 files changed, 15 insertions(+), 12 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/bus/devtree.c b/src/drivers/bus/devtree.c index 55f68ee33..796fe56a0 100644 --- a/src/drivers/bus/devtree.c +++ b/src/drivers/bus/devtree.c @@ -54,16 +54,25 @@ static void dt_remove_children ( struct dt_device *parent ); */ void * dt_ioremap ( struct dt_device *dt, unsigned int offset, unsigned int index, size_t len ) { - struct dt_device *parent = - container_of ( dt->dev.parent, struct dt_device, dev ); - struct fdt_reg_cells *regs = &parent->regs; + struct fdt_reg_cells regs; + unsigned int parent; uint64_t address; uint64_t size; void *io_addr; int rc; + /* Get parent node */ + if ( ( rc = fdt_parent ( &sysfdt, offset, &parent ) ) != 0 ) { + DBGC ( dt, "DT %s could not locate parent: %s\n", + dt->path, strerror ( rc ) ); + return NULL; + } + + /* Read #address-cells and #size-cells, if present */ + fdt_reg_cells ( &sysfdt, parent, ®s ); + /* Read address */ - if ( ( rc = fdt_reg_address ( &sysfdt, offset, regs, index, + if ( ( rc = fdt_reg_address ( &sysfdt, offset, ®s, index, &address ) ) != 0 ) { DBGC ( dt, "DT %s could not read region %d address: %s\n", dt->path, index, strerror ( rc ) ); @@ -72,8 +81,8 @@ void * dt_ioremap ( struct dt_device *dt, unsigned int offset, /* Read size (or assume sufficient, if tree specifies no sizes) */ size = len; - if ( regs->size_cells && - ( ( rc = fdt_reg_size ( &sysfdt, offset, regs, index, + if ( regs.size_cells && + ( ( rc = fdt_reg_size ( &sysfdt, offset, ®s, index, &size ) ) != 0 ) ) { DBGC ( dt, "DT %s could not read region %d size: %s\n", dt->path, index, strerror ( rc ) ); @@ -222,9 +231,6 @@ static int dt_probe_node ( struct dt_device *parent, unsigned int offset, INIT_LIST_HEAD ( &dt->dev.children ); list_add_tail ( &dt->dev.siblings, &dt->dev.parent->children ); - /* Read #address-cells and #size-cells, if present */ - fdt_reg_cells ( &sysfdt, offset, &dt->regs ); - /* Probe device */ if ( ( rc = dt_probe ( dt, offset ) ) != 0 ) goto err_probe; diff --git a/src/include/ipxe/devtree.h b/src/include/ipxe/devtree.h index 6e9286af4..46d8b5d86 100644 --- a/src/include/ipxe/devtree.h +++ b/src/include/ipxe/devtree.h @@ -25,9 +25,6 @@ struct dt_device { struct dt_driver *driver; /** Driver-private data */ void *priv; - - /** Register cell size specification */ - struct fdt_reg_cells regs; }; /** A devicetree driver */ -- cgit v1.2.3-55-g7522 From c4a3d438e642e8692e6a94e7d4db75d75744e73f Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 11 Jun 2025 12:51:56 +0100 Subject: [dt] Allow for creation of standalone devices We will want to be able to create the console device as early as possible. Refactor devicetree probing to remove the assumption that a devicetree device must have a devicetree parent, and expose functions to allow a standalone device to be created given only the offset of a node within the tree. The full device path is no longer trivial to construct with this assumption removed. The full path is currently used only for debug messages. Remove the stored full path, use just the node name for debug messages, and ensure that the topology information previously visible in the full path is reconstructible from the combined debug output if needed. Signed-off-by: Michael Brown --- src/drivers/bus/devtree.c | 111 +++++++++++++++++++++------------------------ src/include/ipxe/devtree.h | 6 ++- 2 files changed, 56 insertions(+), 61 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/bus/devtree.c b/src/drivers/bus/devtree.c index 796fe56a0..59bbc9bf7 100644 --- a/src/drivers/bus/devtree.c +++ b/src/drivers/bus/devtree.c @@ -39,7 +39,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include static struct dt_driver dt_node_driver __dt_driver; -struct root_device dt_root_device __root_device; static void dt_remove_children ( struct dt_device *parent ); @@ -64,7 +63,7 @@ void * dt_ioremap ( struct dt_device *dt, unsigned int offset, /* Get parent node */ if ( ( rc = fdt_parent ( &sysfdt, offset, &parent ) ) != 0 ) { DBGC ( dt, "DT %s could not locate parent: %s\n", - dt->path, strerror ( rc ) ); + dt->name, strerror ( rc ) ); return NULL; } @@ -75,7 +74,7 @@ void * dt_ioremap ( struct dt_device *dt, unsigned int offset, if ( ( rc = fdt_reg_address ( &sysfdt, offset, ®s, index, &address ) ) != 0 ) { DBGC ( dt, "DT %s could not read region %d address: %s\n", - dt->path, index, strerror ( rc ) ); + dt->name, index, strerror ( rc ) ); return NULL; } @@ -85,7 +84,7 @@ void * dt_ioremap ( struct dt_device *dt, unsigned int offset, ( ( rc = fdt_reg_size ( &sysfdt, offset, ®s, index, &size ) ) != 0 ) ) { DBGC ( dt, "DT %s could not read region %d size: %s\n", - dt->path, index, strerror ( rc ) ); + dt->name, index, strerror ( rc ) ); return NULL; } @@ -93,13 +92,13 @@ void * dt_ioremap ( struct dt_device *dt, unsigned int offset, if ( ! len ) len = size; DBGC ( dt, "DT %s region %d at %#08llx+%#04llx\n", - dt->path, index, ( ( unsigned long long ) address ), + dt->name, index, ( ( unsigned long long ) address ), ( ( unsigned long long ) size ) ); /* Verify size */ if ( len > size ) { DBGC ( dt, "DT %s region %d is too small (%#llx/%#zx bytes)\n", - dt->path, index, ( ( unsigned long long ) size ), len ); + dt->name, index, ( ( unsigned long long ) size ), len ); return NULL; } @@ -107,7 +106,7 @@ void * dt_ioremap ( struct dt_device *dt, unsigned int offset, io_addr = ioremap ( address, len ); if ( ! io_addr ) { DBGC ( dt, "DT %s could not map region %d\n", - dt->path, index ); + dt->name, index ); return NULL; } @@ -119,7 +118,7 @@ void * dt_ioremap ( struct dt_device *dt, unsigned int offset, * * @v dt Devicetree device * @v offset Starting node offset - * @ret driver Driver, or NULL + * @ret driver Driver */ static struct dt_driver * dt_find_driver ( struct dt_device *dt, unsigned int offset ) { @@ -135,19 +134,20 @@ static struct dt_driver * dt_find_driver ( struct dt_device *dt, /* Look for a compatible driver */ for ( id = ids ; count-- ; id += ( strlen ( id ) + 1 ) ) { DBGC2 ( &sysfdt, "DT %s is compatible with %s\n", - dt->path, id ); + dt->name, id ); for_each_table_entry ( driver, DT_DRIVERS ) { for ( i = 0 ; i < driver->id_count ; i++ ) { if ( strcmp ( id, driver->ids[i] ) == 0 ) { DBGC ( dt, "DT %s has %s driver %s\n", - dt->path, id, driver->name ); + dt->name, id, driver->name ); return driver; } } } } - return NULL; + /* Use generic node driver if no other driver matches */ + return &dt_node_driver; } /** @@ -158,19 +158,11 @@ static struct dt_driver * dt_find_driver ( struct dt_device *dt, * @ret rc Return status code */ static int dt_probe ( struct dt_device *dt, unsigned int offset ) { - struct dt_driver *driver = NULL; + struct dt_driver *driver; int rc; - /* Identify driver. Use the generic node driver if no other - * driver matches, or if this is the root device (which has no - * valid devicetree parent). - */ - if ( offset > 0 ) - driver = dt_find_driver ( dt, offset ); - if ( ! driver ) - driver = &dt_node_driver; - - /* Record driver */ + /* Identify driver */ + driver = dt_find_driver ( dt, offset ); dt->driver = driver; dt->dev.driver_name = driver->name; @@ -178,7 +170,7 @@ static int dt_probe ( struct dt_device *dt, unsigned int offset ) { if ( ( rc = driver->probe ( dt, offset ) ) != 0 ) { if ( driver != &dt_node_driver ) { DBGC ( dt, "DT %s could not probe: %s\n", - dt->path, strerror ( rc ) ); + dt->name, strerror ( rc ) ); } return rc; } @@ -192,44 +184,44 @@ static int dt_probe ( struct dt_device *dt, unsigned int offset ) { * @v dt Devicetree device */ static void dt_remove ( struct dt_device *dt ) { + struct dt_driver *driver = dt->driver; /* Remove device */ - dt->driver->remove ( dt ); + driver->remove ( dt ); + if ( driver != &dt_node_driver ) + DBGC ( dt, "DT %s removed\n", dt->name ); } /** * Probe devicetree node * - * @v parent Parent device, or NULL for root of tree + * @v parent Parent generic device * @v offset Starting node offset - * @v name Node name * @ret rc Return status code */ -static int dt_probe_node ( struct dt_device *parent, unsigned int offset, - const char *name ) { +int dt_probe_node ( struct device *parent, unsigned int offset ) { + struct fdt_descriptor desc; struct dt_device *dt; - const char *ppath; - size_t path_len; - void *path; + const char *name; int rc; + /* Describe token */ + if ( ( rc = fdt_describe ( &sysfdt, offset, &desc ) ) != 0 ) + goto err_describe; + /* Allocate and initialise device */ - ppath = ( ( parent && parent->path[1] ) ? parent->path : "" ); - path_len = ( strlen ( ppath ) + 1 /* "/" */ + - strlen ( name ) + 1 /* NUL */ ); - dt = zalloc ( sizeof ( *dt ) + path_len ); + dt = zalloc ( sizeof ( *dt ) ); if ( ! dt ) { rc = -ENOMEM; goto err_alloc; } - path = ( ( ( void * ) dt ) + sizeof ( *dt ) ); - sprintf ( path, "%s/%s", ppath, name ); - dt->path = path; + name = ( offset ? desc.name : "root node" ); + dt->name = dt->dev.name; snprintf ( dt->dev.name, sizeof ( dt->dev.name ), "%s", name ); dt->dev.desc.bus_type = BUS_TYPE_DT; - dt->dev.parent = ( parent ? &parent->dev : &dt_root_device.dev ); + dt->dev.parent = parent; INIT_LIST_HEAD ( &dt->dev.children ); - list_add_tail ( &dt->dev.siblings, &dt->dev.parent->children ); + list_add_tail ( &dt->dev.siblings, &parent->children ); /* Probe device */ if ( ( rc = dt_probe ( dt, offset ) ) != 0 ) @@ -242,15 +234,22 @@ static int dt_probe_node ( struct dt_device *parent, unsigned int offset, list_del ( &dt->dev.siblings ); free ( dt ); err_alloc: + err_describe: return rc; } /** * Remove devicetree node * - * @v dt Devicetree device + * @v parent Parent generic device */ -static void dt_remove_node ( struct dt_device *dt ) { +void dt_remove_node ( struct device *parent ) { + struct dt_device *dt; + + /* Identify most recently added child */ + dt = list_last_entry ( &parent->children, struct dt_device, + dev.siblings ); + assert ( dt != NULL ); /* Remove driver */ dt_remove ( dt ); @@ -279,7 +278,7 @@ static int dt_probe_children ( struct dt_device *parent, /* Describe token */ if ( ( rc = fdt_describe ( &sysfdt, offset, &desc ) ) != 0 ) { DBGC ( &sysfdt, "DT %s has malformed node: %s\n", - parent->path, strerror ( rc ) ); + parent->name, strerror ( rc ) ); goto err_describe; } @@ -288,8 +287,11 @@ static int dt_probe_children ( struct dt_device *parent, break; /* Probe child node, if applicable */ - if ( ( depth == 0 ) && desc.name && ( ! desc.data ) ) - dt_probe_node ( parent, desc.offset, desc.name ); + if ( ( depth == 0 ) && desc.name && ( ! desc.data ) ) { + DBGC2 ( &sysfdt, "DT %s is child of %s\n", + desc.name, parent->name ); + dt_probe_node ( &parent->dev, desc.offset ); + } } /* Fail if we have no children (so that this device will be freed) */ @@ -312,15 +314,10 @@ static int dt_probe_children ( struct dt_device *parent, * @v parent Parent device */ static void dt_remove_children ( struct dt_device *parent ) { - struct dt_device *dt; - struct dt_device *tmp; /* Remove all child nodes */ - list_for_each_entry_safe ( dt, tmp, &parent->dev.children, - dev.siblings ) { - dt_remove_node ( dt ); - } - assert ( list_empty ( &parent->dev.children ) ); + while ( ! list_empty ( &parent->dev.children ) ) + dt_remove_node ( &parent->dev ); } /** Generic node driver */ @@ -336,10 +333,10 @@ static struct dt_driver dt_node_driver __dt_driver = { * @v rootdev Devicetree root device * @ret rc Return status code */ -static int dt_probe_all ( struct root_device *rootdev __unused ) { +static int dt_probe_all ( struct root_device *rootdev ) { /* Probe root node */ - return dt_probe_node ( NULL, 0, "" ); + return dt_probe_node ( &rootdev->dev, 0 ); } /** @@ -348,13 +345,9 @@ static int dt_probe_all ( struct root_device *rootdev __unused ) { * @v rootdev Devicetree root device */ static void dt_remove_all ( struct root_device *rootdev ) { - struct dt_device *dt; /* Remove root node */ - dt = list_first_entry ( &rootdev->dev.children, struct dt_device, - dev.siblings ); - assert ( dt != NULL ); - dt_remove_node ( dt ); + dt_remove_node ( &rootdev->dev ); } /** Devicetree bus root device driver */ diff --git a/src/include/ipxe/devtree.h b/src/include/ipxe/devtree.h index 46d8b5d86..cdf173938 100644 --- a/src/include/ipxe/devtree.h +++ b/src/include/ipxe/devtree.h @@ -15,12 +15,12 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /** A devicetree device */ struct dt_device { + /** Device name */ + const char *name; /** Generic device */ struct device dev; /** DMA device */ struct dma_device dma; - /** Device path */ - const char *path; /** Driver for this device */ struct dt_driver *driver; /** Driver-private data */ @@ -79,5 +79,7 @@ static inline void * dt_get_drvdata ( struct dt_device *dt ) { extern void * dt_ioremap ( struct dt_device *dt, unsigned int offset, unsigned int index, size_t len ); +extern int dt_probe_node ( struct device *parent, unsigned int offset ); +extern void dt_remove_node ( struct device *parent ); #endif /* _IPXE_DEVTREE_H */ -- cgit v1.2.3-55-g7522 From 1de3aef78c1a8c87cc921463bb2cf6054a442fa7 Mon Sep 17 00:00:00 2001 From: Joseph Wong Date: Wed, 11 Jun 2025 15:07:16 +0100 Subject: [bnxt] Remove TX padding Remove unnecessary TX padding. Signed-off-by: Joseph Wong --- src/drivers/net/bnxt/bnxt.c | 2 -- src/drivers/net/bnxt/bnxt_dbg.h | 6 ------ 2 files changed, 8 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/bnxt/bnxt.c b/src/drivers/net/bnxt/bnxt.c index 5a547703c..233cc46a2 100644 --- a/src/drivers/net/bnxt/bnxt.c +++ b/src/drivers/net/bnxt/bnxt.c @@ -2160,8 +2160,6 @@ static void bnxt_tx_adjust_pkt ( struct bnxt *bp, struct io_buffer *iob ) if ( iob_len ( iob ) != prev_len ) prev_len = iob_len ( iob ); - iob_pad ( iob, ETH_ZLEN ); - dbg_tx_pad ( prev_len, iob_len ( iob ) ); } static int bnxt_tx ( struct net_device *dev, struct io_buffer *iob ) diff --git a/src/drivers/net/bnxt/bnxt_dbg.h b/src/drivers/net/bnxt/bnxt_dbg.h index 145402818..eaa5f7110 100644 --- a/src/drivers/net/bnxt/bnxt_dbg.h +++ b/src/drivers/net/bnxt/bnxt_dbg.h @@ -537,12 +537,6 @@ void dbg_tx_vlan(struct bnxt *bp, char *src, u16 plen, u16 len) dbg_prn(" old len %d new len %d\n", plen, len); } -void dbg_tx_pad(u16 plen, u16 len) -{ - if (len != plen) - dbg_prn("- Tx padded(0) old len %d new len %d\n", plen, len); -} - void dump_tx_stat(struct bnxt *bp) { dbg_prn(" TX stats cnt %d req_cnt %d", bp->tx.cnt, bp->tx.cnt_req); -- cgit v1.2.3-55-g7522 From 6c8fb4b89d49c40339fe61b7ec549d90f1ce9480 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 17 Jun 2025 14:28:18 +0100 Subject: [uart] Allow for the existence of non-16550 UARTs Remove the assumption that all platforms use a fixed number of 16550 UARTs identifiable by a simple numeric index. Create an abstraction allowing for dynamic instantiation and registration of any number of arbitrary UART models. The common case of the serial console on x86 uses a single fixed UART specified at compile time. Avoid unnecessarily dragging in the dynamic instantiation code in this use case by allowing COMCONSOLE to refer to a single static UART object representing the relevant port. When selecting a UART by command-line argument (as used in the "gdbstub serial " command), allow the UART to be specified as either a numeric index (to retain backwards compatiblity) or a case-insensitive port name such as "COM2". Signed-off-by: Michael Brown --- src/Makefile | 1 + src/arch/x86/core/x86_uart.c | 58 +++---- src/arch/x86/include/bits/ns16550.h | 60 +++++++ src/arch/x86/include/bits/uart.h | 41 ----- src/arch/x86/interface/syslinux/comboot_call.c | 17 +- src/core/gdbserial.c | 42 ++--- src/core/serial.c | 62 ++++--- src/core/uart.c | 176 ++++++++++---------- src/drivers/uart/ns16550.c | 179 +++++++++++++++++++++ src/include/bits/ns16550.h | 15 ++ src/include/bits/uart.h | 15 -- src/include/ipxe/errfile.h | 1 + src/include/ipxe/gdbserial.h | 2 +- src/include/ipxe/ns16550.h | 112 +++++++++++++ src/include/ipxe/serial.h | 2 +- src/include/ipxe/uart.h | 214 +++++++++++++++---------- 16 files changed, 683 insertions(+), 314 deletions(-) create mode 100644 src/arch/x86/include/bits/ns16550.h delete mode 100644 src/arch/x86/include/bits/uart.h create mode 100644 src/drivers/uart/ns16550.c create mode 100644 src/include/bits/ns16550.h delete mode 100644 src/include/bits/uart.h create mode 100644 src/include/ipxe/ns16550.h (limited to 'src/drivers') diff --git a/src/Makefile b/src/Makefile index 6367b13ea..f3d378e05 100644 --- a/src/Makefile +++ b/src/Makefile @@ -94,6 +94,7 @@ SRCDIRS += drivers/infiniband/mlx_utils/mlx_lib/mlx_link_speed SRCDIRS += drivers/infiniband/mlx_utils/mlx_lib/mlx_mtu SRCDIRS += drivers/infiniband/mlx_nodnic/src SRCDIRS += drivers/usb +SRCDIRS += drivers/uart SRCDIRS += interface/pxe interface/efi interface/smbios SRCDIRS += interface/bofm SRCDIRS += interface/xen diff --git a/src/arch/x86/core/x86_uart.c b/src/arch/x86/core/x86_uart.c index e455775bf..2580b931b 100644 --- a/src/arch/x86/core/x86_uart.c +++ b/src/arch/x86/core/x86_uart.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014 Michael Brown . + * Copyright (C) 2025 Michael Brown . * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -29,41 +29,45 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * */ -#include -#include +#include +#include +#include -/** UART port bases */ -static uint16_t uart_base[] = { - [COM1] = 0x3f8, - [COM2] = 0x2f8, - [COM3] = 0x3e8, - [COM4] = 0x2e8, -}; +/** Define a fixed ISA UART */ +#define ISA_UART( NAME, BASE ) \ + struct ns16550_uart NAME = { \ + .uart = { \ + .refcnt = REF_INIT ( ref_no_free ), \ + .name = #NAME, \ + .op = &ns16550_operations, \ + }, \ + .base = ( ( void * ) (BASE) ), \ + } + +/* Fixed ISA UARTs */ +ISA_UART ( com1, COM1_BASE ); +ISA_UART ( com2, COM2_BASE ); +ISA_UART ( com3, COM3_BASE ); +ISA_UART ( com4, COM4_BASE ); /** - * Select UART port + * Register fixed ISA UARTs * - * @v uart UART - * @v port Port number, or 0 to disable * @ret rc Return status code */ -int uart_select ( struct uart *uart, unsigned int port ) { +int uart_register_fixed ( void ) { + static struct uart *ports[] = { COM1, COM2, COM3, COM4 }; + unsigned int i; int rc; - /* Set new UART base */ - if ( port >= ( sizeof ( uart_base ) / sizeof ( uart_base[0] ) ) ) { - rc = -ENODEV; - goto err; + /* Register all fixed ISA UARTs */ + for ( i = 0 ; i < ( sizeof ( ports ) / sizeof ( ports[0] ) ) ; i++ ) { + if ( ( rc = uart_register ( ports[i] ) ) != 0 ) { + DBGC ( ports[i], "UART could not register %s: %s\n", + ports[i]->name, strerror ( rc ) ); + return rc; + } } - uart->base = ( ( void * ) ( intptr_t ) uart_base[port] ); - - /* Check that UART exists */ - if ( ( rc = uart_exists ( uart ) ) != 0 ) - goto err; return 0; - - err: - uart->base = NULL; - return rc; } diff --git a/src/arch/x86/include/bits/ns16550.h b/src/arch/x86/include/bits/ns16550.h new file mode 100644 index 000000000..9f7d741ae --- /dev/null +++ b/src/arch/x86/include/bits/ns16550.h @@ -0,0 +1,60 @@ +#ifndef _BITS_NS16550_H +#define _BITS_NS16550_H + +/** @file + * + * 16550-compatible UART + * + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#include +#include + +/** + * Write to UART register + * + * @v ns16550 16550 UART + * @v address Register address + * @v data Data + */ +static inline __attribute__ (( always_inline )) void +ns16550_write ( struct ns16550_uart *ns16550, unsigned int address, + uint8_t data ) { + + outb ( data, ( ns16550->base + address ) ); +} + +/** + * Read from UART register + * + * @v ns16550 16550 UART + * @v address Register address + * @ret data Data + */ +static inline __attribute__ (( always_inline )) uint8_t +ns16550_read ( struct ns16550_uart *ns16550, unsigned int address ) { + + return inb ( ns16550->base + address ); +} + +/* Fixed ISA serial port base addresses */ +#define COM1_BASE 0x3f8 +#define COM2_BASE 0x2f8 +#define COM3_BASE 0x3e8 +#define COM4_BASE 0x2e8 + +/* Fixed ISA serial ports */ +extern struct ns16550_uart com1; +extern struct ns16550_uart com2; +extern struct ns16550_uart com3; +extern struct ns16550_uart com4; + +/* Fixed ISA serial port names */ +#define COM1 &com1.uart +#define COM2 &com2.uart +#define COM3 &com3.uart +#define COM4 &com4.uart + +#endif /* _BITS_NS16550_H */ diff --git a/src/arch/x86/include/bits/uart.h b/src/arch/x86/include/bits/uart.h deleted file mode 100644 index e09cd3f4c..000000000 --- a/src/arch/x86/include/bits/uart.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef _BITS_UART_H -#define _BITS_UART_H - -/** @file - * - * 16550-compatible UART - * - */ - -FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); - -#include -#include - -/** - * Write to UART register - * - * @v uart UART - * @v addr Register address - * @v data Data - */ -static inline __attribute__ (( always_inline )) void -uart_write ( struct uart *uart, unsigned int addr, uint8_t data ) { - outb ( data, ( uart->base + addr ) ); -} - -/** - * Read from UART register - * - * @v uart UART - * @v addr Register address - * @ret data Data - */ -static inline __attribute__ (( always_inline )) uint8_t -uart_read ( struct uart *uart, unsigned int addr ) { - return inb ( uart->base + addr ); -} - -extern int uart_select ( struct uart *uart, unsigned int port ); - -#endif /* _BITS_UART_H */ diff --git a/src/arch/x86/interface/syslinux/comboot_call.c b/src/arch/x86/interface/syslinux/comboot_call.c index f7cceb30f..97bdaeae3 100644 --- a/src/arch/x86/interface/syslinux/comboot_call.c +++ b/src/arch/x86/interface/syslinux/comboot_call.c @@ -37,6 +37,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include #include #include +#include #include #include #include @@ -253,8 +254,8 @@ static __asmcall __used void int21 ( struct i386_all_regs *ix86 ) { break; case 0x04: /* Write Character to Serial Port */ - if ( serial_console.base ) { - uart_transmit ( &serial_console, ix86->regs.dl ); + if ( serial_console ) { + uart_transmit ( serial_console, ix86->regs.dl ); ix86->flags &= ~CF; } break; @@ -445,9 +446,13 @@ static __asmcall __used void int22 ( struct i386_all_regs *ix86 ) { break; case 0x000B: /* Get Serial Console Configuration */ - if ( serial_console.base ) { - ix86->regs.dx = ( ( intptr_t ) serial_console.base ); - ix86->regs.cx = serial_console.divisor; + if ( serial_console ) { + struct ns16550_uart *comport = + container_of ( serial_console, + struct ns16550_uart, uart ); + + ix86->regs.dx = ( ( intptr_t ) comport->base ); + ix86->regs.cx = comport->divisor; ix86->regs.bx = 0; ix86->flags &= ~CF; } @@ -685,4 +690,4 @@ void unhook_comboot_interrupts ( ) { } /* Avoid dragging in serial console support unconditionally */ -struct uart serial_console __attribute__ (( weak )); +struct uart *serial_console __attribute__ (( weak )); diff --git a/src/core/gdbserial.c b/src/core/gdbserial.c index 1edc28109..0f74e5fe0 100644 --- a/src/core/gdbserial.c +++ b/src/core/gdbserial.c @@ -25,20 +25,12 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include -#include #include #include #include #include #include -/* UART port number */ -#ifdef COMCONSOLE -#define GDBSERIAL_PORT COMCONSOLE -#else -#define GDBSERIAL_PORT 0 -#endif - /* UART baud rate */ #ifdef COMPRESERVE #define GDBSERIAL_BAUD 0 @@ -47,37 +39,30 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #endif /** GDB serial UART */ -static struct uart gdbserial_uart; +static struct uart *gdbserial_uart; struct gdb_transport serial_gdb_transport __gdb_transport; static size_t gdbserial_recv ( char *buf, size_t len ) { assert ( len > 0 ); - while ( ! uart_data_ready ( &gdbserial_uart ) ) {} - buf[0] = uart_receive ( &gdbserial_uart ); + while ( ! uart_data_ready ( gdbserial_uart ) ) {} + buf[0] = uart_receive ( gdbserial_uart ); return 1; } static void gdbserial_send ( const char *buf, size_t len ) { while ( len-- > 0 ) { - uart_transmit ( &gdbserial_uart, *buf++ ); + uart_transmit ( gdbserial_uart, *buf++ ); } } static int gdbserial_init ( int argc, char **argv ) { - unsigned int port; - char *endp; - - if ( argc == 0 ) { - port = GDBSERIAL_PORT; - } else if ( argc == 1 ) { - port = strtoul ( argv[0], &endp, 10 ); - if ( *endp ) { - printf ( "serial: invalid port\n" ); - return 1; - } + const char *port; + + if ( argc == 1 ) { + port = argv[0]; } else { printf ( "serial: syntax \n" ); return 1; @@ -98,14 +83,19 @@ struct gdb_transport serial_gdb_transport __gdb_transport = { .send = gdbserial_send, }; -struct gdb_transport * gdbserial_configure ( unsigned int port, +struct gdb_transport * gdbserial_configure ( const char *name, unsigned int baud ) { int rc; - if ( ( rc = uart_select ( &gdbserial_uart, port ) ) != 0 ) + uart_put ( gdbserial_uart ); + gdbserial_uart = NULL; + + gdbserial_uart = uart_find ( name ); + if ( ! gdbserial_uart ) return NULL; + uart_get ( gdbserial_uart ); - if ( ( rc = uart_init ( &gdbserial_uart, baud ) ) != 0 ) + if ( ( rc = uart_init ( gdbserial_uart, baud ) ) != 0 ) return NULL; return &serial_gdb_transport; diff --git a/src/core/serial.c b/src/core/serial.c index 2866681a8..e718f0d42 100644 --- a/src/core/serial.c +++ b/src/core/serial.c @@ -35,6 +35,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include #include @@ -44,22 +45,21 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define CONSOLE_SERIAL ( CONSOLE_USAGE_ALL & ~CONSOLE_USAGE_LOG ) #endif -/* UART port number */ -#ifdef COMCONSOLE -#define CONSOLE_PORT COMCONSOLE -#else -#define CONSOLE_PORT 0 +/* Serial console UART */ +#ifndef COMCONSOLE +#define COMCONSOLE NULL #endif -/* UART baud rate */ -#ifdef COMPRESERVE -#define CONSOLE_BAUD 0 -#else -#define CONSOLE_BAUD COMSPEED +/* Serial console baud rate */ +#ifndef COMSPEED +#define COMSPEED 0 #endif -/** Serial console UART */ -struct uart serial_console; +/** Default serial console UART */ +static struct uart * const default_serial_console = COMCONSOLE; + +/** Active serial console UART */ +struct uart *serial_console; /** * Print a character to serial console @@ -69,11 +69,11 @@ struct uart serial_console; static void serial_putchar ( int character ) { /* Do nothing if we have no UART */ - if ( ! serial_console.base ) + if ( ! serial_console ) return; /* Transmit character */ - uart_transmit ( &serial_console, character ); + uart_transmit ( serial_console, character ); } /** @@ -85,14 +85,14 @@ static int serial_getchar ( void ) { uint8_t data; /* Do nothing if we have no UART */ - if ( ! serial_console.base ) + if ( ! serial_console ) return 0; /* Wait for data to be ready */ - while ( ! uart_data_ready ( &serial_console ) ) {} + while ( ! uart_data_ready ( serial_console ) ) {} /* Receive data */ - data = uart_receive ( &serial_console ); + data = uart_receive ( serial_console ); /* Strip any high bit and convert DEL to backspace */ data &= 0x7f; @@ -111,11 +111,11 @@ static int serial_getchar ( void ) { static int serial_iskey ( void ) { /* Do nothing if we have no UART */ - if ( ! serial_console.base ) + if ( ! serial_console ) return 0; /* Check UART */ - return uart_data_ready ( &serial_console ); + return uart_data_ready ( serial_console ); } /** Serial console */ @@ -128,25 +128,23 @@ struct console_driver serial_console_driver __console_driver = { /** Initialise serial console */ static void serial_init ( void ) { + struct uart *uart = default_serial_console; int rc; /* Do nothing if we have no default port */ - if ( ! CONSOLE_PORT ) + if ( ! uart ) return; - /* Select UART */ - if ( ( rc = uart_select ( &serial_console, CONSOLE_PORT ) ) != 0 ) { - DBG ( "Could not select UART %d: %s\n", - CONSOLE_PORT, strerror ( rc ) ); - return; - } - /* Initialise UART */ - if ( ( rc = uart_init ( &serial_console, CONSOLE_BAUD ) ) != 0 ) { - DBG ( "Could not initialise UART %d baud %d: %s\n", - CONSOLE_PORT, CONSOLE_BAUD, strerror ( rc ) ); + if ( ( rc = uart_init ( uart, COMSPEED ) ) != 0 ) { + DBGC ( uart, "SERIAL could not initialise %s baud %d: %s\n", + uart->name, COMSPEED, strerror ( rc ) ); return; } + + /* Record UART as serial console */ + serial_console = uart; + DBGC ( uart, "SERIAL using %s\n", uart->name ); } /** @@ -157,11 +155,11 @@ static void serial_init ( void ) { static void serial_shutdown ( int flags __unused ) { /* Do nothing if we have no UART */ - if ( ! serial_console.base ) + if ( ! serial_console ) return; /* Flush any pending output */ - uart_flush ( &serial_console ); + uart_flush ( serial_console ); /* Leave console enabled; it's still usable */ } diff --git a/src/core/uart.c b/src/core/uart.c index 4dc307fce..a645bd398 100644 --- a/src/core/uart.c +++ b/src/core/uart.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014 Michael Brown . + * Copyright (C) 2025 Michael Brown . * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -25,125 +25,139 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /** @file * - * 16550-compatible UART + * Generic UARTs * */ -#include +#include +#include #include #include -/** Timeout for transmit holding register to become empty */ -#define UART_THRE_TIMEOUT_MS 100 +/** List of registered UARTs */ +LIST_HEAD ( uarts ); -/** Timeout for transmitter to become empty */ -#define UART_TEMT_TIMEOUT_MS 1000 +static void null_uart_transmit ( struct uart *uart __unused, + uint8_t byte __unused ) { +} + +static int null_uart_data_ready ( struct uart *uart __unused ) { + return 0; +} + +static uint8_t null_uart_receive ( struct uart *uart __unused ) { + return 0; +} + +static int null_uart_init ( struct uart *uart __unused, + unsigned int baud __unused ) { + return 0; +} + +static void null_uart_flush ( struct uart *uart __unused ) { +} + +/** Null UART operations */ +struct uart_operations null_uart_operations = { + .transmit = null_uart_transmit, + .data_ready = null_uart_data_ready, + .receive = null_uart_receive, + .init = null_uart_init, + .flush = null_uart_flush, +}; /** - * Transmit data + * Allocate UART * - * @v uart UART - * @v data Data + * @v priv_len Length of private data + * @ret uart UART, or NULL on error */ -void uart_transmit ( struct uart *uart, uint8_t data ) { - unsigned int i; - uint8_t lsr; - - /* Wait for transmitter holding register to become empty */ - for ( i = 0 ; i < UART_THRE_TIMEOUT_MS ; i++ ) { - lsr = uart_read ( uart, UART_LSR ); - if ( lsr & UART_LSR_THRE ) - break; - mdelay ( 1 ); - } +struct uart * alloc_uart ( size_t priv_len ) { + struct uart *uart; + + /* Allocate and initialise UART */ + uart = zalloc ( sizeof ( *uart ) + priv_len ); + if ( ! uart ) + return NULL; + uart->priv = ( ( ( void * ) uart ) + sizeof ( *uart ) ); - /* Transmit data (even if we timed out) */ - uart_write ( uart, UART_THR, data ); + return uart; } /** - * Flush data + * Register fixed UARTs (when not provided by platform) * - * @v uart UART + * @ret rc Return status code */ -void uart_flush ( struct uart *uart ) { - unsigned int i; - uint8_t lsr; - - /* Wait for transmitter and receiver to become empty */ - for ( i = 0 ; i < UART_TEMT_TIMEOUT_MS ; i++ ) { - uart_read ( uart, UART_RBR ); - lsr = uart_read ( uart, UART_LSR ); - if ( ( lsr & UART_LSR_TEMT ) && ! ( lsr & UART_LSR_DR ) ) - break; - } +__weak int uart_register_fixed ( void ) { + + return 0; } /** - * Check for existence of UART + * Register UART * * @v uart UART * @ret rc Return status code */ -int uart_exists ( struct uart *uart ) { - - /* Fail if no UART port is defined */ - if ( ! uart->base ) - return -ENODEV; +int uart_register ( struct uart *uart ) { - /* Fail if UART scratch register seems not to be present */ - uart_write ( uart, UART_SCR, 0x18 ); - if ( uart_read ( uart, UART_SCR ) != 0x18 ) - return -ENODEV; - uart_write ( uart, UART_SCR, 0xae ); - if ( uart_read ( uart, UART_SCR ) != 0xae ) - return -ENODEV; + /* Add to list of registered UARTs */ + uart_get ( uart ); + list_add_tail ( &uart->list, &uarts ); + DBGC ( uart, "UART %s registered\n", uart->name ); return 0; } /** - * Initialise UART + * Unregister UART * * @v uart UART - * @v baud Baud rate, or zero to leave unchanged - * @ret rc Return status code */ -int uart_init ( struct uart *uart, unsigned int baud ) { - uint8_t dlm; - uint8_t dll; +void uart_unregister ( struct uart *uart ) { + + /* Remove from list of registered UARTs */ + list_del ( &uart->list ); + uart_put ( uart ); +} + +/** + * Find named UART + * + * @v name UART name + * @ret uart UART, or NULL if not found + */ +struct uart * uart_find ( const char *name ) { + struct uart *uart; + unsigned int index; + char *endp; int rc; - /* Check for existence of UART */ - if ( ( rc = uart_exists ( uart ) ) != 0 ) - return rc; - - /* Configure divisor and line control register, if applicable */ - uart_write ( uart, UART_LCR, ( UART_LCR_8N1 | UART_LCR_DLAB ) ); - if ( baud ) { - uart->divisor = ( UART_MAX_BAUD / baud ); - dlm = ( ( uart->divisor >> 8 ) & 0xff ); - dll = ( ( uart->divisor >> 0 ) & 0xff ); - uart_write ( uart, UART_DLM, dlm ); - uart_write ( uart, UART_DLL, dll ); - } else { - dlm = uart_read ( uart, UART_DLM ); - dll = uart_read ( uart, UART_DLL ); - uart->divisor = ( ( dlm << 8 ) | dll ); + /* Register fixed platform UARTs if not already registered */ + if ( list_empty ( &uarts ) ) { + if ( ( rc = uart_register_fixed() ) != 0 ) { + DBGC ( &uarts, "UART could not register fixed UARTs: " + "%s\n", strerror ( rc ) ); + /* Continue anyway */ + } } - uart_write ( uart, UART_LCR, UART_LCR_8N1 ); - /* Disable interrupts */ - uart_write ( uart, UART_IER, 0 ); + /* Try parsing name as a numeric index */ + index = strtoul ( name, &endp, 10 ); - /* Enable FIFOs */ - uart_write ( uart, UART_FCR, UART_FCR_FE ); + /* Find matching UART, if any */ + list_for_each_entry ( uart, &uarts, list ) { - /* Assert DTR and RTS */ - uart_write ( uart, UART_MCR, ( UART_MCR_DTR | UART_MCR_RTS ) ); + /* Check for a matching name */ + if ( strcasecmp ( name, uart->name ) == 0 ) + return uart; - /* Flush any stale data */ - uart_flush ( uart ); + /* Check for a matching numeric index */ + if ( ( *endp == '\0' ) && ( index-- == 0 ) ) + return uart; + } - return 0; + DBGC ( &uarts, "UART %s not found\n", name ); + return NULL; } diff --git a/src/drivers/uart/ns16550.c b/src/drivers/uart/ns16550.c new file mode 100644 index 000000000..58a71261b --- /dev/null +++ b/src/drivers/uart/ns16550.c @@ -0,0 +1,179 @@ +/* + * Copyright (C) 2025 Michael Brown . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + * + * You can also choose to distribute this program under the terms of + * the Unmodified Binary Distribution Licence (as given in the file + * COPYING.UBDL), provided that you have satisfied its requirements. + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +/** @file + * + * 16550-compatible UART + * + */ + +#include +#include +#include +#include + +/** Timeout for transmit holding register to become empty */ +#define NS16550_THRE_TIMEOUT_MS 100 + +/** Timeout for transmitter to become empty */ +#define NS16550_TEMT_TIMEOUT_MS 1000 + +/** + * Transmit data + * + * @v uart UART + * @v data Data + */ +static void ns16550_transmit ( struct uart *uart, uint8_t data ) { + struct ns16550_uart *ns16550 = + container_of ( uart, struct ns16550_uart, uart ); + unsigned int i; + uint8_t lsr; + + /* Wait for transmitter holding register to become empty */ + for ( i = 0 ; i < NS16550_THRE_TIMEOUT_MS ; i++ ) { + lsr = ns16550_read ( ns16550, NS16550_LSR ); + if ( lsr & NS16550_LSR_THRE ) + break; + mdelay ( 1 ); + } + + /* Transmit data (even if we timed out) */ + ns16550_write ( ns16550, NS16550_THR, data ); +} + +/** + * Check if data is ready + * + * @v uart UART + * @ret ready Data is ready + */ +static int ns16550_data_ready ( struct uart *uart ) { + struct ns16550_uart *ns16550 = + container_of ( uart, struct ns16550_uart, uart ); + uint8_t lsr; + + /* Check for receive data ready */ + lsr = ns16550_read ( ns16550, NS16550_LSR ); + return ( lsr & NS16550_LSR_DR ); +} + +/** + * Receive data + * + * @v uart UART + * @ret data Data + */ +static uint8_t ns16550_receive ( struct uart *uart ) { + struct ns16550_uart *ns16550 = + container_of ( uart, struct ns16550_uart, uart ); + uint8_t rbr; + + /* Receive byte */ + rbr = ns16550_read ( ns16550, NS16550_RBR ); + return rbr; +} + +/** + * Flush transmitted data + * + * @v uart UART + */ +static void ns16550_flush ( struct uart *uart ) { + struct ns16550_uart *ns16550 = + container_of ( uart, struct ns16550_uart, uart ); + unsigned int i; + uint8_t lsr; + + /* Wait for transmitter to become empty */ + for ( i = 0 ; i < NS16550_TEMT_TIMEOUT_MS ; i++ ) { + lsr = ns16550_read ( ns16550, NS16550_LSR ); + if ( lsr & NS16550_LSR_TEMT ) + break; + } +} + +/** + * Initialise UART + * + * @v uart UART + * @v baud Baud rate, or zero to leave unchanged + * @ret rc Return status code + */ +static int ns16550_init ( struct uart *uart, unsigned int baud ) { + struct ns16550_uart *ns16550 = + container_of ( uart, struct ns16550_uart, uart ); + uint8_t dlm; + uint8_t dll; + + /* Fail if UART scratch register seems not to be present */ + ns16550_write ( ns16550, NS16550_SCR, 0x18 ); + if ( ns16550_read ( ns16550, NS16550_SCR ) != 0x18 ) + return -ENODEV; + ns16550_write ( ns16550, NS16550_SCR, 0xae ); + if ( ns16550_read ( ns16550, NS16550_SCR ) != 0xae ) + return -ENODEV; + + /* Configure divisor and line control register, if applicable */ + ns16550_write ( ns16550, NS16550_LCR, + ( NS16550_LCR_8N1 | NS16550_LCR_DLAB ) ); + if ( baud ) { + ns16550->divisor = ( NS16550_MAX_BAUD / baud ); + dlm = ( ( ns16550->divisor >> 8 ) & 0xff ); + dll = ( ( ns16550->divisor >> 0 ) & 0xff ); + ns16550_write ( ns16550, NS16550_DLM, dlm ); + ns16550_write ( ns16550, NS16550_DLL, dll ); + } else { + dlm = ns16550_read ( ns16550, NS16550_DLM ); + dll = ns16550_read ( ns16550, NS16550_DLL ); + ns16550->divisor = ( ( dlm << 8 ) | dll ); + } + ns16550_write ( ns16550, NS16550_LCR, NS16550_LCR_8N1 ); + + /* Disable interrupts */ + ns16550_write ( ns16550, NS16550_IER, 0 ); + + /* Enable FIFOs */ + ns16550_write ( ns16550, NS16550_FCR, NS16550_FCR_FE ); + + /* Assert DTR and RTS */ + ns16550_write ( ns16550, NS16550_MCR, + ( NS16550_MCR_DTR | NS16550_MCR_RTS ) ); + + /* Flush any stale received data */ + while ( ns16550_data_ready ( uart ) ) + ns16550_receive ( uart ); + + return 0; +} + +/** 16550 UART operations */ +struct uart_operations ns16550_operations = { + .transmit = ns16550_transmit, + .data_ready = ns16550_data_ready, + .receive = ns16550_receive, + .init = ns16550_init, + .flush = ns16550_flush, +}; diff --git a/src/include/bits/ns16550.h b/src/include/bits/ns16550.h new file mode 100644 index 000000000..4b3e30c76 --- /dev/null +++ b/src/include/bits/ns16550.h @@ -0,0 +1,15 @@ +#ifndef _BITS_NS16550_H +#define _BITS_NS16550_H + +/** @file + * + * Dummy architecture-specific 16550-compatible UART + * + * This file is included only if the architecture does not provide its + * own version of this file. + * + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#endif /* _BITS_NS16550_H */ diff --git a/src/include/bits/uart.h b/src/include/bits/uart.h deleted file mode 100644 index e132d5c3d..000000000 --- a/src/include/bits/uart.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef _BITS_UART_H -#define _BITS_UART_H - -/** @file - * - * Dummy architecture-specific UART - * - * This file is included only if the architecture does not provide its - * own version of this file. - * - */ - -FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); - -#endif /* _BITS_UART_H */ diff --git a/src/include/ipxe/errfile.h b/src/include/ipxe/errfile.h index d00191fbe..1a39af43f 100644 --- a/src/include/ipxe/errfile.h +++ b/src/include/ipxe/errfile.h @@ -109,6 +109,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define ERRFILE_spi_bit ( ERRFILE_DRIVER | 0x00130000 ) #define ERRFILE_nvsvpd ( ERRFILE_DRIVER | 0x00140000 ) #define ERRFILE_uart ( ERRFILE_DRIVER | 0x00150000 ) +#define ERRFILE_ns16550 ( ERRFILE_DRIVER | 0x00160000 ) #define ERRFILE_3c509 ( ERRFILE_DRIVER | 0x00200000 ) #define ERRFILE_bnx2 ( ERRFILE_DRIVER | 0x00210000 ) diff --git a/src/include/ipxe/gdbserial.h b/src/include/ipxe/gdbserial.h index 166eb4f0d..62cc16014 100644 --- a/src/include/ipxe/gdbserial.h +++ b/src/include/ipxe/gdbserial.h @@ -11,7 +11,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); struct gdb_transport; -extern struct gdb_transport * gdbserial_configure ( unsigned int port, +extern struct gdb_transport * gdbserial_configure ( const char *port, unsigned int baud ); #endif /* _IPXE_GDBSERIAL_H */ diff --git a/src/include/ipxe/ns16550.h b/src/include/ipxe/ns16550.h new file mode 100644 index 000000000..f7bb55a84 --- /dev/null +++ b/src/include/ipxe/ns16550.h @@ -0,0 +1,112 @@ +#ifndef _IPXE_NS16550_H +#define _IPXE_NS16550_H + +/** @file + * + * 16550-compatible UART + * + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#include + +/** Transmitter holding register */ +#define NS16550_THR 0x00 + +/** Receiver buffer register */ +#define NS16550_RBR 0x00 + +/** Interrupt enable register */ +#define NS16550_IER 0x01 + +/** FIFO control register */ +#define NS16550_FCR 0x02 +#define NS16550_FCR_FE 0x01 /**< FIFO enable */ + +/** Line control register */ +#define NS16550_LCR 0x03 +#define NS16550_LCR_WLS0 0x01 /**< Word length select bit 0 */ +#define NS16550_LCR_WLS1 0x02 /**< Word length select bit 1 */ +#define NS16550_LCR_STB 0x04 /**< Number of stop bits */ +#define NS16550_LCR_PEN 0x08 /**< Parity enable */ +#define NS16550_LCR_EPS 0x10 /**< Even parity select */ +#define NS16550_LCR_DLAB 0x80 /**< Divisor latch access bit */ + +#define NS16550_LCR_WORD_LEN(x) ( ( (x) - 5 ) << 0 ) /**< Word length */ +#define NS16550_LCR_STOP_BITS(x) ( ( (x) - 1 ) << 2 ) /**< Stop bits */ +#define NS16550_LCR_PARITY(x) ( ( (x) - 0 ) << 3 ) /**< Parity */ + +/** + * Calculate line control register value + * + * @v word_len Word length (5-8) + * @v parity Parity (0=none, 1=odd, 3=even) + * @v stop_bits Stop bits (1-2) + * @ret lcr Line control register value + */ +#define NS16550_LCR_WPS( word_len, parity, stop_bits ) \ + ( NS16550_LCR_WORD_LEN ( (word_len) ) | \ + NS16550_LCR_PARITY ( (parity) ) | \ + NS16550_LCR_STOP_BITS ( (stop_bits) ) ) + +/** Default LCR value: 8 data bits, no parity, one stop bit */ +#define NS16550_LCR_8N1 NS16550_LCR_WPS ( 8, 0, 1 ) + +/** Modem control register */ +#define NS16550_MCR 0x04 +#define NS16550_MCR_DTR 0x01 /**< Data terminal ready */ +#define NS16550_MCR_RTS 0x02 /**< Request to send */ + +/** Line status register */ +#define NS16550_LSR 0x05 +#define NS16550_LSR_DR 0x01 /**< Data ready */ +#define NS16550_LSR_THRE 0x20 /**< Transmitter holding reg. empty */ +#define NS16550_LSR_TEMT 0x40 /**< Transmitter empty */ + +/** Scratch register */ +#define NS16550_SCR 0x07 + +/** Divisor latch (least significant byte) */ +#define NS16550_DLL 0x00 + +/** Divisor latch (most significant byte) */ +#define NS16550_DLM 0x01 + +/** Maximum baud rate */ +#define NS16550_MAX_BAUD 115200 + +/** A 16550-compatible UART */ +struct ns16550_uart { + /** Generic UART */ + struct uart uart; + /** Register base address */ + void *base; + /** Baud rate divisor */ + uint16_t divisor; +}; + +#include + +/** Dummy COM1 UART for non-x86 platforms + * + * The architecture-independent config/serial.h header has long + * included the line + * + * #define COMCONSOLE COM1 + * + * which is meaningless on non-x86 platforms where there is no COM1 + * port. Allow COM1 to be treated as equivalent to "no UART" on + * non-x86 platforms, to avoid breaking existing build configurations. + */ +#ifndef COM1 +#define COM1 NULL +#endif + +void ns16550_write ( struct ns16550_uart *ns16550, unsigned int address, + uint8_t data ); +uint8_t ns16550_read ( struct ns16550_uart *ns16550, unsigned int address ); + +extern struct uart_operations ns16550_operations; + +#endif /* _IPXE_NS16550_H */ diff --git a/src/include/ipxe/serial.h b/src/include/ipxe/serial.h index 83be59c31..86a618670 100644 --- a/src/include/ipxe/serial.h +++ b/src/include/ipxe/serial.h @@ -11,6 +11,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include -extern struct uart serial_console; +extern struct uart *serial_console; #endif /* _IPXE_SERIAL_H */ diff --git a/src/include/ipxe/uart.h b/src/include/ipxe/uart.h index 86583ee2f..15adfa932 100644 --- a/src/include/ipxe/uart.h +++ b/src/include/ipxe/uart.h @@ -3,128 +3,174 @@ /** @file * - * 16550-compatible UART + * Generic UART * */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include +#include -/** Transmitter holding register */ -#define UART_THR 0x00 - -/** Receiver buffer register */ -#define UART_RBR 0x00 - -/** Interrupt enable register */ -#define UART_IER 0x01 +/** A generic UART */ +struct uart { + /** Reference count */ + struct refcnt refcnt; + /** Name */ + const char *name; + /** List of registered UARTs */ + struct list_head list; + + /** UART operations */ + struct uart_operations *op; + /** Driver-private data */ + void *priv; +}; -/** FIFO control register */ -#define UART_FCR 0x02 -#define UART_FCR_FE 0x01 /**< FIFO enable */ +/** UART operations */ +struct uart_operations { + /** + * Transmit byte + * + * @v uart UART + * @v byte Byte to transmit + * @ret rc Return status code + */ + void ( * transmit ) ( struct uart *uart, uint8_t byte ); + /** + * Check if data is ready + * + * @v uart UART + * @ret ready Data is ready + */ + int ( * data_ready ) ( struct uart *uart ); + /** + * Receive byte + * + * @v uart UART + * @ret byte Received byte + */ + uint8_t ( * receive ) ( struct uart *uart ); + /** + * Initialise UART + * + * @v uart UART + * @v baud Baud rate, or zero to leave unchanged + * @ret rc Return status code + */ + int ( * init ) ( struct uart *uart, unsigned int baud ); + /** + * Flush transmitted data + * + * @v uart UART + */ + void ( * flush ) ( struct uart *uart ); +}; -/** Line control register */ -#define UART_LCR 0x03 -#define UART_LCR_WLS0 0x01 /**< Word length select bit 0 */ -#define UART_LCR_WLS1 0x02 /**< Word length select bit 1 */ -#define UART_LCR_STB 0x04 /**< Number of stop bits */ -#define UART_LCR_PEN 0x08 /**< Parity enable */ -#define UART_LCR_EPS 0x10 /**< Even parity select */ -#define UART_LCR_DLAB 0x80 /**< Divisor latch access bit */ +/** + * Transmit byte + * + * @v uart UART + * @v byte Byte to transmit + * @ret rc Return status code + */ +static inline __attribute__ (( always_inline )) void +uart_transmit ( struct uart *uart, uint8_t byte ) { -#define UART_LCR_WORD_LEN(x) ( ( (x) - 5 ) << 0 ) /**< Word length */ -#define UART_LCR_STOP_BITS(x) ( ( (x) - 1 ) << 2 ) /**< Stop bits */ -#define UART_LCR_PARITY(x) ( ( (x) - 0 ) << 3 ) /**< Parity */ + uart->op->transmit ( uart, byte ); +} /** - * Calculate line control register value + * Check if data is ready * - * @v word_len Word length (5-8) - * @v parity Parity (0=none, 1=odd, 3=even) - * @v stop_bits Stop bits (1-2) - * @ret lcr Line control register value + * @v uart UART + * @ret ready Data is ready */ -#define UART_LCR_WPS( word_len, parity, stop_bits ) \ - ( UART_LCR_WORD_LEN ( (word_len) ) | \ - UART_LCR_PARITY ( (parity) ) | \ - UART_LCR_STOP_BITS ( (stop_bits) ) ) - -/** Default LCR value: 8 data bits, no parity, one stop bit */ -#define UART_LCR_8N1 UART_LCR_WPS ( 8, 0, 1 ) +static inline __attribute__ (( always_inline )) int +uart_data_ready ( struct uart *uart ) { -/** Modem control register */ -#define UART_MCR 0x04 -#define UART_MCR_DTR 0x01 /**< Data terminal ready */ -#define UART_MCR_RTS 0x02 /**< Request to send */ + return uart->op->data_ready ( uart ); +} -/** Line status register */ -#define UART_LSR 0x05 -#define UART_LSR_DR 0x01 /**< Data ready */ -#define UART_LSR_THRE 0x20 /**< Transmitter holding register empty */ -#define UART_LSR_TEMT 0x40 /**< Transmitter empty */ +/** + * Receive byte + * + * @v uart UART + * @ret byte Received byte + */ +static inline __attribute__ (( always_inline )) uint8_t +uart_receive ( struct uart *uart ) { -/** Scratch register */ -#define UART_SCR 0x07 + return uart->op->receive ( uart ); +} -/** Divisor latch (least significant byte) */ -#define UART_DLL 0x00 +/** + * Initialise UART + * + * @v uart UART + * @v baud Baud rate, or zero to leave unchanged + * @ret rc Return status code + */ +static inline __attribute__ (( always_inline )) int +uart_init ( struct uart *uart, unsigned int baud ) { -/** Divisor latch (most significant byte) */ -#define UART_DLM 0x01 + return uart->op->init ( uart, baud ); +} -/** Maximum baud rate */ -#define UART_MAX_BAUD 115200 +/** + * Flush transmitted data + * + * @v uart UART + */ +static inline __attribute__ (( always_inline )) void +uart_flush ( struct uart *uart ) { -/** A 16550-compatible UART */ -struct uart { - /** I/O port base address */ - void *base; - /** Baud rate divisor */ - uint16_t divisor; -}; + uart->op->flush ( uart ); +} -/** Symbolic names for port indexes */ -enum uart_port { - COM1 = 1, - COM2 = 2, - COM3 = 3, - COM4 = 4, -}; +extern struct list_head uarts; +extern struct uart_operations null_uart_operations; -#include +/** + * Get reference to UART + * + * @v uart UART + * @ret uart UART + */ +static inline __attribute__ (( always_inline )) struct uart * +uart_get ( struct uart *uart ) { -void uart_write ( struct uart *uart, unsigned int addr, uint8_t data ); -uint8_t uart_read ( struct uart *uart, unsigned int addr ); -int uart_select ( struct uart *uart, unsigned int port ); + ref_get ( &uart->refcnt ); + return uart; +} /** - * Check if received data is ready + * Drop reference to UART * * @v uart UART - * @ret ready Data is ready */ -static inline int uart_data_ready ( struct uart *uart ) { - uint8_t lsr; +static inline __attribute__ (( always_inline )) void +uart_put ( struct uart *uart ) { - lsr = uart_read ( uart, UART_LSR ); - return ( lsr & UART_LSR_DR ); + ref_put ( &uart->refcnt ); } /** - * Receive data + * Nullify UART * * @v uart UART - * @ret data Data */ -static inline uint8_t uart_receive ( struct uart *uart ) { +static inline __attribute__ (( always_inline )) void +uart_nullify ( struct uart *uart ) { - return uart_read ( uart, UART_RBR ); + uart->op = &null_uart_operations; } -extern void uart_transmit ( struct uart *uart, uint8_t data ); -extern void uart_flush ( struct uart *uart ); -extern int uart_exists ( struct uart *uart ); -extern int uart_init ( struct uart *uart, unsigned int baud ); +extern struct uart * alloc_uart ( size_t priv_len ); +extern int uart_register ( struct uart *uart ); +extern int uart_register_fixed ( void ); +extern void uart_unregister ( struct uart *uart ); +extern struct uart * uart_find ( const char *name ); #endif /* _IPXE_UART_H */ -- cgit v1.2.3-55-g7522 From cca1cfd49ec3ac0ada90197d11118a99d16aed5b Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sat, 21 Jun 2025 23:11:56 +0100 Subject: [uart] Allow for dynamically registered 16550 UARTs Use the generic UART driver-private data pointer, rather than embedding the generic UART within the 16550 UART structure. Signed-off-by: Michael Brown --- src/arch/x86/core/x86_uart.c | 13 +++++++------ src/arch/x86/include/bits/ns16550.h | 16 ++++++++-------- src/arch/x86/interface/syslinux/comboot_call.c | 4 +--- src/drivers/uart/ns16550.c | 15 +++++---------- src/include/ipxe/ns16550.h | 2 -- 5 files changed, 21 insertions(+), 29 deletions(-) (limited to 'src/drivers') diff --git a/src/arch/x86/core/x86_uart.c b/src/arch/x86/core/x86_uart.c index 2580b931b..a1d643a58 100644 --- a/src/arch/x86/core/x86_uart.c +++ b/src/arch/x86/core/x86_uart.c @@ -35,13 +35,14 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /** Define a fixed ISA UART */ #define ISA_UART( NAME, BASE ) \ - struct ns16550_uart NAME = { \ - .uart = { \ - .refcnt = REF_INIT ( ref_no_free ), \ - .name = #NAME, \ - .op = &ns16550_operations, \ - }, \ + static struct ns16550_uart ns16550_ ## NAME = { \ .base = ( ( void * ) (BASE) ), \ + }; \ + struct uart NAME = { \ + .refcnt = REF_INIT ( ref_no_free ), \ + .name = #NAME, \ + .op = &ns16550_operations, \ + .priv = &ns16550_ ## NAME, \ } /* Fixed ISA UARTs */ diff --git a/src/arch/x86/include/bits/ns16550.h b/src/arch/x86/include/bits/ns16550.h index 9f7d741ae..cc2bd84c1 100644 --- a/src/arch/x86/include/bits/ns16550.h +++ b/src/arch/x86/include/bits/ns16550.h @@ -46,15 +46,15 @@ ns16550_read ( struct ns16550_uart *ns16550, unsigned int address ) { #define COM4_BASE 0x2e8 /* Fixed ISA serial ports */ -extern struct ns16550_uart com1; -extern struct ns16550_uart com2; -extern struct ns16550_uart com3; -extern struct ns16550_uart com4; +extern struct uart com1; +extern struct uart com2; +extern struct uart com3; +extern struct uart com4; /* Fixed ISA serial port names */ -#define COM1 &com1.uart -#define COM2 &com2.uart -#define COM3 &com3.uart -#define COM4 &com4.uart +#define COM1 &com1 +#define COM2 &com2 +#define COM3 &com3 +#define COM4 &com4 #endif /* _BITS_NS16550_H */ diff --git a/src/arch/x86/interface/syslinux/comboot_call.c b/src/arch/x86/interface/syslinux/comboot_call.c index 97bdaeae3..c3e921075 100644 --- a/src/arch/x86/interface/syslinux/comboot_call.c +++ b/src/arch/x86/interface/syslinux/comboot_call.c @@ -447,9 +447,7 @@ static __asmcall __used void int22 ( struct i386_all_regs *ix86 ) { case 0x000B: /* Get Serial Console Configuration */ if ( serial_console ) { - struct ns16550_uart *comport = - container_of ( serial_console, - struct ns16550_uart, uart ); + struct ns16550_uart *comport = serial_console->priv; ix86->regs.dx = ( ( intptr_t ) comport->base ); ix86->regs.cx = comport->divisor; diff --git a/src/drivers/uart/ns16550.c b/src/drivers/uart/ns16550.c index 58a71261b..cf8c744c6 100644 --- a/src/drivers/uart/ns16550.c +++ b/src/drivers/uart/ns16550.c @@ -47,8 +47,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * @v data Data */ static void ns16550_transmit ( struct uart *uart, uint8_t data ) { - struct ns16550_uart *ns16550 = - container_of ( uart, struct ns16550_uart, uart ); + struct ns16550_uart *ns16550 = uart->priv; unsigned int i; uint8_t lsr; @@ -71,8 +70,7 @@ static void ns16550_transmit ( struct uart *uart, uint8_t data ) { * @ret ready Data is ready */ static int ns16550_data_ready ( struct uart *uart ) { - struct ns16550_uart *ns16550 = - container_of ( uart, struct ns16550_uart, uart ); + struct ns16550_uart *ns16550 = uart->priv; uint8_t lsr; /* Check for receive data ready */ @@ -87,8 +85,7 @@ static int ns16550_data_ready ( struct uart *uart ) { * @ret data Data */ static uint8_t ns16550_receive ( struct uart *uart ) { - struct ns16550_uart *ns16550 = - container_of ( uart, struct ns16550_uart, uart ); + struct ns16550_uart *ns16550 = uart->priv; uint8_t rbr; /* Receive byte */ @@ -102,8 +99,7 @@ static uint8_t ns16550_receive ( struct uart *uart ) { * @v uart UART */ static void ns16550_flush ( struct uart *uart ) { - struct ns16550_uart *ns16550 = - container_of ( uart, struct ns16550_uart, uart ); + struct ns16550_uart *ns16550 = uart->priv; unsigned int i; uint8_t lsr; @@ -123,8 +119,7 @@ static void ns16550_flush ( struct uart *uart ) { * @ret rc Return status code */ static int ns16550_init ( struct uart *uart, unsigned int baud ) { - struct ns16550_uart *ns16550 = - container_of ( uart, struct ns16550_uart, uart ); + struct ns16550_uart *ns16550 = uart->priv; uint8_t dlm; uint8_t dll; diff --git a/src/include/ipxe/ns16550.h b/src/include/ipxe/ns16550.h index 3aaab6891..6699205e2 100644 --- a/src/include/ipxe/ns16550.h +++ b/src/include/ipxe/ns16550.h @@ -78,8 +78,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /** A 16550-compatible UART */ struct ns16550_uart { - /** Generic UART */ - struct uart uart; /** Register base address */ void *base; /** Register shift */ -- cgit v1.2.3-55-g7522 From 53a3befb692a34ef84047a0fe3320a0ec04d8d9d Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sat, 21 Jun 2025 23:13:58 +0100 Subject: [dwuart] Add a basic driver for the Synopsys DesignWare UART Signed-off-by: Michael Brown --- src/drivers/uart/dwuart.c | 120 +++++++++++++++++++++++++++++++++++++++++++++ src/include/ipxe/errfile.h | 1 + 2 files changed, 121 insertions(+) create mode 100644 src/drivers/uart/dwuart.c (limited to 'src/drivers') diff --git a/src/drivers/uart/dwuart.c b/src/drivers/uart/dwuart.c new file mode 100644 index 000000000..bf83afd80 --- /dev/null +++ b/src/drivers/uart/dwuart.c @@ -0,0 +1,120 @@ +/* + * Copyright (C) 2025 Michael Brown . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + * + * You can also choose to distribute this program under the terms of + * the Unmodified Binary Distribution Licence (as given in the file + * COPYING.UBDL), provided that you have satisfied its requirements. + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +/** @file + * + * DesignWare UART + * + */ + +#include +#include +#include +#include +#include + +/** + * Probe devicetree device + * + * @v dt Devicetree device + * @v offset Starting node offset + * @ret rc Return status code + */ +static int dwuart_probe ( struct dt_device *dt, unsigned int offset ) { + struct ns16550_uart *ns16550; + struct uart *uart; + uint32_t shift; + int rc; + + /* Allocate and initialise UART */ + uart = alloc_uart ( sizeof ( *ns16550 ) ); + if ( ! uart ) { + rc = -ENOMEM; + goto err_alloc; + } + uart->name = dt->name; + uart->op = &ns16550_operations; + ns16550 = uart->priv; + dt_set_drvdata ( dt, uart ); + + /* Map registers */ + ns16550->base = dt_ioremap ( dt, offset, 0, 0 ); + if ( ! ns16550->base ) { + rc = -ENODEV; + goto err_ioremap; + } + + /* Get register shift */ + if ( ( rc = fdt_u32 ( &sysfdt, offset, "reg-shift", &shift ) ) != 0 ) + shift = 0; + ns16550->shift = shift; + + /* Register UART */ + if ( ( rc = uart_register ( uart ) ) != 0 ) + goto err_register; + + return 0; + + uart_unregister ( uart ); + err_register: + iounmap ( ns16550->base ); + err_ioremap: + uart_nullify ( uart ); + uart_put ( uart ); + err_alloc: + return rc; +} + +/** + * Remove devicetree device + * + * @v dt Devicetree device + */ +static void dwuart_remove ( struct dt_device *dt ) { + struct uart *uart = dt_get_drvdata ( dt ); + struct ns16550_uart *ns16550 = uart->priv; + + /* Unregister UART */ + uart_unregister ( uart ); + + /* Free UART */ + iounmap ( ns16550->base ); + uart_nullify ( uart ); + uart_put ( uart ); +} + +/** DesignWare UART compatible model identifiers */ +static const char * dwuart_ids[] = { + "snps,dw-apb-uart", +}; + +/** DesignWare UART devicetree driver */ +struct dt_driver dwuart_driver __dt_driver = { + .name = "dwuart", + .ids = dwuart_ids, + .id_count = ( sizeof ( dwuart_ids ) / sizeof ( dwuart_ids[0] ) ), + .probe = dwuart_probe, + .remove = dwuart_remove, +}; diff --git a/src/include/ipxe/errfile.h b/src/include/ipxe/errfile.h index 1a39af43f..9eaa784fc 100644 --- a/src/include/ipxe/errfile.h +++ b/src/include/ipxe/errfile.h @@ -110,6 +110,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define ERRFILE_nvsvpd ( ERRFILE_DRIVER | 0x00140000 ) #define ERRFILE_uart ( ERRFILE_DRIVER | 0x00150000 ) #define ERRFILE_ns16550 ( ERRFILE_DRIVER | 0x00160000 ) +#define ERRFILE_dwuart ( ERRFILE_DRIVER | 0x00170000 ) #define ERRFILE_3c509 ( ERRFILE_DRIVER | 0x00200000 ) #define ERRFILE_bnx2 ( ERRFILE_DRIVER | 0x00210000 ) -- cgit v1.2.3-55-g7522 From 5d9f20bbd69408ad349e7ead0e72979f90c84e2d Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 23 Jun 2025 15:10:27 +0100 Subject: [dwuart] Add "ns16550a" compatible device ID Signed-off-by: Michael Brown --- src/drivers/uart/dwuart.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/drivers') diff --git a/src/drivers/uart/dwuart.c b/src/drivers/uart/dwuart.c index bf83afd80..540cde057 100644 --- a/src/drivers/uart/dwuart.c +++ b/src/drivers/uart/dwuart.c @@ -108,6 +108,7 @@ static void dwuart_remove ( struct dt_device *dt ) { /** DesignWare UART compatible model identifiers */ static const char * dwuart_ids[] = { "snps,dw-apb-uart", + "ns16550a", }; /** DesignWare UART devicetree driver */ -- cgit v1.2.3-55-g7522 From 0ed1dea7f4f5c5b2b7cd0130eb49c2c5c0b0ea42 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 23 Jun 2025 22:37:32 +0100 Subject: [uart] Wait for 16550 UART to become idle before modifying LCR Some implementations of 16550-compatible UARTs (e.g. the DesignWare UART) are known to ignore writes to the line control register while the transmitter is active. Wait for the transmitter to become empty before attempting to write to the line control register. Signed-off-by: Michael Brown --- src/drivers/uart/ns16550.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/drivers') diff --git a/src/drivers/uart/ns16550.c b/src/drivers/uart/ns16550.c index cf8c744c6..5455c68fb 100644 --- a/src/drivers/uart/ns16550.c +++ b/src/drivers/uart/ns16550.c @@ -131,6 +131,9 @@ static int ns16550_init ( struct uart *uart, unsigned int baud ) { if ( ns16550_read ( ns16550, NS16550_SCR ) != 0xae ) return -ENODEV; + /* Wait for UART to become idle before modifying LCR */ + ns16550_flush ( uart ); + /* Configure divisor and line control register, if applicable */ ns16550_write ( ns16550, NS16550_LCR, ( NS16550_LCR_8N1 | NS16550_LCR_DLAB ) ); -- cgit v1.2.3-55-g7522 From 9ada09c91966c42b49393307b326ff9b078ed448 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 23 Jun 2025 22:40:04 +0100 Subject: [dwuart] Read input clock frequency from the device tree The 16550 design includes a programmable 16-bit clock divider for an arbitrary input clock, requiring knowledge of the input clock frequency in order to calculate the divider value for a given baud rate. The 16550 UARTs in an x86 PC will always have a 1.8432 MHz input clock. Non-x86 systems may have other input clock frequencies. Define the input clock frequency as a property of a 16550 UART, and read the value from the device tree "clock-frequency" property. Signed-off-by: Michael Brown --- src/arch/x86/core/x86_uart.c | 1 + src/drivers/uart/dwuart.c | 8 ++++++++ src/drivers/uart/ns16550.c | 3 ++- src/include/ipxe/ns16550.h | 11 ++++++++--- 4 files changed, 19 insertions(+), 4 deletions(-) (limited to 'src/drivers') diff --git a/src/arch/x86/core/x86_uart.c b/src/arch/x86/core/x86_uart.c index a1d643a58..03809ff9b 100644 --- a/src/arch/x86/core/x86_uart.c +++ b/src/arch/x86/core/x86_uart.c @@ -37,6 +37,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define ISA_UART( NAME, BASE ) \ static struct ns16550_uart ns16550_ ## NAME = { \ .base = ( ( void * ) (BASE) ), \ + .clock = NS16550_CLK_DEFAULT, \ }; \ struct uart NAME = { \ .refcnt = REF_INIT ( ref_no_free ), \ diff --git a/src/drivers/uart/dwuart.c b/src/drivers/uart/dwuart.c index 540cde057..ce08e8ebf 100644 --- a/src/drivers/uart/dwuart.c +++ b/src/drivers/uart/dwuart.c @@ -46,6 +46,7 @@ static int dwuart_probe ( struct dt_device *dt, unsigned int offset ) { struct ns16550_uart *ns16550; struct uart *uart; uint32_t shift; + uint32_t clock; int rc; /* Allocate and initialise UART */ @@ -71,6 +72,13 @@ static int dwuart_probe ( struct dt_device *dt, unsigned int offset ) { shift = 0; ns16550->shift = shift; + /* Get clock rate */ + if ( ( rc = fdt_u32 ( &sysfdt, offset, "clock-frequency", + &clock ) ) != 0 ) { + clock = NS16550_CLK_DEFAULT; + } + ns16550->clock = clock; + /* Register UART */ if ( ( rc = uart_register ( uart ) ) != 0 ) goto err_register; diff --git a/src/drivers/uart/ns16550.c b/src/drivers/uart/ns16550.c index 5455c68fb..428771ab5 100644 --- a/src/drivers/uart/ns16550.c +++ b/src/drivers/uart/ns16550.c @@ -138,7 +138,8 @@ static int ns16550_init ( struct uart *uart, unsigned int baud ) { ns16550_write ( ns16550, NS16550_LCR, ( NS16550_LCR_8N1 | NS16550_LCR_DLAB ) ); if ( baud ) { - ns16550->divisor = ( NS16550_MAX_BAUD / baud ); + ns16550->divisor = ( ( ns16550->clock / baud ) / + NS16550_CLK_BIT ); dlm = ( ( ns16550->divisor >> 8 ) & 0xff ); dll = ( ( ns16550->divisor >> 0 ) & 0xff ); ns16550_write ( ns16550, NS16550_DLM, dlm ); diff --git a/src/include/ipxe/ns16550.h b/src/include/ipxe/ns16550.h index 6699205e2..693094866 100644 --- a/src/include/ipxe/ns16550.h +++ b/src/include/ipxe/ns16550.h @@ -73,19 +73,24 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /** Divisor latch (most significant byte) */ #define NS16550_DLM 0x01 -/** Maximum baud rate */ -#define NS16550_MAX_BAUD 115200 - /** A 16550-compatible UART */ struct ns16550_uart { /** Register base address */ void *base; /** Register shift */ unsigned int shift; + /** Input clock frequency */ + unsigned int clock; /** Baud rate divisor */ uint16_t divisor; }; +/** Post-division clock cycles per data bit */ +#define NS16550_CLK_BIT 16 + +/** Default input clock rate (1.8432 MHz) */ +#define NS16550_CLK_DEFAULT 1843200 + #include /** Dummy COM1 UART for non-x86 platforms -- cgit v1.2.3-55-g7522 From d0c02e0df8ae42b75b422f5df83c600a98d7cbc7 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 24 Jun 2025 13:40:50 +0100 Subject: [legacy] Allocate extra padding in receive buffers Allow for legacy drivers that include VLAN tags or CRCs within their received packets. Signed-off-by: Michael Brown --- src/drivers/net/legacy.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/drivers') diff --git a/src/drivers/net/legacy.c b/src/drivers/net/legacy.c index 73a80194f..cde8c02d5 100644 --- a/src/drivers/net/legacy.c +++ b/src/drivers/net/legacy.c @@ -42,7 +42,8 @@ static void legacy_poll ( struct net_device *netdev ) { struct nic *nic = netdev->priv; struct io_buffer *iobuf; - iobuf = alloc_iob ( ETH_FRAME_LEN ); + iobuf = alloc_iob ( ETH_FRAME_LEN + 4 /* possible VLAN */ + + 4 /* possible CRC */ ); if ( ! iobuf ) return; -- cgit v1.2.3-55-g7522 From 6ea800ab549823fc957902e85b587a7b8d3859de Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 24 Jun 2025 13:10:53 +0100 Subject: [legacy] Rename the global legacy NIC to "legacy_nic" We currently have contexts in which the local variable "nic" is a pointer to the global variable also called "nic". This complicates the creation of macros. Rename the global variable to "legacy_nic" to reduce pollution of the global namespace and to allow for the creation of macros referring to fields within this global variable. Signed-off-by: Michael Brown --- src/drivers/net/legacy.c | 20 +++++++++++--------- src/include/nic.h | 8 +++++--- 2 files changed, 16 insertions(+), 12 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/legacy.c b/src/drivers/net/legacy.c index cde8c02d5..3b208a28b 100644 --- a/src/drivers/net/legacy.c +++ b/src/drivers/net/legacy.c @@ -19,7 +19,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); -struct nic nic; +struct nic legacy_nic; static int legacy_registered = 0; @@ -86,6 +86,7 @@ int legacy_probe ( void *hwdev, int ( * probe ) ( struct nic *nic, void *hwdev ), void ( * disable ) ( struct nic *nic, void *hwdev ) ) { struct net_device *netdev; + struct nic *nic; int rc; if ( legacy_registered ) @@ -95,15 +96,16 @@ int legacy_probe ( void *hwdev, if ( ! netdev ) return -ENOMEM; netdev_init ( netdev, &legacy_operations ); - netdev->priv = &nic; - memset ( &nic, 0, sizeof ( nic ) ); + nic = &legacy_nic; + netdev->priv = nic; + memset ( nic, 0, sizeof ( *nic ) ); set_drvdata ( hwdev, netdev ); netdev->dev = dev; - nic.node_addr = netdev->hw_addr; - nic.irqno = dev->desc.irq; + nic->node_addr = netdev->hw_addr; + nic->irqno = dev->desc.irq; - if ( ! probe ( &nic, hwdev ) ) { + if ( ! probe ( nic, hwdev ) ) { rc = -ENODEV; goto err_probe; } @@ -113,7 +115,7 @@ int legacy_probe ( void *hwdev, * don't support interrupts; doing this allows the timer * interrupt to be used instead. */ - dev->desc.irq = nic.irqno; + dev->desc.irq = nic->irqno; if ( ( rc = register_netdev ( netdev ) ) != 0 ) goto err_register; @@ -123,13 +125,13 @@ int legacy_probe ( void *hwdev, /* Do not remove this message */ printf ( "WARNING: Using legacy NIC wrapper on %s\n", - netdev->ll_protocol->ntoa ( nic.node_addr ) ); + netdev->ll_protocol->ntoa ( nic->node_addr ) ); legacy_registered = 1; return 0; err_register: - disable ( &nic, hwdev ); + disable ( nic, hwdev ); err_probe: netdev_nullify ( netdev ); netdev_put ( netdev ); diff --git a/src/include/nic.h b/src/include/nic.h index 8e928beb4..678e23075 100644 --- a/src/include/nic.h +++ b/src/include/nic.h @@ -67,15 +67,17 @@ struct nic_operations { void ( *irq ) ( struct nic *, irq_action_t ); }; -extern struct nic nic; +extern struct nic legacy_nic; static inline int eth_poll ( int retrieve ) { - return nic.nic_op->poll ( &nic, retrieve ); + struct nic *nic = &legacy_nic; + return nic->nic_op->poll ( nic, retrieve ); } static inline void eth_transmit ( const char *dest, unsigned int type, unsigned int size, const void *packet ) { - nic.nic_op->transmit ( &nic, dest, type, size, packet ); + struct nic *nic = &legacy_nic; + nic->nic_op->transmit ( nic, dest, type, size, packet ); } /* -- cgit v1.2.3-55-g7522 From d3e10ebd354928d56ba660cd2ea14af1663702a2 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 24 Jun 2025 13:17:19 +0100 Subject: [legacy] Allocate legacy driver .bss-like segments at probe time Some legacy drivers use large static allocations for transmit and receive buffers. To avoid bloating the .bss segment, we currently implement these as a single common symbol named "_shared_bss" (which is permissible since only one legacy driver may be active at any one time). Switch to dynamic allocation of these .bss-like segments, to avoid the requirement for using common symbols. Signed-off-by: Michael Brown --- src/drivers/net/3c509-eisa.c | 2 +- src/drivers/net/3c509.c | 2 +- src/drivers/net/3c515.c | 4 ++-- src/drivers/net/3c529.c | 2 +- src/drivers/net/3c595.c | 2 +- src/drivers/net/amd8111e.c | 5 ++--- src/drivers/net/bnx2.c | 8 +++++--- src/drivers/net/cs89x0.c | 2 +- src/drivers/net/davicom.c | 7 ++++--- src/drivers/net/depca.c | 2 +- src/drivers/net/dmfe.c | 7 ++++--- src/drivers/net/eepro.c | 2 +- src/drivers/net/epic100.c | 7 ++++--- src/drivers/net/legacy.c | 33 +++++++++++++++++++++++++++------ src/drivers/net/ne2k_isa.c | 2 +- src/drivers/net/ns8390.c | 2 +- src/drivers/net/prism2_pci.c | 2 +- src/drivers/net/prism2_plx.c | 3 +-- src/drivers/net/sis900.c | 7 ++++--- src/drivers/net/smc9000.c | 2 +- src/drivers/net/sundance.c | 7 ++++--- src/drivers/net/tlan.c | 7 ++++--- src/drivers/net/tulip.c | 7 ++++--- src/drivers/net/w89c840.c | 7 ++++--- src/include/compiler.h | 22 ---------------------- src/include/nic.h | 27 ++++++++++++++++++++------- 26 files changed, 100 insertions(+), 80 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/3c509-eisa.c b/src/drivers/net/3c509-eisa.c index 81c60ee91..ada34a6b9 100644 --- a/src/drivers/net/3c509-eisa.c +++ b/src/drivers/net/3c509-eisa.c @@ -35,7 +35,7 @@ static struct eisa_device_id el3_eisa_adapters[] = { EISA_DRIVER ( el3_eisa_driver, el3_eisa_adapters ); DRIVER ( "3c509 (EISA)", nic_driver, eisa_driver, el3_eisa_driver, - el3_eisa_probe, el3_eisa_disable ); + el3_eisa_probe, el3_eisa_disable, no_fake_bss ); ISA_ROM ( "3c509-eisa","3c509 (EISA)" ); diff --git a/src/drivers/net/3c509.c b/src/drivers/net/3c509.c index 4326a835c..0f721315d 100644 --- a/src/drivers/net/3c509.c +++ b/src/drivers/net/3c509.c @@ -316,7 +316,7 @@ static int t509_probe ( struct t509_device *t509 ) { DBG ( "Adding 3c509 device %02x (I/O %04x)\n", t509->tag, t509->ioaddr ); return legacy_probe ( t509, legacy_t509_set_drvdata, &t509->dev, - legacy_t509_probe, legacy_t509_disable ); + legacy_t509_probe, legacy_t509_disable, 0 ); } /** diff --git a/src/drivers/net/3c515.c b/src/drivers/net/3c515.c index 1591e0617..353d45794 100644 --- a/src/drivers/net/3c515.c +++ b/src/drivers/net/3c515.c @@ -64,7 +64,6 @@ static void t3c515_wait(unsigned int nticks) /* TJL definations */ #define HZ 100 static int if_port; -static struct corkscrew_private *vp; /* Brought directly from 3c515.c by Becker */ #define CORKSCREW 1 @@ -237,6 +236,7 @@ struct corkscrew_private { full_bus_master_tx:1, full_bus_master_rx:1, /* Boomerang */ tx_full:1; }; +#define vp NIC_FAKE_BSS_PTR ( struct corkscrew_private ) /* The action to take with a media selection timer tick. Note that we deviate from the 3Com order by checking 10base2 before AUI. @@ -759,6 +759,6 @@ static struct isapnp_device_id t515_adapters[] = { ISAPNP_DRIVER ( t515_driver, t515_adapters ); DRIVER ( "3c515", nic_driver, isapnp_driver, t515_driver, - t515_probe, t515_disable ); + t515_probe, t515_disable, *vp ); ISA_ROM ( "3c515", "3c515 Fast EtherLink ISAPnP" ); diff --git a/src/drivers/net/3c529.c b/src/drivers/net/3c529.c index d68f28ec1..8b408f255 100644 --- a/src/drivers/net/3c529.c +++ b/src/drivers/net/3c529.c @@ -49,7 +49,7 @@ static struct mca_device_id el3_mca_adapters[] = { MCA_DRIVER ( t529_driver, el3_mca_adapters ); DRIVER ( "3c529", nic_driver, mca_driver, t529_driver, - t529_probe, t529_disable ); + t529_probe, t529_disable, no_fake_bss ); ISA_ROM( "3c529", "3c529 == MCA 3c509" ); diff --git a/src/drivers/net/3c595.c b/src/drivers/net/3c595.c index 7792c17d6..58cfc41ae 100644 --- a/src/drivers/net/3c595.c +++ b/src/drivers/net/3c595.c @@ -541,7 +541,7 @@ PCI_ROM(0x10b7, 0x9805, "3c9805-1", "3Com9805", 0), /* Dual Port Server PCI_DRIVER ( t595_driver, t595_nics, PCI_NO_CLASS ); DRIVER ( "3C595", nic_driver, pci_driver, t595_driver, - t595_probe, t595_disable ); + t595_probe, t595_disable, no_fake_bss ); /* * Local variables: diff --git a/src/drivers/net/amd8111e.c b/src/drivers/net/amd8111e.c index 213c4f44b..c21c11835 100644 --- a/src/drivers/net/amd8111e.c +++ b/src/drivers/net/amd8111e.c @@ -105,8 +105,7 @@ struct amd8111e_priv { struct nic *nic; void *mmio; }; - -static struct amd8111e_priv amd8111e; +#define amd8111e NIC_FAKE_BSS ( struct amd8111e_priv ) /******************************************************** @@ -683,7 +682,7 @@ static struct pci_device_id amd8111e_nics[] = { PCI_DRIVER ( amd8111e_driver, amd8111e_nics, PCI_NO_CLASS ); DRIVER ( "AMD8111E", nic_driver, pci_driver, amd8111e_driver, - amd8111e_probe, amd8111e_disable ); + amd8111e_probe, amd8111e_disable, amd8111e ); /* * Local variables: diff --git a/src/drivers/net/bnx2.c b/src/drivers/net/bnx2.c index 186cc17d4..ae94c9bed 100644 --- a/src/drivers/net/bnx2.c +++ b/src/drivers/net/bnx2.c @@ -36,13 +36,14 @@ FILE_LICENCE ( GPL_ANY ); /* The bnx2 seems to be picky about the alignment of the receive buffers * and possibly the status block. */ -static struct bss { +struct bss { struct tx_bd tx_desc_ring[TX_DESC_CNT]; struct rx_bd rx_desc_ring[RX_DESC_CNT]; unsigned char rx_buf[RX_BUF_CNT][RX_BUF_SIZE]; struct status_block status_blk; struct statistics_block stats_blk; -} bnx2_bss; +}; +#define bnx2_bss NIC_FAKE_BSS ( struct bss ) static struct bnx2 bnx2; @@ -2686,7 +2687,8 @@ static struct pci_device_id bnx2_nics[] = { PCI_DRIVER ( bnx2_driver, bnx2_nics, PCI_NO_CLASS ); -DRIVER ( "BNX2", nic_driver, pci_driver, bnx2_driver, bnx2_probe, bnx2_remove ); +DRIVER ( "BNX2", nic_driver, pci_driver, bnx2_driver, + bnx2_probe, bnx2_remove, bnx2_bss ); /* static struct pci_driver bnx2_driver __pci_driver = { diff --git a/src/drivers/net/cs89x0.c b/src/drivers/net/cs89x0.c index 17b7157a1..fc311a18a 100644 --- a/src/drivers/net/cs89x0.c +++ b/src/drivers/net/cs89x0.c @@ -725,7 +725,7 @@ ISA_DRIVER ( cs89x0_driver, cs89x0_probe_addrs, cs89x0_probe_addr, ISAPNP_VENDOR('C','S','C'), 0x0007 ); DRIVER ( "cs89x0", nic_driver, isa_driver, cs89x0_driver, - cs89x0_probe, cs89x0_disable ); + cs89x0_probe, cs89x0_disable, no_fake_bss ); ISA_ROM ( "cs89x0", "Crystal Semiconductor CS89x0" ); diff --git a/src/drivers/net/davicom.c b/src/drivers/net/davicom.c index 307ae9811..2b063ad1b 100644 --- a/src/drivers/net/davicom.c +++ b/src/drivers/net/davicom.c @@ -134,12 +134,13 @@ static unsigned long ioaddr; /* transmit descriptor and buffer */ #define NTXD 2 #define NRXD 4 -struct { +struct davicom_bss { struct txdesc txd[NTXD] __attribute__ ((aligned(4))); unsigned char txb[BUFLEN] __attribute__ ((aligned(4))); struct rxdesc rxd[NRXD] __attribute__ ((aligned(4))); unsigned char rxb[NRXD * BUFLEN] __attribute__ ((aligned(4))); -} davicom_bufs __shared; +}; +#define davicom_bufs NIC_FAKE_BSS ( struct davicom_bss ) #define txd davicom_bufs.txd #define txb davicom_bufs.txb #define rxd davicom_bufs.rxd @@ -698,7 +699,7 @@ PCI_ROM(0x1282, 0x9132, "davicom9132", "Davicom 9132", 0), /* Needs probably som PCI_DRIVER ( davicom_driver, davicom_nics, PCI_NO_CLASS ); DRIVER ( "DAVICOM", nic_driver, pci_driver, davicom_driver, - davicom_probe, davicom_disable ); + davicom_probe, davicom_disable, davicom_bufs ); /* * Local variables: diff --git a/src/drivers/net/depca.c b/src/drivers/net/depca.c index 30e2fcb0a..335928667 100644 --- a/src/drivers/net/depca.c +++ b/src/drivers/net/depca.c @@ -789,7 +789,7 @@ ISA_DRIVER ( depca_driver, depca_probe_addrs, depca_probe1, GENERIC_ISAPNP_VENDOR, 0x80f7 ); DRIVER ( "depce", nic_driver, isa_driver, depca_driver, - depca_probe, depca_disable ); + depca_probe, depca_disable, no_fake_bss ); ISA_ROM ( "depca", "Digital DE100 and DE200" ); diff --git a/src/drivers/net/dmfe.c b/src/drivers/net/dmfe.c index a76dd792d..2ed108e8c 100644 --- a/src/drivers/net/dmfe.c +++ b/src/drivers/net/dmfe.c @@ -209,14 +209,15 @@ static u8 SF_mode; /* Special Function: 1:VLAN, 2:RX Flow Control /********************************************** * Descriptor Ring and Buffer defination ***********************************************/ -struct { +struct dmfe_bss { struct tx_desc txd[TX_DESC_CNT] __attribute__ ((aligned(32))); unsigned char txb[TX_BUF_ALLOC * TX_DESC_CNT] __attribute__ ((aligned(32))); struct rx_desc rxd[RX_DESC_CNT] __attribute__ ((aligned(32))); unsigned char rxb[RX_ALLOC_SIZE * RX_DESC_CNT] __attribute__ ((aligned(32))); -} dmfe_bufs __shared; +}; +#define dmfe_bufs NIC_FAKE_BSS ( struct dmfe_bss ) #define txd dmfe_bufs.txd #define txb dmfe_bufs.txb #define rxd dmfe_bufs.rxd @@ -1217,7 +1218,7 @@ static struct pci_device_id dmfe_nics[] = { PCI_DRIVER ( dmfe_driver, dmfe_nics, PCI_NO_CLASS ); DRIVER ( "DMFE/PCI", nic_driver, pci_driver, dmfe_driver, - dmfe_probe, dmfe_disable ); + dmfe_probe, dmfe_disable, dmfe_bufs ); /* * Local variables: diff --git a/src/drivers/net/eepro.c b/src/drivers/net/eepro.c index 97b4c4061..3863553fa 100644 --- a/src/drivers/net/eepro.c +++ b/src/drivers/net/eepro.c @@ -635,7 +635,7 @@ ISA_DRIVER ( eepro_driver, eepro_probe_addrs, eepro_probe1, GENERIC_ISAPNP_VENDOR, 0x828a ); DRIVER ( "eepro", nic_driver, isa_driver, eepro_driver, - eepro_probe, eepro_disable ); + eepro_probe, eepro_disable, no_fake_bss ); ISA_ROM ( "eepro", "Intel Etherexpress Pro/10" ); diff --git a/src/drivers/net/epic100.c b/src/drivers/net/epic100.c index 01c0c43c9..03b394e6b 100644 --- a/src/drivers/net/epic100.c +++ b/src/drivers/net/epic100.c @@ -86,14 +86,15 @@ static unsigned int cur_rx, cur_tx; /* The next free ring entry */ static unsigned short eeprom[64]; #endif static signed char phys[4]; /* MII device addresses. */ -struct { +struct epic100_bss { struct epic_rx_desc rx_ring[RX_RING_SIZE] __attribute__ ((aligned(4))); struct epic_tx_desc tx_ring[TX_RING_SIZE] __attribute__ ((aligned(4))); unsigned char rx_packet[PKT_BUF_SZ * RX_RING_SIZE]; unsigned char tx_packet[PKT_BUF_SZ * TX_RING_SIZE]; -} epic100_bufs __shared; +}; +#define epic100_bufs NIC_FAKE_BSS ( struct epic100_bss ) #define rx_ring epic100_bufs.rx_ring #define tx_ring epic100_bufs.tx_ring #define rx_packet epic100_bufs.rx_packet @@ -525,7 +526,7 @@ PCI_ROM(0x10b8, 0x0006, "smc-83c175", "SMC EPIC/C 83c175", 0), PCI_DRIVER ( epic100_driver, epic100_nics, PCI_NO_CLASS ); DRIVER ( "EPIC100", nic_driver, pci_driver, epic100_driver, - epic100_probe, epic100_disable ); + epic100_probe, epic100_disable, epic100_bufs ); /* * Local variables: diff --git a/src/drivers/net/legacy.c b/src/drivers/net/legacy.c index 3b208a28b..b86f77fc8 100644 --- a/src/drivers/net/legacy.c +++ b/src/drivers/net/legacy.c @@ -84,17 +84,22 @@ int legacy_probe ( void *hwdev, void ( * set_drvdata ) ( void *hwdev, void *priv ), struct device *dev, int ( * probe ) ( struct nic *nic, void *hwdev ), - void ( * disable ) ( struct nic *nic, void *hwdev ) ) { + void ( * disable ) ( struct nic *nic, void *hwdev ), + size_t fake_bss_len ) { struct net_device *netdev; struct nic *nic; int rc; - if ( legacy_registered ) - return -EBUSY; - + if ( legacy_registered ) { + rc = -EBUSY; + goto err_registered; + } + netdev = alloc_etherdev ( 0 ); - if ( ! netdev ) - return -ENOMEM; + if ( ! netdev ) { + rc = -ENOMEM; + goto err_alloc; + } netdev_init ( netdev, &legacy_operations ); nic = &legacy_nic; netdev->priv = nic; @@ -105,6 +110,15 @@ int legacy_probe ( void *hwdev, nic->node_addr = netdev->hw_addr; nic->irqno = dev->desc.irq; + if ( fake_bss_len ) { + nic->fake_bss = malloc_phys ( fake_bss_len, PAGE_SIZE ); + if ( ! nic->fake_bss ) { + rc = -ENOMEM; + goto err_fake_bss; + } + } + nic->fake_bss_len = fake_bss_len; + if ( ! probe ( nic, hwdev ) ) { rc = -ENODEV; goto err_probe; @@ -133,8 +147,13 @@ int legacy_probe ( void *hwdev, err_register: disable ( nic, hwdev ); err_probe: + if ( fake_bss_len ) + free_phys ( nic->fake_bss, fake_bss_len ); + err_fake_bss: netdev_nullify ( netdev ); netdev_put ( netdev ); + err_alloc: + err_registered: return rc; } @@ -146,6 +165,8 @@ void legacy_remove ( void *hwdev, unregister_netdev ( netdev ); disable ( nic, hwdev ); + if ( nic->fake_bss_len ) + free_phys ( nic->fake_bss, nic->fake_bss_len ); netdev_nullify ( netdev ); netdev_put ( netdev ); legacy_registered = 0; diff --git a/src/drivers/net/ne2k_isa.c b/src/drivers/net/ne2k_isa.c index a923fd3c5..8c8188af3 100644 --- a/src/drivers/net/ne2k_isa.c +++ b/src/drivers/net/ne2k_isa.c @@ -370,6 +370,6 @@ ISA_DRIVER ( ne_driver, ne_probe_addrs, ne_probe1, GENERIC_ISAPNP_VENDOR, 0x0600 ); DRIVER ( "ne", nic_driver, isapnp_driver, ne_driver, - ne_probe, ne_disable ); + ne_probe, ne_disable, no_fake_bss ); ISA_ROM("ne","NE1000/2000 and clones"); diff --git a/src/drivers/net/ns8390.c b/src/drivers/net/ns8390.c index a81ec6eea..bc94aabe3 100644 --- a/src/drivers/net/ns8390.c +++ b/src/drivers/net/ns8390.c @@ -1022,7 +1022,7 @@ PCI_ROM(0x8e2e, 0x3000, "ktiet32p2", "KTI ET32P2", 0), PCI_DRIVER ( nepci_driver, nepci_nics, PCI_NO_CLASS ); DRIVER ( "NE2000/PCI", nic_driver, pci_driver, nepci_driver, - nepci_probe, ns8390_disable ); + nepci_probe, ns8390_disable, no_fake_bss ); #endif /* INCLUDE_NS8390 */ diff --git a/src/drivers/net/prism2_pci.c b/src/drivers/net/prism2_pci.c index 9940f76a7..128bdedc1 100644 --- a/src/drivers/net/prism2_pci.c +++ b/src/drivers/net/prism2_pci.c @@ -55,7 +55,7 @@ PCI_ROM(0x1260, 0x3873, "prism2_pci", "Harris Semiconductor Prism2.5 clone", 0), PCI_DRIVER ( prism2_pci_driver, prism2_pci_nics, PCI_NO_CLASS ); DRIVER ( "Prism2/PCI", nic_driver, pci_driver, prism2_pci_driver, - prism2_pci_probe, prism2_pci_disable ); + prism2_pci_probe, prism2_pci_disable, no_fake_bss ); /* * Local variables: diff --git a/src/drivers/net/prism2_plx.c b/src/drivers/net/prism2_plx.c index f3200e89c..dac63ba9f 100644 --- a/src/drivers/net/prism2_plx.c +++ b/src/drivers/net/prism2_plx.c @@ -119,9 +119,8 @@ PCI_ROM(0xec80, 0xec00, "f5d6000", "Belkin F5D6000", 0), PCI_DRIVER ( prism2_plx_driver, prism2_plx_nics, PCI_NO_CLASS ); - DRIVER ( "Prism2/PLX", nic_driver, pci_driver, prism2_plx_driver, - prism2_plx_probe, prism2_plx_disable ); + prism2_plx_probe, prism2_plx_disable, no_fake_bss ); /* * Local variables: diff --git a/src/drivers/net/sis900.c b/src/drivers/net/sis900.c index c8fd3e9b5..59deb8df9 100644 --- a/src/drivers/net/sis900.c +++ b/src/drivers/net/sis900.c @@ -65,12 +65,13 @@ static unsigned int cur_phy; static unsigned int cur_rx; -struct { +struct sis900_bss { BufferDesc txd; BufferDesc rxd[NUM_RX_DESC]; unsigned char txb[TX_BUF_SIZE]; unsigned char rxb[NUM_RX_DESC * RX_BUF_SIZE]; -} sis900_bufs __shared; +}; +#define sis900_bufs NIC_FAKE_BSS ( struct sis900_bss ) #define txd sis900_bufs.txd #define rxd sis900_bufs.rxd #define txb sis900_bufs.txb @@ -1291,7 +1292,7 @@ PCI_ROM(0x1039, 0x7016, "sis7016", "SIS7016", 0), PCI_DRIVER ( sis900_driver, sis900_nics, PCI_NO_CLASS ); DRIVER ( "SIS900", nic_driver, pci_driver, sis900_driver, - sis900_probe, sis900_disable ); + sis900_probe, sis900_disable, sis900_bufs ); /* * Local variables: diff --git a/src/drivers/net/smc9000.c b/src/drivers/net/smc9000.c index c9762d580..420aca9bd 100644 --- a/src/drivers/net/smc9000.c +++ b/src/drivers/net/smc9000.c @@ -939,7 +939,7 @@ ISA_DRIVER ( smc9000_driver, smc9000_probe_addrs, smc9000_probe_addr, GENERIC_ISAPNP_VENDOR, 0x8228 ); DRIVER ( "SMC9000", nic_driver, isa_driver, smc9000_driver, - smc9000_probe, smc9000_disable ); + smc9000_probe, smc9000_disable, no_fake_bss ); ISA_ROM ( "smc9000", "SMC9000" ); diff --git a/src/drivers/net/sundance.c b/src/drivers/net/sundance.c index 0439c983f..964365ef6 100644 --- a/src/drivers/net/sundance.c +++ b/src/drivers/net/sundance.c @@ -233,10 +233,11 @@ static struct netdev_desc rx_ring[RX_RING_SIZE]; /* Create a static buffer of size PKT_BUF_SZ for each RX and TX descriptor. All descriptors point to a part of this buffer */ -struct { +struct sundance_bss { unsigned char txb[PKT_BUF_SZ * TX_RING_SIZE]; unsigned char rxb[RX_RING_SIZE * PKT_BUF_SZ]; -} rx_tx_buf __shared; +}; +#define rx_tx_buf NIC_FAKE_BSS ( struct sundance_bss ) #define rxb rx_tx_buf.rxb #define txb rx_tx_buf.txb @@ -888,7 +889,7 @@ static struct pci_device_id sundance_nics[] = { PCI_DRIVER ( sundance_driver, sundance_nics, PCI_NO_CLASS ); DRIVER ( "SUNDANCE/PCI", nic_driver, pci_driver, sundance_driver, - sundance_probe, sundance_disable ); + sundance_probe, sundance_disable, rx_tx_buf ); /* * Local variables: diff --git a/src/drivers/net/tlan.c b/src/drivers/net/tlan.c index 245766a87..01193006f 100644 --- a/src/drivers/net/tlan.c +++ b/src/drivers/net/tlan.c @@ -179,12 +179,13 @@ struct TLanList { } buffer[TLAN_BUFFERS_PER_LIST]; }; -struct { +struct tlan_bss { struct TLanList tx_ring[TLAN_NUM_TX_LISTS]; unsigned char txb[TLAN_MAX_FRAME_SIZE * TLAN_NUM_TX_LISTS]; struct TLanList rx_ring[TLAN_NUM_RX_LISTS]; unsigned char rxb[TLAN_MAX_FRAME_SIZE * TLAN_NUM_RX_LISTS]; -} tlan_buffers __shared; +}; +#define tlan_buffers NIC_FAKE_BSS ( struct tlan_bss ) #define tx_ring tlan_buffers.tx_ring #define txb tlan_buffers.txb #define rx_ring tlan_buffers.rx_ring @@ -1715,7 +1716,7 @@ static struct pci_device_id tlan_nics[] = { PCI_DRIVER ( tlan_driver, tlan_nics, PCI_NO_CLASS ); DRIVER ( "TLAN/PCI", nic_driver, pci_driver, tlan_driver, - tlan_probe, tlan_disable ); + tlan_probe, tlan_disable, tlan_buffers ); /* * Local variables: diff --git a/src/drivers/net/tulip.c b/src/drivers/net/tulip.c index c01bc208e..1030e3698 100644 --- a/src/drivers/net/tulip.c +++ b/src/drivers/net/tulip.c @@ -426,13 +426,14 @@ struct tulip_private { #define TX_RING_SIZE 2 #define RX_RING_SIZE 4 -struct { +struct tulip_bss { struct tulip_tx_desc tx_ring[TX_RING_SIZE]; unsigned char txb[BUFLEN]; struct tulip_rx_desc rx_ring[RX_RING_SIZE]; unsigned char rxb[RX_RING_SIZE * BUFLEN]; struct tulip_private tpx; -} tulip_bss __shared __attribute__ ((aligned(4))); +}; +#define tulip_bss NIC_FAKE_BSS ( struct tulip_bss ) #define tx_ring tulip_bss.tx_ring #define txb tulip_bss.txb #define rx_ring tulip_bss.rx_ring @@ -1958,7 +1959,7 @@ PCI_ROM(0x8086, 0x0039, "intel21145", "Intel Tulip", 0), PCI_DRIVER ( tulip_driver, tulip_nics, PCI_NO_CLASS ); DRIVER ( "Tulip", nic_driver, pci_driver, tulip_driver, - tulip_probe, tulip_disable ); + tulip_probe, tulip_disable, tulip_bss ); /* * Local variables: diff --git a/src/drivers/net/w89c840.c b/src/drivers/net/w89c840.c index 0c222214e..33a6658d2 100644 --- a/src/drivers/net/w89c840.c +++ b/src/drivers/net/w89c840.c @@ -254,10 +254,11 @@ static struct winbond_private static int ioaddr; static unsigned short eeprom [0x40]; -struct { +struct w89c840_bss { char rx_packet[PKT_BUF_SZ * RX_RING_SIZE]; char tx_packet[PKT_BUF_SZ * TX_RING_SIZE]; -} w89c840_buf __shared; +}; +#define w89c840_buf NIC_FAKE_BSS ( struct w89c840_bss ) static int eeprom_read(long ioaddr, int location); static int mdio_read(int base_address, int phy_id, int location); @@ -956,7 +957,7 @@ static void init_ring(void) DRIVER ( "W89C840F", nic_driver, pci_driver, w89c840_driver, - w89c840_probe, w89c840_disable ); + w89c840_probe, w89c840_disable, w89c840_buf ); /* * Local variables: diff --git a/src/include/compiler.h b/src/include/compiler.h index ec03f6f96..f8e948829 100644 --- a/src/include/compiler.h +++ b/src/include/compiler.h @@ -623,28 +623,6 @@ char __debug_disable(OBJECT) = ( DBGLVL_MAX & ~DBGLVL_DFLT ); */ #define inline inline __attribute__ (( no_instrument_function )) -/** - * Shared data. - * - * To save space in the binary when multiple-driver images are - * compiled, uninitialised data areas can be shared between drivers. - * This will typically be used to share statically-allocated receive - * and transmit buffers between drivers. - * - * Use as e.g. - * - * @code - * - * struct { - * char rx_buf[NUM_RX_BUF][RX_BUF_SIZE]; - * char tx_buf[TX_BUF_SIZE]; - * } my_static_data __shared; - * - * @endcode - * - */ -#define __shared __asm__ ( "_shared_bss" ) __aligned - #endif /* ASSEMBLY */ /** @} */ diff --git a/src/include/nic.h b/src/include/nic.h index 678e23075..779d1d394 100644 --- a/src/include/nic.h +++ b/src/include/nic.h @@ -57,8 +57,14 @@ struct nic { unsigned int mbps; duplex_t duplex; void *priv_data; /* driver private data */ + void *fake_bss; + size_t fake_bss_len; }; +#define NIC_FAKE_BSS_PTR( type ) ( ( type * ) legacy_nic.fake_bss ) +#define NIC_FAKE_BSS( type ) ( * NIC_FAKE_BSS_PTR ( type ) ) +extern struct {} no_fake_bss; + struct nic_operations { int ( *connect ) ( struct nic * ); int ( *poll ) ( struct nic *, int retrieve ); @@ -90,7 +96,8 @@ extern int legacy_probe ( void *hwdev, void ( * set_drvdata ) ( void *hwdev, void *priv ), struct device *dev, int ( * probe ) ( struct nic *nic, void *hwdev ), - void ( * disable ) ( struct nic *nic, void *hwdev )); + void ( * disable ) ( struct nic *nic, void *hwdev ), + size_t fake_bss_len ); void legacy_remove ( void *hwdev, void * ( * get_drvdata ) ( void *hwdev ), void ( * disable ) ( struct nic *nic, void *hwdev ) ); @@ -210,7 +217,8 @@ static inline void * legacy_isa_get_drvdata ( void *hwdev ) { } #undef DRIVER -#define DRIVER(_name_text,_unused2,_unused3,_name,_probe,_disable) \ +#define DRIVER( _name_text, _unused2, _unused3, _name, _probe, _disable, \ + _fake_bss ) \ static __attribute__ (( unused )) const char \ _name ## _text[] = _name_text; \ static inline int \ @@ -225,7 +233,8 @@ static inline void * legacy_isa_get_drvdata ( void *hwdev ) { _name ## _pci_legacy_probe ( struct pci_device *pci ) { \ return legacy_probe ( pci, legacy_pci_set_drvdata, \ &pci->dev, _name ## _probe, \ - _name ## _disable ); \ + _name ## _disable, \ + sizeof ( _fake_bss ) ); \ } \ static inline void \ _name ## _pci_legacy_remove ( struct pci_device *pci ) { \ @@ -237,7 +246,8 @@ static inline void * legacy_isa_get_drvdata ( void *hwdev ) { const struct isapnp_device_id *id __unused ) { \ return legacy_probe ( isapnp, legacy_isapnp_set_drvdata, \ &isapnp->dev, _name ## _probe, \ - _name ## _disable ); \ + _name ## _disable, \ + sizeof ( _fake_bss ) ); \ } \ static inline void \ _name ## _isapnp_legacy_remove ( struct isapnp_device *isapnp ) { \ @@ -249,7 +259,8 @@ static inline void * legacy_isa_get_drvdata ( void *hwdev ) { const struct eisa_device_id *id __unused ) { \ return legacy_probe ( eisa, legacy_eisa_set_drvdata, \ &eisa->dev, _name ## _probe, \ - _name ## _disable ); \ + _name ## _disable, \ + sizeof ( _fake_bss ) ); \ } \ static inline void \ _name ## _eisa_legacy_remove ( struct eisa_device *eisa ) { \ @@ -261,7 +272,8 @@ static inline void * legacy_isa_get_drvdata ( void *hwdev ) { const struct mca_device_id *id __unused ) { \ return legacy_probe ( mca, legacy_mca_set_drvdata, \ &mca->dev, _name ## _probe, \ - _name ## _disable ); \ + _name ## _disable, \ + sizeof ( _fake_bss ) ); \ } \ static inline void \ _name ## _mca_legacy_remove ( struct mca_device *mca ) { \ @@ -272,7 +284,8 @@ static inline void * legacy_isa_get_drvdata ( void *hwdev ) { _name ## _isa_legacy_probe ( struct isa_device *isa ) { \ return legacy_probe ( isa, legacy_isa_set_drvdata, \ &isa->dev, _name ## _probe, \ - _name ## _disable ); \ + _name ## _disable, \ + sizeof ( _fake_bss ) ); \ } \ static inline void \ _name ## _isa_legacy_remove ( struct isa_device *isa ) { \ -- cgit v1.2.3-55-g7522 From 54392f0d70b54209bd074528f8cfcf33743e097f Mon Sep 17 00:00:00 2001 From: Joseph Wong Date: Wed, 25 Jun 2025 14:05:33 +0100 Subject: [bnxt] Increase Tx descriptors Increase TX and CMP descriptor counts. Signed-off-by: Joseph Wong --- src/drivers/net/bnxt/bnxt.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/bnxt/bnxt.h b/src/drivers/net/bnxt/bnxt.h index 1d5fc8df1..4d8bdc7f2 100644 --- a/src/drivers/net/bnxt/bnxt.h +++ b/src/drivers/net/bnxt/bnxt.h @@ -145,8 +145,8 @@ #define DEFAULT_NUMBER_OF_STAT_CTXS 0x01 #define NUM_RX_BUFFERS 8 #define MAX_RX_DESC_CNT 16 -#define MAX_TX_DESC_CNT 16 -#define MAX_CQ_DESC_CNT 64 +#define MAX_TX_DESC_CNT 64 +#define MAX_CQ_DESC_CNT 128 #define TX_RING_BUFFER_SIZE (MAX_TX_DESC_CNT * sizeof(struct tx_bd_short)) #define RX_RING_BUFFER_SIZE \ (MAX_RX_DESC_CNT * sizeof(struct rx_prod_pkt_bd)) -- cgit v1.2.3-55-g7522 From 126366ac47920ac5ea4ec1a1a4e5863ea3e612a3 Mon Sep 17 00:00:00 2001 From: Joseph Wong Date: Thu, 26 Jun 2025 15:37:05 -0700 Subject: [bnxt] Remove VLAN stripping logic Remove logic that programs the hardware to strip out VLAN from RX packets. Do not drop packets due to VLAN mismatch and allow the upper layer to decide whether to discard the packets. Signed-off-by: Joseph Wong --- src/drivers/net/bnxt/bnxt.c | 92 +---------------------------------------- src/drivers/net/bnxt/bnxt.h | 1 - src/drivers/net/bnxt/bnxt_dbg.h | 12 +----- 3 files changed, 3 insertions(+), 102 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/bnxt/bnxt.c b/src/drivers/net/bnxt/bnxt.c index 233cc46a2..f3db30db5 100644 --- a/src/drivers/net/bnxt/bnxt.c +++ b/src/drivers/net/bnxt/bnxt.c @@ -284,51 +284,6 @@ static u16 bnxt_get_pkt_vlan ( char *src ) return 0; } -static u16 bnxt_get_rx_vlan ( struct rx_pkt_cmpl *rx_cmp, struct rx_pkt_cmpl_hi *rx_cmp_hi ) -{ - struct rx_pkt_v3_cmpl *rx_cmp_v3 = ( struct rx_pkt_v3_cmpl * )rx_cmp; - struct rx_pkt_v3_cmpl_hi *rx_cmp_hi_v3 = ( struct rx_pkt_v3_cmpl_hi * )rx_cmp_hi; - u16 rx_vlan; - - /* Get VLAN ID from RX completion ring */ - if ( ( rx_cmp_v3->flags_type & RX_PKT_V3_CMPL_TYPE_MASK ) == - RX_PKT_V3_CMPL_TYPE_RX_L2_V3 ) { - if ( rx_cmp_hi_v3->flags2 & RX_PKT_V3_CMPL_HI_FLAGS2_META_FORMAT_ACT_REC_PTR ) - rx_vlan = ( rx_cmp_hi_v3->metadata0 & - RX_PKT_V3_CMPL_HI_METADATA0_VID_MASK ); - else - rx_vlan = 0; - } else { - if ( rx_cmp_hi->flags2 & RX_PKT_CMPL_FLAGS2_META_FORMAT_VLAN ) - rx_vlan = ( rx_cmp_hi->metadata & - RX_PKT_CMPL_METADATA_VID_MASK ); - else - rx_vlan = 0; - } - - return rx_vlan; -} - -int bnxt_vlan_drop ( struct bnxt *bp, u16 rx_vlan ) -{ - if ( rx_vlan ) { - if ( bp->vlan_tx ) { - if ( rx_vlan == bp->vlan_tx ) - return 0; - } else { - if ( rx_vlan == bp->vlan_id ) - return 0; - if ( rx_vlan && !bp->vlan_id ) - return 0; - } - } else { - if ( !bp->vlan_tx && !bp->vlan_id ) - return 0; - } - - return 1; -} - static inline u32 bnxt_tx_avail ( struct bnxt *bp ) { u32 avail; @@ -461,7 +416,7 @@ u8 bnxt_rx_drop ( struct bnxt *bp, struct io_buffer *iob, struct rx_pkt_v3_cmpl *rx_cmp_v3 = ( struct rx_pkt_v3_cmpl * )rx_cmp; struct rx_pkt_v3_cmpl_hi *rx_cmp_hi_v3 = ( struct rx_pkt_v3_cmpl_hi * )rx_cmp_hi; u8 *rx_buf = ( u8 * )iob->data; - u16 err_flags, rx_vlan; + u16 err_flags; u8 ignore_chksum_err = 0; int i; @@ -489,17 +444,8 @@ u8 bnxt_rx_drop ( struct bnxt *bp, struct io_buffer *iob, return 2; } - rx_vlan = bnxt_get_rx_vlan ( rx_cmp, rx_cmp_hi ); - dbg_rx_vlan ( bp, rx_cmp_hi->metadata, rx_cmp_hi->flags2, rx_vlan ); - if ( bnxt_vlan_drop ( bp, rx_vlan ) ) { - bp->rx.drop_vlan++; - return 3; - } iob_put ( iob, rx_len ); - if ( rx_vlan ) - bnxt_add_vlan ( iob, rx_vlan ); - bp->rx.good++; return 0; } @@ -1386,40 +1332,6 @@ static int bnxt_get_link_speed ( struct bnxt *bp ) return STATUS_SUCCESS; } -static int bnxt_get_vlan ( struct bnxt *bp ) -{ - u32 *ptr32 = ( u32 * ) DMA_DMA_ADDR ( bp ); - - /* If VF is set to TRUE, Do not issue this command */ - if ( bp->vf ) - return STATUS_SUCCESS; - - if ( ! ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P7 ) ) ) { - test_if ( bnxt_hwrm_nvm_get_variable_req ( bp, 1, - ( u16 )FUNC_CFG_PRE_BOOT_MBA_VLAN_NUM, 1, - ( u16 )bp->ordinal_value ) != STATUS_SUCCESS ) - return STATUS_FAILURE; - - bp->mba_cfg2 = SET_MBA ( *ptr32, VLAN_MASK, VLAN_SHIFT ); - test_if ( bnxt_hwrm_nvm_get_variable_req ( bp, 16, - ( u16 )FUNC_CFG_PRE_BOOT_MBA_VLAN_VALUE_NUM, 1, - ( u16 )bp->ordinal_value ) != STATUS_SUCCESS ) - return STATUS_FAILURE; - - bp->mba_cfg2 |= SET_MBA ( *ptr32, VLAN_VALUE_MASK, VLAN_VALUE_SHIFT ); - if ( bp->mba_cfg2 & FUNC_CFG_PRE_BOOT_MBA_VLAN_ENABLED ) - bp->vlan_id = bp->mba_cfg2 & VLAN_VALUE_MASK; - else - bp->vlan_id = 0; - - if ( bp->mba_cfg2 & FUNC_CFG_PRE_BOOT_MBA_VLAN_ENABLED ) - DBGP ( "VLAN MBA Enabled ( %d )\n", - ( bp->mba_cfg2 & VLAN_VALUE_MASK ) ); - - } - return STATUS_SUCCESS; -} - static int bnxt_hwrm_backing_store_qcfg ( struct bnxt *bp ) { u16 cmd_len = ( u16 )sizeof ( struct hwrm_func_backing_store_qcfg_input ); @@ -2045,7 +1957,6 @@ static int bnxt_hwrm_vnic_cfg ( struct bnxt *bp ) req->dflt_ring_grp = bp->ring_grp_id; } - req->flags = VNIC_CFG_REQ_FLAGS_VLAN_STRIP_MODE; req->vnic_id = bp->vnic_id; return wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ ); } @@ -2091,7 +2002,6 @@ hwrm_func_t bring_up_chip[] = { bnxt_hwrm_func_resource_qcaps, /* HWRM_FUNC_RESOURCE_QCAPS */ bnxt_hwrm_port_phy_qcaps_req, /* HWRM_PORT_PHY_QCAPS */ bnxt_hwrm_func_qcfg_req, /* HWRM_FUNC_QCFG */ - bnxt_get_vlan, /* HWRM_NVM_GET_VARIABLE - vlan */ bnxt_hwrm_port_mac_cfg, /* HWRM_PORT_MAC_CFG */ bnxt_hwrm_func_cfg_req, /* HWRM_FUNC_CFG */ bnxt_query_phy_link, /* HWRM_PORT_PHY_QCFG */ diff --git a/src/drivers/net/bnxt/bnxt.h b/src/drivers/net/bnxt/bnxt.h index 4d8bdc7f2..726acc7db 100644 --- a/src/drivers/net/bnxt/bnxt.h +++ b/src/drivers/net/bnxt/bnxt.h @@ -894,7 +894,6 @@ struct rx_info { u32 good; u32 drop_err; u32 drop_lb; - u32 drop_vlan; u8 epoch; u8 res[3]; }; diff --git a/src/drivers/net/bnxt/bnxt_dbg.h b/src/drivers/net/bnxt/bnxt_dbg.h index eaa5f7110..efa8f1215 100644 --- a/src/drivers/net/bnxt/bnxt_dbg.h +++ b/src/drivers/net/bnxt/bnxt_dbg.h @@ -418,13 +418,6 @@ void dump_rx_bd(struct rx_pkt_cmpl *rx_cmp, #endif } -void dbg_rx_vlan(struct bnxt *bp, u32 meta, u16 f2, u16 rx_vid) -{ - dbg_prn(" Rx VLAN metadata %x flags2 %x\n", meta, f2); - dbg_prn(" Rx VLAN MBA %d TX %d RX %d\n", - bp->vlan_id, bp->vlan_tx, rx_vid); -} - void dbg_alloc_rx_iob(struct io_buffer *iob, u16 id, u16 cid) { dbg_prn(" Rx alloc_iob (%d) %p bd_virt (%d)\n", @@ -460,13 +453,12 @@ void dbg_rxp(u8 *iob, u16 rx_len, u8 drop) void dbg_rx_stat(struct bnxt *bp) { - dbg_prn("- RX Stat Total %d Good %d Drop err %d LB %d VLAN %d\n", + dbg_prn("- RX Stat Total %d Good %d Drop err %d LB %d\n", bp->rx.cnt, bp->rx.good, - bp->rx.drop_err, bp->rx.drop_lb, bp->rx.drop_vlan); + bp->rx.drop_err, bp->rx.drop_lb); } #else #define dump_rx_bd(rx_cmp, rx_cmp_hi, desc_idx) -#define dbg_rx_vlan(bp, metadata, flags2, rx_vid) #define dbg_alloc_rx_iob(iob, id, cid) #define dbg_rx_cid(idx, cid) #define dbg_alloc_rx_iob_fail(iob_idx, cons_id) -- cgit v1.2.3-55-g7522 From 0020627777027041203332dbc61ae8c872402f9d Mon Sep 17 00:00:00 2001 From: Joseph Wong Date: Tue, 1 Jul 2025 00:24:05 -0700 Subject: [bnxt] Update device descriptions Use human readable strings for dev_description in PCI_ROM array. Signed-off-by: Joseph Wong --- src/drivers/net/bnxt/bnxt.c | 118 ++++++++++++++++++++++---------------------- 1 file changed, 59 insertions(+), 59 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/bnxt/bnxt.c b/src/drivers/net/bnxt/bnxt.c index f3db30db5..426ff88f5 100644 --- a/src/drivers/net/bnxt/bnxt.c +++ b/src/drivers/net/bnxt/bnxt.c @@ -26,65 +26,65 @@ static int bnxt_rx_complete ( struct net_device *dev, struct rx_pkt_cmpl *rx ); void bnxt_link_evt ( struct bnxt *bp, struct hwrm_async_event_cmpl *evt ); static struct pci_device_id bnxt_nics[] = { - PCI_ROM( 0x14e4, 0x1604, "14e4-1604", "14e4-1604", 0 ), - PCI_ROM( 0x14e4, 0x1605, "14e4-1605", "14e4-1605", 0 ), - PCI_ROM( 0x14e4, 0x1606, "14e4-1606", "14e4-1606", 0 ), - PCI_ROM( 0x14e4, 0x1609, "14e4-1609", "14e4-1609", 0 ), - PCI_ROM( 0x14e4, 0x1614, "14e4-1614", "14e4-1614", 0 ), - PCI_ROM( 0x14e4, 0x16c0, "14e4-16C0", "14e4-16C0", 0 ), - PCI_ROM( 0x14e4, 0x16c1, "14e4-16C1", "14e4-16C1", BNXT_FLAG_PCI_VF ), - PCI_ROM( 0x14e4, 0x16c8, "14e4-16C8", "14e4-16C8", 0 ), - PCI_ROM( 0x14e4, 0x16c9, "14e4-16C9", "14e4-16C9", 0 ), - PCI_ROM( 0x14e4, 0x16ca, "14e4-16CA", "14e4-16CA", 0 ), - PCI_ROM( 0x14e4, 0x16cc, "14e4-16CC", "14e4-16CC", 0 ), - PCI_ROM( 0x14e4, 0x16cd, "14e4-16CD", "14e4-16CD", 0 ), - PCI_ROM( 0x14e4, 0x16ce, "14e4-16CE", "14e4-16CE", 0 ), - PCI_ROM( 0x14e4, 0x16cf, "14e4-16CF", "14e4-16CF", 0 ), - PCI_ROM( 0x14e4, 0x16d0, "14e4-16D0", "14e4-16D0", 0 ), - PCI_ROM( 0x14e4, 0x16d1, "14e4-16D1", "14e4-16D1", 0 ), - PCI_ROM( 0x14e4, 0x16d2, "14e4-16D2", "14e4-16D2", 0 ), - PCI_ROM( 0x14e4, 0x16d4, "14e4-16D4", "14e4-16D4", 0 ), - PCI_ROM( 0x14e4, 0x16d5, "14e4-16D5", "14e4-16D5", 0 ), - PCI_ROM( 0x14e4, 0x16d6, "14e4-16D6", "14e4-16D6", 0 ), - PCI_ROM( 0x14e4, 0x16d7, "14e4-16D7", "14e4-16D7", 0 ), - PCI_ROM( 0x14e4, 0x16d8, "14e4-16D8", "14e4-16D8", 0 ), - PCI_ROM( 0x14e4, 0x16d9, "14e4-16D9", "14e4-16D9", 0 ), - PCI_ROM( 0x14e4, 0x16da, "14e4-16DA", "14e4-16DA", 0 ), - PCI_ROM( 0x14e4, 0x16db, "14e4-16DB", "14e4-16DB", 0 ), - PCI_ROM( 0x14e4, 0x16dc, "14e4-16DC", "14e4-16DC", BNXT_FLAG_PCI_VF ), - PCI_ROM( 0x14e4, 0x16de, "14e4-16DE", "14e4-16DE", 0 ), - PCI_ROM( 0x14e4, 0x16df, "14e4-16DF", "14e4-16DF", 0 ), - PCI_ROM( 0x14e4, 0x16e0, "14e4-16E0", "14e4-16E0", 0 ), - PCI_ROM( 0x14e4, 0x16e2, "14e4-16E2", "14e4-16E2", 0 ), - PCI_ROM( 0x14e4, 0x16e3, "14e4-16E3", "14e4-16E3", 0 ), - PCI_ROM( 0x14e4, 0x16e4, "14e4-16E4", "14e4-16E4", 0 ), - PCI_ROM( 0x14e4, 0x16e7, "14e4-16E7", "14e4-16E7", 0 ), - PCI_ROM( 0x14e4, 0x16e8, "14e4-16E8", "14e4-16E8", 0 ), - PCI_ROM( 0x14e4, 0x16e9, "14e4-16E9", "14e4-16E9", 0 ), - PCI_ROM( 0x14e4, 0x16ea, "14e4-16EA", "14e4-16EA", 0 ), - PCI_ROM( 0x14e4, 0x16eb, "14e4-16EB", "14e4-16EB", 0 ), - PCI_ROM( 0x14e4, 0x16ec, "14e4-16EC", "14e4-16EC", 0 ), - PCI_ROM( 0x14e4, 0x16ed, "14e4-16ED", "14e4-16ED", 0 ), - PCI_ROM( 0x14e4, 0x16ee, "14e4-16EE", "14e4-16EE", 0 ), - PCI_ROM( 0x14e4, 0x16ef, "14e4-16EF", "14e4-16EF", 0 ), - PCI_ROM( 0x14e4, 0x16f0, "14e4-16F0", "14e4-16F0", 0 ), - PCI_ROM( 0x14e4, 0x16f1, "14e4-16F1", "14e4-16F1", 0 ), - PCI_ROM( 0x14e4, 0x1750, "14e4-1750", "14e4-1750", 0 ), - PCI_ROM( 0x14e4, 0x1751, "14e4-1751", "14e4-1751", 0 ), - PCI_ROM( 0x14e4, 0x1752, "14e4-1752", "14e4-1752", 0 ), - PCI_ROM( 0x14e4, 0x1760, "14e4-1760", "14e4-1760", 0 ), - PCI_ROM( 0x14e4, 0x1800, "14e4-1800", "14e4-1800", 0 ), - PCI_ROM( 0x14e4, 0x1801, "14e4-1801", "14e4-1801", 0 ), - PCI_ROM( 0x14e4, 0x1802, "14e4-1802", "14e4-1802", 0 ), - PCI_ROM( 0x14e4, 0x1803, "14e4-1803", "14e4-1803", 0 ), - PCI_ROM( 0x14e4, 0x1804, "14e4-1804", "14e4-1804", 0 ), - PCI_ROM( 0x14e4, 0x1805, "14e4-1805", "14e4-1805", 0 ), - PCI_ROM( 0x14e4, 0x1806, "14e4-1806", "14e4-1806", BNXT_FLAG_PCI_VF ), - PCI_ROM( 0x14e4, 0x1807, "14e4-1807", "14e4-1807", BNXT_FLAG_PCI_VF ), - PCI_ROM( 0x14e4, 0x1808, "14e4-1808", "14e4-1808", BNXT_FLAG_PCI_VF ), - PCI_ROM( 0x14e4, 0x1809, "14e4-1809", "14e4-1809", BNXT_FLAG_PCI_VF ), - PCI_ROM( 0x14e4, 0xd802, "14e4-D802", "14e4-D802", 0 ), - PCI_ROM( 0x14e4, 0xd804, "14e4-D804", "14e4-D804", 0 ), + PCI_ROM( 0x14e4, 0x1604, "14e4-1604", "Broadcom BCM957454", 0 ), + PCI_ROM( 0x14e4, 0x1605, "14e4-1605", "Broadcom BCM957454 RDMA", 0 ), + PCI_ROM( 0x14e4, 0x1606, "14e4-1606", "Broadcom BCM957454 RDMA VF", BNXT_FLAG_PCI_VF ), + PCI_ROM( 0x14e4, 0x1609, "14e4-1609", "Broadcom BCM957454 VF", BNXT_FLAG_PCI_VF ), + PCI_ROM( 0x14e4, 0x1614, "14e4-1614", "Broadcom BCM957454", 0 ), + PCI_ROM( 0x14e4, 0x16c0, "14e4-16c0", "Broadcom BCM957417", 0 ), + PCI_ROM( 0x14e4, 0x16c1, "14e4-16c1", "Broadcom BCM95741x VF", BNXT_FLAG_PCI_VF ), + PCI_ROM( 0x14e4, 0x16c8, "14e4-16c8", "Broadcom BCM957301", 0 ), + PCI_ROM( 0x14e4, 0x16c9, "14e4-16c9", "Broadcom BCM957302", 0 ), + PCI_ROM( 0x14e4, 0x16ca, "14e4-16ca", "Broadcom BCM957304", 0 ), + PCI_ROM( 0x14e4, 0x16cc, "14e4-16cc", "Broadcom BCM957417 MF", 0 ), + PCI_ROM( 0x14e4, 0x16cd, "14e4-16cd", "Broadcom BCM958700", 0 ), + PCI_ROM( 0x14e4, 0x16ce, "14e4-16ce", "Broadcom BCM957311", 0 ), + PCI_ROM( 0x14e4, 0x16cf, "14e4-16cf", "Broadcom BCM957312", 0 ), + PCI_ROM( 0x14e4, 0x16d0, "14e4-16d0", "Broadcom BCM957402", 0 ), + PCI_ROM( 0x14e4, 0x16d1, "14e4-16d1", "Broadcom BCM957404", 0 ), + PCI_ROM( 0x14e4, 0x16d2, "14e4-16d2", "Broadcom BCM957406", 0 ), + PCI_ROM( 0x14e4, 0x16d4, "14e4-16d4", "Broadcom BCM957402 MF", 0 ), + PCI_ROM( 0x14e4, 0x16d5, "14e4-16d5", "Broadcom BCM957407", 0 ), + PCI_ROM( 0x14e4, 0x16d6, "14e4-16d6", "Broadcom BCM957412", 0 ), + PCI_ROM( 0x14e4, 0x16d7, "14e4-16d7", "Broadcom BCM957414", 0 ), + PCI_ROM( 0x14e4, 0x16d8, "14e4-16d8", "Broadcom BCM957416", 0 ), + PCI_ROM( 0x14e4, 0x16d9, "14e4-16d9", "Broadcom BCM957417", 0 ), + PCI_ROM( 0x14e4, 0x16da, "14e4-16da", "Broadcom BCM957402", 0 ), + PCI_ROM( 0x14e4, 0x16db, "14e4-16db", "Broadcom BCM957404", 0 ), + PCI_ROM( 0x14e4, 0x16dc, "14e4-16dc", "Broadcom BCM95741x VF", BNXT_FLAG_PCI_VF ), + PCI_ROM( 0x14e4, 0x16de, "14e4-16de", "Broadcom BCM957412 MF", 0 ), + PCI_ROM( 0x14e4, 0x16df, "14e4-16df", "Broadcom BCM957314", 0 ), + PCI_ROM( 0x14e4, 0x16e0, "14e4-16e0", "Broadcom BCM957317", 0 ), + PCI_ROM( 0x14e4, 0x16e2, "14e4-16e2", "Broadcom BCM957417", 0 ), + PCI_ROM( 0x14e4, 0x16e3, "14e4-16e3", "Broadcom BCM957416", 0 ), + PCI_ROM( 0x14e4, 0x16e4, "14e4-16e4", "Broadcom BCM957317", 0 ), + PCI_ROM( 0x14e4, 0x16e7, "14e4-16e7", "Broadcom BCM957404 MF", 0 ), + PCI_ROM( 0x14e4, 0x16e8, "14e4-16e8", "Broadcom BCM957406 MF", 0 ), + PCI_ROM( 0x14e4, 0x16e9, "14e4-16e9", "Broadcom BCM957407", 0 ), + PCI_ROM( 0x14e4, 0x16ea, "14e4-16ea", "Broadcom BCM957407 MF", 0 ), + PCI_ROM( 0x14e4, 0x16eb, "14e4-16eb", "Broadcom BCM957412 RDMA MF", 0 ), + PCI_ROM( 0x14e4, 0x16ec, "14e4-16ec", "Broadcom BCM957414 MF", 0 ), + PCI_ROM( 0x14e4, 0x16ed, "14e4-16ed", "Broadcom BCM957414 RDMA MF", 0 ), + PCI_ROM( 0x14e4, 0x16ee, "14e4-16ee", "Broadcom BCM957416 MF", 0 ), + PCI_ROM( 0x14e4, 0x16ef, "14e4-16ef", "Broadcom BCM957416 RDMA MF", 0 ), + PCI_ROM( 0x14e4, 0x16f0, "14e4-16f0", "Broadcom BCM957320", 0 ), + PCI_ROM( 0x14e4, 0x16f1, "14e4-16f1", "Broadcom BCM957320", 0 ), + PCI_ROM( 0x14e4, 0x1750, "14e4-1750", "Broadcom BCM957508", 0 ), + PCI_ROM( 0x14e4, 0x1751, "14e4-1751", "Broadcom BCM957504", 0 ), + PCI_ROM( 0x14e4, 0x1752, "14e4-1752", "Broadcom BCM957502", 0 ), + PCI_ROM( 0x14e4, 0x1760, "14e4-1760", "Broadcom BCM957608", 0 ), + PCI_ROM( 0x14e4, 0x1800, "14e4-1800", "Broadcom BCM957502 MF", 0 ), + PCI_ROM( 0x14e4, 0x1801, "14e4-1801", "Broadcom BCM957504 MF", 0 ), + PCI_ROM( 0x14e4, 0x1802, "14e4-1802", "Broadcom BCM957508 MF", 0 ), + PCI_ROM( 0x14e4, 0x1803, "14e4-1803", "Broadcom BCM957502 RDMA MF", 0 ), + PCI_ROM( 0x14e4, 0x1804, "14e4-1804", "Broadcom BCM957504 RDMA MF", 0 ), + PCI_ROM( 0x14e4, 0x1805, "14e4-1805", "Broadcom BCM957508 RDMA MF", 0 ), + PCI_ROM( 0x14e4, 0x1806, "14e4-1806", "Broadcom BCM9575xx VF", BNXT_FLAG_PCI_VF ), + PCI_ROM( 0x14e4, 0x1807, "14e4-1807", "Broadcom BCM9575xx RDMA VF", BNXT_FLAG_PCI_VF ), + PCI_ROM( 0x14e4, 0x1808, "14e4-1808", "Broadcom BCM9575xx HV VF", BNXT_FLAG_PCI_VF ), + PCI_ROM( 0x14e4, 0x1809, "14e4-1809", "Broadcom BCM9575xx RDMA HV VF", BNXT_FLAG_PCI_VF ), + PCI_ROM( 0x14e4, 0xd802, "14e4-d802", "14e4-d802", 0 ), + PCI_ROM( 0x14e4, 0xd804, "14e4-d804", "14e4-d804", 0 ), }; /** -- cgit v1.2.3-55-g7522 From 6bc55d65b16fefdc53837ecd7bcee44eda03b3ac Mon Sep 17 00:00:00 2001 From: Joseph Wong Date: Wed, 2 Jul 2025 10:29:06 -0700 Subject: [bnxt] Update supported devices array Add support for new device IDs. Remove device IDs which were never in use. Signed-off-by: Joseph Wong --- src/drivers/net/bnxt/bnxt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/bnxt/bnxt.c b/src/drivers/net/bnxt/bnxt.c index 426ff88f5..33071fd78 100644 --- a/src/drivers/net/bnxt/bnxt.c +++ b/src/drivers/net/bnxt/bnxt.c @@ -29,10 +29,14 @@ static struct pci_device_id bnxt_nics[] = { PCI_ROM( 0x14e4, 0x1604, "14e4-1604", "Broadcom BCM957454", 0 ), PCI_ROM( 0x14e4, 0x1605, "14e4-1605", "Broadcom BCM957454 RDMA", 0 ), PCI_ROM( 0x14e4, 0x1606, "14e4-1606", "Broadcom BCM957454 RDMA VF", BNXT_FLAG_PCI_VF ), + PCI_ROM( 0x14e4, 0x1607, "bcm957454-1607", "Broadcom BCM957454 HV VF", BNXT_FLAG_PCI_VF ), + PCI_ROM( 0x14e4, 0x1608, "bcm957454-1608", "Broadcom BCM957454 RDMA HV VF", BNXT_FLAG_PCI_VF ), PCI_ROM( 0x14e4, 0x1609, "14e4-1609", "Broadcom BCM957454 VF", BNXT_FLAG_PCI_VF ), PCI_ROM( 0x14e4, 0x1614, "14e4-1614", "Broadcom BCM957454", 0 ), + PCI_ROM( 0x14e4, 0x16bd, "bcm95741x-16bd", "Broadcom BCM95741x RDMA_HV_VF", BNXT_FLAG_PCI_VF ), PCI_ROM( 0x14e4, 0x16c0, "14e4-16c0", "Broadcom BCM957417", 0 ), PCI_ROM( 0x14e4, 0x16c1, "14e4-16c1", "Broadcom BCM95741x VF", BNXT_FLAG_PCI_VF ), + PCI_ROM( 0x14e4, 0x16c5, "bcm95741x-16c5", "Broadcom BCM95741x HV VF", BNXT_FLAG_PCI_VF ), PCI_ROM( 0x14e4, 0x16c8, "14e4-16c8", "Broadcom BCM957301", 0 ), PCI_ROM( 0x14e4, 0x16c9, "14e4-16c9", "Broadcom BCM957302", 0 ), PCI_ROM( 0x14e4, 0x16ca, "14e4-16ca", "Broadcom BCM957304", 0 ), @@ -83,8 +87,8 @@ static struct pci_device_id bnxt_nics[] = { PCI_ROM( 0x14e4, 0x1807, "14e4-1807", "Broadcom BCM9575xx RDMA VF", BNXT_FLAG_PCI_VF ), PCI_ROM( 0x14e4, 0x1808, "14e4-1808", "Broadcom BCM9575xx HV VF", BNXT_FLAG_PCI_VF ), PCI_ROM( 0x14e4, 0x1809, "14e4-1809", "Broadcom BCM9575xx RDMA HV VF", BNXT_FLAG_PCI_VF ), - PCI_ROM( 0x14e4, 0xd802, "14e4-d802", "14e4-d802", 0 ), - PCI_ROM( 0x14e4, 0xd804, "14e4-d804", "14e4-d804", 0 ), + PCI_ROM( 0x14e4, 0x1819, "bcm95760x-1819", "Broadcom BCM95760x VF", BNXT_FLAG_PCI_VF ), + PCI_ROM( 0x14e4, 0x181b, "bcm95760x-181b", "Broadcom BCM95760x HV VF", BNXT_FLAG_PCI_VF ), }; /** -- cgit v1.2.3-55-g7522 From 22de0c4edf2fe1cdbca5e22c52c86a2289d04816 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 8 Jul 2025 12:38:05 +0100 Subject: [dma] Use virtual addresses for dma_map() Cache management operations must generally be performed on virtual addresses rather than physical addresses. Change the address parameter in dma_map() to be a virtual address, and make dma() the API-level primitive instead of dma_phys(). Signed-off-by: Michael Brown --- src/core/dma.c | 6 +++--- src/drivers/net/intelxl.c | 4 ++-- src/include/ipxe/dma.h | 42 +++++++++++++----------------------------- src/include/ipxe/iobuf.h | 3 +-- src/interface/efi/efi_pci.c | 19 ++++++++++--------- 5 files changed, 29 insertions(+), 45 deletions(-) (limited to 'src/drivers') diff --git a/src/core/dma.c b/src/core/dma.c index cf4b20379..cbc9b8d10 100644 --- a/src/core/dma.c +++ b/src/core/dma.c @@ -47,7 +47,7 @@ PROVIDE_DMAAPI_INLINE ( flat, dma_free ); PROVIDE_DMAAPI_INLINE ( flat, dma_umalloc ); PROVIDE_DMAAPI_INLINE ( flat, dma_ufree ); PROVIDE_DMAAPI_INLINE ( flat, dma_set_mask ); -PROVIDE_DMAAPI_INLINE ( flat, dma_phys ); +PROVIDE_DMAAPI_INLINE ( flat, dma ); /****************************************************************************** * @@ -67,7 +67,7 @@ PROVIDE_DMAAPI_INLINE ( flat, dma_phys ); * @ret rc Return status code */ static int dma_op_map ( struct dma_device *dma, struct dma_mapping *map, - physaddr_t addr, size_t len, int flags ) { + void *addr, size_t len, int flags ) { struct dma_operations *op = dma->op; if ( ! op ) @@ -175,4 +175,4 @@ PROVIDE_DMAAPI ( op, dma_free, dma_op_free ); PROVIDE_DMAAPI ( op, dma_umalloc, dma_op_umalloc ); PROVIDE_DMAAPI ( op, dma_ufree, dma_op_ufree ); PROVIDE_DMAAPI ( op, dma_set_mask, dma_op_set_mask ); -PROVIDE_DMAAPI_INLINE ( op, dma_phys ); +PROVIDE_DMAAPI_INLINE ( op, dma ); diff --git a/src/drivers/net/intelxl.c b/src/drivers/net/intelxl.c index 82b07833c..1d4c22a09 100644 --- a/src/drivers/net/intelxl.c +++ b/src/drivers/net/intelxl.c @@ -65,8 +65,8 @@ int intelxl_msix_enable ( struct intelxl_nic *intelxl, /* Map dummy target location */ if ( ( rc = dma_map ( intelxl->dma, &intelxl->msix.map, - virt_to_phys ( &intelxl->msix.msg ), - sizeof ( intelxl->msix.msg ), DMA_RX ) ) != 0 ) { + &intelxl->msix.msg, sizeof ( intelxl->msix.msg ), + DMA_RX ) ) != 0 ) { DBGC ( intelxl, "INTELXL %p could not map MSI-X target: %s\n", intelxl, strerror ( rc ) ); goto err_map; diff --git a/src/include/ipxe/dma.h b/src/include/ipxe/dma.h index 6e5c43289..d450ef523 100644 --- a/src/include/ipxe/dma.h +++ b/src/include/ipxe/dma.h @@ -68,7 +68,7 @@ struct dma_operations { * @ret rc Return status code */ int ( * map ) ( struct dma_device *dma, struct dma_mapping *map, - physaddr_t addr, size_t len, int flags ); + void *addr, size_t len, int flags ); /** * Unmap buffer * @@ -178,8 +178,7 @@ struct dma_operations { */ static inline __always_inline int DMAAPI_INLINE ( flat, dma_map ) ( struct dma_device *dma, - struct dma_mapping *map, - physaddr_t addr __unused, + struct dma_mapping *map, void *addr __unused, size_t len __unused, int flags __unused ) { /* Increment mapping count (for debugging) */ @@ -319,32 +318,31 @@ DMAAPI_INLINE ( flat, dma_set_mask ) ( struct dma_device *dma __unused, } /** - * Get DMA address from physical address + * Get DMA address from virtual address * * @v map DMA mapping - * @v addr Physical address within the mapped region + * @v addr Address within the mapped region * @ret addr Device-side DMA address */ static inline __always_inline physaddr_t -DMAAPI_INLINE ( flat, dma_phys ) ( struct dma_mapping *map __unused, - physaddr_t addr ) { +DMAAPI_INLINE ( flat, dma ) ( struct dma_mapping *map __unused, void *addr ) { /* Use physical address as device address */ - return addr; + return virt_to_phys ( addr ); } /** - * Get DMA address from physical address + * Get DMA address from virtual address * * @v map DMA mapping - * @v addr Physical address within the mapped region + * @v addr Address within the mapped region * @ret addr Device-side DMA address */ static inline __always_inline physaddr_t -DMAAPI_INLINE ( op, dma_phys ) ( struct dma_mapping *map, physaddr_t addr ) { +DMAAPI_INLINE ( op, dma ) ( struct dma_mapping *map, void *addr ) { /* Adjust physical address using mapping offset */ - return ( addr + map->offset ); + return ( virt_to_phys ( addr ) + map->offset ); } /** @@ -358,7 +356,7 @@ DMAAPI_INLINE ( op, dma_phys ) ( struct dma_mapping *map, physaddr_t addr ) { * @ret rc Return status code */ int dma_map ( struct dma_device *dma, struct dma_mapping *map, - physaddr_t addr, size_t len, int flags ); + void *addr, size_t len, int flags ); /** * Unmap buffer @@ -417,28 +415,14 @@ void dma_ufree ( struct dma_mapping *map, void *addr, size_t len ); */ void dma_set_mask ( struct dma_device *dma, physaddr_t mask ); -/** - * Get DMA address from physical address - * - * @v map DMA mapping - * @v addr Physical address within the mapped region - * @ret addr Device-side DMA address - */ -physaddr_t dma_phys ( struct dma_mapping *map, physaddr_t addr ); - /** * Get DMA address from virtual address * * @v map DMA mapping - * @v addr Virtual address within the mapped region + * @v addr Address within the mapped region * @ret addr Device-side DMA address */ -static inline __always_inline physaddr_t dma ( struct dma_mapping *map, - void *addr ) { - - /* Get DMA address from corresponding physical address */ - return dma_phys ( map, virt_to_phys ( addr ) ); -} +physaddr_t dma ( struct dma_mapping *map, void *addr ); /** * Check if DMA unmapping is required diff --git a/src/include/ipxe/iobuf.h b/src/include/ipxe/iobuf.h index 2bdca6b5d..df8d0b854 100644 --- a/src/include/ipxe/iobuf.h +++ b/src/include/ipxe/iobuf.h @@ -230,8 +230,7 @@ static inline void iob_populate ( struct io_buffer *iobuf, static inline __always_inline int iob_map ( struct io_buffer *iobuf, struct dma_device *dma, size_t len, int flags ) { - return dma_map ( dma, &iobuf->map, virt_to_phys ( iobuf->data ), - len, flags ); + return dma_map ( dma, &iobuf->map, iobuf->data, len, flags ); } /** diff --git a/src/interface/efi/efi_pci.c b/src/interface/efi/efi_pci.c index 1b1f05816..ae0ec4264 100644 --- a/src/interface/efi/efi_pci.c +++ b/src/interface/efi/efi_pci.c @@ -455,7 +455,7 @@ PROVIDE_PCIAPI ( efi, pci_ioremap, efipci_ioremap ); * @ret rc Return status code */ static int efipci_dma_map ( struct dma_device *dma, struct dma_mapping *map, - physaddr_t addr, size_t len, int flags ) { + void *addr, size_t len, int flags ) { struct efi_pci_device *efipci = container_of ( dma, struct efi_pci_device, pci.dma ); struct pci_device *pci = &efipci->pci; @@ -464,6 +464,7 @@ static int efipci_dma_map ( struct dma_device *dma, struct dma_mapping *map, EFI_PHYSICAL_ADDRESS bus; UINTN count; VOID *mapping; + physaddr_t phys; EFI_STATUS efirc; int rc; @@ -486,18 +487,19 @@ static int efipci_dma_map ( struct dma_device *dma, struct dma_mapping *map, } /* Map buffer (if non-zero length) */ + phys = virt_to_phys ( addr ); count = len; if ( len ) { - if ( ( efirc = pci_io->Map ( pci_io, op, phys_to_virt ( addr ), - &count, &bus, &mapping ) ) != 0 ) { + if ( ( efirc = pci_io->Map ( pci_io, op, addr, &count, &bus, + &mapping ) ) != 0 ) { rc = -EEFI ( efirc ); - DBGC ( pci, "EFIPCI " PCI_FMT " cannot map %08lx+%zx: " + DBGC ( pci, "EFIPCI " PCI_FMT " cannot map %p+%zx: " "%s\n", PCI_ARGS ( pci ), addr, len, strerror ( rc ) ); goto err_map; } } else { - bus = addr; + bus = phys; mapping = NULL; } @@ -508,14 +510,14 @@ static int efipci_dma_map ( struct dma_device *dma, struct dma_mapping *map, */ if ( count != len ) { DBGC ( pci, "EFIPCI " PCI_FMT " attempted split mapping for " - "%08lx+%zx\n", PCI_ARGS ( pci ), addr, len ); + "%p+%zx\n", PCI_ARGS ( pci ), addr, len ); rc = -ENOTSUP; goto err_len; } /* Populate mapping */ map->dma = dma; - map->offset = ( bus - addr ); + map->offset = ( bus - phys ); map->token = mapping; /* Increment mapping count (for debugging) */ @@ -594,8 +596,7 @@ static void * efipci_dma_alloc ( struct dma_device *dma, memset ( addr, 0, ( pages * EFI_PAGE_SIZE ) ); /* Map buffer */ - if ( ( rc = efipci_dma_map ( dma, map, virt_to_phys ( addr ), - ( pages * EFI_PAGE_SIZE ), + if ( ( rc = efipci_dma_map ( dma, map, addr, ( pages * EFI_PAGE_SIZE ), DMA_BI ) ) != 0 ) goto err_map; -- cgit v1.2.3-55-g7522 From bbabde8ff8182fcef738893c29a698783758a489 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 10 Jul 2025 14:33:34 +0100 Subject: [riscv] Invalidate data cache on completed RX DMA buffers The data cache must be invalidated twice for RX DMA buffers: once before passing ownership to the DMA device (in case the cache happens to contain dirty data that will be written back at an undefined future point), and once after receiving ownership from the DMA device (in case the CPU happens to have speculatively accessed data in the buffer while it was owned by the hardware). Only the used portion of the buffer needs to be invalidated after completion, since we do not care about data within the unused portion. Update the DMA API to include the used length as an additional parameter to dma_unmap(), and add the necessary second cache invalidation pass to the RISC-V DMA API implementation. Signed-off-by: Michael Brown --- src/arch/riscv/core/riscv_dma.c | 52 +++++++++++++++++++++++++++++---- src/arch/riscv/include/ipxe/riscv_dma.h | 11 ------- src/core/dma.c | 5 ++-- src/drivers/net/intelxl.c | 4 +-- src/include/ipxe/dma.h | 11 +++++-- src/include/ipxe/iobuf.h | 2 +- src/interface/efi/efi_pci.c | 7 +++-- 7 files changed, 65 insertions(+), 27 deletions(-) (limited to 'src/drivers') diff --git a/src/arch/riscv/core/riscv_dma.c b/src/arch/riscv/core/riscv_dma.c index d215fba2c..ab88f2785 100644 --- a/src/arch/riscv/core/riscv_dma.c +++ b/src/arch/riscv/core/riscv_dma.c @@ -44,24 +44,57 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * @v flags Mapping flags * @ret rc Return status code */ -static int riscv_dma_map ( struct dma_device *dma __unused, - struct dma_mapping *map __unused, +static int riscv_dma_map ( struct dma_device *dma, + struct dma_mapping *map, void *addr, size_t len, int flags ) { /* Sanity check: we cannot support bidirectional mappings */ assert ( ! ( ( flags & DMA_TX ) & ( flags & DMA_RX ) ) ); + /* Populate mapping */ + map->dma = dma; + map->offset = 0; + map->token = NULL; + /* Flush cached data to transmit buffers */ if ( flags & DMA_TX ) cache_clean ( addr, len ); - /* Invalidate cached data in receive buffers */ - if ( flags & DMA_RX ) + /* Invalidate cached data in receive buffers and record address */ + if ( flags & DMA_RX ) { cache_invalidate ( addr, len ); + map->token = addr; + } + + /* Increment mapping count (for debugging) */ + if ( DBG_LOG ) + dma->mapped++; return 0; } +/** + * Unmap buffer + * + * @v map DMA mapping + * @v len Used length + */ +static void riscv_dma_unmap ( struct dma_mapping *map, size_t len ) { + struct dma_device *dma = map->dma; + void *addr = map->token; + + /* Invalidate cached data in receive buffers */ + if ( addr ) + cache_invalidate ( addr, len ); + + /* Clear mapping */ + map->dma = NULL; + + /* Decrement mapping count (for debugging) */ + if ( DBG_LOG ) + dma->mapped--; +} + /** * Allocate and map DMA-coherent buffer * @@ -98,6 +131,10 @@ static void * riscv_dma_alloc ( struct dma_device *dma, DBGC ( dma, "DMA allocated [%#08lx,%#08lx) via %p\n", phys, ( phys + len ), caddr ); + /* Increment allocation count (for debugging) */ + if ( DBG_LOG ) + dma->allocated++; + return caddr; } @@ -111,6 +148,7 @@ static void * riscv_dma_alloc ( struct dma_device *dma, */ static void riscv_dma_free ( struct dma_mapping *map, void *addr, size_t len ) { + struct dma_device *dma = map->dma; /* Sanity check */ assert ( virt_to_phys ( addr ) == virt_to_phys ( map->token ) ); @@ -121,10 +159,14 @@ static void riscv_dma_free ( struct dma_mapping *map, /* Clear mapping */ map->dma = NULL; map->token = NULL; + + /* Decrement allocation count (for debugging) */ + if ( DBG_LOG ) + dma->allocated--; } PROVIDE_DMAAPI ( riscv, dma_map, riscv_dma_map ); -PROVIDE_DMAAPI_INLINE ( riscv, dma_unmap ); +PROVIDE_DMAAPI ( riscv, dma_unmap, riscv_dma_unmap ); PROVIDE_DMAAPI ( riscv, dma_alloc, riscv_dma_alloc ); PROVIDE_DMAAPI ( riscv, dma_free, riscv_dma_free ); PROVIDE_DMAAPI ( riscv, dma_umalloc, riscv_dma_alloc ); diff --git a/src/arch/riscv/include/ipxe/riscv_dma.h b/src/arch/riscv/include/ipxe/riscv_dma.h index 568f28afe..d35904d88 100644 --- a/src/arch/riscv/include/ipxe/riscv_dma.h +++ b/src/arch/riscv/include/ipxe/riscv_dma.h @@ -15,17 +15,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define DMAAPI_PREFIX_riscv __riscv_ #endif -/** - * Unmap buffer - * - * @v map DMA mapping - */ -static inline __always_inline void -DMAAPI_INLINE ( riscv, dma_unmap ) ( struct dma_mapping *map __unused ) { - - /* Nothing to do */ -} - /** * Set addressable space mask * diff --git a/src/core/dma.c b/src/core/dma.c index cbc9b8d10..3f3023c4d 100644 --- a/src/core/dma.c +++ b/src/core/dma.c @@ -79,13 +79,14 @@ static int dma_op_map ( struct dma_device *dma, struct dma_mapping *map, * Unmap buffer * * @v map DMA mapping + * @v len Used length */ -static void dma_op_unmap ( struct dma_mapping *map ) { +static void dma_op_unmap ( struct dma_mapping *map, size_t len ) { struct dma_device *dma = map->dma; assert ( dma != NULL ); assert ( dma->op != NULL ); - dma->op->unmap ( dma, map ); + dma->op->unmap ( dma, map, len ); } /** diff --git a/src/drivers/net/intelxl.c b/src/drivers/net/intelxl.c index 1d4c22a09..31a3e2577 100644 --- a/src/drivers/net/intelxl.c +++ b/src/drivers/net/intelxl.c @@ -90,7 +90,7 @@ int intelxl_msix_enable ( struct intelxl_nic *intelxl, pci_msix_disable ( pci, &intelxl->msix.cap ); err_enable: - dma_unmap ( &intelxl->msix.map ); + dma_unmap ( &intelxl->msix.map, sizeof ( intelxl->msix.msg ) ); err_map: return rc; } @@ -112,7 +112,7 @@ void intelxl_msix_disable ( struct intelxl_nic *intelxl, pci_msix_disable ( pci, &intelxl->msix.cap ); /* Unmap dummy target location */ - dma_unmap ( &intelxl->msix.map ); + dma_unmap ( &intelxl->msix.map, sizeof ( intelxl->msix.msg ) ); } /****************************************************************************** diff --git a/src/include/ipxe/dma.h b/src/include/ipxe/dma.h index b675df212..a6e41c1ab 100644 --- a/src/include/ipxe/dma.h +++ b/src/include/ipxe/dma.h @@ -74,8 +74,10 @@ struct dma_operations { * * @v dma DMA device * @v map DMA mapping + * @v len Used length */ - void ( * unmap ) ( struct dma_device *dma, struct dma_mapping *map ); + void ( * unmap ) ( struct dma_device *dma, struct dma_mapping *map, + size_t len ); /** * Allocate and map DMA-coherent buffer * @@ -194,9 +196,11 @@ DMAAPI_INLINE ( flat, dma_map ) ( struct dma_device *dma, * Unmap buffer * * @v map DMA mapping + * @v len Used length */ static inline __always_inline void -DMAAPI_INLINE ( flat, dma_unmap ) ( struct dma_mapping *map ) { +DMAAPI_INLINE ( flat, dma_unmap ) ( struct dma_mapping *map, + size_t len __unused ) { /* Decrement mapping count (for debugging) */ if ( DBG_LOG ) { @@ -365,8 +369,9 @@ int dma_map ( struct dma_device *dma, struct dma_mapping *map, * Unmap buffer * * @v map DMA mapping + * @v len Used length */ -void dma_unmap ( struct dma_mapping *map ); +void dma_unmap ( struct dma_mapping *map, size_t len ); /** * Allocate and map DMA-coherent buffer diff --git a/src/include/ipxe/iobuf.h b/src/include/ipxe/iobuf.h index df8d0b854..46b350458 100644 --- a/src/include/ipxe/iobuf.h +++ b/src/include/ipxe/iobuf.h @@ -276,7 +276,7 @@ static inline __always_inline physaddr_t iob_dma ( struct io_buffer *iobuf ) { * @ret rc Return status code */ static inline __always_inline void iob_unmap ( struct io_buffer *iobuf ) { - dma_unmap ( &iobuf->map ); + dma_unmap ( &iobuf->map, iob_len ( iobuf ) ); } extern struct io_buffer * __malloc alloc_iob_raw ( size_t len, size_t align, diff --git a/src/interface/efi/efi_pci.c b/src/interface/efi/efi_pci.c index ae0ec4264..fbf06300b 100644 --- a/src/interface/efi/efi_pci.c +++ b/src/interface/efi/efi_pci.c @@ -537,9 +537,10 @@ static int efipci_dma_map ( struct dma_device *dma, struct dma_mapping *map, * * @v dma DMA device * @v map DMA mapping + * @v len Used length */ static void efipci_dma_unmap ( struct dma_device *dma, - struct dma_mapping *map ) { + struct dma_mapping *map, size_t len __unused ) { struct efi_pci_device *efipci = container_of ( dma, struct efi_pci_device, pci.dma ); EFI_PCI_IO_PROTOCOL *pci_io = efipci->io; @@ -606,7 +607,7 @@ static void * efipci_dma_alloc ( struct dma_device *dma, return addr; - efipci_dma_unmap ( dma, map ); + efipci_dma_unmap ( dma, map, len ); err_map: pci_io->FreeBuffer ( pci_io, pages, addr ); err_alloc: @@ -632,7 +633,7 @@ static void efipci_dma_free ( struct dma_device *dma, struct dma_mapping *map, pages = ( ( len + EFI_PAGE_SIZE - 1 ) / EFI_PAGE_SIZE ); /* Unmap buffer */ - efipci_dma_unmap ( dma, map ); + efipci_dma_unmap ( dma, map, len ); /* Free buffer */ pci_io->FreeBuffer ( pci_io, pages, addr ); -- cgit v1.2.3-55-g7522 From c2cdc1d31e0bbe368dd28818b21b9169a2c5e2be Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 10 Jul 2025 13:44:37 +0100 Subject: [dwmac] Add driver for DesignWare Ethernet MAC Add a basic driver for the DesignWare Ethernet MAC network interface as found in the Lichee Pi 4A. Signed-off-by: Michael Brown --- src/drivers/net/dwmac.c | 656 +++++++++++++++++++++++++++++++++++++++++++++ src/drivers/net/dwmac.h | 238 ++++++++++++++++ src/include/ipxe/errfile.h | 1 + 3 files changed, 895 insertions(+) create mode 100644 src/drivers/net/dwmac.c create mode 100644 src/drivers/net/dwmac.h (limited to 'src/drivers') diff --git a/src/drivers/net/dwmac.c b/src/drivers/net/dwmac.c new file mode 100644 index 000000000..67656e7f1 --- /dev/null +++ b/src/drivers/net/dwmac.c @@ -0,0 +1,656 @@ +/* + * Copyright (C) 2025 Michael Brown . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + * + * You can also choose to distribute this program under the terms of + * the Unmodified Binary Distribution Licence (as given in the file + * COPYING.UBDL), provided that you have satisfied its requirements. + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "dwmac.h" + +/** @file + * + * Synopsys DesignWare MAC network driver + * + */ + +/****************************************************************************** + * + * Debug + * + ****************************************************************************** + */ + +/** + * Dump MAC registers (for debugging) + * + * @v dwmac DesignWare MAC device + */ +static void dwmac_dump_mac ( struct dwmac *dwmac ) { + + /* Do nothing unless debugging is enabled */ + if ( ! DBG_LOG ) + return; + + /* Dump MAC registers */ + DBGC ( dwmac, "DWMAC %s ver %08x cfg %08x flt %08x flo %08x\n", + dwmac->name, readl ( dwmac->regs + DWMAC_VER ), + readl ( dwmac->regs + DWMAC_CFG ), + readl ( dwmac->regs + DWMAC_FILTER ), + readl ( dwmac->regs + DWMAC_FLOW ) ); + DBGC ( dwmac, "DWMAC %s isr %08x dbg %08x gmi %08x\n", + dwmac->name, readl ( dwmac->regs + DWMAC_ISR ), + readl ( dwmac->regs + DWMAC_DEBUG ), + readl ( dwmac->regs + DWMAC_GMII ) ); +} + +/** + * Dump DMA registers (for debugging) + * + * @v dwmac DesignWare MAC device + */ +static void dwmac_dump_dma ( struct dwmac *dwmac ) { + uint32_t status; + + /* Do nothing unless debugging is enabled */ + if ( ! DBG_LOG ) + return; + + /* Dump DMA registers */ + status = readl ( dwmac->regs + DWMAC_STATUS ); + DBGC ( dwmac, "DWMAC %s bus %08x fea %08x axi %08x ahb %08x\n", + dwmac->name, readl ( dwmac->regs + DWMAC_BUS ), + readl ( dwmac->regs + DWMAC_FEATURE ), + readl ( dwmac->regs + DWMAC_AXI ), + readl ( dwmac->regs + DWMAC_AHB ) ); + DBGC ( dwmac, "DWMAC %s opm %08x sta %08x drp %08x\n", + dwmac->name, readl ( dwmac->regs + DWMAC_OP ), + status, readl ( dwmac->regs + DWMAC_DROP ) ); + DBGC ( dwmac, "DWMAC %s txb %08x txd %08x txb %08x\n", + dwmac->name, readl ( dwmac->regs + DWMAC_TXBASE ), + readl ( dwmac->regs + DWMAC_TXDESC ), + readl ( dwmac->regs + DWMAC_TXBUF ) ); + DBGC ( dwmac, "DWMAC %s rxb %08x rxd %08x rxb %08x\n", + dwmac->name, readl ( dwmac->regs + DWMAC_RXBASE ), + readl ( dwmac->regs + DWMAC_RXDESC ), + readl ( dwmac->regs + DWMAC_RXBUF ) ); + + /* Clear sticky bits in status register, since nothing else will */ + writel ( status, ( dwmac->regs + DWMAC_STATUS ) ); +} + +/** + * Dump all registers (for debugging) + * + * @v dwmac DesignWare MAC device + */ +static void __attribute__ (( unused )) dwmac_dump ( struct dwmac *dwmac ) { + + /* Dump MAC and DMA registers */ + dwmac_dump_mac ( dwmac ); + dwmac_dump_dma ( dwmac ); +} + +/****************************************************************************** + * + * Device reset + * + ****************************************************************************** + */ + +/** + * Reset hardware + * + * @v dwmac DesignWare MAC device + * @ret rc Return status code + */ +static int dwmac_reset ( struct dwmac *dwmac ) { + unsigned int i; + uint32_t bus; + + /* Trigger software reset */ + writel ( DWMAC_BUS_SWR, ( dwmac->regs + DWMAC_BUS ) ); + + /* Wait for reset to complete */ + for ( i = 0 ; i < DWMAC_RESET_MAX_WAIT_MS ; i++ ) { + + /* Delay */ + mdelay ( 1 ); + + /* Check for reset completion */ + bus = readl ( dwmac->regs + DWMAC_BUS ); + if ( ! ( bus & DWMAC_BUS_SWR ) ) + return 0; + } + + DBGC ( dwmac, "DWMAC %s timed out waiting for reset\n", + dwmac->name ); + return -ETIMEDOUT; +} + +/****************************************************************************** + * + * Link state + * + ****************************************************************************** + */ + +/** + * Check link state + * + * @v netdev Network device + */ +static void dwmac_check_link ( struct net_device *netdev ) { + struct dwmac *dwmac = netdev->priv; + uint32_t gmii; + + /* Read SGMII/RGMII link status */ + gmii = readl ( dwmac->regs + DWMAC_GMII ); + DBGC ( dwmac, "DWMAC %s GMII link status %#08x\n", dwmac->name, gmii ); + + /* Update network device */ + if ( gmii & DWMAC_GMII_LINK ) { + netdev_link_up ( netdev ); + } else { + netdev_link_down ( netdev ); + } +} + +/****************************************************************************** + * + * Network device interface + * + ****************************************************************************** + */ + +/** + * Create descriptor ring + * + * @v dwmac DesignWare MAC device + * @v ring Descriptor ring + * @ret rc Return status code + */ +static int dwmac_create_ring ( struct dwmac *dwmac, struct dwmac_ring *ring ) { + struct dwmac_descriptor *desc; + struct dwmac_descriptor *next; + physaddr_t base; + unsigned int i; + + /* Allocate descriptor ring (on its own size) */ + ring->desc = dma_alloc ( dwmac->dma, &ring->map, ring->len, ring->len ); + if ( ! ring->desc ) + return -ENOMEM; + + /* Initialise descriptor ring */ + memset ( ring->desc, 0, ring->len ); + for ( i = 0 ; i < ring->count ; i++ ) { + desc = &ring->desc[i]; + desc->size = cpu_to_le16 ( DWMAC_RX_LEN | + DWMAC_SIZE_RX_CHAIN ); + desc->ctrl = ring->ctrl; + assert ( desc->ctrl & DWMAC_CTRL_CHAIN ); + next = &ring->desc[ ( i + 1 ) & ( ring->count - 1 ) ]; + desc->next = dma ( &ring->map, next ); + } + wmb(); + + /* Program ring address */ + base = dma ( &ring->map, ring->desc ); + assert ( base == ( ( uint32_t ) base ) ); + writel ( base, ( dwmac->regs + DWMAC_DMA + ring->qbase ) ); + + DBGC ( dwmac, "DWMAC %s ring %02x is at [%08lx,%08lx)\n", + dwmac->name, ring->qbase, virt_to_phys ( ring->desc ), + ( virt_to_phys ( ring->desc ) + ring->len ) ); + return 0; +} + +/** + * Destroy descriptor ring + * + * @v dwmac DesignWare MAC device + * @v ring Descriptor ring + */ +static void dwmac_destroy_ring ( struct dwmac *dwmac, + struct dwmac_ring *ring ) { + + /* Clear ring address */ + writel ( 0, ( dwmac->regs + DWMAC_DMA + ring->qbase ) ); + + /* Free descriptor ring */ + dma_free ( &ring->map, ring->desc, ring->len ); + ring->desc = NULL; + ring->prod = 0; + ring->cons = 0; +} + +/** + * Refill receive descriptor ring + * + * @v dwmac DesignWare MAC device + */ +static void dwmac_refill_rx ( struct dwmac *dwmac ) { + struct dwmac_descriptor *rx; + struct io_buffer *iobuf; + unsigned int rx_idx; + unsigned int refilled = 0; + + /* Refill ring */ + while ( ( dwmac->rx.prod - dwmac->rx.cons ) != DWMAC_NUM_RX_DESC ) { + + /* Allocate I/O buffer */ + iobuf = alloc_rx_iob ( DWMAC_RX_LEN, dwmac->dma ); + if ( ! iobuf ) { + /* Wait for next refill */ + break; + } + + /* Get next receive descriptor */ + rx_idx = ( dwmac->rx.prod++ % DWMAC_NUM_RX_DESC ); + rx = &dwmac->rx.desc[rx_idx]; + + /* Populate receive descriptor */ + rx->addr = cpu_to_le32 ( iob_dma ( iobuf ) ); + wmb(); + rx->stat = cpu_to_le32 ( DWMAC_STAT_OWN ); + + /* Record I/O buffer */ + assert ( dwmac->rx_iobuf[rx_idx] == NULL ); + dwmac->rx_iobuf[rx_idx] = iobuf; + + DBGC2 ( dwmac, "DWMAC %s RX %d is [%08lx,%08lx)\n", + dwmac->name, rx_idx, virt_to_phys ( iobuf->data ), + ( virt_to_phys ( iobuf->data ) + DWMAC_RX_LEN ) ); + refilled++; + } + + /* Trigger poll */ + if ( refilled ) { + wmb(); + writel ( 0, ( dwmac->regs + DWMAC_RXPOLL ) ); + } +} + +/** + * Open network device + * + * @v netdev Network device + * @ret rc Return status code + */ +static int dwmac_open ( struct net_device *netdev ) { + struct dwmac *dwmac = netdev->priv; + union dwmac_mac mac; + int rc; + + /* Create transmit descriptor ring */ + if ( ( rc = dwmac_create_ring ( dwmac, &dwmac->tx ) ) != 0 ) + goto err_create_tx; + + /* Create receive descriptor ring */ + if ( ( rc = dwmac_create_ring ( dwmac, &dwmac->rx ) ) != 0 ) + goto err_create_rx; + + /* Set MAC address */ + memcpy ( mac.raw, netdev->ll_addr, ETH_ALEN ); + writel ( mac.reg.addrl, ( dwmac->regs + DWMAC_ADDRL ) ); + writel ( mac.reg.addrh, ( dwmac->regs + DWMAC_ADDRH ) ); + + /* Enable promiscuous mode */ + writel ( DWMAC_FILTER_PR, ( dwmac->regs + DWMAC_FILTER ) ); + + /* Enable transmit and receive */ + writel ( ( DWMAC_OP_TXSF | DWMAC_OP_RXSF | + DWMAC_OP_TXEN | DWMAC_OP_RXEN ), + ( dwmac->regs + DWMAC_OP ) ); + writel ( ( DWMAC_CFG_DO | DWMAC_CFG_FD | + DWMAC_CFG_TXEN | DWMAC_CFG_RXEN ), + ( dwmac->regs + DWMAC_CFG ) ); + + /* Refill receive descriptor ring */ + dwmac_refill_rx ( dwmac ); + + /* Update link state */ + dwmac_check_link ( netdev ); + + return 0; + + dwmac_destroy_ring ( dwmac, &dwmac->rx ); + err_create_rx: + dwmac_destroy_ring ( dwmac, &dwmac->tx ); + err_create_tx: + return rc; +} + +/** + * Close network device + * + * @v netdev Network device + */ +static void dwmac_close ( struct net_device *netdev ) { + struct dwmac *dwmac = netdev->priv; + unsigned int i; + + /* Reset NIC */ + dwmac_reset ( dwmac ); + + /* Discard unused receive buffers */ + for ( i = 0 ; i < DWMAC_NUM_RX_DESC ; i++ ) { + if ( dwmac->rx_iobuf[i] ) + free_rx_iob ( dwmac->rx_iobuf[i] ); + dwmac->rx_iobuf[i] = NULL; + } + + /* Destroy receive descriptor ring */ + dwmac_destroy_ring ( dwmac, &dwmac->rx ); + + /* Destroy transmit descriptor ring */ + dwmac_destroy_ring ( dwmac, &dwmac->tx ); +} + +/** + * Transmit packet + * + * @v netdev Network device + * @v iobuf I/O buffer + * @ret rc Return status code + */ +static int dwmac_transmit ( struct net_device *netdev, + struct io_buffer *iobuf ) { + struct dwmac *dwmac = netdev->priv; + struct dwmac_descriptor *tx; + unsigned int tx_idx; + + /* Get next transmit descriptor */ + if ( ( dwmac->tx.prod - dwmac->tx.cons ) >= DWMAC_NUM_TX_DESC ) { + DBGC ( dwmac, "DWMAC %s out of transmit descriptors\n", + dwmac->name ); + return -ENOBUFS; + } + tx_idx = ( dwmac->tx.prod % DWMAC_NUM_TX_DESC ); + tx = &dwmac->tx.desc[tx_idx]; + + /* Update producer index */ + dwmac->tx.prod++; + + /* Populate transmit descriptor */ + tx->size = cpu_to_le16 ( iob_len ( iobuf ) ); + tx->addr = cpu_to_le32 ( iob_dma ( iobuf ) ); + wmb(); + tx->stat = cpu_to_le32 ( DWMAC_STAT_OWN | DWMAC_STAT_TX_LAST | + DWMAC_STAT_TX_FIRST | DWMAC_STAT_TX_CHAIN ); + wmb(); + + /* Initiate transmission */ + writel ( 0, ( dwmac->regs + DWMAC_TXPOLL ) ); + + DBGC2 ( dwmac, "DWMAC %s TX %d is [%08lx,%08lx)\n", + dwmac->name, tx_idx, virt_to_phys ( iobuf->data ), + ( virt_to_phys ( iobuf->data ) + iob_len ( iobuf ) ) ); + return 0; +} + +/** + * Poll for completed packets + * + * @V netdev Network device + */ +static void dwmac_poll_tx ( struct net_device *netdev ) { + struct dwmac *dwmac = netdev->priv; + struct dwmac_descriptor *tx; + unsigned int tx_idx; + + /* Check for completed packets */ + while ( dwmac->tx.cons != dwmac->tx.prod ) { + + /* Get next transmit descriptor */ + tx_idx = ( dwmac->tx.cons % DWMAC_NUM_TX_DESC ); + tx = &dwmac->tx.desc[tx_idx]; + + /* Stop if descriptor is still owned by hardware */ + if ( tx->stat & cpu_to_le32 ( DWMAC_STAT_OWN ) ) + return; + dwmac->tx.cons++; + + /* Report completion */ + if ( tx->stat & cpu_to_le32 ( DWMAC_STAT_ERR ) ) { + DBGC ( dwmac, "DWMAC %s TX %d error %#08x\n", + dwmac->name, tx_idx, le32_to_cpu ( tx->stat ) ); + dwmac_dump ( dwmac ); + netdev_tx_complete_next_err ( netdev, -EIO ); + } else { + DBGC2 ( dwmac, "DWMAC %s TX %d complete\n", + dwmac->name, tx_idx ); + netdev_tx_complete_next ( netdev ); + } + } +} + +/** + * Poll for received packets + * + * @v netdev Network device + */ +static void dwmac_poll_rx ( struct net_device *netdev ) { + struct dwmac *dwmac = netdev->priv; + struct dwmac_descriptor *rx; + struct io_buffer *iobuf; + unsigned int rx_idx; + uint32_t stat; + size_t len; + + /* Check for received packets */ + while ( dwmac->rx.cons != dwmac->rx.prod ) { + + /* Get next receive descriptor */ + rx_idx = ( dwmac->rx.cons % DWMAC_NUM_RX_DESC ); + rx = &dwmac->rx.desc[rx_idx]; + + /* Stop if descriptor is still in use */ + if ( rx->stat & cpu_to_le32 ( DWMAC_STAT_OWN ) ) + return; + dwmac->rx.cons++; + + /* Consume I/O buffer */ + iobuf = dwmac->rx_iobuf[rx_idx]; + assert ( iobuf != NULL ); + dwmac->rx_iobuf[rx_idx] = NULL; + + /* Hand off to network stack */ + stat = le32_to_cpu ( rx->stat ); + assert ( stat & DWMAC_STAT_RX_FIRST ); + assert ( stat & DWMAC_STAT_RX_LAST ); + if ( stat & DWMAC_STAT_ERR ) { + DBGC ( dwmac, "DWMAC %s RX %d error %#08x\n", + dwmac->name, rx_idx, stat ); + dwmac_dump ( dwmac ); + netdev_rx_err ( netdev, iobuf, -EIO ); + } else { + len = ( DWMAC_STAT_RX_LEN ( stat ) - 4 /* CRC */ ); + iob_put ( iobuf, len ); + DBGC2 ( dwmac, "DWMAC %s RX %d complete (length " + "%zd)\n", dwmac->name, rx_idx, len ); + netdev_rx ( netdev, iobuf ); + } + } +} + +/** + * Poll for completed and received packets + * + * @v netdev Network device + */ +static void dwmac_poll ( struct net_device *netdev ) { + struct dwmac *dwmac = netdev->priv; + uint32_t status; + + /* Check for link status changes */ + status = readl ( dwmac->regs + DWMAC_STATUS ); + if ( status & DWMAC_STATUS_LINK ) + dwmac_check_link ( netdev ); + + /* Poll for TX competions, if applicable */ + dwmac_poll_tx ( netdev ); + + /* Poll for RX completions */ + dwmac_poll_rx ( netdev ); + + /* Refill RX ring */ + dwmac_refill_rx ( dwmac ); +} + +/** DesignWare MAC network device operations */ +static struct net_device_operations dwmac_operations = { + .open = dwmac_open, + .close = dwmac_close, + .transmit = dwmac_transmit, + .poll = dwmac_poll, +}; + +/****************************************************************************** + * + * Devicetree interface + * + ****************************************************************************** + */ + +/** + * Probe devicetree device + * + * @v dt Devicetree device + * @v offset Starting node offset + * @ret rc Return status code + */ +static int dwmac_probe ( struct dt_device *dt, unsigned int offset ) { + struct net_device *netdev; + struct dwmac *dwmac; + union dwmac_mac mac; + int rc; + + /* Allocate and initialise net device */ + netdev = alloc_etherdev ( sizeof ( *dwmac ) ); + if ( ! netdev ) { + rc = -ENOMEM; + goto err_alloc; + } + netdev_init ( netdev, &dwmac_operations ); + dwmac = netdev->priv; + dt_set_drvdata ( dt, netdev ); + netdev->dev = &dt->dev; + netdev->dma = &dt->dma; + memset ( dwmac, 0, sizeof ( *dwmac ) ); + dwmac->dma = &dt->dma; + dwmac->name = netdev->dev->name; + dwmac_init_ring ( &dwmac->tx, DWMAC_NUM_TX_DESC, DWMAC_TXBASE, + ( DWMAC_CTRL_TX_FIRST | DWMAC_CTRL_TX_LAST | + DWMAC_CTRL_CHAIN ) ); + dwmac_init_ring ( &dwmac->rx, DWMAC_NUM_RX_DESC, DWMAC_RXBASE, + DWMAC_CTRL_CHAIN ); + + /* Map registers */ + dwmac->regs = dt_ioremap ( dt, offset, DWMAC_REG_IDX, DWMAC_REG_LEN ); + if ( ! dwmac->regs ) { + rc = -ENODEV; + goto err_ioremap; + } + + /* Fetch devicetree MAC address */ + if ( ( rc = fdt_mac ( &sysfdt, offset, netdev ) ) != 0 ) { + DBGC ( dwmac, "DWMAC %s could not fetch MAC: %s\n", + dwmac->name, strerror ( rc ) ); + goto err_mac; + } + + /* Fetch current MAC address, if set */ + mac.reg.addrl = readl ( dwmac->regs + DWMAC_ADDRL ); + mac.reg.addrh = readl ( dwmac->regs + DWMAC_ADDRH ); + memcpy ( netdev->ll_addr, mac.raw, ETH_ALEN ); + + /* Reset the NIC */ + if ( ( rc = dwmac_reset ( dwmac ) ) != 0 ) + goto err_reset; + + /* Register network device */ + if ( ( rc = register_netdev ( netdev ) ) != 0 ) + goto err_register_netdev; + + /* Update link state */ + dwmac_check_link ( netdev ); + + return 0; + + unregister_netdev ( netdev ); + err_register_netdev: + dwmac_reset ( dwmac ); + err_reset: + err_mac: + iounmap ( dwmac->regs ); + err_ioremap: + netdev_nullify ( netdev ); + netdev_put ( netdev ); + err_alloc: + return rc; +} + +/** + * Remove devicetree device + * + * @v dt Devicetree device + */ +static void dwmac_remove ( struct dt_device *dt ) { + struct net_device *netdev = dt_get_drvdata ( dt ); + struct dwmac *dwmac = netdev->priv; + + /* Unregister network device */ + unregister_netdev ( netdev ); + + /* Reset card */ + dwmac_reset ( dwmac ); + + /* Free network device */ + iounmap ( dwmac->regs ); + netdev_nullify ( netdev ); + netdev_put ( netdev ); +} + +/** DesignWare MAC compatible model identifiers */ +static const char * dwmac_ids[] = { + "thead,light-dwmac", + "snps,dwmac", +}; + +/** DesignWare MAC devicetree driver */ +struct dt_driver dwmac_driver __dt_driver = { + .name = "dwmac", + .ids = dwmac_ids, + .id_count = ( sizeof ( dwmac_ids ) / sizeof ( dwmac_ids[0] ) ), + .probe = dwmac_probe, + .remove = dwmac_remove, +}; diff --git a/src/drivers/net/dwmac.h b/src/drivers/net/dwmac.h new file mode 100644 index 000000000..d36bfd4da --- /dev/null +++ b/src/drivers/net/dwmac.h @@ -0,0 +1,238 @@ +#ifndef _DWMAC_H +#define _DWMAC_H + +/** @file + * + * Synopsys DesignWare MAC network driver + * + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#include +#include + +/** I/O region index */ +#define DWMAC_REG_IDX 0 + +/** I/O region length */ +#define DWMAC_REG_LEN 0x2000 + +/** MAC register block */ +#define DWMAC_MAC 0x0000 +#define DWMAC_MAC_REG( n ) ( DWMAC_MAC + ( (n) * 4 ) ) + +/** MAC configuration register */ +#define DWMAC_CFG DWMAC_MAC_REG ( 0 ) +#define DWMAC_CFG_DO 0x00002000 /**< Disable RX own frames */ +#define DWMAC_CFG_FD 0x00000800 /**< Full duplex */ +#define DWMAC_CFG_TXEN 0x00000008 /**< TX enabled */ +#define DWMAC_CFG_RXEN 0x00000004 /**< RX enabled */ + +/** MAC filter register */ +#define DWMAC_FILTER DWMAC_MAC_REG ( 1 ) +#define DWMAC_FILTER_PR 0x00000001 /**< Promiscuous mode */ + +/** Flow control register */ +#define DWMAC_FLOW DWMAC_MAC_REG ( 6 ) + +/** Version register */ +#define DWMAC_VER DWMAC_MAC_REG ( 8 ) + +/** Debug register */ +#define DWMAC_DEBUG DWMAC_MAC_REG ( 9 ) + +/** Interrupt status register */ +#define DWMAC_ISR DWMAC_MAC_REG ( 14 ) + +/** MAC address high register */ +#define DWMAC_ADDRH DWMAC_MAC_REG ( 16 ) + +/** MAC address low register */ +#define DWMAC_ADDRL DWMAC_MAC_REG ( 17 ) + +/** A DesignWare MAC address */ +union dwmac_mac { + struct { + uint32_t addrl; + uint32_t addrh; + } __attribute__ (( packed )) reg; + uint8_t raw[ETH_ALEN]; +}; + +/** SGMII/RGMII status register */ +#define DWMAC_GMII DWMAC_MAC_REG ( 54 ) +#define DWMAC_GMII_LINK 0x00000008 /**< Link up */ + +/** DMA register block */ +#define DWMAC_DMA 0x1000 +#define DWMAC_DMA_REG( n ) ( DWMAC_DMA + ( (n) * 4 ) ) + +/** Bus mode register */ +#define DWMAC_BUS DWMAC_DMA_REG ( 0 ) +#define DWMAC_BUS_PBL4 0x01000000 /**< 4x PBL mode */ +#define DWMAC_BUS_USP 0x00800000 /**< Use separate PBL */ +#define DWMAC_BUS_RPBL(x) ( (x) << 17 ) /**< RX DMA PBL */ +#define DWMAC_BUS_FB 0x00010000 /**< Fixed burst */ +#define DWMAC_BUS_PBL(x) ( (x) << 8 ) /**< (TX) DMA PBL */ +#define DWMAC_BUS_SWR 0x00000001 /**< Software reset */ + +/** Time to wait for software reset to complete */ +#define DWMAC_RESET_MAX_WAIT_MS 500 + +/** Transmit poll demand register */ +#define DWMAC_TXPOLL DWMAC_DMA_REG ( 1 ) + +/** Receive poll demand register */ +#define DWMAC_RXPOLL DWMAC_DMA_REG ( 2 ) + +/** Receive descriptor list address register */ +#define DWMAC_RXBASE DWMAC_DMA_REG ( 3 ) + +/** Transmit descriptor list address register */ +#define DWMAC_TXBASE DWMAC_DMA_REG ( 4 ) + +/** Status register */ +#define DWMAC_STATUS DWMAC_DMA_REG ( 5 ) +#define DWMAC_STATUS_LINK 0x04000000 /**< Link status change */ + +/** Operation mode register */ +#define DWMAC_OP DWMAC_DMA_REG ( 6 ) +#define DWMAC_OP_RXSF 0x02000000 /**< RX store and forward */ +#define DWMAC_OP_TXSF 0x00200000 /**< TX store and forward */ +#define DWMAC_OP_TXEN 0x00002000 /**< TX enabled */ +#define DWMAC_OP_RXEN 0x00000002 /**< RX enabled */ + +/** Packet drop counter register */ +#define DWMAC_DROP DWMAC_DMA_REG ( 8 ) + +/** AXI bus mode register */ +#define DWMAC_AXI DWMAC_DMA_REG ( 10 ) + +/** AHB or AXI status register */ +#define DWMAC_AHB DWMAC_DMA_REG ( 11 ) + +/** Current transmit descriptor register */ +#define DWMAC_TXDESC DWMAC_DMA_REG ( 18 ) + +/** Current receive descriptor register */ +#define DWMAC_RXDESC DWMAC_DMA_REG ( 19 ) + +/** Current transmit buffer address register */ +#define DWMAC_TXBUF DWMAC_DMA_REG ( 20 ) + +/** Current receive buffer address register */ +#define DWMAC_RXBUF DWMAC_DMA_REG ( 21 ) + +/** Hardware feature register */ +#define DWMAC_FEATURE DWMAC_DMA_REG ( 22 ) + +/** A frame descriptor + * + * We populate the descriptor with values that are valid for both + * normal and enhanced descriptor formats, to avoid needing to care + * about which version of the hardware we have. + */ +struct dwmac_descriptor { + /** Completion status */ + uint32_t stat; + /** Buffer size */ + uint16_t size; + /** Reserved */ + uint8_t reserved_a; + /** Ring control */ + uint8_t ctrl; + /** Buffer address */ + uint32_t addr; + /** Next descriptor address */ + uint32_t next; +} __attribute__ (( packed )); + +/* Completion status */ +#define DWMAC_STAT_OWN 0x80000000 /**< Owned by hardware */ +#define DWMAC_STAT_TX_LAST 0x20000000 /**< Last segment (TX) */ +#define DWMAC_STAT_TX_FIRST 0x10000000 /**< First segment (TX) */ +#define DWMAC_STAT_TX_CHAIN 0x00100000 /**< Chained descriptor (TX) */ +#define DWMAC_STAT_ERR 0x00008000 /**< Error summary */ +#define DWMAC_STAT_RX_FIRST 0x00000200 /**< First segment (RX) */ +#define DWMAC_STAT_RX_LAST 0x00000100 /**< Last segment (RX) */ +#define DWMAC_STAT_RX_LEN(x) \ + ( ( (x) >> 16 ) & 0x3fff ) /**< Frame length (RX) */ + +/** Buffer size */ +#define DWMAC_SIZE_RX_CHAIN 0x4000 /**< Chained descriptor (RX) */ + +/* Ring control */ +#define DWMAC_CTRL_TX_LAST 0x40 /**< Last segment (TX) */ +#define DWMAC_CTRL_TX_FIRST 0x20 /**< First segment (TX) */ +#define DWMAC_CTRL_CHAIN 0x01 /**< Chained descriptor */ + +/** A DesignWare descriptor ring */ +struct dwmac_ring { + /** Descriptors */ + struct dwmac_descriptor *desc; + /** Descriptor ring DMA mapping */ + struct dma_mapping map; + /** Producer index */ + unsigned int prod; + /** Consumer index */ + unsigned int cons; + + /** Queue base address register (within DMA block) */ + uint8_t qbase; + /** Number of descriptors */ + uint8_t count; + /** Default control flags */ + uint8_t ctrl; + /** Length of descriptors */ + size_t len; +}; + +/** Number of transmit descriptors */ +#define DWMAC_NUM_TX_DESC 16 + +/** Number of receive descriptors */ +#define DWMAC_NUM_RX_DESC 16 + +/** Length of receive buffers + * + * Must be a multiple of 16. + */ +#define DWMAC_RX_LEN 1536 + +/** + * Initialise descriptor ring + * + * @v ring Descriptor ring + * @v count Number of descriptors + * @v qbase Queue base address register + * @v ctrl Default descriptor control flags + */ +static inline __attribute__ (( always_inline )) void +dwmac_init_ring ( struct dwmac_ring *ring, unsigned int count, + unsigned int qbase, unsigned int ctrl ) { + + ring->qbase = ( qbase - DWMAC_DMA ); + ring->count = count; + ring->ctrl = ctrl; + ring->len = ( count * sizeof ( ring->desc[0] ) ); +} + +/** A DesignWare MAC network card */ +struct dwmac { + /** Registers */ + void *regs; + /** DMA device */ + struct dma_device *dma; + /** Device name (for debugging) */ + const char *name; + + /** Transmit ring */ + struct dwmac_ring tx; + /** Receive ring */ + struct dwmac_ring rx; + /** Receive I/O buffers */ + struct io_buffer *rx_iobuf[DWMAC_NUM_RX_DESC]; +}; + +#endif /* _DWMAC_H */ diff --git a/src/include/ipxe/errfile.h b/src/include/ipxe/errfile.h index 9eaa784fc..eee71bfaa 100644 --- a/src/include/ipxe/errfile.h +++ b/src/include/ipxe/errfile.h @@ -235,6 +235,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define ERRFILE_atl2_hw ( ERRFILE_DRIVER | 0x00d90000 ) #define ERRFILE_devtree ( ERRFILE_DRIVER | 0x00da0000 ) #define ERRFILE_cgem ( ERRFILE_DRIVER | 0x00db0000 ) +#define ERRFILE_dwmac ( ERRFILE_DRIVER | 0x00dc0000 ) #define ERRFILE_aoe ( ERRFILE_NET | 0x00000000 ) #define ERRFILE_arp ( ERRFILE_NET | 0x00010000 ) -- cgit v1.2.3-55-g7522 From 7ac4b3c6f1c0d40b9e6d799e77df711784029f82 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 15 Jul 2025 09:12:54 +0100 Subject: [efi] Assume that vendor wireless drivers are unusable via SNP The UEFI model for wireless network boot cannot sensibly be described without cursing. Commit 758a504 ("[efi] Inhibit calls to Shutdown() for wireless SNP devices") attempts to work around some of the known issues. Experimentation shows that on at least some platforms (observed with a Lenovo ThinkPad T14s Gen 5) the vendor SNP driver is broken to the point of being unusable in anything other than the single use case envisioned by the firwmare authors. Doing almost anything directly via the SNP protocol interface has a greater than 50% chance of locking up the system. Assume, in the absence of any evidence to the contrary so far, that vendor SNP drivers for wireless network devices are so badly written as to be unusable. Refuse to even attempt to interact with these drivers via the SNP or NII protocol interfaces. Signed-off-by: Michael Brown --- src/drivers/net/efi/mnp.c | 2 +- src/drivers/net/efi/snp.c | 6 ++++-- src/drivers/net/efi/snpnet.c | 16 ++++++++++++++-- src/drivers/net/efi/snpnet.h | 3 ++- src/drivers/net/efi/snponly.c | 16 +++++++++++++++- 5 files changed, 36 insertions(+), 7 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/efi/mnp.c b/src/drivers/net/efi/mnp.c index 3c839d968..212c712df 100644 --- a/src/drivers/net/efi/mnp.c +++ b/src/drivers/net/efi/mnp.c @@ -44,7 +44,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); static int mnp_supported ( EFI_HANDLE device ) { EFI_GUID *binding = &efi_managed_network_service_binding_protocol_guid; - return snpnet_supported ( device, binding ); + return snpnet_supported ( device, binding, 0 ); } /** EFI MNP driver */ diff --git a/src/drivers/net/efi/snp.c b/src/drivers/net/efi/snp.c index 2e0d9df3a..a675050e4 100644 --- a/src/drivers/net/efi/snp.c +++ b/src/drivers/net/efi/snp.c @@ -41,8 +41,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * @ret rc Return status code */ static int snp_supported ( EFI_HANDLE device ) { + EFI_GUID *protocol = &efi_simple_network_protocol_guid; - return snpnet_supported ( device, &efi_simple_network_protocol_guid ); + return snpnet_supported ( device, protocol, 1 ); } /** @@ -52,8 +53,9 @@ static int snp_supported ( EFI_HANDLE device ) { * @ret rc Return status code */ static int nii_supported ( EFI_HANDLE device ) { + EFI_GUID *protocol = &efi_nii31_protocol_guid; - return snpnet_supported ( device, &efi_nii31_protocol_guid ); + return snpnet_supported ( device, protocol, 1 ); } /** EFI SNP driver */ diff --git a/src/drivers/net/efi/snpnet.c b/src/drivers/net/efi/snpnet.c index 109eecf01..8427b6ce3 100644 --- a/src/drivers/net/efi/snpnet.c +++ b/src/drivers/net/efi/snpnet.c @@ -504,9 +504,11 @@ static struct net_device_operations snpnet_operations = { * * @v device EFI device handle * @v protocol Protocol GUID + * @v inhibit_wifi Inhibit wireless devices * @ret rc Return status code */ -int snpnet_supported ( EFI_HANDLE device, EFI_GUID *protocol ) { +int snpnet_supported ( EFI_HANDLE device, EFI_GUID *protocol, + int inhibit_wifi ) { EFI_HANDLE parent; int rc; @@ -536,9 +538,19 @@ int snpnet_supported ( EFI_HANDLE device, EFI_GUID *protocol ) { DBGC2 ( device, "%s\n", efi_handle_name ( parent ) ); return -ENOTTY; } - DBGC ( device, "HANDLE %s is a %s device\n", efi_handle_name ( device ), efi_guid_ntoa ( protocol ) ); + + /* Check for wireless devices, if applicable */ + if ( inhibit_wifi && + ( ( efi_test ( device, &efi_wifi2_protocol_guid ) ) == 0 ) ) { + DBGC ( device, "HANDLE %s is wireless: assuming vendor %s " + "driver is too unreliable to use\n", + efi_handle_name ( device ), + efi_guid_ntoa ( protocol ) ); + return -ENOTTY; + } + return 0; } diff --git a/src/drivers/net/efi/snpnet.h b/src/drivers/net/efi/snpnet.h index d3602a589..507350210 100644 --- a/src/drivers/net/efi/snpnet.h +++ b/src/drivers/net/efi/snpnet.h @@ -11,7 +11,8 @@ FILE_LICENCE ( GPL2_OR_LATER ); struct efi_device; -extern int snpnet_supported ( EFI_HANDLE device, EFI_GUID *protocol ); +extern int snpnet_supported ( EFI_HANDLE device, EFI_GUID *protocol, + int inhibit_wifi ); extern int snpnet_exclude ( EFI_HANDLE device ); extern int snpnet_start ( struct efi_device *efidev ); extern void snpnet_stop ( struct efi_device *efidev ); diff --git a/src/drivers/net/efi/snponly.c b/src/drivers/net/efi/snponly.c index 88c74ed42..f0a5277a2 100644 --- a/src/drivers/net/efi/snponly.c +++ b/src/drivers/net/efi/snponly.c @@ -63,16 +63,20 @@ struct chained_protocol { * reinstalling the protocol instance. */ EFI_HANDLE device; + /** Assume wireless devices are unusable */ + int inhibit_wifi; }; /** Chainloaded SNP protocol */ static struct chained_protocol chained_snp = { .protocol = &efi_simple_network_protocol_guid, + .inhibit_wifi = 1, }; /** Chainloaded NII protocol */ static struct chained_protocol chained_nii = { .protocol = &efi_nii31_protocol_guid, + .inhibit_wifi = 1, }; /** Chainloaded MNP protocol */ @@ -166,10 +170,20 @@ static int chained_supported ( EFI_HANDLE device, efi_guid_ntoa ( chained->protocol ) ); return -ENOTTY; } - DBGC ( device, "CHAINED %s is the chainloaded %s\n", efi_handle_name ( device ), efi_guid_ntoa ( chained->protocol ) ); + + /* Check for wireless devices, if applicable */ + if ( chained->inhibit_wifi && + ( ( efi_test ( device, &efi_wifi2_protocol_guid ) ) == 0 ) ) { + DBGC ( device, "CHAINED %s is wireless: assuming vendor %s " + "driver is too unreliable to use\n", + efi_handle_name ( device ), + efi_guid_ntoa ( chained->protocol ) ); + return -ENOTTY; + } + return 0; } -- cgit v1.2.3-55-g7522 From 1e3fb1b37e16cd7cd30f6b20b9eee929568f35a9 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 15 Jul 2025 14:08:15 +0100 Subject: [init] Show initialisation function names in debug messages Signed-off-by: Michael Brown --- src/arch/x86/core/cpuid_settings.c | 1 + src/arch/x86/core/debugcon.c | 1 + src/arch/x86/core/pci_autoboot.c | 1 + src/arch/x86/core/video_subr.c | 1 + src/arch/x86/interface/pcbios/bios_cachedhcp.c | 1 + src/arch/x86/interface/pcbios/int13con.c | 1 + src/arch/x86/interface/pcbios/pcicloud.c | 1 + src/arch/x86/interface/pxe/pxe_call.c | 1 + src/arch/x86/interface/vmware/guestinfo.c | 1 + src/arch/x86/interface/vmware/vmconsole.c | 1 + src/core/acpi_settings.c | 1 + src/core/fnrec.c | 1 + src/core/init.c | 4 +++- src/core/malloc.c | 1 + src/core/memmap_settings.c | 1 + src/core/process.c | 1 + src/core/serial.c | 1 + src/core/settings.c | 1 + src/core/timer.c | 1 + src/crypto/certstore.c | 1 + src/crypto/des.c | 1 + src/crypto/x25519.c | 1 + src/drivers/bus/pci_settings.c | 1 + src/drivers/bus/usb_settings.c | 1 + src/drivers/net/efi/snponly.c | 1 + src/image/embedded.c | 1 + src/include/ipxe/init.h | 1 + src/interface/efi/efi_cacert.c | 1 + src/interface/efi/efi_console.c | 1 + src/interface/efi/efi_fdt.c | 1 + src/interface/efi/efi_settings.c | 1 + src/interface/efi/efiprefix.c | 1 + src/interface/smbios/smbios_settings.c | 1 + src/net/netdev_settings.c | 1 + src/tests/bofm_test.c | 1 + src/tests/test.c | 1 + 36 files changed, 38 insertions(+), 1 deletion(-) (limited to 'src/drivers') diff --git a/src/arch/x86/core/cpuid_settings.c b/src/arch/x86/core/cpuid_settings.c index 9bc69f477..44d38debc 100644 --- a/src/arch/x86/core/cpuid_settings.c +++ b/src/arch/x86/core/cpuid_settings.c @@ -250,6 +250,7 @@ static void cpuid_settings_init ( void ) { /** CPUID settings initialiser */ struct init_fn cpuid_settings_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "cpuid", .initialise = cpuid_settings_init, }; diff --git a/src/arch/x86/core/debugcon.c b/src/arch/x86/core/debugcon.c index 60de61f55..0e3a5dfc7 100644 --- a/src/arch/x86/core/debugcon.c +++ b/src/arch/x86/core/debugcon.c @@ -86,5 +86,6 @@ static void debugcon_init ( void ) { * Debug port console initialisation function */ struct init_fn debugcon_init_fn __init_fn ( INIT_EARLY ) = { + .name = "debugcon", .initialise = debugcon_init, }; diff --git a/src/arch/x86/core/pci_autoboot.c b/src/arch/x86/core/pci_autoboot.c index 337598091..243e45026 100644 --- a/src/arch/x86/core/pci_autoboot.c +++ b/src/arch/x86/core/pci_autoboot.c @@ -44,5 +44,6 @@ static void pci_autoboot_init ( void ) { /** PCI autoboot device initialisation function */ struct init_fn pci_autoboot_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "autoboot", .initialise = pci_autoboot_init, }; diff --git a/src/arch/x86/core/video_subr.c b/src/arch/x86/core/video_subr.c index f5cc4cdd4..4e9ef466f 100644 --- a/src/arch/x86/core/video_subr.c +++ b/src/arch/x86/core/video_subr.c @@ -109,5 +109,6 @@ struct console_driver vga_console __console_driver = { }; struct init_fn video_init_fn __init_fn ( INIT_EARLY ) = { + .name = "video", .initialise = video_init, }; diff --git a/src/arch/x86/interface/pcbios/bios_cachedhcp.c b/src/arch/x86/interface/pcbios/bios_cachedhcp.c index 897858143..60191c9c5 100644 --- a/src/arch/x86/interface/pcbios/bios_cachedhcp.c +++ b/src/arch/x86/interface/pcbios/bios_cachedhcp.c @@ -74,5 +74,6 @@ static void cachedhcp_init ( void ) { /** Cached DHCPACK initialisation function */ struct init_fn cachedhcp_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "cachedhcp", .initialise = cachedhcp_init, }; diff --git a/src/arch/x86/interface/pcbios/int13con.c b/src/arch/x86/interface/pcbios/int13con.c index 8106cd153..925228874 100644 --- a/src/arch/x86/interface/pcbios/int13con.c +++ b/src/arch/x86/interface/pcbios/int13con.c @@ -288,6 +288,7 @@ static void int13con_init ( void ) { * INT13 console initialisation function */ struct init_fn int13con_init_fn __init_fn ( INIT_CONSOLE ) = { + .name = "int13con", .initialise = int13con_init, }; diff --git a/src/arch/x86/interface/pcbios/pcicloud.c b/src/arch/x86/interface/pcbios/pcicloud.c index f7d4a2da1..5d4d02ac4 100644 --- a/src/arch/x86/interface/pcbios/pcicloud.c +++ b/src/arch/x86/interface/pcbios/pcicloud.c @@ -191,5 +191,6 @@ static void pcicloud_init ( void ) { /** Cloud VM PCI configuration space access initialisation function */ struct init_fn pcicloud_init_fn __init_fn ( INIT_EARLY ) = { + .name = "pcicloud", .initialise = pcicloud_init, }; diff --git a/src/arch/x86/interface/pxe/pxe_call.c b/src/arch/x86/interface/pxe/pxe_call.c index a530f919f..9a6a20dd3 100644 --- a/src/arch/x86/interface/pxe/pxe_call.c +++ b/src/arch/x86/interface/pxe/pxe_call.c @@ -257,6 +257,7 @@ static void pxe_init_structures ( void ) { /** PXE structure initialiser */ struct init_fn pxe_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "pxe", .initialise = pxe_init_structures, }; diff --git a/src/arch/x86/interface/vmware/guestinfo.c b/src/arch/x86/interface/vmware/guestinfo.c index 4134515c1..c181d96e9 100644 --- a/src/arch/x86/interface/vmware/guestinfo.c +++ b/src/arch/x86/interface/vmware/guestinfo.c @@ -200,6 +200,7 @@ static void guestinfo_init ( void ) { /** GuestInfo settings initialiser */ struct init_fn guestinfo_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "guestinfo", .initialise = guestinfo_init, }; diff --git a/src/arch/x86/interface/vmware/vmconsole.c b/src/arch/x86/interface/vmware/vmconsole.c index f7df4f75b..3b892c837 100644 --- a/src/arch/x86/interface/vmware/vmconsole.c +++ b/src/arch/x86/interface/vmware/vmconsole.c @@ -134,5 +134,6 @@ static void vmconsole_init ( void ) { * VMware logfile console initialisation function */ struct init_fn vmconsole_init_fn __init_fn ( INIT_CONSOLE ) = { + .name = "vmconsole", .initialise = vmconsole_init, }; diff --git a/src/core/acpi_settings.c b/src/core/acpi_settings.c index cdee1f865..63f271855 100644 --- a/src/core/acpi_settings.c +++ b/src/core/acpi_settings.c @@ -156,5 +156,6 @@ static void acpi_settings_init ( void ) { /** ACPI settings initialiser */ struct init_fn acpi_settings_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "acpi", .initialise = acpi_settings_init, }; diff --git a/src/core/fnrec.c b/src/core/fnrec.c index 0430817f8..b63ffc1f5 100644 --- a/src/core/fnrec.c +++ b/src/core/fnrec.c @@ -177,6 +177,7 @@ static void fnrec_init ( void ) { } struct init_fn fnrec_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "fnrec", .initialise = fnrec_init, }; diff --git a/src/core/init.c b/src/core/init.c index c13fd1667..406d22d7b 100644 --- a/src/core/init.c +++ b/src/core/init.c @@ -53,8 +53,10 @@ void initialise ( void ) { struct init_fn *init_fn; /* Call registered initialisation functions */ - for_each_table_entry ( init_fn, INIT_FNS ) + for_each_table_entry ( init_fn, INIT_FNS ) { + DBGC ( colour, "INIT initialising %s...\n", init_fn->name ); init_fn->initialise (); + } } /** diff --git a/src/core/malloc.c b/src/core/malloc.c index 545927a30..a05871085 100644 --- a/src/core/malloc.c +++ b/src/core/malloc.c @@ -765,6 +765,7 @@ static void init_heap ( void ) { /** Memory allocator initialisation function */ struct init_fn heap_init_fn __init_fn ( INIT_EARLY ) = { + .name = "heap", .initialise = init_heap, }; diff --git a/src/core/memmap_settings.c b/src/core/memmap_settings.c index d07e9747e..f54de9150 100644 --- a/src/core/memmap_settings.c +++ b/src/core/memmap_settings.c @@ -243,6 +243,7 @@ static void memmap_settings_init ( void ) { /** Memory map settings initialiser */ struct init_fn memmap_settings_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "memmap", .initialise = memmap_settings_init, }; diff --git a/src/core/process.c b/src/core/process.c index 69852c416..c944b6f50 100644 --- a/src/core/process.c +++ b/src/core/process.c @@ -133,5 +133,6 @@ static void init_processes ( void ) { /** Process initialiser */ struct init_fn process_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "process", .initialise = init_processes, }; diff --git a/src/core/serial.c b/src/core/serial.c index 4b569ffad..0883ad051 100644 --- a/src/core/serial.c +++ b/src/core/serial.c @@ -180,6 +180,7 @@ static void serial_shutdown ( int flags __unused ) { /** Serial console initialisation function */ struct init_fn serial_console_init_fn __init_fn ( INIT_CONSOLE ) = { + .name = "serial", .initialise = serial_init, }; diff --git a/src/core/settings.c b/src/core/settings.c index 9fbf753ab..05e495dcf 100644 --- a/src/core/settings.c +++ b/src/core/settings.c @@ -2819,5 +2819,6 @@ static void builtin_init ( void ) { /** Built-in settings initialiser */ struct init_fn builtin_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "builtin", .initialise = builtin_init, }; diff --git a/src/core/timer.c b/src/core/timer.c index 24745cef7..d45797adb 100644 --- a/src/core/timer.c +++ b/src/core/timer.c @@ -170,6 +170,7 @@ static void timer_probe ( void ) { /** Timer initialisation function */ struct init_fn timer_init_fn __init_fn ( INIT_EARLY ) = { + .name = "timer", .initialise = timer_probe, }; diff --git a/src/crypto/certstore.c b/src/crypto/certstore.c index 81179f9cc..aad874297 100644 --- a/src/crypto/certstore.c +++ b/src/crypto/certstore.c @@ -210,6 +210,7 @@ static void certstore_init ( void ) { /** Certificate store initialisation function */ struct init_fn certstore_init_fn __init_fn ( INIT_LATE ) = { + .name = "certstore", .initialise = certstore_init, }; diff --git a/src/crypto/des.c b/src/crypto/des.c index 6918bec3e..206f78d50 100644 --- a/src/crypto/des.c +++ b/src/crypto/des.c @@ -369,6 +369,7 @@ static void des_init ( void ) { /** Initialisation function */ struct init_fn des_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "des", .initialise = des_init, }; diff --git a/src/crypto/x25519.c b/src/crypto/x25519.c index 995cfa352..41bc5fc5e 100644 --- a/src/crypto/x25519.c +++ b/src/crypto/x25519.c @@ -334,6 +334,7 @@ static void x25519_init_constants ( void ) { /** Initialisation function */ struct init_fn x25519_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "x25519", .initialise = x25519_init_constants, }; diff --git a/src/drivers/bus/pci_settings.c b/src/drivers/bus/pci_settings.c index 84aa76827..fc73c651e 100644 --- a/src/drivers/bus/pci_settings.c +++ b/src/drivers/bus/pci_settings.c @@ -125,5 +125,6 @@ static void pci_settings_init ( void ) { /** PCI device settings initialiser */ struct init_fn pci_settings_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "pci", .initialise = pci_settings_init, }; diff --git a/src/drivers/bus/usb_settings.c b/src/drivers/bus/usb_settings.c index 4fd190d83..bb01f34d5 100644 --- a/src/drivers/bus/usb_settings.c +++ b/src/drivers/bus/usb_settings.c @@ -173,5 +173,6 @@ static void usb_settings_init ( void ) { /** USB device settings initialiser */ struct init_fn usb_settings_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "usb", .initialise = usb_settings_init, }; diff --git a/src/drivers/net/efi/snponly.c b/src/drivers/net/efi/snponly.c index f0a5277a2..876479133 100644 --- a/src/drivers/net/efi/snponly.c +++ b/src/drivers/net/efi/snponly.c @@ -259,5 +259,6 @@ static void chained_init ( void ) { /** EFI chainloaded-device-only initialisation function */ struct init_fn chained_init_fn __init_fn ( INIT_LATE ) = { + .name = "chained", .initialise = chained_init, }; diff --git a/src/image/embedded.c b/src/image/embedded.c index 2934d4ee7..652cfc85f 100644 --- a/src/image/embedded.c +++ b/src/image/embedded.c @@ -80,5 +80,6 @@ static void embedded_init ( void ) { /** Embedded image initialisation function */ struct init_fn embedded_init_fn __init_fn ( INIT_LATE ) = { + .name = "embedded", .initialise = embedded_init, }; diff --git a/src/include/ipxe/init.h b/src/include/ipxe/init.h index 32927e3a6..da01b2953 100644 --- a/src/include/ipxe/init.h +++ b/src/include/ipxe/init.h @@ -12,6 +12,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * call to initialise(). */ struct init_fn { + const char *name; void ( * initialise ) ( void ); }; diff --git a/src/interface/efi/efi_cacert.c b/src/interface/efi/efi_cacert.c index 2b6c5c343..64bb0bae2 100644 --- a/src/interface/efi/efi_cacert.c +++ b/src/interface/efi/efi_cacert.c @@ -178,6 +178,7 @@ static void efi_cacert_init ( void ) { /** EFI CA certificates initialisation function */ struct init_fn efi_cacert_init_fn __init_fn ( INIT_LATE ) = { + .name = "eficacert", .initialise = efi_cacert_init, }; diff --git a/src/interface/efi/efi_console.c b/src/interface/efi/efi_console.c index 9fc3c65c0..4557671a0 100644 --- a/src/interface/efi/efi_console.c +++ b/src/interface/efi/efi_console.c @@ -448,5 +448,6 @@ static void efi_console_init ( void ) { * EFI console initialisation function */ struct init_fn efi_console_init_fn __init_fn ( INIT_EARLY ) = { + .name = "eficonsole", .initialise = efi_console_init, }; diff --git a/src/interface/efi/efi_fdt.c b/src/interface/efi/efi_fdt.c index 3a90fd7ce..3c249693e 100644 --- a/src/interface/efi/efi_fdt.c +++ b/src/interface/efi/efi_fdt.c @@ -77,6 +77,7 @@ static void efi_fdt_init ( void ) { /** EFI Flattened Device Tree initialisation function */ struct init_fn efi_fdt_init_fn __init_fn ( INIT_EARLY ) = { + .name = "efifdt", .initialise = efi_fdt_init, }; diff --git a/src/interface/efi/efi_settings.c b/src/interface/efi/efi_settings.c index cde0ff8d1..5ddbe12f1 100644 --- a/src/interface/efi/efi_settings.c +++ b/src/interface/efi/efi_settings.c @@ -232,5 +232,6 @@ static void efivars_init ( void ) { /** EFI variable settings initialiser */ struct init_fn efivars_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "efivars", .initialise = efivars_init, }; diff --git a/src/interface/efi/efiprefix.c b/src/interface/efi/efiprefix.c index 10d8f0bf6..ddce6aa60 100644 --- a/src/interface/efi/efiprefix.c +++ b/src/interface/efi/efiprefix.c @@ -98,6 +98,7 @@ static void efi_init_application ( void ) { /** EFI application initialisation function */ struct init_fn efi_init_application_fn __init_fn ( INIT_NORMAL ) = { + .name = "efi", .initialise = efi_init_application, }; diff --git a/src/interface/smbios/smbios_settings.c b/src/interface/smbios/smbios_settings.c index 1fe545f38..6358a4709 100644 --- a/src/interface/smbios/smbios_settings.c +++ b/src/interface/smbios/smbios_settings.c @@ -200,6 +200,7 @@ static void smbios_init ( void ) { /** SMBIOS settings initialiser */ struct init_fn smbios_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "smbios", .initialise = smbios_init, }; diff --git a/src/net/netdev_settings.c b/src/net/netdev_settings.c index 9432dc2fa..90b804c6c 100644 --- a/src/net/netdev_settings.c +++ b/src/net/netdev_settings.c @@ -429,6 +429,7 @@ static void netdev_redirect_settings_init ( void ) { /** "netX" settings initialiser */ struct init_fn netdev_redirect_settings_init_fn __init_fn ( INIT_LATE ) = { + .name = "netX", .initialise = netdev_redirect_settings_init, }; diff --git a/src/tests/bofm_test.c b/src/tests/bofm_test.c index 6d472bc7e..bc400284f 100644 --- a/src/tests/bofm_test.c +++ b/src/tests/bofm_test.c @@ -278,5 +278,6 @@ static void bofm_test_init ( void ) { /** BOFM test initialisation function */ struct init_fn bofm_test_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "bofm", .initialise = bofm_test_init, }; diff --git a/src/tests/test.c b/src/tests/test.c index 9fa12e27a..e4f5eb838 100644 --- a/src/tests/test.c +++ b/src/tests/test.c @@ -180,5 +180,6 @@ static void test_init ( void ) { /** Self-test initialisation function */ struct init_fn test_init_fn __init_fn ( INIT_EARLY ) = { + .name = "test", .initialise = test_init, }; -- cgit v1.2.3-55-g7522 From eca97c2ee2e44c606f6c9664003751ae0f444c72 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 18 Jul 2025 14:24:23 +0100 Subject: [xhci] Use root hub port number to determine slot type We currently use the downstream hub's port number to determine the xHCI slot type for a newly connected USB device. The downstream hub port number is irrelevant to the xHCI controller's supported protocols table: the relevant value is the number of the root hub port through which the device is attached. Fix by using the root hub port number instead of the immediate parent hub's port number. This bug has not previously been detected since the slot type for the first N root hub ports will invariably be zero to indicate that these are USB ports. For any xHCI controller with a sufficiently large number of root hub ports, the code would therefore end up happening to calculate the correct slot type value despite using an incorrect port number. Signed-off-by: Michael Brown --- src/drivers/usb/xhci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/drivers') diff --git a/src/drivers/usb/xhci.c b/src/drivers/usb/xhci.c index 30ee09bbb..b7781f3ed 100644 --- a/src/drivers/usb/xhci.c +++ b/src/drivers/usb/xhci.c @@ -2770,6 +2770,7 @@ static int xhci_endpoint_stream ( struct usb_endpoint *ep, */ static int xhci_device_open ( struct usb_device *usb ) { struct xhci_device *xhci = usb_bus_get_hostdata ( usb->port->hub->bus ); + struct usb_port *root_port = usb_root_hub_port ( usb ); struct usb_port *tt = usb_transaction_translator ( usb ); struct xhci_slot *slot; struct xhci_slot *tt_slot; @@ -2779,7 +2780,7 @@ static int xhci_device_open ( struct usb_device *usb ) { int rc; /* Determine applicable slot type */ - type = xhci_port_slot_type ( xhci, usb->port->address ); + type = xhci_port_slot_type ( xhci, root_port->address ); if ( type < 0 ) { rc = type; DBGC ( xhci, "XHCI %s-%d has no slot type\n", -- cgit v1.2.3-55-g7522 From 6c42ea1275fffc11fc8558c9ebed6d526d5d9fa1 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 21 Jul 2025 13:43:32 +0100 Subject: [xhci] Allow for non-PCI xHCI host controllers Allow for the existence of xHCI host controllers where the underlying hardware is not a PCI device. Signed-off-by: Michael Brown --- src/drivers/usb/xhci.c | 136 ++++-- src/drivers/usb/xhci.h | 1178 ---------------------------------------------- src/include/ipxe/xhci.h | 1184 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1273 insertions(+), 1225 deletions(-) delete mode 100644 src/drivers/usb/xhci.h create mode 100644 src/include/ipxe/xhci.h (limited to 'src/drivers') diff --git a/src/drivers/usb/xhci.c b/src/drivers/usb/xhci.c index b7781f3ed..440c347c8 100644 --- a/src/drivers/usb/xhci.c +++ b/src/drivers/usb/xhci.c @@ -35,7 +35,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include "xhci.h" +#include /** @file * @@ -259,9 +259,8 @@ static struct profiler xhci_transfer_profiler __profiler = * Initialise device * * @v xhci xHCI device - * @v regs MMIO registers */ -static void xhci_init ( struct xhci_device *xhci, void *regs ) { +void xhci_init ( struct xhci_device *xhci ) { uint32_t hcsparams1; uint32_t hcsparams2; uint32_t hccparams1; @@ -270,8 +269,11 @@ static void xhci_init ( struct xhci_device *xhci, void *regs ) { size_t rtsoff; size_t dboff; + /* Set device name */ + xhci->name = xhci->dev->name; + /* Locate capability, operational, runtime, and doorbell registers */ - xhci->cap = regs; + xhci->cap = xhci->regs; caplength = readb ( xhci->cap + XHCI_CAP_CAPLENGTH ); rtsoff = readl ( xhci->cap + XHCI_CAP_RTSOFF ); dboff = readl ( xhci->cap + XHCI_CAP_DBOFF ); @@ -310,6 +312,10 @@ static void xhci_init ( struct xhci_device *xhci, void *regs ) { assert ( ( ( xhci->pagesize ) & ( xhci->pagesize - 1 ) ) == 0 ); DBGC2 ( xhci, "XHCI %s page size %zd bytes\n", xhci->name, xhci->pagesize ); + + /* Configure DMA device */ + if ( xhci->dma && xhci->addr64 ) + dma_set_mask_64bit ( xhci->dma ); } /** @@ -3264,7 +3270,7 @@ static int xhci_root_clear_tt ( struct usb_hub *hub, struct usb_port *port, /****************************************************************************** * - * PCI interface + * Hardware-independent interface * ****************************************************************************** */ @@ -3303,6 +3309,75 @@ static struct usb_host_operations xhci_operations = { }, }; +/** + * Register xHCI controller + * + * @v xhci xHCI device + * @ret rc Return status code + */ +int xhci_register ( struct xhci_device *xhci ) { + struct usb_port *port; + unsigned int i; + int rc; + + /* Reset device */ + if ( ( rc = xhci_reset ( xhci ) ) != 0 ) + goto err_reset; + + /* Allocate USB bus */ + xhci->bus = alloc_usb_bus ( xhci->dev, xhci->ports, XHCI_MTU, + &xhci_operations ); + if ( ! xhci->bus ) { + rc = -ENOMEM; + goto err_alloc_bus; + } + usb_bus_set_hostdata ( xhci->bus, xhci ); + usb_hub_set_drvdata ( xhci->bus->hub, xhci ); + + /* Set port protocols */ + for ( i = 1 ; i <= xhci->ports ; i++ ) { + port = usb_port ( xhci->bus->hub, i ); + port->protocol = xhci_port_protocol ( xhci, i ); + } + + /* Register USB bus */ + if ( ( rc = register_usb_bus ( xhci->bus ) ) != 0 ) + goto err_register; + + return 0; + + unregister_usb_bus ( xhci->bus ); + err_register: + free_usb_bus ( xhci->bus ); + err_alloc_bus: + xhci_reset ( xhci ); + err_reset: + return rc; +} + +/** + * Unregister xHCI controller + * + * @v xhci xHCI device + */ +void xhci_unregister ( struct xhci_device *xhci ) { + struct usb_bus *bus = xhci->bus; + + /* Unregister and free USB bus */ + unregister_usb_bus ( bus ); + free_usb_bus ( bus ); + + /* Reset device */ + xhci_reset ( xhci ); +} + +/****************************************************************************** + * + * PCI interface + * + ****************************************************************************** + */ + /** * Fix Intel PCH-specific quirks * @@ -3365,10 +3440,8 @@ static void xhci_pch_undo ( struct xhci_device *xhci, struct pci_device *pci ) { */ static int xhci_probe ( struct pci_device *pci ) { struct xhci_device *xhci; - struct usb_port *port; unsigned long bar_start; size_t bar_size; - unsigned int i; int rc; /* Allocate and initialise structure */ @@ -3377,7 +3450,8 @@ static int xhci_probe ( struct pci_device *pci ) { rc = -ENOMEM; goto err_alloc; } - xhci->name = pci->dev.name; + xhci->dev = &pci->dev; + xhci->dma = &pci->dma; xhci->quirks = pci->id->driver_data; /* Fix up PCI device */ @@ -3393,12 +3467,7 @@ static int xhci_probe ( struct pci_device *pci ) { } /* Initialise xHCI device */ - xhci_init ( xhci, xhci->regs ); - - /* Configure DMA device */ - xhci->dma = &pci->dma; - if ( xhci->addr64 ) - dma_set_mask_64bit ( xhci->dma ); + xhci_init ( xhci ); /* Initialise USB legacy support and claim ownership */ xhci_legacy_init ( xhci ); @@ -3408,39 +3477,15 @@ static int xhci_probe ( struct pci_device *pci ) { if ( xhci->quirks & XHCI_PCH ) xhci_pch_fix ( xhci, pci ); - /* Reset device */ - if ( ( rc = xhci_reset ( xhci ) ) != 0 ) - goto err_reset; - - /* Allocate USB bus */ - xhci->bus = alloc_usb_bus ( &pci->dev, xhci->ports, XHCI_MTU, - &xhci_operations ); - if ( ! xhci->bus ) { - rc = -ENOMEM; - goto err_alloc_bus; - } - usb_bus_set_hostdata ( xhci->bus, xhci ); - usb_hub_set_drvdata ( xhci->bus->hub, xhci ); - - /* Set port protocols */ - for ( i = 1 ; i <= xhci->ports ; i++ ) { - port = usb_port ( xhci->bus->hub, i ); - port->protocol = xhci_port_protocol ( xhci, i ); - } - - /* Register USB bus */ - if ( ( rc = register_usb_bus ( xhci->bus ) ) != 0 ) + /* Register xHCI device */ + if ( ( rc = xhci_register ( xhci ) ) != 0 ) goto err_register; pci_set_drvdata ( pci, xhci ); return 0; - unregister_usb_bus ( xhci->bus ); + xhci_unregister ( xhci ); err_register: - free_usb_bus ( xhci->bus ); - err_alloc_bus: - xhci_reset ( xhci ); - err_reset: if ( xhci->quirks & XHCI_PCH ) xhci_pch_undo ( xhci, pci ); xhci_legacy_release ( xhci ); @@ -3458,7 +3503,6 @@ static int xhci_probe ( struct pci_device *pci ) { */ static void xhci_remove ( struct pci_device *pci ) { struct xhci_device *xhci = pci_get_drvdata ( pci ); - struct usb_bus *bus = xhci->bus; uint16_t command; /* Some systems are observed to disable bus mastering on @@ -3473,12 +3517,10 @@ static void xhci_remove ( struct pci_device *pci ) { xhci_fail ( xhci ); } - /* Unregister and free USB bus */ - unregister_usb_bus ( bus ); - free_usb_bus ( bus ); + /* Unregister xHCI controller */ + xhci_unregister ( xhci ); - /* Reset device and undo any PCH-specific fixes */ - xhci_reset ( xhci ); + /* Undo any PCH-specific fixes */ if ( xhci->quirks & XHCI_PCH ) xhci_pch_undo ( xhci, pci ); diff --git a/src/drivers/usb/xhci.h b/src/drivers/usb/xhci.h deleted file mode 100644 index 22bc115c2..000000000 --- a/src/drivers/usb/xhci.h +++ /dev/null @@ -1,1178 +0,0 @@ -#ifndef _IPXE_XHCI_H -#define _IPXE_XHCI_H - -/** @file - * - * USB eXtensible Host Controller Interface (xHCI) driver - * - */ - -FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); - -#include -#include -#include - -/** Minimum alignment required for data structures - * - * With the exception of the scratchpad buffer pages (which are - * page-aligned), data structures used by xHCI generally require from - * 16 to 64 byte alignment and must not cross an (xHCI) page boundary. - * We simplify this requirement by aligning each structure on its own - * size, with a minimum of a 64 byte alignment. - */ -#define XHCI_MIN_ALIGN 64 - -/** Maximum transfer size */ -#define XHCI_MTU 65536 - -/** xHCI PCI BAR */ -#define XHCI_BAR PCI_BASE_ADDRESS_0 - -/** Capability register length */ -#define XHCI_CAP_CAPLENGTH 0x00 - -/** Host controller interface version number */ -#define XHCI_CAP_HCIVERSION 0x02 - -/** Structural parameters 1 */ -#define XHCI_CAP_HCSPARAMS1 0x04 - -/** Number of device slots */ -#define XHCI_HCSPARAMS1_SLOTS(params) ( ( (params) >> 0 ) & 0xff ) - -/** Number of interrupters */ -#define XHCI_HCSPARAMS1_INTRS(params) ( ( (params) >> 8 ) & 0x3ff ) - -/** Number of ports */ -#define XHCI_HCSPARAMS1_PORTS(params) ( ( (params) >> 24 ) & 0xff ) - -/** Structural parameters 2 */ -#define XHCI_CAP_HCSPARAMS2 0x08 - -/** Number of page-sized scratchpad buffers */ -#define XHCI_HCSPARAMS2_SCRATCHPADS(params) \ - ( ( ( (params) >> 16 ) & 0x3e0 ) | ( ( (params) >> 27 ) & 0x1f ) ) - -/** Capability parameters */ -#define XHCI_CAP_HCCPARAMS1 0x10 - -/** 64-bit addressing capability */ -#define XHCI_HCCPARAMS1_ADDR64(params) ( ( (params) >> 0 ) & 0x1 ) - -/** Context size shift */ -#define XHCI_HCCPARAMS1_CSZ_SHIFT(params) ( 5 + ( ( (params) >> 2 ) & 0x1 ) ) - -/** xHCI extended capabilities pointer */ -#define XHCI_HCCPARAMS1_XECP(params) ( ( ( (params) >> 16 ) & 0xffff ) << 2 ) - -/** Doorbell offset */ -#define XHCI_CAP_DBOFF 0x14 - -/** Runtime register space offset */ -#define XHCI_CAP_RTSOFF 0x18 - -/** xHCI extended capability ID */ -#define XHCI_XECP_ID(xecp) ( ( (xecp) >> 0 ) & 0xff ) - -/** Next xHCI extended capability pointer */ -#define XHCI_XECP_NEXT(xecp) ( ( ( (xecp) >> 8 ) & 0xff ) << 2 ) - -/** USB legacy support extended capability */ -#define XHCI_XECP_ID_LEGACY 1 - -/** USB legacy support BIOS owned semaphore */ -#define XHCI_USBLEGSUP_BIOS 0x02 - -/** USB legacy support BIOS ownership flag */ -#define XHCI_USBLEGSUP_BIOS_OWNED 0x01 - -/** USB legacy support OS owned semaphore */ -#define XHCI_USBLEGSUP_OS 0x03 - -/** USB legacy support OS ownership flag */ -#define XHCI_USBLEGSUP_OS_OWNED 0x01 - -/** USB legacy support control/status */ -#define XHCI_USBLEGSUP_CTLSTS 0x04 - -/** Supported protocol extended capability */ -#define XHCI_XECP_ID_SUPPORTED 2 - -/** Supported protocol revision */ -#define XHCI_SUPPORTED_REVISION 0x00 - -/** Supported protocol minor revision */ -#define XHCI_SUPPORTED_REVISION_VER(revision) ( ( (revision) >> 16 ) & 0xffff ) - -/** Supported protocol name */ -#define XHCI_SUPPORTED_NAME 0x04 - -/** Supported protocol ports */ -#define XHCI_SUPPORTED_PORTS 0x08 - -/** Supported protocol port offset */ -#define XHCI_SUPPORTED_PORTS_OFFSET(ports) ( ( (ports) >> 0 ) & 0xff ) - -/** Supported protocol port count */ -#define XHCI_SUPPORTED_PORTS_COUNT(ports) ( ( (ports) >> 8 ) & 0xff ) - -/** Supported protocol PSI count */ -#define XHCI_SUPPORTED_PORTS_PSIC(ports) ( ( (ports) >> 28 ) & 0x0f ) - -/** Supported protocol slot */ -#define XHCI_SUPPORTED_SLOT 0x0c - -/** Supported protocol slot type */ -#define XHCI_SUPPORTED_SLOT_TYPE(slot) ( ( (slot) >> 0 ) & 0x1f ) - -/** Supported protocol PSI */ -#define XHCI_SUPPORTED_PSI(index) ( 0x10 + ( (index) * 4 ) ) - -/** Supported protocol PSI value */ -#define XHCI_SUPPORTED_PSI_VALUE(psi) ( ( (psi) >> 0 ) & 0x0f ) - -/** Supported protocol PSI mantissa */ -#define XHCI_SUPPORTED_PSI_MANTISSA(psi) ( ( (psi) >> 16 ) & 0xffff ) - -/** Supported protocol PSI exponent */ -#define XHCI_SUPPORTED_PSI_EXPONENT(psi) ( ( (psi) >> 4 ) & 0x03 ) - -/** Default PSI values */ -enum xhci_default_psi_value { - /** Full speed (12Mbps) */ - XHCI_SPEED_FULL = 1, - /** Low speed (1.5Mbps) */ - XHCI_SPEED_LOW = 2, - /** High speed (480Mbps) */ - XHCI_SPEED_HIGH = 3, - /** Super speed */ - XHCI_SPEED_SUPER = 4, -}; - -/** USB command register */ -#define XHCI_OP_USBCMD 0x00 - -/** Run/stop */ -#define XHCI_USBCMD_RUN 0x00000001UL - -/** Host controller reset */ -#define XHCI_USBCMD_HCRST 0x00000002UL - -/** USB status register */ -#define XHCI_OP_USBSTS 0x04 - -/** Host controller halted */ -#define XHCI_USBSTS_HCH 0x00000001UL - -/** Page size register */ -#define XHCI_OP_PAGESIZE 0x08 - -/** Page size */ -#define XHCI_PAGESIZE(pagesize) ( (pagesize) << 12 ) - -/** Device notifcation control register */ -#define XHCI_OP_DNCTRL 0x14 - -/** Command ring control register */ -#define XHCI_OP_CRCR 0x18 - -/** Command ring cycle state */ -#define XHCI_CRCR_RCS 0x00000001UL - -/** Command abort */ -#define XHCI_CRCR_CA 0x00000004UL - -/** Command ring running */ -#define XHCI_CRCR_CRR 0x00000008UL - -/** Device context base address array pointer */ -#define XHCI_OP_DCBAAP 0x30 - -/** Configure register */ -#define XHCI_OP_CONFIG 0x38 - -/** Maximum device slots enabled */ -#define XHCI_CONFIG_MAX_SLOTS_EN(slots) ( (slots) << 0 ) - -/** Maximum device slots enabled mask */ -#define XHCI_CONFIG_MAX_SLOTS_EN_MASK \ - XHCI_CONFIG_MAX_SLOTS_EN ( 0xff ) - -/** Port status and control register */ -#define XHCI_OP_PORTSC(port) ( 0x400 - 0x10 + ( (port) << 4 ) ) - -/** Current connect status */ -#define XHCI_PORTSC_CCS 0x00000001UL - -/** Port enabled */ -#define XHCI_PORTSC_PED 0x00000002UL - -/** Port reset */ -#define XHCI_PORTSC_PR 0x00000010UL - -/** Port link state */ -#define XHCI_PORTSC_PLS(pls) ( (pls) << 5 ) - -/** Disabled port link state */ -#define XHCI_PORTSC_PLS_DISABLED XHCI_PORTSC_PLS ( 4 ) - -/** RxDetect port link state */ -#define XHCI_PORTSC_PLS_RXDETECT XHCI_PORTSC_PLS ( 5 ) - -/** Port link state mask */ -#define XHCI_PORTSC_PLS_MASK XHCI_PORTSC_PLS ( 0xf ) - -/** Port power */ -#define XHCI_PORTSC_PP 0x00000200UL - -/** Time to delay after enabling power to a port */ -#define XHCI_PORT_POWER_DELAY_MS 20 - -/** Port speed ID value */ -#define XHCI_PORTSC_PSIV(portsc) ( ( (portsc) >> 10 ) & 0xf ) - -/** Port indicator control */ -#define XHCI_PORTSC_PIC(indicators) ( (indicators) << 14 ) - -/** Port indicator control mask */ -#define XHCI_PORTSC_PIC_MASK XHCI_PORTSC_PIC ( 3 ) - -/** Port link state write strobe */ -#define XHCI_PORTSC_LWS 0x00010000UL - -/** Time to delay after writing the port link state */ -#define XHCI_LINK_STATE_DELAY_MS 100 - -/** Connect status change */ -#define XHCI_PORTSC_CSC 0x00020000UL - -/** Port enabled/disabled change */ -#define XHCI_PORTSC_PEC 0x00040000UL - -/** Warm port reset change */ -#define XHCI_PORTSC_WRC 0x00080000UL - -/** Over-current change */ -#define XHCI_PORTSC_OCC 0x00100000UL - -/** Port reset change */ -#define XHCI_PORTSC_PRC 0x00200000UL - -/** Port link state change */ -#define XHCI_PORTSC_PLC 0x00400000UL - -/** Port config error change */ -#define XHCI_PORTSC_CEC 0x00800000UL - -/** Port status change mask */ -#define XHCI_PORTSC_CHANGE \ - ( XHCI_PORTSC_CSC | XHCI_PORTSC_PEC | XHCI_PORTSC_WRC | \ - XHCI_PORTSC_OCC | XHCI_PORTSC_PRC | XHCI_PORTSC_PLC | \ - XHCI_PORTSC_CEC ) - -/** Port status and control bits which should be preserved - * - * The port status and control register is a horrendous mix of - * differing semantics. Some bits are written to only when a separate - * write strobe bit is set. Some bits should be preserved when - * modifying other bits. Some bits will be cleared if written back as - * a one. Most excitingly, the "port enabled" bit has the semantics - * that 1=enabled, 0=disabled, yet writing a 1 will disable the port. - */ -#define XHCI_PORTSC_PRESERVE ( XHCI_PORTSC_PP | XHCI_PORTSC_PIC_MASK ) - -/** Port power management status and control register */ -#define XHCI_OP_PORTPMSC(port) ( 0x404 - 0x10 + ( (port) << 4 ) ) - -/** Port link info register */ -#define XHCI_OP_PORTLI(port) ( 0x408 - 0x10 + ( (port) << 4 ) ) - -/** Port hardware link power management control register */ -#define XHCI_OP_PORTHLPMC(port) ( 0x40c - 0x10 + ( (port) << 4 ) ) - -/** Event ring segment table size register */ -#define XHCI_RUN_ERSTSZ(intr) ( 0x28 + ( (intr) << 5 ) ) - -/** Event ring segment table base address register */ -#define XHCI_RUN_ERSTBA(intr) ( 0x30 + ( (intr) << 5 ) ) - -/** Event ring dequeue pointer register */ -#define XHCI_RUN_ERDP(intr) ( 0x38 + ( (intr) << 5 ) ) - -/** A transfer request block template */ -struct xhci_trb_template { - /** Parameter */ - uint64_t parameter; - /** Status */ - uint32_t status; - /** Control */ - uint32_t control; -}; - -/** A transfer request block */ -struct xhci_trb_common { - /** Reserved */ - uint64_t reserved_a; - /** Reserved */ - uint32_t reserved_b; - /** Flags */ - uint8_t flags; - /** Type */ - uint8_t type; - /** Reserved */ - uint16_t reserved_c; -} __attribute__ (( packed )); - -/** Transfer request block cycle bit flag */ -#define XHCI_TRB_C 0x01 - -/** Transfer request block toggle cycle bit flag */ -#define XHCI_TRB_TC 0x02 - -/** Transfer request block chain flag */ -#define XHCI_TRB_CH 0x10 - -/** Transfer request block interrupt on completion flag */ -#define XHCI_TRB_IOC 0x20 - -/** Transfer request block immediate data flag */ -#define XHCI_TRB_IDT 0x40 - -/** Transfer request block type */ -#define XHCI_TRB_TYPE(type) ( (type) << 2 ) - -/** Transfer request block type mask */ -#define XHCI_TRB_TYPE_MASK XHCI_TRB_TYPE ( 0x3f ) - -/** A normal transfer request block */ -struct xhci_trb_normal { - /** Data buffer */ - uint64_t data; - /** Length */ - uint32_t len; - /** Flags */ - uint8_t flags; - /** Type */ - uint8_t type; - /** Reserved */ - uint16_t reserved; -} __attribute__ (( packed )); - -/** A normal transfer request block */ -#define XHCI_TRB_NORMAL XHCI_TRB_TYPE ( 1 ) - -/** Construct TD size field */ -#define XHCI_TD_SIZE(remaining) \ - ( ( ( (remaining) <= 0xf ) ? remaining : 0xf ) << 17 ) - -/** A setup stage transfer request block */ -struct xhci_trb_setup { - /** Setup packet */ - struct usb_setup_packet packet; - /** Length */ - uint32_t len; - /** Flags */ - uint8_t flags; - /** Type */ - uint8_t type; - /** Transfer direction */ - uint8_t direction; - /** Reserved */ - uint8_t reserved; -} __attribute__ (( packed )); - -/** A setup stage transfer request block */ -#define XHCI_TRB_SETUP XHCI_TRB_TYPE ( 2 ) - -/** Setup stage input data direction */ -#define XHCI_SETUP_IN 3 - -/** Setup stage output data direction */ -#define XHCI_SETUP_OUT 2 - -/** A data stage transfer request block */ -struct xhci_trb_data { - /** Data buffer */ - uint64_t data; - /** Length */ - uint32_t len; - /** Flags */ - uint8_t flags; - /** Type */ - uint8_t type; - /** Transfer direction */ - uint8_t direction; - /** Reserved */ - uint8_t reserved; -} __attribute__ (( packed )); - -/** A data stage transfer request block */ -#define XHCI_TRB_DATA XHCI_TRB_TYPE ( 3 ) - -/** Input data direction */ -#define XHCI_DATA_IN 0x01 - -/** Output data direction */ -#define XHCI_DATA_OUT 0x00 - -/** A status stage transfer request block */ -struct xhci_trb_status { - /** Reserved */ - uint64_t reserved_a; - /** Reserved */ - uint32_t reserved_b; - /** Flags */ - uint8_t flags; - /** Type */ - uint8_t type; - /** Direction */ - uint8_t direction; - /** Reserved */ - uint8_t reserved_c; -} __attribute__ (( packed )); - -/** A status stage transfer request block */ -#define XHCI_TRB_STATUS XHCI_TRB_TYPE ( 4 ) - -/** Input status direction */ -#define XHCI_STATUS_IN 0x01 - -/** Output status direction */ -#define XHCI_STATUS_OUT 0x00 - -/** A link transfer request block */ -struct xhci_trb_link { - /** Next ring segment */ - uint64_t next; - /** Reserved */ - uint32_t reserved_a; - /** Flags */ - uint8_t flags; - /** Type */ - uint8_t type; - /** Reserved */ - uint16_t reserved_c; -} __attribute__ (( packed )); - -/** A link transfer request block */ -#define XHCI_TRB_LINK XHCI_TRB_TYPE ( 6 ) - -/** A no-op transfer request block */ -#define XHCI_TRB_NOP XHCI_TRB_TYPE ( 8 ) - -/** An enable slot transfer request block */ -struct xhci_trb_enable_slot { - /** Reserved */ - uint64_t reserved_a; - /** Reserved */ - uint32_t reserved_b; - /** Flags */ - uint8_t flags; - /** Type */ - uint8_t type; - /** Slot type */ - uint8_t slot; - /** Reserved */ - uint8_t reserved_c; -} __attribute__ (( packed )); - -/** An enable slot transfer request block */ -#define XHCI_TRB_ENABLE_SLOT XHCI_TRB_TYPE ( 9 ) - -/** A disable slot transfer request block */ -struct xhci_trb_disable_slot { - /** Reserved */ - uint64_t reserved_a; - /** Reserved */ - uint32_t reserved_b; - /** Flags */ - uint8_t flags; - /** Type */ - uint8_t type; - /** Reserved */ - uint8_t reserved_c; - /** Slot ID */ - uint8_t slot; -} __attribute__ (( packed )); - -/** A disable slot transfer request block */ -#define XHCI_TRB_DISABLE_SLOT XHCI_TRB_TYPE ( 10 ) - -/** A context transfer request block */ -struct xhci_trb_context { - /** Input context */ - uint64_t input; - /** Reserved */ - uint32_t reserved_a; - /** Flags */ - uint8_t flags; - /** Type */ - uint8_t type; - /** Reserved */ - uint8_t reserved_b; - /** Slot ID */ - uint8_t slot; -} __attribute__ (( packed )); - -/** An address device transfer request block */ -#define XHCI_TRB_ADDRESS_DEVICE XHCI_TRB_TYPE ( 11 ) - -/** A configure endpoint transfer request block */ -#define XHCI_TRB_CONFIGURE_ENDPOINT XHCI_TRB_TYPE ( 12 ) - -/** An evaluate context transfer request block */ -#define XHCI_TRB_EVALUATE_CONTEXT XHCI_TRB_TYPE ( 13 ) - -/** A reset endpoint transfer request block */ -struct xhci_trb_reset_endpoint { - /** Reserved */ - uint64_t reserved_a; - /** Reserved */ - uint32_t reserved_b; - /** Flags */ - uint8_t flags; - /** Type */ - uint8_t type; - /** Endpoint ID */ - uint8_t endpoint; - /** Slot ID */ - uint8_t slot; -} __attribute__ (( packed )); - -/** A reset endpoint transfer request block */ -#define XHCI_TRB_RESET_ENDPOINT XHCI_TRB_TYPE ( 14 ) - -/** A stop endpoint transfer request block */ -struct xhci_trb_stop_endpoint { - /** Reserved */ - uint64_t reserved_a; - /** Reserved */ - uint32_t reserved_b; - /** Flags */ - uint8_t flags; - /** Type */ - uint8_t type; - /** Endpoint ID */ - uint8_t endpoint; - /** Slot ID */ - uint8_t slot; -} __attribute__ (( packed )); - -/** A stop endpoint transfer request block */ -#define XHCI_TRB_STOP_ENDPOINT XHCI_TRB_TYPE ( 15 ) - -/** A set transfer ring dequeue pointer transfer request block */ -struct xhci_trb_set_tr_dequeue_pointer { - /** Dequeue pointer */ - uint64_t dequeue; - /** Reserved */ - uint32_t reserved; - /** Flags */ - uint8_t flags; - /** Type */ - uint8_t type; - /** Endpoint ID */ - uint8_t endpoint; - /** Slot ID */ - uint8_t slot; -} __attribute__ (( packed )); - -/** A set transfer ring dequeue pointer transfer request block */ -#define XHCI_TRB_SET_TR_DEQUEUE_POINTER XHCI_TRB_TYPE ( 16 ) - -/** A no-op command transfer request block */ -#define XHCI_TRB_NOP_CMD XHCI_TRB_TYPE ( 23 ) - -/** A transfer event transfer request block */ -struct xhci_trb_transfer { - /** Transfer TRB pointer */ - uint64_t transfer; - /** Residual transfer length */ - uint16_t residual; - /** Reserved */ - uint8_t reserved; - /** Completion code */ - uint8_t code; - /** Flags */ - uint8_t flags; - /** Type */ - uint8_t type; - /** Endpoint ID */ - uint8_t endpoint; - /** Slot ID */ - uint8_t slot; -} __attribute__ (( packed )); - -/** A transfer event transfer request block */ -#define XHCI_TRB_TRANSFER XHCI_TRB_TYPE ( 32 ) - -/** A command completion event transfer request block */ -struct xhci_trb_complete { - /** Command TRB pointer */ - uint64_t command; - /** Parameter */ - uint8_t parameter[3]; - /** Completion code */ - uint8_t code; - /** Flags */ - uint8_t flags; - /** Type */ - uint8_t type; - /** Virtual function ID */ - uint8_t vf; - /** Slot ID */ - uint8_t slot; -} __attribute__ (( packed )); - -/** A command completion event transfer request block */ -#define XHCI_TRB_COMPLETE XHCI_TRB_TYPE ( 33 ) - -/** xHCI completion codes */ -enum xhci_completion_code { - /** Success */ - XHCI_CMPLT_SUCCESS = 1, - /** Short packet */ - XHCI_CMPLT_SHORT = 13, - /** Command ring stopped */ - XHCI_CMPLT_CMD_STOPPED = 24, -}; - -/** A port status change transfer request block */ -struct xhci_trb_port_status { - /** Reserved */ - uint8_t reserved_a[3]; - /** Port ID */ - uint8_t port; - /** Reserved */ - uint8_t reserved_b[7]; - /** Completion code */ - uint8_t code; - /** Flags */ - uint8_t flags; - /** Type */ - uint8_t type; - /** Reserved */ - uint16_t reserved_c; -} __attribute__ (( packed )); - -/** A port status change transfer request block */ -#define XHCI_TRB_PORT_STATUS XHCI_TRB_TYPE ( 34 ) - -/** A port status change transfer request block */ -struct xhci_trb_host_controller { - /** Reserved */ - uint64_t reserved_a; - /** Reserved */ - uint8_t reserved_b[3]; - /** Completion code */ - uint8_t code; - /** Flags */ - uint8_t flags; - /** Type */ - uint8_t type; - /** Reserved */ - uint16_t reserved_c; -} __attribute__ (( packed )); - -/** A port status change transfer request block */ -#define XHCI_TRB_HOST_CONTROLLER XHCI_TRB_TYPE ( 37 ) - -/** A transfer request block */ -union xhci_trb { - /** Template */ - struct xhci_trb_template template; - /** Common fields */ - struct xhci_trb_common common; - /** Normal TRB */ - struct xhci_trb_normal normal; - /** Setup stage TRB */ - struct xhci_trb_setup setup; - /** Data stage TRB */ - struct xhci_trb_data data; - /** Status stage TRB */ - struct xhci_trb_status status; - /** Link TRB */ - struct xhci_trb_link link; - /** Enable slot TRB */ - struct xhci_trb_enable_slot enable; - /** Disable slot TRB */ - struct xhci_trb_disable_slot disable; - /** Input context TRB */ - struct xhci_trb_context context; - /** Reset endpoint TRB */ - struct xhci_trb_reset_endpoint reset; - /** Stop endpoint TRB */ - struct xhci_trb_stop_endpoint stop; - /** Set transfer ring dequeue pointer TRB */ - struct xhci_trb_set_tr_dequeue_pointer dequeue; - /** Transfer event */ - struct xhci_trb_transfer transfer; - /** Command completion event */ - struct xhci_trb_complete complete; - /** Port status changed event */ - struct xhci_trb_port_status port; - /** Host controller event */ - struct xhci_trb_host_controller host; -} __attribute__ (( packed )); - -/** An input control context */ -struct xhci_control_context { - /** Drop context flags */ - uint32_t drop; - /** Add context flags */ - uint32_t add; - /** Reserved */ - uint32_t reserved_a[5]; - /** Configuration value */ - uint8_t config; - /** Interface number */ - uint8_t intf; - /** Alternate setting */ - uint8_t alt; - /** Reserved */ - uint8_t reserved_b; -} __attribute__ (( packed )); - -/** A slot context */ -struct xhci_slot_context { - /** Device info */ - uint32_t info; - /** Maximum exit latency */ - uint16_t latency; - /** Root hub port number */ - uint8_t port; - /** Number of downstream ports */ - uint8_t ports; - /** TT hub slot ID */ - uint8_t tt_id; - /** TT port number */ - uint8_t tt_port; - /** Interrupter target */ - uint16_t intr; - /** USB address */ - uint8_t address; - /** Reserved */ - uint16_t reserved_a; - /** Slot state */ - uint8_t state; - /** Reserved */ - uint32_t reserved_b[4]; -} __attribute__ (( packed )); - -/** Construct slot context device info */ -#define XHCI_SLOT_INFO( entries, hub, speed, route ) \ - ( ( (entries) << 27 ) | ( (hub) << 26 ) | ( (speed) << 20 ) | (route) ) - -/** An endpoint context */ -struct xhci_endpoint_context { - /** Endpoint state */ - uint8_t state; - /** Stream configuration */ - uint8_t stream; - /** Polling interval */ - uint8_t interval; - /** Max ESIT payload high */ - uint8_t esit_high; - /** Endpoint type */ - uint8_t type; - /** Maximum burst size */ - uint8_t burst; - /** Maximum packet size */ - uint16_t mtu; - /** Transfer ring dequeue pointer */ - uint64_t dequeue; - /** Average TRB length */ - uint16_t trb_len; - /** Max ESIT payload low */ - uint16_t esit_low; - /** Reserved */ - uint32_t reserved[3]; -} __attribute__ (( packed )); - -/** Endpoint states */ -enum xhci_endpoint_state { - /** Endpoint is disabled */ - XHCI_ENDPOINT_DISABLED = 0, - /** Endpoint is running */ - XHCI_ENDPOINT_RUNNING = 1, - /** Endpoint is halted due to a USB Halt condition */ - XHCI_ENDPOINT_HALTED = 2, - /** Endpoint is stopped */ - XHCI_ENDPOINT_STOPPED = 3, - /** Endpoint is halted due to a TRB error */ - XHCI_ENDPOINT_ERROR = 4, -}; - -/** Endpoint state mask */ -#define XHCI_ENDPOINT_STATE_MASK 0x07 - -/** Endpoint type */ -#define XHCI_EP_TYPE(type) ( (type) << 3 ) - -/** Control endpoint type */ -#define XHCI_EP_TYPE_CONTROL XHCI_EP_TYPE ( 4 ) - -/** Input endpoint type */ -#define XHCI_EP_TYPE_IN XHCI_EP_TYPE ( 4 ) - -/** Periodic endpoint type */ -#define XHCI_EP_TYPE_PERIODIC XHCI_EP_TYPE ( 1 ) - -/** Endpoint dequeue cycle state */ -#define XHCI_EP_DCS 0x00000001UL - -/** Control endpoint average TRB length */ -#define XHCI_EP0_TRB_LEN 8 - -/** An event ring segment */ -struct xhci_event_ring_segment { - /** Base address */ - uint64_t base; - /** Number of TRBs */ - uint32_t count; - /** Reserved */ - uint32_t reserved; -} __attribute__ (( packed )); - -/** A transfer request block command/transfer ring */ -struct xhci_trb_ring { - /** Producer counter */ - unsigned int prod; - /** Consumer counter */ - unsigned int cons; - /** Ring size (log2) */ - unsigned int shift; - /** Ring counter mask */ - unsigned int mask; - - /** I/O buffers */ - struct io_buffer **iobuf; - - /** Transfer request blocks */ - union xhci_trb *trb; - /** Length of transfer request blocks */ - size_t len; - /** DMA mapping */ - struct dma_mapping map; - /** Link TRB (if applicable) */ - struct xhci_trb_link *link; - - /** Doorbell register */ - void *db; - /** Doorbell register value */ - uint32_t dbval; -}; - -/** An event ring */ -struct xhci_event_ring { - /** Consumer counter */ - unsigned int cons; - /** Event ring segment table */ - struct xhci_event_ring_segment *segment; - /** Event ring segment table DMA mapping */ - struct dma_mapping segment_map; - /** Transfer request blocks */ - union xhci_trb *trb; - /** Transfer request blocks DMA mapping */ - struct dma_mapping trb_map; -}; - -/** - * Calculate doorbell register value - * - * @v target Doorbell target - * @v stream Doorbell stream ID - * @ret dbval Doorbell register value - */ -#define XHCI_DBVAL( target, stream ) ( (target) | ( (stream) << 16 ) ) - -/** - * Calculate space used in TRB ring - * - * @v ring TRB ring - * @ret fill Number of entries used - */ -static inline __attribute__ (( always_inline )) unsigned int -xhci_ring_fill ( struct xhci_trb_ring *ring ) { - - return ( ring->prod - ring->cons ); -} - -/** - * Calculate space remaining in TRB ring - * - * @v ring TRB ring - * @ret remaining Number of entries remaining - * - * xHCI does not allow us to completely fill a ring; there must be at - * least one free entry (excluding the Link TRB). - */ -static inline __attribute__ (( always_inline )) unsigned int -xhci_ring_remaining ( struct xhci_trb_ring *ring ) { - unsigned int fill = xhci_ring_fill ( ring ); - - /* We choose to utilise rings with ( 2^n + 1 ) entries, with - * the final entry being a Link TRB. The maximum fill level - * is therefore - * - * ( ( 2^n + 1 ) - 1 (Link TRB) - 1 (one slot always empty) - * == ( 2^n - 1 ) - * - * which is therefore equal to the ring mask. - */ - assert ( fill <= ring->mask ); - return ( ring->mask - fill ); -} - -/** - * Calculate physical address of most recently consumed TRB - * - * @v ring TRB ring - * @ret trb TRB physical address - */ -static inline __attribute__ (( always_inline )) physaddr_t -xhci_ring_consumed ( struct xhci_trb_ring *ring ) { - unsigned int index = ( ( ring->cons - 1 ) & ring->mask ); - - return virt_to_phys ( &ring->trb[index] ); -} - -/** Slot context index */ -#define XHCI_CTX_SLOT 0 - -/** Calculate context index from USB endpoint address */ -#define XHCI_CTX(address) \ - ( (address) ? ( ( ( (address) & 0x0f ) << 1 ) | \ - ( ( (address) & 0x80 ) >> 7 ) ) : 1 ) - -/** Endpoint zero context index */ -#define XHCI_CTX_EP0 XHCI_CTX ( 0x00 ) - -/** End of contexts */ -#define XHCI_CTX_END 32 - -/** Device context index */ -#define XHCI_DCI(ctx) ( (ctx) + 0 ) - -/** Input context index */ -#define XHCI_ICI(ctx) ( (ctx) + 1 ) - -/** Number of TRBs (excluding Link TRB) in the command ring - * - * This is a policy decision. - */ -#define XHCI_CMD_TRBS_LOG2 2 - -/** Number of TRBs in the event ring - * - * This is a policy decision. - */ -#define XHCI_EVENT_TRBS_LOG2 6 - -/** Number of TRBs in a transfer ring - * - * This is a policy decision. - */ -#define XHCI_TRANSFER_TRBS_LOG2 6 - -/** Maximum time to wait for BIOS to release ownership - * - * This is a policy decision. - */ -#define XHCI_USBLEGSUP_MAX_WAIT_MS 100 - -/** Maximum time to wait for host controller to stop - * - * This is a policy decision. - */ -#define XHCI_STOP_MAX_WAIT_MS 100 - -/** Maximum time to wait for reset to complete - * - * This is a policy decision. - */ -#define XHCI_RESET_MAX_WAIT_MS 500 - -/** Maximum time to wait for a command to complete - * - * The "address device" command involves waiting for a response to a - * USB control transaction, and so we must wait for up to the 5000ms - * that USB allows for devices to respond to control transactions. - */ -#define XHCI_COMMAND_MAX_WAIT_MS USB_CONTROL_MAX_WAIT_MS - -/** Time to delay after aborting a command - * - * This is a policy decision - */ -#define XHCI_COMMAND_ABORT_DELAY_MS 500 - -/** Maximum time to wait for a port reset to complete - * - * This is a policy decision. - */ -#define XHCI_PORT_RESET_MAX_WAIT_MS 500 - -/** Intel PCH quirk */ -struct xhci_pch { - /** USB2 port routing register original value */ - uint32_t xusb2pr; - /** USB3 port SuperSpeed enable register original value */ - uint32_t usb3pssen; -}; - -/** Intel PCH quirk flag */ -#define XHCI_PCH 0x0001 - -/** Intel PCH USB2 port routing register */ -#define XHCI_PCH_XUSB2PR 0xd0 - -/** Intel PCH USB2 port routing mask register */ -#define XHCI_PCH_XUSB2PRM 0xd4 - -/** Intel PCH SuperSpeed enable register */ -#define XHCI_PCH_USB3PSSEN 0xd8 - -/** Intel PCH USB3 port routing mask register */ -#define XHCI_PCH_USB3PRM 0xdc - -/** Invalid protocol speed ID values quirk */ -#define XHCI_BAD_PSIV 0x0002 - -/** Device context base address array */ -struct xhci_dcbaa { - /** Context base addresses */ - uint64_t *context; - /** DMA mapping */ - struct dma_mapping map; -}; - -/** Scratchpad buffer */ -struct xhci_scratchpad { - /** Number of page-sized scratchpad buffers */ - unsigned int count; - /** Scratchpad buffer area */ - void *buffer; - /** Buffer DMA mapping */ - struct dma_mapping buffer_map; - /** Scratchpad array */ - uint64_t *array; - /** Array DMA mapping */ - struct dma_mapping array_map; -}; - -/** An xHCI device */ -struct xhci_device { - /** Registers */ - void *regs; - /** DMA device */ - struct dma_device *dma; - /** Name */ - const char *name; - /** Quirks */ - unsigned int quirks; - - /** Capability registers */ - void *cap; - /** Operational registers */ - void *op; - /** Runtime registers */ - void *run; - /** Doorbell registers */ - void *db; - - /** Number of device slots */ - unsigned int slots; - /** Number of interrupters */ - unsigned int intrs; - /** Number of ports */ - unsigned int ports; - - /** 64-bit addressing capability */ - int addr64; - /** Context size shift */ - unsigned int csz_shift; - /** xHCI extended capabilities offset */ - unsigned int xecp; - - /** Page size */ - size_t pagesize; - - /** USB legacy support capability (if present and enabled) */ - unsigned int legacy; - - /** Device context base address array */ - struct xhci_dcbaa dcbaa; - - /** Scratchpad buffer */ - struct xhci_scratchpad scratch; - - /** Command ring */ - struct xhci_trb_ring command; - /** Event ring */ - struct xhci_event_ring event; - /** Current command (if any) */ - union xhci_trb *pending; - /** Command mechanism has permanently failed */ - int failed; - - /** Device slots, indexed by slot ID */ - struct xhci_slot **slot; - - /** USB bus */ - struct usb_bus *bus; - - /** Intel PCH quirk */ - struct xhci_pch pch; -}; - -/** An xHCI device slot */ -struct xhci_slot { - /** xHCI device */ - struct xhci_device *xhci; - /** USB device */ - struct usb_device *usb; - /** Slot ID */ - unsigned int id; - /** Slot context */ - struct xhci_slot_context *context; - /** DMA mapping */ - struct dma_mapping map; - /** Route string */ - unsigned int route; - /** Root hub port number */ - unsigned int port; - /** Protocol speed ID */ - unsigned int psiv; - /** Number of ports (if this device is a hub) */ - unsigned int ports; - /** Transaction translator slot ID */ - unsigned int tt_id; - /** Transaction translator port */ - unsigned int tt_port; - /** Endpoints, indexed by context ID */ - struct xhci_endpoint *endpoint[XHCI_CTX_END]; -}; - -/** An xHCI endpoint */ -struct xhci_endpoint { - /** xHCI device */ - struct xhci_device *xhci; - /** xHCI slot */ - struct xhci_slot *slot; - /** USB endpoint */ - struct usb_endpoint *ep; - /** Context index */ - unsigned int ctx; - /** Endpoint type */ - unsigned int type; - /** Endpoint interval */ - unsigned int interval; - /** Endpoint context */ - struct xhci_endpoint_context *context; - /** Transfer ring */ - struct xhci_trb_ring ring; -}; - -#endif /* _IPXE_XHCI_H */ diff --git a/src/include/ipxe/xhci.h b/src/include/ipxe/xhci.h new file mode 100644 index 000000000..586d5d320 --- /dev/null +++ b/src/include/ipxe/xhci.h @@ -0,0 +1,1184 @@ +#ifndef _IPXE_XHCI_H +#define _IPXE_XHCI_H + +/** @file + * + * USB eXtensible Host Controller Interface (xHCI) driver + * + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#include +#include +#include + +/** Minimum alignment required for data structures + * + * With the exception of the scratchpad buffer pages (which are + * page-aligned), data structures used by xHCI generally require from + * 16 to 64 byte alignment and must not cross an (xHCI) page boundary. + * We simplify this requirement by aligning each structure on its own + * size, with a minimum of a 64 byte alignment. + */ +#define XHCI_MIN_ALIGN 64 + +/** Maximum transfer size */ +#define XHCI_MTU 65536 + +/** xHCI PCI BAR */ +#define XHCI_BAR PCI_BASE_ADDRESS_0 + +/** Capability register length */ +#define XHCI_CAP_CAPLENGTH 0x00 + +/** Host controller interface version number */ +#define XHCI_CAP_HCIVERSION 0x02 + +/** Structural parameters 1 */ +#define XHCI_CAP_HCSPARAMS1 0x04 + +/** Number of device slots */ +#define XHCI_HCSPARAMS1_SLOTS(params) ( ( (params) >> 0 ) & 0xff ) + +/** Number of interrupters */ +#define XHCI_HCSPARAMS1_INTRS(params) ( ( (params) >> 8 ) & 0x3ff ) + +/** Number of ports */ +#define XHCI_HCSPARAMS1_PORTS(params) ( ( (params) >> 24 ) & 0xff ) + +/** Structural parameters 2 */ +#define XHCI_CAP_HCSPARAMS2 0x08 + +/** Number of page-sized scratchpad buffers */ +#define XHCI_HCSPARAMS2_SCRATCHPADS(params) \ + ( ( ( (params) >> 16 ) & 0x3e0 ) | ( ( (params) >> 27 ) & 0x1f ) ) + +/** Capability parameters */ +#define XHCI_CAP_HCCPARAMS1 0x10 + +/** 64-bit addressing capability */ +#define XHCI_HCCPARAMS1_ADDR64(params) ( ( (params) >> 0 ) & 0x1 ) + +/** Context size shift */ +#define XHCI_HCCPARAMS1_CSZ_SHIFT(params) ( 5 + ( ( (params) >> 2 ) & 0x1 ) ) + +/** xHCI extended capabilities pointer */ +#define XHCI_HCCPARAMS1_XECP(params) ( ( ( (params) >> 16 ) & 0xffff ) << 2 ) + +/** Doorbell offset */ +#define XHCI_CAP_DBOFF 0x14 + +/** Runtime register space offset */ +#define XHCI_CAP_RTSOFF 0x18 + +/** xHCI extended capability ID */ +#define XHCI_XECP_ID(xecp) ( ( (xecp) >> 0 ) & 0xff ) + +/** Next xHCI extended capability pointer */ +#define XHCI_XECP_NEXT(xecp) ( ( ( (xecp) >> 8 ) & 0xff ) << 2 ) + +/** USB legacy support extended capability */ +#define XHCI_XECP_ID_LEGACY 1 + +/** USB legacy support BIOS owned semaphore */ +#define XHCI_USBLEGSUP_BIOS 0x02 + +/** USB legacy support BIOS ownership flag */ +#define XHCI_USBLEGSUP_BIOS_OWNED 0x01 + +/** USB legacy support OS owned semaphore */ +#define XHCI_USBLEGSUP_OS 0x03 + +/** USB legacy support OS ownership flag */ +#define XHCI_USBLEGSUP_OS_OWNED 0x01 + +/** USB legacy support control/status */ +#define XHCI_USBLEGSUP_CTLSTS 0x04 + +/** Supported protocol extended capability */ +#define XHCI_XECP_ID_SUPPORTED 2 + +/** Supported protocol revision */ +#define XHCI_SUPPORTED_REVISION 0x00 + +/** Supported protocol minor revision */ +#define XHCI_SUPPORTED_REVISION_VER(revision) ( ( (revision) >> 16 ) & 0xffff ) + +/** Supported protocol name */ +#define XHCI_SUPPORTED_NAME 0x04 + +/** Supported protocol ports */ +#define XHCI_SUPPORTED_PORTS 0x08 + +/** Supported protocol port offset */ +#define XHCI_SUPPORTED_PORTS_OFFSET(ports) ( ( (ports) >> 0 ) & 0xff ) + +/** Supported protocol port count */ +#define XHCI_SUPPORTED_PORTS_COUNT(ports) ( ( (ports) >> 8 ) & 0xff ) + +/** Supported protocol PSI count */ +#define XHCI_SUPPORTED_PORTS_PSIC(ports) ( ( (ports) >> 28 ) & 0x0f ) + +/** Supported protocol slot */ +#define XHCI_SUPPORTED_SLOT 0x0c + +/** Supported protocol slot type */ +#define XHCI_SUPPORTED_SLOT_TYPE(slot) ( ( (slot) >> 0 ) & 0x1f ) + +/** Supported protocol PSI */ +#define XHCI_SUPPORTED_PSI(index) ( 0x10 + ( (index) * 4 ) ) + +/** Supported protocol PSI value */ +#define XHCI_SUPPORTED_PSI_VALUE(psi) ( ( (psi) >> 0 ) & 0x0f ) + +/** Supported protocol PSI mantissa */ +#define XHCI_SUPPORTED_PSI_MANTISSA(psi) ( ( (psi) >> 16 ) & 0xffff ) + +/** Supported protocol PSI exponent */ +#define XHCI_SUPPORTED_PSI_EXPONENT(psi) ( ( (psi) >> 4 ) & 0x03 ) + +/** Default PSI values */ +enum xhci_default_psi_value { + /** Full speed (12Mbps) */ + XHCI_SPEED_FULL = 1, + /** Low speed (1.5Mbps) */ + XHCI_SPEED_LOW = 2, + /** High speed (480Mbps) */ + XHCI_SPEED_HIGH = 3, + /** Super speed */ + XHCI_SPEED_SUPER = 4, +}; + +/** USB command register */ +#define XHCI_OP_USBCMD 0x00 + +/** Run/stop */ +#define XHCI_USBCMD_RUN 0x00000001UL + +/** Host controller reset */ +#define XHCI_USBCMD_HCRST 0x00000002UL + +/** USB status register */ +#define XHCI_OP_USBSTS 0x04 + +/** Host controller halted */ +#define XHCI_USBSTS_HCH 0x00000001UL + +/** Page size register */ +#define XHCI_OP_PAGESIZE 0x08 + +/** Page size */ +#define XHCI_PAGESIZE(pagesize) ( (pagesize) << 12 ) + +/** Device notifcation control register */ +#define XHCI_OP_DNCTRL 0x14 + +/** Command ring control register */ +#define XHCI_OP_CRCR 0x18 + +/** Command ring cycle state */ +#define XHCI_CRCR_RCS 0x00000001UL + +/** Command abort */ +#define XHCI_CRCR_CA 0x00000004UL + +/** Command ring running */ +#define XHCI_CRCR_CRR 0x00000008UL + +/** Device context base address array pointer */ +#define XHCI_OP_DCBAAP 0x30 + +/** Configure register */ +#define XHCI_OP_CONFIG 0x38 + +/** Maximum device slots enabled */ +#define XHCI_CONFIG_MAX_SLOTS_EN(slots) ( (slots) << 0 ) + +/** Maximum device slots enabled mask */ +#define XHCI_CONFIG_MAX_SLOTS_EN_MASK \ + XHCI_CONFIG_MAX_SLOTS_EN ( 0xff ) + +/** Port status and control register */ +#define XHCI_OP_PORTSC(port) ( 0x400 - 0x10 + ( (port) << 4 ) ) + +/** Current connect status */ +#define XHCI_PORTSC_CCS 0x00000001UL + +/** Port enabled */ +#define XHCI_PORTSC_PED 0x00000002UL + +/** Port reset */ +#define XHCI_PORTSC_PR 0x00000010UL + +/** Port link state */ +#define XHCI_PORTSC_PLS(pls) ( (pls) << 5 ) + +/** Disabled port link state */ +#define XHCI_PORTSC_PLS_DISABLED XHCI_PORTSC_PLS ( 4 ) + +/** RxDetect port link state */ +#define XHCI_PORTSC_PLS_RXDETECT XHCI_PORTSC_PLS ( 5 ) + +/** Port link state mask */ +#define XHCI_PORTSC_PLS_MASK XHCI_PORTSC_PLS ( 0xf ) + +/** Port power */ +#define XHCI_PORTSC_PP 0x00000200UL + +/** Time to delay after enabling power to a port */ +#define XHCI_PORT_POWER_DELAY_MS 20 + +/** Port speed ID value */ +#define XHCI_PORTSC_PSIV(portsc) ( ( (portsc) >> 10 ) & 0xf ) + +/** Port indicator control */ +#define XHCI_PORTSC_PIC(indicators) ( (indicators) << 14 ) + +/** Port indicator control mask */ +#define XHCI_PORTSC_PIC_MASK XHCI_PORTSC_PIC ( 3 ) + +/** Port link state write strobe */ +#define XHCI_PORTSC_LWS 0x00010000UL + +/** Time to delay after writing the port link state */ +#define XHCI_LINK_STATE_DELAY_MS 100 + +/** Connect status change */ +#define XHCI_PORTSC_CSC 0x00020000UL + +/** Port enabled/disabled change */ +#define XHCI_PORTSC_PEC 0x00040000UL + +/** Warm port reset change */ +#define XHCI_PORTSC_WRC 0x00080000UL + +/** Over-current change */ +#define XHCI_PORTSC_OCC 0x00100000UL + +/** Port reset change */ +#define XHCI_PORTSC_PRC 0x00200000UL + +/** Port link state change */ +#define XHCI_PORTSC_PLC 0x00400000UL + +/** Port config error change */ +#define XHCI_PORTSC_CEC 0x00800000UL + +/** Port status change mask */ +#define XHCI_PORTSC_CHANGE \ + ( XHCI_PORTSC_CSC | XHCI_PORTSC_PEC | XHCI_PORTSC_WRC | \ + XHCI_PORTSC_OCC | XHCI_PORTSC_PRC | XHCI_PORTSC_PLC | \ + XHCI_PORTSC_CEC ) + +/** Port status and control bits which should be preserved + * + * The port status and control register is a horrendous mix of + * differing semantics. Some bits are written to only when a separate + * write strobe bit is set. Some bits should be preserved when + * modifying other bits. Some bits will be cleared if written back as + * a one. Most excitingly, the "port enabled" bit has the semantics + * that 1=enabled, 0=disabled, yet writing a 1 will disable the port. + */ +#define XHCI_PORTSC_PRESERVE ( XHCI_PORTSC_PP | XHCI_PORTSC_PIC_MASK ) + +/** Port power management status and control register */ +#define XHCI_OP_PORTPMSC(port) ( 0x404 - 0x10 + ( (port) << 4 ) ) + +/** Port link info register */ +#define XHCI_OP_PORTLI(port) ( 0x408 - 0x10 + ( (port) << 4 ) ) + +/** Port hardware link power management control register */ +#define XHCI_OP_PORTHLPMC(port) ( 0x40c - 0x10 + ( (port) << 4 ) ) + +/** Event ring segment table size register */ +#define XHCI_RUN_ERSTSZ(intr) ( 0x28 + ( (intr) << 5 ) ) + +/** Event ring segment table base address register */ +#define XHCI_RUN_ERSTBA(intr) ( 0x30 + ( (intr) << 5 ) ) + +/** Event ring dequeue pointer register */ +#define XHCI_RUN_ERDP(intr) ( 0x38 + ( (intr) << 5 ) ) + +/** A transfer request block template */ +struct xhci_trb_template { + /** Parameter */ + uint64_t parameter; + /** Status */ + uint32_t status; + /** Control */ + uint32_t control; +}; + +/** A transfer request block */ +struct xhci_trb_common { + /** Reserved */ + uint64_t reserved_a; + /** Reserved */ + uint32_t reserved_b; + /** Flags */ + uint8_t flags; + /** Type */ + uint8_t type; + /** Reserved */ + uint16_t reserved_c; +} __attribute__ (( packed )); + +/** Transfer request block cycle bit flag */ +#define XHCI_TRB_C 0x01 + +/** Transfer request block toggle cycle bit flag */ +#define XHCI_TRB_TC 0x02 + +/** Transfer request block chain flag */ +#define XHCI_TRB_CH 0x10 + +/** Transfer request block interrupt on completion flag */ +#define XHCI_TRB_IOC 0x20 + +/** Transfer request block immediate data flag */ +#define XHCI_TRB_IDT 0x40 + +/** Transfer request block type */ +#define XHCI_TRB_TYPE(type) ( (type) << 2 ) + +/** Transfer request block type mask */ +#define XHCI_TRB_TYPE_MASK XHCI_TRB_TYPE ( 0x3f ) + +/** A normal transfer request block */ +struct xhci_trb_normal { + /** Data buffer */ + uint64_t data; + /** Length */ + uint32_t len; + /** Flags */ + uint8_t flags; + /** Type */ + uint8_t type; + /** Reserved */ + uint16_t reserved; +} __attribute__ (( packed )); + +/** A normal transfer request block */ +#define XHCI_TRB_NORMAL XHCI_TRB_TYPE ( 1 ) + +/** Construct TD size field */ +#define XHCI_TD_SIZE(remaining) \ + ( ( ( (remaining) <= 0xf ) ? remaining : 0xf ) << 17 ) + +/** A setup stage transfer request block */ +struct xhci_trb_setup { + /** Setup packet */ + struct usb_setup_packet packet; + /** Length */ + uint32_t len; + /** Flags */ + uint8_t flags; + /** Type */ + uint8_t type; + /** Transfer direction */ + uint8_t direction; + /** Reserved */ + uint8_t reserved; +} __attribute__ (( packed )); + +/** A setup stage transfer request block */ +#define XHCI_TRB_SETUP XHCI_TRB_TYPE ( 2 ) + +/** Setup stage input data direction */ +#define XHCI_SETUP_IN 3 + +/** Setup stage output data direction */ +#define XHCI_SETUP_OUT 2 + +/** A data stage transfer request block */ +struct xhci_trb_data { + /** Data buffer */ + uint64_t data; + /** Length */ + uint32_t len; + /** Flags */ + uint8_t flags; + /** Type */ + uint8_t type; + /** Transfer direction */ + uint8_t direction; + /** Reserved */ + uint8_t reserved; +} __attribute__ (( packed )); + +/** A data stage transfer request block */ +#define XHCI_TRB_DATA XHCI_TRB_TYPE ( 3 ) + +/** Input data direction */ +#define XHCI_DATA_IN 0x01 + +/** Output data direction */ +#define XHCI_DATA_OUT 0x00 + +/** A status stage transfer request block */ +struct xhci_trb_status { + /** Reserved */ + uint64_t reserved_a; + /** Reserved */ + uint32_t reserved_b; + /** Flags */ + uint8_t flags; + /** Type */ + uint8_t type; + /** Direction */ + uint8_t direction; + /** Reserved */ + uint8_t reserved_c; +} __attribute__ (( packed )); + +/** A status stage transfer request block */ +#define XHCI_TRB_STATUS XHCI_TRB_TYPE ( 4 ) + +/** Input status direction */ +#define XHCI_STATUS_IN 0x01 + +/** Output status direction */ +#define XHCI_STATUS_OUT 0x00 + +/** A link transfer request block */ +struct xhci_trb_link { + /** Next ring segment */ + uint64_t next; + /** Reserved */ + uint32_t reserved_a; + /** Flags */ + uint8_t flags; + /** Type */ + uint8_t type; + /** Reserved */ + uint16_t reserved_c; +} __attribute__ (( packed )); + +/** A link transfer request block */ +#define XHCI_TRB_LINK XHCI_TRB_TYPE ( 6 ) + +/** A no-op transfer request block */ +#define XHCI_TRB_NOP XHCI_TRB_TYPE ( 8 ) + +/** An enable slot transfer request block */ +struct xhci_trb_enable_slot { + /** Reserved */ + uint64_t reserved_a; + /** Reserved */ + uint32_t reserved_b; + /** Flags */ + uint8_t flags; + /** Type */ + uint8_t type; + /** Slot type */ + uint8_t slot; + /** Reserved */ + uint8_t reserved_c; +} __attribute__ (( packed )); + +/** An enable slot transfer request block */ +#define XHCI_TRB_ENABLE_SLOT XHCI_TRB_TYPE ( 9 ) + +/** A disable slot transfer request block */ +struct xhci_trb_disable_slot { + /** Reserved */ + uint64_t reserved_a; + /** Reserved */ + uint32_t reserved_b; + /** Flags */ + uint8_t flags; + /** Type */ + uint8_t type; + /** Reserved */ + uint8_t reserved_c; + /** Slot ID */ + uint8_t slot; +} __attribute__ (( packed )); + +/** A disable slot transfer request block */ +#define XHCI_TRB_DISABLE_SLOT XHCI_TRB_TYPE ( 10 ) + +/** A context transfer request block */ +struct xhci_trb_context { + /** Input context */ + uint64_t input; + /** Reserved */ + uint32_t reserved_a; + /** Flags */ + uint8_t flags; + /** Type */ + uint8_t type; + /** Reserved */ + uint8_t reserved_b; + /** Slot ID */ + uint8_t slot; +} __attribute__ (( packed )); + +/** An address device transfer request block */ +#define XHCI_TRB_ADDRESS_DEVICE XHCI_TRB_TYPE ( 11 ) + +/** A configure endpoint transfer request block */ +#define XHCI_TRB_CONFIGURE_ENDPOINT XHCI_TRB_TYPE ( 12 ) + +/** An evaluate context transfer request block */ +#define XHCI_TRB_EVALUATE_CONTEXT XHCI_TRB_TYPE ( 13 ) + +/** A reset endpoint transfer request block */ +struct xhci_trb_reset_endpoint { + /** Reserved */ + uint64_t reserved_a; + /** Reserved */ + uint32_t reserved_b; + /** Flags */ + uint8_t flags; + /** Type */ + uint8_t type; + /** Endpoint ID */ + uint8_t endpoint; + /** Slot ID */ + uint8_t slot; +} __attribute__ (( packed )); + +/** A reset endpoint transfer request block */ +#define XHCI_TRB_RESET_ENDPOINT XHCI_TRB_TYPE ( 14 ) + +/** A stop endpoint transfer request block */ +struct xhci_trb_stop_endpoint { + /** Reserved */ + uint64_t reserved_a; + /** Reserved */ + uint32_t reserved_b; + /** Flags */ + uint8_t flags; + /** Type */ + uint8_t type; + /** Endpoint ID */ + uint8_t endpoint; + /** Slot ID */ + uint8_t slot; +} __attribute__ (( packed )); + +/** A stop endpoint transfer request block */ +#define XHCI_TRB_STOP_ENDPOINT XHCI_TRB_TYPE ( 15 ) + +/** A set transfer ring dequeue pointer transfer request block */ +struct xhci_trb_set_tr_dequeue_pointer { + /** Dequeue pointer */ + uint64_t dequeue; + /** Reserved */ + uint32_t reserved; + /** Flags */ + uint8_t flags; + /** Type */ + uint8_t type; + /** Endpoint ID */ + uint8_t endpoint; + /** Slot ID */ + uint8_t slot; +} __attribute__ (( packed )); + +/** A set transfer ring dequeue pointer transfer request block */ +#define XHCI_TRB_SET_TR_DEQUEUE_POINTER XHCI_TRB_TYPE ( 16 ) + +/** A no-op command transfer request block */ +#define XHCI_TRB_NOP_CMD XHCI_TRB_TYPE ( 23 ) + +/** A transfer event transfer request block */ +struct xhci_trb_transfer { + /** Transfer TRB pointer */ + uint64_t transfer; + /** Residual transfer length */ + uint16_t residual; + /** Reserved */ + uint8_t reserved; + /** Completion code */ + uint8_t code; + /** Flags */ + uint8_t flags; + /** Type */ + uint8_t type; + /** Endpoint ID */ + uint8_t endpoint; + /** Slot ID */ + uint8_t slot; +} __attribute__ (( packed )); + +/** A transfer event transfer request block */ +#define XHCI_TRB_TRANSFER XHCI_TRB_TYPE ( 32 ) + +/** A command completion event transfer request block */ +struct xhci_trb_complete { + /** Command TRB pointer */ + uint64_t command; + /** Parameter */ + uint8_t parameter[3]; + /** Completion code */ + uint8_t code; + /** Flags */ + uint8_t flags; + /** Type */ + uint8_t type; + /** Virtual function ID */ + uint8_t vf; + /** Slot ID */ + uint8_t slot; +} __attribute__ (( packed )); + +/** A command completion event transfer request block */ +#define XHCI_TRB_COMPLETE XHCI_TRB_TYPE ( 33 ) + +/** xHCI completion codes */ +enum xhci_completion_code { + /** Success */ + XHCI_CMPLT_SUCCESS = 1, + /** Short packet */ + XHCI_CMPLT_SHORT = 13, + /** Command ring stopped */ + XHCI_CMPLT_CMD_STOPPED = 24, +}; + +/** A port status change transfer request block */ +struct xhci_trb_port_status { + /** Reserved */ + uint8_t reserved_a[3]; + /** Port ID */ + uint8_t port; + /** Reserved */ + uint8_t reserved_b[7]; + /** Completion code */ + uint8_t code; + /** Flags */ + uint8_t flags; + /** Type */ + uint8_t type; + /** Reserved */ + uint16_t reserved_c; +} __attribute__ (( packed )); + +/** A port status change transfer request block */ +#define XHCI_TRB_PORT_STATUS XHCI_TRB_TYPE ( 34 ) + +/** A port status change transfer request block */ +struct xhci_trb_host_controller { + /** Reserved */ + uint64_t reserved_a; + /** Reserved */ + uint8_t reserved_b[3]; + /** Completion code */ + uint8_t code; + /** Flags */ + uint8_t flags; + /** Type */ + uint8_t type; + /** Reserved */ + uint16_t reserved_c; +} __attribute__ (( packed )); + +/** A port status change transfer request block */ +#define XHCI_TRB_HOST_CONTROLLER XHCI_TRB_TYPE ( 37 ) + +/** A transfer request block */ +union xhci_trb { + /** Template */ + struct xhci_trb_template template; + /** Common fields */ + struct xhci_trb_common common; + /** Normal TRB */ + struct xhci_trb_normal normal; + /** Setup stage TRB */ + struct xhci_trb_setup setup; + /** Data stage TRB */ + struct xhci_trb_data data; + /** Status stage TRB */ + struct xhci_trb_status status; + /** Link TRB */ + struct xhci_trb_link link; + /** Enable slot TRB */ + struct xhci_trb_enable_slot enable; + /** Disable slot TRB */ + struct xhci_trb_disable_slot disable; + /** Input context TRB */ + struct xhci_trb_context context; + /** Reset endpoint TRB */ + struct xhci_trb_reset_endpoint reset; + /** Stop endpoint TRB */ + struct xhci_trb_stop_endpoint stop; + /** Set transfer ring dequeue pointer TRB */ + struct xhci_trb_set_tr_dequeue_pointer dequeue; + /** Transfer event */ + struct xhci_trb_transfer transfer; + /** Command completion event */ + struct xhci_trb_complete complete; + /** Port status changed event */ + struct xhci_trb_port_status port; + /** Host controller event */ + struct xhci_trb_host_controller host; +} __attribute__ (( packed )); + +/** An input control context */ +struct xhci_control_context { + /** Drop context flags */ + uint32_t drop; + /** Add context flags */ + uint32_t add; + /** Reserved */ + uint32_t reserved_a[5]; + /** Configuration value */ + uint8_t config; + /** Interface number */ + uint8_t intf; + /** Alternate setting */ + uint8_t alt; + /** Reserved */ + uint8_t reserved_b; +} __attribute__ (( packed )); + +/** A slot context */ +struct xhci_slot_context { + /** Device info */ + uint32_t info; + /** Maximum exit latency */ + uint16_t latency; + /** Root hub port number */ + uint8_t port; + /** Number of downstream ports */ + uint8_t ports; + /** TT hub slot ID */ + uint8_t tt_id; + /** TT port number */ + uint8_t tt_port; + /** Interrupter target */ + uint16_t intr; + /** USB address */ + uint8_t address; + /** Reserved */ + uint16_t reserved_a; + /** Slot state */ + uint8_t state; + /** Reserved */ + uint32_t reserved_b[4]; +} __attribute__ (( packed )); + +/** Construct slot context device info */ +#define XHCI_SLOT_INFO( entries, hub, speed, route ) \ + ( ( (entries) << 27 ) | ( (hub) << 26 ) | ( (speed) << 20 ) | (route) ) + +/** An endpoint context */ +struct xhci_endpoint_context { + /** Endpoint state */ + uint8_t state; + /** Stream configuration */ + uint8_t stream; + /** Polling interval */ + uint8_t interval; + /** Max ESIT payload high */ + uint8_t esit_high; + /** Endpoint type */ + uint8_t type; + /** Maximum burst size */ + uint8_t burst; + /** Maximum packet size */ + uint16_t mtu; + /** Transfer ring dequeue pointer */ + uint64_t dequeue; + /** Average TRB length */ + uint16_t trb_len; + /** Max ESIT payload low */ + uint16_t esit_low; + /** Reserved */ + uint32_t reserved[3]; +} __attribute__ (( packed )); + +/** Endpoint states */ +enum xhci_endpoint_state { + /** Endpoint is disabled */ + XHCI_ENDPOINT_DISABLED = 0, + /** Endpoint is running */ + XHCI_ENDPOINT_RUNNING = 1, + /** Endpoint is halted due to a USB Halt condition */ + XHCI_ENDPOINT_HALTED = 2, + /** Endpoint is stopped */ + XHCI_ENDPOINT_STOPPED = 3, + /** Endpoint is halted due to a TRB error */ + XHCI_ENDPOINT_ERROR = 4, +}; + +/** Endpoint state mask */ +#define XHCI_ENDPOINT_STATE_MASK 0x07 + +/** Endpoint type */ +#define XHCI_EP_TYPE(type) ( (type) << 3 ) + +/** Control endpoint type */ +#define XHCI_EP_TYPE_CONTROL XHCI_EP_TYPE ( 4 ) + +/** Input endpoint type */ +#define XHCI_EP_TYPE_IN XHCI_EP_TYPE ( 4 ) + +/** Periodic endpoint type */ +#define XHCI_EP_TYPE_PERIODIC XHCI_EP_TYPE ( 1 ) + +/** Endpoint dequeue cycle state */ +#define XHCI_EP_DCS 0x00000001UL + +/** Control endpoint average TRB length */ +#define XHCI_EP0_TRB_LEN 8 + +/** An event ring segment */ +struct xhci_event_ring_segment { + /** Base address */ + uint64_t base; + /** Number of TRBs */ + uint32_t count; + /** Reserved */ + uint32_t reserved; +} __attribute__ (( packed )); + +/** A transfer request block command/transfer ring */ +struct xhci_trb_ring { + /** Producer counter */ + unsigned int prod; + /** Consumer counter */ + unsigned int cons; + /** Ring size (log2) */ + unsigned int shift; + /** Ring counter mask */ + unsigned int mask; + + /** I/O buffers */ + struct io_buffer **iobuf; + + /** Transfer request blocks */ + union xhci_trb *trb; + /** Length of transfer request blocks */ + size_t len; + /** DMA mapping */ + struct dma_mapping map; + /** Link TRB (if applicable) */ + struct xhci_trb_link *link; + + /** Doorbell register */ + void *db; + /** Doorbell register value */ + uint32_t dbval; +}; + +/** An event ring */ +struct xhci_event_ring { + /** Consumer counter */ + unsigned int cons; + /** Event ring segment table */ + struct xhci_event_ring_segment *segment; + /** Event ring segment table DMA mapping */ + struct dma_mapping segment_map; + /** Transfer request blocks */ + union xhci_trb *trb; + /** Transfer request blocks DMA mapping */ + struct dma_mapping trb_map; +}; + +/** + * Calculate doorbell register value + * + * @v target Doorbell target + * @v stream Doorbell stream ID + * @ret dbval Doorbell register value + */ +#define XHCI_DBVAL( target, stream ) ( (target) | ( (stream) << 16 ) ) + +/** + * Calculate space used in TRB ring + * + * @v ring TRB ring + * @ret fill Number of entries used + */ +static inline __attribute__ (( always_inline )) unsigned int +xhci_ring_fill ( struct xhci_trb_ring *ring ) { + + return ( ring->prod - ring->cons ); +} + +/** + * Calculate space remaining in TRB ring + * + * @v ring TRB ring + * @ret remaining Number of entries remaining + * + * xHCI does not allow us to completely fill a ring; there must be at + * least one free entry (excluding the Link TRB). + */ +static inline __attribute__ (( always_inline )) unsigned int +xhci_ring_remaining ( struct xhci_trb_ring *ring ) { + unsigned int fill = xhci_ring_fill ( ring ); + + /* We choose to utilise rings with ( 2^n + 1 ) entries, with + * the final entry being a Link TRB. The maximum fill level + * is therefore + * + * ( ( 2^n + 1 ) - 1 (Link TRB) - 1 (one slot always empty) + * == ( 2^n - 1 ) + * + * which is therefore equal to the ring mask. + */ + assert ( fill <= ring->mask ); + return ( ring->mask - fill ); +} + +/** + * Calculate physical address of most recently consumed TRB + * + * @v ring TRB ring + * @ret trb TRB physical address + */ +static inline __attribute__ (( always_inline )) physaddr_t +xhci_ring_consumed ( struct xhci_trb_ring *ring ) { + unsigned int index = ( ( ring->cons - 1 ) & ring->mask ); + + return virt_to_phys ( &ring->trb[index] ); +} + +/** Slot context index */ +#define XHCI_CTX_SLOT 0 + +/** Calculate context index from USB endpoint address */ +#define XHCI_CTX(address) \ + ( (address) ? ( ( ( (address) & 0x0f ) << 1 ) | \ + ( ( (address) & 0x80 ) >> 7 ) ) : 1 ) + +/** Endpoint zero context index */ +#define XHCI_CTX_EP0 XHCI_CTX ( 0x00 ) + +/** End of contexts */ +#define XHCI_CTX_END 32 + +/** Device context index */ +#define XHCI_DCI(ctx) ( (ctx) + 0 ) + +/** Input context index */ +#define XHCI_ICI(ctx) ( (ctx) + 1 ) + +/** Number of TRBs (excluding Link TRB) in the command ring + * + * This is a policy decision. + */ +#define XHCI_CMD_TRBS_LOG2 2 + +/** Number of TRBs in the event ring + * + * This is a policy decision. + */ +#define XHCI_EVENT_TRBS_LOG2 6 + +/** Number of TRBs in a transfer ring + * + * This is a policy decision. + */ +#define XHCI_TRANSFER_TRBS_LOG2 6 + +/** Maximum time to wait for BIOS to release ownership + * + * This is a policy decision. + */ +#define XHCI_USBLEGSUP_MAX_WAIT_MS 100 + +/** Maximum time to wait for host controller to stop + * + * This is a policy decision. + */ +#define XHCI_STOP_MAX_WAIT_MS 100 + +/** Maximum time to wait for reset to complete + * + * This is a policy decision. + */ +#define XHCI_RESET_MAX_WAIT_MS 500 + +/** Maximum time to wait for a command to complete + * + * The "address device" command involves waiting for a response to a + * USB control transaction, and so we must wait for up to the 5000ms + * that USB allows for devices to respond to control transactions. + */ +#define XHCI_COMMAND_MAX_WAIT_MS USB_CONTROL_MAX_WAIT_MS + +/** Time to delay after aborting a command + * + * This is a policy decision + */ +#define XHCI_COMMAND_ABORT_DELAY_MS 500 + +/** Maximum time to wait for a port reset to complete + * + * This is a policy decision. + */ +#define XHCI_PORT_RESET_MAX_WAIT_MS 500 + +/** Intel PCH quirk */ +struct xhci_pch { + /** USB2 port routing register original value */ + uint32_t xusb2pr; + /** USB3 port SuperSpeed enable register original value */ + uint32_t usb3pssen; +}; + +/** Intel PCH quirk flag */ +#define XHCI_PCH 0x0001 + +/** Intel PCH USB2 port routing register */ +#define XHCI_PCH_XUSB2PR 0xd0 + +/** Intel PCH USB2 port routing mask register */ +#define XHCI_PCH_XUSB2PRM 0xd4 + +/** Intel PCH SuperSpeed enable register */ +#define XHCI_PCH_USB3PSSEN 0xd8 + +/** Intel PCH USB3 port routing mask register */ +#define XHCI_PCH_USB3PRM 0xdc + +/** Invalid protocol speed ID values quirk */ +#define XHCI_BAD_PSIV 0x0002 + +/** Device context base address array */ +struct xhci_dcbaa { + /** Context base addresses */ + uint64_t *context; + /** DMA mapping */ + struct dma_mapping map; +}; + +/** Scratchpad buffer */ +struct xhci_scratchpad { + /** Number of page-sized scratchpad buffers */ + unsigned int count; + /** Scratchpad buffer area */ + void *buffer; + /** Buffer DMA mapping */ + struct dma_mapping buffer_map; + /** Scratchpad array */ + uint64_t *array; + /** Array DMA mapping */ + struct dma_mapping array_map; +}; + +/** An xHCI device */ +struct xhci_device { + /** Registers */ + void *regs; + /** Underlying hardware device */ + struct device *dev; + /** DMA device */ + struct dma_device *dma; + /** Name */ + const char *name; + /** Quirks */ + unsigned int quirks; + + /** Capability registers */ + void *cap; + /** Operational registers */ + void *op; + /** Runtime registers */ + void *run; + /** Doorbell registers */ + void *db; + + /** Number of device slots */ + unsigned int slots; + /** Number of interrupters */ + unsigned int intrs; + /** Number of ports */ + unsigned int ports; + + /** 64-bit addressing capability */ + int addr64; + /** Context size shift */ + unsigned int csz_shift; + /** xHCI extended capabilities offset */ + unsigned int xecp; + + /** Page size */ + size_t pagesize; + + /** USB legacy support capability (if present and enabled) */ + unsigned int legacy; + + /** Device context base address array */ + struct xhci_dcbaa dcbaa; + + /** Scratchpad buffer */ + struct xhci_scratchpad scratch; + + /** Command ring */ + struct xhci_trb_ring command; + /** Event ring */ + struct xhci_event_ring event; + /** Current command (if any) */ + union xhci_trb *pending; + /** Command mechanism has permanently failed */ + int failed; + + /** Device slots, indexed by slot ID */ + struct xhci_slot **slot; + + /** USB bus */ + struct usb_bus *bus; + + /** Intel PCH quirk */ + struct xhci_pch pch; +}; + +/** An xHCI device slot */ +struct xhci_slot { + /** xHCI device */ + struct xhci_device *xhci; + /** USB device */ + struct usb_device *usb; + /** Slot ID */ + unsigned int id; + /** Slot context */ + struct xhci_slot_context *context; + /** DMA mapping */ + struct dma_mapping map; + /** Route string */ + unsigned int route; + /** Root hub port number */ + unsigned int port; + /** Protocol speed ID */ + unsigned int psiv; + /** Number of ports (if this device is a hub) */ + unsigned int ports; + /** Transaction translator slot ID */ + unsigned int tt_id; + /** Transaction translator port */ + unsigned int tt_port; + /** Endpoints, indexed by context ID */ + struct xhci_endpoint *endpoint[XHCI_CTX_END]; +}; + +/** An xHCI endpoint */ +struct xhci_endpoint { + /** xHCI device */ + struct xhci_device *xhci; + /** xHCI slot */ + struct xhci_slot *slot; + /** USB endpoint */ + struct usb_endpoint *ep; + /** Context index */ + unsigned int ctx; + /** Endpoint type */ + unsigned int type; + /** Endpoint interval */ + unsigned int interval; + /** Endpoint context */ + struct xhci_endpoint_context *context; + /** Transfer ring */ + struct xhci_trb_ring ring; +}; + +extern void xhci_init ( struct xhci_device *xhci ); +extern int xhci_register ( struct xhci_device *xhci ); +extern void xhci_unregister ( struct xhci_device *xhci ); + +#endif /* _IPXE_XHCI_H */ -- cgit v1.2.3-55-g7522 From e01e5ff7c6863a7825d58fb414181a0209dce6f9 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 21 Jul 2025 13:44:38 +0100 Subject: [dwusb] Add driver for DesignWare USB3 host controller Add a basic driver for the DesignWare USB3 host controller as found in the Lichee Pi 4A. This driver covers only the DesignWare host controller hardware. On the Lichee Pi 4A, this is sufficient to get the single USB root hub port (exposed internally via the SODIMM connector) up and running. The driver does not yet handle the various GPIOs that control power and signal routing for the Lichee Pi 4A's onboard VL817 USB hub and the four physical USB-A ports. This therefore leaves the USB hub and the USB-A ports unpowered, and the USB2 root hub port routed to the physical USB-C port. Devices plugged in to the USB-A ports will not be powered up, and a device plugged in to the USB-C port will enumerate as a USB2 device. Signed-off-by: Michael Brown --- src/drivers/usb/dwusb.c | 131 +++++++++++++++++++++++++++++++++++++++++++++ src/drivers/usb/dwusb.h | 23 ++++++++ src/include/ipxe/errfile.h | 1 + 3 files changed, 155 insertions(+) create mode 100644 src/drivers/usb/dwusb.c create mode 100644 src/drivers/usb/dwusb.h (limited to 'src/drivers') diff --git a/src/drivers/usb/dwusb.c b/src/drivers/usb/dwusb.c new file mode 100644 index 000000000..1bae2ce74 --- /dev/null +++ b/src/drivers/usb/dwusb.c @@ -0,0 +1,131 @@ +/* + * Copyright (C) 2025 Michael Brown . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + * + * You can also choose to distribute this program under the terms of + * the Unmodified Binary Distribution Licence (as given in the file + * COPYING.UBDL), provided that you have satisfied its requirements. + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#include +#include +#include +#include +#include +#include +#include "dwusb.h" + +/** @file + * + * Synopsys DesignWare USB3 host controller driver + * + */ + +/** + * Probe devicetree device + * + * @v dt Devicetree device + * @v offset Starting node offset + * @ret rc Return status code + */ +static int dwusb_probe ( struct dt_device *dt, unsigned int offset ) { + struct xhci_device *xhci; + uint32_t gctl; + int rc; + + /* Allocate and initialise structure */ + xhci = zalloc ( sizeof ( *xhci ) ); + if ( ! xhci ) { + rc = -ENOMEM; + goto err_alloc; + } + xhci->dev = &dt->dev; + xhci->dma = &dt->dma; + + /* Map registers */ + xhci->regs = dt_ioremap ( dt, offset, 0, 0 ); + if ( ! xhci->regs ) { + rc = -ENODEV; + goto err_ioremap; + } + + /* Reset via global core control register */ + gctl = readl ( xhci->regs + DWUSB_GCTL ); + writel ( ( gctl | DWUSB_GCTL_RESET ), ( xhci->regs + DWUSB_GCTL ) ); + mdelay ( 100 ); + writel ( gctl, ( xhci->regs + DWUSB_GCTL ) ); + + /* Configure as a host controller */ + gctl &= ~DWUSB_GCTL_PRTDIR_MASK; + gctl |= DWUSB_GCTL_PRTDIR_HOST; + writel ( gctl, ( xhci->regs + DWUSB_GCTL ) ); + + /* Initialise xHCI device */ + xhci_init ( xhci ); + + /* Register xHCI device */ + if ( ( rc = xhci_register ( xhci ) ) != 0 ) { + DBGC ( xhci, "XHCI %s could not register: %s\n", + xhci->name, strerror ( rc ) ); + goto err_register; + } + + dt_set_drvdata ( dt, xhci ); + return 0; + + xhci_unregister ( xhci ); + err_register: + iounmap ( xhci->regs ); + err_ioremap: + free ( xhci ); + err_alloc: + return rc; +} + +/** + * Remove devicetree device + * + * @v dt Devicetree device + */ +static void dwusb_remove ( struct dt_device *dt ) { + struct xhci_device *xhci = dt_get_drvdata ( dt ); + + /* Unregister xHCI device */ + xhci_unregister ( xhci ); + + /* Unmap registers */ + iounmap ( xhci->regs ); + + /* Free device */ + free ( xhci ); +} + +/** DesignWare USB3 compatible model identifiers */ +static const char * dwusb_ids[] = { + "snps,dwc3", +}; + +/** DesignWare USB3 devicetree driver */ +struct dt_driver dwusb_driver __dt_driver = { + .name = "dwusb", + .ids = dwusb_ids, + .id_count = ( sizeof ( dwusb_ids ) / sizeof ( dwusb_ids[0] ) ), + .probe = dwusb_probe, + .remove = dwusb_remove, +}; diff --git a/src/drivers/usb/dwusb.h b/src/drivers/usb/dwusb.h new file mode 100644 index 000000000..523f7ba81 --- /dev/null +++ b/src/drivers/usb/dwusb.h @@ -0,0 +1,23 @@ +#ifndef _DWUSB_H +#define _DWUSB_H + +/** @file + * + * Synopsys DesignWare USB3 host controller driver + * + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#include + +/** Global core control register */ +#define DWUSB_GCTL 0xc110 +#define DWUSB_GCTL_PRTDIR( x ) ( (x) << 12 ) /**< Port direction */ +#define DWUSB_GCTL_PRTDIR_HOST \ + DWUSB_GCTL_PRTDIR ( 1 ) /**< Operate as a host */ +#define DWUSB_GCTL_PRTDIR_MASK \ + DWUSB_GCTL_PRTDIR ( 3 ) /**< Port direction mask */ +#define DWUSB_GCTL_RESET 0x00000800 /**< Core soft reset */ + +#endif /* _DWUSB_H */ diff --git a/src/include/ipxe/errfile.h b/src/include/ipxe/errfile.h index 0e3634f9e..7db8d5679 100644 --- a/src/include/ipxe/errfile.h +++ b/src/include/ipxe/errfile.h @@ -237,6 +237,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define ERRFILE_devtree ( ERRFILE_DRIVER | 0x00da0000 ) #define ERRFILE_cgem ( ERRFILE_DRIVER | 0x00db0000 ) #define ERRFILE_dwmac ( ERRFILE_DRIVER | 0x00dc0000 ) +#define ERRFILE_dwusb ( ERRFILE_DRIVER | 0x00dd0000 ) #define ERRFILE_aoe ( ERRFILE_NET | 0x00000000 ) #define ERRFILE_arp ( ERRFILE_NET | 0x00010000 ) -- cgit v1.2.3-55-g7522 From 6ca7a560a43a97f029c006e6a514e9df0759fb50 Mon Sep 17 00:00:00 2001 From: Joseph Wong Date: Thu, 24 Jul 2025 11:41:16 -0700 Subject: [bnxt] Remove unnecessary I/O macros Remove unnecessary driver specific macros. Use standard pci_read_config_xxxx, pci_write_config_xxx, writel/q calls. Signed-off-by: Joseph Wong --- src/drivers/net/bnxt/bnxt.c | 28 ++++++++++++++-------------- src/drivers/net/bnxt/bnxt.h | 5 ----- 2 files changed, 14 insertions(+), 19 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/bnxt/bnxt.c b/src/drivers/net/bnxt/bnxt.c index 33071fd78..f6cc7bb3d 100644 --- a/src/drivers/net/bnxt/bnxt.c +++ b/src/drivers/net/bnxt/bnxt.c @@ -134,23 +134,23 @@ static int bnxt_get_pci_info ( struct bnxt *bp ) DBGP ( "%s\n", __func__ ); /* Disable Interrupt */ - pci_read_word16 ( bp->pdev, PCI_COMMAND, &bp->cmd_reg ); + pci_read_config_word ( bp->pdev, PCI_COMMAND, &bp->cmd_reg ); cmd_reg = bp->cmd_reg | PCI_COMMAND_INTX_DISABLE; - pci_write_word ( bp->pdev, PCI_COMMAND, cmd_reg ); - pci_read_word16 ( bp->pdev, PCI_COMMAND, &cmd_reg ); + pci_write_config_word ( bp->pdev, PCI_COMMAND, cmd_reg ); + pci_read_config_word ( bp->pdev, PCI_COMMAND, &cmd_reg ); /* SSVID */ - pci_read_word16 ( bp->pdev, + pci_read_config_word ( bp->pdev, PCI_SUBSYSTEM_VENDOR_ID, &bp->subsystem_vendor ); /* SSDID */ - pci_read_word16 ( bp->pdev, + pci_read_config_word ( bp->pdev, PCI_SUBSYSTEM_ID, &bp->subsystem_device ); /* Function Number */ - pci_read_byte ( bp->pdev, + pci_read_config_byte ( bp->pdev, PCICFG_ME_REGISTER, &bp->pf_num ); @@ -200,7 +200,7 @@ static void dev_p5_db ( struct bnxt *bp, u32 idx, u32 xid, u32 flag ) val = ( ( u64 )DBC_MSG_XID ( xid, flag ) << 32 ) | ( u64 )DBC_MSG_IDX ( idx ); - write64 ( val, off ); + writeq ( val, off ); } static void dev_p7_db ( struct bnxt *bp, u32 idx, u32 xid, u32 flag, u32 epoch, u32 toggle ) @@ -214,7 +214,7 @@ static void dev_p7_db ( struct bnxt *bp, u32 idx, u32 xid, u32 flag, u32 epoch, ( u64 )DBC_MSG_IDX ( idx ) | ( u64 )DBC_MSG_EPCH ( epoch ) | ( u64 )DBC_MSG_TOGGLE ( toggle ); - write64 ( val, off ); + writeq ( val, off ); } static void bnxt_db_nq ( struct bnxt *bp ) @@ -227,7 +227,7 @@ static void bnxt_db_nq ( struct bnxt *bp ) dev_p5_db ( bp, ( u32 )bp->nq.cons_id, ( u32 )bp->nq_ring_id, DBC_DBC_TYPE_NQ_ARM ); else - write32 ( CMPL_DOORBELL_KEY_CMPL, ( bp->bar1 + 0 ) ); + writel ( CMPL_DOORBELL_KEY_CMPL, ( bp->bar1 + 0 ) ); } static void bnxt_db_cq ( struct bnxt *bp ) @@ -240,7 +240,7 @@ static void bnxt_db_cq ( struct bnxt *bp ) dev_p5_db ( bp, ( u32 )bp->cq.cons_id, ( u32 )bp->cq_ring_id, DBC_DBC_TYPE_CQ_ARMALL ); else - write32 ( CQ_DOORBELL_KEY_IDX ( bp->cq.cons_id ), + writel ( CQ_DOORBELL_KEY_IDX ( bp->cq.cons_id ), ( bp->bar1 + 0 ) ); } @@ -252,7 +252,7 @@ static void bnxt_db_rx ( struct bnxt *bp, u32 idx ) else if ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P5 ) ) dev_p5_db ( bp, idx, ( u32 )bp->rx_ring_id, DBC_DBC_TYPE_SRQ ); else - write32 ( RX_DOORBELL_KEY_RX | idx, ( bp->bar1 + 0 ) ); + writel ( RX_DOORBELL_KEY_RX | idx, ( bp->bar1 + 0 ) ); } static void bnxt_db_tx ( struct bnxt *bp, u32 idx ) @@ -263,7 +263,7 @@ static void bnxt_db_tx ( struct bnxt *bp, u32 idx ) else if ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P5 ) ) dev_p5_db ( bp, idx, ( u32 )bp->tx_ring_id, DBC_DBC_TYPE_SQ ); else - write32 ( ( u32 ) ( TX_DOORBELL_KEY_TX | idx ), + writel ( ( u32 ) ( TX_DOORBELL_KEY_TX | idx ), ( bp->bar1 + 0 ) ); } @@ -655,10 +655,10 @@ static void hwrm_write_req ( struct bnxt *bp, void *req, u32 cnt ) u32 i = 0; for ( i = 0; i < cnt; i++ ) { - write32 ( ( ( u32 * )req )[i], + writel ( ( ( u32 * )req )[i], ( bp->bar0 + GRC_COM_CHAN_BASE + ( i * 4 ) ) ); } - write32 ( 0x1, ( bp->bar0 + GRC_COM_CHAN_BASE + GRC_COM_CHAN_TRIG ) ); + writel ( 0x1, ( bp->bar0 + GRC_COM_CHAN_BASE + GRC_COM_CHAN_TRIG ) ); } static void short_hwrm_cmd_req ( struct bnxt *bp, u16 len ) diff --git a/src/drivers/net/bnxt/bnxt.h b/src/drivers/net/bnxt/bnxt.h index 726acc7db..779e90d19 100644 --- a/src/drivers/net/bnxt/bnxt.h +++ b/src/drivers/net/bnxt/bnxt.h @@ -1020,11 +1020,6 @@ struct bnxt { /* defines required to rsolve checkpatch errors / warnings */ #define test_if if -#define write32 writel -#define write64 writeq -#define pci_read_byte pci_read_config_byte -#define pci_read_word16 pci_read_config_word -#define pci_write_word pci_write_config_word #define SHORT_CMD_SUPPORTED VER_GET_RESP_DEV_CAPS_CFG_SHORT_CMD_SUPPORTED #define SHORT_CMD_REQUIRED VER_GET_RESP_DEV_CAPS_CFG_SHORT_CMD_REQUIRED #define CQ_DOORBELL_KEY_MASK(a) (\ -- cgit v1.2.3-55-g7522 From 01b1028d4e1556852e3e7fa1f204137950ac1e6b Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 30 Jul 2025 14:08:25 +0100 Subject: [bnxt] Remove unnecessary test_if macro Signed-off-by: Michael Brown --- src/drivers/net/bnxt/bnxt.c | 14 +++++++------- src/drivers/net/bnxt/bnxt.h | 1 - src/drivers/net/bnxt/bnxt_dbg.h | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/bnxt/bnxt.c b/src/drivers/net/bnxt/bnxt.c index f6cc7bb3d..0a7091b5f 100644 --- a/src/drivers/net/bnxt/bnxt.c +++ b/src/drivers/net/bnxt/bnxt.c @@ -624,7 +624,7 @@ int bnxt_alloc_mem ( struct bnxt *bp ) CQ_RING_BUFFER_SIZE, BNXT_DMA_ALIGNMENT ); bp->nq.bd_virt = dma_alloc ( bp->dma, &bp->nq_mapping, NQ_RING_BUFFER_SIZE, BNXT_DMA_ALIGNMENT ); - test_if ( bp->hwrm_addr_req && + if ( bp->hwrm_addr_req && bp->hwrm_addr_resp && bp->hwrm_addr_dma && bp->tx.bd_virt && @@ -693,7 +693,7 @@ static int wait_resp ( struct bnxt *bp, u32 tmo, u16 len, const char *func ) for ( idx = 0; idx < wait_cnt; idx++ ) { resp_len = resp->resp_len; - test_if ( resp->seq_id == req->seq_id && + if ( resp->seq_id == req->seq_id && resp->req_type == req->req_type && ptr[resp_len - 1] == 1 ) { bp->last_resp_code = resp->error_code; @@ -739,7 +739,7 @@ static int bnxt_hwrm_ver_get ( struct bnxt *bp ) resp->chip_bond_id << 8 | resp->chip_platform_type; bp->chip_num = resp->chip_num; - test_if ( ( resp->dev_caps_cfg & SHORT_CMD_SUPPORTED ) && + if ( ( resp->dev_caps_cfg & SHORT_CMD_SUPPORTED ) && ( resp->dev_caps_cfg & SHORT_CMD_REQUIRED ) ) FLAG_SET ( bp->flags, BNXT_FLAG_HWRM_SHORT_CMD_SUPP ); bp->hwrm_max_ext_req_len = resp->max_ext_req_len; @@ -1257,24 +1257,24 @@ static int bnxt_get_link_speed ( struct bnxt *bp ) DBGP ( "%s\n", __func__ ); if ( ! ( FLAG_TEST (bp->flags, BNXT_FLAG_IS_CHIP_P7 ) ) ) { - test_if ( bnxt_hwrm_nvm_get_variable_req ( bp, 4, + if ( bnxt_hwrm_nvm_get_variable_req ( bp, 4, ( u16 )LINK_SPEED_DRV_NUM, 1, ( u16 )bp->port_idx ) != STATUS_SUCCESS ) return STATUS_FAILURE; bp->link_set = SET_LINK ( *ptr32, SPEED_DRV_MASK, SPEED_DRV_SHIFT ); - test_if ( bnxt_hwrm_nvm_get_variable_req ( bp, 4, + if ( bnxt_hwrm_nvm_get_variable_req ( bp, 4, ( u16 )D3_LINK_SPEED_FW_NUM, 1, ( u16 )bp->port_idx ) != STATUS_SUCCESS ) return STATUS_FAILURE; bp->link_set |= SET_LINK ( *ptr32, D3_SPEED_FW_MASK, D3_SPEED_FW_SHIFT ); } - test_if ( bnxt_hwrm_nvm_get_variable_req ( bp, 4, + if ( bnxt_hwrm_nvm_get_variable_req ( bp, 4, ( u16 )LINK_SPEED_FW_NUM, 1, ( u16 )bp->port_idx ) != STATUS_SUCCESS ) return STATUS_FAILURE; bp->link_set |= SET_LINK ( *ptr32, SPEED_FW_MASK, SPEED_FW_SHIFT ); - test_if ( bnxt_hwrm_nvm_get_variable_req ( bp, 1, + if ( bnxt_hwrm_nvm_get_variable_req ( bp, 1, ( u16 )PORT_CFG_LINK_SETTINGS_MEDIA_AUTO_DETECT_NUM, 1, ( u16 )bp->port_idx ) != STATUS_SUCCESS ) return STATUS_FAILURE; diff --git a/src/drivers/net/bnxt/bnxt.h b/src/drivers/net/bnxt/bnxt.h index 779e90d19..5eed766eb 100644 --- a/src/drivers/net/bnxt/bnxt.h +++ b/src/drivers/net/bnxt/bnxt.h @@ -1019,7 +1019,6 @@ struct bnxt { }; /* defines required to rsolve checkpatch errors / warnings */ -#define test_if if #define SHORT_CMD_SUPPORTED VER_GET_RESP_DEV_CAPS_CFG_SHORT_CMD_SUPPORTED #define SHORT_CMD_REQUIRED VER_GET_RESP_DEV_CAPS_CFG_SHORT_CMD_REQUIRED #define CQ_DOORBELL_KEY_MASK(a) (\ diff --git a/src/drivers/net/bnxt/bnxt_dbg.h b/src/drivers/net/bnxt/bnxt_dbg.h index efa8f1215..d6e66ceef 100644 --- a/src/drivers/net/bnxt/bnxt_dbg.h +++ b/src/drivers/net/bnxt/bnxt_dbg.h @@ -197,7 +197,7 @@ void dbg_fw_ver(struct hwrm_ver_get_output *resp, u32 tmo) (u32)(resp->chip_metal << 16) | (u32)(resp->chip_bond_id << 8) | (u32)resp->chip_platform_type); - test_if((resp->dev_caps_cfg & SHORT_CMD_SUPPORTED) && + if((resp->dev_caps_cfg & SHORT_CMD_SUPPORTED) && (resp->dev_caps_cfg & SHORT_CMD_REQUIRED)) dbg_prn(" SHORT_CMD_SUPPORTED\n"); } -- cgit v1.2.3-55-g7522 From f7a1e9ef8e1dc22ebded786507b872a45e3fb05d Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 30 Jul 2025 15:59:38 +0100 Subject: [dwmac] Show core version in debug messages Read and display the core version immediately after mapping the MMIO registers, to provide a basic sanity check that the registers have been correctly mapped and the core is not held in reset. Signed-off-by: Michael Brown --- src/drivers/net/dwmac.c | 7 +++++++ src/drivers/net/dwmac.h | 8 ++++++++ 2 files changed, 15 insertions(+) (limited to 'src/drivers') diff --git a/src/drivers/net/dwmac.c b/src/drivers/net/dwmac.c index 67656e7f1..f581a48a4 100644 --- a/src/drivers/net/dwmac.c +++ b/src/drivers/net/dwmac.c @@ -552,6 +552,7 @@ static int dwmac_probe ( struct dt_device *dt, unsigned int offset ) { struct net_device *netdev; struct dwmac *dwmac; union dwmac_mac mac; + uint32_t version; int rc; /* Allocate and initialise net device */ @@ -580,6 +581,12 @@ static int dwmac_probe ( struct dt_device *dt, unsigned int offset ) { rc = -ENODEV; goto err_ioremap; } + version = readl ( dwmac->regs + DWMAC_VER ); + DBGC ( dwmac, "DWMAC %s version %x.%x (user %x.%x)\n", dwmac->name, + DWMAC_VER_CORE_MAJOR ( version ), + DWMAC_VER_CORE_MINOR ( version ), + DWMAC_VER_USER_MAJOR ( version ), + DWMAC_VER_USER_MINOR ( version ) ); /* Fetch devicetree MAC address */ if ( ( rc = fdt_mac ( &sysfdt, offset, netdev ) ) != 0 ) { diff --git a/src/drivers/net/dwmac.h b/src/drivers/net/dwmac.h index d36bfd4da..4de62b0ce 100644 --- a/src/drivers/net/dwmac.h +++ b/src/drivers/net/dwmac.h @@ -38,6 +38,14 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /** Version register */ #define DWMAC_VER DWMAC_MAC_REG ( 8 ) +#define DWMAC_VER_USER_MAJOR( x ) \ + ( ( (x) >> 12 ) & 0xf ) /**< User major version */ +#define DWMAC_VER_USER_MINOR( x ) \ + ( ( (x) >> 8 ) & 0xf ) /**< User minor version */ +#define DWMAC_VER_CORE_MAJOR( x ) \ + ( ( (x) >> 4 ) & 0xf ) /**< Core major version */ +#define DWMAC_VER_CORE_MINOR( x ) \ + ( ( (x) >> 0 ) & 0xf ) /**< Core minor version */ /** Debug register */ #define DWMAC_DEBUG DWMAC_MAC_REG ( 9 ) -- cgit v1.2.3-55-g7522 From 5f10b7455547fc563caab58f8941111346346433 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 4 Aug 2025 14:52:00 +0100 Subject: [fdt] Use phandle as device location Consumption of phandles will be in the form of locating a functional device (e.g. a GPIO device, or an I2C device, or a reset controller) by phandle, rather than locating the device tree node to which the phandle refers. Repurpose fdt_phandle() to obtain the phandle value (instead of searching by phandle), and record this value as the bus location within the generic device structure. Signed-off-by: Michael Brown --- src/core/fdt.c | 73 ++++++++++++++--------------------------------- src/drivers/bus/devtree.c | 1 + src/include/ipxe/fdt.h | 3 +- src/tests/fdt_test.c | 19 ++++++------ 4 files changed, 34 insertions(+), 62 deletions(-) (limited to 'src/drivers') diff --git a/src/core/fdt.c b/src/core/fdt.c index 6989690bf..ae723213b 100644 --- a/src/core/fdt.c +++ b/src/core/fdt.c @@ -482,57 +482,6 @@ int fdt_alias ( struct fdt *fdt, const char *name, unsigned int *offset ) { return 0; } -/** - * Find node by package handle (phandle) - * - * @v fdt Device tree - * @v phandle Package handle - * @v offset Offset to fill in - * @ret rc Return status code - */ -int fdt_phandle ( struct fdt *fdt, uint32_t phandle, unsigned int *offset ) { - struct fdt_descriptor desc; - uint32_t value; - int depth; - int rc; - - /* Initialise offset */ - *offset = 0; - - /* Find node with matching phandle */ - for ( depth = -1 ; ; depth += desc.depth, *offset = desc.next ) { - - /* Describe token */ - if ( ( rc = fdt_describe ( fdt, *offset, &desc ) ) != 0 ) { - DBGC ( fdt, "FDT +%#04x has malformed node: %s\n", - *offset, strerror ( rc ) ); - return rc; - } - - /* Terminate when we exit the root node */ - if ( ( depth == 0 ) && ( desc.depth < 0 ) ) - break; - - /* Ignore non-nodes */ - if ( ( ! desc.name ) || desc.data ) - continue; - - /* Check for matching "phandle" or "linux-phandle" property */ - if ( ( ( ( rc = fdt_u32 ( fdt, *offset, "phandle", - &value ) ) == 0 ) || - ( ( rc = fdt_u32 ( fdt, *offset, "linux,phandle", - &value ) ) == 0 ) ) && - ( value == phandle ) ) { - DBGC2 ( fdt, "FDT +%#04x has phandle %#02x\n", - *offset, phandle ); - return 0; - } - } - - DBGC ( fdt, "FDT has no phandle %#02x\n", phandle ); - return -ENOENT; -} - /** * Find property * @@ -730,6 +679,28 @@ int fdt_u32 ( struct fdt *fdt, unsigned int offset, const char *name, return 0; } +/** + * Get package handle (phandle) property + * + * @v fdt Device tree + * @v offset Starting node offset + * @ret phandle Package handle, or 0 on error + */ +uint32_t fdt_phandle ( struct fdt *fdt, unsigned int offset ) { + uint32_t phandle; + int rc; + + /* Get "phandle" or "linux,phandle" property */ + if ( ( ( rc = fdt_u32 ( fdt, offset, "phandle", &phandle ) ) == 0 ) || + ( ( rc = fdt_u32 ( fdt, offset, "linux,phandle", + &phandle ) ) == 0 ) ) { + assert ( phandle != 0 ); + return phandle; + } + + return 0; +} + /** * Get region cell size specification * diff --git a/src/drivers/bus/devtree.c b/src/drivers/bus/devtree.c index 59bbc9bf7..cd5bb09a0 100644 --- a/src/drivers/bus/devtree.c +++ b/src/drivers/bus/devtree.c @@ -219,6 +219,7 @@ int dt_probe_node ( struct device *parent, unsigned int offset ) { dt->name = dt->dev.name; snprintf ( dt->dev.name, sizeof ( dt->dev.name ), "%s", name ); dt->dev.desc.bus_type = BUS_TYPE_DT; + dt->dev.desc.location = fdt_phandle ( &sysfdt, offset ); dt->dev.parent = parent; INIT_LIST_HEAD ( &dt->dev.children ); list_add_tail ( &dt->dev.siblings, &parent->children ); diff --git a/src/include/ipxe/fdt.h b/src/include/ipxe/fdt.h index c73389ad7..eec02c5b3 100644 --- a/src/include/ipxe/fdt.h +++ b/src/include/ipxe/fdt.h @@ -176,8 +176,6 @@ extern int fdt_path ( struct fdt *fdt, const char *path, unsigned int *offset ); extern int fdt_alias ( struct fdt *fdt, const char *name, unsigned int *offset ); -extern int fdt_phandle ( struct fdt *fdt, uint32_t phandle, - unsigned int *offset ); extern const char * fdt_strings ( struct fdt *fdt, unsigned int offset, const char *name, unsigned int *count ); extern const char * fdt_string ( struct fdt *fdt, unsigned int offset, @@ -189,6 +187,7 @@ extern int fdt_u64 ( struct fdt *fdt, unsigned int offset, const char *name, uint64_t *value ); extern int fdt_u32 ( struct fdt *fdt, unsigned int offset, const char *name, uint32_t *value ); +extern uint32_t fdt_phandle ( struct fdt *fdt, unsigned int offset ); extern void fdt_reg_cells ( struct fdt *fdt, unsigned int offset, struct fdt_reg_cells *regs ); extern int fdt_reg_count ( struct fdt *fdt, unsigned int offset, diff --git a/src/tests/fdt_test.c b/src/tests/fdt_test.c index 099a093b4..07f7e8911 100644 --- a/src/tests/fdt_test.c +++ b/src/tests/fdt_test.c @@ -237,6 +237,16 @@ static void fdt_test_exec ( void ) { ok ( fdt_path ( &fdt, "/soc/ethernet@10090000", &offset ) == 0 ); ok ( fdt_u32 ( &fdt, offset, "max-speed", &u32 ) != 0 ); + /* Verify phandle properties */ + ok ( fdt_path ( &fdt, "/cpus/cpu@0/interrupt-controller", + &offset ) == 0 ); + ok ( fdt_phandle ( &fdt, offset ) == 0x03 ); + ok ( fdt_path ( &fdt, "/soc/ethernet@10090000/ethernet-phy@0", + &offset ) == 0 ); + ok ( fdt_phandle ( &fdt, offset ) == 0x08 ); + ok ( fdt_path ( &fdt, "/soc/serial@10010000", &offset ) == 0 ); + ok ( fdt_phandle ( &fdt, offset ) == 0 ); + /* Verify cell properties */ ok ( fdt_path ( &fdt, "/soc/ethernet@10090000", &offset ) == 0 ); ok ( fdt_cells ( &fdt, offset, "reg", 4, 2, &u64 ) == 0 ); @@ -261,15 +271,6 @@ static void fdt_test_exec ( void ) { ok ( ( string = fdt_string ( &fdt, offset, "phy-mode" ) ) != NULL ); ok ( strcmp ( string, "gmii" ) == 0 ); - /* Verify phandle lookup */ - ok ( fdt_phandle ( &fdt, 0x03, &offset ) == 0 ); - ok ( fdt_describe ( &fdt, offset, &desc ) == 0 ); - ok ( strcmp ( desc.name, "interrupt-controller" ) == 0 ); - ok ( fdt_phandle ( &fdt, 0x08, &offset ) == 0 ); - ok ( fdt_describe ( &fdt, offset, &desc ) == 0 ); - ok ( strcmp ( desc.name, "ethernet-phy@0" ) == 0 ); - ok ( fdt_phandle ( &fdt, 0x2a, &offset ) != 0 ); - /* Verify node description */ ok ( fdt_path ( &fdt, "/memory@80000000", &offset ) == 0 ); ok ( fdt_describe ( &fdt, offset, &desc ) == 0 ); -- cgit v1.2.3-55-g7522 From 2e4e1f7e9e474f6555009238304780448d3ea238 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 5 Aug 2025 13:55:23 +0100 Subject: [dwgpio] Add driver for the DesignWare GPIO controller Signed-off-by: Michael Brown --- src/Makefile | 1 + src/drivers/bus/devtree.c | 7 +- src/drivers/gpio/dwgpio.c | 337 +++++++++++++++++++++++++++++++++++++++++++++ src/drivers/gpio/dwgpio.h | 81 +++++++++++ src/include/ipxe/devtree.h | 12 ++ src/include/ipxe/errfile.h | 1 + 6 files changed, 434 insertions(+), 5 deletions(-) create mode 100644 src/drivers/gpio/dwgpio.c create mode 100644 src/drivers/gpio/dwgpio.h (limited to 'src/drivers') diff --git a/src/Makefile b/src/Makefile index f3d378e05..22f413d25 100644 --- a/src/Makefile +++ b/src/Makefile @@ -83,6 +83,7 @@ SRCDIRS += drivers/net/marvell SRCDIRS += drivers/block SRCDIRS += drivers/nvs SRCDIRS += drivers/bitbash +SRCDIRS += drivers/gpio SRCDIRS += drivers/infiniband SRCDIRS += drivers/infiniband/mlx_utils_flexboot/src SRCDIRS += drivers/infiniband/mlx_utils/src/public diff --git a/src/drivers/bus/devtree.c b/src/drivers/bus/devtree.c index cd5bb09a0..32ab1c2cb 100644 --- a/src/drivers/bus/devtree.c +++ b/src/drivers/bus/devtree.c @@ -40,8 +40,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); static struct dt_driver dt_node_driver __dt_driver; -static void dt_remove_children ( struct dt_device *parent ); - /** * Map devicetree range * @@ -267,8 +265,7 @@ void dt_remove_node ( struct device *parent ) { * @v offset Starting node offset * @ret rc Return status code */ -static int dt_probe_children ( struct dt_device *parent, - unsigned int offset ) { +int dt_probe_children ( struct dt_device *parent, unsigned int offset ) { struct fdt_descriptor desc; int depth; int rc; @@ -314,7 +311,7 @@ static int dt_probe_children ( struct dt_device *parent, * * @v parent Parent device */ -static void dt_remove_children ( struct dt_device *parent ) { +void dt_remove_children ( struct dt_device *parent ) { /* Remove all child nodes */ while ( ! list_empty ( &parent->dev.children ) ) diff --git a/src/drivers/gpio/dwgpio.c b/src/drivers/gpio/dwgpio.c new file mode 100644 index 000000000..0b300e0c3 --- /dev/null +++ b/src/drivers/gpio/dwgpio.c @@ -0,0 +1,337 @@ +/* + * Copyright (C) 2025 Michael Brown . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + * + * You can also choose to distribute this program under the terms of + * the Unmodified Binary Distribution Licence (as given in the file + * COPYING.UBDL), provided that you have satisfied its requirements. + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#include +#include +#include +#include +#include +#include +#include "dwgpio.h" + +/** @file + * + * Synopsys DesignWare GPIO driver + * + */ + +/****************************************************************************** + * + * GPIO port group + * + ****************************************************************************** + */ + +/** + * Probe port group + * + * @v dt Devicetree device + * @v offset Starting node offset + * @ret rc Return status code + */ +static int dwgpio_group_probe ( struct dt_device *dt, unsigned int offset ) { + struct dwgpio_group *group; + int rc; + + /* Allocate and initialise structure */ + group = zalloc ( sizeof ( *group ) ); + if ( ! group ) { + rc = -ENOMEM; + goto err_alloc; + } + dt_set_drvdata ( dt, group ); + + /* Map registers */ + group->base = dt_ioremap ( dt, offset, 0, 0 ); + if ( ! group->base ) { + rc = -ENODEV; + goto err_ioremap; + } + + /* Get region cell size specification */ + fdt_reg_cells ( &sysfdt, offset, &group->regs ); + + /* Probe child ports */ + if ( ( rc = dt_probe_children ( dt, offset ) ) != 0 ) + goto err_children; + + return 0; + + dt_remove_children ( dt ); + err_children: + iounmap ( group->base ); + err_ioremap: + free ( group ); + err_alloc: + return rc; +} + +/** + * Remove port group + * + * @v dt Devicetree device + */ +static void dwgpio_group_remove ( struct dt_device *dt ) { + struct dwgpio_group *group = dt_get_drvdata ( dt ); + + /* Remove child ports */ + dt_remove_children ( dt ); + + /* Unmap registers */ + iounmap ( group->base ); + + /* Free device */ + free ( group ); +} + +/** DesignWare GPIO port group compatible model identifiers */ +static const char * dwgpio_group_ids[] = { + "snps,dw-apb-gpio", +}; + +/** DesignWare GPIO port group devicetree driver */ +struct dt_driver dwgpio_group_driver __dt_driver = { + .name = "dwgpio-group", + .ids = dwgpio_group_ids, + .id_count = ( sizeof ( dwgpio_group_ids ) / + sizeof ( dwgpio_group_ids[0] ) ), + .probe = dwgpio_group_probe, + .remove = dwgpio_group_remove, +}; + +/****************************************************************************** + * + * GPIO port + * + ****************************************************************************** + */ + +/** + * Dump GPIO port status + * + * @v dwgpio DesignWare GPIO port + */ +static inline void dwgpio_dump ( struct dwgpio *dwgpio ) { + + DBGC2 ( dwgpio, "DWGPIO %s dr %#08x ddr %#08x ctl %#08x\n", + dwgpio->name, readl ( dwgpio->swport + DWGPIO_SWPORT_DR ), + readl ( dwgpio->swport + DWGPIO_SWPORT_DDR ), + readl ( dwgpio->swport + DWGPIO_SWPORT_CTL ) ); +} + +/** + * Get current GPIO input value + * + * @v gpios GPIO controller + * @v gpio GPIO pin + * @ret active Pin is in the active state + */ +static int dwgpio_in ( struct gpios *gpios, struct gpio *gpio ) { + struct dwgpio *dwgpio = gpios->priv; + uint32_t ext; + + /* Read external port status */ + ext = readl ( dwgpio->ext ); + return ( ( ( ext >> gpio->index ) ^ gpio->config ) & 1 ); +} + +/** + * Set current GPIO output value + * + * @v gpios GPIO controller + * @v gpio GPIO pin + * @v active Set pin to active state + */ +static void dwgpio_out ( struct gpios *gpios, struct gpio *gpio, int active ) { + struct dwgpio *dwgpio = gpios->priv; + uint32_t mask = ( 1UL << gpio->index ); + uint32_t dr; + + /* Update data register */ + dr = readl ( dwgpio->swport + DWGPIO_SWPORT_DR ); + dr &= ~mask; + if ( ( ( !! active ) ^ gpio->config ) & 1 ) + dr |= mask; + writel ( dr, ( dwgpio->swport + DWGPIO_SWPORT_DR ) ); + dwgpio_dump ( dwgpio ); +} + +/** + * Configure GPIO pin + * + * @v gpios GPIO controller + * @v gpio GPIO pin + * @v config Configuration + * @ret rc Return status code + */ +static int dwgpio_config ( struct gpios *gpios, struct gpio *gpio, + unsigned int config ) { + struct dwgpio *dwgpio = gpios->priv; + uint32_t mask = ( 1UL << gpio->index ); + uint32_t ddr; + uint32_t ctl; + + /* Update data direction and control registers */ + ddr = readl ( dwgpio->swport + DWGPIO_SWPORT_DDR ); + ctl = readl ( dwgpio->swport + DWGPIO_SWPORT_CTL ); + ctl &= ~mask; + ddr &= ~mask; + if ( config & GPIO_CFG_OUTPUT ) + ddr |= mask; + writel ( ctl, ( dwgpio->swport + DWGPIO_SWPORT_CTL ) ); + writel ( ddr, ( dwgpio->swport + DWGPIO_SWPORT_DDR ) ); + dwgpio_dump ( dwgpio ); + + return 0; +} + +/** GPIO operations */ +static struct gpio_operations dwgpio_operations = { + .in = dwgpio_in, + .out = dwgpio_out, + .config = dwgpio_config, +}; + +/** + * Probe port + * + * @v dt Devicetree device + * @v offset Starting node offset + * @ret rc Return status code + */ +static int dwgpio_probe ( struct dt_device *dt, unsigned int offset ) { + struct dt_device *parent; + struct dwgpio_group *group; + struct dwgpio *dwgpio; + struct gpios *gpios; + uint32_t count; + uint64_t port; + int rc; + + /* Get number of GPIOs */ + if ( ( rc = fdt_u32 ( &sysfdt, offset, "nr-gpios-snps", + &count ) ) != 0 ) { + goto err_count; + } + assert ( count <= DWGPIO_MAX_COUNT ); + + /* Allocate and initialise device */ + gpios = alloc_gpios ( count, sizeof ( *dwgpio ) ); + if ( ! gpios ) { + rc = -ENOMEM; + goto err_alloc; + } + dt_set_drvdata ( dt, gpios ); + gpios->dev = &dt->dev; + gpios_init ( gpios, &dwgpio_operations ); + dwgpio = gpios->priv; + dwgpio->name = dt->name; + + /* Identify group */ + parent = dt_parent ( dt ); + if ( parent->driver != &dwgpio_group_driver ) { + DBGC ( dwgpio, "DWGPIO %s has invalid parent %s\n", + dwgpio->name, parent->name ); + rc = -EINVAL; + goto err_parent; + } + group = dt_get_drvdata ( parent ); + + /* Identify port */ + if ( ( rc = fdt_reg_address ( &sysfdt, offset, &group->regs, 0, + &port ) ) != 0 ) { + DBGC ( dwgpio, "DWGPIO %s could not get port number: %s\n", + dwgpio->name, strerror ( rc ) ); + goto err_port; + } + dwgpio->port = port; + DBGC ( dwgpio, "DWGPIO %s is %s port %d (%d GPIOs)\n", + dwgpio->name, parent->name, dwgpio->port, gpios->count ); + + /* Map registers */ + dwgpio->swport = ( group->base + DWGPIO_SWPORT ( port ) ); + dwgpio->ext = ( group->base + DWGPIO_EXT_PORT ( port ) ); + dwgpio_dump ( dwgpio ); + + /* Record original register values */ + dwgpio->dr = readl ( dwgpio->swport + DWGPIO_SWPORT_DR ); + dwgpio->ddr = readl ( dwgpio->swport + DWGPIO_SWPORT_DDR ); + dwgpio->ctl = readl ( dwgpio->swport + DWGPIO_SWPORT_CTL ); + + /* Register GPIO controller */ + if ( ( rc = gpios_register ( gpios ) ) != 0 ) { + DBGC ( dwgpio, "DWGPIO %s could not register: %s\n", + dwgpio->name, strerror ( rc ) ); + goto err_register; + } + + return 0; + + gpios_unregister ( gpios ); + err_register: + err_port: + err_parent: + gpios_nullify ( gpios ); + gpios_put ( gpios ); + err_alloc: + err_count: + return rc; +} + +/** + * Remove port + * + * @v dt Devicetree device + */ +static void dwgpio_remove ( struct dt_device *dt ) { + struct gpios *gpios = dt_get_drvdata ( dt ); + struct dwgpio *dwgpio = gpios->priv; + + /* Unregister GPIO controller */ + gpios_unregister ( gpios ); + + /* Restore original register values */ + writel ( dwgpio->ctl, ( dwgpio->swport + DWGPIO_SWPORT_CTL ) ); + writel ( dwgpio->ddr, ( dwgpio->swport + DWGPIO_SWPORT_DDR ) ); + writel ( dwgpio->dr, ( dwgpio->swport + DWGPIO_SWPORT_DR ) ); + + /* Free GPIO device */ + gpios_nullify ( gpios ); + gpios_put ( gpios ); +} + +/** DesignWare GPIO port compatible model identifiers */ +static const char * dwgpio_ids[] = { + "snps,dw-apb-gpio-port", +}; + +/** DesignWare GPIO port devicetree driver */ +struct dt_driver dwgpio_driver __dt_driver = { + .name = "dwgpio", + .ids = dwgpio_ids, + .id_count = ( sizeof ( dwgpio_ids ) / sizeof ( dwgpio_ids[0] ) ), + .probe = dwgpio_probe, + .remove = dwgpio_remove, +}; diff --git a/src/drivers/gpio/dwgpio.h b/src/drivers/gpio/dwgpio.h new file mode 100644 index 000000000..4deb6227c --- /dev/null +++ b/src/drivers/gpio/dwgpio.h @@ -0,0 +1,81 @@ +#ifndef _DWGPIO_H +#define _DWGPIO_H + +/** @file + * + * Synopsys DesignWare GPIO driver + * + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +/** Maximum number of GPIOs per port */ +#define DWGPIO_MAX_COUNT 32 + +/** Software port + * + * This is the register bank containing the DR, DDR, and CTL bits. + */ +#define DWGPIO_SWPORT( x ) ( 0x00 + ( (x) * 0x0c ) ) + +/** Data register + * + * Bits written to this register are output if the corresponding DDR + * bit is set to 1 (output) and the corresponding CTL bit is set to 0 + * (software control). + * + * Bits read from this register reflect the most recently written + * value, and do not reflect the actual status of the GPIO pin. + */ +#define DWGPIO_SWPORT_DR 0x00 + +/** Data direction register + * + * The GPIO is an output if the corresponding bit in this register is + * set to 1. + */ +#define DWGPIO_SWPORT_DDR 0x04 + +/** Control register + * + * The GPIO is under software control (i.e. is functioning as a GPIO, + * rather than being controlled by a separate functional block) if the + * corresponding bit in this register is set to 0. + */ +#define DWGPIO_SWPORT_CTL 0x08 + +/** External port + * + * Bits read from this register reflect the current status of the GPIO + * pin. + */ +#define DWGPIO_EXT_PORT( x ) ( 0x50 + ( (x) * 0x04 ) ) + +/** A DesignWare GPIO port group */ +struct dwgpio_group { + /** Register base */ + void *base; + /** Region cell size specification */ + struct fdt_reg_cells regs; +}; + +/** A DesignWare GPIO port */ +struct dwgpio { + /** Device name */ + const char *name; + /** Port index */ + unsigned int port; + /** Software port registers */ + void *swport; + /** External port register */ + void *ext; + + /** Original data register value */ + uint32_t dr; + /** Original data direction register value */ + uint32_t ddr; + /** Original control register value */ + uint32_t ctl; +}; + +#endif /* _DWGPIO_H */ diff --git a/src/include/ipxe/devtree.h b/src/include/ipxe/devtree.h index cdf173938..2bf473a3b 100644 --- a/src/include/ipxe/devtree.h +++ b/src/include/ipxe/devtree.h @@ -77,9 +77,21 @@ static inline void * dt_get_drvdata ( struct dt_device *dt ) { return dt->priv; } +/** + * Get devicetree parent device + * + * @v dt Devicetree device + * @ret parent Parent devicetree device + */ +static inline struct dt_device * dt_parent ( struct dt_device *dt ) { + return container_of ( dt->dev.parent, struct dt_device, dev ); +} + extern void * dt_ioremap ( struct dt_device *dt, unsigned int offset, unsigned int index, size_t len ); extern int dt_probe_node ( struct device *parent, unsigned int offset ); extern void dt_remove_node ( struct device *parent ); +extern int dt_probe_children ( struct dt_device *parent, unsigned int offset ); +extern void dt_remove_children ( struct dt_device *parent ); #endif /* _IPXE_DEVTREE_H */ diff --git a/src/include/ipxe/errfile.h b/src/include/ipxe/errfile.h index b99d2101e..1a8bddbcf 100644 --- a/src/include/ipxe/errfile.h +++ b/src/include/ipxe/errfile.h @@ -239,6 +239,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define ERRFILE_cgem ( ERRFILE_DRIVER | 0x00db0000 ) #define ERRFILE_dwmac ( ERRFILE_DRIVER | 0x00dc0000 ) #define ERRFILE_dwusb ( ERRFILE_DRIVER | 0x00dd0000 ) +#define ERRFILE_dwgpio ( ERRFILE_DRIVER | 0x00de0000 ) #define ERRFILE_aoe ( ERRFILE_NET | 0x00000000 ) #define ERRFILE_arp ( ERRFILE_NET | 0x00010000 ) -- cgit v1.2.3-55-g7522 From 88ba0117649bd8ec711ec0d799acb649284dc492 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 7 Aug 2025 15:41:42 +0100 Subject: [fdt] Provide fdt_reg() for unsized single-entry regions Many region types (e.g. I2C bus addresses) can only ever contain a single region with no size cells specified. Provide fdt_reg() to reduce boilerplate in this common use case. Signed-off-by: Michael Brown --- src/core/fdt.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++ src/drivers/bus/devtree.c | 10 +++------- src/include/ipxe/fdt.h | 3 +++ 3 files changed, 55 insertions(+), 7 deletions(-) (limited to 'src/drivers') diff --git a/src/core/fdt.c b/src/core/fdt.c index ae723213b..08adb166e 100644 --- a/src/core/fdt.c +++ b/src/core/fdt.c @@ -732,6 +732,29 @@ void fdt_reg_cells ( struct fdt *fdt, unsigned int offset, regs->stride = ( regs->address_cells + regs->size_cells ); } +/** + * Get parent region cell size specification + * + * @v fdt Device tree + * @v offset Starting node offset + * @v regs Region cell size specification to fill in + * @ret rc Return status code + */ +int fdt_parent_reg_cells ( struct fdt *fdt, unsigned int offset, + struct fdt_reg_cells *regs ) { + unsigned int parent; + int rc; + + /* Get parent node */ + if ( ( rc = fdt_parent ( fdt, offset, &parent ) ) != 0 ) + return rc; + + /* Read #address-cells and #size-cells, if present */ + fdt_reg_cells ( fdt, parent, regs ); + + return 0; +} + /** * Get number of regions * @@ -806,6 +829,32 @@ int fdt_reg_size ( struct fdt *fdt, unsigned int offset, return 0; } +/** + * Get unsized single-entry region address + * + * @v fdt Device tree + * @v offset Starting node offset + * @v address Region address to fill in + * @ret rc Return status code + * + * Many region types (e.g. I2C bus addresses) can only ever contain a + * single region with no size cells specified. + */ +int fdt_reg ( struct fdt *fdt, unsigned int offset, uint64_t *region ) { + struct fdt_reg_cells regs; + int rc; + + /* Get parent region cell size specification */ + if ( ( rc = fdt_parent_reg_cells ( fdt, offset, ®s ) ) != 0 ) + return rc; + + /* Get first region address */ + if ( ( rc = fdt_reg_address ( fdt, offset, ®s, 0, region ) ) != 0 ) + return rc; + + return 0; +} + /** * Get MAC address from property * diff --git a/src/drivers/bus/devtree.c b/src/drivers/bus/devtree.c index 32ab1c2cb..f71ad1ea4 100644 --- a/src/drivers/bus/devtree.c +++ b/src/drivers/bus/devtree.c @@ -52,22 +52,18 @@ static struct dt_driver dt_node_driver __dt_driver; void * dt_ioremap ( struct dt_device *dt, unsigned int offset, unsigned int index, size_t len ) { struct fdt_reg_cells regs; - unsigned int parent; uint64_t address; uint64_t size; void *io_addr; int rc; - /* Get parent node */ - if ( ( rc = fdt_parent ( &sysfdt, offset, &parent ) ) != 0 ) { - DBGC ( dt, "DT %s could not locate parent: %s\n", + /* Get parent region cell size specification */ + if ( ( rc = fdt_parent_reg_cells ( &sysfdt, offset, ®s ) ) != 0 ) { + DBGC ( dt, "DT %s could not get region cell sizes: %s\n", dt->name, strerror ( rc ) ); return NULL; } - /* Read #address-cells and #size-cells, if present */ - fdt_reg_cells ( &sysfdt, parent, ®s ); - /* Read address */ if ( ( rc = fdt_reg_address ( &sysfdt, offset, ®s, index, &address ) ) != 0 ) { diff --git a/src/include/ipxe/fdt.h b/src/include/ipxe/fdt.h index eec02c5b3..e951aea59 100644 --- a/src/include/ipxe/fdt.h +++ b/src/include/ipxe/fdt.h @@ -190,6 +190,8 @@ extern int fdt_u32 ( struct fdt *fdt, unsigned int offset, const char *name, extern uint32_t fdt_phandle ( struct fdt *fdt, unsigned int offset ); extern void fdt_reg_cells ( struct fdt *fdt, unsigned int offset, struct fdt_reg_cells *regs ); +extern int fdt_parent_reg_cells ( struct fdt *fdt, unsigned int offset, + struct fdt_reg_cells *regs ); extern int fdt_reg_count ( struct fdt *fdt, unsigned int offset, struct fdt_reg_cells *regs ); extern int fdt_reg_address ( struct fdt *fdt, unsigned int offset, @@ -198,6 +200,7 @@ extern int fdt_reg_address ( struct fdt *fdt, unsigned int offset, extern int fdt_reg_size ( struct fdt *fdt, unsigned int offset, struct fdt_reg_cells *regs, unsigned int index, uint64_t *size ); +extern int fdt_reg ( struct fdt *fdt, unsigned int offset, uint64_t *region ); extern int fdt_mac ( struct fdt *fdt, unsigned int offset, struct net_device *netdev ); extern int fdt_parse ( struct fdt *fdt, struct fdt_header *hdr, -- cgit v1.2.3-55-g7522 From 8460dc4e8ffc98db62377d1c5502d6aac40f5a64 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 7 Aug 2025 15:43:58 +0100 Subject: [dwgpio] Use fdt_reg() to get GPIO port numbers DesignWare GPIO port numbers are represented as unsized single-entry regions. Use fdt_reg() to obtain the GPIO port number, rather than requiring access to a region cell size specification stored in the port group structure. This allows the field name "regs" in the port group structure to be repurposed to hold the I/O register base address, which then matches the common usage in other drivers. Signed-off-by: Michael Brown --- src/drivers/gpio/dwgpio.c | 18 +++++++----------- src/drivers/gpio/dwgpio.h | 6 ++---- 2 files changed, 9 insertions(+), 15 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/gpio/dwgpio.c b/src/drivers/gpio/dwgpio.c index 0b300e0c3..eb3882d08 100644 --- a/src/drivers/gpio/dwgpio.c +++ b/src/drivers/gpio/dwgpio.c @@ -64,15 +64,12 @@ static int dwgpio_group_probe ( struct dt_device *dt, unsigned int offset ) { dt_set_drvdata ( dt, group ); /* Map registers */ - group->base = dt_ioremap ( dt, offset, 0, 0 ); - if ( ! group->base ) { + group->regs = dt_ioremap ( dt, offset, 0, 0 ); + if ( ! group->regs ) { rc = -ENODEV; goto err_ioremap; } - /* Get region cell size specification */ - fdt_reg_cells ( &sysfdt, offset, &group->regs ); - /* Probe child ports */ if ( ( rc = dt_probe_children ( dt, offset ) ) != 0 ) goto err_children; @@ -81,7 +78,7 @@ static int dwgpio_group_probe ( struct dt_device *dt, unsigned int offset ) { dt_remove_children ( dt ); err_children: - iounmap ( group->base ); + iounmap ( group->regs ); err_ioremap: free ( group ); err_alloc: @@ -100,7 +97,7 @@ static void dwgpio_group_remove ( struct dt_device *dt ) { dt_remove_children ( dt ); /* Unmap registers */ - iounmap ( group->base ); + iounmap ( group->regs ); /* Free device */ free ( group ); @@ -260,8 +257,7 @@ static int dwgpio_probe ( struct dt_device *dt, unsigned int offset ) { group = dt_get_drvdata ( parent ); /* Identify port */ - if ( ( rc = fdt_reg_address ( &sysfdt, offset, &group->regs, 0, - &port ) ) != 0 ) { + if ( ( rc = fdt_reg ( &sysfdt, offset, &port ) ) != 0 ) { DBGC ( dwgpio, "DWGPIO %s could not get port number: %s\n", dwgpio->name, strerror ( rc ) ); goto err_port; @@ -271,8 +267,8 @@ static int dwgpio_probe ( struct dt_device *dt, unsigned int offset ) { dwgpio->name, parent->name, dwgpio->port, gpios->count ); /* Map registers */ - dwgpio->swport = ( group->base + DWGPIO_SWPORT ( port ) ); - dwgpio->ext = ( group->base + DWGPIO_EXT_PORT ( port ) ); + dwgpio->swport = ( group->regs + DWGPIO_SWPORT ( port ) ); + dwgpio->ext = ( group->regs + DWGPIO_EXT_PORT ( port ) ); dwgpio_dump ( dwgpio ); /* Record original register values */ diff --git a/src/drivers/gpio/dwgpio.h b/src/drivers/gpio/dwgpio.h index 4deb6227c..cee97a6ab 100644 --- a/src/drivers/gpio/dwgpio.h +++ b/src/drivers/gpio/dwgpio.h @@ -53,10 +53,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /** A DesignWare GPIO port group */ struct dwgpio_group { - /** Register base */ - void *base; - /** Region cell size specification */ - struct fdt_reg_cells regs; + /** Registers */ + void *regs; }; /** A DesignWare GPIO port */ -- cgit v1.2.3-55-g7522 From a53ec449327788e2015642bff21443d3a399c05b Mon Sep 17 00:00:00 2001 From: Joseph Wong Date: Wed, 13 Aug 2025 12:36:20 +0100 Subject: [bnxt] Update CQ doorbell type Update completion queue doorbell to a non-arming type, since polling is used. Signed-off-by: Joseph Wong --- src/drivers/net/bnxt/bnxt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/bnxt/bnxt.c b/src/drivers/net/bnxt/bnxt.c index 0a7091b5f..463a1a585 100644 --- a/src/drivers/net/bnxt/bnxt.c +++ b/src/drivers/net/bnxt/bnxt.c @@ -234,11 +234,11 @@ static void bnxt_db_cq ( struct bnxt *bp ) { if ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P7 ) ) dev_p7_db ( bp, ( u32 )bp->cq.cons_id, - ( u32 )bp->cq_ring_id, DBC_DBC_TYPE_CQ_ARMALL, + ( u32 )bp->cq_ring_id, DBC_DBC_TYPE_CQ, ( u32 )bp->cq.epoch, ( u32 )bp->nq.toggle ); else if ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P5 ) ) dev_p5_db ( bp, ( u32 )bp->cq.cons_id, - ( u32 )bp->cq_ring_id, DBC_DBC_TYPE_CQ_ARMALL ); + ( u32 )bp->cq_ring_id, DBC_DBC_TYPE_CQ); else writel ( CQ_DOORBELL_KEY_IDX ( bp->cq.cons_id ), ( bp->bar1 + 0 ) ); -- cgit v1.2.3-55-g7522 From 61b4585e2aa273cd75a4da4369f2bc9e3095290d Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 27 Aug 2025 13:12:11 +0100 Subject: [efi] Drag in MNP driver whenever SNP driver is present The chainloaded-device-only "snponly" driver already drags in support for driving SNP, NII, and MNP devices, on the basis that the user generally doesn't care which UEFI API is used and just wants to boot from the same network device that was used to load iPXE. The multi-device "snp" driver already drags in support for driving SNP and NII devices, but does not drag in support for MNP devices. There is essentially zero code size overhead to dragging in support for MNP devices, since this support is always present in any iPXE application build anyway (as part of the code to download "autoexec.ipxe" prior to installing our own drivers). Minimise surprise by dragging in support for MNP devices whenever using the "snp" driver, following the same reasoning used for the "snponly" driver. Signed-off-by: Michael Brown --- src/drivers/net/efi/snp.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/drivers') diff --git a/src/drivers/net/efi/snp.c b/src/drivers/net/efi/snp.c index a675050e4..854fa872d 100644 --- a/src/drivers/net/efi/snp.c +++ b/src/drivers/net/efi/snp.c @@ -75,3 +75,7 @@ struct efi_driver nii_driver __efi_driver ( EFI_DRIVER_NII ) = { .start = nii_start, .stop = nii_stop, }; + +/** Drag in MNP driver */ +REQUIRING_SYMBOL ( snp_driver ); +REQUIRE_SYMBOL ( mnp_driver ); -- cgit v1.2.3-55-g7522 From 6464f2edb855274cd3e311eff0aa718935b3eef6 Mon Sep 17 00:00:00 2001 From: Joseph Wong Date: Fri, 29 Aug 2025 10:02:00 +0000 Subject: [bnxt] Add error recovery support Add support to advertise adapter error recovery support to the firmware. Implement error recovery operations if adapter fault is detected. Refactor memory allocation to better align with probe and open functions. Signed-off-by: Joseph Wong --- src/drivers/net/bnxt/bnxt.c | 574 +++++++++++++++++++++++++++++++++++----- src/drivers/net/bnxt/bnxt.h | 46 +++- src/drivers/net/bnxt/bnxt_hsi.h | 102 +++++++ 3 files changed, 662 insertions(+), 60 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/bnxt/bnxt.c b/src/drivers/net/bnxt/bnxt.c index 463a1a585..bac601ab6 100644 --- a/src/drivers/net/bnxt/bnxt.c +++ b/src/drivers/net/bnxt/bnxt.c @@ -25,6 +25,7 @@ static void bnxt_adv_cq_index ( struct bnxt *bp, u16 cnt ); static int bnxt_rx_complete ( struct net_device *dev, struct rx_pkt_cmpl *rx ); void bnxt_link_evt ( struct bnxt *bp, struct hwrm_async_event_cmpl *evt ); + static struct pci_device_id bnxt_nics[] = { PCI_ROM( 0x14e4, 0x1604, "14e4-1604", "Broadcom BCM957454", 0 ), PCI_ROM( 0x14e4, 0x1605, "14e4-1605", "Broadcom BCM957454 RDMA", 0 ), @@ -512,12 +513,20 @@ static int bnxt_rx_complete ( struct net_device *dev, return NO_MORE_CQ_BD_TO_SERVICE; } -void bnxt_mm_init ( struct bnxt *bp, const char *func ) +void bnxt_mm_init_hwrm ( struct bnxt *bp, const char *func ) { DBGP ( "%s\n", __func__ ); memset ( bp->hwrm_addr_req, 0, REQ_BUFFER_SIZE ); memset ( bp->hwrm_addr_resp, 0, RESP_BUFFER_SIZE ); memset ( bp->hwrm_addr_dma, 0, DMA_BUFFER_SIZE ); + bp->hwrm_max_req_len = HWRM_MAX_REQ_LEN; + bp->hwrm_cmd_timeout = HWRM_CMD_DEFAULT_TIMEOUT; + dbg_mem ( bp, func ); +} + +void bnxt_mm_init_rings ( struct bnxt *bp, const char *func ) +{ + DBGP ( "%s\n", __func__ ); memset ( bp->tx.bd_virt, 0, TX_RING_BUFFER_SIZE ); memset ( bp->rx.bd_virt, 0, RX_RING_BUFFER_SIZE ); memset ( bp->cq.bd_virt, 0, CQ_RING_BUFFER_SIZE ); @@ -526,7 +535,6 @@ void bnxt_mm_init ( struct bnxt *bp, const char *func ) bp->link_status = STATUS_LINK_DOWN; bp->wait_link_timeout = LINK_DEFAULT_TIMEOUT; bp->mtu = MAX_ETHERNET_PACKET_BUFFER_SIZE; - bp->hwrm_max_req_len = HWRM_MAX_REQ_LEN; bp->nq.ring_cnt = MAX_NQ_DESC_CNT; bp->cq.ring_cnt = MAX_CQ_DESC_CNT; bp->tx.ring_cnt = MAX_TX_DESC_CNT; @@ -556,10 +564,7 @@ void bnxt_mm_nic ( struct bnxt *bp ) bp->rx.iob_cnt = 0; bp->rx.epoch = 0; - bp->link_status = STATUS_LINK_DOWN; - bp->wait_link_timeout = LINK_DEFAULT_TIMEOUT; - bp->mtu = MAX_ETHERNET_PACKET_BUFFER_SIZE; - bp->hwrm_max_req_len = HWRM_MAX_REQ_LEN; + bp->mtu = MAX_ETHERNET_PACKET_BUFFER_SIZE; bp->nq.ring_cnt = MAX_NQ_DESC_CNT; bp->cq.ring_cnt = MAX_CQ_DESC_CNT; bp->tx.ring_cnt = MAX_TX_DESC_CNT; @@ -567,7 +572,7 @@ void bnxt_mm_nic ( struct bnxt *bp ) bp->rx.buf_cnt = NUM_RX_BUFFERS; } -void bnxt_free_mem ( struct bnxt *bp ) +void bnxt_free_rings_mem ( struct bnxt *bp ) { DBGP ( "%s\n", __func__ ); if ( bp->nq.bd_virt ) { @@ -590,6 +595,12 @@ void bnxt_free_mem ( struct bnxt *bp ) bp->tx.bd_virt = NULL; } + DBGP ( "- %s ( ): - Done\n", __func__ ); +} + +void bnxt_free_hwrm_mem ( struct bnxt *bp ) +{ + DBGP ( "%s\n", __func__ ); if ( bp->hwrm_addr_dma ) { dma_free ( &bp->dma_mapped, bp->hwrm_addr_dma, DMA_BUFFER_SIZE ); bp->hwrm_addr_dma = NULL; @@ -607,7 +618,7 @@ void bnxt_free_mem ( struct bnxt *bp ) DBGP ( "- %s ( ): - Done\n", __func__ ); } -int bnxt_alloc_mem ( struct bnxt *bp ) +int bnxt_alloc_hwrm_mem ( struct bnxt *bp ) { DBGP ( "%s\n", __func__ ); bp->hwrm_addr_req = dma_alloc ( bp->dma, &bp->req_mapping, @@ -616,6 +627,22 @@ int bnxt_alloc_mem ( struct bnxt *bp ) RESP_BUFFER_SIZE, RESP_BUFFER_SIZE ); bp->hwrm_addr_dma = dma_alloc ( bp->dma, &bp->dma_mapped, DMA_BUFFER_SIZE, DMA_BUFFER_SIZE); + + if ( bp->hwrm_addr_req && + bp->hwrm_addr_resp && + bp->hwrm_addr_dma ) { + bnxt_mm_init_hwrm ( bp, __func__ ); + return STATUS_SUCCESS; + } + + DBGP ( "- %s ( ): Failed\n", __func__ ); + bnxt_free_hwrm_mem ( bp ); + return -ENOMEM; +} + +int bnxt_alloc_rings_mem ( struct bnxt *bp ) +{ + DBGP ( "%s\n", __func__ ); bp->tx.bd_virt = dma_alloc ( bp->dma, &bp->tx_mapping, TX_RING_BUFFER_SIZE, DMA_ALIGN_4K ); bp->rx.bd_virt = dma_alloc ( bp->dma, &bp->rx_mapping, @@ -624,19 +651,16 @@ int bnxt_alloc_mem ( struct bnxt *bp ) CQ_RING_BUFFER_SIZE, BNXT_DMA_ALIGNMENT ); bp->nq.bd_virt = dma_alloc ( bp->dma, &bp->nq_mapping, NQ_RING_BUFFER_SIZE, BNXT_DMA_ALIGNMENT ); - if ( bp->hwrm_addr_req && - bp->hwrm_addr_resp && - bp->hwrm_addr_dma && - bp->tx.bd_virt && + if ( bp->tx.bd_virt && bp->rx.bd_virt && bp->nq.bd_virt && bp->cq.bd_virt ) { - bnxt_mm_init ( bp, __func__ ); + bnxt_mm_init_rings ( bp, __func__ ); return STATUS_SUCCESS; } DBGP ( "- %s ( ): Failed\n", __func__ ); - bnxt_free_mem ( bp ); + bnxt_free_rings_mem ( bp ); return -ENOMEM; } @@ -897,9 +921,14 @@ static int bnxt_hwrm_func_qcaps_req ( struct bnxt *bp ) bp->fid = resp->fid; bp->port_idx = ( u8 )resp->port_id; + if ( resp->flags & FUNC_QCAPS_OUTPUT_FLAGS_ERROR_RECOVERY_CAPABLE ) { + bp->err_rcvry_supported = 1; + } + /* Get MAC address for this PF */ memcpy ( &bp->mac_addr[0], &resp->mac_address[0], ETH_ALEN ); dbg_func_qcaps ( bp ); + return STATUS_SUCCESS; } @@ -1006,6 +1035,69 @@ static int bnxt_hwrm_func_cfg_req ( struct bnxt *bp ) return wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ ); } +static int bnxt_hwrm_error_recovery_req ( struct bnxt *bp ) +{ + struct hwrm_error_recovery_qcfg_input *req; + struct hwrm_error_recovery_qcfg_output *resp; + int rc = 0; + u8 i = 0; + u16 cmd_len = ( u16 ) sizeof ( struct hwrm_error_recovery_qcfg_input ); + + DBGP ( "%s\n", __func__ ); + /* Set default error recovery heartbeat polling value (in 100ms)*/ + bp->er.drv_poll_freq = 100; + if ( ! ( bp->err_rcvry_supported ) ) { + return STATUS_SUCCESS; + } + + req = ( struct hwrm_error_recovery_qcfg_input * ) REQ_DMA_ADDR ( bp ); + resp = ( struct hwrm_error_recovery_qcfg_output * ) RESP_DMA_ADDR ( bp ); + + hwrm_init ( bp, ( void * ) req, ( u16 ) HWRM_ER_QCFG, cmd_len ); + + rc = wait_resp ( bp, HWRM_CMD_WAIT ( 6 ), cmd_len, __func__ ); + if ( rc ) { + DBGP ( "- %s ( ): Failed\n", __func__ ); + return STATUS_FAILURE; + } + + bp->er.flags = resp->flags; + bp->er.drv_poll_freq = resp->driver_polling_freq; + bp->er.master_wait_period = resp->master_wait_period; + bp->er.normal_wait_period = resp->normal_wait_period; + bp->er.master_wait_post_rst = resp->master_wait_post_reset; + bp->er.max_bailout_post_rst = resp->max_bailout_time; + + bp->er.fw_status_reg = resp->fw_health_status_reg; + bp->er.fw_hb_reg = resp->fw_heartbeat_reg; + bp->er.fw_rst_cnt_reg = resp->fw_reset_cnt_reg; + bp->er.recvry_cnt_reg = resp->err_recovery_cnt_reg; + bp->er.rst_inprg_reg = resp->reset_inprogress_reg; + + bp->er.rst_inprg_reg_mask = resp->reset_inprogress_reg_mask; + bp->er.reg_array_cnt = resp->reg_array_cnt; + + DBGP ( "flags = 0x%x\n", resp->flags ); + DBGP ( "driver_polling_freq = 0x%x\n", resp->driver_polling_freq ); + DBGP ( "master_wait_period = 0x%x\n", resp->master_wait_period ); + DBGP ( "normal_wait_period = 0x%x\n", resp->normal_wait_period ); + DBGP ( "wait_post_reset = 0x%x\n", resp->master_wait_post_reset ); + DBGP ( "bailout_post_reset = 0x%x\n", resp->max_bailout_time ); + DBGP ( "reg_array_cnt = %x\n", resp->reg_array_cnt ); + + for ( i = 0; i < resp->reg_array_cnt; i++ ) { + bp->er.rst_reg[i] = resp->reset_reg[i]; + bp->er.rst_reg_val[i] = resp->reset_reg_val[i]; + bp->er.delay_after_rst[i] = resp->delay_after_reset[i]; + + DBGP ( "rst_reg = %x ", bp->er.rst_reg[i] ); + DBGP ( "rst_reg_val = %x ", bp->er.rst_reg_val[i] ); + DBGP ( "rst_after_reset = %x\n", bp->er.delay_after_rst[i] ); + } + + return STATUS_SUCCESS; +} + static int bnxt_hwrm_func_drv_rgtr ( struct bnxt *bp ) { u16 cmd_len = ( u16 )sizeof ( struct hwrm_func_drv_rgtr_input ); @@ -1020,7 +1112,15 @@ static int bnxt_hwrm_func_drv_rgtr ( struct bnxt *bp ) req->enables = FUNC_DRV_RGTR_REQ_ENABLES_OS_TYPE | FUNC_DRV_RGTR_REQ_ENABLES_ASYNC_EVENT_FWD | FUNC_DRV_RGTR_REQ_ENABLES_VER; - req->async_event_fwd[0] |= 0x01; + req->flags = FUNC_DRV_RGTR_REQ_FLAGS_16BIT_VER_MODE; + + if ( bp->err_rcvry_supported ) { + req->flags |= FUNC_DRV_RGTR_REQ_FLAGS_ERROR_RECOVERY_SUPPORT; + req->flags |= FUNC_DRV_RGTR_REQ_FLAGS_MASTER_SUPPORT; + req->async_event_fwd[0] |= 0x301; + } else { + req->async_event_fwd[0] |= 0x01; + } req->os_type = FUNC_DRV_RGTR_REQ_OS_TYPE_OTHER; req->ver_maj = IPXE_VERSION_MAJOR; req->ver_min = IPXE_VERSION_MINOR; @@ -1612,7 +1712,9 @@ static int bnxt_get_phy_link ( struct bnxt *bp ) mdelay ( LINK_POLL_WAIT_TIME ); } dbg_link_state ( bp, ( u32 ) ( ( i + 1 ) * 100 ) ); - bnxt_set_link ( bp ); + if ( !bp->er.er_rst_on ) { + bnxt_set_link ( bp ); + } return STATUS_SUCCESS; } @@ -1975,8 +2077,27 @@ static int bnxt_reset_rx_mask ( struct bnxt *bp ) return bnxt_hwrm_set_rx_mask ( bp, 0 ); } +static int bnxt_get_link_state ( struct bnxt *bp ) +{ + int rc = 0; + + DBGP ( "%s \n", __func__ ); + rc = bnxt_hwrm_port_phy_qcfg ( bp, PHY_STATUS ); + + return rc; +} + typedef int ( *hwrm_func_t ) ( struct bnxt *bp ); +hwrm_func_t bring_up_init[] = { + bnxt_hwrm_ver_get, /* HWRM_VER_GET */ + bnxt_hwrm_func_qcaps_req, /* HWRM_FUNC_QCAPS */ + bnxt_hwrm_func_qcfg_req, /* HWRM_FUNC_QCFG */ + bnxt_get_device_address, /* HW MAC address */ + bnxt_get_link_state, + NULL +}; + hwrm_func_t bring_down_chip[] = { bnxt_hwrm_func_drv_unrgtr, /* HWRM_FUNC_DRV_UNRGTR */ NULL, @@ -1994,13 +2115,15 @@ hwrm_func_t bring_down_nic[] = { bnxt_hwrm_stat_ctx_free, /* HWRM_STAT_CTX_FREE */ bnxt_hwrm_ring_free_cq, /* HWRM_RING_FREE - CQ Ring */ bnxt_hwrm_ring_free_nq, /* HWRM_RING_FREE - NQ Ring */ + bnxt_hwrm_func_drv_unrgtr, /* HWRM_FUNC_DRV_UNRGTR */ NULL, }; hwrm_func_t bring_up_chip[] = { bnxt_hwrm_ver_get, /* HWRM_VER_GET */ bnxt_hwrm_func_reset_req, /* HWRM_FUNC_RESET */ - bnxt_hwrm_func_drv_rgtr, /* HWRM_FUNC_DRV_RGTR */ bnxt_hwrm_func_qcaps_req, /* HWRM_FUNC_QCAPS */ + bnxt_hwrm_func_drv_rgtr, /* HWRM_FUNC_DRV_RGTR */ + bnxt_hwrm_error_recovery_req, /* HWRM_ERROR_RECOVERY_REQ */ bnxt_hwrm_backing_store_cfg, /* HWRM_FUNC_BACKING_STORE_CFG */ bnxt_hwrm_backing_store_qcfg, /* HWRM_FUNC_BACKING_STORE_QCFG */ bnxt_hwrm_func_resource_qcaps, /* HWRM_FUNC_RESOURCE_QCAPS */ @@ -2052,14 +2175,40 @@ int bnxt_hwrm_run ( hwrm_func_t cmds[], struct bnxt *bp ) #define bnxt_up_chip( bp ) bnxt_hwrm_run ( bring_up_chip, bp ) #define bnxt_down_nic( bp ) bnxt_hwrm_run ( bring_down_nic, bp ) #define bnxt_up_nic( bp ) bnxt_hwrm_run ( bring_up_nic, bp ) +#define bnxt_up_init( bp ) bnxt_hwrm_run ( bring_up_init, bp ) static int bnxt_open ( struct net_device *dev ) { struct bnxt *bp = dev->priv; DBGP ( "%s\n", __func__ ); + + /* Allocate and Initialise device specific parameters */ + if ( bnxt_alloc_rings_mem ( bp ) != 0 ) { + DBGP ( "- %s ( ): bnxt_alloc_rings_mem Failed\n", __func__ ); + return -ENOMEM; + } + bnxt_mm_nic ( bp ); - return (bnxt_up_nic ( bp )); + + if ( bnxt_up_chip ( bp ) != 0 ) { + DBGP ( "- %s ( ): bnxt_up_chip Failed\n", __func__ ); + goto err_bnxt_open; + } + + if ( bnxt_up_nic ( bp ) != 0 ) { + DBGP ( "- %s ( ): bnxt_up_nic\n", __func__); + goto err_bnxt_open; + } + + return 0; + +err_bnxt_open: + bnxt_down_nic ( bp ); + + bnxt_free_rings_mem ( bp ); + + return -1; } static void bnxt_tx_adjust_pkt ( struct bnxt *bp, struct io_buffer *iob ) @@ -2082,6 +2231,11 @@ static int bnxt_tx ( struct net_device *dev, struct io_buffer *iob ) u16 len, entry; physaddr_t mapping; + if ( bp->er.er_rst_on ) { + /* Error recovery has been initiated */ + return -EBUSY; + } + if ( bnxt_tx_avail ( bp ) < 1 ) { DBGP ( "- %s ( ): Failed no bd's available\n", __func__ ); return -ENOBUFS; @@ -2123,17 +2277,264 @@ static void bnxt_adv_nq_index ( struct bnxt *bp, u16 cnt ) void bnxt_link_evt ( struct bnxt *bp, struct hwrm_async_event_cmpl *evt ) { - switch ( evt->event_id ) { - case ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE: - if ( evt->event_data1 & 0x01 ) - bp->link_status = STATUS_LINK_ACTIVE; - else - bp->link_status = STATUS_LINK_DOWN; - bnxt_set_link ( bp ); - dbg_link_status ( bp ); - break; - default: - break; + if ( evt->event_data1 & 0x01 ) + bp->link_status = STATUS_LINK_ACTIVE; + else + bp->link_status = STATUS_LINK_DOWN; + + bnxt_set_link ( bp ); + dbg_link_status ( bp ); +} + +#define BNXT_FW_HEALTH_WIN_OFF 0x3000 +#define BNXT_REG_WINDOW_BASE 0x400 +#define BNXT_GRC_BASE_MASK 0xfff +#define BNXT_GRC_OFFSET_MASK 0xffc + +u32 bnxt_er_reg_write ( struct bnxt *bp, u32 reg_addr, u32 reg_val) +{ + u32 reg_base = 0; + + reg_base = reg_addr & ~BNXT_GRC_BASE_MASK; + + writel ( reg_base, bp->bar0 + BNXT_REG_WINDOW_BASE + 8 ); + + writel ( reg_val, bp->bar0 + ( BNXT_FW_HEALTH_WIN_OFF + + ( reg_addr & BNXT_GRC_OFFSET_MASK ) ) ); + + DBGP ("bnxt_er_reg_write: reg_addr = %x, reg_val = %x\n", reg_addr, reg_val); + return reg_val; +} + +u32 bnxt_er_reg_read ( struct bnxt *bp, u32 reg_addr) +{ + u32 reg_val = 0; + u32 reg_base = 0; + + reg_base = reg_addr & ~BNXT_GRC_BASE_MASK; + + writel ( reg_base, bp->bar0 + BNXT_REG_WINDOW_BASE + 8 ); + + reg_val = readl ( bp->bar0 + ( BNXT_FW_HEALTH_WIN_OFF + + ( reg_addr & BNXT_GRC_OFFSET_MASK ) ) ); + + DBGP ("bnxt_er_reg_read: reg_addr = %x, reg_val = %x\n", reg_addr, reg_val); + return reg_val; +} + +u32 bnxt_er_get_reg_val ( struct bnxt *bp, u32 reg_addr, u32 reg_type, u32 mask ) +{ + u32 reg_val = 0; + + switch ( reg_type ) { + case ER_QCFG_FW_HEALTH_REG_ADDR_SPACE_PCIE_CFG: + pci_read_config_dword ( bp->pdev, reg_addr & mask, ®_val ); + break; + case ER_QCFG_FW_HEALTH_REG_ADDR_SPACE_GRC: + reg_val = bnxt_er_reg_read ( bp, reg_addr ); + break; + case ER_QCFG_FW_HEALTH_REG_ADDR_SPACE_BAR0: + reg_val = readl ( bp->bar0 + ( reg_addr & mask ) ); + break; + case ER_QCFG_FW_HEALTH_REG_ADDR_SPACE_BAR1: + reg_val = readl ( bp->bar1 + ( reg_addr & mask ) ); + break; + default: + break; + } + DBGP ( "read_reg_val bp %p addr %x type %x : reg_val = %x\n", bp, reg_addr, reg_type, reg_val ); + return reg_val; +} + +void bnxt_rst_reg_val ( struct bnxt *bp, u32 reg_addr, u32 reg_val ) +{ + u32 mask = ER_QCFG_RESET_REG_ADDR_MASK; + u32 reg_type = reg_addr & ER_QCFG_RESET_REG_ADDR_SPACE_MASK; + + switch ( reg_type ) { + case ER_QCFG_FW_HEALTH_REG_ADDR_SPACE_PCIE_CFG: + pci_write_config_dword ( bp->pdev, reg_addr & mask, reg_val ); + break; + case ER_QCFG_FW_HEALTH_REG_ADDR_SPACE_GRC: + bnxt_er_reg_write ( bp, reg_addr, reg_val ); + break; + case ER_QCFG_FW_HEALTH_REG_ADDR_SPACE_BAR0: + writel ( reg_val, bp->bar0 + ( reg_addr & mask ) ); + break; + case ER_QCFG_FW_HEALTH_REG_ADDR_SPACE_BAR1: + writel ( reg_val, bp->bar1 + ( reg_addr & mask ) ); + break; + default: + break; + } +} + +void bnxt_rst_er_registers ( struct bnxt *bp ) +{ + u32 delay_time = 0; + u8 i; + + for ( i = 0; i < bp->er.reg_array_cnt; i++ ) { + bnxt_rst_reg_val ( bp, bp->er.rst_reg[i], bp->er.rst_reg_val[i] ); + + delay_time = bp->er.delay_after_rst[i]; + if ( delay_time ) { + udelay ( delay_time * 100000 ); + } + } + +} + +void bnxt_er_task ( struct bnxt* bp, u8 hb_task ) +{ + u32 present_hb_cnt; + unsigned short pci_command, new_command; + u8 i; + + DBGP ( "%s(hb_task: %d)\n", __func__, hb_task ); + if ( bp->er.er_rst_on ) { + if ( timer_running ( &bp->wait_timer) ) { + /* Reset already in progress */ + return; + } + } + + if ( hb_task ) { + present_hb_cnt = bnxt_er_get_reg_val ( bp, + bp->er.fw_hb_reg, + bp->er.fw_hb_reg & ER_QCFG_FW_HB_REG_ADDR_SPACE_MASK, + ER_QCFG_FW_HB_REG_ADDR_MASK ) ; + + if ( present_hb_cnt != bp->er.last_fw_hb ) { + bp->er.last_fw_hb = present_hb_cnt; + return; + } + } + + /* Heartbeat not incrementing, trigger error recovery */ + DBGP ( "%s(): Trigger Error Recovery\n", __func__ ); + bp->er.er_rst_on = 1; + /* Set a recovery phase wait timer */ + start_timer_fixed ( &bp->wait_timer, BNXT_ER_WAIT_TIMER_INTERVAL ( bp ) ); + + /* Disable bus master */ + pci_read_config_word ( bp->pdev, PCI_COMMAND, &pci_command ); + new_command = pci_command & ~PCI_COMMAND_MASTER; + pci_write_config_word ( bp->pdev, PCI_COMMAND, new_command ); + + /* Free up resources */ + bnxt_free_rx_iob ( bp ); + + /* wait for firmware to be operational */ + udelay ( bp->er.rst_min_dsecs * 100000 ); + + /* Reconfigure the PCI attributes */ + pci_write_config_word ( bp->pdev, PCI_COMMAND, pci_command ); + + if ( hb_task ) { + if ( bp->er.master_pf ) { + /* wait for master func wait period */ + udelay ( bp->er.master_wait_period * 100000 ); + + /* Reset register values */ + bnxt_rst_er_registers ( bp ); + + /* wait for master wait post reset */ + udelay ( bp->er.master_wait_post_rst * 100000 ); + } else { + /* wait for normal func wait period */ + udelay ( bp->er.normal_wait_period * 100000 ); + } + } + + for ( i = 0; i < bp->er.max_bailout_post_rst; i++ ) { + bp->er.fw_health_status = bnxt_er_get_reg_val ( bp, + bp->er.fw_status_reg, + bp->er.fw_status_reg & ER_QCFG_FW_HEALTH_REG_ADDR_SPACE_MASK, + ER_QCFG_FW_HEALTH_REG_ADDR_MASK ); + + if ( bp->er.fw_health_status == FW_STATUS_REG_CODE_READY ) + break; + + /* wait for 1 second */ + udelay ( 1000000 ); + } + + if ( bp->er.fw_health_status == FW_STATUS_REG_CODE_READY ) { + /* Initialize resources */ + bnxt_mm_nic ( bp ); + + /* Get device specific information */ + bnxt_up_chip ( bp ); + + /* Allocate queues */ + bnxt_up_nic ( bp ); + } + + /* Clear Reset in progress flag */ + bp->er.er_rst_on = 0; + stop_timer ( &bp->wait_timer ); +} + +void bnxt_process_er_event ( struct bnxt *bp, + struct hwrm_async_event_cmpl *evt ) +{ + if ( evt->event_data1 & + ASYNC_EVENT_CMPL_ER_EVENT_DATA1_RECOVERY_ENABLED ) { + bp->er.driver_initiated_recovery = 1; + start_timer_fixed ( &bp->task_timer, BNXT_ER_TIMER_INTERVAL ( bp ) ); + + } else { + bp->er.driver_initiated_recovery = 0; + stop_timer ( &bp->task_timer ); + } + + if ( evt->event_data1 & + ASYNC_EVENT_CMPL_ER_EVENT_DATA1_MASTER_FUNC ) { + bp->er.master_pf = 1; + } else { + bp->er.master_pf = 0; + } + + bp->er.fw_health_status = bnxt_er_get_reg_val ( bp, + bp->er.fw_status_reg, + bp->er.fw_status_reg & ER_QCFG_FW_HEALTH_REG_ADDR_SPACE_MASK, + ER_QCFG_FW_HEALTH_REG_ADDR_MASK ); + /* Intialize the last fw heart beat count */ + bp->er.last_fw_hb = 0; + bp->er.last_fw_rst_cnt = bnxt_er_get_reg_val ( bp, + bp->er.fw_rst_cnt_reg, + bp->er.fw_rst_cnt_reg & ER_QCFG_FW_RESET_CNT_REG_ADDR_SPACE_MASK, + ER_QCFG_FW_RESET_CNT_REG_ADDR_MASK ); + bp->er.rst_in_progress = bnxt_er_get_reg_val ( bp, + bp->er.rst_inprg_reg, + bp->er.rst_inprg_reg & ER_QCFG_RESET_INPRG_REG_ADDR_SPACE_MASK, + ER_QCFG_RESET_INPRG_REG_ADDR_MASK ); + bp->er.err_recovery_cnt = bnxt_er_get_reg_val ( bp, + bp->er.recvry_cnt_reg, + bp->er.recvry_cnt_reg & ER_QCFG_RCVRY_CNT_REG_ADDR_SPACE_MASK, + ER_QCFG_RCVRY_CNT_REG_ADDR_MASK ); +} + +void bnxt_process_reset_notify_event ( struct bnxt *bp, + struct hwrm_async_event_cmpl *evt ) +{ + DBGP ( "Reset Notify Async event" ); + if ( ( ( evt->event_data1 ) & + ASYNC_EVENT_CMPL_EVENT_DATA1_REASON_CODE_MASK ) == + ASYNC_EVENT_CMPL_EVENT_DATA1_REASON_CODE_FATAL) { + DBGP ( " error recovery initiated\n" ); + bp->er.rst_min_dsecs = evt->timestamp_lo; + bp->er.rst_max_dsecs = evt->timestamp_hi; + + if ( bp->er.rst_min_dsecs == 0 ) + bp->er.rst_min_dsecs = ER_DFLT_FW_RST_MIN_DSECS; + + if ( bp->er.rst_max_dsecs == 0 ) + bp->er.rst_max_dsecs = ER_DFLT_FW_RST_MAX_DSECS; + + // Trigger Error recovery + bp->er.er_initiate = 1; } } @@ -2145,6 +2546,7 @@ static void bnxt_service_cq ( struct net_device *dev ) u16 old_cid = bp->cq.cons_id; int done = SERVICE_NEXT_CQ_BD; u32 cq_type; + struct hwrm_async_event_cmpl *evt; while ( done == SERVICE_NEXT_CQ_BD ) { cmp = ( struct cmpl_base * )BD_NOW ( CQ_DMA_ADDR ( bp ), @@ -2172,8 +2574,23 @@ static void bnxt_service_cq ( struct net_device *dev ) ( struct rx_pkt_cmpl * )cmp ); break; case CMPL_BASE_TYPE_HWRM_ASYNC_EVENT: - bnxt_link_evt ( bp, - ( struct hwrm_async_event_cmpl * )cmp ); + evt = (struct hwrm_async_event_cmpl * )cmp; + switch ( evt->event_id ) { + case ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE: + bnxt_link_evt ( bp, + ( struct hwrm_async_event_cmpl * )cmp ); + break; + case ASYNC_EVENT_CMPL_EVENT_ID_ERROR_RECOVERY: + bnxt_process_er_event ( bp, + ( struct hwrm_async_event_cmpl * )cmp ); + break; + case ASYNC_EVENT_CMPL_EVENT_ID_RESET_NOTIFY: + bnxt_process_reset_notify_event ( bp, + ( struct hwrm_async_event_cmpl * )cmp ); + break; + default: + break; + } bnxt_adv_cq_index ( bp, 1 ); break; default: @@ -2193,6 +2610,7 @@ static void bnxt_service_nq ( struct net_device *dev ) u16 old_cid = bp->nq.cons_id; int done = SERVICE_NEXT_NQ_BD; u32 nq_type; + struct hwrm_async_event_cmpl *evt; if ( ! ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P5_PLUS ) ) ) return; @@ -2210,9 +2628,25 @@ static void bnxt_service_nq ( struct net_device *dev ) switch ( nq_type ) { case CMPL_BASE_TYPE_HWRM_ASYNC_EVENT: - bnxt_link_evt ( bp, - ( struct hwrm_async_event_cmpl * )nqp ); - /* Fall through */ + evt = (struct hwrm_async_event_cmpl * )nqp; + switch ( evt->event_id ) { + case ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE: + bnxt_link_evt ( bp, + ( struct hwrm_async_event_cmpl * )nqp ); + break; + case ASYNC_EVENT_CMPL_EVENT_ID_ERROR_RECOVERY: + bnxt_process_er_event ( bp, + ( struct hwrm_async_event_cmpl * )nqp ); + break; + case ASYNC_EVENT_CMPL_EVENT_ID_RESET_NOTIFY: + bnxt_process_reset_notify_event ( bp, + ( struct hwrm_async_event_cmpl * )nqp ); + break; + default: + break; + } + bnxt_adv_nq_index ( bp, 1 ); + break; case NQ_CN_TYPE_CQ_NOTIFICATION: bnxt_adv_nq_index ( bp, 1 ); break; @@ -2226,11 +2660,40 @@ static void bnxt_service_nq ( struct net_device *dev ) bnxt_db_nq ( bp ); } +static void bnxt_er_task_timer ( struct retry_timer *timer, int over __unused ) +{ + struct bnxt *bp = container_of (timer, struct bnxt, task_timer ); + + /* Restart timer */ + start_timer_fixed ( timer, BNXT_ER_TIMER_INTERVAL ( bp ) ); + if ( bp->er.driver_initiated_recovery ) { + bnxt_er_task ( bp, 1 ); + } +} + +static void bnxt_er_wait_timer ( struct retry_timer *timer, int over __unused ) +{ + struct bnxt *bp = container_of (timer, struct bnxt, wait_timer ); + /* The sole function of this timer is to wait for the specified + * amount of time to complete error recovery phase + */ + stop_timer ( &bp->wait_timer ); + return; +} + static void bnxt_poll ( struct net_device *dev ) { + struct bnxt *bp = dev->priv; + mb ( ); bnxt_service_nq ( dev ); bnxt_service_cq ( dev ); + + if ( bp->er.er_initiate ) { + bnxt_er_task ( bp, 0 ); + bp->er.er_initiate = 0; + } + } static void bnxt_close ( struct net_device *dev ) @@ -2238,15 +2701,12 @@ static void bnxt_close ( struct net_device *dev ) struct bnxt *bp = dev->priv; DBGP ( "%s\n", __func__ ); - bnxt_down_nic (bp); + stop_timer ( &bp->task_timer ); + stop_timer ( &bp->wait_timer ); - /* iounmap PCI BAR ( s ) */ - bnxt_down_pci(bp); + bnxt_down_nic (bp); - /* Get Bar Address */ - bp->bar0 = bnxt_pci_base ( bp->pdev, PCI_BASE_ADDRESS_0 ); - bp->bar1 = bnxt_pci_base ( bp->pdev, PCI_BASE_ADDRESS_2 ); - bp->bar2 = bnxt_pci_base ( bp->pdev, PCI_BASE_ADDRESS_4 ); + bnxt_free_rings_mem ( bp ); } @@ -2287,6 +2747,9 @@ static int bnxt_init_one ( struct pci_device *pci ) bp->dev = netdev; netdev->dev = &pci->dev; + timer_init ( &bp->task_timer, bnxt_er_task_timer, &netdev->refcnt ); + timer_init ( &bp->wait_timer, bnxt_er_wait_timer, &netdev->refcnt ); + /* Configure DMA */ bp->dma = &pci->dma; netdev->dma = bp->dma; @@ -2297,16 +2760,12 @@ static int bnxt_init_one ( struct pci_device *pci ) /* Get PCI Information */ bnxt_get_pci_info ( bp ); - /* Allocate and Initialise device specific parameters */ - if ( ( err = bnxt_alloc_mem ( bp ) ) != 0 ) { - DBGP ( "- %s ( ): bnxt_alloc_mem Failed\n", __func__ ); - goto err_down_pci; - } + /* Allocate HWRM memory */ + bnxt_alloc_hwrm_mem ( bp ); - /* Get device specific information */ - if ( bnxt_up_chip ( bp ) != 0 ) { - DBGP ( "- %s ( ): bnxt_up_chip Failed\n", __func__ ); - err = -ENODEV; + bp->link_status = STATUS_LINK_DOWN; + bp->wait_link_timeout = LINK_DEFAULT_TIMEOUT; + if ( bnxt_up_init ( bp ) != 0 ) { goto err_down_chip; } @@ -2316,15 +2775,14 @@ static int bnxt_init_one ( struct pci_device *pci ) goto err_down_chip; } + /* Set Initial Link State */ + bnxt_set_link ( bp ); + return 0; unregister_netdev ( netdev ); err_down_chip: - bnxt_down_chip (bp); - bnxt_free_mem ( bp ); - -err_down_pci: bnxt_down_pci ( bp ); netdev_nullify ( netdev ); netdev_put ( netdev ); @@ -2343,11 +2801,8 @@ static void bnxt_remove_one ( struct pci_device *pci ) /* Unregister network device */ unregister_netdev ( netdev ); - /* Bring down Chip */ - bnxt_down_chip(bp); - - /* Free Allocated resource */ - bnxt_free_mem ( bp ); + /* Free HWRM buffers */ + bnxt_free_hwrm_mem ( bp ); /* iounmap PCI BAR ( s ) */ bnxt_down_pci ( bp ); @@ -2357,6 +2812,7 @@ static void bnxt_remove_one ( struct pci_device *pci ) /* Drop refernce to network device */ netdev_put ( netdev ); + DBGP ( "%s - Done\n", __func__ ); } /* Broadcom NXE PCI driver */ diff --git a/src/drivers/net/bnxt/bnxt.h b/src/drivers/net/bnxt/bnxt.h index 5eed766eb..53d9fa733 100644 --- a/src/drivers/net/bnxt/bnxt.h +++ b/src/drivers/net/bnxt/bnxt.h @@ -909,6 +909,45 @@ struct rx_info { #define VALID_L2_FILTER 0x0100 #define VALID_RING_NQ 0x0200 +struct lm_error_recovery +{ + __le32 flags; + __le32 drv_poll_freq; + __le32 master_wait_period; + __le32 normal_wait_period; + __le32 master_wait_post_rst; + __le32 max_bailout_post_rst; + __le32 fw_status_reg; + __le32 fw_hb_reg; + __le32 fw_rst_cnt_reg; + __le32 rst_inprg_reg; + __le32 rst_inprg_reg_mask; + __le32 rst_reg[16]; + __le32 rst_reg_val[16]; + u8 delay_after_rst[16]; + __le32 recvry_cnt_reg; + + __le32 last_fw_hb; + __le32 last_fw_rst_cnt; + __le32 fw_health_status; + __le32 err_recovery_cnt; + __le32 rst_in_progress; + __le16 rst_max_dsecs; + + u8 master_pf; + u8 error_recvry_supported; + u8 driver_initiated_recovery; + u8 er_rst_on; + +#define ER_DFLT_FW_RST_MIN_DSECS 20 +#define ER_DFLT_FW_RST_MAX_DSECS 60 +#define FW_STATUS_REG_CODE_READY 0x8000UL + u8 rst_min_dsecs; + u8 reg_array_cnt; + u8 er_initiate; + u8 rsvd[3]; +}; + struct bnxt { /* begin "general, frequently-used members" cacheline section */ /* If the IRQ handler (which runs lockless) needs to be @@ -945,6 +984,9 @@ struct bnxt { struct rx_info rx; /* Rx info. */ struct cmp_info cq; /* completion info. */ struct nq_info nq; /* completion info. */ + struct lm_error_recovery er; /* error recovery. */ + struct retry_timer task_timer; + struct retry_timer wait_timer; u16 nq_ring_id; u8 queue_id; u16 last_resp_code; @@ -991,7 +1033,7 @@ struct bnxt { u16 auto_link_speeds2_mask; u32 link_set; u8 media_detect; - u8 rsvd; + u8 err_rcvry_supported; u16 max_vfs; u16 vf_res_strategy; u16 min_vnics; @@ -1064,3 +1106,5 @@ struct bnxt { #define CHIP_NUM_57502 0x1752 #define CHIP_NUM_57608 0x1760 +#define BNXT_ER_TIMER_INTERVAL(x) ( TICKS_PER_SEC * ( (x)->er.drv_poll_freq ) ) +#define BNXT_ER_WAIT_TIMER_INTERVAL(x) ( TICKS_PER_SEC * ( ( (x)->er.normal_wait_period / 10 ) ) ) diff --git a/src/drivers/net/bnxt/bnxt_hsi.h b/src/drivers/net/bnxt/bnxt_hsi.h index dbcffd909..e1ed7c1f2 100644 --- a/src/drivers/net/bnxt/bnxt_hsi.h +++ b/src/drivers/net/bnxt/bnxt_hsi.h @@ -96,6 +96,7 @@ struct hwrm_short_input { struct cmd_nums { __le16 req_type; #define HWRM_VER_GET 0x0UL + #define HWRM_ER_QCFG 0xcUL #define HWRM_FUNC_DRV_IF_CHANGE 0xdUL #define HWRM_FUNC_BUF_UNRGTR 0xeUL #define HWRM_FUNC_VF_CFG 0xfUL @@ -559,6 +560,7 @@ struct hwrm_async_event_cmpl { #define ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE 0x6UL #define ASYNC_EVENT_CMPL_EVENT_ID_PORT_PHY_CFG_CHANGE 0x7UL #define ASYNC_EVENT_CMPL_EVENT_ID_RESET_NOTIFY 0x8UL + #define ASYNC_EVENT_CMPL_EVENT_ID_ERROR_RECOVERY 0x9UL #define ASYNC_EVENT_CMPL_EVENT_ID_FUNC_DRVR_UNLOAD 0x10UL #define ASYNC_EVENT_CMPL_EVENT_ID_FUNC_DRVR_LOAD 0x11UL #define ASYNC_EVENT_CMPL_EVENT_ID_FUNC_FLR_PROC_CMPLT 0x12UL @@ -583,6 +585,10 @@ struct hwrm_async_event_cmpl { u8 timestamp_lo; __le16 timestamp_hi; __le32 event_data1; + #define ASYNC_EVENT_CMPL_ER_EVENT_DATA1_MASTER_FUNC 0x1UL + #define ASYNC_EVENT_CMPL_ER_EVENT_DATA1_RECOVERY_ENABLED 0x2UL + #define ASYNC_EVENT_CMPL_EVENT_DATA1_REASON_CODE_FATAL (0x2UL << 8) + #define ASYNC_EVENT_CMPL_EVENT_DATA1_REASON_CODE_MASK 0xff00UL }; /* hwrm_async_event_cmpl_link_status_change (size:128b/16B) */ @@ -1357,6 +1363,7 @@ struct hwrm_func_qcaps_output { #define FUNC_QCAPS_RESP_FLAGS_WCB_PUSH_MODE 0x100000UL #define FUNC_QCAPS_RESP_FLAGS_DYNAMIC_TX_RING_ALLOC 0x200000UL #define FUNC_QCAPS_RESP_FLAGS_HOT_RESET_CAPABLE 0x400000UL + #define FUNC_QCAPS_OUTPUT_FLAGS_ERROR_RECOVERY_CAPABLE 0x800000UL u8 mac_address[6]; __le16 max_rsscos_ctx; __le16 max_cmpl_rings; @@ -1718,6 +1725,99 @@ struct hwrm_func_vf_resc_free_output { u8 valid; }; +/* hwrm_error_recovery_input (size:192b/24B) */ +struct hwrm_error_recovery_qcfg_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + u8 unused_0[8]; +}; + +/* hwrm_error_recovery_qcfg_output (size:1664b/208B) */ +struct hwrm_error_recovery_qcfg_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + __le32 flags; + #define ER_QCFG_FLAGS_HOST 0x1UL + #define ER_QCFG_FLAGS_CO_CPU 0x2UL + __le32 driver_polling_freq; + __le32 master_wait_period; + __le32 normal_wait_period; + __le32 master_wait_post_reset; + __le32 max_bailout_time; + __le32 fw_health_status_reg; + #define ER_QCFG_FW_HEALTH_REG_ADDR_SPACE_MASK 0x3UL + #define ER_QCFG_FW_HEALTH_REG_ADDR_SPACE_SFT 0 + #define ER_QCFG_FW_HEALTH_REG_ADDR_SPACE_PCIE_CFG 0x0UL + #define ER_QCFG_FW_HEALTH_REG_ADDR_SPACE_GRC 0x1UL + #define ER_QCFG_FW_HEALTH_REG_ADDR_SPACE_BAR0 0x2UL + #define ER_QCFG_FW_HEALTH_REG_ADDR_SPACE_BAR1 0x3UL + #define ER_QCFG_FW_HEALTH_REG_ADDR_SPACE_LAST ER_QCFG_FW_HEALTH_REG_ADDR_SPACE_BAR1 + #define ER_QCFG_FW_HEALTH_REG_ADDR_MASK 0xfffffffcUL + #define ER_QCFG_FW_HEALTH_REG_ADDR_SFT 2 + __le32 fw_heartbeat_reg; + #define ER_QCFG_FW_HB_REG_ADDR_SPACE_MASK 0x3UL + #define ER_QCFG_FW_HB_REG_ADDR_SPACE_SFT 0 + #define ER_QCFG_FW_HB_REG_ADDR_SPACE_PCIE_CFG 0x0UL + #define ER_QCFG_FW_HB_REG_ADDR_SPACE_GRC 0x1UL + #define ER_QCFG_FW_HB_REG_ADDR_SPACE_BAR0 0x2UL + #define ER_QCFG_FW_HB_REG_ADDR_SPACE_BAR1 0x3UL + #define ER_QCFG_FW_HB_REG_ADDR_SPACE_LAST ER_QCFG_FW_HB_REG_ADDR_SPACE_BAR1 + #define ER_QCFG_FW_HB_REG_ADDR_MASK 0xfffffffcUL + #define ER_QCFG_FW_HB_REG_ADDR_SFT 2 + __le32 fw_reset_cnt_reg; + #define ER_QCFG_FW_RESET_CNT_REG_ADDR_SPACE_MASK 0x3UL + #define ER_QCFG_FW_RESET_CNT_REG_ADDR_SPACE_SFT 0 + #define ER_QCFG_FW_RESET_CNT_REG_ADDR_SPACE_PCIE_CFG 0x0UL + #define ER_QCFG_FW_RESET_CNT_REG_ADDR_SPACE_GRC 0x1UL + #define ER_QCFG_FW_RESET_CNT_REG_ADDR_SPACE_BAR0 0x2UL + #define ER_QCFG_FW_RESET_CNT_REG_ADDR_SPACE_BAR1 0x3UL + #define ER_QCFG_FW_RESET_CNT_REG_ADDR_SPACE_LAST ER_QCFG_FW_RESET_CNT_REG_ADDR_SPACE_BAR1 + #define ER_QCFG_FW_RESET_CNT_REG_ADDR_MASK 0xfffffffcUL + #define ER_QCFG_FW_RESET_CNT_REG_ADDR_SFT 2 + __le32 reset_inprogress_reg; + #define ER_QCFG_RESET_INPRG_REG_ADDR_SPACE_MASK 0x3UL + #define ER_QCFG_RESET_INPRG_REG_ADDR_SPACE_SFT 0 + #define ER_QCFG_RESET_INPRG_REG_ADDR_SPACE_PCIE_CFG 0x0UL + #define ER_QCFG_RESET_INPRG_REG_ADDR_SPACE_GRC 0x1UL + #define ER_QCFG_RESET_INPRG_REG_ADDR_SPACE_BAR0 0x2UL + #define ER_QCFG_RESET_INPRG_REG_ADDR_SPACE_BAR1 0x3UL + #define ER_QCFG_RESET_INPRG_REG_ADDR_SPACE_LAST ER_QCFG_RESET_INPRG_REG_ADDR_SPACE_BAR1 + #define ER_QCFG_RESET_INPRG_REG_ADDR_MASK 0xfffffffcUL + #define ER_QCFG_RESET_INPRG_REG_ADDR_SFT 2 + __le32 reset_inprogress_reg_mask; + u8 unused_0[3]; + u8 reg_array_cnt; + __le32 reset_reg[16]; + #define ER_QCFG_RESET_REG_ADDR_SPACE_MASK 0x3UL + #define ER_QCFG_RESET_REG_ADDR_SPACE_SFT 0 + #define ER_QCFG_RESET_REG_ADDR_SPACE_PCIE_CFG 0x0UL + #define ER_QCFG_RESET_REG_ADDR_SPACE_GRC 0x1UL + #define ER_QCFG_RESET_REG_ADDR_SPACE_BAR0 0x2UL + #define ER_QCFG_RESET_REG_ADDR_SPACE_BAR1 0x3UL + #define ER_QCFG_RESET_REG_ADDR_SPACE_LAST ER_QCFG_RESET_REG_ADDR_SPACE_BAR1 + #define ER_QCFG_RESET_REG_ADDR_MASK 0xfffffffcUL + #define ER_QCFG_RESET_REG_ADDR_SFT 2 + __le32 reset_reg_val[16]; + u8 delay_after_reset[16]; + __le32 err_recovery_cnt_reg; + #define ER_QCFG_RCVRY_CNT_REG_ADDR_SPACE_MASK 0x3UL + #define ER_QCFG_RCVRY_CNT_REG_ADDR_SPACE_SFT 0 + #define ER_QCFG_RCVRY_CNT_REG_ADDR_SPACE_PCIE_CFG 0x0UL + #define ER_QCFG_RCVRY_CNT_REG_ADDR_SPACE_GRC 0x1UL + #define ER_QCFG_RCVRY_CNT_REG_ADDR_SPACE_BAR0 0x2UL + #define ER_QCFG_RCVRY_CNT_REG_ADDR_SPACE_BAR1 0x3UL + #define ER_QCFG_RCVRY_CNT_REG_ADDR_SPACE_LAST ER_QCFG_RCVRY_CNT_REG_ADDR_SPACE_BAR1 + #define ER_QCFG_RCVRY_CNT_REG_ADDR_MASK 0xfffffffcUL + #define ER_QCFG_RCVRY_CNT_REG_ADDR_SFT 2 + u8 unused_1[3]; + u8 valid; +}; + /* hwrm_func_drv_rgtr_input (size:896b/112B) */ struct hwrm_func_drv_rgtr_input { __le16 req_type; @@ -1731,6 +1831,8 @@ struct hwrm_func_drv_rgtr_input { #define FUNC_DRV_RGTR_REQ_FLAGS_16BIT_VER_MODE 0x4UL #define FUNC_DRV_RGTR_REQ_FLAGS_FLOW_HANDLE_64BIT_MODE 0x8UL #define FUNC_DRV_RGTR_REQ_FLAGS_HOT_RESET_SUPPORT 0x10UL + #define FUNC_DRV_RGTR_REQ_FLAGS_ERROR_RECOVERY_SUPPORT 0x20UL + #define FUNC_DRV_RGTR_REQ_FLAGS_MASTER_SUPPORT 0x40UL __le32 enables; #define FUNC_DRV_RGTR_REQ_ENABLES_OS_TYPE 0x1UL #define FUNC_DRV_RGTR_REQ_ENABLES_VER 0x2UL -- cgit v1.2.3-55-g7522 From ee9aea7893b7e1e08b591c06f18b24940198e7c5 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 25 Sep 2025 14:42:19 +0100 Subject: [gve] Parse option list returned in device descriptor Provide space for the device to return its list of supported options. Parse the option list and record the existence of each option in a support bitmask. Signed-off-by: Michael Brown --- src/drivers/net/gve.c | 38 ++++++++++++++++++++++++++++++++++++++ src/drivers/net/gve.h | 42 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 79 insertions(+), 1 deletion(-) (limited to 'src/drivers') diff --git a/src/drivers/net/gve.c b/src/drivers/net/gve.c index 20ea6b97b..bfce6016f 100644 --- a/src/drivers/net/gve.c +++ b/src/drivers/net/gve.c @@ -420,6 +420,12 @@ static int gve_describe ( struct gve_nic *gve ) { struct net_device *netdev = gve->netdev; struct gve_device_descriptor *desc = &gve->scratch.buf->desc; union gve_admin_command *cmd; + struct gve_option *opt; + unsigned int count; + unsigned int id; + size_t offset; + size_t max; + size_t len; int rc; /* Construct request */ @@ -451,6 +457,38 @@ static int gve_describe ( struct gve_nic *gve ) { gve, eth_ntoa ( netdev->hw_addr ), inet_ntoa ( desc->mac.in ), netdev->mtu ); + /* Parse options */ + count = be16_to_cpu ( desc->opt_count ); + max = be16_to_cpu ( desc->len ); + gve->options = 0; + for ( offset = offsetof ( typeof ( *desc ), opts ) ; count ; + count--, offset += len ) { + + /* Check space for option header */ + if ( ( offset + sizeof ( *opt ) ) > max ) { + DBGC ( gve, "GVE %p underlength option at +%#02zx:\n", + gve, offset ); + DBGC_HDA ( gve, 0, desc, sizeof ( *desc ) ); + return -EINVAL; + } + opt = ( ( ( void * ) desc ) + offset ); + + /* Check space for option body */ + len = ( sizeof ( *opt ) + be16_to_cpu ( opt->len ) ); + if ( ( offset + len ) > max ) { + DBGC ( gve, "GVE %p malformed option at +%#02zx:\n", + gve, offset ); + DBGC_HDA ( gve, 0, desc, sizeof ( *desc ) ); + return -EINVAL; + } + + /* Record option as supported */ + id = be16_to_cpu ( opt->id ); + if ( id < ( 8 * sizeof ( gve->options ) ) ) + gve->options |= ( 1 << id ); + } + DBGC ( gve, "GVE %p supports options %#08x\n", gve, gve->options ); + return 0; } diff --git a/src/drivers/net/gve.h b/src/drivers/net/gve.h index 881c25fe2..704c1cbe1 100644 --- a/src/drivers/net/gve.h +++ b/src/drivers/net/gve.h @@ -155,10 +155,48 @@ struct gve_device_descriptor { uint8_t reserved_c[4]; /** MAC address */ struct google_mac mac; + /** Number of device options */ + uint16_t opt_count; + /** Total length (including this header) */ + uint16_t len; /** Reserved */ - uint8_t reserved_d[10]; + uint8_t reserved_d[6]; + /** Space for options + * + * There is no specified upper limit, and no negotiation + * mechanism for the amount of space required. We allow space + * for seems like a reasonable number of options. + */ + uint8_t opts[216]; +} __attribute__ (( packed )); + +/** Device option header */ +struct gve_option { + /** Option ID */ + uint16_t id; + /** Length (excluding this header) */ + uint16_t len; + /** Required feature mask + * + * The purpose of this field is remarkably unclear. The Linux + * kernel driver does define enum gve_dev_opt_req_feat_mask, + * but every member of this enum has a zero value. + */ + uint32_t required; } __attribute__ (( packed )); +/** In-order descriptor queues with raw DMA addressing */ +#define GVE_OPT_GQI_RDA 0x02 + +/** In-order descriptor queues with queue page list addressing */ +#define GVE_OPT_GQI_QPL 0x03 + +/** Out-of-order descriptor queues with raw DMA addressing */ +#define GVE_OPT_DQO_RDA 0x04 + +/** Out-of-order descriptor queues with queue page list addressing */ +#define GVE_OPT_DQO_QPL 0x07 + /** Configure device resources command */ #define GVE_ADMIN_CONFIGURE 0x0002 @@ -663,6 +701,8 @@ struct gve_nic { struct gve_events events; /** Scratch buffer */ struct gve_scratch scratch; + /** Supported options */ + uint32_t options; /** Transmit queue */ struct gve_queue tx; -- cgit v1.2.3-55-g7522 From 610089b98e52c26d8590f9ace9bb8fbc3ff5dcff Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 29 Sep 2025 14:45:32 +0100 Subject: [gve] Remove separate concept of "packet descriptor" The Linux driver occasionally uses the terminology "packet descriptor" to refer to the portion of the descriptor excluding the buffer address. This is not a helpful separation, and merely adds complexity. Simplify the code by removing this artifical separation. Signed-off-by: Michael Brown --- src/drivers/net/gve.c | 34 +++++++++++++++++----------------- src/drivers/net/gve.h | 28 ++++++++-------------------- 2 files changed, 25 insertions(+), 37 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/gve.c b/src/drivers/net/gve.c index bfce6016f..e0badd78a 100644 --- a/src/drivers/net/gve.c +++ b/src/drivers/net/gve.c @@ -1283,19 +1283,19 @@ static int gve_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) { /* Populate descriptor */ index = ( tx->prod++ & ( tx->count - 1 ) ); desc = &tx->desc.tx[index]; - memset ( &desc->pkt, 0, sizeof ( desc->pkt ) ); if ( offset ) { - desc->pkt.type = GVE_TX_TYPE_CONT; + desc->type = GVE_TX_TYPE_CONT; + desc->count = 0; + desc->total = 0; } else { - desc->pkt.type = GVE_TX_TYPE_START; - desc->pkt.count = count; - desc->pkt.total = cpu_to_be16 ( len ); + desc->type = GVE_TX_TYPE_START; + desc->count = count; + desc->total = cpu_to_be16 ( len ); } - desc->pkt.len = cpu_to_be16 ( frag_len ); + desc->len = cpu_to_be16 ( frag_len ); DBGC2 ( gve, "GVE %p TX %#04x %#02x:%#02x len %#04x/%#04x at " - "%#08zx\n", gve, index, desc->pkt.type, - desc->pkt.count, be16_to_cpu ( desc->pkt.len ), - be16_to_cpu ( desc->pkt.total ), + "%#08zx\n", gve, index, desc->type, desc->count, + be16_to_cpu ( desc->len ), be16_to_cpu ( desc->total ), gve_address ( tx, index ) ); } assert ( ( tx->prod - tx->cons ) <= tx->fill ); @@ -1363,22 +1363,22 @@ static void gve_poll_rx ( struct net_device *netdev ) { cmplt = &rx->cmplt.rx[index]; /* Check sequence number */ - if ( ( cmplt->pkt.seq & GVE_RX_SEQ_MASK ) != seq ) + if ( ( cmplt->seq & GVE_RX_SEQ_MASK ) != seq ) break; seq = gve_next ( seq ); /* Parse completion */ - len = be16_to_cpu ( cmplt->pkt.len ); + len = be16_to_cpu ( cmplt->len ); DBGC2 ( gve, "GVE %p RX %#04x %#02x:%#02x len %#04zx at " - "%#08zx\n", gve, index, cmplt->pkt.seq, - cmplt->pkt.flags, len, gve_address ( rx, index ) ); + "%#08zx\n", gve, index, cmplt->seq, cmplt->flags, + len, gve_address ( rx, index ) ); /* Accumulate a complete packet */ - if ( cmplt->pkt.flags & GVE_RXF_ERROR ) { + if ( cmplt->flags & GVE_RXF_ERROR ) { total = 0; } else { total += len; - if ( cmplt->pkt.flags & GVE_RXF_MORE ) + if ( cmplt->flags & GVE_RXF_MORE ) continue; } gve->seq = seq; @@ -1393,7 +1393,7 @@ static void gve_poll_rx ( struct net_device *netdev ) { /* Copy data */ if ( iobuf ) { - len = be16_to_cpu ( cmplt->pkt.len ); + len = be16_to_cpu ( cmplt->len ); memcpy ( iob_put ( iobuf, len ), gve_buffer ( rx, rx->cons ), len ); } @@ -1406,7 +1406,7 @@ static void gve_poll_rx ( struct net_device *netdev ) { iob_pull ( iobuf, GVE_RX_PAD ); netdev_rx ( netdev, iobuf ); } else { - rc = ( ( cmplt->pkt.flags & GVE_RXF_ERROR ) ? + rc = ( ( cmplt->flags & GVE_RXF_ERROR ) ? -EIO : -ENOMEM ); netdev_rx_err ( netdev, NULL, rc ); } diff --git a/src/drivers/net/gve.h b/src/drivers/net/gve.h index 704c1cbe1..ca43d6060 100644 --- a/src/drivers/net/gve.h +++ b/src/drivers/net/gve.h @@ -524,8 +524,8 @@ struct gve_buffer { uint64_t addr; } __attribute__ (( packed )); -/** A transmit packet descriptor */ -struct gve_tx_packet { +/** A transmit descriptor */ +struct gve_tx_descriptor { /** Type */ uint8_t type; /** Reserved */ @@ -536,12 +536,6 @@ struct gve_tx_packet { uint16_t total; /** Length of this descriptor */ uint16_t len; -} __attribute__ (( packed )); - -/** A transmit descriptor */ -struct gve_tx_descriptor { - /** Packet descriptor */ - struct gve_tx_packet pkt; /** Buffer descriptor */ struct gve_buffer buf; } __attribute__ (( packed )); @@ -573,16 +567,6 @@ struct gve_rx_descriptor { struct gve_buffer buf; } __attribute__ (( packed )); -/** A receive packet descriptor */ -struct gve_rx_packet { - /** Length */ - uint16_t len; - /** Flags */ - uint8_t flags; - /** Sequence number */ - uint8_t seq; -} __attribute__ (( packed )); - /** Receive error */ #define GVE_RXF_ERROR 0x08 @@ -596,8 +580,12 @@ struct gve_rx_packet { struct gve_rx_completion { /** Reserved */ uint8_t reserved[60]; - /** Packet descriptor */ - struct gve_rx_packet pkt; + /** Length */ + uint16_t len; + /** Flags */ + uint8_t flags; + /** Sequence number */ + uint8_t seq; } __attribute__ (( packed )); /** Padding at the start of all received packets */ -- cgit v1.2.3-55-g7522 From 048a3467052d00c42041231e11127fe147f6e7c5 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 29 Sep 2025 11:46:15 +0100 Subject: [gve] Add concept of operating mode The GVE family supports two incompatible descriptor queue formats: * GQI: in-order descriptor queues * DQO: out-of-order descriptor queues and two addressing modes: * QPL: pre-registered queue page list addressing * RDA: raw DMA addressing All four combinations (GQI-QPL, GQI-RDA, DQO-QPL, and DQO-RDA) are theoretically supported by the Linux driver, which is essentially the only public reference provided by Google. The original versions of the GVE NIC supported only GQI-QPL mode, and so the iPXE driver is written to target this mode, on the assumption that it would continue to be supported by all models of the GVE NIC. This assumption turns out to be incorrect: Google does not deem it necessary to retain backwards compatibility. Some newer machine types (such as a4-highgpu-8g) support only the DQO-RDA operating mode. Add a definition of operating mode, and pass this as an explicit parameter to the "configure device resources" admin queue command. We choose a representation that subtracts one from the value passed in this command, since this happens to allow us to decompose the mode into two independent bits (one representing the use of DQO descriptor format, one representing the use of QPL addressing). Signed-off-by: Michael Brown --- src/drivers/net/gve.c | 22 ++++++++++++++++++++++ src/drivers/net/gve.h | 20 ++++++++++++++++++++ 2 files changed, 42 insertions(+) (limited to 'src/drivers') diff --git a/src/drivers/net/gve.c b/src/drivers/net/gve.c index e0badd78a..4ac8d2a8a 100644 --- a/src/drivers/net/gve.c +++ b/src/drivers/net/gve.c @@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include @@ -182,6 +183,21 @@ static int gve_reset ( struct gve_nic *gve ) { ****************************************************************************** */ +/** + * Get operating mode name (for debugging) + * + * @v mode Operating mode + * @ret name Mode name + */ +static inline const char * gve_mode_name ( unsigned int mode ) { + static char buf[ 8 /* "XXX-XXX" + NUL */ ]; + + snprintf ( buf, sizeof ( buf ), "%s-%s", + ( ( mode & GVE_MODE_DQO ) ? "DQO" : "GQI" ), + ( ( mode & GVE_MODE_QPL ) ? "QPL" : "RDA" ) ); + return buf; +} + /** * Allocate admin queue * @@ -489,6 +505,11 @@ static int gve_describe ( struct gve_nic *gve ) { } DBGC ( gve, "GVE %p supports options %#08x\n", gve, gve->options ); + /* Select preferred operating mode */ + gve->mode = GVE_MODE_QPL; + DBGC ( gve, "GVE %p using %s mode\n", + gve, gve_mode_name ( gve->mode ) ); + return 0; } @@ -516,6 +537,7 @@ static int gve_configure ( struct gve_nic *gve ) { cmd->conf.num_events = cpu_to_be32 ( events->count ); cmd->conf.num_irqs = cpu_to_be32 ( GVE_IRQ_COUNT ); cmd->conf.irq_stride = cpu_to_be32 ( sizeof ( irqs->irq[0] ) ); + cmd->conf.format = GVE_FORMAT ( gve->mode ); /* Issue command */ if ( ( rc = gve_admin ( gve ) ) != 0 ) diff --git a/src/drivers/net/gve.h b/src/drivers/net/gve.h index ca43d6060..78f085671 100644 --- a/src/drivers/net/gve.h +++ b/src/drivers/net/gve.h @@ -214,8 +214,17 @@ struct gve_admin_configure { uint32_t num_irqs; /** IRQ doorbell stride */ uint32_t irq_stride; + /** MSI-X base index */ + uint32_t msix_base; + /** Descriptor queue format */ + uint8_t format; + /** Reserved */ + uint8_t reserved[7]; } __attribute__ (( packed )); +/** Descriptor queue format */ +#define GVE_FORMAT( mode ) ( (mode) + 1 ) + /** Register page list command */ #define GVE_ADMIN_REGISTER 0x0003 @@ -691,6 +700,8 @@ struct gve_nic { struct gve_scratch scratch; /** Supported options */ uint32_t options; + /** Operating mode */ + unsigned int mode; /** Transmit queue */ struct gve_queue tx; @@ -711,6 +722,15 @@ struct gve_nic { uint32_t activity; }; +/** Operating mode + * + * These values are chosen to allow for easy transformation to a queue + * format identifier as used for the "Configure device resources" + * command. + */ +#define GVE_MODE_QPL 0x01 /**< Use registered queue pages */ +#define GVE_MODE_DQO 0x02 /**< Use out-of-order queues */ + /** Maximum time to wait for admin queue commands */ #define GVE_ADMIN_MAX_WAIT_MS 500 -- cgit v1.2.3-55-g7522 From 91db5b68ffaf15791a204a2f39f5558311539c01 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 29 Sep 2025 12:37:25 +0100 Subject: [gve] Set descriptor and completion ring sizes when creating queues The "create TX queue" and "create RX queue" commands have fields for the descriptor and completion ring sizes, which are currently left unpopulated since they are not required for the original GQI-QPL operating mode. Populate these fields, and allow for the possibility that a transmit completion ring exists (which will be the case when using the DQO operating mode). Signed-off-by: Michael Brown --- src/drivers/net/gve.c | 14 +++++++++++--- src/drivers/net/gve.h | 16 ++++++++++++++-- 2 files changed, 25 insertions(+), 5 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/gve.c b/src/drivers/net/gve.c index 4ac8d2a8a..62e02f050 100644 --- a/src/drivers/net/gve.c +++ b/src/drivers/net/gve.c @@ -639,9 +639,15 @@ static void gve_create_tx_param ( struct gve_queue *queue, /* Construct request parameters */ create->res = cpu_to_be64 ( dma ( &queue->res_map, queue->res ) ); create->desc = - cpu_to_be64 ( dma ( &queue->desc_map, queue->desc.tx ) ); + cpu_to_be64 ( dma ( &queue->desc_map, queue->desc.raw ) ); create->qpl_id = cpu_to_be32 ( type->qpl ); create->notify_id = cpu_to_be32 ( type->irq ); + create->desc_count = cpu_to_be16 ( queue->count ); + if ( queue->cmplt.raw ) { + create->cmplt = cpu_to_be64 ( dma ( &queue->cmplt_map, + queue->cmplt.raw ) ); + create->cmplt_count = cpu_to_be16 ( queue->count ); + } } /** @@ -659,11 +665,13 @@ static void gve_create_rx_param ( struct gve_queue *queue, create->notify_id = cpu_to_be32 ( type->irq ); create->res = cpu_to_be64 ( dma ( &queue->res_map, queue->res ) ); create->desc = - cpu_to_be64 ( dma ( &queue->desc_map, queue->desc.rx ) ); + cpu_to_be64 ( dma ( &queue->desc_map, queue->desc.raw ) ); create->cmplt = - cpu_to_be64 ( dma ( &queue->cmplt_map, queue->cmplt.rx ) ); + cpu_to_be64 ( dma ( &queue->cmplt_map, queue->cmplt.raw ) ); create->qpl_id = cpu_to_be32 ( type->qpl ); + create->desc_count = cpu_to_be16 ( queue->count ); create->bufsz = cpu_to_be16 ( GVE_BUF_SIZE ); + create->cmplt_count = cpu_to_be16 ( queue->count ); } /** diff --git a/src/drivers/net/gve.h b/src/drivers/net/gve.h index 78f085671..333839be6 100644 --- a/src/drivers/net/gve.h +++ b/src/drivers/net/gve.h @@ -278,6 +278,14 @@ struct gve_admin_create_tx { uint32_t qpl_id; /** Notification channel ID */ uint32_t notify_id; + /** Completion ring address */ + uint64_t cmplt; + /** Number of descriptor ring entries */ + uint16_t desc_count; + /** Number of completion ring entries */ + uint16_t cmplt_count; + /** Reserved */ + uint8_t reserved_b[4]; } __attribute__ (( packed )); /** Create receive queue command */ @@ -303,10 +311,14 @@ struct gve_admin_create_rx { uint64_t desc; /** Queue page list ID */ uint32_t qpl_id; - /** Reserved */ - uint8_t reserved_b[2]; + /** Number of descriptor ring entries */ + uint16_t desc_count; /** Packet buffer size */ uint16_t bufsz; + /** Number of completion ring entries */ + uint16_t cmplt_count; + /** Reserved */ + uint8_t reserved[6]; } __attribute__ (( packed )); /** Destroy transmit queue command */ -- cgit v1.2.3-55-g7522 From 9f554ec9d07db63e3132b31df5f5ae68a0debe07 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 29 Sep 2025 12:04:13 +0100 Subject: [gve] Add concept of a queue page list base device address Allow for the existence of a queue page list where the base device address is non-zero, as will be the case for the raw DMA addressing (RDA) operating mode. Signed-off-by: Michael Brown --- src/drivers/net/gve.c | 26 ++++++++++++++++++++------ src/drivers/net/gve.h | 7 +++++++ 2 files changed, 27 insertions(+), 6 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/gve.c b/src/drivers/net/gve.c index 62e02f050..d1f129e2e 100644 --- a/src/drivers/net/gve.c +++ b/src/drivers/net/gve.c @@ -848,14 +848,14 @@ static void gve_free_qpl ( struct gve_nic *nic __unused, } /** - * Get buffer address (within queue page list address space) + * Get buffer offset (within queue page list allocation) * * @v queue Descriptor queue * @v index Buffer index * @ret addr Buffer address within queue page list address space */ static inline __attribute__ (( always_inline)) size_t -gve_address ( struct gve_queue *queue, unsigned int index ) { +gve_offset ( struct gve_queue *queue, unsigned int index ) { /* We allocate sufficient pages for the maximum fill level of * buffers, and reuse the pages in strict rotation as we @@ -864,6 +864,20 @@ gve_address ( struct gve_queue *queue, unsigned int index ) { return ( ( index & ( queue->fill - 1 ) ) * GVE_BUF_SIZE ); } +/** + * Get buffer address (within queue page list address space) + * + * @v queue Descriptor queue + * @v index Buffer index + * @ret addr Buffer address within queue page list address space + */ +static inline __attribute__ (( always_inline)) physaddr_t +gve_address ( struct gve_queue *queue, unsigned int index ) { + + /* Pages are allocated as a single contiguous block */ + return ( queue->qpl.base + gve_offset ( queue, index ) ); +} + /** * Get buffer address * @@ -874,8 +888,8 @@ gve_address ( struct gve_queue *queue, unsigned int index ) { static inline __attribute__ (( always_inline )) void * gve_buffer ( struct gve_queue *queue, unsigned int index ) { - /* Pages are currently allocated as a single contiguous block */ - return ( queue->qpl.data + gve_address ( queue, index ) ); + /* Pages are allocated as a single contiguous block */ + return ( queue->qpl.data + gve_offset ( queue, index ) ); } /** @@ -1326,7 +1340,7 @@ static int gve_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) { DBGC2 ( gve, "GVE %p TX %#04x %#02x:%#02x len %#04x/%#04x at " "%#08zx\n", gve, index, desc->type, desc->count, be16_to_cpu ( desc->len ), be16_to_cpu ( desc->total ), - gve_address ( tx, index ) ); + gve_offset ( tx, index ) ); } assert ( ( tx->prod - tx->cons ) <= tx->fill ); @@ -1401,7 +1415,7 @@ static void gve_poll_rx ( struct net_device *netdev ) { len = be16_to_cpu ( cmplt->len ); DBGC2 ( gve, "GVE %p RX %#04x %#02x:%#02x len %#04zx at " "%#08zx\n", gve, index, cmplt->seq, cmplt->flags, - len, gve_address ( rx, index ) ); + len, gve_offset ( rx, index ) ); /* Accumulate a complete packet */ if ( cmplt->flags & GVE_RXF_ERROR ) { diff --git a/src/drivers/net/gve.h b/src/drivers/net/gve.h index 333839be6..e3d6c3f76 100644 --- a/src/drivers/net/gve.h +++ b/src/drivers/net/gve.h @@ -524,6 +524,13 @@ struct gve_qpl { unsigned int count; /** Queue page list ID */ unsigned int id; + /** Queue page list base device address + * + * This will be zero if queue page list addressing is in use, + * or the DMA address of the first page if raw DMA addressing + * is in use. + */ + physaddr_t base; }; /** -- cgit v1.2.3-55-g7522 From b8dd3c384baeeab14c0455e4f1ce704c6e097c96 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 26 Sep 2025 12:33:19 +0100 Subject: [gve] Add support for raw DMA addressing Raw DMA addressing allows the transmit and receive descriptors to provide the DMA address of the data buffer directly, without requiring the use of a pre-registered queue page list. It is modelled in the device as a magic "raw DMA" queue page list (with QPL ID 0xffffffff) covering the whole of the DMA address space. When using raw DMA addressing, the transmit and receive datapaths could use the normal pattern of mapping I/O buffers directly, and avoid copying packet data into and out of the fixed queue page list ring buffer. However, since we must retain support for queue page list addressing (which requires this additional copying), we choose to minimise code size by continuing to use the fixed ring buffer even when using raw DMA addressing. Add support for using raw DMA addressing by setting the queue page list base device address appropriately, omitting the commands to register and unregister the queue page lists, and specifying the raw DMA QPL ID when creating the TX and RX queues. Signed-off-by: Michael Brown --- src/drivers/net/gve.c | 24 +++++++++++++++++++----- src/drivers/net/gve.h | 6 +++++- 2 files changed, 24 insertions(+), 6 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/gve.c b/src/drivers/net/gve.c index d1f129e2e..80eb2e012 100644 --- a/src/drivers/net/gve.c +++ b/src/drivers/net/gve.c @@ -585,6 +585,10 @@ static int gve_register ( struct gve_nic *gve, struct gve_qpl *qpl ) { unsigned int i; int rc; + /* Do nothing if using raw DMA addressing */ + if ( ! ( gve->mode & GVE_MODE_QPL ) ) + return 0; + /* Build page address list */ for ( i = 0 ; i < qpl->count ; i++ ) { addr = ( qpl->data + ( i * GVE_PAGE_SIZE ) ); @@ -616,6 +620,10 @@ static int gve_register ( struct gve_nic *gve, struct gve_qpl *qpl ) { static int gve_unregister ( struct gve_nic *gve, struct gve_qpl *qpl ) { int rc; + /* Do nothing if using raw DMA addressing */ + if ( ! ( gve->mode & GVE_MODE_QPL ) ) + return 0; + /* Issue command */ if ( ( rc = gve_admin_simple ( gve, GVE_ADMIN_UNREGISTER, qpl->id ) ) != 0 ) { @@ -629,9 +637,10 @@ static int gve_unregister ( struct gve_nic *gve, struct gve_qpl *qpl ) { * Construct command to create transmit queue * * @v queue Transmit queue + * @v qpl Queue page list ID * @v cmd Admin queue command */ -static void gve_create_tx_param ( struct gve_queue *queue, +static void gve_create_tx_param ( struct gve_queue *queue, uint32_t qpl, union gve_admin_command *cmd ) { struct gve_admin_create_tx *create = &cmd->create_tx; const struct gve_queue_type *type = queue->type; @@ -640,7 +649,7 @@ static void gve_create_tx_param ( struct gve_queue *queue, create->res = cpu_to_be64 ( dma ( &queue->res_map, queue->res ) ); create->desc = cpu_to_be64 ( dma ( &queue->desc_map, queue->desc.raw ) ); - create->qpl_id = cpu_to_be32 ( type->qpl ); + create->qpl_id = cpu_to_be32 ( qpl ); create->notify_id = cpu_to_be32 ( type->irq ); create->desc_count = cpu_to_be16 ( queue->count ); if ( queue->cmplt.raw ) { @@ -654,9 +663,10 @@ static void gve_create_tx_param ( struct gve_queue *queue, * Construct command to create receive queue * * @v queue Receive queue + * @v qpl Queue page list ID * @v cmd Admin queue command */ -static void gve_create_rx_param ( struct gve_queue *queue, +static void gve_create_rx_param ( struct gve_queue *queue, uint32_t qpl, union gve_admin_command *cmd ) { struct gve_admin_create_rx *create = &cmd->create_rx; const struct gve_queue_type *type = queue->type; @@ -668,7 +678,7 @@ static void gve_create_rx_param ( struct gve_queue *queue, cpu_to_be64 ( dma ( &queue->desc_map, queue->desc.raw ) ); create->cmplt = cpu_to_be64 ( dma ( &queue->cmplt_map, queue->cmplt.raw ) ); - create->qpl_id = cpu_to_be32 ( type->qpl ); + create->qpl_id = cpu_to_be32 ( qpl ); create->desc_count = cpu_to_be16 ( queue->count ); create->bufsz = cpu_to_be16 ( GVE_BUF_SIZE ); create->cmplt_count = cpu_to_be16 ( queue->count ); @@ -686,6 +696,7 @@ static int gve_create_queue ( struct gve_nic *gve, struct gve_queue *queue ) { union gve_admin_command *cmd; unsigned int db_off; unsigned int evt_idx; + uint32_t qpl; int rc; /* Reset queue */ @@ -695,7 +706,8 @@ static int gve_create_queue ( struct gve_nic *gve, struct gve_queue *queue ) { /* Construct request */ cmd = gve_admin_command ( gve ); cmd->hdr.opcode = type->create; - type->param ( queue, cmd ); + qpl = ( ( gve->mode & GVE_MODE_QPL ) ? type->qpl : GVE_RAW_QPL ); + type->param ( queue, qpl, cmd ); /* Issue command */ if ( ( rc = gve_admin ( gve ) ) != 0 ) @@ -826,6 +838,8 @@ static int gve_alloc_qpl ( struct gve_nic *gve, struct gve_qpl *qpl, qpl->data = dma_umalloc ( gve->dma, &qpl->map, len, GVE_ALIGN ); if ( ! qpl->data ) return -ENOMEM; + qpl->base = ( ( gve->mode & GVE_MODE_QPL ) ? + 0 : dma ( &qpl->map, qpl->data ) ); DBGC ( gve, "GVE %p QPL %#08x at [%08lx,%08lx)\n", gve, qpl->id, virt_to_phys ( qpl->data ), diff --git a/src/drivers/net/gve.h b/src/drivers/net/gve.h index e3d6c3f76..d3b7ca760 100644 --- a/src/drivers/net/gve.h +++ b/src/drivers/net/gve.h @@ -533,6 +533,9 @@ struct gve_qpl { physaddr_t base; }; +/** Raw DMA addressing queue page list ID */ +#define GVE_RAW_QPL 0xffffffff + /** * Maximum number of transmit buffers * @@ -676,9 +679,10 @@ struct gve_queue_type { * Populate command parameters to create queue * * @v queue Descriptor queue + * @v qpl Queue page list ID * @v cmd Admin queue command */ - void ( * param ) ( struct gve_queue *queue, + void ( * param ) ( struct gve_queue *queue, uint32_t qpl, union gve_admin_command *cmd ); /** Queue page list ID */ uint32_t qpl; -- cgit v1.2.3-55-g7522 From 86b322d9992542aeb2e05d6277f7dec98a1637da Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 29 Sep 2025 12:41:06 +0100 Subject: [gve] Allow for out-of-order buffer consumption We currently assume that the buffer index is equal to the descriptor ring index, which is correct only for in-order queues. Out-of-order queues will include a buffer tag value that is copied from the descriptor to the completion. Redefine the data buffers as being indexed by this tag value (rather than by the descriptor ring index), and add a circular ring buffer to allow for tags to be reused in whatever order they are released by the hardware. Signed-off-by: Michael Brown --- src/drivers/net/gve.c | 169 +++++++++++++++++++++++++++++--------------------- src/drivers/net/gve.h | 8 ++- 2 files changed, 106 insertions(+), 71 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/gve.c b/src/drivers/net/gve.c index 80eb2e012..0fb60ac90 100644 --- a/src/drivers/net/gve.c +++ b/src/drivers/net/gve.c @@ -124,6 +124,59 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); EIO_ADMIN_UNAUTH, EIO_ADMIN_RESOURCE, \ EIO_ADMIN_UNAVAIL, EIO_ADMIN_NOTSUP, EIO_ADMIN_UNKNOWN ) +/****************************************************************************** + * + * Buffer layout + * + ****************************************************************************** + */ + +/** + * Get buffer offset (within queue page list allocation) + * + * @v queue Descriptor queue + * @v tag Buffer tag + * @ret addr Buffer address within queue page list address space + */ +static inline __attribute__ (( always_inline)) size_t +gve_offset ( struct gve_queue *queue, unsigned int tag ) { + + /* We allocate sufficient pages for the maximum fill level of + * buffers, and reuse the buffers in strict rotation as they + * are released by the hardware. + */ + assert ( tag < queue->fill ); + return ( tag * GVE_BUF_SIZE ); +} + +/** + * Get buffer address (within queue page list address space) + * + * @v queue Descriptor queue + * @v tag Buffer tag + * @ret addr Buffer address within queue page list address space + */ +static inline __attribute__ (( always_inline)) physaddr_t +gve_address ( struct gve_queue *queue, unsigned int tag ) { + + /* Pages are allocated as a single contiguous block */ + return ( queue->qpl.base + gve_offset ( queue, tag ) ); +} + +/** + * Get buffer address + * + * @v queue Descriptor queue + * @v tag Buffer tag + * @ret addr Buffer address + */ +static inline __attribute__ (( always_inline )) void * +gve_buffer ( struct gve_queue *queue, unsigned int tag ) { + + /* Pages are allocated as a single contiguous block */ + return ( queue->qpl.data + gve_offset ( queue, tag ) ); +} + /****************************************************************************** * * Device reset @@ -694,14 +747,29 @@ static void gve_create_rx_param ( struct gve_queue *queue, uint32_t qpl, static int gve_create_queue ( struct gve_nic *gve, struct gve_queue *queue ) { const struct gve_queue_type *type = queue->type; union gve_admin_command *cmd; + struct gve_buffer *buf; unsigned int db_off; unsigned int evt_idx; + unsigned int tag; + unsigned int i; uint32_t qpl; int rc; /* Reset queue */ queue->prod = 0; queue->cons = 0; + memset ( queue->desc.raw, 0, ( queue->count * type->desc_len ) ); + memset ( queue->cmplt.raw, 0, ( queue->count * type->cmplt_len ) ); + for ( i = 0 ; i < queue->fill ; i++ ) + queue->tag[i] = i; + + /* Pre-populate descriptor offsets */ + buf = ( queue->desc.raw + type->desc_len - sizeof ( *buf ) ); + for ( i = 0 ; i < queue->count ; i++ ) { + tag = ( i & ( queue->fill - 1 ) ); + buf->addr = cpu_to_be64 ( gve_address ( queue, tag ) ); + buf = ( ( ( void * ) buf ) + type->desc_len ); + } /* Construct request */ cmd = gve_admin_command ( gve ); @@ -861,51 +929,6 @@ static void gve_free_qpl ( struct gve_nic *nic __unused, dma_ufree ( &qpl->map, qpl->data, len ); } -/** - * Get buffer offset (within queue page list allocation) - * - * @v queue Descriptor queue - * @v index Buffer index - * @ret addr Buffer address within queue page list address space - */ -static inline __attribute__ (( always_inline)) size_t -gve_offset ( struct gve_queue *queue, unsigned int index ) { - - /* We allocate sufficient pages for the maximum fill level of - * buffers, and reuse the pages in strict rotation as we - * progress through the queue. - */ - return ( ( index & ( queue->fill - 1 ) ) * GVE_BUF_SIZE ); -} - -/** - * Get buffer address (within queue page list address space) - * - * @v queue Descriptor queue - * @v index Buffer index - * @ret addr Buffer address within queue page list address space - */ -static inline __attribute__ (( always_inline)) physaddr_t -gve_address ( struct gve_queue *queue, unsigned int index ) { - - /* Pages are allocated as a single contiguous block */ - return ( queue->qpl.base + gve_offset ( queue, index ) ); -} - -/** - * Get buffer address - * - * @v queue Descriptor queue - * @v index Buffer index - * @ret addr Buffer address - */ -static inline __attribute__ (( always_inline )) void * -gve_buffer ( struct gve_queue *queue, unsigned int index ) { - - /* Pages are allocated as a single contiguous block */ - return ( queue->qpl.data + gve_offset ( queue, index ) ); -} - /** * Calculate next receive sequence number * @@ -944,8 +967,6 @@ static int gve_alloc_queue ( struct gve_nic *gve, struct gve_queue *queue ) { size_t desc_len = ( queue->count * type->desc_len ); size_t cmplt_len = ( queue->count * type->cmplt_len ); size_t res_len = sizeof ( *queue->res ); - struct gve_buffer *buf; - unsigned int i; int rc; /* Sanity checks */ @@ -1002,13 +1023,6 @@ static int gve_alloc_queue ( struct gve_nic *gve, struct gve_queue *queue ) { } memset ( queue->res, 0, res_len ); - /* Populate descriptor offsets */ - buf = ( queue->desc.raw + type->desc_len - sizeof ( *buf ) ); - for ( i = 0 ; i < queue->count ; i++ ) { - buf->addr = cpu_to_be64 ( gve_address ( queue, i ) ); - buf = ( ( ( void * ) buf ) + type->desc_len ); - } - return 0; dma_free ( &queue->res_map, queue->res, res_len ); @@ -1073,9 +1087,6 @@ static int gve_start ( struct gve_nic *gve ) { netdev_tx_complete_err ( netdev, iobuf, -ECANCELED ); } - /* Invalidate receive completions */ - memset ( rx->cmplt.raw, 0, ( rx->count * rx->type->cmplt_len ) ); - /* Reset receive sequence */ gve->seq = gve_next ( 0 ); @@ -1309,6 +1320,7 @@ static int gve_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) { struct gve_tx_descriptor *desc; unsigned int count; unsigned int index; + unsigned int tag; size_t frag_len; size_t offset; size_t len; @@ -1326,20 +1338,24 @@ static int gve_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) { } /* Copy packet to queue pages and populate descriptors */ - for ( offset = 0 ; offset < len ; offset += frag_len ) { + offset = 0; + while ( 1 ) { + + /* Identify next available buffer */ + index = ( tx->prod++ & ( tx->count - 1 ) ); + tag = tx->tag[ index % GVE_TX_FILL ]; /* Sanity check */ - assert ( gve->tx_iobuf[ tx->prod % GVE_TX_FILL ] == NULL ); + assert ( gve->tx_iobuf[tag] == NULL ); /* Copy packet fragment */ frag_len = ( len - offset ); if ( frag_len > GVE_BUF_SIZE ) frag_len = GVE_BUF_SIZE; - memcpy ( gve_buffer ( tx, tx->prod ), + memcpy ( gve_buffer ( tx, tag ), ( iobuf->data + offset ), frag_len ); /* Populate descriptor */ - index = ( tx->prod++ & ( tx->count - 1 ) ); desc = &tx->desc.tx[index]; if ( offset ) { desc->type = GVE_TX_TYPE_CONT; @@ -1354,13 +1370,19 @@ static int gve_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) { DBGC2 ( gve, "GVE %p TX %#04x %#02x:%#02x len %#04x/%#04x at " "%#08zx\n", gve, index, desc->type, desc->count, be16_to_cpu ( desc->len ), be16_to_cpu ( desc->total ), - gve_offset ( tx, index ) ); + gve_offset ( tx, tag ) ); + + /* Move to next descriptor */ + offset += frag_len; + if ( offset < len ) + continue; + + /* Record I/O buffer against final descriptor */ + gve->tx_iobuf[tag] = iobuf; + break; } assert ( ( tx->prod - tx->cons ) <= tx->fill ); - /* Record I/O buffer against final descriptor */ - gve->tx_iobuf[ ( tx->prod - 1U ) % GVE_TX_FILL ] = iobuf; - /* Ring doorbell */ wmb(); writel ( bswap_32 ( tx->prod ), tx->db ); @@ -1377,6 +1399,7 @@ static void gve_poll_tx ( struct net_device *netdev ) { struct gve_nic *gve = netdev->priv; struct gve_queue *tx = &gve->tx; struct io_buffer *iobuf; + unsigned int tag; uint32_t count; /* Read event counter */ @@ -1385,8 +1408,9 @@ static void gve_poll_tx ( struct net_device *netdev ) { /* Process transmit completions */ while ( count != tx->cons ) { DBGC2 ( gve, "GVE %p TX %#04x complete\n", gve, tx->cons ); - iobuf = gve->tx_iobuf[ tx->cons % GVE_TX_FILL ]; - gve->tx_iobuf[ tx->cons % GVE_TX_FILL ] = NULL; + tag = ( tx->cons % GVE_TX_FILL ); + iobuf = gve->tx_iobuf[tag]; + gve->tx_iobuf[tag] = NULL; tx->cons++; if ( iobuf ) netdev_tx_complete ( netdev, iobuf ); @@ -1405,6 +1429,7 @@ static void gve_poll_rx ( struct net_device *netdev ) { struct io_buffer *iobuf; unsigned int index; unsigned int seq; + unsigned int tag; uint32_t cons; size_t total; size_t len; @@ -1427,9 +1452,10 @@ static void gve_poll_rx ( struct net_device *netdev ) { /* Parse completion */ len = be16_to_cpu ( cmplt->len ); + tag = ( index % GVE_RX_FILL ); DBGC2 ( gve, "GVE %p RX %#04x %#02x:%#02x len %#04zx at " "%#08zx\n", gve, index, cmplt->seq, cmplt->flags, - len, gve_offset ( rx, index ) ); + len, gve_offset ( rx, tag ) ); /* Accumulate a complete packet */ if ( cmplt->flags & GVE_RXF_ERROR ) { @@ -1445,15 +1471,16 @@ static void gve_poll_rx ( struct net_device *netdev ) { iobuf = ( total ? alloc_iob ( total ) : NULL ); for ( ; rx->cons != cons ; rx->cons++ ) { - /* Re-read completion length */ + /* Re-read completion */ index = ( rx->cons & ( rx->count - 1 ) ); cmplt = &rx->cmplt.rx[index]; + tag = ( index % GVE_RX_FILL ); /* Copy data */ if ( iobuf ) { len = be16_to_cpu ( cmplt->len ); memcpy ( iob_put ( iobuf, len ), - gve_buffer ( rx, rx->cons ), len ); + gve_buffer ( rx, tag ), len ); } } assert ( ( iobuf == NULL ) || ( iob_len ( iobuf ) == total ) ); @@ -1628,6 +1655,8 @@ static int gve_probe ( struct pci_device *pci ) { gve->netdev = netdev; gve->tx.type = &gve_tx_type; gve->rx.type = &gve_rx_type; + gve->tx.tag = gve->tx_tag; + gve->rx.tag = gve->rx_tag; process_init_stopped ( &gve->startup, &gve_startup_desc, &netdev->refcnt ); timer_init ( &gve->watchdog, gve_watchdog, &netdev->refcnt ); diff --git a/src/drivers/net/gve.h b/src/drivers/net/gve.h index d3b7ca760..2ad713f90 100644 --- a/src/drivers/net/gve.h +++ b/src/drivers/net/gve.h @@ -666,6 +666,8 @@ struct gve_queue { uint32_t prod; /** Consumer counter */ uint32_t cons; + /** Tag ring */ + uint8_t *tag; /** Queue page list */ struct gve_qpl qpl; @@ -730,8 +732,12 @@ struct gve_nic { struct gve_queue tx; /** Receive queue */ struct gve_queue rx; - /** Transmit I/O buffers */ + /** Transmit I/O buffers (indexed by tag) */ struct io_buffer *tx_iobuf[GVE_TX_FILL]; + /** Transmit tag ring */ + uint8_t tx_tag[GVE_TX_FILL]; + /** Receive tag ring */ + uint8_t rx_tag[GVE_RX_FILL]; /** Receive sequence number */ unsigned int seq; -- cgit v1.2.3-55-g7522 From 20a489253c748c6d6e55b73d9961819dbfd7f663 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 29 Sep 2025 14:58:42 +0100 Subject: [gve] Rename GQI-specific data structures and constants Rename data structures and constants that are specific to the GQI operating mode, to allow for a cleaner separation from other operating modes. Signed-off-by: Michael Brown --- src/drivers/net/gve.c | 50 +++++++++++++++++++++++++------------------------- src/drivers/net/gve.h | 37 +++++++++++++++++++++++-------------- 2 files changed, 48 insertions(+), 39 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/gve.c b/src/drivers/net/gve.c index 0fb60ac90..a9a11a383 100644 --- a/src/drivers/net/gve.c +++ b/src/drivers/net/gve.c @@ -950,7 +950,7 @@ gve_next ( unsigned int seq ) { * that the sequence number changes whenever a new completion * is first written to a zero-initialised completion ring. */ - seq = ( ( seq + 1 ) & GVE_RX_SEQ_MASK ); + seq = ( ( seq + 1 ) & GVE_GQI_RX_SEQ_MASK ); return ( seq ? seq : 1 ); } @@ -1317,7 +1317,7 @@ static void gve_close ( struct net_device *netdev ) { static int gve_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) { struct gve_nic *gve = netdev->priv; struct gve_queue *tx = &gve->tx; - struct gve_tx_descriptor *desc; + struct gve_gqi_tx_descriptor *gqi; unsigned int count; unsigned int index; unsigned int tag; @@ -1356,20 +1356,20 @@ static int gve_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) { ( iobuf->data + offset ), frag_len ); /* Populate descriptor */ - desc = &tx->desc.tx[index]; + gqi = &tx->desc.tx.gqi[index]; if ( offset ) { - desc->type = GVE_TX_TYPE_CONT; - desc->count = 0; - desc->total = 0; + gqi->type = GVE_GQI_TX_TYPE_CONT; + gqi->count = 0; + gqi->total = 0; } else { - desc->type = GVE_TX_TYPE_START; - desc->count = count; - desc->total = cpu_to_be16 ( len ); + gqi->type = GVE_GQI_TX_TYPE_START; + gqi->count = count; + gqi->total = cpu_to_be16 ( len ); } - desc->len = cpu_to_be16 ( frag_len ); + gqi->len = cpu_to_be16 ( frag_len ); DBGC2 ( gve, "GVE %p TX %#04x %#02x:%#02x len %#04x/%#04x at " - "%#08zx\n", gve, index, desc->type, desc->count, - be16_to_cpu ( desc->len ), be16_to_cpu ( desc->total ), + "%#08zx\n", gve, index, gqi->type, gqi->count, + be16_to_cpu ( gqi->len ), be16_to_cpu ( gqi->total ), gve_offset ( tx, tag ) ); /* Move to next descriptor */ @@ -1425,7 +1425,7 @@ static void gve_poll_tx ( struct net_device *netdev ) { static void gve_poll_rx ( struct net_device *netdev ) { struct gve_nic *gve = netdev->priv; struct gve_queue *rx = &gve->rx; - struct gve_rx_completion *cmplt; + struct gve_gqi_rx_completion *gqi; struct io_buffer *iobuf; unsigned int index; unsigned int seq; @@ -1443,26 +1443,26 @@ static void gve_poll_rx ( struct net_device *netdev ) { /* Read next possible completion */ index = ( cons++ & ( rx->count - 1 ) ); - cmplt = &rx->cmplt.rx[index]; + gqi = &rx->cmplt.rx.gqi[index]; /* Check sequence number */ - if ( ( cmplt->seq & GVE_RX_SEQ_MASK ) != seq ) + if ( ( gqi->seq & GVE_GQI_RX_SEQ_MASK ) != seq ) break; seq = gve_next ( seq ); /* Parse completion */ - len = be16_to_cpu ( cmplt->len ); + len = be16_to_cpu ( gqi->len ); tag = ( index % GVE_RX_FILL ); DBGC2 ( gve, "GVE %p RX %#04x %#02x:%#02x len %#04zx at " - "%#08zx\n", gve, index, cmplt->seq, cmplt->flags, + "%#08zx\n", gve, index, gqi->seq, gqi->flags, len, gve_offset ( rx, tag ) ); /* Accumulate a complete packet */ - if ( cmplt->flags & GVE_RXF_ERROR ) { + if ( gqi->flags & GVE_GQI_RXF_ERROR ) { total = 0; } else { total += len; - if ( cmplt->flags & GVE_RXF_MORE ) + if ( gqi->flags & GVE_GQI_RXF_MORE ) continue; } gve->seq = seq; @@ -1473,12 +1473,12 @@ static void gve_poll_rx ( struct net_device *netdev ) { /* Re-read completion */ index = ( rx->cons & ( rx->count - 1 ) ); - cmplt = &rx->cmplt.rx[index]; + gqi = &rx->cmplt.rx.gqi[index]; tag = ( index % GVE_RX_FILL ); /* Copy data */ if ( iobuf ) { - len = be16_to_cpu ( cmplt->len ); + len = be16_to_cpu ( gqi->len ); memcpy ( iob_put ( iobuf, len ), gve_buffer ( rx, tag ), len ); } @@ -1491,7 +1491,7 @@ static void gve_poll_rx ( struct net_device *netdev ) { iob_pull ( iobuf, GVE_RX_PAD ); netdev_rx ( netdev, iobuf ); } else { - rc = ( ( cmplt->flags & GVE_RXF_ERROR ) ? + rc = ( ( gqi->flags & GVE_GQI_RXF_ERROR ) ? -EIO : -ENOMEM ); netdev_rx_err ( netdev, NULL, rc ); } @@ -1570,7 +1570,7 @@ static const struct gve_queue_type gve_tx_type = { .qpl = GVE_TX_QPL, .irq = GVE_TX_IRQ, .fill = GVE_TX_FILL, - .desc_len = sizeof ( struct gve_tx_descriptor ), + .desc_len = sizeof ( struct gve_gqi_tx_descriptor ), .create = GVE_ADMIN_CREATE_TX, .destroy = GVE_ADMIN_DESTROY_TX, }; @@ -1582,8 +1582,8 @@ static const struct gve_queue_type gve_rx_type = { .qpl = GVE_RX_QPL, .irq = GVE_RX_IRQ, .fill = GVE_RX_FILL, - .desc_len = sizeof ( struct gve_rx_descriptor ), - .cmplt_len = sizeof ( struct gve_rx_completion ), + .desc_len = sizeof ( struct gve_gqi_rx_descriptor ), + .cmplt_len = sizeof ( struct gve_gqi_rx_completion ), .create = GVE_ADMIN_CREATE_RX, .destroy = GVE_ADMIN_DESTROY_RX, }; diff --git a/src/drivers/net/gve.h b/src/drivers/net/gve.h index 2ad713f90..d091ff9f4 100644 --- a/src/drivers/net/gve.h +++ b/src/drivers/net/gve.h @@ -555,8 +555,8 @@ struct gve_buffer { uint64_t addr; } __attribute__ (( packed )); -/** A transmit descriptor */ -struct gve_tx_descriptor { +/** An in-order transmit descriptor */ +struct gve_gqi_tx_descriptor { /** Type */ uint8_t type; /** Reserved */ @@ -572,10 +572,10 @@ struct gve_tx_descriptor { } __attribute__ (( packed )); /** Start of packet transmit descriptor type */ -#define GVE_TX_TYPE_START 0x00 +#define GVE_GQI_TX_TYPE_START 0x00 /** Continuation of packet transmit descriptor type */ -#define GVE_TX_TYPE_CONT 0x20 +#define GVE_GQI_TX_TYPE_CONT 0x20 /** * Maximum number of receive buffers @@ -592,23 +592,23 @@ struct gve_tx_descriptor { /** Receive queue interrupt channel */ #define GVE_RX_IRQ 1 -/** A receive descriptor */ -struct gve_rx_descriptor { +/** An in-order receive descriptor */ +struct gve_gqi_rx_descriptor { /** Buffer descriptor */ struct gve_buffer buf; } __attribute__ (( packed )); /** Receive error */ -#define GVE_RXF_ERROR 0x08 +#define GVE_GQI_RXF_ERROR 0x08 /** Receive packet continues into next descriptor */ -#define GVE_RXF_MORE 0x20 +#define GVE_GQI_RXF_MORE 0x20 /** Receive sequence number mask */ -#define GVE_RX_SEQ_MASK 0x07 +#define GVE_GQI_RX_SEQ_MASK 0x07 -/** A receive completion descriptor */ -struct gve_rx_completion { +/** An in-order receive completion descriptor */ +struct gve_gqi_rx_completion { /** Reserved */ uint8_t reserved[60]; /** Length */ @@ -627,16 +627,25 @@ struct gve_queue { /** Descriptor ring */ union { /** Transmit descriptors */ - struct gve_tx_descriptor *tx; + union { + /** In-order transmit descriptors */ + struct gve_gqi_tx_descriptor *gqi; + } tx; /** Receive descriptors */ - struct gve_rx_descriptor *rx; + union { + /** In-order receive descriptors */ + struct gve_gqi_rx_descriptor *gqi; + } rx; /** Raw data */ void *raw; } desc; /** Completion ring */ union { /** Receive completions */ - struct gve_rx_completion *rx; + union { + /** In-order receive completions */ + struct gve_gqi_rx_completion *gqi; + } rx; /** Raw data */ void *raw; } cmplt; -- cgit v1.2.3-55-g7522 From 4508e10233c588b92498f158baa3efb36cce4caf Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 29 Sep 2025 15:00:11 +0100 Subject: [gve] Allow for descriptor and completion lengths to vary by mode The descriptors and completions in the DQO operating mode are not the same sizes as the equivalent structures in the GQI operating mode. Allow the queue stride size to vary by operating mode (and therefore to be known only after reading the device descriptor and selecting the operating mode). Signed-off-by: Michael Brown --- src/drivers/net/gve.c | 42 +++++++++++++++++++++++++++++------------- src/drivers/net/gve.h | 19 +++++++++++++++---- 2 files changed, 44 insertions(+), 17 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/gve.c b/src/drivers/net/gve.c index a9a11a383..cf796a8b5 100644 --- a/src/drivers/net/gve.c +++ b/src/drivers/net/gve.c @@ -746,6 +746,7 @@ static void gve_create_rx_param ( struct gve_queue *queue, uint32_t qpl, */ static int gve_create_queue ( struct gve_nic *gve, struct gve_queue *queue ) { const struct gve_queue_type *type = queue->type; + const struct gve_queue_stride *stride = &queue->stride; union gve_admin_command *cmd; struct gve_buffer *buf; unsigned int db_off; @@ -758,17 +759,17 @@ static int gve_create_queue ( struct gve_nic *gve, struct gve_queue *queue ) { /* Reset queue */ queue->prod = 0; queue->cons = 0; - memset ( queue->desc.raw, 0, ( queue->count * type->desc_len ) ); - memset ( queue->cmplt.raw, 0, ( queue->count * type->cmplt_len ) ); + memset ( queue->desc.raw, 0, ( queue->count * stride->desc ) ); + memset ( queue->cmplt.raw, 0, ( queue->count * stride->cmplt ) ); for ( i = 0 ; i < queue->fill ; i++ ) queue->tag[i] = i; /* Pre-populate descriptor offsets */ - buf = ( queue->desc.raw + type->desc_len - sizeof ( *buf ) ); + buf = ( queue->desc.raw + stride->desc - sizeof ( *buf ) ); for ( i = 0 ; i < queue->count ; i++ ) { tag = ( i & ( queue->fill - 1 ) ); buf->addr = cpu_to_be64 ( gve_address ( queue, tag ) ); - buf = ( ( ( void * ) buf ) + type->desc_len ); + buf = ( ( ( void * ) buf ) + stride->desc ); } /* Construct request */ @@ -963,10 +964,11 @@ gve_next ( unsigned int seq ) { */ static int gve_alloc_queue ( struct gve_nic *gve, struct gve_queue *queue ) { const struct gve_queue_type *type = queue->type; + struct gve_queue_stride *stride = &queue->stride; struct dma_device *dma = gve->dma; - size_t desc_len = ( queue->count * type->desc_len ); - size_t cmplt_len = ( queue->count * type->cmplt_len ); - size_t res_len = sizeof ( *queue->res ); + size_t desc_len; + size_t cmplt_len; + size_t res_len; int rc; /* Sanity checks */ @@ -978,6 +980,12 @@ static int gve_alloc_queue ( struct gve_nic *gve, struct gve_queue *queue ) { goto err_sanity; } + /* Set queue strides and calculate total lengths */ + *stride = type->stride.gqi; + desc_len = ( queue->count * stride->desc ); + cmplt_len = ( queue->count * stride->cmplt ); + res_len = sizeof ( *queue->res ); + /* Calculate maximum fill level */ assert ( ( type->fill & ( type->fill - 1 ) ) == 0 ); queue->fill = type->fill; @@ -1045,9 +1053,9 @@ static int gve_alloc_queue ( struct gve_nic *gve, struct gve_queue *queue ) { * @v queue Descriptor queue */ static void gve_free_queue ( struct gve_nic *gve, struct gve_queue *queue ) { - const struct gve_queue_type *type = queue->type; - size_t desc_len = ( queue->count * type->desc_len ); - size_t cmplt_len = ( queue->count * type->cmplt_len ); + const struct gve_queue_stride *stride = &queue->stride; + size_t desc_len = ( queue->count * stride->desc ); + size_t cmplt_len = ( queue->count * stride->cmplt ); size_t res_len = sizeof ( *queue->res ); /* Free queue resources */ @@ -1570,7 +1578,11 @@ static const struct gve_queue_type gve_tx_type = { .qpl = GVE_TX_QPL, .irq = GVE_TX_IRQ, .fill = GVE_TX_FILL, - .desc_len = sizeof ( struct gve_gqi_tx_descriptor ), + .stride = { + .gqi = { + .desc = sizeof ( struct gve_gqi_tx_descriptor ), + }, + }, .create = GVE_ADMIN_CREATE_TX, .destroy = GVE_ADMIN_DESTROY_TX, }; @@ -1582,8 +1594,12 @@ static const struct gve_queue_type gve_rx_type = { .qpl = GVE_RX_QPL, .irq = GVE_RX_IRQ, .fill = GVE_RX_FILL, - .desc_len = sizeof ( struct gve_gqi_rx_descriptor ), - .cmplt_len = sizeof ( struct gve_gqi_rx_completion ), + .stride = { + .gqi = { + .desc = sizeof ( struct gve_gqi_rx_descriptor ), + .cmplt = sizeof ( struct gve_gqi_rx_completion ), + }, + }, .create = GVE_ADMIN_CREATE_RX, .destroy = GVE_ADMIN_DESTROY_RX, }; diff --git a/src/drivers/net/gve.h b/src/drivers/net/gve.h index d091ff9f4..c15cb808f 100644 --- a/src/drivers/net/gve.h +++ b/src/drivers/net/gve.h @@ -622,6 +622,14 @@ struct gve_gqi_rx_completion { /** Padding at the start of all received packets */ #define GVE_RX_PAD 2 +/** Queue strides */ +struct gve_queue_stride { + /** Descriptor ring stride */ + uint8_t desc; + /** Completion ring stride */ + uint8_t cmplt; +}; + /** A descriptor queue */ struct gve_queue { /** Descriptor ring */ @@ -654,6 +662,8 @@ struct gve_queue { /** Queue type */ const struct gve_queue_type *type; + /** Queue strides */ + struct gve_queue_stride stride; /** Number of descriptors (must be a power of two) */ unsigned int count; /** Maximum fill level (must be a power of two) */ @@ -701,10 +711,11 @@ struct gve_queue_type { uint8_t irq; /** Maximum fill level */ uint8_t fill; - /** Descriptor size */ - uint8_t desc_len; - /** Completion size */ - uint8_t cmplt_len; + /** Queue strides */ + struct { + /** In-order queue strides */ + struct gve_queue_stride gqi; + } stride; /** Command to create queue */ uint8_t create; /** Command to destroy queue */ -- cgit v1.2.3-55-g7522 From cf534975411051ea0ddcbea28347d8d643a36360 Mon Sep 17 00:00:00 2001 From: Joseph Wong Date: Thu, 18 Sep 2025 12:27:43 -0700 Subject: [bnxt] Handle link related async events Handle async events related to link speed change, link speed config change, and port phy config changes. Signed-off-by: Joseph Wong --- src/drivers/net/bnxt/bnxt.c | 84 ++++++++++++++++++++++++++++++++++++++--- src/drivers/net/bnxt/bnxt_dbg.h | 1 + src/drivers/net/bnxt/bnxt_hsi.h | 50 ++++++++++++------------ 3 files changed, 105 insertions(+), 30 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/bnxt/bnxt.c b/src/drivers/net/bnxt/bnxt.c index bac601ab6..703f6e384 100644 --- a/src/drivers/net/bnxt/bnxt.c +++ b/src/drivers/net/bnxt/bnxt.c @@ -1114,13 +1114,18 @@ static int bnxt_hwrm_func_drv_rgtr ( struct bnxt *bp ) FUNC_DRV_RGTR_REQ_ENABLES_VER; req->flags = FUNC_DRV_RGTR_REQ_FLAGS_16BIT_VER_MODE; + req->async_event_fwd[0] |= 1 << ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE; + req->async_event_fwd[0] |= 1 << ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CHANGE; + req->async_event_fwd[0] |= 1 << ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE; + req->async_event_fwd[0] |= 1 << ASYNC_EVENT_CMPL_EVENT_ID_PORT_PHY_CFG_CHANGE; + if ( bp->err_rcvry_supported ) { req->flags |= FUNC_DRV_RGTR_REQ_FLAGS_ERROR_RECOVERY_SUPPORT; req->flags |= FUNC_DRV_RGTR_REQ_FLAGS_MASTER_SUPPORT; - req->async_event_fwd[0] |= 0x301; - } else { - req->async_event_fwd[0] |= 0x01; + req->async_event_fwd[0] |= 1 << ASYNC_EVENT_CMPL_EVENT_ID_RESET_NOTIFY; + req->async_event_fwd[0] |= 1 << ASYNC_EVENT_CMPL_EVENT_ID_ERROR_RECOVERY; } + req->os_type = FUNC_DRV_RGTR_REQ_OS_TYPE_OTHER; req->ver_maj = IPXE_VERSION_MAJOR; req->ver_min = IPXE_VERSION_MINOR; @@ -2538,6 +2543,51 @@ void bnxt_process_reset_notify_event ( struct bnxt *bp, } } +void bnxt_link_speed_evt ( struct bnxt *bp, struct hwrm_async_event_cmpl *evt ) +{ + if ( evt->event_data1 & ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_FORCE ) { + DBGP ("bnxt_link_speed_evt: event data = %lx\n", + ( evt->event_data1 & ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_MASK )); + } + + if ( bnxt_hwrm_port_phy_qcfg ( bp, QCFG_PHY_ALL ) != STATUS_SUCCESS ) { + return; + } + + bnxt_set_link ( bp ); + dbg_link_info ( bp ); + dbg_link_status ( bp ); +} + +void bnxt_link_speed_chg_evt ( struct bnxt *bp, struct hwrm_async_event_cmpl *evt ) +{ + if ( ( evt->event_data1 & ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_SUPPORTED_LINK_SPEEDS_CHANGE ) || + ( evt->event_data1 & ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_ILLEGAL_LINK_SPEED_CFG ) ) { + if ( bnxt_hwrm_port_phy_qcfg ( bp, QCFG_PHY_ALL ) != STATUS_SUCCESS ) { + return; + } + } + + bnxt_set_link ( bp ); + dbg_link_info ( bp ); + dbg_link_status ( bp ); +} + +void bnxt_port_phy_chg_evt ( struct bnxt *bp, struct hwrm_async_event_cmpl *evt ) +{ + if ( ( evt->event_data1 & ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_FEC_CFG_CHANGE ) || + ( evt->event_data1 & ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_EEE_CFG_CHANGE ) || + ( evt->event_data1 & ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_PAUSE_CFG_CHANGE)) { + if ( bnxt_hwrm_port_phy_qcfg ( bp, QCFG_PHY_ALL ) != STATUS_SUCCESS ) { + return; + } + } + + bnxt_set_link ( bp ); + dbg_link_info ( bp ); + dbg_link_status ( bp ); +} + static void bnxt_service_cq ( struct net_device *dev ) { struct bnxt *bp = dev->priv; @@ -2574,12 +2624,24 @@ static void bnxt_service_cq ( struct net_device *dev ) ( struct rx_pkt_cmpl * )cmp ); break; case CMPL_BASE_TYPE_HWRM_ASYNC_EVENT: - evt = (struct hwrm_async_event_cmpl * )cmp; + evt = ( struct hwrm_async_event_cmpl * )cmp; switch ( evt->event_id ) { case ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE: bnxt_link_evt ( bp, ( struct hwrm_async_event_cmpl * )cmp ); break; + case ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CHANGE: + bnxt_link_speed_evt ( bp, + ( struct hwrm_async_event_cmpl * )cmp ); + break; + case ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE: + bnxt_link_speed_chg_evt ( bp, + ( struct hwrm_async_event_cmpl * )cmp ); + break; + case ASYNC_EVENT_CMPL_EVENT_ID_PORT_PHY_CFG_CHANGE: + bnxt_port_phy_chg_evt ( bp, + ( struct hwrm_async_event_cmpl * )cmp ); + break; case ASYNC_EVENT_CMPL_EVENT_ID_ERROR_RECOVERY: bnxt_process_er_event ( bp, ( struct hwrm_async_event_cmpl * )cmp ); @@ -2628,12 +2690,24 @@ static void bnxt_service_nq ( struct net_device *dev ) switch ( nq_type ) { case CMPL_BASE_TYPE_HWRM_ASYNC_EVENT: - evt = (struct hwrm_async_event_cmpl * )nqp; + evt = ( struct hwrm_async_event_cmpl * )nqp; switch ( evt->event_id ) { case ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE: bnxt_link_evt ( bp, ( struct hwrm_async_event_cmpl * )nqp ); break; + case ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CHANGE: + bnxt_link_speed_evt ( bp, + ( struct hwrm_async_event_cmpl * )nqp ); + break; + case ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE: + bnxt_link_speed_chg_evt ( bp, + ( struct hwrm_async_event_cmpl * )nqp ); + break; + case ASYNC_EVENT_CMPL_EVENT_ID_PORT_PHY_CFG_CHANGE: + bnxt_port_phy_chg_evt ( bp, + ( struct hwrm_async_event_cmpl * )nqp ); + break; case ASYNC_EVENT_CMPL_EVENT_ID_ERROR_RECOVERY: bnxt_process_er_event ( bp, ( struct hwrm_async_event_cmpl * )nqp ); diff --git a/src/drivers/net/bnxt/bnxt_dbg.h b/src/drivers/net/bnxt/bnxt_dbg.h index d6e66ceef..2cda84488 100644 --- a/src/drivers/net/bnxt/bnxt_dbg.h +++ b/src/drivers/net/bnxt/bnxt_dbg.h @@ -659,5 +659,6 @@ void dbg_link_state(struct bnxt *bp, u32 tmo) #else #define dump_evt(cq, ty, id, ring) #define dbg_link_status(bp) +#define dbg_link_info(bp) #define dbg_link_state(bp, tmo) #endif diff --git a/src/drivers/net/bnxt/bnxt_hsi.h b/src/drivers/net/bnxt/bnxt_hsi.h index e1ed7c1f2..77706504c 100644 --- a/src/drivers/net/bnxt/bnxt_hsi.h +++ b/src/drivers/net/bnxt/bnxt_hsi.h @@ -661,22 +661,22 @@ struct hwrm_async_event_cmpl_link_speed_change { u8 timestamp_lo; __le16 timestamp_hi; __le32 event_data1; - #define ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_FORCE 0x1UL - #define ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_MASK 0xfffeUL - #define ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_SFT 1 - #define ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_100MB (0x1UL << 1) - #define ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_1GB (0xaUL << 1) - #define ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_2GB (0x14UL << 1) - #define ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_2_5GB (0x19UL << 1) - #define ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_10GB (0x64UL << 1) - #define ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_20GB (0xc8UL << 1) - #define ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_25GB (0xfaUL << 1) - #define ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_40GB (0x190UL << 1) - #define ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_50GB (0x1f4UL << 1) - #define ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_100GB (0x3e8UL << 1) - #define ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_LAST ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_100GB - #define ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_PORT_ID_MASK 0xffff0000UL - #define ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_PORT_ID_SFT 16 + #define ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_FORCE 0x1UL + #define ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_MASK 0xfffeUL + #define ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_NEW_LINK_SPEED_100MBPS_SFT 1 + #define ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_NEW_LINK_SPEED_100MBPS_100MB (0x1UL << 1) + #define ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_NEW_LINK_SPEED_100MBPS_1GB (0xaUL << 1) + #define ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_NEW_LINK_SPEED_100MBPS_2GB (0x14UL << 1) + #define ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_NEW_LINK_SPEED_100MBPS_2_5GB (0x19UL << 1) + #define ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_NEW_LINK_SPEED_100MBPS_10GB (0x64UL << 1) + #define ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_NEW_LINK_SPEED_100MBPS_20GB (0xc8UL << 1) + #define ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_NEW_LINK_SPEED_100MBPS_25GB (0xfaUL << 1) + #define ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_NEW_LINK_SPEED_100MBPS_40GB (0x190UL << 1) + #define ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_NEW_LINK_SPEED_100MBPS_50GB (0x1f4UL << 1) + #define ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_NEW_LINK_SPEED_100MBPS_100GB (0x3e8UL << 1) + #define ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_NEW_LINK_SPEED_100MBPS_LAST ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_NEW_LINK_SPEED_100MBPS_100GB + #define ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_PORT_ID_MASK 0xffff0000UL + #define ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_PORT_ID_SFT 16 }; /* hwrm_async_event_cmpl_dcb_config_change (size:128b/16B) */ @@ -781,10 +781,10 @@ struct hwrm_async_event_cmpl_link_speed_cfg_change { u8 timestamp_lo; __le16 timestamp_hi; __le32 event_data1; - #define ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_EVENT_DATA1_PORT_ID_MASK 0xffffUL - #define ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_EVENT_DATA1_PORT_ID_SFT 0 - #define ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_EVENT_DATA1_SUPPORTED_LINK_SPEEDS_CHANGE 0x10000UL - #define ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_EVENT_DATA1_ILLEGAL_LINK_SPEED_CFG 0x20000UL + #define ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_PORT_ID_MASK 0xffffUL + #define ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_PORT_ID_SFT 0 + #define ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_SUPPORTED_LINK_SPEEDS_CHANGE 0x10000UL + #define ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_ILLEGAL_LINK_SPEED_CFG 0x20000UL }; /* hwrm_async_event_cmpl_port_phy_cfg_change (size:128b/16B) */ @@ -805,11 +805,11 @@ struct hwrm_async_event_cmpl_port_phy_cfg_change { u8 timestamp_lo; __le16 timestamp_hi; __le32 event_data1; - #define ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_EVENT_DATA1_PORT_ID_MASK 0xffffUL - #define ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_EVENT_DATA1_PORT_ID_SFT 0 - #define ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_EVENT_DATA1_FEC_CFG_CHANGE 0x10000UL - #define ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_EVENT_DATA1_EEE_CFG_CHANGE 0x20000UL - #define ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_EVENT_DATA1_PAUSE_CFG_CHANGE 0x40000UL + #define ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_PORT_ID_MASK 0xffffUL + #define ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_PORT_ID_SFT 0 + #define ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_FEC_CFG_CHANGE 0x10000UL + #define ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_EEE_CFG_CHANGE 0x20000UL + #define ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_PAUSE_CFG_CHANGE 0x40000UL }; /* hwrm_async_event_cmpl_reset_notify (size:128b/16B) */ -- cgit v1.2.3-55-g7522 From 0d1ddfe42c55a691340f2d8979b5f0a031dfcf62 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 6 Oct 2025 13:06:06 +0100 Subject: [gve] Cancel pending transmissions when closing device We cancel any pending transmissions when (re)starting the device since any transmissions that were initiated before the admin queue reset will not complete. The network device core will also cancel any pending transmissions after the device is closed. If the device is closed with some transmissions still pending and is then reopened, this will therefore result in a stale I/O buffer being passed to netdev_tx_complete_err() when the device is restarted. This error has not been observed in practice since transmissions generally complete almost immediately and it is therefore unlikely that the device will ever be closed with transmissions still pending. With out-of-order queues, the device seems to delay transmit completions (with no upper time limit) until a complete batch is available to be written out as a block of 128 bytes. It is therefore very likely that the device will be closed with transmissions still pending. Fix by ensuring that we have dropped all references to transmit I/O buffers before returning from gve_close(). Signed-off-by: Michael Brown --- src/drivers/net/gve.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/gve.c b/src/drivers/net/gve.c index cf796a8b5..fa8a15407 100644 --- a/src/drivers/net/gve.c +++ b/src/drivers/net/gve.c @@ -1073,18 +1073,14 @@ static void gve_free_queue ( struct gve_nic *gve, struct gve_queue *queue ) { } /** - * Start up device + * Cancel any pending transmissions * * @v gve GVE device - * @ret rc Return status code */ -static int gve_start ( struct gve_nic *gve ) { +static void gve_cancel_tx ( struct gve_nic *gve ) { struct net_device *netdev = gve->netdev; - struct gve_queue *tx = &gve->tx; - struct gve_queue *rx = &gve->rx; struct io_buffer *iobuf; unsigned int i; - int rc; /* Cancel any pending transmissions */ for ( i = 0 ; i < ( sizeof ( gve->tx_iobuf ) / @@ -1094,6 +1090,21 @@ static int gve_start ( struct gve_nic *gve ) { if ( iobuf ) netdev_tx_complete_err ( netdev, iobuf, -ECANCELED ); } +} + +/** + * Start up device + * + * @v gve GVE device + * @ret rc Return status code + */ +static int gve_start ( struct gve_nic *gve ) { + struct gve_queue *tx = &gve->tx; + struct gve_queue *rx = &gve->rx; + int rc; + + /* Cancel any pending transmissions */ + gve_cancel_tx ( gve ); /* Reset receive sequence */ gve->seq = gve_next ( 0 ); @@ -1307,6 +1318,9 @@ static void gve_close ( struct net_device *netdev ) { gve_stop ( gve ); gve_reset ( gve ); + /* Cancel any pending transmissions */ + gve_cancel_tx ( gve ); + /* Free queues */ gve_free_queue ( gve, rx ); gve_free_queue ( gve, tx ); -- cgit v1.2.3-55-g7522 From 74c9fd72cf3cc7b23ea3e197b1248a701beaeb02 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 6 Oct 2025 14:04:11 +0100 Subject: [gve] Add support for out-of-order queues Add support for the "DQO" out-of-order transmit and receive queue formats. These are almost entirely different in format and usage (and even endianness) from the original "GQI" in-order transmit and receive queues, and arguably should belong to a completely different device with a different PCI ID. However, Google chose to essentially crowbar two unrelated device models into the same virtual hardware, and so we must handle both of these device models within the same driver. Most of the new code exists solely to handle the differences in descriptor sizes and formats. Out-of-order completions are handled via a buffer ID ring (as with other devices supporting out-of-order completions, such as the Xen, Hyper-V, and Amazon virtual NICs). A slight twist is that on the transmit datapath (but not the receive datapath) the Google NIC provides only one completion per packet instead of one completion per descriptor, and so we must record the list of chained buffer IDs in a separate array at the time of transmission. Signed-off-by: Michael Brown --- src/drivers/net/gve.c | 363 +++++++++++++++++++++++++++++++++++++------------- src/drivers/net/gve.h | 130 +++++++++++++++++- 2 files changed, 398 insertions(+), 95 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/gve.c b/src/drivers/net/gve.c index fa8a15407..8759d71a9 100644 --- a/src/drivers/net/gve.c +++ b/src/drivers/net/gve.c @@ -759,17 +759,20 @@ static int gve_create_queue ( struct gve_nic *gve, struct gve_queue *queue ) { /* Reset queue */ queue->prod = 0; queue->cons = 0; + queue->done = 0; memset ( queue->desc.raw, 0, ( queue->count * stride->desc ) ); memset ( queue->cmplt.raw, 0, ( queue->count * stride->cmplt ) ); for ( i = 0 ; i < queue->fill ; i++ ) queue->tag[i] = i; - /* Pre-populate descriptor offsets */ - buf = ( queue->desc.raw + stride->desc - sizeof ( *buf ) ); - for ( i = 0 ; i < queue->count ; i++ ) { - tag = ( i & ( queue->fill - 1 ) ); - buf->addr = cpu_to_be64 ( gve_address ( queue, tag ) ); - buf = ( ( ( void * ) buf ) + stride->desc ); + /* Pre-populate descriptor offsets for in-order queues */ + if ( ! ( gve->mode & GVE_MODE_DQO ) ) { + buf = ( queue->desc.raw + stride->desc - sizeof ( *buf ) ); + for ( i = 0 ; i < queue->count ; i++ ) { + tag = ( i & ( queue->fill - 1 ) ); + buf->addr = cpu_to_be64 ( gve_address ( queue, tag ) ); + buf = ( ( ( void * ) buf ) + stride->desc ); + } } /* Construct request */ @@ -981,7 +984,8 @@ static int gve_alloc_queue ( struct gve_nic *gve, struct gve_queue *queue ) { } /* Set queue strides and calculate total lengths */ - *stride = type->stride.gqi; + *stride = ( ( gve->mode & GVE_MODE_DQO ) ? + type->stride.dqo : type->stride.gqi ); desc_len = ( queue->count * stride->desc ); cmplt_len = ( queue->count * stride->cmplt ); res_len = sizeof ( *queue->res ); @@ -1340,11 +1344,15 @@ static int gve_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) { struct gve_nic *gve = netdev->priv; struct gve_queue *tx = &gve->tx; struct gve_gqi_tx_descriptor *gqi; + struct gve_dqo_tx_descriptor *dqo; unsigned int count; unsigned int index; unsigned int tag; + unsigned int chain; + uint32_t doorbell; size_t frag_len; size_t offset; + size_t next; size_t len; /* Do nothing if queues are not yet set up */ @@ -1360,8 +1368,7 @@ static int gve_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) { } /* Copy packet to queue pages and populate descriptors */ - offset = 0; - while ( 1 ) { + for ( offset = 0, chain = 0 ; ; offset = next, chain = tag ) { /* Identify next available buffer */ index = ( tx->prod++ & ( tx->count - 1 ) ); @@ -1376,38 +1383,66 @@ static int gve_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) { frag_len = GVE_BUF_SIZE; memcpy ( gve_buffer ( tx, tag ), ( iobuf->data + offset ), frag_len ); + next = ( offset + frag_len ); /* Populate descriptor */ - gqi = &tx->desc.tx.gqi[index]; - if ( offset ) { - gqi->type = GVE_GQI_TX_TYPE_CONT; - gqi->count = 0; - gqi->total = 0; + if ( gve->mode & GVE_MODE_DQO ) { + + /* Out-of-order descriptor */ + dqo = &tx->desc.tx.dqo[index]; + dqo->buf.addr = + cpu_to_le64 ( gve_address ( tx, tag ) ); + if ( next == len ) { + dqo->type = ( GVE_DQO_TX_TYPE_PACKET | + GVE_DQO_TX_TYPE_LAST | + GVE_DQO_TX_TYPE_REPORT ); + dqo->tag.id = tag; + dqo->tag.count = count; + } else { + dqo->type = GVE_DQO_TX_TYPE_PACKET; + dqo->tag.id = 0; + dqo->tag.count = 0; + } + dqo->len = cpu_to_le16 ( frag_len ); + gve->tx_chain[tag] = chain; + } else { - gqi->type = GVE_GQI_TX_TYPE_START; - gqi->count = count; - gqi->total = cpu_to_be16 ( len ); + + /* In-order descriptor */ + gqi = &tx->desc.tx.gqi[index]; + if ( offset ) { + gqi->type = GVE_GQI_TX_TYPE_CONT; + gqi->count = 0; + gqi->total = 0; + } else { + gqi->type = GVE_GQI_TX_TYPE_START; + gqi->count = count; + gqi->total = cpu_to_be16 ( len ); + } + gqi->len = cpu_to_be16 ( frag_len ); + } - gqi->len = cpu_to_be16 ( frag_len ); - DBGC2 ( gve, "GVE %p TX %#04x %#02x:%#02x len %#04x/%#04x at " - "%#08zx\n", gve, index, gqi->type, gqi->count, - be16_to_cpu ( gqi->len ), be16_to_cpu ( gqi->total ), - gve_offset ( tx, tag ) ); - - /* Move to next descriptor */ - offset += frag_len; - if ( offset < len ) - continue; + DBGC2 ( gve, "GVE %p TXD %#04x %#02x:%#02x len %#04zx/%#04zx " + "at %#08lx\n", gve, index, tag, count, frag_len, len, + gve_address ( tx, tag ) ); /* Record I/O buffer against final descriptor */ - gve->tx_iobuf[tag] = iobuf; - break; + if ( next == len ) { + gve->tx_iobuf[tag] = iobuf; + break; + } } assert ( ( tx->prod - tx->cons ) <= tx->fill ); /* Ring doorbell */ + doorbell = tx->prod; + if ( gve->mode & GVE_MODE_DQO ) { + doorbell &= ( tx->count - 1 ); + } else { + doorbell = bswap_32 ( doorbell ); + } wmb(); - writel ( bswap_32 ( tx->prod ), tx->db ); + writel ( doorbell, tx->db ); return 0; } @@ -1420,22 +1455,76 @@ static int gve_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) { static void gve_poll_tx ( struct net_device *netdev ) { struct gve_nic *gve = netdev->priv; struct gve_queue *tx = &gve->tx; + struct gve_dqo_tx_completion *dqo; struct io_buffer *iobuf; + unsigned int index; + unsigned int gen; + unsigned int bit; unsigned int tag; uint32_t count; - /* Read event counter */ - count = be32_to_cpu ( tx->event->count ); - /* Process transmit completions */ - while ( count != tx->cons ) { - DBGC2 ( gve, "GVE %p TX %#04x complete\n", gve, tx->cons ); - tag = ( tx->cons % GVE_TX_FILL ); - iobuf = gve->tx_iobuf[tag]; - gve->tx_iobuf[tag] = NULL; - tx->cons++; - if ( iobuf ) - netdev_tx_complete ( netdev, iobuf ); + if ( gve->mode & GVE_MODE_DQO ) { + + /* Out-of-order completions */ + while ( 1 ) { + + /* Read next possible completion */ + gen = ( tx->done & tx->count ); + index = ( tx->done & ( tx->count - 1 ) ); + dqo = &tx->cmplt.tx.dqo[index]; + + /* Check generation bit */ + bit = ( dqo->flags & GVE_DQO_TXF_GEN ); + if ( ( !! bit ) == ( !! gen ) ) + break; + tx->done++; + + /* Ignore non-packet completions */ + if ( ( ! ( dqo->flags & GVE_DQO_TXF_PKT ) ) || + ( dqo->tag.count < 0 ) ) { + DBGC2 ( gve, "GVE %p TXC %#04x flags %#02x " + "ignored\n", gve, index, dqo->flags ); + continue; + } + + /* Parse completion */ + tag = dqo->tag.id; + count = dqo->tag.count; + iobuf = gve->tx_iobuf[tag]; + gve->tx_iobuf[tag] = NULL; + assert ( iobuf != NULL ); + + /* Return completed descriptors to ring */ + while ( count-- ) { + DBGC2 ( gve, "GVE %p TXC %#04x %#02x:%#02x " + "complete\n", gve, index, tag, + dqo->tag.count ); + tx->tag[ tx->cons++ % GVE_TX_FILL ] = tag; + tag = gve->tx_chain[tag]; + } + + /* Hand off to network stack */ + if ( iobuf ) + netdev_tx_complete ( netdev, iobuf ); + } + + } else { + + /* Read event counter */ + count = be32_to_cpu ( tx->event->count ); + + /* Process transmit completions */ + while ( count != tx->cons ) { + DBGC2 ( gve, "GVE %p TXC %#04x complete\n", + gve, tx->cons ); + tag = ( tx->cons % GVE_TX_FILL ); + iobuf = gve->tx_iobuf[tag]; + gve->tx_iobuf[tag] = NULL; + tx->cons++; + if ( iobuf ) + netdev_tx_complete ( netdev, iobuf ); + } } } @@ -1448,59 +1537,107 @@ static void gve_poll_rx ( struct net_device *netdev ) { struct gve_nic *gve = netdev->priv; struct gve_queue *rx = &gve->rx; struct gve_gqi_rx_completion *gqi; + struct gve_dqo_rx_completion *dqo; struct io_buffer *iobuf; unsigned int index; + unsigned int gen; + unsigned int bit; unsigned int seq; unsigned int tag; - uint32_t cons; + uint32_t done; size_t total; size_t len; int rc; /* Process receive completions */ - cons = rx->cons; + done = rx->done; seq = gve->seq; total = 0; while ( 1 ) { /* Read next possible completion */ - index = ( cons++ & ( rx->count - 1 ) ); - gqi = &rx->cmplt.rx.gqi[index]; + rc = 0; + gen = ( done & rx->count ); + index = ( done++ & ( rx->count - 1 ) ); + if ( gve->mode & GVE_MODE_DQO ) { + + /* Out-of-order completion */ + dqo = &rx->cmplt.rx.dqo[index]; + + /* Check generation bit */ + bit = ( dqo->len & cpu_to_le16 ( GVE_DQO_RXL_GEN ) ); + if ( ( !! bit ) == ( !! gen ) ) + break; + + /* Parse completion */ + len = ( le16_to_cpu ( dqo->len ) & + ( GVE_BUF_SIZE - 1 ) ); + tag = dqo->tag; + DBGC2 ( gve, "GVE %p RXC %#04x %#02x:%#02x len %#04zx " + "at %#08zx\n", gve, index, tag, dqo->flags, + len, gve_offset ( rx, tag ) ); + + /* Accumulate a complete packet */ + if ( dqo->status & GVE_DQO_RXS_ERROR ) { + rc = -EIO; + total = 0; + } else { + total += len; + if ( ! ( dqo->flags & GVE_DQO_RXF_LAST ) ) + continue; + } - /* Check sequence number */ - if ( ( gqi->seq & GVE_GQI_RX_SEQ_MASK ) != seq ) - break; - seq = gve_next ( seq ); - - /* Parse completion */ - len = be16_to_cpu ( gqi->len ); - tag = ( index % GVE_RX_FILL ); - DBGC2 ( gve, "GVE %p RX %#04x %#02x:%#02x len %#04zx at " - "%#08zx\n", gve, index, gqi->seq, gqi->flags, - len, gve_offset ( rx, tag ) ); - - /* Accumulate a complete packet */ - if ( gqi->flags & GVE_GQI_RXF_ERROR ) { - total = 0; } else { - total += len; - if ( gqi->flags & GVE_GQI_RXF_MORE ) - continue; + + /* In-order completion */ + gqi = &rx->cmplt.rx.gqi[index]; + + /* Check sequence number */ + if ( ( gqi->seq & GVE_GQI_RX_SEQ_MASK ) != seq ) + break; + seq = gve_next ( seq ); + + /* Parse completion */ + len = be16_to_cpu ( gqi->len ); + tag = ( index % GVE_RX_FILL ); + DBGC2 ( gve, "GVE %p RXC %#04x %#02x:%#02x len %#04zx " + "at %#08zx\n", gve, index, gqi->seq, + gqi->flags, len, gve_offset ( rx, tag ) ); + + /* Accumulate a complete packet */ + if ( gqi->flags & GVE_GQI_RXF_ERROR ) { + rc = -EIO; + total = 0; + } else { + total += len; + if ( gqi->flags & GVE_GQI_RXF_MORE ) + continue; + } + gve->seq = seq; } - gve->seq = seq; /* Allocate and populate I/O buffer */ iobuf = ( total ? alloc_iob ( total ) : NULL ); - for ( ; rx->cons != cons ; rx->cons++ ) { - - /* Re-read completion */ - index = ( rx->cons & ( rx->count - 1 ) ); - gqi = &rx->cmplt.rx.gqi[index]; - tag = ( index % GVE_RX_FILL ); + for ( ; rx->done != done ; rx->done++ ) { + + /* Re-read completion and return tag to ring */ + index = ( rx->done & ( rx->count - 1 ) ); + if ( gve->mode & GVE_MODE_DQO ) { + dqo = &rx->cmplt.rx.dqo[index]; + tag = dqo->tag; + len = ( le16_to_cpu ( dqo->len ) & + ( GVE_BUF_SIZE - 1 ) ); + rx->tag[ rx->cons++ % GVE_RX_FILL ] = tag; + } else { + gqi = &rx->cmplt.rx.gqi[index]; + tag = ( index % GVE_RX_FILL ); + len = be16_to_cpu ( gqi->len ); + assert ( rx->cons == rx->done ); + rx->cons++; + } /* Copy data */ if ( iobuf ) { - len = be16_to_cpu ( gqi->len ); memcpy ( iob_put ( iobuf, len ), gve_buffer ( rx, tag ), len ); } @@ -1510,18 +1647,12 @@ static void gve_poll_rx ( struct net_device *netdev ) { /* Hand off packet to network stack */ if ( iobuf ) { - iob_pull ( iobuf, GVE_RX_PAD ); + if ( ! ( gve->mode & GVE_MODE_DQO ) ) + iob_pull ( iobuf, GVE_GQI_RX_PAD ); netdev_rx ( netdev, iobuf ); } else { - rc = ( ( gqi->flags & GVE_GQI_RXF_ERROR ) ? - -EIO : -ENOMEM ); - netdev_rx_err ( netdev, NULL, rc ); + netdev_rx_err ( netdev, NULL, ( rc ? rc : -ENOMEM ) ); } - - /* Sanity check */ - assert ( rx->cons == cons ); - assert ( gve->seq == seq ); - assert ( total == 0 ); } } @@ -1533,20 +1664,60 @@ static void gve_poll_rx ( struct net_device *netdev ) { static void gve_refill_rx ( struct net_device *netdev ) { struct gve_nic *gve = netdev->priv; struct gve_queue *rx = &gve->rx; - unsigned int prod; + struct gve_dqo_rx_descriptor *dqo; + unsigned int refill; + unsigned int index; + unsigned int tag; + uint32_t doorbell; - /* The receive descriptors are prepopulated at the time of - * creating the receive queue (pointing to the preallocated - * queue pages). Refilling is therefore just a case of - * ringing the doorbell if the device is not yet aware of any - * available descriptors. - */ - prod = ( rx->cons + rx->fill ); - if ( prod != rx->prod ) { - rx->prod = prod; - writel ( bswap_32 ( prod ), rx->db ); - DBGC2 ( gve, "GVE %p RX %#04x ready\n", gve, rx->prod ); + /* Calculate refill quantity */ + doorbell = ( rx->cons + rx->fill ); + refill = ( doorbell - rx->prod ); + if ( ! refill ) + return; + + /* Refill ring */ + if ( gve->mode & GVE_MODE_DQO ) { + + /* Out-of-order descriptors */ + while ( refill-- ) { + + /* Identify next available buffer */ + index = ( rx->prod++ & ( rx->count - 1 ) ); + tag = rx->tag[ index % GVE_RX_FILL ]; + + /* Populate descriptor */ + dqo = &rx->desc.rx.dqo[index]; + dqo->tag = tag; + dqo->buf.addr = + cpu_to_le64 ( gve_address ( rx, tag ) ); + DBGC2 ( gve, "GVE %p RXD %#04x:%#02x at %#08llx\n", + gve, index, dqo->tag, + ( ( unsigned long long ) + le64_to_cpu ( dqo->buf.addr ) ) ); + } + wmb(); + assert ( rx->prod == doorbell ); + + } else { + + /* The in-order receive descriptors are prepopulated + * at the time of creating the receive queue (pointing + * to the preallocated queue pages). Refilling is + * therefore just a case of ringing the doorbell if + * the device is not yet aware of any available + * descriptors. + */ + rx->prod += refill; + assert ( rx->prod == doorbell ); + DBGC2 ( gve, "GVE %p RXD %#04x ready\n", gve, rx->prod ); + + /* Doorbell is big-endian */ + doorbell = bswap_32 ( doorbell ); } + + /* Ring doorbell */ + writel ( doorbell, rx->db ); } /** @@ -1596,6 +1767,10 @@ static const struct gve_queue_type gve_tx_type = { .gqi = { .desc = sizeof ( struct gve_gqi_tx_descriptor ), }, + .dqo = { + .desc = sizeof ( struct gve_dqo_tx_descriptor ), + .cmplt = sizeof ( struct gve_dqo_tx_completion ), + }, }, .create = GVE_ADMIN_CREATE_TX, .destroy = GVE_ADMIN_DESTROY_TX, @@ -1613,6 +1788,10 @@ static const struct gve_queue_type gve_rx_type = { .desc = sizeof ( struct gve_gqi_rx_descriptor ), .cmplt = sizeof ( struct gve_gqi_rx_completion ), }, + .dqo = { + .desc = sizeof ( struct gve_dqo_rx_descriptor ), + .cmplt = sizeof ( struct gve_dqo_rx_completion ), + }, }, .create = GVE_ADMIN_CREATE_RX, .destroy = GVE_ADMIN_DESTROY_RX, diff --git a/src/drivers/net/gve.h b/src/drivers/net/gve.h index c15cb808f..f185aca4a 100644 --- a/src/drivers/net/gve.h +++ b/src/drivers/net/gve.h @@ -539,9 +539,14 @@ struct gve_qpl { /** * Maximum number of transmit buffers * - * This is a policy decision. + * This is a policy decision. Experiments suggest that out-of-order + * transmit queues will write completions only in batches of 128 + * bytes, comprising 8 descriptor completions and 8 packet + * completions. The transmit fill level must therefore be greater + * than 8, so that completions will be written out before the transmit + * ring runs out of space. */ -#define GVE_TX_FILL 8 +#define GVE_TX_FILL 16 /** Transmit queue page list ID */ #define GVE_TX_QPL 0x18ae5458 @@ -577,6 +582,65 @@ struct gve_gqi_tx_descriptor { /** Continuation of packet transmit descriptor type */ #define GVE_GQI_TX_TYPE_CONT 0x20 +/** An out-of-order transmit tag + * + * From the hardware perspective, this is an opaque 15-bit (sic) value + * that is simply copied from the descriptor to the corresponding + * completion. + */ +struct gve_dqo_tx_tag { + /** Buffer index within queue page list */ + uint8_t id; + /** Number of descriptors covered by this completion + * + * Note that this is a 7-bit quantity: the high bit may be + * (ab)used by the hardware to indicate that a completion is a + * terminologically undefined "miss" completion. + */ + int8_t count; +} __attribute__ (( packed )); + +/** An out-of-order transmit descriptor */ +struct gve_dqo_tx_descriptor { + /** Buffer descriptor */ + struct gve_buffer buf; + /** Descriptor type and flags */ + uint8_t type; + /** Reserved */ + uint8_t reserved_a[3]; + /** Tag */ + struct gve_dqo_tx_tag tag; + /** Length of this descriptor */ + uint16_t len; +} __attribute__ (( packed )); + +/** Normal packet transmit descriptor type */ +#define GVE_DQO_TX_TYPE_PACKET 0x0c + +/** Last transmit descriptor in a packet */ +#define GVE_DQO_TX_TYPE_LAST 0x20 + +/** Report transmit completion */ +#define GVE_DQO_TX_TYPE_REPORT 0x80 + +/** An out-of-order transmit completion */ +struct gve_dqo_tx_completion { + /** Reserved */ + uint8_t reserved_a[1]; + /** Completion flags */ + uint8_t flags; + /** Tag */ + struct gve_dqo_tx_tag tag; + /** Reserved */ + uint8_t reserved_b[4]; +} __attribute__ (( packed )); + +/** Transmit completion packet flag */ +#define GVE_DQO_TXF_PKT 0x10 + +/** Transmit completion generation flag */ +#define GVE_DQO_TXF_GEN 0x80 + /** * Maximum number of receive buffers * @@ -620,7 +684,50 @@ struct gve_gqi_rx_completion { } __attribute__ (( packed )); /** Padding at the start of all received packets */ -#define GVE_RX_PAD 2 +#define GVE_GQI_RX_PAD 2 + +/** An out-of-order receive descriptor */ +struct gve_dqo_rx_descriptor { + /** Tag */ + uint8_t tag; + /** Reserved */ + uint8_t reserved_a[7]; + /** Buffer descriptor */ + struct gve_buffer buf; + /** Reserved */ + uint8_t reserved_b[16]; +} __attribute__ (( packed )); + +/** An out-of-order receive completion */ +struct gve_dqo_rx_completion { + /** Reserved */ + uint8_t reserved_a[1]; + /** Status */ + uint8_t status; + /** Reserved */ + uint8_t reserved_b[2]; + /** Length and generation bit */ + uint16_t len; + /** Reserved */ + uint8_t reserved_c[2]; + /** Flags */ + uint8_t flags; + /** Reserved */ + uint8_t reserved_d[3]; + /** Tag */ + uint8_t tag; + /** Reserved */ + uint8_t reserved_e[19]; +} __attribute__ (( packed )); + +/** Receive error */ +#define GVE_DQO_RXS_ERROR 0x04 + +/** Receive completion generation flag */ +#define GVE_DQO_RXL_GEN 0x4000 + +/** Last receive descriptor in a packet */ +#define GVE_DQO_RXF_LAST 0x02 /** Queue strides */ struct gve_queue_stride { @@ -638,21 +745,32 @@ struct gve_queue { union { /** In-order transmit descriptors */ struct gve_gqi_tx_descriptor *gqi; + /** Out-of-order transmit descriptors */ + struct gve_dqo_tx_descriptor *dqo; } tx; /** Receive descriptors */ union { /** In-order receive descriptors */ struct gve_gqi_rx_descriptor *gqi; + /** Out-of-order receive descriptors */ + struct gve_dqo_rx_descriptor *dqo; } rx; /** Raw data */ void *raw; } desc; /** Completion ring */ union { + /** Transmit completions */ + union { + /** Out-of-order transmit completions */ + struct gve_dqo_tx_completion *dqo; + } tx; /** Receive completions */ union { /** In-order receive completions */ struct gve_gqi_rx_completion *gqi; + /** Out-of-order receive completions */ + struct gve_dqo_rx_completion *dqo; } rx; /** Raw data */ void *raw; @@ -685,6 +803,8 @@ struct gve_queue { uint32_t prod; /** Consumer counter */ uint32_t cons; + /** Completion counter */ + uint32_t done; /** Tag ring */ uint8_t *tag; @@ -715,6 +835,8 @@ struct gve_queue_type { struct { /** In-order queue strides */ struct gve_queue_stride gqi; + /** Out-of-order queue strides */ + struct gve_queue_stride dqo; } stride; /** Command to create queue */ uint8_t create; @@ -754,6 +876,8 @@ struct gve_nic { struct gve_queue rx; /** Transmit I/O buffers (indexed by tag) */ struct io_buffer *tx_iobuf[GVE_TX_FILL]; + /** Transmit tag chain */ + uint8_t tx_chain[GVE_TX_FILL]; /** Transmit tag ring */ uint8_t tx_tag[GVE_TX_FILL]; /** Receive tag ring */ -- cgit v1.2.3-55-g7522 From ce30ba14fcf1a50e5e8cd7461b098023d08cab42 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 6 Oct 2025 14:04:18 +0100 Subject: [gve] Select preferred operating mode Select a preferred operating mode from those advertised as supported by the device, falling back to the oldest known mode (GQI-QPL) if no modes are advertised. Since there are devices in existence that support only QPL addressing, and since we want to minimise code size, we choose to always use a single fixed ring buffer even when using raw DMA addressing. Having paid this penalty, we therefore choose to prefer QPL over RDA since this allows the (virtual) hardware to minimise the number of page table manipulations required. We similarly prefer GQI over DQO since this minimises the amount of work we have to do: in particular, the RX descriptor ring contents can remain untouched for the lifetime of the device and refills require only a doorbell write. Signed-off-by: Michael Brown --- src/drivers/net/gve.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/drivers') diff --git a/src/drivers/net/gve.c b/src/drivers/net/gve.c index 8759d71a9..11ef35351 100644 --- a/src/drivers/net/gve.c +++ b/src/drivers/net/gve.c @@ -559,7 +559,22 @@ static int gve_describe ( struct gve_nic *gve ) { DBGC ( gve, "GVE %p supports options %#08x\n", gve, gve->options ); /* Select preferred operating mode */ - gve->mode = GVE_MODE_QPL; + if ( gve->options & ( 1 << GVE_OPT_GQI_QPL ) ) { + /* GQI-QPL: in-order queues, queue page list addressing */ + gve->mode = GVE_MODE_QPL; + } else if ( gve->options & ( 1 << GVE_OPT_GQI_RDA ) ) { + /* GQI-RDA: in-order queues, raw DMA addressing */ + gve->mode = 0; + } else if ( gve->options & ( 1 << GVE_OPT_DQO_QPL ) ) { + /* DQO-QPL: out-of-order queues, queue page list addressing */ + gve->mode = ( GVE_MODE_DQO | GVE_MODE_QPL ); + } else if ( gve->options & ( 1 << GVE_OPT_DQO_RDA ) ) { + /* DQO-RDA: out-of-order queues, raw DMA addressing */ + gve->mode = GVE_MODE_DQO; + } else { + /* No options matched: assume the original GQI-QPL mode */ + gve->mode = GVE_MODE_QPL; + } DBGC ( gve, "GVE %p using %s mode\n", gve, gve_mode_name ( gve->mode ) ); -- cgit v1.2.3-55-g7522 From 4224f574daa2cea6e8f402e766cdbb35a0178487 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 9 Oct 2025 16:01:51 +0100 Subject: [pci] Map all MSI-X interrupts to a dummy target address by default Interrupts as such are not used in iPXE, which operates in polling mode. However, some network cards (such as the Intel 40GbE and 100GbE NICs) will defer writing out completions until the point of asserting an MSI-X interrupt. From the point of view of the PCI device, asserting an MSI-X interrupt is just a 32-bit DMA write of an opaque value to an opaque target address. The PCI device has no know to know whether or not the target address corresponds to a real APIC. We can therefore trick the PCI device into believing that it is asserting an MSI-X interrupt, by configuring it to write an opaque 32-bit value to a dummy target address in host memory. This is sufficient to trigger the associated write of the completions to host memory. Allocate a dummy target address when enabling MSI-X on a PCI device, and map all interrupts to this target address by default. Signed-off-by: Michael Brown --- src/drivers/bus/pcimsix.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++ src/include/ipxe/pcimsix.h | 4 ++++ 2 files changed, 56 insertions(+) (limited to 'src/drivers') diff --git a/src/drivers/bus/pcimsix.c b/src/drivers/bus/pcimsix.c index eb0450d91..f55488ad7 100644 --- a/src/drivers/bus/pcimsix.c +++ b/src/drivers/bus/pcimsix.c @@ -33,6 +33,38 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * * PCI MSI-X interrupts * + * Interrupts as such are not used in iPXE, which operates in polling + * mode. However, some network cards (such as the Intel 40GbE and + * 100GbE NICs) will defer writing out completions until the point of + * asserting an MSI-X interrupt. + * + * From the point of view of the PCI device, asserting an MSI-X + * interrupt is just a 32-bit DMA write of an opaque value to an + * opaque target address. The PCI device has no know to know whether + * or not the target address corresponds to a real APIC. + * + * We can therefore trick the PCI device into believing that it is + * asserting an MSI-X interrupt, by configuring it to write an opaque + * 32-bit value to a dummy target address in host memory. This is + * sufficient to trigger the associated write of the completions to + * host memory. + * + * When running in a virtual machine, the hypervisor will intercept + * our attempt to configure MSI-X on the PCI device. The physical + * hardware will be configured to raise an interrupt under the + * hypervisor's control, which will then be reflected back into the + * virtual machine. The opaque value that we write will be assumed to + * indicate an interrupt vector number (as would normally be the case + * when configuring MSI-X), and the opaque address will generally be + * ignored. The reflected interrupt will be ignored (since it is not + * enabled within the virtual machine), but the device still asserts + * an MSI-X interrupt and so still triggers the associated write of + * the completions to host memory. + * + * Note that since the opaque target address will generally be ignored + * by the hypervisor, we cannot examine the value present at the dummy + * target address to find out whether or not an interrupt has been + * raised. */ /** @@ -103,6 +135,8 @@ static void * pci_msix_ioremap ( struct pci_device *pci, struct pci_msix *msix, */ int pci_msix_enable ( struct pci_device *pci, struct pci_msix *msix ) { uint16_t ctrl; + physaddr_t msg; + unsigned int i; int rc; /* Locate capability */ @@ -134,6 +168,19 @@ int pci_msix_enable ( struct pci_device *pci, struct pci_msix *msix ) { goto err_pba; } + /* Allocate dummy target */ + msix->msg = dma_alloc ( &pci->dma, &msix->map, sizeof ( *msix->msg ), + sizeof ( *msix->msg ) ); + if ( ! msix->msg ) { + rc = -ENOMEM; + goto err_msg; + } + + /* Map all interrupts to dummy target by default */ + msg = dma ( &msix->map, msix->msg ); + for ( i = 0 ; i < msix->count ; i++ ) + pci_msix_map ( msix, i, msg, 0 ); + /* Enable MSI-X */ ctrl &= ~PCI_MSIX_CTRL_MASK; ctrl |= PCI_MSIX_CTRL_ENABLE; @@ -141,6 +188,8 @@ int pci_msix_enable ( struct pci_device *pci, struct pci_msix *msix ) { return 0; + dma_free ( &msix->map, msix->msg, sizeof ( *msix->msg ) ); + err_msg: iounmap ( msix->pba ); err_pba: iounmap ( msix->table ); @@ -163,6 +212,9 @@ void pci_msix_disable ( struct pci_device *pci, struct pci_msix *msix ) { ctrl &= ~PCI_MSIX_CTRL_ENABLE; pci_write_config_word ( pci, ( msix->cap + PCI_MSIX_CTRL ), ctrl ); + /* Free dummy target */ + dma_free ( &msix->map, msix->msg, sizeof ( *msix->msg ) ); + /* Unmap pending bit array */ iounmap ( msix->pba ); diff --git a/src/include/ipxe/pcimsix.h b/src/include/ipxe/pcimsix.h index aa2aaf017..b40c6c357 100644 --- a/src/include/ipxe/pcimsix.h +++ b/src/include/ipxe/pcimsix.h @@ -40,6 +40,10 @@ struct pci_msix { void *table; /** Pending bit array */ void *pba; + /** Dummy message target */ + uint32_t *msg; + /** Dummy message target mapping */ + struct dma_mapping map; }; extern int pci_msix_enable ( struct pci_device *pci, struct pci_msix *msix ); -- cgit v1.2.3-55-g7522 From 5438299649d26edce89c39803f4d85477e315781 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 9 Oct 2025 16:27:49 +0100 Subject: [intelxl] Use default dummy MSI-X target address Use the default dummy MSI-X target address that is now allocated and configured automatically by pci_msix_enable(). Signed-off-by: Michael Brown --- src/drivers/net/intelxl.c | 28 +++++----------------------- src/drivers/net/intelxl.h | 12 +----------- 2 files changed, 6 insertions(+), 34 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/intelxl.c b/src/drivers/net/intelxl.c index 31a3e2577..76b9ff48f 100644 --- a/src/drivers/net/intelxl.c +++ b/src/drivers/net/intelxl.c @@ -63,35 +63,20 @@ int intelxl_msix_enable ( struct intelxl_nic *intelxl, struct pci_device *pci, unsigned int vector ) { int rc; - /* Map dummy target location */ - if ( ( rc = dma_map ( intelxl->dma, &intelxl->msix.map, - &intelxl->msix.msg, sizeof ( intelxl->msix.msg ), - DMA_RX ) ) != 0 ) { - DBGC ( intelxl, "INTELXL %p could not map MSI-X target: %s\n", - intelxl, strerror ( rc ) ); - goto err_map; - } - /* Enable MSI-X capability */ - if ( ( rc = pci_msix_enable ( pci, &intelxl->msix.cap ) ) != 0 ) { + if ( ( rc = pci_msix_enable ( pci, &intelxl->msix ) ) != 0 ) { DBGC ( intelxl, "INTELXL %p could not enable MSI-X: %s\n", intelxl, strerror ( rc ) ); goto err_enable; } - /* Configure interrupt to write to dummy location */ - pci_msix_map ( &intelxl->msix.cap, vector, - dma ( &intelxl->msix.map, &intelxl->msix.msg ), 0 ); - /* Enable dummy interrupt */ - pci_msix_unmask ( &intelxl->msix.cap, vector ); + pci_msix_unmask ( &intelxl->msix, vector ); return 0; - pci_msix_disable ( pci, &intelxl->msix.cap ); + pci_msix_disable ( pci, &intelxl->msix ); err_enable: - dma_unmap ( &intelxl->msix.map, sizeof ( intelxl->msix.msg ) ); - err_map: return rc; } @@ -106,13 +91,10 @@ void intelxl_msix_disable ( struct intelxl_nic *intelxl, struct pci_device *pci, unsigned int vector ) { /* Disable dummy interrupts */ - pci_msix_mask ( &intelxl->msix.cap, vector ); + pci_msix_mask ( &intelxl->msix, vector ); /* Disable MSI-X capability */ - pci_msix_disable ( pci, &intelxl->msix.cap ); - - /* Unmap dummy target location */ - dma_unmap ( &intelxl->msix.map, sizeof ( intelxl->msix.msg ) ); + pci_msix_disable ( pci, &intelxl->msix ); } /****************************************************************************** diff --git a/src/drivers/net/intelxl.h b/src/drivers/net/intelxl.h index 6c7865aa2..d23acf96e 100644 --- a/src/drivers/net/intelxl.h +++ b/src/drivers/net/intelxl.h @@ -891,16 +891,6 @@ intelxl_init_ring ( struct intelxl_ring *ring, unsigned int count, size_t len, #define INTELXL_PFGEN_PORTNUM_PORT_NUM(x) \ ( ( (x) >> 0 ) & 0x3 ) /**< Port number */ -/** MSI-X interrupt */ -struct intelxl_msix { - /** PCI capability */ - struct pci_msix cap; - /** MSI-X dummy interrupt target */ - uint32_t msg; - /** DMA mapping for dummy interrupt target */ - struct dma_mapping map; -}; - /** MSI-X interrupt vector */ #define INTELXL_MSIX_VECTOR 0 @@ -934,7 +924,7 @@ struct intelxl_nic { /** PCI Express capability offset */ unsigned int exp; /** MSI-X interrupt */ - struct intelxl_msix msix; + struct pci_msix msix; /** Admin command queue */ struct intelxl_admin command; -- cgit v1.2.3-55-g7522 From c2d7ddd0c2855a935e0ba7987a300bcecc46261a Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 6 Oct 2025 16:39:19 +0100 Subject: [gve] Add missing memory barriers Ensure that remainder of completion records are read only after verifying the generation bit (or sequence number). Signed-off-by: Michael Brown --- src/drivers/net/gve.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/drivers') diff --git a/src/drivers/net/gve.c b/src/drivers/net/gve.c index 11ef35351..1696c249d 100644 --- a/src/drivers/net/gve.c +++ b/src/drivers/net/gve.c @@ -1493,6 +1493,7 @@ static void gve_poll_tx ( struct net_device *netdev ) { bit = ( dqo->flags & GVE_DQO_TXF_GEN ); if ( ( !! bit ) == ( !! gen ) ) break; + rmb(); tx->done++; /* Ignore non-packet completions */ @@ -1583,6 +1584,7 @@ static void gve_poll_rx ( struct net_device *netdev ) { bit = ( dqo->len & cpu_to_le16 ( GVE_DQO_RXL_GEN ) ); if ( ( !! bit ) == ( !! gen ) ) break; + rmb(); /* Parse completion */ len = ( le16_to_cpu ( dqo->len ) & @@ -1610,6 +1612,7 @@ static void gve_poll_rx ( struct net_device *netdev ) { /* Check sequence number */ if ( ( gqi->seq & GVE_GQI_RX_SEQ_MASK ) != seq ) break; + rmb(); seq = gve_next ( seq ); /* Parse completion */ -- cgit v1.2.3-55-g7522 From d2e1e591ab957955794584aed911f701922cd2c7 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 9 Oct 2025 17:12:20 +0100 Subject: [gve] Use dummy interrupt to trigger completion writeback in DQO mode When operating in the DQO operating mode, the device will defer writing transmit and receive completions until an entire internal cacheline (128 bytes) is full, or until an associated interrupt is asserted. Since each receive descriptor is 32 bytes, this will cause received packets to be effectively delayed until up to three further packets have arrived. When network traffic volumes are very low (such as during DHCP, DNS lookups, or TCP handshakes), this typically induces delays of up to 30 seconds and results in a very poor user experience. Work around this hardware problem in the same way as for the Intel 40GbE and 100GbE NICs: by enabling dummy MSI-X interrupts to trick the hardware into believing that it needs to write out completions to host memory. There is no documentation around the interrupt rearming mechanism. The value written to the interrupt doorbell does not include a consumer counter value, and so must be relying on some undocumented ordering constraints. Comments in the Linux driver source suggest that the authors believe that the device will automatically and atomically mask an MSI-X interrupt at the point of asserting it, that any further interrupts arriving before the doorbell is written will be recorded in the pending bit array, and that writing the doorbell will therefore immediately assert a new interrupt if needed. In the absence of any documentation, choose to rearm the interrupt once per observed completion. This is overkill, but is less impactful than the alternative of rearming the interrupt unconditionally on every poll. Signed-off-by: Michael Brown --- src/drivers/net/gve.c | 30 +++++++++++++++++++++++++++++- src/drivers/net/gve.h | 10 ++++++++-- 2 files changed, 37 insertions(+), 3 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/gve.c b/src/drivers/net/gve.c index 1696c249d..66e529abc 100644 --- a/src/drivers/net/gve.c +++ b/src/drivers/net/gve.c @@ -591,6 +591,7 @@ static int gve_configure ( struct gve_nic *gve ) { struct gve_events *events = &gve->events; struct gve_irqs *irqs = &gve->irqs; union gve_admin_command *cmd; + uint32_t doorbell; unsigned int db_off; unsigned int i; int rc; @@ -612,12 +613,14 @@ static int gve_configure ( struct gve_nic *gve ) { return rc; /* Disable all interrupts */ + doorbell = ( ( gve->mode & GVE_MODE_DQO ) ? + 0 : bswap_32 ( GVE_GQI_IRQ_DISABLE ) ); for ( i = 0 ; i < GVE_IRQ_COUNT ; i++ ) { db_off = ( be32_to_cpu ( irqs->irq[i].db_idx ) * sizeof ( uint32_t ) ); DBGC ( gve, "GVE %p IRQ %d doorbell +%#04x\n", gve, i, db_off ); irqs->db[i] = ( gve->db + db_off ); - writel ( bswap_32 ( GVE_IRQ_DISABLE ), irqs->db[i] ); + writel ( doorbell, irqs->db[i] ); } return 0; @@ -810,6 +813,13 @@ static int gve_create_queue ( struct gve_nic *gve, struct gve_queue *queue ) { queue->event = &gve->events.event[evt_idx]; assert ( queue->event->count == 0 ); + /* Unmask dummy interrupt */ + pci_msix_unmask ( &gve->msix, type->irq ); + + /* Rearm queue interrupt if applicable */ + if ( gve->mode & GVE_MODE_DQO ) + writel ( GVE_DQO_IRQ_REARM, gve->irqs.db[type->irq] ); + return 0; } @@ -824,6 +834,9 @@ static int gve_destroy_queue ( struct gve_nic *gve, struct gve_queue *queue ) { const struct gve_queue_type *type = queue->type; int rc; + /* Mask dummy interrupt */ + pci_msix_mask ( &gve->msix, type->irq ); + /* Issue command */ if ( ( rc = gve_admin_simple ( gve, type->destroy, 0 ) ) != 0 ) return rc; @@ -1496,6 +1509,9 @@ static void gve_poll_tx ( struct net_device *netdev ) { rmb(); tx->done++; + /* Re-arm interrupt */ + writel ( GVE_DQO_IRQ_REARM, gve->irqs.db[GVE_TX_IRQ] ); + /* Ignore non-packet completions */ if ( ( ! ( dqo->flags & GVE_DQO_TXF_PKT ) ) || ( dqo->tag.count < 0 ) ) { @@ -1586,6 +1602,9 @@ static void gve_poll_rx ( struct net_device *netdev ) { break; rmb(); + /* Re-arm interrupt */ + writel ( GVE_DQO_IRQ_REARM, gve->irqs.db[GVE_RX_IRQ] ); + /* Parse completion */ len = ( le16_to_cpu ( dqo->len ) & ( GVE_BUF_SIZE - 1 ) ); @@ -1917,6 +1936,10 @@ static int gve_probe ( struct pci_device *pci ) { dma_set_mask_64bit ( gve->dma ); assert ( netdev->dma == NULL ); + /* Configure dummy MSI-X interrupt */ + if ( ( rc = pci_msix_enable ( pci, &gve->msix ) ) != 0 ) + goto err_msix; + /* Allocate admin queue */ if ( ( rc = gve_admin_alloc ( gve ) ) != 0 ) goto err_admin; @@ -1937,6 +1960,8 @@ static int gve_probe ( struct pci_device *pci ) { gve_reset ( gve ); gve_admin_free ( gve ); err_admin: + pci_msix_disable ( pci, &gve->msix ); + err_msix: iounmap ( gve->db ); err_db: iounmap ( gve->cfg ); @@ -1965,6 +1990,9 @@ static void gve_remove ( struct pci_device *pci ) { /* Free admin queue */ gve_admin_free ( gve ); + /* Disable dummy MSI-X interrupt */ + pci_msix_disable ( pci, &gve->msix ); + /* Unmap registers */ iounmap ( gve->db ); iounmap ( gve->cfg ); diff --git a/src/drivers/net/gve.h b/src/drivers/net/gve.h index f185aca4a..29928a34a 100644 --- a/src/drivers/net/gve.h +++ b/src/drivers/net/gve.h @@ -16,6 +16,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include #include #include @@ -443,8 +444,11 @@ struct gve_irqs { volatile uint32_t *db[GVE_IRQ_COUNT]; }; -/** Disable interrupts */ -#define GVE_IRQ_DISABLE 0x40000000UL +/** Disable in-order queue interrupt */ +#define GVE_GQI_IRQ_DISABLE 0x40000000UL + +/** Rearm out-of-order queue interrupt */ +#define GVE_DQO_IRQ_REARM 0x00000019UL /** * Queue resources @@ -856,6 +860,8 @@ struct gve_nic { struct net_device *netdev; /** DMA device */ struct dma_device *dma; + /** Dummy MSI-X interrupt */ + struct pci_msix msix; /** Admin queue */ struct gve_admin admin; -- cgit v1.2.3-55-g7522 From 1cc1f1cd4f06e297552b3cf15d43ee23f5fa1ce2 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 9 Oct 2025 17:25:25 +0100 Subject: [gve] Report only packet completions for the transmit ring The hardware reports descriptor and packet completions separately for the transmit ring. We currently ignore descriptor completions (since we cannot free up the transmit buffers in the queue page list and advance the consumer counter until the packet has also completed). Now that transmit completions are written out immediately (instead of being delayed until 128 bytes of completions are available), there is no value in retaining the descriptor completions. Omit descriptor completions entirely, and reduce the transmit fill level back down to its original value. Signed-off-by: Michael Brown --- src/drivers/net/gve.c | 3 +-- src/drivers/net/gve.h | 12 ++---------- 2 files changed, 3 insertions(+), 12 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/gve.c b/src/drivers/net/gve.c index 66e529abc..3c45b92fa 100644 --- a/src/drivers/net/gve.c +++ b/src/drivers/net/gve.c @@ -1422,8 +1422,7 @@ static int gve_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) { cpu_to_le64 ( gve_address ( tx, tag ) ); if ( next == len ) { dqo->type = ( GVE_DQO_TX_TYPE_PACKET | - GVE_DQO_TX_TYPE_LAST | - GVE_DQO_TX_TYPE_REPORT ); + GVE_DQO_TX_TYPE_LAST ); dqo->tag.id = tag; dqo->tag.count = count; } else { diff --git a/src/drivers/net/gve.h b/src/drivers/net/gve.h index 29928a34a..9cef01a02 100644 --- a/src/drivers/net/gve.h +++ b/src/drivers/net/gve.h @@ -543,14 +543,9 @@ struct gve_qpl { /** * Maximum number of transmit buffers * - * This is a policy decision. Experiments suggest that out-of-order - * transmit queues will write completions only in batches of 128 - * bytes, comprising 8 descriptor completions and 8 packet - * completions. The transmit fill level must therefore be greater - * than 8, so that completions will be written out before the transmit - * ring runs out of space. + * This is a policy decision. */ -#define GVE_TX_FILL 16 +#define GVE_TX_FILL 8 /** Transmit queue page list ID */ #define GVE_TX_QPL 0x18ae5458 @@ -624,9 +619,6 @@ struct gve_dqo_tx_descriptor { /** Last transmit descriptor in a packet */ #define GVE_DQO_TX_TYPE_LAST 0x20 -/** Report transmit completion */ -#define GVE_DQO_TX_TYPE_REPORT 0x80 - /** An out-of-order transmit completion */ struct gve_dqo_tx_completion { /** Reserved */ -- cgit v1.2.3-55-g7522 From f5ca1de7380a7be7257ed62c42de00310164f79e Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 10 Oct 2025 12:44:01 +0100 Subject: [gve] Use raw DMA addresses in descriptors in DQO-QPL mode The DQO-QPL operating mode uses registered queue page lists but still requires the raw DMA address (rather than the linear offset within the QPL) to be provided in transmit and receive descriptors. Set the queue page list base device address appropriately. Signed-off-by: Michael Brown --- src/drivers/net/gve.c | 2 +- src/drivers/net/gve.h | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/gve.c b/src/drivers/net/gve.c index 3c45b92fa..c25f1d452 100644 --- a/src/drivers/net/gve.c +++ b/src/drivers/net/gve.c @@ -938,7 +938,7 @@ static int gve_alloc_qpl ( struct gve_nic *gve, struct gve_qpl *qpl, qpl->data = dma_umalloc ( gve->dma, &qpl->map, len, GVE_ALIGN ); if ( ! qpl->data ) return -ENOMEM; - qpl->base = ( ( gve->mode & GVE_MODE_QPL ) ? + qpl->base = ( ( gve->mode == GVE_MODE_QPL ) ? 0 : dma ( &qpl->map, qpl->data ) ); DBGC ( gve, "GVE %p QPL %#08x at [%08lx,%08lx)\n", diff --git a/src/drivers/net/gve.h b/src/drivers/net/gve.h index 9cef01a02..d352306ef 100644 --- a/src/drivers/net/gve.h +++ b/src/drivers/net/gve.h @@ -530,9 +530,10 @@ struct gve_qpl { unsigned int id; /** Queue page list base device address * - * This will be zero if queue page list addressing is in use, - * or the DMA address of the first page if raw DMA addressing - * is in use. + * This will be zero in the GQI-QPL operating mode, or the DMA + * address of the first page in any other operating mode. + * (Despite its name, DQO-QPL still requires the use of raw + * DMA addresses in transmit and receive descriptors.) */ physaddr_t base; }; -- cgit v1.2.3-55-g7522 From 4f44f624027c9e62cf2ed4486cd9e3429e6ebb52 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 10 Oct 2025 13:07:05 +0100 Subject: [gve] Rearm interrupts unconditionally on every poll Experimentation suggests that rearming the interrupt once per observed completion is not sufficient: we still see occasional delays during which the hardware fails to write out completions. As described in commit d2e1e59 ("[gve] Use dummy interrupt to trigger completion writeback in DQO mode"), there is no documentation around the precise semantics of the interrupt rearming mechanism, and so experimentation is the only available guide. Switch to rearming both TX and RX interrupts unconditionally on every poll, since this produces better experimental results. Signed-off-by: Michael Brown --- src/drivers/net/gve.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/gve.c b/src/drivers/net/gve.c index c25f1d452..77eb4b674 100644 --- a/src/drivers/net/gve.c +++ b/src/drivers/net/gve.c @@ -1508,9 +1508,6 @@ static void gve_poll_tx ( struct net_device *netdev ) { rmb(); tx->done++; - /* Re-arm interrupt */ - writel ( GVE_DQO_IRQ_REARM, gve->irqs.db[GVE_TX_IRQ] ); - /* Ignore non-packet completions */ if ( ( ! ( dqo->flags & GVE_DQO_TXF_PKT ) ) || ( dqo->tag.count < 0 ) ) { @@ -1601,9 +1598,6 @@ static void gve_poll_rx ( struct net_device *netdev ) { break; rmb(); - /* Re-arm interrupt */ - writel ( GVE_DQO_IRQ_REARM, gve->irqs.db[GVE_RX_IRQ] ); - /* Parse completion */ len = ( le16_to_cpu ( dqo->len ) & ( GVE_BUF_SIZE - 1 ) ); @@ -1762,6 +1756,7 @@ static void gve_refill_rx ( struct net_device *netdev ) { * @v netdev Network device */ static void gve_poll ( struct net_device *netdev ) { + struct gve_nic *gve = netdev->priv; /* Do nothing if queues are not yet set up */ if ( ! netdev_link_ok ( netdev ) ) @@ -1775,6 +1770,12 @@ static void gve_poll ( struct net_device *netdev ) { /* Refill receive queue */ gve_refill_rx ( netdev ); + + /* Rearm queue interrupts if applicable */ + if ( gve->mode & GVE_MODE_DQO ) { + writel ( GVE_DQO_IRQ_REARM, gve->irqs.db[GVE_TX_IRQ] ); + writel ( GVE_DQO_IRQ_REARM, gve->irqs.db[GVE_RX_IRQ] ); + } } /** GVE network device operations */ -- cgit v1.2.3-55-g7522 From 94902ae1877f8799cdaa6fe627034f26d610552b Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 14 Oct 2025 13:46:54 +0100 Subject: [pci] Handle sizing of 64-bit BARs Provide pci_bar_set() to handle setting the base address for a potentially 64-bit BAR, and rewrite pci_bar_size() to correctly handle sizing of 64-bit BARs. Signed-off-by: Michael Brown --- src/drivers/bus/pci.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++ src/drivers/bus/pciextra.c | 36 ---------------------- src/include/ipxe/pci.h | 4 ++- 3 files changed, 79 insertions(+), 37 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/bus/pci.c b/src/drivers/bus/pci.c index 60740ac18..f3ea6d478 100644 --- a/src/drivers/bus/pci.c +++ b/src/drivers/bus/pci.c @@ -104,6 +104,82 @@ unsigned long pci_bar_start ( struct pci_device *pci, unsigned int reg ) { } } +/** + * Set the start of a PCI BAR + * + * @v pci PCI device + * @v reg PCI register number + * @v start BAR start address + */ +void pci_bar_set ( struct pci_device *pci, unsigned int reg, + unsigned long start ) { + unsigned int type; + uint32_t low; + uint32_t high; + + /* Check for a 64-bit BAR */ + pci_read_config_dword ( pci, reg, &low ); + type = ( low & ( PCI_BASE_ADDRESS_SPACE_IO | + PCI_BASE_ADDRESS_MEM_TYPE_MASK ) ); + + /* Write low 32 bits */ + low = start; + pci_write_config_dword ( pci, reg, low ); + + /* Write high 32 bits, if applicable */ + if ( type == PCI_BASE_ADDRESS_MEM_TYPE_64 ) { + if ( sizeof ( unsigned long ) > sizeof ( uint32_t ) ) { + high = ( ( ( uint64_t ) start ) >> 32 ); + } else { + high = 0; + } + pci_write_config_dword ( pci, reg + 4, high ); + } +} + +/** + * Get the size of a PCI BAR + * + * @v pci PCI device + * @v reg PCI register number + * @ret size BAR size + * + * Most drivers should not need to call this function. It is not + * necessary to map the whole PCI BAR, only the portion that will be + * used for register access. Since register offsets are almost always + * fixed by hardware design, the length of the mapped portion will + * almost always be a compile-time constant. + */ +unsigned long pci_bar_size ( struct pci_device *pci, unsigned int reg ) { + unsigned long start; + unsigned long size; + uint16_t cmd; + + /* Save the original command register and disable decoding */ + pci_read_config_word ( pci, PCI_COMMAND, &cmd ); + pci_write_config_word ( pci, PCI_COMMAND, + ( cmd & ~( PCI_COMMAND_MEM | + PCI_COMMAND_IO ) ) ); + + /* Save the original start address */ + start = pci_bar_start ( pci, reg ); + + /* Set all possible bits */ + pci_bar_set ( pci, reg, -1UL ); + + /* Determine size by finding lowest set bit */ + size = pci_bar_start ( pci, reg ); + size &= ( -size ); + + /* Restore the original start address */ + pci_bar_set ( pci, reg, start ); + + /* Restore the original command register */ + pci_write_config_word ( pci, PCI_COMMAND, cmd ); + + return size; +} + /** * Read membase and ioaddr for a PCI device * diff --git a/src/drivers/bus/pciextra.c b/src/drivers/bus/pciextra.c index 1eeb9b2a0..3654a2d1c 100644 --- a/src/drivers/bus/pciextra.c +++ b/src/drivers/bus/pciextra.c @@ -79,42 +79,6 @@ int pci_find_next_capability ( struct pci_device *pci, int pos, int cap ) { return pci_find_capability_common ( pci, new_pos, cap ); } -/** - * Find the size of a PCI BAR - * - * @v pci PCI device - * @v reg PCI register number - * @ret size BAR size - * - * It should not be necessary for any Etherboot code to call this - * function. - */ -unsigned long pci_bar_size ( struct pci_device *pci, unsigned int reg ) { - uint16_t cmd; - uint32_t start, size; - - /* Save the original command register */ - pci_read_config_word ( pci, PCI_COMMAND, &cmd ); - /* Save the original bar */ - pci_read_config_dword ( pci, reg, &start ); - /* Compute which bits can be set */ - pci_write_config_dword ( pci, reg, ~0 ); - pci_read_config_dword ( pci, reg, &size ); - /* Restore the original size */ - pci_write_config_dword ( pci, reg, start ); - /* Find the significant bits */ - /* Restore the original command register. This reenables decoding. */ - pci_write_config_word ( pci, PCI_COMMAND, cmd ); - if ( start & PCI_BASE_ADDRESS_SPACE_IO ) { - size &= ~PCI_BASE_ADDRESS_IO_MASK; - } else { - size &= ~PCI_BASE_ADDRESS_MEM_MASK; - } - /* Find the lowest bit set */ - size = size & ~( size - 1 ); - return size; -} - /** * Perform PCI Express function-level reset (FLR) * diff --git a/src/include/ipxe/pci.h b/src/include/ipxe/pci.h index 8c6d9e4e2..6eeabef30 100644 --- a/src/include/ipxe/pci.h +++ b/src/include/ipxe/pci.h @@ -314,6 +314,9 @@ struct pci_driver { extern void adjust_pci_device ( struct pci_device *pci ); extern unsigned long pci_bar_start ( struct pci_device *pci, unsigned int reg ); +extern void pci_bar_set ( struct pci_device *pci, unsigned int reg, + unsigned long start ); +extern unsigned long pci_bar_size ( struct pci_device *pci, unsigned int reg ); extern int pci_read_config ( struct pci_device *pci ); extern int pci_find_next ( struct pci_device *pci, uint32_t *busdevfn ); extern int pci_find_driver ( struct pci_device *pci ); @@ -322,7 +325,6 @@ extern void pci_remove ( struct pci_device *pci ); extern int pci_find_capability ( struct pci_device *pci, int capability ); extern int pci_find_next_capability ( struct pci_device *pci, int pos, int capability ); -extern unsigned long pci_bar_size ( struct pci_device *pci, unsigned int reg ); extern void pci_reset ( struct pci_device *pci, unsigned int exp ); /** -- cgit v1.2.3-55-g7522 From 04a61c413d8f56171eff45929174b441211331c6 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 14 Oct 2025 14:44:56 +0100 Subject: [ena] Use pci_bar_set() to place device within bridge memory window Use pci_bar_set() when we need to set a device base address (on instance types such as c6i.metal where the BIOS fails to do so), so that 64-bit BARs will be handled automatically. This particular issue has so far been observed only on 6th generation instances. These use 32-bit BARs, and so the lack of support for handling 64-bit BARs has not caused any observable issue. Signed-off-by: Michael Brown --- src/drivers/net/ena.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/drivers') diff --git a/src/drivers/net/ena.c b/src/drivers/net/ena.c index 89483eae1..dc822dcf6 100644 --- a/src/drivers/net/ena.c +++ b/src/drivers/net/ena.c @@ -1102,7 +1102,7 @@ static int ena_membase ( struct ena_nic *ena, struct pci_device *pci ) { } /* Place device at start of memory window */ - pci_write_config_dword ( pci, PCI_BASE_ADDRESS_0, bridge->membase ); + pci_bar_set ( pci, PCI_BASE_ADDRESS_0, bridge->membase ); pci->membase = bridge->membase; DBGC ( ena, "ENA %p at " PCI_FMT " claiming bridge " PCI_FMT " mem " "%08x\n", ena, PCI_ARGS ( pci ), PCI_ARGS ( bridge->pci ), -- cgit v1.2.3-55-g7522 From 3538e9c39a3f59a7bad70d4ebff44e7dbe2fe2b9 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 14 Oct 2025 18:37:39 +0100 Subject: [pci] Record prefetchable memory window for PCI bridges Signed-off-by: Michael Brown --- src/drivers/bus/pcibridge.c | 28 +++++++++++++++++++++++----- src/include/ipxe/pci.h | 6 +++++- src/include/ipxe/pcibridge.h | 4 ++++ 3 files changed, 32 insertions(+), 6 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/bus/pcibridge.c b/src/drivers/bus/pcibridge.c index d2763faf9..67c97589f 100644 --- a/src/drivers/bus/pcibridge.c +++ b/src/drivers/bus/pcibridge.c @@ -68,6 +68,8 @@ static int pcibridge_probe ( struct pci_device *pci ) { struct pci_bridge *bridge; uint16_t base; uint16_t limit; + uint32_t base_hi; + uint32_t limit_hi; int rc; /* Allocate and initialise structure */ @@ -78,17 +80,33 @@ static int pcibridge_probe ( struct pci_device *pci ) { } bridge->pci = pci; - /* Read configuration */ + /* Read bus configuration */ pci_read_config_dword ( pci, PCI_PRIMARY, &bridge->buses ); cpu_to_le32s ( &buses ); + + /* Read memory base and limit */ pci_read_config_word ( pci, PCI_MEM_BASE, &base ); bridge->membase = ( ( base & ~PCI_MEM_MASK ) << 16 ); pci_read_config_word ( pci, PCI_MEM_LIMIT, &limit ); bridge->memlimit = ( ( ( ( limit | PCI_MEM_MASK ) + 1 ) << 16 ) - 1 ); - DBGC ( bridge, "BRIDGE " PCI_FMT " bus %02x to [%02x,%02x) mem " - "[%08x,%08x)\n", PCI_ARGS ( pci ), bridge->primary, - bridge->secondary, bridge->subordinate, bridge->membase, - bridge->memlimit ); + + /* Read prefetchable memory base and limit */ + pci_read_config_word ( pci, PCI_PREFMEM_BASE, &base ); + pci_read_config_dword ( pci, PCI_PREFMEM_BASE_HI, &base_hi ); + bridge->prefmembase = ( ( ( base & ~PCI_MEM_MASK ) << 16 ) | + ( ( ( uint64_t ) base_hi ) << 32 ) ); + pci_read_config_word ( pci, PCI_PREFMEM_LIMIT, &limit ); + pci_read_config_dword ( pci, PCI_PREFMEM_LIMIT_HI, &limit_hi ); + bridge->prefmemlimit = ( ( ( ( ( limit | PCI_MEM_MASK ) + 1 ) << 16 ) | + ( ( ( uint64_t ) limit_hi ) << 32 ) ) - 1 ); + + DBGC ( bridge, "BRIDGE " PCI_FMT " bus %02x to [%02x,%02x)\n", + PCI_ARGS ( pci ), bridge->primary, bridge->secondary, + bridge->subordinate ); + DBGC ( bridge, "BRIDGE " PCI_FMT " mem [%08x,%08x) prefmem " + "[%08llx,%08llx)\n", PCI_ARGS ( pci ), bridge->membase, + bridge->memlimit, ( ( unsigned long long ) bridge->prefmembase ), + ( ( unsigned long long ) bridge->prefmemlimit ) ); /* Add to list of PCI bridges */ list_add ( &bridge->list, &pcibridges ); diff --git a/src/include/ipxe/pci.h b/src/include/ipxe/pci.h index 6eeabef30..2728cbd45 100644 --- a/src/include/ipxe/pci.h +++ b/src/include/ipxe/pci.h @@ -151,7 +151,11 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /** Memory base and limit */ #define PCI_MEM_BASE 0x20 #define PCI_MEM_LIMIT 0x22 -#define PCI_MEM_MASK 0x000f +#define PCI_MEM_MASK 0x000fUL +#define PCI_PREFMEM_BASE 0x24 +#define PCI_PREFMEM_LIMIT 0x26 +#define PCI_PREFMEM_BASE_HI 0x28 +#define PCI_PREFMEM_LIMIT_HI 0x2c /** Construct PCI class * diff --git a/src/include/ipxe/pcibridge.h b/src/include/ipxe/pcibridge.h index c57a81067..3a278a0ca 100644 --- a/src/include/ipxe/pcibridge.h +++ b/src/include/ipxe/pcibridge.h @@ -34,6 +34,10 @@ struct pci_bridge { uint32_t membase; /** Memory limit */ uint32_t memlimit; + /** Prefetchable memory base */ + uint64_t prefmembase; + /** Prefetchable memory limit */ + uint64_t prefmemlimit; /** List of bridges */ struct list_head list; }; -- cgit v1.2.3-55-g7522 From 510f3e5e17c1961e5487ba59937f4abef33f24a8 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 15 Oct 2025 12:00:42 +0100 Subject: [ena] Add descriptive messages for any admin queue command failures Signed-off-by: Michael Brown --- src/drivers/net/ena.c | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/ena.c b/src/drivers/net/ena.c index dc822dcf6..7f6e8164f 100644 --- a/src/drivers/net/ena.c +++ b/src/drivers/net/ena.c @@ -371,8 +371,11 @@ static int ena_set_aenq_config ( struct ena_nic *ena, uint32_t enabled ) { feature->aenq.enabled = cpu_to_le32 ( enabled ); /* Issue request */ - if ( ( rc = ena_admin ( ena, req, &rsp ) ) != 0 ) + if ( ( rc = ena_admin ( ena, req, &rsp ) ) != 0 ) { + DBGC ( ena, "ENA %p could not set AENQ configuration: %s\n", + ena, strerror ( rc ) ); return rc; + } return 0; } @@ -468,8 +471,11 @@ static int ena_create_sq ( struct ena_nic *ena, struct ena_sq *sq, req->create_sq.address = cpu_to_le64 ( virt_to_bus ( sq->sqe.raw ) ); /* Issue request */ - if ( ( rc = ena_admin ( ena, req, &rsp ) ) != 0 ) + if ( ( rc = ena_admin ( ena, req, &rsp ) ) != 0 ) { + DBGC ( ena, "ENA %p could not create %s SQ: %s\n", + ena, ena_direction ( sq->direction ), strerror ( rc ) ); goto err_admin; + } /* Parse response */ sq->id = le16_to_cpu ( rsp->create_sq.id ); @@ -520,8 +526,12 @@ static int ena_destroy_sq ( struct ena_nic *ena, struct ena_sq *sq ) { req->destroy_sq.direction = sq->direction; /* Issue request */ - if ( ( rc = ena_admin ( ena, req, &rsp ) ) != 0 ) + if ( ( rc = ena_admin ( ena, req, &rsp ) ) != 0 ) { + DBGC ( ena, "ENA %p could not destroy %s SQ%d: %s\n", + ena, ena_direction ( sq->direction ), sq->id, + strerror ( rc ) ); return rc; + } /* Free submission queue entries */ free_phys ( sq->sqe.raw, sq->len ); @@ -561,8 +571,8 @@ static int ena_create_cq ( struct ena_nic *ena, struct ena_cq *cq ) { /* Issue request */ if ( ( rc = ena_admin ( ena, req, &rsp ) ) != 0 ) { - DBGC ( ena, "ENA %p CQ%d creation failed (broken firmware?)\n", - ena, cq->id ); + DBGC ( ena, "ENA %p could not create CQ (broken firmware?): " + "%s\n", ena, strerror ( rc ) ); goto err_admin; } @@ -609,8 +619,11 @@ static int ena_destroy_cq ( struct ena_nic *ena, struct ena_cq *cq ) { req->destroy_cq.id = cpu_to_le16 ( cq->id ); /* Issue request */ - if ( ( rc = ena_admin ( ena, req, &rsp ) ) != 0 ) + if ( ( rc = ena_admin ( ena, req, &rsp ) ) != 0 ) { + DBGC ( ena, "ENA %p could not destroy CQ%d: %s\n", + ena, cq->id, strerror ( rc ) ); return rc; + } /* Free completion queue entries */ free_phys ( cq->cqe.raw, cq->len ); @@ -683,8 +696,11 @@ static int ena_get_device_attributes ( struct net_device *netdev ) { req->get_feature.id = ENA_DEVICE_ATTRIBUTES; /* Issue request */ - if ( ( rc = ena_admin ( ena, req, &rsp ) ) != 0 ) + if ( ( rc = ena_admin ( ena, req, &rsp ) ) != 0 ) { + DBGC ( ena, "ENA %p could not get device attributes: %s\n", + ena, strerror ( rc ) ); return rc; + } /* Parse response */ feature = &rsp->get_feature.feature; @@ -717,8 +733,11 @@ static int ena_set_host_attributes ( struct ena_nic *ena ) { feature->host.info = cpu_to_le64 ( virt_to_bus ( ena->info ) ); /* Issue request */ - if ( ( rc = ena_admin ( ena, req, &rsp ) ) != 0 ) + if ( ( rc = ena_admin ( ena, req, &rsp ) ) != 0 ) { + DBGC ( ena, "ENA %p could not set host attributes: %s\n", + ena, strerror ( rc ) ); return rc; + } return 0; } @@ -747,8 +766,11 @@ static int ena_get_stats ( struct ena_nic *ena ) { req->get_stats.device = ENA_DEVICE_MINE; /* Issue request */ - if ( ( rc = ena_admin ( ena, req, &rsp ) ) != 0 ) + if ( ( rc = ena_admin ( ena, req, &rsp ) ) != 0 ) { + DBGC ( ena, "ENA %p could not get statistics: %s\n", + ena, strerror ( rc ) ); return rc; + } /* Parse response */ stats = &rsp->get_stats; -- cgit v1.2.3-55-g7522 From dcc5d36ce59e9aaf662f6d827d1966a3e1fb87d5 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 15 Oct 2025 15:27:03 +0100 Subject: [ena] Map the on-device memory, if present Newer generations of the ENA hardware require the use of low latency transmit queues, where the submission queues and the initial portion of the transmitted packet are written to on-device memory via BAR2 instead of being read from host memory. Prepare for this by mapping the on-device memory BAR. As with the register BAR, we may need to steal a base address from the upstream PCI bridge since the BIOS on some instance types (observed with an m8i.metal-48xl instance in eu-south-2) will fail to assign an address to the device. Signed-off-by: Michael Brown --- src/drivers/net/ena.c | 75 ++++++++++++++++++++++++++++++++++++++++----------- src/drivers/net/ena.h | 12 +++++++-- 2 files changed, 70 insertions(+), 17 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/ena.c b/src/drivers/net/ena.c index 7f6e8164f..51375e47f 100644 --- a/src/drivers/net/ena.c +++ b/src/drivers/net/ena.c @@ -1095,10 +1095,12 @@ static struct net_device_operations ena_operations = { */ /** - * Assign memory BAR + * Assign memory BARs * * @v ena ENA device * @v pci PCI device + * @v prefmembase On-device memory base address to fill in + * @v prefmemsize On-device memory size to fill in * @ret rc Return status code * * Some BIOSes in AWS EC2 are observed to fail to assign a base @@ -1106,15 +1108,27 @@ static struct net_device_operations ena_operations = { * its bridge, and the BIOS does assign a memory window to the bridge. * We therefore place the device at the start of the memory window. */ -static int ena_membase ( struct ena_nic *ena, struct pci_device *pci ) { +static int ena_membases ( struct ena_nic *ena, struct pci_device *pci, + unsigned long *prefmembase, + unsigned long *prefmemsize ) { struct pci_bridge *bridge; + /* Get on-device memory base address and size */ + *prefmembase = pci_bar_start ( pci, ENA_MEM_BAR ); + *prefmemsize = pci_bar_size ( pci, ENA_MEM_BAR ); + + /* Do nothing if addresses are already assigned */ + if ( pci->membase && ( *prefmembase || ( ! *prefmemsize ) ) ) + return 0; + /* Locate PCI bridge */ bridge = pcibridge_find ( pci ); if ( ! bridge ) { DBGC ( ena, "ENA %p found no PCI bridge\n", ena ); return -ENOTCONN; } + DBGC ( ena, "ENA %p at " PCI_FMT " claiming bridge " PCI_FMT "\n", + ena, PCI_ARGS ( pci ), PCI_ARGS ( bridge->pci ) ); /* Sanity check */ if ( PCI_SLOT ( pci->busdevfn ) || PCI_FUNC ( pci->busdevfn ) ) { @@ -1123,12 +1137,21 @@ static int ena_membase ( struct ena_nic *ena, struct pci_device *pci ) { return -ENOTSUP; } - /* Place device at start of memory window */ - pci_bar_set ( pci, PCI_BASE_ADDRESS_0, bridge->membase ); - pci->membase = bridge->membase; - DBGC ( ena, "ENA %p at " PCI_FMT " claiming bridge " PCI_FMT " mem " - "%08x\n", ena, PCI_ARGS ( pci ), PCI_ARGS ( bridge->pci ), - bridge->membase ); + /* Place register BAR at start of memory window, if applicable */ + if ( ! pci->membase ) { + pci_bar_set ( pci, ENA_REGS_BAR, bridge->membase ); + pci->membase = bridge->membase; + DBGC ( ena, "ENA %p at " PCI_FMT " claiming mem %08lx\n", + ena, PCI_ARGS ( pci ), pci->membase ); + } + + /* Place memory BAR at start of prefetchable window, if applicable */ + if ( *prefmemsize && ( ! *prefmembase ) ) { + pci_bar_set ( pci, ENA_MEM_BAR, bridge->prefmembase ); + *prefmembase = bridge->prefmembase; + DBGC ( ena, "ENA %p at " PCI_FMT " claiming prefmem %08lx\n", + ena, PCI_ARGS ( pci ), *prefmembase ); + } return 0; } @@ -1143,6 +1166,8 @@ static int ena_probe ( struct pci_device *pci ) { struct net_device *netdev; struct ena_nic *ena; struct ena_host_info *info; + unsigned long prefmembase; + unsigned long prefmemsize; int rc; /* Allocate and initialise net device */ @@ -1170,14 +1195,27 @@ static int ena_probe ( struct pci_device *pci ) { adjust_pci_device ( pci ); /* Fix up PCI BAR if left unassigned by BIOS */ - if ( ( ! pci->membase ) && ( ( rc = ena_membase ( ena, pci ) ) != 0 ) ) - goto err_membase; + if ( ( rc = ena_membases ( ena, pci, &prefmembase, + &prefmemsize ) ) != 0 ) { + goto err_membases; + } /* Map registers */ - ena->regs = pci_ioremap ( pci, pci->membase, ENA_BAR_SIZE ); + ena->regs = pci_ioremap ( pci, pci->membase, ENA_REGS_SIZE ); if ( ! ena->regs ) { rc = -ENODEV; - goto err_ioremap; + goto err_regs; + } + + /* Map device memory */ + if ( prefmemsize ) { + ena->mem = pci_ioremap ( pci, prefmembase, prefmemsize ); + if ( ! ena->mem ) { + rc = -ENODEV; + goto err_mem; + } + DBGC ( ena, "ENA %p has %ldkB of on-device memory\n", + ena, ( prefmemsize >> 10 ) ); } /* Allocate and initialise host info */ @@ -1242,9 +1280,12 @@ static int ena_probe ( struct pci_device *pci ) { err_reset: free_phys ( ena->info, PAGE_SIZE ); err_info: + if ( ena->mem ) + iounmap ( ena->mem ); + err_mem: iounmap ( ena->regs ); - err_ioremap: - err_membase: + err_regs: + err_membases: netdev_nullify ( netdev ); netdev_put ( netdev ); err_alloc: @@ -1275,8 +1316,12 @@ static void ena_remove ( struct pci_device *pci ) { /* Free host info */ free_phys ( ena->info, PAGE_SIZE ); - /* Free network device */ + /* Unmap registers and on-device memory */ + if ( ena->mem ) + iounmap ( ena->mem ); iounmap ( ena->regs ); + + /* Free network device */ netdev_nullify ( netdev ); netdev_put ( netdev ); } diff --git a/src/drivers/net/ena.h b/src/drivers/net/ena.h index 9fda9979f..b5ec6d0bf 100644 --- a/src/drivers/net/ena.h +++ b/src/drivers/net/ena.h @@ -12,8 +12,14 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include -/** BAR size */ -#define ENA_BAR_SIZE 16384 +/** Register BAR */ +#define ENA_REGS_BAR PCI_BASE_ADDRESS_0 + +/** Register BAR size */ +#define ENA_REGS_SIZE 16384 + +/** On-device memory BAR */ +#define ENA_MEM_BAR PCI_BASE_ADDRESS_2 /** Queue alignment */ #define ENA_ALIGN 4096 @@ -743,6 +749,8 @@ struct ena_qp { struct ena_nic { /** Registers */ void *regs; + /** On-device memory */ + void *mem; /** Host info */ struct ena_host_info *info; /** Admin queue */ -- cgit v1.2.3-55-g7522 From e5e371f485bfd10c45a96859aa4aaf91007d570b Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 16 Oct 2025 16:31:03 +0100 Subject: [ena] Cancel uncompleted transmit buffers on close Avoid spurious assertion failures by ensuring that references to uncompleted transmit buffers are not retained after the device has been closed. Signed-off-by: Michael Brown --- src/drivers/net/ena.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/ena.c b/src/drivers/net/ena.c index 51375e47f..c6b08acbe 100644 --- a/src/drivers/net/ena.c +++ b/src/drivers/net/ena.c @@ -859,12 +859,32 @@ static void ena_refill_rx ( struct net_device *netdev ) { * @v ena ENA device */ static void ena_empty_rx ( struct ena_nic *ena ) { + struct io_buffer *iobuf; unsigned int i; for ( i = 0 ; i < ENA_RX_COUNT ; i++ ) { - if ( ena->rx_iobuf[i] ) - free_iob ( ena->rx_iobuf[i] ); + iobuf = ena->rx_iobuf[i]; ena->rx_iobuf[i] = NULL; + if ( iobuf ) + free_iob ( iobuf ); + } +} + +/** + * Cancel uncompleted transmit I/O buffers + * + * @v netdev Network device + */ +static void ena_cancel_tx ( struct net_device *netdev ) { + struct ena_nic *ena = netdev->priv; + struct io_buffer *iobuf; + unsigned int i; + + for ( i = 0 ; i < ENA_TX_COUNT ; i++ ) { + iobuf = ena->tx_iobuf[i]; + ena->tx_iobuf[i] = NULL; + if ( iobuf ) + netdev_tx_complete_err ( netdev, iobuf, -ECANCELED ); } } @@ -917,6 +937,9 @@ static void ena_close ( struct net_device *netdev ) { /* Destroy transmit queue pair */ ena_destroy_qp ( ena, &ena->tx ); + + /* Cancel any uncompleted transmit buffers */ + ena_cancel_tx ( netdev ); } /** -- cgit v1.2.3-55-g7522 From 0d15d7f0a52341cf75245d45a7e71cf03500034c Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 16 Oct 2025 15:53:47 +0100 Subject: [ena] Record supported device features Signed-off-by: Michael Brown --- src/drivers/net/ena.c | 6 ++++-- src/drivers/net/ena.h | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/ena.c b/src/drivers/net/ena.c index c6b08acbe..ebaeeb748 100644 --- a/src/drivers/net/ena.c +++ b/src/drivers/net/ena.c @@ -707,9 +707,11 @@ static int ena_get_device_attributes ( struct net_device *netdev ) { memcpy ( netdev->hw_addr, feature->device.mac, ETH_ALEN ); netdev->max_pkt_len = le32_to_cpu ( feature->device.mtu ); netdev->mtu = ( netdev->max_pkt_len - ETH_HLEN ); + ena->features = le32_to_cpu ( feature->device.features ); - DBGC ( ena, "ENA %p MAC %s MTU %zd\n", - ena, eth_ntoa ( netdev->hw_addr ), netdev->max_pkt_len ); + DBGC ( ena, "ENA %p MAC %s MTU %zd features %#08x\n", + ena, eth_ntoa ( netdev->hw_addr ), netdev->max_pkt_len, + ena->features ); return 0; } diff --git a/src/drivers/net/ena.h b/src/drivers/net/ena.h index b5ec6d0bf..2e549bdb5 100644 --- a/src/drivers/net/ena.h +++ b/src/drivers/net/ena.h @@ -751,6 +751,8 @@ struct ena_nic { void *regs; /** On-device memory */ void *mem; + /** Device features */ + uint32_t features; /** Host info */ struct ena_host_info *info; /** Admin queue */ -- cgit v1.2.3-55-g7522 From c1badf71ca22f94277873ebc6171bfa41a50e378 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 16 Oct 2025 15:58:23 +0100 Subject: [ena] Add support for low latency transmit queues Newer generations of the ENA hardware require the use of low latency transmit queues, where the submission queues and the initial portion of the transmitted packet are written to on-device memory via BAR2 instead of being read from host memory. Detect support for low latency queues and set the placement policy appropriately. We attempt the use of low latency queues only if the device reports that it supports inline headers, 128-byte entries, and two descriptors prior to the inlined header, on the basis that we don't care about using low latency queues on older versions of the hardware since those versions will support normal host memory submission queues anyway. We reuse the redundant memory allocated for the submission queue as the bounce buffer for constructing the descriptors and inlined packet data, since this avoids needing a separate allocation just for the bounce buffer. We construct a metadata submission queue entry prior to the actual submission queue entry, since experimentation suggests that newer generations of the hardware require this to be present even though it conveys no information beyond its own existence. Signed-off-by: Michael Brown --- src/drivers/net/ena.c | 172 +++++++++++++++++++++++++++++++++++++++++++++++--- src/drivers/net/ena.h | 108 ++++++++++++++++++++++++++++--- 2 files changed, 263 insertions(+), 17 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/ena.c b/src/drivers/net/ena.c index ebaeeb748..b90a57c07 100644 --- a/src/drivers/net/ena.c +++ b/src/drivers/net/ena.c @@ -450,6 +450,7 @@ static int ena_create_sq ( struct ena_nic *ena, struct ena_sq *sq, union ena_aq_req *req; union ena_acq_rsp *rsp; unsigned int i; + size_t llqe; int rc; /* Allocate submission queue entries */ @@ -464,8 +465,7 @@ static int ena_create_sq ( struct ena_nic *ena, struct ena_sq *sq, req = ena_admin_req ( ena ); req->header.opcode = ENA_CREATE_SQ; req->create_sq.direction = sq->direction; - req->create_sq.policy = cpu_to_le16 ( ENA_SQ_HOST_MEMORY | - ENA_SQ_CONTIGUOUS ); + req->create_sq.policy = cpu_to_le16 ( sq->policy ); req->create_sq.cq_id = cpu_to_le16 ( cq->id ); req->create_sq.count = cpu_to_le16 ( sq->count ); req->create_sq.address = cpu_to_le64 ( virt_to_bus ( sq->sqe.raw ) ); @@ -480,6 +480,14 @@ static int ena_create_sq ( struct ena_nic *ena, struct ena_sq *sq, /* Parse response */ sq->id = le16_to_cpu ( rsp->create_sq.id ); sq->doorbell = le32_to_cpu ( rsp->create_sq.doorbell ); + llqe = le32_to_cpu ( rsp->create_sq.llqe ); + if ( sq->policy & ENA_SQ_DEVICE_MEMORY ) { + assert ( ena->mem != NULL ); + assert ( sq->len >= sizeof ( *sq->sqe.llq ) ); + sq->llqe = ( ena->mem + llqe ); + } else { + sq->llqe = NULL; + } /* Reset producer counter and phase */ sq->prod = 0; @@ -494,10 +502,16 @@ static int ena_create_sq ( struct ena_nic *ena, struct ena_sq *sq, for ( i = 0 ; i < sq->count ; i++ ) sq->ids[i] = i; - DBGC ( ena, "ENA %p %s SQ%d at [%08lx,%08lx) fill %d db +%04x CQ%d\n", - ena, ena_direction ( sq->direction ), sq->id, - virt_to_phys ( sq->sqe.raw ), - ( virt_to_phys ( sq->sqe.raw ) + sq->len ), + DBGC ( ena, "ENA %p %s SQ%d at ", + ena, ena_direction ( sq->direction ), sq->id ); + if ( sq->policy & ENA_SQ_DEVICE_MEMORY ) { + DBGC ( ena, "LLQ [+%08zx,+%08zx)", llqe, + ( llqe + ( sq->count * sizeof ( sq->sqe.llq[0] ) ) ) ); + } else { + DBGC ( ena, "[%08lx,%08lx)", virt_to_phys ( sq->sqe.raw ), + ( virt_to_phys ( sq->sqe.raw ) + sq->len ) ); + } + DBGC ( ena, " fill %d db +%04x CQ%d\n", sq->fill, sq->doorbell, cq->id ); return 0; @@ -744,6 +758,101 @@ static int ena_set_host_attributes ( struct ena_nic *ena ) { return 0; } +/** + * Configure low latency queues + * + * @v ena ENA device + * @ret rc Return status code + */ +static int ena_llq_config ( struct ena_nic *ena ) { + union ena_aq_req *req; + union ena_acq_rsp *rsp; + union ena_feature *feature; + uint16_t header; + uint16_t size; + uint16_t desc; + uint16_t stride; + uint16_t mode; + int rc; + + /* Construct request */ + req = ena_admin_req ( ena ); + req->header.opcode = ENA_GET_FEATURE; + req->get_feature.id = ENA_LLQ_CONFIG; + + /* Issue request */ + if ( ( rc = ena_admin ( ena, req, &rsp ) ) != 0 ) { + DBGC ( ena, "ENA %p could not get LLQ configuration: %s\n", + ena, strerror ( rc ) ); + return rc; + } + + /* Parse response */ + feature = &rsp->get_feature.feature; + header = le16_to_cpu ( feature->llq.header.supported ); + size = le16_to_cpu ( feature->llq.size.supported ); + desc = le16_to_cpu ( feature->llq.desc.supported ); + stride = le16_to_cpu ( feature->llq.stride.supported ); + mode = le16_to_cpu ( feature->llq.mode ); + DBGC ( ena, "ENA %p LLQ supports %02x:%02x:%02x:%02x:%02x with %dx%d " + "entries\n", ena, header, size, desc, stride, mode, + le32_to_cpu ( feature->llq.queues ), + le32_to_cpu ( feature->llq.count ) ); + + /* Check for a supported configuration */ + if ( ! feature->llq.queues ) { + DBGC ( ena, "ENA %p LLQ has no queues\n", ena ); + return -ENOTSUP; + } + if ( ! ( header & ENA_LLQ_HEADER_INLINE ) ) { + DBGC ( ena, "ENA %p LLQ does not support inline headers\n", + ena ); + return -ENOTSUP; + } + if ( ! ( size & ENA_LLQ_SIZE_128 ) ) { + DBGC ( ena, "ENA %p LLQ does not support 128-byte entries\n", + ena ); + return -ENOTSUP; + } + if ( ! ( desc & ENA_LLQ_DESC_2 ) ) { + DBGC ( ena, "ENA %p LLQ does not support two-descriptor " + "entries\n", ena ); + return -ENOTSUP; + } + + /* Enable a minimal configuration */ + header = ENA_LLQ_HEADER_INLINE; + size = ENA_LLQ_SIZE_128; + desc = ENA_LLQ_DESC_2; + stride &= ( -stride ); /* Don't care: use first supported option */ + DBGC ( ena, "ENA %p LLQ enabling %02x:%02x:%02x:%02x:%02x\n", + ena, header, size, desc, stride, mode ); + + /* Construct request */ + req = ena_admin_req ( ena ); + req->header.opcode = ENA_SET_FEATURE; + req->set_feature.id = ENA_LLQ_CONFIG; + feature = &req->set_feature.feature; + feature->llq.header.enabled = cpu_to_le16 ( header ); + feature->llq.size.enabled = cpu_to_le16 ( size ); + feature->llq.desc.enabled = cpu_to_le16 ( desc ); + feature->llq.stride.enabled = cpu_to_le16 ( stride ); + feature->llq.mode = cpu_to_le16 ( mode ); + + /* Issue request */ + if ( ( rc = ena_admin ( ena, req, &rsp ) ) != 0 ) { + DBGC ( ena, "ENA %p could not set LLQ configuration: %s\n", + ena, strerror ( rc ) ); + return rc; + } + + /* Use on-device memory for transmit queue */ + ena->tx.sq.policy |= ENA_SQ_DEVICE_MEMORY; + ena->tx.sq.inlined = sizeof ( ena->tx.sq.sqe.llq->inlined ); + + return 0; +} + /** * Get statistics (for debugging) * @@ -954,9 +1063,15 @@ static void ena_close ( struct net_device *netdev ) { static int ena_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) { struct ena_nic *ena = netdev->priv; struct ena_tx_sqe *sqe; + struct ena_tx_llqe *llqe; + const uint64_t *src; + uint64_t *dest; physaddr_t address; unsigned int index; unsigned int id; + unsigned int i; + uint8_t flags; + size_t inlined; size_t len; /* Get next submission queue entry */ @@ -968,17 +1083,50 @@ static int ena_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) { sqe = &ena->tx.sq.sqe.tx[index]; id = ena->tx_ids[index]; - /* Construct submission queue entry */ + /* Construct submission queue entry values */ address = virt_to_bus ( iobuf->data ); len = iob_len ( iobuf ); + inlined = ena->tx.sq.inlined; + if ( inlined > len ) + inlined = len; + len -= inlined; + address += inlined; + flags = ( ENA_SQE_FIRST | ENA_SQE_LAST | ENA_SQE_CPL | + ena->tx.sq.phase ); + + /* Prepare low-latency queue bounce buffer, if applicable */ + llqe = ena->tx.sq.sqe.llq; + if ( ena->tx.sq.llqe ) { + + /* Construct zero-information metadata queue entry */ + llqe->meta.meta = ENA_TX_SQE_META; + llqe->meta.flags = ( flags & ~( ENA_SQE_LAST | ENA_SQE_CPL ) ); + + /* Copy inlined data */ + memcpy ( llqe->inlined, iobuf->data, inlined ); + + /* Place submission queue entry within bounce buffer */ + sqe = &llqe->sqe; + flags &= ~ENA_SQE_FIRST; + } + + /* Construct submission queue entry */ sqe->len = cpu_to_le16 ( len ); sqe->id = cpu_to_le16 ( id ); sqe->address = cpu_to_le64 ( address ); + sqe->inlined = inlined; wmb(); - sqe->flags = ( ENA_SQE_FIRST | ENA_SQE_LAST | ENA_SQE_CPL | - ena->tx.sq.phase ); + sqe->flags = flags; wmb(); + /* Copy bounce buffer to on-device memory, if applicable */ + if ( ena->tx.sq.llqe ) { + src = ( ( const void * ) llqe ); + dest = ( ena->tx.sq.llqe + ( index * sizeof ( *llqe ) ) ); + for ( i = 0 ; i < ( sizeof ( *llqe ) / sizeof ( *src ) ); i++ ) + writeq ( *(src++), dest++ ); + } + /* Increment producer counter */ ena->tx.sq.prod++; if ( ( ena->tx.sq.prod % ENA_TX_COUNT ) == 0 ) @@ -1282,6 +1430,12 @@ static int ena_probe ( struct pci_device *pci ) { if ( ( rc = ena_get_device_attributes ( netdev ) ) != 0 ) goto err_get_device_attributes; + /* Attempt to configure low latency queues, if applicable. + * Ignore any errors and continue without using LLQs. + */ + if ( ena->mem && ( ena->features & ENA_FEATURE_LLQ ) ) + ena_llq_config ( ena ); + /* Register network device */ if ( ( rc = register_netdev ( netdev ) ) != 0 ) goto err_register_netdev; diff --git a/src/drivers/net/ena.h b/src/drivers/net/ena.h index 2e549bdb5..cfdee5e52 100644 --- a/src/drivers/net/ena.h +++ b/src/drivers/net/ena.h @@ -145,6 +145,62 @@ struct ena_device_attributes { uint32_t mtu; } __attribute__ (( packed )); +/** Device supports low latency queues */ +#define ENA_FEATURE_LLQ 0x00000010 + +/** Low latency queue config */ +#define ENA_LLQ_CONFIG 4 + +/** A low latency queue option */ +struct ena_llq_option { + /** Bitmask of supported option values */ + uint16_t supported; + /** Single-entry bitmask of the enabled option value */ + uint16_t enabled; +} __attribute__ (( packed )); + +/** Low latency queue config */ +struct ena_llq_config { + /** Maximum number of low latency queues */ + uint32_t queues; + /** Maximum queue depth */ + uint32_t count; + /** Header locations */ + struct ena_llq_option header; + /** Entry sizes */ + struct ena_llq_option size; + /** Descriptor counts */ + struct ena_llq_option desc; + /** Descriptor strides */ + struct ena_llq_option stride; + /** Reserved */ + uint8_t reserved_a[4]; + /** Acceleration mode */ + uint16_t mode; + /** Maximum burst size */ + uint16_t burst; + /** Reserved */ + uint8_t reserved_b[4]; +} __attribute__ (( packed )); + +/** Low latency queue header locations */ +enum ena_llq_header { + /** Headers are placed inline immediately after descriptors */ + ENA_LLQ_HEADER_INLINE = 0x0001, +}; + +/** Low latency queue entry sizes */ +enum ena_llq_size { + /** Entries are 128 bytes */ + ENA_LLQ_SIZE_128 = 0x0001, +}; + +/** Low latency queue descriptor count */ +enum ena_llq_desc { + /** Two descriptors before inline headers */ + ENA_LLQ_DESC_2 = 0x0002, +}; + /** Async event notification queue config */ #define ENA_AENQ_CONFIG 26 @@ -237,6 +293,8 @@ struct ena_host_info { union ena_feature { /** Device attributes */ struct ena_device_attributes device; + /** Low latency queue configuration */ + struct ena_llq_config llq; /** Async event notification queue config */ struct ena_aenq_config aenq; /** Host attributes */ @@ -280,6 +338,8 @@ struct ena_create_sq_req { enum ena_sq_policy { /** Use host memory */ ENA_SQ_HOST_MEMORY = 0x0001, + /** Use on-device memory (must be used in addition to host memory) */ + ENA_SQ_DEVICE_MEMORY = 0x0002, /** Memory is contiguous */ ENA_SQ_CONTIGUOUS = 0x0100, }; @@ -291,13 +351,13 @@ struct ena_create_sq_rsp { /** Submission queue identifier */ uint16_t id; /** Reserved */ - uint8_t reserved[2]; + uint8_t reserved_a[2]; /** Doorbell register offset */ uint32_t doorbell; /** LLQ descriptor ring offset */ - uint32_t llq_desc; - /** LLQ header offset */ - uint32_t llq_data; + uint32_t llqe; + /** Reserved */ + uint8_t reserved_b[4]; } __attribute__ (( packed )); /** Destroy submission queue */ @@ -563,18 +623,31 @@ struct ena_aenq { struct ena_tx_sqe { /** Length */ uint16_t len; - /** Reserved */ - uint8_t reserved_a; + /** Metadata flags */ + uint8_t meta; /** Flags */ uint8_t flags; /** Reserved */ uint8_t reserved_b[3]; /** Request identifier */ uint8_t id; - /** Address */ - uint64_t address; + /** Address and inlined length */ + union { + /** Address */ + uint64_t address; + /** Inlined length */ + struct { + /** Reserved */ + uint8_t reserved[7]; + /** Inlined length */ + uint8_t inlined; + } __attribute__ (( packed )); + } __attribute__ (( packed )); } __attribute__ (( packed )); +/** This is a metadata entry */ +#define ENA_TX_SQE_META 0x80 + /** Receive submission queue entry */ struct ena_rx_sqe { /** Length */ @@ -637,6 +710,16 @@ struct ena_rx_cqe { /** Completion queue ownership phase flag */ #define ENA_CQE_PHASE 0x01 +/** Low latency transmit queue bounce buffer */ +struct ena_tx_llqe { + /** Pointless metadata descriptor */ + struct ena_tx_sqe meta; + /** Transmit descriptor */ + struct ena_tx_sqe sqe; + /** Inlined header data */ + uint8_t inlined[96]; +} __attribute__ (( packed )); + /** Submission queue */ struct ena_sq { /** Entries */ @@ -645,11 +728,15 @@ struct ena_sq { struct ena_tx_sqe *tx; /** Receive submission queue entries */ struct ena_rx_sqe *rx; + /** Low latency queue bounce buffer */ + struct ena_tx_llqe *llq; /** Raw data */ void *raw; } sqe; /** Buffer IDs */ uint8_t *ids; + /** Low latency queue base */ + void *llqe; /** Doorbell register offset */ unsigned int doorbell; /** Total length of entries */ @@ -658,6 +745,8 @@ struct ena_sq { unsigned int prod; /** Phase */ unsigned int phase; + /** Queue policy */ + uint16_t policy; /** Submission queue identifier */ uint16_t id; /** Direction */ @@ -668,6 +757,8 @@ struct ena_sq { uint8_t max; /** Fill level (limited to completion queue size) */ uint8_t fill; + /** Maximum inline header length */ + uint8_t inlined; }; /** @@ -685,6 +776,7 @@ ena_sq_init ( struct ena_sq *sq, unsigned int direction, unsigned int count, unsigned int max, size_t size, uint8_t *ids ) { sq->len = ( count * size ); + sq->policy = ( ENA_SQ_HOST_MEMORY | ENA_SQ_CONTIGUOUS ); sq->direction = direction; sq->count = count; sq->max = max; -- cgit v1.2.3-55-g7522 From c296747d0e87d2d72cb13357430d6b9a8e4b5969 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 16 Oct 2025 16:33:38 +0100 Subject: [ena] Increase receive fill level Experiments suggest that at least some instance types (observed with c6i.large in eu-west-2) experience high packet drop rates with only 16 receive buffers allocated. Increase the fill level to 32 buffers. Signed-off-by: Michael Brown --- src/drivers/net/ena.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/drivers') diff --git a/src/drivers/net/ena.h b/src/drivers/net/ena.h index cfdee5e52..b1150d1a0 100644 --- a/src/drivers/net/ena.h +++ b/src/drivers/net/ena.h @@ -40,7 +40,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define ENA_RX_COUNT 128 /** Receive queue maximum fill level */ -#define ENA_RX_FILL 16 +#define ENA_RX_FILL 32 /** Base address low register offset */ #define ENA_BASE_LO 0x0 -- cgit v1.2.3-55-g7522 From 0ae5e25de2f8490c7be85a441ae7d7537d9b7445 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 17 Oct 2025 12:34:03 +0100 Subject: [ena] Add memory barrier after writing to on-device memory Ensure that writes to on-device memory have taken place before writing to the doorbell register. Signed-off-by: Michael Brown --- src/drivers/net/ena.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/drivers') diff --git a/src/drivers/net/ena.c b/src/drivers/net/ena.c index b90a57c07..5dd0ef23e 100644 --- a/src/drivers/net/ena.c +++ b/src/drivers/net/ena.c @@ -1125,6 +1125,7 @@ static int ena_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) { dest = ( ena->tx.sq.llqe + ( index * sizeof ( *llqe ) ) ); for ( i = 0 ; i < ( sizeof ( *llqe ) / sizeof ( *src ) ); i++ ) writeq ( *(src++), dest++ ); + wmb(); } /* Increment producer counter */ -- cgit v1.2.3-55-g7522 From 846c505ae9ad0b95494759d50ae015a52eb0a2f2 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 17 Oct 2025 13:24:16 +0100 Subject: [ena] Increase transmit queue size to match receive fill level Avoid running out of transmit descriptors when sending TCP ACKs by increasing the transmit queue size to match the increased received fill level. Signed-off-by: Michael Brown --- src/drivers/net/ena.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/drivers') diff --git a/src/drivers/net/ena.h b/src/drivers/net/ena.h index b1150d1a0..5008b966a 100644 --- a/src/drivers/net/ena.h +++ b/src/drivers/net/ena.h @@ -34,7 +34,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define ENA_AENQ_COUNT 2 /** Number of transmit queue entries */ -#define ENA_TX_COUNT 16 +#define ENA_TX_COUNT 32 /** Number of receive queue entries */ #define ENA_RX_COUNT 128 -- cgit v1.2.3-55-g7522 From b2e8468219ca2c44bfef3b62f16bbfbd938eb8eb Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 17 Oct 2025 12:35:11 +0100 Subject: [ena] Limit receive queue size to work around hardware bugs Commit a801244 ("[ena] Increase receive ring size to 128 entries") increased the receive ring size to 128 entries (while leaving the fill level at 16), since using a smaller receive ring caused unexplained failures on some instance types. The original hardware bug that resulted in that commit seems to have been fixed: experiments suggest that the original failure (observed on a c6i.large instance in eu-west-2) will no longer reproduce when using a receive ring containing only 16 entries (as was the case prior to that commit). Newer generations of the ENA hardware (observed on an m8i.large instance in eu-south-2) seem to have a new and exciting hardware bug: these instance types appear to use a hash of the received packet header to determine which portion of the (out-of-order) receive ring to use. If that portion of the ring happens to be empty (e.g. because only 32 entries of the 128-entry ring are filled at any one time), then the packet will be silently dropped. Work around this new hardware bug by reducing the receive ring size down to the current fill level of 32 entries. This appears to work on all current instance types (but has not been exhaustively tested). Signed-off-by: Michael Brown --- src/drivers/net/ena.c | 6 +++--- src/drivers/net/ena.h | 11 ++--------- 2 files changed, 5 insertions(+), 12 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/net/ena.c b/src/drivers/net/ena.c index 5dd0ef23e..35bdd34c2 100644 --- a/src/drivers/net/ena.c +++ b/src/drivers/net/ena.c @@ -494,7 +494,7 @@ static int ena_create_sq ( struct ena_nic *ena, struct ena_sq *sq, sq->phase = ENA_SQE_PHASE; /* Calculate fill level */ - sq->fill = sq->max; + sq->fill = sq->count; if ( sq->fill > cq->actual ) sq->fill = cq->actual; @@ -1358,11 +1358,11 @@ static int ena_probe ( struct pci_device *pci ) { ena->acq.phase = ENA_ACQ_PHASE; ena_cq_init ( &ena->tx.cq, ENA_TX_COUNT, sizeof ( ena->tx.cq.cqe.tx[0] ) ); - ena_sq_init ( &ena->tx.sq, ENA_SQ_TX, ENA_TX_COUNT, ENA_TX_COUNT, + ena_sq_init ( &ena->tx.sq, ENA_SQ_TX, ENA_TX_COUNT, sizeof ( ena->tx.sq.sqe.tx[0] ), ena->tx_ids ); ena_cq_init ( &ena->rx.cq, ENA_RX_COUNT, sizeof ( ena->rx.cq.cqe.rx[0] ) ); - ena_sq_init ( &ena->rx.sq, ENA_SQ_RX, ENA_RX_COUNT, ENA_RX_FILL, + ena_sq_init ( &ena->rx.sq, ENA_SQ_RX, ENA_RX_COUNT, sizeof ( ena->rx.sq.sqe.rx[0] ), ena->rx_ids ); /* Fix up PCI device */ diff --git a/src/drivers/net/ena.h b/src/drivers/net/ena.h index 5008b966a..240e64480 100644 --- a/src/drivers/net/ena.h +++ b/src/drivers/net/ena.h @@ -37,10 +37,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define ENA_TX_COUNT 32 /** Number of receive queue entries */ -#define ENA_RX_COUNT 128 - -/** Receive queue maximum fill level */ -#define ENA_RX_FILL 32 +#define ENA_RX_COUNT 32 /** Base address low register offset */ #define ENA_BASE_LO 0x0 @@ -753,8 +750,6 @@ struct ena_sq { uint8_t direction; /** Number of entries */ uint8_t count; - /** Maximum fill level */ - uint8_t max; /** Fill level (limited to completion queue size) */ uint8_t fill; /** Maximum inline header length */ @@ -767,19 +762,17 @@ struct ena_sq { * @v sq Submission queue * @v direction Direction * @v count Number of entries - * @v max Maximum fill level * @v size Size of each entry * @v ids Buffer IDs */ static inline __attribute__ (( always_inline )) void ena_sq_init ( struct ena_sq *sq, unsigned int direction, unsigned int count, - unsigned int max, size_t size, uint8_t *ids ) { + size_t size, uint8_t *ids ) { sq->len = ( count * size ); sq->policy = ( ENA_SQ_HOST_MEMORY | ENA_SQ_CONTIGUOUS ); sq->direction = direction; sq->count = count; - sq->max = max; sq->ids = ids; } -- cgit v1.2.3-55-g7522 From 0336e2987c3e671298af8c2817ec17aa67e98065 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 27 Oct 2025 12:41:36 +0000 Subject: [ena] Leave queue base address empty when creating a low latency queue The queue base address is meaningless for a low latency queue, since the queue entries are written directly to the on-device memory. Any non-zero queue base address will be safely ignored by the hardware, but leaves open the possibility that future revisions could treat it as an error. Leave this field as zero, to match the behaviour of the Linux driver. Signed-off-by: Michael Brown --- src/drivers/net/ena.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/drivers') diff --git a/src/drivers/net/ena.c b/src/drivers/net/ena.c index 35bdd34c2..56984d142 100644 --- a/src/drivers/net/ena.c +++ b/src/drivers/net/ena.c @@ -468,7 +468,10 @@ static int ena_create_sq ( struct ena_nic *ena, struct ena_sq *sq, req->create_sq.policy = cpu_to_le16 ( sq->policy ); req->create_sq.cq_id = cpu_to_le16 ( cq->id ); req->create_sq.count = cpu_to_le16 ( sq->count ); - req->create_sq.address = cpu_to_le64 ( virt_to_bus ( sq->sqe.raw ) ); + if ( ! ( sq->policy & ENA_SQ_DEVICE_MEMORY ) ) { + req->create_sq.address = + cpu_to_le64 ( virt_to_bus ( sq->sqe.raw ) ); + } /* Issue request */ if ( ( rc = ena_admin ( ena, req, &rsp ) ) != 0 ) { -- cgit v1.2.3-55-g7522 From fde35ff003a610eca04db0e11fb81e8dfee8a681 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 29 Oct 2025 23:07:32 +0000 Subject: [pci] Disable decoding while setting a BAR value Setting the base address for a 64-bit BAR requires two separate 32-bit writes to configuration space, and so will necessarily result in the BAR temporarily holding an invalid partially written address. Some hypervisors (observed on an AWS EC2 c7a.medium instance in eu-west-2) will assume that guests will write BAR values only while decoding is disabled, and may not rebuild MMIO mappings for the guest if the BAR registers are written while decoding is enabled. The effect of this is that MMIO accesses are not routed through to the device even though inspection from within the guest shows that every single PCI configuration register has the correct value. Writes to the device will be ignored, and reads will return the all-ones pattern that typically indicates a nonexistent device. With the ENA network driver now using low latency transmit queues, this results in the transmit descriptors being lost (since the MMIO writes to BAR2 never reach the device), which in turn causes the device to lock up as soon as the transmit doorbell is rung for the first time. Fix by disabling decoding of memory and I/O cycles while setting a BAR address (as we already do while sizing a BAR), so that the invalid partial address can never be decoded and so that hypervisors will rebuild MMIO mappings as expected. Signed-off-by: Michael Brown --- src/drivers/bus/pci.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/drivers') diff --git a/src/drivers/bus/pci.c b/src/drivers/bus/pci.c index f3ea6d478..43ccb751d 100644 --- a/src/drivers/bus/pci.c +++ b/src/drivers/bus/pci.c @@ -116,6 +116,13 @@ void pci_bar_set ( struct pci_device *pci, unsigned int reg, unsigned int type; uint32_t low; uint32_t high; + uint16_t cmd; + + /* Save the original command register and disable decoding */ + pci_read_config_word ( pci, PCI_COMMAND, &cmd ); + pci_write_config_word ( pci, PCI_COMMAND, + ( cmd & ~( PCI_COMMAND_MEM | + PCI_COMMAND_IO ) ) ); /* Check for a 64-bit BAR */ pci_read_config_dword ( pci, reg, &low ); @@ -135,6 +142,9 @@ void pci_bar_set ( struct pci_device *pci, unsigned int reg, } pci_write_config_dword ( pci, reg + 4, high ); } + + /* Restore the original command register */ + pci_write_config_word ( pci, PCI_COMMAND, cmd ); } /** -- cgit v1.2.3-55-g7522 From 08d4d7fe9db04c8f44ac063d4b722fb3e8f3fffe Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 5 Nov 2025 12:16:22 +0000 Subject: [uart] Make baud rate a property of the UART Make the current baud rate (if specified) a property of the UART, to allow the default_serial_console() function to specify the default baud rate as well as the default UART device. Signed-off-by: Michael Brown --- src/core/gdbserial.c | 4 +++- src/core/serial.c | 14 ++++++++++---- src/core/uart.c | 3 +-- src/drivers/uart/ns16550.c | 7 +++---- src/include/ipxe/uart.h | 11 ++++++----- 5 files changed, 23 insertions(+), 16 deletions(-) (limited to 'src/drivers') diff --git a/src/core/gdbserial.c b/src/core/gdbserial.c index 0f74e5fe0..61add5d47 100644 --- a/src/core/gdbserial.c +++ b/src/core/gdbserial.c @@ -95,7 +95,9 @@ struct gdb_transport * gdbserial_configure ( const char *name, return NULL; uart_get ( gdbserial_uart ); - if ( ( rc = uart_init ( gdbserial_uart, baud ) ) != 0 ) + gdbserial_uart->baud = baud; + + if ( ( rc = uart_init ( gdbserial_uart ) ) != 0 ) return NULL; return &serial_gdb_transport; diff --git a/src/core/serial.c b/src/core/serial.c index f3b33cd90..34ae4a17b 100644 --- a/src/core/serial.c +++ b/src/core/serial.c @@ -74,8 +74,14 @@ struct uart *serial_console = NULL; * @ret uart Serial console UART, or NULL */ static struct uart * serial_comconsole ( void ) { + struct uart *uart = COMCONSOLE; + unsigned int baud = COMSPEED; - return COMCONSOLE; + /* Set default baud rate, if applicable */ + if ( uart && baud ) + uart->baud = baud; + + return uart; } /** @@ -154,9 +160,9 @@ static void serial_init ( void ) { return; /* Initialise UART */ - if ( ( rc = uart_init ( uart, COMSPEED ) ) != 0 ) { - DBGC ( uart, "SERIAL could not initialise %s baud %d: %s\n", - uart->name, COMSPEED, strerror ( rc ) ); + if ( ( rc = uart_init ( uart ) ) != 0 ) { + DBGC ( uart, "SERIAL could not initialise %s: %s\n", + uart->name, strerror ( rc ) ); return; } diff --git a/src/core/uart.c b/src/core/uart.c index a645bd398..5bff9fdd5 100644 --- a/src/core/uart.c +++ b/src/core/uart.c @@ -49,8 +49,7 @@ static uint8_t null_uart_receive ( struct uart *uart __unused ) { return 0; } -static int null_uart_init ( struct uart *uart __unused, - unsigned int baud __unused ) { +static int null_uart_init ( struct uart *uart __unused ) { return 0; } diff --git a/src/drivers/uart/ns16550.c b/src/drivers/uart/ns16550.c index 428771ab5..f00e834b4 100644 --- a/src/drivers/uart/ns16550.c +++ b/src/drivers/uart/ns16550.c @@ -115,10 +115,9 @@ static void ns16550_flush ( struct uart *uart ) { * Initialise UART * * @v uart UART - * @v baud Baud rate, or zero to leave unchanged * @ret rc Return status code */ -static int ns16550_init ( struct uart *uart, unsigned int baud ) { +static int ns16550_init ( struct uart *uart ) { struct ns16550_uart *ns16550 = uart->priv; uint8_t dlm; uint8_t dll; @@ -137,8 +136,8 @@ static int ns16550_init ( struct uart *uart, unsigned int baud ) { /* Configure divisor and line control register, if applicable */ ns16550_write ( ns16550, NS16550_LCR, ( NS16550_LCR_8N1 | NS16550_LCR_DLAB ) ); - if ( baud ) { - ns16550->divisor = ( ( ns16550->clock / baud ) / + if ( uart->baud ) { + ns16550->divisor = ( ( ns16550->clock / uart->baud ) / NS16550_CLK_BIT ); dlm = ( ( ns16550->divisor >> 8 ) & 0xff ); dll = ( ( ns16550->divisor >> 0 ) & 0xff ); diff --git a/src/include/ipxe/uart.h b/src/include/ipxe/uart.h index 15adfa932..f2ecf3ce9 100644 --- a/src/include/ipxe/uart.h +++ b/src/include/ipxe/uart.h @@ -22,6 +22,9 @@ struct uart { /** List of registered UARTs */ struct list_head list; + /** Baud rate (if specified) */ + unsigned int baud; + /** UART operations */ struct uart_operations *op; /** Driver-private data */ @@ -56,10 +59,9 @@ struct uart_operations { * Initialise UART * * @v uart UART - * @v baud Baud rate, or zero to leave unchanged * @ret rc Return status code */ - int ( * init ) ( struct uart *uart, unsigned int baud ); + int ( * init ) ( struct uart *uart ); /** * Flush transmitted data * @@ -109,13 +111,12 @@ uart_receive ( struct uart *uart ) { * Initialise UART * * @v uart UART - * @v baud Baud rate, or zero to leave unchanged * @ret rc Return status code */ static inline __attribute__ (( always_inline )) int -uart_init ( struct uart *uart, unsigned int baud ) { +uart_init ( struct uart *uart ) { - return uart->op->init ( uart, baud ); + return uart->op->init ( uart ); } /** -- cgit v1.2.3-55-g7522 From ff1a17dc7e5d764b905559fdc623249741d173dd Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 24 Nov 2025 20:18:52 +0000 Subject: [pci] Use linker tables for runtime selectable PCI APIs Use the linker table mechanism to enumerate the underlying PCI I/O APIs, to allow PCIAPI_CLOUD to become architecture-independent code. Signed-off-by: Michael Brown --- src/arch/x86/core/pcidirect.c | 3 +- src/arch/x86/include/bits/pci_io.h | 1 - src/arch/x86/include/ipxe/pcibios.h | 2 - src/arch/x86/include/ipxe/pcicloud.h | 28 ---- src/arch/x86/include/ipxe/pcidirect.h | 2 - src/arch/x86/interface/pcbios/pcibios.c | 3 +- src/arch/x86/interface/pcbios/pcicloud.c | 269 ------------------------------- src/config/cloud/ioapi.h | 3 + src/config/config_pci.c | 11 ++ src/drivers/bus/ecam.c | 3 +- src/drivers/bus/pcicloud.c | 257 +++++++++++++++++++++++++++++ src/include/ipxe/ecam.h | 2 - src/include/ipxe/pci_io.h | 56 +++++-- src/include/ipxe/pcicloud.h | 28 ++++ 14 files changed, 342 insertions(+), 326 deletions(-) delete mode 100644 src/arch/x86/include/ipxe/pcicloud.h delete mode 100644 src/arch/x86/interface/pcbios/pcicloud.c create mode 100644 src/drivers/bus/pcicloud.c create mode 100644 src/include/ipxe/pcicloud.h (limited to 'src/drivers') diff --git a/src/arch/x86/core/pcidirect.c b/src/arch/x86/core/pcidirect.c index 90d4623b3..887b78a0b 100644 --- a/src/arch/x86/core/pcidirect.c +++ b/src/arch/x86/core/pcidirect.c @@ -54,5 +54,4 @@ PROVIDE_PCIAPI_INLINE ( direct, pci_write_config_byte ); PROVIDE_PCIAPI_INLINE ( direct, pci_write_config_word ); PROVIDE_PCIAPI_INLINE ( direct, pci_write_config_dword ); PROVIDE_PCIAPI_INLINE ( direct, pci_ioremap ); - -struct pci_api pcidirect_api = PCIAPI_RUNTIME ( direct ); +PROVIDE_PCIAPI_RUNTIME ( direct, PCIAPI_PRIORITY_DIRECT ); diff --git a/src/arch/x86/include/bits/pci_io.h b/src/arch/x86/include/bits/pci_io.h index a074d3370..b41e562ee 100644 --- a/src/arch/x86/include/bits/pci_io.h +++ b/src/arch/x86/include/bits/pci_io.h @@ -11,6 +11,5 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include -#include #endif /* _BITS_PCI_IO_H */ diff --git a/src/arch/x86/include/ipxe/pcibios.h b/src/arch/x86/include/ipxe/pcibios.h index ef9585654..87b403555 100644 --- a/src/arch/x86/include/ipxe/pcibios.h +++ b/src/arch/x86/include/ipxe/pcibios.h @@ -155,6 +155,4 @@ PCIAPI_INLINE ( pcbios, pci_ioremap ) ( struct pci_device *pci __unused, return ioremap ( bus_addr, len ); } -extern struct pci_api pcibios_api; - #endif /* _IPXE_PCIBIOS_H */ diff --git a/src/arch/x86/include/ipxe/pcicloud.h b/src/arch/x86/include/ipxe/pcicloud.h deleted file mode 100644 index 1feef56cb..000000000 --- a/src/arch/x86/include/ipxe/pcicloud.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _IPXE_PCICLOUD_H -#define _IPXE_PCICLOUD_H - -/** @file - * - * Cloud VM PCI configuration space access - * - */ - -FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); - -#ifdef PCIAPI_CLOUD -#define PCIAPI_PREFIX_cloud -#else -#define PCIAPI_PREFIX_cloud __cloud_ -#endif - -/** - * Check if PCI bus probing is allowed - * - * @ret ok Bus probing is allowed - */ -static inline __always_inline int -PCIAPI_INLINE ( cloud, pci_can_probe ) ( void ) { - return 1; -} - -#endif /* _IPXE_PCICLOUD_H */ diff --git a/src/arch/x86/include/ipxe/pcidirect.h b/src/arch/x86/include/ipxe/pcidirect.h index 999b52763..501576582 100644 --- a/src/arch/x86/include/ipxe/pcidirect.h +++ b/src/arch/x86/include/ipxe/pcidirect.h @@ -165,6 +165,4 @@ PCIAPI_INLINE ( direct, pci_ioremap ) ( struct pci_device *pci __unused, return ioremap ( bus_addr, len ); } -extern struct pci_api pcidirect_api; - #endif /* _PCIDIRECT_H */ diff --git a/src/arch/x86/interface/pcbios/pcibios.c b/src/arch/x86/interface/pcbios/pcibios.c index ebe40ba7d..6b88ee907 100644 --- a/src/arch/x86/interface/pcbios/pcibios.c +++ b/src/arch/x86/interface/pcbios/pcibios.c @@ -129,5 +129,4 @@ PROVIDE_PCIAPI_INLINE ( pcbios, pci_write_config_byte ); PROVIDE_PCIAPI_INLINE ( pcbios, pci_write_config_word ); PROVIDE_PCIAPI_INLINE ( pcbios, pci_write_config_dword ); PROVIDE_PCIAPI_INLINE ( pcbios, pci_ioremap ); - -struct pci_api pcibios_api = PCIAPI_RUNTIME ( pcbios ); +PROVIDE_PCIAPI_RUNTIME ( pcbios, PCIAPI_PRIORITY_PCBIOS ); diff --git a/src/arch/x86/interface/pcbios/pcicloud.c b/src/arch/x86/interface/pcbios/pcicloud.c deleted file mode 100644 index 284cd078c..000000000 --- a/src/arch/x86/interface/pcbios/pcicloud.c +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Copyright (C) 2022 Michael Brown . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - * - * You can also choose to distribute this program under the terms of - * the Unmodified Binary Distribution Licence (as given in the file - * COPYING.UBDL), provided that you have satisfied its requirements. - */ - -FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); - -#include -#include -#include -#include -#include -#include -#include - -/** @file - * - * Cloud VM PCI configuration space access - * - */ - -/** Underlying PCI configuration space access APIs */ -static struct pci_api *pcicloud_apis[] = { - &ecam_api, &pcibios_api, &pcidirect_api -}; - -/** Cached PCI configuration space access API */ -static struct { - /** PCI bus:dev.fn address range */ - struct pci_range range; - /** API for this bus:dev.fn address */ - struct pci_api *api; -} pcicloud; - -/** - * Find PCI configuration space access API for address - * - * @v busdevfn Starting PCI bus:dev.fn address - * @v range PCI bus:dev.fn address range to fill in - * @ret api Configuration space access API, or NULL - */ -static struct pci_api * pcicloud_find ( uint32_t busdevfn, - struct pci_range *range ) { - struct pci_range candidate; - struct pci_api *api; - uint32_t best = 0; - uint32_t index; - uint32_t first; - uint32_t last; - unsigned int i; - - /* Return empty range on error */ - range->count = 0; - - /* Try discovery via all known APIs */ - for ( i = 0 ; i < ( sizeof ( pcicloud_apis ) / - sizeof ( pcicloud_apis[0] ) ) ; i++ ) { - - /* Discover via this API */ - api = pcicloud_apis[i]; - api->pci_discover ( busdevfn, &candidate ); - - /* Check for a matching or new closest allocation */ - index = ( busdevfn - candidate.start ); - if ( ( index < candidate.count ) || ( index > best ) ) { - memcpy ( range, &candidate, sizeof ( *range ) ); - best = index; - } - - /* Stop if this range contains the target bus:dev.fn address */ - if ( index < candidate.count ) { - first = range->start; - last = ( range->start + range->count - 1 ); - DBGC ( &pcicloud, "PCICLOUD [" PCI_FMT "," PCI_FMT ") " - "using %s API\n", PCI_SEG ( first ), - PCI_BUS ( first ), PCI_SLOT ( first ), - PCI_FUNC ( first ), PCI_SEG ( last ), - PCI_BUS ( last ), PCI_SLOT ( last ), - PCI_FUNC ( last ), api->name ); - return api; - } - } - - return NULL; -} - -/** - * Find next PCI bus:dev.fn address range in system - * - * @v busdevfn Starting PCI bus:dev.fn address - * @v range PCI bus:dev.fn address range to fill in - */ -static void pcicloud_discover ( uint32_t busdevfn, struct pci_range *range ) { - - /* Find new range, if any */ - pcicloud_find ( busdevfn, range ); -} - -/** - * Find configuration space access API for PCI device - * - * @v pci PCI device - * @ret api Configuration space access API - */ -static struct pci_api * pcicloud_api ( struct pci_device *pci ) { - struct pci_range *range = &pcicloud.range; - struct pci_api *api; - uint32_t first; - uint32_t last; - - /* Reuse cached API if applicable */ - if ( ( pci->busdevfn - range->start ) < range->count ) - return pcicloud.api; - - /* Find highest priority API claiming this range */ - api = pcicloud_find ( pci->busdevfn, range ); - - /* Fall back to lowest priority API for any unclaimed gaps in ranges */ - if ( ! api ) { - api = pcicloud_apis[ ( sizeof ( pcicloud_apis ) / - sizeof ( pcicloud_apis[0] ) ) - 1 ]; - range->count = ( range->start - pci->busdevfn ); - range->start = pci->busdevfn; - first = range->start; - last = ( range->start + range->count - 1 ); - DBGC ( &pcicloud, "PCICLOUD [" PCI_FMT "," PCI_FMT ") falling " - "back to %s API\n", PCI_SEG ( first ), - PCI_BUS ( first ), PCI_SLOT ( first ), - PCI_FUNC ( first ), PCI_SEG ( last ), PCI_BUS ( last ), - PCI_SLOT ( last ), PCI_FUNC ( last ), api->name ); - } - - /* Cache API for this range */ - pcicloud.api = api; - - return api; -} - -/** - * Read byte from PCI configuration space - * - * @v pci PCI device - * @v where Location within PCI configuration space - * @v value Value read - * @ret rc Return status code - */ -static int pcicloud_read_config_byte ( struct pci_device *pci, - unsigned int where, uint8_t *value ) { - struct pci_api *api = pcicloud_api ( pci ); - - return api->pci_read_config_byte ( pci, where, value ); -} - -/** - * Read 16-bit word from PCI configuration space - * - * @v pci PCI device - * @v where Location within PCI configuration space - * @v value Value read - * @ret rc Return status code - */ -static int pcicloud_read_config_word ( struct pci_device *pci, - unsigned int where, uint16_t *value ) { - struct pci_api *api = pcicloud_api ( pci ); - - return api->pci_read_config_word ( pci, where, value ); -} - -/** - * Read 32-bit dword from PCI configuration space - * - * @v pci PCI device - * @v where Location within PCI configuration space - * @v value Value read - * @ret rc Return status code - */ -static int pcicloud_read_config_dword ( struct pci_device *pci, - unsigned int where, uint32_t *value ) { - struct pci_api *api = pcicloud_api ( pci ); - - return api->pci_read_config_dword ( pci, where, value ); -} - -/** - * Write byte to PCI configuration space - * - * @v pci PCI device - * @v where Location within PCI configuration space - * @v value Value to be written - * @ret rc Return status code - */ -static int pcicloud_write_config_byte ( struct pci_device *pci, - unsigned int where, uint8_t value ) { - struct pci_api *api = pcicloud_api ( pci ); - - return api->pci_write_config_byte ( pci, where, value ); -} - -/** - * Write 16-bit word to PCI configuration space - * - * @v pci PCI device - * @v where Location within PCI configuration space - * @v value Value to be written - * @ret rc Return status code - */ -static int pcicloud_write_config_word ( struct pci_device *pci, - unsigned int where, uint16_t value ) { - struct pci_api *api = pcicloud_api ( pci ); - - return api->pci_write_config_word ( pci, where, value ); -} - -/** - * Write 32-bit dword to PCI configuration space - * - * @v pci PCI device - * @v where Location within PCI configuration space - * @v value Value to be written - * @ret rc Return status code - */ -static int pcicloud_write_config_dword ( struct pci_device *pci, - unsigned int where, uint32_t value ) { - struct pci_api *api = pcicloud_api ( pci ); - - return api->pci_write_config_dword ( pci, where, value ); -} - -/** - * Map PCI bus address as an I/O address - * - * @v bus_addr PCI bus address - * @v len Length of region - * @ret io_addr I/O address, or NULL on error - */ -static void * pcicloud_ioremap ( struct pci_device *pci, - unsigned long bus_addr, size_t len ) { - struct pci_api *api = pcicloud_api ( pci ); - - return api->pci_ioremap ( pci, bus_addr, len ); -} - -PROVIDE_PCIAPI_INLINE ( cloud, pci_can_probe ); -PROVIDE_PCIAPI ( cloud, pci_discover, pcicloud_discover ); -PROVIDE_PCIAPI ( cloud, pci_read_config_byte, pcicloud_read_config_byte ); -PROVIDE_PCIAPI ( cloud, pci_read_config_word, pcicloud_read_config_word ); -PROVIDE_PCIAPI ( cloud, pci_read_config_dword, pcicloud_read_config_dword ); -PROVIDE_PCIAPI ( cloud, pci_write_config_byte, pcicloud_write_config_byte ); -PROVIDE_PCIAPI ( cloud, pci_write_config_word, pcicloud_write_config_word ); -PROVIDE_PCIAPI ( cloud, pci_write_config_dword, pcicloud_write_config_dword ); -PROVIDE_PCIAPI ( cloud, pci_ioremap, pcicloud_ioremap ); diff --git a/src/config/cloud/ioapi.h b/src/config/cloud/ioapi.h index ba0896a9a..bcd245981 100644 --- a/src/config/cloud/ioapi.h +++ b/src/config/cloud/ioapi.h @@ -4,4 +4,7 @@ #ifdef PLATFORM_pcbios #undef PCIAPI_PCBIOS #define PCIAPI_CLOUD +#define PCIAPI_RUNTIME_ECAM +#define PCIAPI_RUNTIME_PCBIOS +#define PCIAPI_RUNTIME_DIRECT #endif diff --git a/src/config/config_pci.c b/src/config/config_pci.c index cb8df712a..8ed9f6603 100644 --- a/src/config/config_pci.c +++ b/src/config/config_pci.c @@ -22,6 +22,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include /** @file * @@ -34,3 +35,13 @@ PROVIDE_REQUIRING_SYMBOL(); #ifdef PCI_SETTINGS REQUIRE_OBJECT ( pci_settings ); #endif + +#ifdef PCIAPI_RUNTIME_ECAM +REQUIRE_OBJECT ( ecam ); +#endif +#ifdef PCIAPI_RUNTIME_PCBIOS +REQUIRE_OBJECT ( pcibios ); +#endif +#ifdef PCIAPI_RUNTIME_DIRECT +REQUIRE_OBJECT ( pcidirect ); +#endif diff --git a/src/drivers/bus/ecam.c b/src/drivers/bus/ecam.c index 976254c18..602f7bd8a 100644 --- a/src/drivers/bus/ecam.c +++ b/src/drivers/bus/ecam.c @@ -279,5 +279,4 @@ PROVIDE_PCIAPI_INLINE ( ecam, pci_write_config_byte ); PROVIDE_PCIAPI_INLINE ( ecam, pci_write_config_word ); PROVIDE_PCIAPI_INLINE ( ecam, pci_write_config_dword ); PROVIDE_PCIAPI_INLINE ( ecam, pci_ioremap ); - -struct pci_api ecam_api = PCIAPI_RUNTIME ( ecam ); +PROVIDE_PCIAPI_RUNTIME ( ecam, PCIAPI_PRIORITY_ECAM ); diff --git a/src/drivers/bus/pcicloud.c b/src/drivers/bus/pcicloud.c new file mode 100644 index 000000000..9e1fd32b2 --- /dev/null +++ b/src/drivers/bus/pcicloud.c @@ -0,0 +1,257 @@ +/* + * Copyright (C) 2022 Michael Brown . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + * + * You can also choose to distribute this program under the terms of + * the Unmodified Binary Distribution Licence (as given in the file + * COPYING.UBDL), provided that you have satisfied its requirements. + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#include +#include +#include +#include + +/** @file + * + * Cloud VM PCI configuration space access + * + */ + +/** Cached PCI configuration space access API */ +static struct { + /** PCI bus:dev.fn address range */ + struct pci_range range; + /** API for this bus:dev.fn address */ + struct pci_api *api; +} pcicloud; + +/** + * Find PCI configuration space access API for address + * + * @v busdevfn Starting PCI bus:dev.fn address + * @v range PCI bus:dev.fn address range to fill in + * @ret api Configuration space access API, or NULL + */ +static struct pci_api * pcicloud_find ( uint32_t busdevfn, + struct pci_range *range ) { + struct pci_range candidate; + struct pci_api *api; + uint32_t best = 0; + uint32_t index; + uint32_t first; + uint32_t last; + + /* Return empty range on error */ + range->count = 0; + + /* Try discovery via all known APIs */ + for_each_table_entry ( api, PCI_APIS ) { + + /* Discover via this API */ + api->pci_discover ( busdevfn, &candidate ); + + /* Check for a matching or new closest allocation */ + index = ( busdevfn - candidate.start ); + if ( ( index < candidate.count ) || ( index > best ) ) { + memcpy ( range, &candidate, sizeof ( *range ) ); + best = index; + } + + /* Stop if this range contains the target bus:dev.fn address */ + if ( index < candidate.count ) { + first = range->start; + last = ( range->start + range->count - 1 ); + DBGC ( &pcicloud, "PCICLOUD [" PCI_FMT "," PCI_FMT ") " + "using %s API\n", PCI_SEG ( first ), + PCI_BUS ( first ), PCI_SLOT ( first ), + PCI_FUNC ( first ), PCI_SEG ( last ), + PCI_BUS ( last ), PCI_SLOT ( last ), + PCI_FUNC ( last ), api->name ); + return api; + } + } + + return NULL; +} + +/** + * Find next PCI bus:dev.fn address range in system + * + * @v busdevfn Starting PCI bus:dev.fn address + * @v range PCI bus:dev.fn address range to fill in + */ +static void pcicloud_discover ( uint32_t busdevfn, struct pci_range *range ) { + + /* Find new range, if any */ + pcicloud_find ( busdevfn, range ); +} + +/** + * Find configuration space access API for PCI device + * + * @v pci PCI device + * @ret api Configuration space access API + */ +static struct pci_api * pcicloud_api ( struct pci_device *pci ) { + struct pci_range *range = &pcicloud.range; + struct pci_api *api; + uint32_t first; + uint32_t last; + + /* Reuse cached API if applicable */ + if ( ( pci->busdevfn - range->start ) < range->count ) + return pcicloud.api; + + /* Find highest priority API claiming this range */ + api = pcicloud_find ( pci->busdevfn, range ); + + /* Fall back to lowest priority API for any unclaimed gaps in ranges */ + if ( ! api ) { + api = ( table_end ( PCI_APIS ) - 1 ); + range->count = ( range->start - pci->busdevfn ); + range->start = pci->busdevfn; + first = range->start; + last = ( range->start + range->count - 1 ); + DBGC ( &pcicloud, "PCICLOUD [" PCI_FMT "," PCI_FMT ") falling " + "back to %s API\n", PCI_SEG ( first ), + PCI_BUS ( first ), PCI_SLOT ( first ), + PCI_FUNC ( first ), PCI_SEG ( last ), PCI_BUS ( last ), + PCI_SLOT ( last ), PCI_FUNC ( last ), api->name ); + } + + /* Cache API for this range */ + pcicloud.api = api; + + return api; +} + +/** + * Read byte from PCI configuration space + * + * @v pci PCI device + * @v where Location within PCI configuration space + * @v value Value read + * @ret rc Return status code + */ +static int pcicloud_read_config_byte ( struct pci_device *pci, + unsigned int where, uint8_t *value ) { + struct pci_api *api = pcicloud_api ( pci ); + + return api->pci_read_config_byte ( pci, where, value ); +} + +/** + * Read 16-bit word from PCI configuration space + * + * @v pci PCI device + * @v where Location within PCI configuration space + * @v value Value read + * @ret rc Return status code + */ +static int pcicloud_read_config_word ( struct pci_device *pci, + unsigned int where, uint16_t *value ) { + struct pci_api *api = pcicloud_api ( pci ); + + return api->pci_read_config_word ( pci, where, value ); +} + +/** + * Read 32-bit dword from PCI configuration space + * + * @v pci PCI device + * @v where Location within PCI configuration space + * @v value Value read + * @ret rc Return status code + */ +static int pcicloud_read_config_dword ( struct pci_device *pci, + unsigned int where, uint32_t *value ) { + struct pci_api *api = pcicloud_api ( pci ); + + return api->pci_read_config_dword ( pci, where, value ); +} + +/** + * Write byte to PCI configuration space + * + * @v pci PCI device + * @v where Location within PCI configuration space + * @v value Value to be written + * @ret rc Return status code + */ +static int pcicloud_write_config_byte ( struct pci_device *pci, + unsigned int where, uint8_t value ) { + struct pci_api *api = pcicloud_api ( pci ); + + return api->pci_write_config_byte ( pci, where, value ); +} + +/** + * Write 16-bit word to PCI configuration space + * + * @v pci PCI device + * @v where Location within PCI configuration space + * @v value Value to be written + * @ret rc Return status code + */ +static int pcicloud_write_config_word ( struct pci_device *pci, + unsigned int where, uint16_t value ) { + struct pci_api *api = pcicloud_api ( pci ); + + return api->pci_write_config_word ( pci, where, value ); +} + +/** + * Write 32-bit dword to PCI configuration space + * + * @v pci PCI device + * @v where Location within PCI configuration space + * @v value Value to be written + * @ret rc Return status code + */ +static int pcicloud_write_config_dword ( struct pci_device *pci, + unsigned int where, uint32_t value ) { + struct pci_api *api = pcicloud_api ( pci ); + + return api->pci_write_config_dword ( pci, where, value ); +} + +/** + * Map PCI bus address as an I/O address + * + * @v bus_addr PCI bus address + * @v len Length of region + * @ret io_addr I/O address, or NULL on error + */ +static void * pcicloud_ioremap ( struct pci_device *pci, + unsigned long bus_addr, size_t len ) { + struct pci_api *api = pcicloud_api ( pci ); + + return api->pci_ioremap ( pci, bus_addr, len ); +} + +PROVIDE_PCIAPI_INLINE ( cloud, pci_can_probe ); +PROVIDE_PCIAPI ( cloud, pci_discover, pcicloud_discover ); +PROVIDE_PCIAPI ( cloud, pci_read_config_byte, pcicloud_read_config_byte ); +PROVIDE_PCIAPI ( cloud, pci_read_config_word, pcicloud_read_config_word ); +PROVIDE_PCIAPI ( cloud, pci_read_config_dword, pcicloud_read_config_dword ); +PROVIDE_PCIAPI ( cloud, pci_write_config_byte, pcicloud_write_config_byte ); +PROVIDE_PCIAPI ( cloud, pci_write_config_word, pcicloud_write_config_word ); +PROVIDE_PCIAPI ( cloud, pci_write_config_dword, pcicloud_write_config_dword ); +PROVIDE_PCIAPI ( cloud, pci_ioremap, pcicloud_ioremap ); diff --git a/src/include/ipxe/ecam.h b/src/include/ipxe/ecam.h index ff08aee5a..856a673c5 100644 --- a/src/include/ipxe/ecam.h +++ b/src/include/ipxe/ecam.h @@ -54,6 +54,4 @@ struct ecam_mapping { int rc; }; -extern struct pci_api ecam_api; - #endif /* _IPXE_ECAM_H */ diff --git a/src/include/ipxe/pci_io.h b/src/include/ipxe/pci_io.h index 9b4cbcab4..456e29e6e 100644 --- a/src/include/ipxe/pci_io.h +++ b/src/include/ipxe/pci_io.h @@ -11,6 +11,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include @@ -61,6 +62,7 @@ struct pci_range { /* Include all architecture-independent I/O API headers */ #include #include +#include #include #include @@ -171,23 +173,45 @@ struct pci_api { typeof ( pci_ioremap ) ( * pci_ioremap ); }; +/** Runtime selectable PCI API table */ +#define PCI_APIS __table ( struct pci_api, "pci_apis" ) + +/** + * Declare a runtime selectable PCI API + * + * In the common case of a non-runtime-selectable PCI I/O API, allow + * the runtime API code to be garbage-collected at link time to save + * space. + */ +#ifdef PCIAPI_CLOUD +#define __pci_api( priority ) __table_entry ( PCI_APIS, priority ) +#else +#define __pci_api( priority ) +#endif + +/* PCI runtime selectable API priorities */ +#define PCIAPI_PRIORITY_ECAM 01 /**< ACPI ECAM */ +#define PCIAPI_PRIORITY_PCBIOS 02 /**< PCI BIOS calls */ +#define PCIAPI_PRIORITY_DIRECT 03 /**< Direct Type 1 accesses */ + /** Provide a runtime selectable PCI I/O API */ -#define PCIAPI_RUNTIME( _subsys ) { \ - .name = #_subsys, \ - .pci_discover = PCIAPI_INLINE ( _subsys, pci_discover ), \ - .pci_read_config_byte = \ - PCIAPI_INLINE ( _subsys, pci_read_config_byte ), \ - .pci_read_config_word = \ - PCIAPI_INLINE ( _subsys, pci_read_config_word ), \ - .pci_read_config_dword = \ - PCIAPI_INLINE ( _subsys, pci_read_config_dword ), \ - .pci_write_config_byte = \ - PCIAPI_INLINE ( _subsys, pci_write_config_byte ), \ - .pci_write_config_word = \ - PCIAPI_INLINE ( _subsys, pci_write_config_word ), \ - .pci_write_config_dword = \ - PCIAPI_INLINE ( _subsys, pci_write_config_dword ), \ - .pci_ioremap = PCIAPI_INLINE ( _subsys, pci_ioremap ), \ +#define PROVIDE_PCIAPI_RUNTIME( subsys, priority ) \ + struct pci_api pciapi_ ## subsys __pci_api ( priority ) = { \ + .name = #subsys, \ + .pci_discover = PCIAPI_INLINE ( subsys, pci_discover ), \ + .pci_read_config_byte = \ + PCIAPI_INLINE ( subsys, pci_read_config_byte ), \ + .pci_read_config_word = \ + PCIAPI_INLINE ( subsys, pci_read_config_word ), \ + .pci_read_config_dword = \ + PCIAPI_INLINE ( subsys, pci_read_config_dword ), \ + .pci_write_config_byte = \ + PCIAPI_INLINE ( subsys, pci_write_config_byte ), \ + .pci_write_config_word = \ + PCIAPI_INLINE ( subsys, pci_write_config_word ), \ + .pci_write_config_dword = \ + PCIAPI_INLINE ( subsys, pci_write_config_dword ), \ + .pci_ioremap = PCIAPI_INLINE ( subsys, pci_ioremap ), \ } #endif /* _IPXE_PCI_IO_H */ diff --git a/src/include/ipxe/pcicloud.h b/src/include/ipxe/pcicloud.h new file mode 100644 index 000000000..1feef56cb --- /dev/null +++ b/src/include/ipxe/pcicloud.h @@ -0,0 +1,28 @@ +#ifndef _IPXE_PCICLOUD_H +#define _IPXE_PCICLOUD_H + +/** @file + * + * Cloud VM PCI configuration space access + * + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#ifdef PCIAPI_CLOUD +#define PCIAPI_PREFIX_cloud +#else +#define PCIAPI_PREFIX_cloud __cloud_ +#endif + +/** + * Check if PCI bus probing is allowed + * + * @ret ok Bus probing is allowed + */ +static inline __always_inline int +PCIAPI_INLINE ( cloud, pci_can_probe ) ( void ) { + return 1; +} + +#endif /* _IPXE_PCICLOUD_H */ -- cgit v1.2.3-55-g7522 From 9c1ac48bcff1a623cc5422fb57c540d910ac9734 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 24 Nov 2025 23:09:53 +0000 Subject: [pci] Allow probing permission to vary by range Make pci_can_probe() part of the runtime selectable PCI I/O API, and defer this check to the per-range API. Signed-off-by: Michael Brown --- src/arch/x86/include/ipxe/pcibios.h | 3 ++- src/arch/x86/include/ipxe/pcidirect.h | 3 ++- src/drivers/bus/pci.c | 8 ++++---- src/drivers/bus/pcicloud.c | 14 +++++++++++++- src/include/ipxe/ecam_io.h | 3 ++- src/include/ipxe/efi/efi_pci_api.h | 3 ++- src/include/ipxe/linux/linux_pci.h | 3 ++- src/include/ipxe/null_pci.h | 3 ++- src/include/ipxe/pci_io.h | 5 ++++- src/include/ipxe/pcicloud.h | 10 ---------- 10 files changed, 33 insertions(+), 22 deletions(-) (limited to 'src/drivers') diff --git a/src/arch/x86/include/ipxe/pcibios.h b/src/arch/x86/include/ipxe/pcibios.h index 87b403555..b62b470f0 100644 --- a/src/arch/x86/include/ipxe/pcibios.h +++ b/src/arch/x86/include/ipxe/pcibios.h @@ -35,10 +35,11 @@ extern int pcibios_write ( struct pci_device *pci, uint32_t command, /** * Check if PCI bus probing is allowed * + * @v pci PCI device * @ret ok Bus probing is allowed */ static inline __always_inline int -PCIAPI_INLINE ( pcbios, pci_can_probe ) ( void ) { +PCIAPI_INLINE ( pcbios, pci_can_probe ) ( struct pci_device *pci __unused ) { return 1; } diff --git a/src/arch/x86/include/ipxe/pcidirect.h b/src/arch/x86/include/ipxe/pcidirect.h index 501576582..1515b20d4 100644 --- a/src/arch/x86/include/ipxe/pcidirect.h +++ b/src/arch/x86/include/ipxe/pcidirect.h @@ -28,10 +28,11 @@ extern void pcidirect_prepare ( struct pci_device *pci, int where ); /** * Check if PCI bus probing is allowed * + * @v pci PCI device * @ret ok Bus probing is allowed */ static inline __always_inline int -PCIAPI_INLINE ( direct, pci_can_probe ) ( void ) { +PCIAPI_INLINE ( direct, pci_can_probe ) ( struct pci_device *pci __unused ) { return 1; } diff --git a/src/drivers/bus/pci.c b/src/drivers/bus/pci.c index 43ccb751d..3908871b8 100644 --- a/src/drivers/bus/pci.c +++ b/src/drivers/bus/pci.c @@ -447,10 +447,6 @@ static int pcibus_probe ( struct root_device *rootdev ) { uint32_t busdevfn = 0; int rc; - /* Skip automatic probing if prohibited */ - if ( ! pci_can_probe() ) - return 0; - do { /* Allocate struct pci_device */ if ( ! pci ) @@ -464,6 +460,10 @@ static int pcibus_probe ( struct root_device *rootdev ) { if ( ( rc = pci_find_next ( pci, &busdevfn ) ) != 0 ) break; + /* Skip automatic probing if prohibited */ + if ( ! pci_can_probe ( pci ) ) + continue; + /* Look for a driver */ if ( ( rc = pci_find_driver ( pci ) ) != 0 ) { DBGC ( pci, PCI_FMT " (%04x:%04x class %06x) has no " diff --git a/src/drivers/bus/pcicloud.c b/src/drivers/bus/pcicloud.c index 9e1fd32b2..0173c3158 100644 --- a/src/drivers/bus/pcicloud.c +++ b/src/drivers/bus/pcicloud.c @@ -142,6 +142,18 @@ static struct pci_api * pcicloud_api ( struct pci_device *pci ) { return api; } +/** + * Check if PCI bus probing is allowed + * + * @v pci PCI device + * @ret ok Bus probing is allowed + */ +static int pcicloud_can_probe ( struct pci_device *pci ) { + struct pci_api *api = pcicloud_api ( pci ); + + return api->pci_can_probe ( pci ); +} + /** * Read byte from PCI configuration space * @@ -246,7 +258,7 @@ static void * pcicloud_ioremap ( struct pci_device *pci, return api->pci_ioremap ( pci, bus_addr, len ); } -PROVIDE_PCIAPI_INLINE ( cloud, pci_can_probe ); +PROVIDE_PCIAPI ( cloud, pci_can_probe, pcicloud_can_probe ); PROVIDE_PCIAPI ( cloud, pci_discover, pcicloud_discover ); PROVIDE_PCIAPI ( cloud, pci_read_config_byte, pcicloud_read_config_byte ); PROVIDE_PCIAPI ( cloud, pci_read_config_word, pcicloud_read_config_word ); diff --git a/src/include/ipxe/ecam_io.h b/src/include/ipxe/ecam_io.h index 788ba9b9a..b2c232013 100644 --- a/src/include/ipxe/ecam_io.h +++ b/src/include/ipxe/ecam_io.h @@ -139,10 +139,11 @@ PCIAPI_INLINE ( ecam, pci_ioremap ) ( struct pci_device *pci __unused, /** * Check if PCI bus probing is allowed * + * @v pci PCI device * @ret ok Bus probing is allowed */ static inline __always_inline int -PCIAPI_INLINE ( ecam, pci_can_probe ) ( void ) { +PCIAPI_INLINE ( ecam, pci_can_probe ) ( struct pci_device *pci __unused ) { return 1; } diff --git a/src/include/ipxe/efi/efi_pci_api.h b/src/include/ipxe/efi/efi_pci_api.h index 9aca02f65..956795254 100644 --- a/src/include/ipxe/efi/efi_pci_api.h +++ b/src/include/ipxe/efi/efi_pci_api.h @@ -35,10 +35,11 @@ extern int efipci_write ( struct pci_device *pci, unsigned long location, /** * Check if PCI bus probing is allowed * + * @v pci PCI device * @ret ok Bus probing is allowed */ static inline __always_inline int -PCIAPI_INLINE ( efi, pci_can_probe ) ( void ) { +PCIAPI_INLINE ( efi, pci_can_probe ) ( struct pci_device *pci __unused ) { return 0; } diff --git a/src/include/ipxe/linux/linux_pci.h b/src/include/ipxe/linux/linux_pci.h index 2b19e13c3..f9cd98819 100644 --- a/src/include/ipxe/linux/linux_pci.h +++ b/src/include/ipxe/linux/linux_pci.h @@ -25,10 +25,11 @@ extern int linux_pci_write ( struct pci_device *pci, unsigned long where, /** * Check if PCI bus probing is allowed * + * @v pci PCI device * @ret ok Bus probing is allowed */ static inline __always_inline int -PCIAPI_INLINE ( linux, pci_can_probe ) ( void ) { +PCIAPI_INLINE ( linux, pci_can_probe ) ( struct pci_device *pci __unused ) { return 1; } diff --git a/src/include/ipxe/null_pci.h b/src/include/ipxe/null_pci.h index 476ede202..0cdcdc109 100644 --- a/src/include/ipxe/null_pci.h +++ b/src/include/ipxe/null_pci.h @@ -22,10 +22,11 @@ struct pci_device; /** * Check if PCI bus probing is allowed * + * @v pci PCI device * @ret ok Bus probing is allowed */ static inline __always_inline int -PCIAPI_INLINE ( null, pci_can_probe ) ( void ) { +PCIAPI_INLINE ( null, pci_can_probe ) ( struct pci_device *pci __unused ) { return 0; } diff --git a/src/include/ipxe/pci_io.h b/src/include/ipxe/pci_io.h index 456e29e6e..0d32adf81 100644 --- a/src/include/ipxe/pci_io.h +++ b/src/include/ipxe/pci_io.h @@ -72,9 +72,10 @@ struct pci_range { /** * Check if PCI bus probing is allowed * + * @v pci PCI device * @ret ok Bus probing is allowed */ -int pci_can_probe ( void ); +int pci_can_probe ( struct pci_device *pci ); /** * Find next PCI bus:dev.fn address range in system @@ -163,6 +164,7 @@ void * pci_ioremap ( struct pci_device *pci, unsigned long bus_addr, /** A runtime selectable PCI I/O API */ struct pci_api { const char *name; + typeof ( pci_can_probe ) ( * pci_can_probe ); typeof ( pci_discover ) ( * pci_discover ); typeof ( pci_read_config_byte ) ( * pci_read_config_byte ); typeof ( pci_read_config_word ) ( * pci_read_config_word ); @@ -198,6 +200,7 @@ struct pci_api { #define PROVIDE_PCIAPI_RUNTIME( subsys, priority ) \ struct pci_api pciapi_ ## subsys __pci_api ( priority ) = { \ .name = #subsys, \ + .pci_can_probe = PCIAPI_INLINE ( subsys, pci_can_probe ), \ .pci_discover = PCIAPI_INLINE ( subsys, pci_discover ), \ .pci_read_config_byte = \ PCIAPI_INLINE ( subsys, pci_read_config_byte ), \ diff --git a/src/include/ipxe/pcicloud.h b/src/include/ipxe/pcicloud.h index 1feef56cb..52268908c 100644 --- a/src/include/ipxe/pcicloud.h +++ b/src/include/ipxe/pcicloud.h @@ -15,14 +15,4 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define PCIAPI_PREFIX_cloud __cloud_ #endif -/** - * Check if PCI bus probing is allowed - * - * @ret ok Bus probing is allowed - */ -static inline __always_inline int -PCIAPI_INLINE ( cloud, pci_can_probe ) ( void ) { - return 1; -} - #endif /* _IPXE_PCICLOUD_H */ -- cgit v1.2.3-55-g7522 From d73981aece2544ee05685dccaf5a71b533fabb44 Mon Sep 17 00:00:00 2001 From: Bert Ezendam Date: Wed, 26 Nov 2025 14:11:18 +0000 Subject: [intel] Add PCI IDs for I225 and I226 chipsets Identifiers are taken from the pci.ids database. Signed-off-by: Bert Ezendam --- src/drivers/net/intel.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/drivers') diff --git a/src/drivers/net/intel.c b/src/drivers/net/intel.c index 7879714f6..598dce754 100644 --- a/src/drivers/net/intel.c +++ b/src/drivers/net/intel.c @@ -1043,6 +1043,7 @@ static struct pci_device_id intel_nics[] = { PCI_ROM ( 0x8086, 0x0d4f, "i219v-10", "I219-V (10)", INTEL_I219 ), PCI_ROM ( 0x8086, 0x0d53, "i219lm-12", "I219-LM (12)", INTEL_I219 ), PCI_ROM ( 0x8086, 0x0d55, "i219v-12", "I219-V (12)", INTEL_I219 ), + PCI_ROM ( 0x8086, 0x0d9f, "i225it", "I225-IT", INTEL_PBSIZE_RST ), PCI_ROM ( 0x8086, 0x0dc5, "i219lm-23", "I219-LM (23)", INTEL_I219 ), PCI_ROM ( 0x8086, 0x1000, "82542-f", "82542 (Fiber)", 0 ), PCI_ROM ( 0x8086, 0x1001, "82543gc-f", "82543GC (Fiber)", 0 ), @@ -1133,6 +1134,9 @@ static struct pci_device_id intel_nics[] = { PCI_ROM ( 0x8086, 0x10f0, "82578dc", "82578DC", 0 ), PCI_ROM ( 0x8086, 0x10f5, "82567lm", "82567LM", 0 ), PCI_ROM ( 0x8086, 0x10f6, "82574l", "82574L", 0 ), + PCI_ROM ( 0x8086, 0x125b, "i226lm", "I226-LM", INTEL_PBSIZE_RST ), + PCI_ROM ( 0x8086, 0x125c, "i226v", "I226-V", INTEL_PBSIZE_RST ), + PCI_ROM ( 0x8086, 0x125d, "i226it", "I226-IT", INTEL_PBSIZE_RST ), PCI_ROM ( 0x8086, 0x1501, "82567v-3", "82567V-3", INTEL_PBS_ERRATA ), PCI_ROM ( 0x8086, 0x1502, "82579lm", "82579LM", INTEL_NO_PHY_RST ), PCI_ROM ( 0x8086, 0x1503, "82579v", "82579V", 0 ), @@ -1180,6 +1184,8 @@ static struct pci_device_id intel_nics[] = { PCI_ROM ( 0x8086, 0x15e1, "i219lm-9", "I219-LM (9)", INTEL_I219 ), PCI_ROM ( 0x8086, 0x15e2, "i219v-9", "I219-V (9)", INTEL_I219 ), PCI_ROM ( 0x8086, 0x15e3, "i219lm-5", "I219-LM (5)", INTEL_I219 ), + PCI_ROM ( 0x8086, 0x15f2, "i225lm", "I225-LM", INTEL_PBSIZE_RST ), + PCI_ROM ( 0x8086, 0x15f3, "i225v", "I225-V", INTEL_PBSIZE_RST ), PCI_ROM ( 0x8086, 0x15f4, "i219lm-15", "I219-LM (15)", INTEL_I219 ), PCI_ROM ( 0x8086, 0x15f5, "i219v-15", "I219-V (15)", INTEL_I219 ), PCI_ROM ( 0x8086, 0x15f9, "i219lm-14", "I219-LM (14)", INTEL_I219 ), @@ -1193,6 +1199,7 @@ static struct pci_device_id intel_nics[] = { PCI_ROM ( 0x8086, 0x1f41, "i354", "I354", INTEL_NO_ASDE ), PCI_ROM ( 0x8086, 0x294c, "82566dc-2", "82566DC-2", 0 ), PCI_ROM ( 0x8086, 0x2e6e, "cemedia", "CE Media Processor", 0 ), + PCI_ROM ( 0x8086, 0x5502, "i225lmvp", "I225-LMvP", INTEL_PBSIZE_RST ), }; /** Intel PCI driver */ -- cgit v1.2.3-55-g7522 From d4258272c679c8bd42430fc2df57402cdc03d711 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 1 Dec 2025 16:02:54 +0000 Subject: [crypto] Construct signatures using ASN.1 builders Signed-off-by: Michael Brown --- src/crypto/crypto_null.c | 3 ++- src/crypto/rsa.c | 24 +++++++++-------- src/drivers/net/iphone.c | 18 +++---------- src/include/ipxe/crypto.h | 9 ++++--- src/net/tls.c | 69 ++++++++++++++++++++++++----------------------- src/tests/pubkey_test.c | 30 ++++++++++----------- 6 files changed, 74 insertions(+), 79 deletions(-) (limited to 'src/drivers') diff --git a/src/crypto/crypto_null.c b/src/crypto/crypto_null.c index ca4e1b134..ee948e00d 100644 --- a/src/crypto/crypto_null.c +++ b/src/crypto/crypto_null.c @@ -113,7 +113,8 @@ int pubkey_null_decrypt ( const struct asn1_cursor *key __unused, int pubkey_null_sign ( const struct asn1_cursor *key __unused, struct digest_algorithm *digest __unused, - const void *value __unused, void *signature __unused ) { + const void *value __unused, + struct asn1_builder *signature __unused ) { return 0; } diff --git a/src/crypto/rsa.c b/src/crypto/rsa.c index b93437518..fd6a1ef39 100644 --- a/src/crypto/rsa.c +++ b/src/crypto/rsa.c @@ -544,13 +544,12 @@ static int rsa_encode_digest ( struct rsa_context *context, * @v digest Digest algorithm * @v value Digest value * @v signature Signature - * @ret signature_len Signature length, or negative error + * @ret rc Return status code */ static int rsa_sign ( const struct asn1_cursor *key, struct digest_algorithm *digest, const void *value, - void *signature ) { + struct asn1_builder *signature ) { struct rsa_context context; - void *temp; int rc; DBGC ( &context, "RSA %p signing %s digest:\n", @@ -561,24 +560,27 @@ static int rsa_sign ( const struct asn1_cursor *key, if ( ( rc = rsa_init ( &context, key ) ) != 0 ) goto err_init; - /* Encode digest (using the big integer output buffer as - * temporary storage) - */ - temp = context.output0; - if ( ( rc = rsa_encode_digest ( &context, digest, value, temp ) ) != 0 ) + /* Create space for encoded digest and signature */ + if ( ( rc = asn1_grow ( signature, context.max_len ) ) != 0 ) + goto err_grow; + + /* Encode digest */ + if ( ( rc = rsa_encode_digest ( &context, digest, value, + signature->data ) ) != 0 ) goto err_encode; /* Encipher the encoded digest */ - rsa_cipher ( &context, temp, signature ); + rsa_cipher ( &context, signature->data, signature->data ); DBGC ( &context, "RSA %p signed %s digest:\n", &context, digest->name ); - DBGC_HDA ( &context, 0, signature, context.max_len ); + DBGC_HDA ( &context, 0, signature->data, signature->len ); /* Free context */ rsa_free ( &context ); - return context.max_len; + return 0; err_encode: + err_grow: rsa_free ( &context ); err_init: return rc; diff --git a/src/drivers/net/iphone.c b/src/drivers/net/iphone.c index bcc9949fe..11f763553 100644 --- a/src/drivers/net/iphone.c +++ b/src/drivers/net/iphone.c @@ -362,7 +362,6 @@ static int icert_cert ( struct icert *icert, struct asn1_cursor *subject, struct asn1_builder raw = { NULL, 0 }; uint8_t digest_ctx[SHA256_CTX_SIZE]; uint8_t digest_out[SHA256_DIGEST_SIZE]; - int len; int rc; /* Construct subjectPublicKeyInfo */ @@ -399,20 +398,12 @@ static int icert_cert ( struct icert *icert, struct asn1_cursor *subject, digest_final ( digest, digest_ctx, digest_out ); /* Construct signature using "private" key */ - if ( ( rc = asn1_grow ( &raw, - pubkey_max_len ( pubkey, private ) ) ) != 0 ) { - DBGC ( icert, "ICERT %p could not build signature: %s\n", - icert, strerror ( rc ) ); - goto err_grow; - } - if ( ( len = pubkey_sign ( pubkey, private, digest, digest_out, - raw.data ) ) < 0 ) { - rc = len; + if ( ( rc = pubkey_sign ( pubkey, private, digest, digest_out, + &raw ) ) != 0 ) { DBGC ( icert, "ICERT %p could not sign: %s\n", icert, strerror ( rc ) ); goto err_pubkey_sign; } - assert ( ( ( size_t ) len ) == raw.len ); /* Construct raw certificate data */ if ( ( rc = ( asn1_prepend_raw ( &raw, icert_nul, @@ -438,12 +429,11 @@ static int icert_cert ( struct icert *icert, struct asn1_cursor *subject, err_x509: err_raw: err_pubkey_sign: + err_tbs: + err_spki: free ( raw.data ); - err_grow: free ( tbs.data ); - err_tbs: free ( spki.data ); - err_spki: return rc; } diff --git a/src/include/ipxe/crypto.h b/src/include/ipxe/crypto.h index 5b87d1a47..c457a74b1 100644 --- a/src/include/ipxe/crypto.h +++ b/src/include/ipxe/crypto.h @@ -153,11 +153,11 @@ struct pubkey_algorithm { * @v digest Digest algorithm * @v value Digest value * @v signature Signature - * @ret signature_len Signature length, or negative error + * @ret rc Return status code */ int ( * sign ) ( const struct asn1_cursor *key, struct digest_algorithm *digest, const void *value, - void *signature ); + struct asn1_builder *builder ); /** Verify signed digest value * * @v key Key @@ -287,7 +287,7 @@ pubkey_decrypt ( struct pubkey_algorithm *pubkey, const struct asn1_cursor *key, static inline __attribute__ (( always_inline )) int pubkey_sign ( struct pubkey_algorithm *pubkey, const struct asn1_cursor *key, struct digest_algorithm *digest, const void *value, - void *signature ) { + struct asn1_builder *signature ) { return pubkey->sign ( key, digest, value, signature ); } @@ -332,7 +332,8 @@ extern int pubkey_null_decrypt ( const struct asn1_cursor *key, void *plaintext ); extern int pubkey_null_sign ( const struct asn1_cursor *key, struct digest_algorithm *digest, - const void *value, void *signature ); + const void *value, + struct asn1_builder *signature ); extern int pubkey_null_verify ( const struct asn1_cursor *key, struct digest_algorithm *digest, const void *value, diff --git a/src/net/tls.c b/src/net/tls.c index 1bcb5c027..c01ce9515 100644 --- a/src/net/tls.c +++ b/src/net/tls.c @@ -1863,6 +1863,7 @@ static int tls_send_certificate_verify ( struct tls_connection *tls ) { struct asn1_cursor *key = privkey_cursor ( tls->client.key ); uint8_t digest_out[ digest->digestsize ]; struct tls_signature_hash_algorithm *sig_hash = NULL; + struct asn1_builder builder = { NULL, 0 }; int rc; /* Generate digest to be signed */ @@ -1880,53 +1881,53 @@ static int tls_send_certificate_verify ( struct tls_connection *tls ) { } } - /* Generate and transmit record */ + /* Sign digest */ + if ( ( rc = pubkey_sign ( pubkey, key, digest, digest_out, + &builder ) ) != 0 ) { + DBGC ( tls, "TLS %p could not sign %s digest using %s client " + "private key: %s\n", tls, digest->name, pubkey->name, + strerror ( rc ) ); + goto err_pubkey_sign; + } + + /* Construct Certificate Verify record */ { - size_t max_len = pubkey_max_len ( pubkey, key ); int use_sig_hash = ( ( sig_hash == NULL ) ? 0 : 1 ); struct { uint32_t type_length; struct tls_signature_hash_id sig_hash[use_sig_hash]; uint16_t signature_len; - uint8_t signature[max_len]; - } __attribute__ (( packed )) certificate_verify; - size_t unused; - int len; - - /* Sign digest */ - len = pubkey_sign ( pubkey, key, digest, digest_out, - certificate_verify.signature ); - if ( len < 0 ) { - rc = len; - DBGC ( tls, "TLS %p could not sign %s digest using %s " - "client private key: %s\n", tls, digest->name, - pubkey->name, strerror ( rc ) ); - goto err_pubkey_sign; - } - unused = ( max_len - len ); - - /* Construct Certificate Verify record */ - certificate_verify.type_length = - ( cpu_to_le32 ( TLS_CERTIFICATE_VERIFY ) | - htonl ( sizeof ( certificate_verify ) - - sizeof ( certificate_verify.type_length ) - - unused ) ); + } __attribute__ (( packed )) header; + + header.type_length = ( cpu_to_le32 ( TLS_CERTIFICATE_VERIFY ) | + htonl ( builder.len + + sizeof ( header ) - + sizeof ( header.type_length ))); if ( use_sig_hash ) { - memcpy ( &certificate_verify.sig_hash[0], - &sig_hash->code, - sizeof ( certificate_verify.sig_hash[0] ) ); + memcpy ( &header.sig_hash[0], &sig_hash->code, + sizeof ( header.sig_hash[0] ) ); } - certificate_verify.signature_len = - htons ( sizeof ( certificate_verify.signature ) - - unused ); + header.signature_len = htons ( builder.len ); - /* Transmit record */ - rc = tls_send_handshake ( tls, &certificate_verify, - ( sizeof ( certificate_verify ) - unused ) ); + if ( ( rc = asn1_prepend_raw ( &builder, &header, + sizeof ( header ) ) ) != 0 ) { + DBGC ( tls, "TLS %p could not construct Certificate " + "Verify: %s\n", tls, strerror ( rc ) ); + goto err_prepend; + } + } + + /* Transmit record */ + if ( ( rc = tls_send_handshake ( tls, builder.data, + builder.len ) ) != 0 ) { + goto err_send; } + err_send: + err_prepend: err_pubkey_sign: err_sig_hash: + free ( builder.data ); return rc; } diff --git a/src/tests/pubkey_test.c b/src/tests/pubkey_test.c index 2e0eeb116..e3fbc3b3f 100644 --- a/src/tests/pubkey_test.c +++ b/src/tests/pubkey_test.c @@ -98,13 +98,10 @@ void pubkey_sign_okx ( struct pubkey_sign_test *test, const char *file, unsigned int line ) { struct pubkey_algorithm *pubkey = test->pubkey; struct digest_algorithm *digest = test->digest; - size_t max_len = pubkey_max_len ( pubkey, &test->private ); - uint8_t bad[test->signature.len]; uint8_t digestctx[digest->ctxsize ]; uint8_t digestout[digest->digestsize]; - uint8_t signature[max_len]; - struct asn1_cursor cursor; - int signature_len; + struct asn1_builder signature = { NULL, 0 }; + uint8_t *bad; /* Construct digest over plaintext */ digest_init ( digest, digestctx ); @@ -113,21 +110,24 @@ void pubkey_sign_okx ( struct pubkey_sign_test *test, const char *file, digest_final ( digest, digestctx, digestout ); /* Test signing using private key */ - signature_len = pubkey_sign ( pubkey, &test->private, digest, - digestout, signature ); - okx ( signature_len == ( ( int ) test->signature.len ), file, line ); - okx ( memcmp ( signature, test->signature.data, - test->signature.len ) == 0, file, line ); + okx ( pubkey_sign ( pubkey, &test->private, digest, digestout, + &signature ) == 0, file, line ); + okx ( signature.len != 0, file, line ); + okx ( asn1_compare ( asn1_built ( &signature ), + &test->signature ) == 0, file, line ); /* Test verification using public key */ okx ( pubkey_verify ( pubkey, &test->public, digest, digestout, &test->signature ) == 0, file, line ); /* Test verification failure of modified signature */ - memcpy ( bad, test->signature.data, test->signature.len ); - bad[ test->signature.len / 2 ] ^= 0x40; - cursor.data = bad; - cursor.len = test->signature.len; + bad = ( signature.data + ( test->signature.len / 2 ) ); + okx ( pubkey_verify ( pubkey, &test->public, digest, digestout, + asn1_built ( &signature ) ) == 0, file, line ); + *bad ^= 0x40; okx ( pubkey_verify ( pubkey, &test->public, digest, digestout, - &cursor ) != 0, file, line ); + asn1_built ( &signature ) ) != 0, file, line ); + + /* Free signature */ + free ( signature.data ); } -- cgit v1.2.3-55-g7522 From 3d5cd3d79e8d8adb723e9e560a636947e19114a3 Mon Sep 17 00:00:00 2001 From: Christian I. Nilsson Date: Mon, 15 Dec 2025 21:47:19 +0100 Subject: [intel] Add PCI ID for I219-V and -LM 24 Signed-off-by: Christian I. Nilsson --- src/drivers/net/intel.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/drivers') diff --git a/src/drivers/net/intel.c b/src/drivers/net/intel.c index 598dce754..845ba3e7f 100644 --- a/src/drivers/net/intel.c +++ b/src/drivers/net/intel.c @@ -1200,6 +1200,8 @@ static struct pci_device_id intel_nics[] = { PCI_ROM ( 0x8086, 0x294c, "82566dc-2", "82566DC-2", 0 ), PCI_ROM ( 0x8086, 0x2e6e, "cemedia", "CE Media Processor", 0 ), PCI_ROM ( 0x8086, 0x5502, "i225lmvp", "I225-LMvP", INTEL_PBSIZE_RST ), + PCI_ROM ( 0x8086, 0x57a0, "i219lm-24", "I219-LM (24)", INTEL_I219 ), + PCI_ROM ( 0x8086, 0x57a1, "i219v-24", "I219-V (24)", INTEL_I219 ), }; /** Intel PCI driver */ -- cgit v1.2.3-55-g7522 From 30948987fda56e55d172cc3b66b291064724624d Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 13 Jan 2026 14:38:37 +0000 Subject: [build] Mark existing files as explicitly forbidden for Secure Boot The third-party 802.11 stack and NFS protocol code are known to include multiple potential vulnerabilities and are explicitly forbidden from being included in Secure Boot signed builds. This is currently handled at the per-directory level by defining a list of source directories (SRCDIRS_INSEC) that are to be excluded from Secure Boot builds. Annotate all files in these directories with FILE_SECBOOT() to convey this information to the new per-file Secure Boot permissibility check, and remove the old separation between SRCDIRS and SRCDIRS_INSEC. Signed-off-by: Michael Brown --- src/Makefile | 16 ++++++---------- src/Makefile.housekeeping | 5 ----- src/drivers/net/ath/ath.h | 1 + src/drivers/net/ath/ath5k/ath5k.c | 1 + src/drivers/net/ath/ath5k/ath5k.h | 1 + src/drivers/net/ath/ath5k/ath5k_attach.c | 1 + src/drivers/net/ath/ath5k/ath5k_caps.c | 1 + src/drivers/net/ath/ath5k/ath5k_desc.c | 1 + src/drivers/net/ath/ath5k/ath5k_dma.c | 1 + src/drivers/net/ath/ath5k/ath5k_eeprom.c | 1 + src/drivers/net/ath/ath5k/ath5k_gpio.c | 1 + src/drivers/net/ath/ath5k/ath5k_initvals.c | 1 + src/drivers/net/ath/ath5k/ath5k_pcu.c | 1 + src/drivers/net/ath/ath5k/ath5k_phy.c | 1 + src/drivers/net/ath/ath5k/ath5k_qcu.c | 1 + src/drivers/net/ath/ath5k/ath5k_reset.c | 1 + src/drivers/net/ath/ath5k/ath5k_rfkill.c | 1 + src/drivers/net/ath/ath5k/base.h | 1 + src/drivers/net/ath/ath5k/desc.h | 2 ++ src/drivers/net/ath/ath5k/eeprom.h | 2 ++ src/drivers/net/ath/ath5k/reg.h | 2 ++ src/drivers/net/ath/ath5k/rfbuffer.h | 1 + src/drivers/net/ath/ath5k/rfgain.h | 2 ++ src/drivers/net/ath/ath9k/ani.h | 1 + src/drivers/net/ath/ath9k/ar5008_initvals.h | 1 + src/drivers/net/ath/ath9k/ar9001_initvals.h | 1 + src/drivers/net/ath/ath9k/ar9002_initvals.h | 1 + src/drivers/net/ath/ath9k/ar9002_phy.h | 1 + src/drivers/net/ath/ath9k/ar9003_2p2_initvals.h | 2 ++ src/drivers/net/ath/ath9k/ar9003_eeprom.h | 1 + src/drivers/net/ath/ath9k/ar9003_mac.h | 2 ++ src/drivers/net/ath/ath9k/ar9003_phy.h | 2 ++ src/drivers/net/ath/ath9k/ar9340_initvals.h | 2 ++ src/drivers/net/ath/ath9k/ar9485_initvals.h | 2 ++ src/drivers/net/ath/ath9k/ath9k.c | 2 ++ src/drivers/net/ath/ath9k/ath9k.h | 1 + src/drivers/net/ath/ath9k/ath9k_ani.c | 2 ++ src/drivers/net/ath/ath9k/ath9k_ar5008_phy.c | 2 ++ src/drivers/net/ath/ath9k/ath9k_ar9002_calib.c | 2 ++ src/drivers/net/ath/ath9k/ath9k_ar9002_hw.c | 1 + src/drivers/net/ath/ath9k/ath9k_ar9002_mac.c | 2 ++ src/drivers/net/ath/ath9k/ath9k_ar9002_phy.c | 2 ++ src/drivers/net/ath/ath9k/ath9k_ar9003_calib.c | 2 ++ src/drivers/net/ath/ath9k/ath9k_ar9003_eeprom.c | 2 ++ src/drivers/net/ath/ath9k/ath9k_ar9003_hw.c | 2 ++ src/drivers/net/ath/ath9k/ath9k_ar9003_mac.c | 3 +++ src/drivers/net/ath/ath9k/ath9k_ar9003_phy.c | 2 ++ src/drivers/net/ath/ath9k/ath9k_calib.c | 2 ++ src/drivers/net/ath/ath9k/ath9k_common.c | 2 ++ src/drivers/net/ath/ath9k/ath9k_eeprom.c | 2 ++ src/drivers/net/ath/ath9k/ath9k_eeprom_4k.c | 2 ++ src/drivers/net/ath/ath9k/ath9k_eeprom_9287.c | 2 ++ src/drivers/net/ath/ath9k/ath9k_eeprom_def.c | 2 ++ src/drivers/net/ath/ath9k/ath9k_hw.c | 2 ++ src/drivers/net/ath/ath9k/ath9k_init.c | 1 + src/drivers/net/ath/ath9k/ath9k_mac.c | 2 ++ src/drivers/net/ath/ath9k/ath9k_main.c | 2 ++ src/drivers/net/ath/ath9k/ath9k_recv.c | 2 ++ src/drivers/net/ath/ath9k/ath9k_xmit.c | 2 ++ src/drivers/net/ath/ath9k/calib.h | 1 + src/drivers/net/ath/ath9k/common.h | 1 + src/drivers/net/ath/ath9k/eeprom.h | 1 + src/drivers/net/ath/ath9k/hw-ops.h | 1 + src/drivers/net/ath/ath9k/hw.h | 1 + src/drivers/net/ath/ath9k/mac.h | 1 + src/drivers/net/ath/ath9k/phy.h | 1 + src/drivers/net/ath/ath9k/reg.h | 1 + src/drivers/net/ath/ath_hw.c | 2 ++ src/drivers/net/ath/ath_key.c | 2 ++ src/drivers/net/ath/ath_regd.c | 2 ++ src/drivers/net/ath/reg.h | 1 + src/drivers/net/ath/regd.h | 1 + src/drivers/net/ath/regd_common.h | 2 ++ src/drivers/net/rtl818x/rtl8180.c | 1 + src/drivers/net/rtl818x/rtl8180_grf5101.c | 1 + src/drivers/net/rtl818x/rtl8180_max2820.c | 1 + src/drivers/net/rtl818x/rtl8180_sa2400.c | 1 + src/drivers/net/rtl818x/rtl8185.c | 1 + src/drivers/net/rtl818x/rtl8185_rtl8225.c | 1 + src/drivers/net/rtl818x/rtl818x.c | 1 + src/drivers/net/rtl818x/rtl818x.h | 1 + src/net/80211/net80211.c | 1 + src/net/80211/rc80211.c | 1 + src/net/80211/sec80211.c | 1 + src/net/80211/wep.c | 1 + src/net/80211/wpa.c | 1 + src/net/80211/wpa_ccmp.c | 1 + src/net/80211/wpa_psk.c | 1 + src/net/80211/wpa_tkip.c | 1 + src/net/oncrpc/mount.c | 2 ++ src/net/oncrpc/nfs.c | 2 ++ src/net/oncrpc/nfs_open.c | 2 ++ src/net/oncrpc/nfs_uri.c | 2 ++ src/net/oncrpc/oncrpc_iob.c | 2 ++ src/net/oncrpc/portmap.c | 2 ++ 95 files changed, 141 insertions(+), 15 deletions(-) (limited to 'src/drivers') diff --git a/src/Makefile b/src/Makefile index 22f413d25..f9d782f97 100644 --- a/src/Makefile +++ b/src/Makefile @@ -107,16 +107,12 @@ SRCDIRS += hci/mucurses hci/mucurses/widgets SRCDIRS += hci/keymap SRCDIRS += usr SRCDIRS += config - -# These directories contain code that is not eligible for UEFI Secure -# Boot signing. -# -SRCDIRS_INSEC += net/oncrpc -SRCDIRS_INSEC += net/80211 -SRCDIRS_INSEC += drivers/net/rtl818x -SRCDIRS_INSEC += drivers/net/ath -SRCDIRS_INSEC += drivers/net/ath/ath5k -SRCDIRS_INSEC += drivers/net/ath/ath9k +SRCDIRS += net/oncrpc +SRCDIRS += net/80211 +SRCDIRS += drivers/net/rtl818x +SRCDIRS += drivers/net/ath +SRCDIRS += drivers/net/ath/ath5k +SRCDIRS += drivers/net/ath/ath9k # NON_AUTO_SRCS lists files that are excluded from the normal # automatic build system. diff --git a/src/Makefile.housekeeping b/src/Makefile.housekeeping index f56766cd6..d2a23c48a 100644 --- a/src/Makefile.housekeeping +++ b/src/Makefile.housekeeping @@ -436,11 +436,6 @@ endif # # Source file handling -# Exclude known-insecure files from Secure Boot builds -ifeq ($(SECUREBOOT),0) -SRCDIRS += $(SRCDIRS_INSEC) -endif - # SRCDIRS lists all directories containing source files. srcdirs : @$(ECHO) $(SRCDIRS) diff --git a/src/drivers/net/ath/ath.h b/src/drivers/net/ath/ath.h index 21f795b70..60d2ee021 100644 --- a/src/drivers/net/ath/ath.h +++ b/src/drivers/net/ath/ath.h @@ -21,6 +21,7 @@ #define ATH_H FILE_LICENCE ( BSD2 ); +FILE_SECBOOT ( FORBIDDEN ); #include #include diff --git a/src/drivers/net/ath/ath5k/ath5k.c b/src/drivers/net/ath/ath5k/ath5k.c index 643884d46..09510d3d2 100644 --- a/src/drivers/net/ath/ath5k/ath5k.c +++ b/src/drivers/net/ath/ath5k/ath5k.c @@ -44,6 +44,7 @@ */ FILE_LICENCE ( BSD3 ); +FILE_SECBOOT ( FORBIDDEN ); #include #include diff --git a/src/drivers/net/ath/ath5k/ath5k.h b/src/drivers/net/ath/ath5k/ath5k.h index 727d41279..612926f17 100644 --- a/src/drivers/net/ath/ath5k/ath5k.h +++ b/src/drivers/net/ath/ath5k/ath5k.h @@ -22,6 +22,7 @@ #define _ATH5K_H FILE_LICENCE ( MIT ); +FILE_SECBOOT ( FORBIDDEN ); #include #include diff --git a/src/drivers/net/ath/ath5k/ath5k_attach.c b/src/drivers/net/ath/ath5k/ath5k_attach.c index 302536dbd..fb3382943 100644 --- a/src/drivers/net/ath/ath5k/ath5k_attach.c +++ b/src/drivers/net/ath/ath5k/ath5k_attach.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( MIT ); +FILE_SECBOOT ( FORBIDDEN ); /*************************************\ * Attach/Detach Functions and helpers * diff --git a/src/drivers/net/ath/ath5k/ath5k_caps.c b/src/drivers/net/ath/ath5k/ath5k_caps.c index 9c00d15d7..bc5abc58c 100644 --- a/src/drivers/net/ath/ath5k/ath5k_caps.c +++ b/src/drivers/net/ath/ath5k/ath5k_caps.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( MIT ); +FILE_SECBOOT ( FORBIDDEN ); /**************\ * Capabilities * diff --git a/src/drivers/net/ath/ath5k/ath5k_desc.c b/src/drivers/net/ath/ath5k/ath5k_desc.c index 816d26ede..a3ac340df 100644 --- a/src/drivers/net/ath/ath5k/ath5k_desc.c +++ b/src/drivers/net/ath/ath5k/ath5k_desc.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( MIT ); +FILE_SECBOOT ( FORBIDDEN ); /******************************\ Hardware Descriptor Functions diff --git a/src/drivers/net/ath/ath5k/ath5k_dma.c b/src/drivers/net/ath/ath5k/ath5k_dma.c index fa1e0d013..f27ea8fd2 100644 --- a/src/drivers/net/ath/ath5k/ath5k_dma.c +++ b/src/drivers/net/ath/ath5k/ath5k_dma.c @@ -19,6 +19,7 @@ */ FILE_LICENCE ( MIT ); +FILE_SECBOOT ( FORBIDDEN ); /*************************************\ * DMA and interrupt masking functions * diff --git a/src/drivers/net/ath/ath5k/ath5k_eeprom.c b/src/drivers/net/ath/ath5k/ath5k_eeprom.c index 46f33d1e8..5219ef148 100644 --- a/src/drivers/net/ath/ath5k/ath5k_eeprom.c +++ b/src/drivers/net/ath/ath5k/ath5k_eeprom.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( MIT ); +FILE_SECBOOT ( FORBIDDEN ); /*************************************\ * EEPROM access functions and helpers * diff --git a/src/drivers/net/ath/ath5k/ath5k_gpio.c b/src/drivers/net/ath/ath5k/ath5k_gpio.c index 2301ec70b..7f9652b1e 100644 --- a/src/drivers/net/ath/ath5k/ath5k_gpio.c +++ b/src/drivers/net/ath/ath5k/ath5k_gpio.c @@ -19,6 +19,7 @@ */ FILE_LICENCE ( MIT ); +FILE_SECBOOT ( FORBIDDEN ); /****************\ GPIO Functions diff --git a/src/drivers/net/ath/ath5k/ath5k_initvals.c b/src/drivers/net/ath/ath5k/ath5k_initvals.c index 8f3bd2034..f2fd23bb4 100644 --- a/src/drivers/net/ath/ath5k/ath5k_initvals.c +++ b/src/drivers/net/ath/ath5k/ath5k_initvals.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( MIT ); +FILE_SECBOOT ( FORBIDDEN ); #include diff --git a/src/drivers/net/ath/ath5k/ath5k_pcu.c b/src/drivers/net/ath/ath5k/ath5k_pcu.c index c8165da79..6821a01d5 100644 --- a/src/drivers/net/ath/ath5k/ath5k_pcu.c +++ b/src/drivers/net/ath/ath5k/ath5k_pcu.c @@ -23,6 +23,7 @@ */ FILE_LICENCE ( MIT ); +FILE_SECBOOT ( FORBIDDEN ); /*********************************\ * Protocol Control Unit Functions * diff --git a/src/drivers/net/ath/ath5k/ath5k_phy.c b/src/drivers/net/ath/ath5k/ath5k_phy.c index c2a66a4d3..d220b255b 100644 --- a/src/drivers/net/ath/ath5k/ath5k_phy.c +++ b/src/drivers/net/ath/ath5k/ath5k_phy.c @@ -23,6 +23,7 @@ */ FILE_LICENCE ( MIT ); +FILE_SECBOOT ( FORBIDDEN ); #define _ATH5K_PHY diff --git a/src/drivers/net/ath/ath5k/ath5k_qcu.c b/src/drivers/net/ath/ath5k/ath5k_qcu.c index e38dba9e2..ff4b9e5e3 100644 --- a/src/drivers/net/ath/ath5k/ath5k_qcu.c +++ b/src/drivers/net/ath/ath5k/ath5k_qcu.c @@ -19,6 +19,7 @@ */ FILE_LICENCE ( MIT ); +FILE_SECBOOT ( FORBIDDEN ); /********************************************\ Queue Control Unit, DFS Control Unit Functions diff --git a/src/drivers/net/ath/ath5k/ath5k_reset.c b/src/drivers/net/ath/ath5k/ath5k_reset.c index 73765a7b0..98c729cf0 100644 --- a/src/drivers/net/ath/ath5k/ath5k_reset.c +++ b/src/drivers/net/ath/ath5k/ath5k_reset.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( MIT ); +FILE_SECBOOT ( FORBIDDEN ); #define _ATH5K_RESET diff --git a/src/drivers/net/ath/ath5k/ath5k_rfkill.c b/src/drivers/net/ath/ath5k/ath5k_rfkill.c index 752ef70b9..74708af9e 100644 --- a/src/drivers/net/ath/ath5k/ath5k_rfkill.c +++ b/src/drivers/net/ath/ath5k/ath5k_rfkill.c @@ -35,6 +35,7 @@ */ FILE_LICENCE ( MIT ); +FILE_SECBOOT ( FORBIDDEN ); #include "base.h" diff --git a/src/drivers/net/ath/ath5k/base.h b/src/drivers/net/ath/ath5k/base.h index 976a3f306..1155da68e 100644 --- a/src/drivers/net/ath/ath5k/base.h +++ b/src/drivers/net/ath/ath5k/base.h @@ -45,6 +45,7 @@ #define _DEV_ATH_ATHVAR_H FILE_LICENCE ( BSD3 ); +FILE_SECBOOT ( FORBIDDEN ); #include "ath5k.h" #include diff --git a/src/drivers/net/ath/ath5k/desc.h b/src/drivers/net/ath/ath5k/desc.h index 6e11b0d43..bcbd291f4 100644 --- a/src/drivers/net/ath/ath5k/desc.h +++ b/src/drivers/net/ath/ath5k/desc.h @@ -16,6 +16,8 @@ * */ +FILE_SECBOOT ( FORBIDDEN ); + /* * Internal RX/TX descriptor structures * (rX: reserved fields possibily used by future versions of the ar5k chipset) diff --git a/src/drivers/net/ath/ath5k/eeprom.h b/src/drivers/net/ath/ath5k/eeprom.h index da4543393..e7b25b09f 100644 --- a/src/drivers/net/ath/ath5k/eeprom.h +++ b/src/drivers/net/ath/ath5k/eeprom.h @@ -16,6 +16,8 @@ * */ +FILE_SECBOOT ( FORBIDDEN ); + /* * Common ar5xxx EEPROM data offsets (set these on AR5K_EEPROM_BASE) */ diff --git a/src/drivers/net/ath/ath5k/reg.h b/src/drivers/net/ath/ath5k/reg.h index 7070d1543..fd9aa7c8e 100644 --- a/src/drivers/net/ath/ath5k/reg.h +++ b/src/drivers/net/ath/ath5k/reg.h @@ -17,6 +17,8 @@ * */ +FILE_SECBOOT ( FORBIDDEN ); + /* * Register values for Atheros 5210/5211/5212 cards from OpenBSD's ar5k * maintained by Reyk Floeter diff --git a/src/drivers/net/ath/ath5k/rfbuffer.h b/src/drivers/net/ath/ath5k/rfbuffer.h index e50baff66..bcbaf1db9 100644 --- a/src/drivers/net/ath/ath5k/rfbuffer.h +++ b/src/drivers/net/ath/ath5k/rfbuffer.h @@ -17,6 +17,7 @@ * */ +FILE_SECBOOT ( FORBIDDEN ); /* * There are some special registers on the RF chip diff --git a/src/drivers/net/ath/ath5k/rfgain.h b/src/drivers/net/ath/ath5k/rfgain.h index 1354d8c39..a220d8661 100644 --- a/src/drivers/net/ath/ath5k/rfgain.h +++ b/src/drivers/net/ath/ath5k/rfgain.h @@ -18,6 +18,8 @@ * */ +FILE_SECBOOT ( FORBIDDEN ); + /* * Mode-specific RF Gain table (64bytes) for RF5111/5112 * (RF5110 only comes with AR5210 and only supports a/turbo a mode so initial diff --git a/src/drivers/net/ath/ath9k/ani.h b/src/drivers/net/ath/ath9k/ani.h index ba87ba0fd..2aeb5654d 100644 --- a/src/drivers/net/ath/ath9k/ani.h +++ b/src/drivers/net/ath/ath9k/ani.h @@ -21,6 +21,7 @@ #define ANI_H FILE_LICENCE ( BSD2 ); +FILE_SECBOOT ( FORBIDDEN ); #define HAL_PROCESS_ANI 0x00000001 diff --git a/src/drivers/net/ath/ath9k/ar5008_initvals.h b/src/drivers/net/ath/ath9k/ar5008_initvals.h index fcc155654..a4466b286 100644 --- a/src/drivers/net/ath/ath9k/ar5008_initvals.h +++ b/src/drivers/net/ath/ath9k/ar5008_initvals.h @@ -15,6 +15,7 @@ */ FILE_LICENCE ( BSD2 ); +FILE_SECBOOT ( FORBIDDEN ); static const u32 ar5416Modes[][6] = { {0x00001030, 0x00000230, 0x00000460, 0x000002c0, 0x00000160, 0x000001e0}, diff --git a/src/drivers/net/ath/ath9k/ar9001_initvals.h b/src/drivers/net/ath/ath9k/ar9001_initvals.h index 6c1ccd50e..5bf2d5dd4 100644 --- a/src/drivers/net/ath/ath9k/ar9001_initvals.h +++ b/src/drivers/net/ath/ath9k/ar9001_initvals.h @@ -15,6 +15,7 @@ */ FILE_LICENCE ( BSD2 ); +FILE_SECBOOT ( FORBIDDEN ); static const u32 ar5416Modes_9100[][6] = { {0x00001030, 0x00000230, 0x00000460, 0x000002c0, 0x00000160, 0x000001e0}, diff --git a/src/drivers/net/ath/ath9k/ar9002_initvals.h b/src/drivers/net/ath/ath9k/ar9002_initvals.h index f9a92c9b7..82bd94a5e 100644 --- a/src/drivers/net/ath/ath9k/ar9002_initvals.h +++ b/src/drivers/net/ath/ath9k/ar9002_initvals.h @@ -15,6 +15,7 @@ */ FILE_LICENCE ( BSD2 ); +FILE_SECBOOT ( FORBIDDEN ); static __unused const u32 ar9280Modes_9280_2[][6] = { {0x00001030, 0x00000230, 0x00000460, 0x000002c0, 0x00000160, 0x000001e0}, diff --git a/src/drivers/net/ath/ath9k/ar9002_phy.h b/src/drivers/net/ath/ath9k/ar9002_phy.h index 71d9162c9..a6f5db97a 100644 --- a/src/drivers/net/ath/ath9k/ar9002_phy.h +++ b/src/drivers/net/ath/ath9k/ar9002_phy.h @@ -17,6 +17,7 @@ #define AR9002_PHY_H FILE_LICENCE ( BSD2 ); +FILE_SECBOOT ( FORBIDDEN ); #define AR_PHY_TEST 0x9800 #define PHY_AGC_CLR 0x10000000 diff --git a/src/drivers/net/ath/ath9k/ar9003_2p2_initvals.h b/src/drivers/net/ath/ath9k/ar9003_2p2_initvals.h index b1303bbaa..b2d30fff5 100644 --- a/src/drivers/net/ath/ath9k/ar9003_2p2_initvals.h +++ b/src/drivers/net/ath/ath9k/ar9003_2p2_initvals.h @@ -17,6 +17,8 @@ #ifndef INITVALS_9003_2P2_H #define INITVALS_9003_2P2_H +FILE_SECBOOT ( FORBIDDEN ); + /* AR9003 2.2 */ static __unused const u32 ar9300_2p2_radio_postamble[][5] = { diff --git a/src/drivers/net/ath/ath9k/ar9003_eeprom.h b/src/drivers/net/ath/ath9k/ar9003_eeprom.h index f03879236..092227564 100644 --- a/src/drivers/net/ath/ath9k/ar9003_eeprom.h +++ b/src/drivers/net/ath/ath9k/ar9003_eeprom.h @@ -21,6 +21,7 @@ #define AR9003_EEPROM_H FILE_LICENCE ( BSD2 ); +FILE_SECBOOT ( FORBIDDEN ); #define AR9300_EEP_VER 0xD000 #define AR9300_EEP_VER_MINOR_MASK 0xFFF diff --git a/src/drivers/net/ath/ath9k/ar9003_mac.h b/src/drivers/net/ath/ath9k/ar9003_mac.h index 6442bb779..a5f7e0432 100644 --- a/src/drivers/net/ath/ath9k/ar9003_mac.h +++ b/src/drivers/net/ath/ath9k/ar9003_mac.h @@ -20,6 +20,8 @@ #ifndef AR9003_MAC_H #define AR9003_MAC_H +FILE_SECBOOT ( FORBIDDEN ); + #define AR_DescId 0xffff0000 #define AR_DescId_S 16 #define AR_CtrlStat 0x00004000 diff --git a/src/drivers/net/ath/ath9k/ar9003_phy.h b/src/drivers/net/ath/ath9k/ar9003_phy.h index 443090d27..130b5c65b 100644 --- a/src/drivers/net/ath/ath9k/ar9003_phy.h +++ b/src/drivers/net/ath/ath9k/ar9003_phy.h @@ -17,6 +17,8 @@ #ifndef AR9003_PHY_H #define AR9003_PHY_H +FILE_SECBOOT ( FORBIDDEN ); + /* * Channel Register Map */ diff --git a/src/drivers/net/ath/ath9k/ar9340_initvals.h b/src/drivers/net/ath/ath9k/ar9340_initvals.h index 784080b16..5ee400050 100644 --- a/src/drivers/net/ath/ath9k/ar9340_initvals.h +++ b/src/drivers/net/ath/ath9k/ar9340_initvals.h @@ -17,6 +17,8 @@ #ifndef INITVALS_9340_H #define INITVALS_9340_H +FILE_SECBOOT ( FORBIDDEN ); + static __unused const u32 ar9340_1p0_radio_postamble[][5] = { /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ {0x000160ac, 0xa4646800, 0xa4646800, 0xa4646800, 0xa4646800}, diff --git a/src/drivers/net/ath/ath9k/ar9485_initvals.h b/src/drivers/net/ath/ath9k/ar9485_initvals.h index c854398aa..8892bb1b7 100644 --- a/src/drivers/net/ath/ath9k/ar9485_initvals.h +++ b/src/drivers/net/ath/ath9k/ar9485_initvals.h @@ -17,6 +17,8 @@ #ifndef INITVALS_9485_H #define INITVALS_9485_H +FILE_SECBOOT ( FORBIDDEN ); + static __unused const u32 ar9485_1_1_mac_core[][2] = { /* Addr allmodes */ {0x00000008, 0x00000000}, diff --git a/src/drivers/net/ath/ath9k/ath9k.c b/src/drivers/net/ath/ath9k/ath9k.c index 98b7ecd5a..a3020bc65 100644 --- a/src/drivers/net/ath/ath9k/ath9k.c +++ b/src/drivers/net/ath/ath9k/ath9k.c @@ -17,6 +17,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +FILE_SECBOOT ( FORBIDDEN ); + #include #include "ath9k.h" diff --git a/src/drivers/net/ath/ath9k/ath9k.h b/src/drivers/net/ath/ath9k/ath9k.h index 36dc97e99..9d62d9b82 100644 --- a/src/drivers/net/ath/ath9k/ath9k.h +++ b/src/drivers/net/ath/ath9k/ath9k.h @@ -21,6 +21,7 @@ #define ATH9K_H FILE_LICENCE ( BSD2 ); +FILE_SECBOOT ( FORBIDDEN ); #include "common.h" diff --git a/src/drivers/net/ath/ath9k/ath9k_ani.c b/src/drivers/net/ath/ath9k/ath9k_ani.c index 76ca79cba..2b0f11c3f 100644 --- a/src/drivers/net/ath/ath9k/ath9k_ani.c +++ b/src/drivers/net/ath/ath9k/ath9k_ani.c @@ -17,6 +17,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +FILE_SECBOOT ( FORBIDDEN ); + #include "hw.h" #include "hw-ops.h" diff --git a/src/drivers/net/ath/ath9k/ath9k_ar5008_phy.c b/src/drivers/net/ath/ath9k/ath9k_ar5008_phy.c index a98e4bb66..622955368 100644 --- a/src/drivers/net/ath/ath9k/ath9k_ar5008_phy.c +++ b/src/drivers/net/ath/ath9k/ath9k_ar5008_phy.c @@ -17,6 +17,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +FILE_SECBOOT ( FORBIDDEN ); + #include #include diff --git a/src/drivers/net/ath/ath9k/ath9k_ar9002_calib.c b/src/drivers/net/ath/ath9k/ath9k_ar9002_calib.c index f8978a558..b03da98b3 100644 --- a/src/drivers/net/ath/ath9k/ath9k_ar9002_calib.c +++ b/src/drivers/net/ath/ath9k/ath9k_ar9002_calib.c @@ -17,6 +17,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +FILE_SECBOOT ( FORBIDDEN ); + #include "hw.h" #include "hw-ops.h" #include "ar9002_phy.h" diff --git a/src/drivers/net/ath/ath9k/ath9k_ar9002_hw.c b/src/drivers/net/ath/ath9k/ath9k_ar9002_hw.c index 85d0c7de6..0477af4d1 100644 --- a/src/drivers/net/ath/ath9k/ath9k_ar9002_hw.c +++ b/src/drivers/net/ath/ath9k/ath9k_ar9002_hw.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( BSD2 ); +FILE_SECBOOT ( FORBIDDEN ); #include "hw.h" #include "ar5008_initvals.h" diff --git a/src/drivers/net/ath/ath9k/ath9k_ar9002_mac.c b/src/drivers/net/ath/ath9k/ath9k_ar9002_mac.c index 057756b2e..b6308ffc4 100644 --- a/src/drivers/net/ath/ath9k/ath9k_ar9002_mac.c +++ b/src/drivers/net/ath/ath9k/ath9k_ar9002_mac.c @@ -17,6 +17,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +FILE_SECBOOT ( FORBIDDEN ); + #include #include "hw.h" diff --git a/src/drivers/net/ath/ath9k/ath9k_ar9002_phy.c b/src/drivers/net/ath/ath9k/ath9k_ar9002_phy.c index 65cfad597..396763533 100644 --- a/src/drivers/net/ath/ath9k/ath9k_ar9002_phy.c +++ b/src/drivers/net/ath/ath9k/ath9k_ar9002_phy.c @@ -17,6 +17,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +FILE_SECBOOT ( FORBIDDEN ); + /** * DOC: Programming Atheros 802.11n analog front end radios * diff --git a/src/drivers/net/ath/ath9k/ath9k_ar9003_calib.c b/src/drivers/net/ath/ath9k/ath9k_ar9003_calib.c index c37168bd2..4b6b7f907 100644 --- a/src/drivers/net/ath/ath9k/ath9k_ar9003_calib.c +++ b/src/drivers/net/ath/ath9k/ath9k_ar9003_calib.c @@ -17,6 +17,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +FILE_SECBOOT ( FORBIDDEN ); + #include #include "hw.h" diff --git a/src/drivers/net/ath/ath9k/ath9k_ar9003_eeprom.c b/src/drivers/net/ath/ath9k/ath9k_ar9003_eeprom.c index 95e54b9b2..96aa9ef2b 100644 --- a/src/drivers/net/ath/ath9k/ath9k_ar9003_eeprom.c +++ b/src/drivers/net/ath/ath9k/ath9k_ar9003_eeprom.c @@ -17,6 +17,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +FILE_SECBOOT ( FORBIDDEN ); + #include #include diff --git a/src/drivers/net/ath/ath9k/ath9k_ar9003_hw.c b/src/drivers/net/ath/ath9k/ath9k_ar9003_hw.c index f3020fd7e..2276ded25 100644 --- a/src/drivers/net/ath/ath9k/ath9k_ar9003_hw.c +++ b/src/drivers/net/ath/ath9k/ath9k_ar9003_hw.c @@ -17,6 +17,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +FILE_SECBOOT ( FORBIDDEN ); + #include "hw.h" #include "ar9003_mac.h" #include "ar9003_2p2_initvals.h" diff --git a/src/drivers/net/ath/ath9k/ath9k_ar9003_mac.c b/src/drivers/net/ath/ath9k/ath9k_ar9003_mac.c index 1fa4039cc..7f1b26182 100644 --- a/src/drivers/net/ath/ath9k/ath9k_ar9003_mac.c +++ b/src/drivers/net/ath/ath9k/ath9k_ar9003_mac.c @@ -16,6 +16,9 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +FILE_SECBOOT ( FORBIDDEN ); + #include #include "hw.h" diff --git a/src/drivers/net/ath/ath9k/ath9k_ar9003_phy.c b/src/drivers/net/ath/ath9k/ath9k_ar9003_phy.c index b66358b92..ebc10c50f 100644 --- a/src/drivers/net/ath/ath9k/ath9k_ar9003_phy.c +++ b/src/drivers/net/ath/ath9k/ath9k_ar9003_phy.c @@ -17,6 +17,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +FILE_SECBOOT ( FORBIDDEN ); + #include #include "hw.h" diff --git a/src/drivers/net/ath/ath9k/ath9k_calib.c b/src/drivers/net/ath/ath9k/ath9k_calib.c index 6f3e07e6d..5da8a5ba0 100644 --- a/src/drivers/net/ath/ath9k/ath9k_calib.c +++ b/src/drivers/net/ath/ath9k/ath9k_calib.c @@ -17,6 +17,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +FILE_SECBOOT ( FORBIDDEN ); + #include "hw.h" #include "hw-ops.h" diff --git a/src/drivers/net/ath/ath9k/ath9k_common.c b/src/drivers/net/ath/ath9k/ath9k_common.c index ce33afbd4..474ff6a0c 100644 --- a/src/drivers/net/ath/ath9k/ath9k_common.c +++ b/src/drivers/net/ath/ath9k/ath9k_common.c @@ -17,6 +17,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +FILE_SECBOOT ( FORBIDDEN ); + /* * Module for common driver code between ath9k and ath9k_htc */ diff --git a/src/drivers/net/ath/ath9k/ath9k_eeprom.c b/src/drivers/net/ath/ath9k/ath9k_eeprom.c index a20423790..95e677591 100644 --- a/src/drivers/net/ath/ath9k/ath9k_eeprom.c +++ b/src/drivers/net/ath/ath9k/ath9k_eeprom.c @@ -17,6 +17,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +FILE_SECBOOT ( FORBIDDEN ); + #include #include "hw.h" diff --git a/src/drivers/net/ath/ath9k/ath9k_eeprom_4k.c b/src/drivers/net/ath/ath9k/ath9k_eeprom_4k.c index a42ad3d97..a0ba897aa 100644 --- a/src/drivers/net/ath/ath9k/ath9k_eeprom_4k.c +++ b/src/drivers/net/ath/ath9k/ath9k_eeprom_4k.c @@ -17,6 +17,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +FILE_SECBOOT ( FORBIDDEN ); + #include #include "hw.h" diff --git a/src/drivers/net/ath/ath9k/ath9k_eeprom_9287.c b/src/drivers/net/ath/ath9k/ath9k_eeprom_9287.c index ee16a6f18..323a6307e 100644 --- a/src/drivers/net/ath/ath9k/ath9k_eeprom_9287.c +++ b/src/drivers/net/ath/ath9k/ath9k_eeprom_9287.c @@ -17,6 +17,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +FILE_SECBOOT ( FORBIDDEN ); + #include #include "hw.h" diff --git a/src/drivers/net/ath/ath9k/ath9k_eeprom_def.c b/src/drivers/net/ath/ath9k/ath9k_eeprom_def.c index 9b144d70b..e4941188f 100644 --- a/src/drivers/net/ath/ath9k/ath9k_eeprom_def.c +++ b/src/drivers/net/ath/ath9k/ath9k_eeprom_def.c @@ -17,6 +17,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +FILE_SECBOOT ( FORBIDDEN ); + #include #include "hw.h" diff --git a/src/drivers/net/ath/ath9k/ath9k_hw.c b/src/drivers/net/ath/ath9k/ath9k_hw.c index 554e9be3c..8f123add6 100644 --- a/src/drivers/net/ath/ath9k/ath9k_hw.c +++ b/src/drivers/net/ath/ath9k/ath9k_hw.c @@ -17,6 +17,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +FILE_SECBOOT ( FORBIDDEN ); + #include #include diff --git a/src/drivers/net/ath/ath9k/ath9k_init.c b/src/drivers/net/ath/ath9k/ath9k_init.c index 05ed3336a..2350f724e 100644 --- a/src/drivers/net/ath/ath9k/ath9k_init.c +++ b/src/drivers/net/ath/ath9k/ath9k_init.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( BSD2 ); +FILE_SECBOOT ( FORBIDDEN ); #include #include diff --git a/src/drivers/net/ath/ath9k/ath9k_mac.c b/src/drivers/net/ath/ath9k/ath9k_mac.c index c2f6d630a..d8ef0682f 100644 --- a/src/drivers/net/ath/ath9k/ath9k_mac.c +++ b/src/drivers/net/ath/ath9k/ath9k_mac.c @@ -17,6 +17,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +FILE_SECBOOT ( FORBIDDEN ); + #include #include "hw.h" diff --git a/src/drivers/net/ath/ath9k/ath9k_main.c b/src/drivers/net/ath/ath9k/ath9k_main.c index 0a17b9bcb..81562c87d 100644 --- a/src/drivers/net/ath/ath9k/ath9k_main.c +++ b/src/drivers/net/ath/ath9k/ath9k_main.c @@ -17,6 +17,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +FILE_SECBOOT ( FORBIDDEN ); + #include #include "ath9k.h" diff --git a/src/drivers/net/ath/ath9k/ath9k_recv.c b/src/drivers/net/ath/ath9k/ath9k_recv.c index 0ffe9d45a..245e1390a 100644 --- a/src/drivers/net/ath/ath9k/ath9k_recv.c +++ b/src/drivers/net/ath/ath9k/ath9k_recv.c @@ -17,6 +17,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +FILE_SECBOOT ( FORBIDDEN ); + #include #include "ath9k.h" diff --git a/src/drivers/net/ath/ath9k/ath9k_xmit.c b/src/drivers/net/ath/ath9k/ath9k_xmit.c index 7f4f28ab8..354cb37a8 100644 --- a/src/drivers/net/ath/ath9k/ath9k_xmit.c +++ b/src/drivers/net/ath/ath9k/ath9k_xmit.c @@ -17,6 +17,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +FILE_SECBOOT ( FORBIDDEN ); + #include #include "ath9k.h" diff --git a/src/drivers/net/ath/ath9k/calib.h b/src/drivers/net/ath/ath9k/calib.h index b811accf0..955721d63 100644 --- a/src/drivers/net/ath/ath9k/calib.h +++ b/src/drivers/net/ath/ath9k/calib.h @@ -21,6 +21,7 @@ #define CALIB_H FILE_LICENCE ( BSD2 ); +FILE_SECBOOT ( FORBIDDEN ); #include "hw.h" diff --git a/src/drivers/net/ath/ath9k/common.h b/src/drivers/net/ath/ath9k/common.h index 0fe3b5be6..b3d4fa481 100644 --- a/src/drivers/net/ath/ath9k/common.h +++ b/src/drivers/net/ath/ath9k/common.h @@ -18,6 +18,7 @@ */ FILE_LICENCE ( BSD2 ); +FILE_SECBOOT ( FORBIDDEN ); #include "../ath.h" diff --git a/src/drivers/net/ath/ath9k/eeprom.h b/src/drivers/net/ath/ath9k/eeprom.h index 8a48d6e5f..86521bccf 100644 --- a/src/drivers/net/ath/ath9k/eeprom.h +++ b/src/drivers/net/ath/ath9k/eeprom.h @@ -21,6 +21,7 @@ #define EEPROM_H FILE_LICENCE ( BSD2 ); +FILE_SECBOOT ( FORBIDDEN ); #define AR_EEPROM_MODAL_SPURS 5 diff --git a/src/drivers/net/ath/ath9k/hw-ops.h b/src/drivers/net/ath/ath9k/hw-ops.h index 51c7b08e4..c35be7dd0 100644 --- a/src/drivers/net/ath/ath9k/hw-ops.h +++ b/src/drivers/net/ath/ath9k/hw-ops.h @@ -18,6 +18,7 @@ #define ATH9K_HW_OPS_H FILE_LICENCE ( BSD2 ); +FILE_SECBOOT ( FORBIDDEN ); #include "hw.h" diff --git a/src/drivers/net/ath/ath9k/hw.h b/src/drivers/net/ath/ath9k/hw.h index 051074691..02e9fc346 100644 --- a/src/drivers/net/ath/ath9k/hw.h +++ b/src/drivers/net/ath/ath9k/hw.h @@ -21,6 +21,7 @@ #define HW_H FILE_LICENCE ( BSD2 ); +FILE_SECBOOT ( FORBIDDEN ); #include diff --git a/src/drivers/net/ath/ath9k/mac.h b/src/drivers/net/ath/ath9k/mac.h index 0c0a75948..be0429169 100644 --- a/src/drivers/net/ath/ath9k/mac.h +++ b/src/drivers/net/ath/ath9k/mac.h @@ -21,6 +21,7 @@ #define MAC_H FILE_LICENCE ( BSD2 ); +FILE_SECBOOT ( FORBIDDEN ); #include diff --git a/src/drivers/net/ath/ath9k/phy.h b/src/drivers/net/ath/ath9k/phy.h index 28f59ecd9..69adbb1a5 100644 --- a/src/drivers/net/ath/ath9k/phy.h +++ b/src/drivers/net/ath/ath9k/phy.h @@ -18,6 +18,7 @@ #define PHY_H FILE_LICENCE ( BSD2 ); +FILE_SECBOOT ( FORBIDDEN ); #define CHANSEL_DIV 15 #define CHANSEL_2G(_freq) (((_freq) * 0x10000) / CHANSEL_DIV) diff --git a/src/drivers/net/ath/ath9k/reg.h b/src/drivers/net/ath/ath9k/reg.h index 67762b6d1..8e81f4787 100644 --- a/src/drivers/net/ath/ath9k/reg.h +++ b/src/drivers/net/ath/ath9k/reg.h @@ -18,6 +18,7 @@ #define REG_H FILE_LICENCE ( BSD2 ); +FILE_SECBOOT ( FORBIDDEN ); #include "../reg.h" diff --git a/src/drivers/net/ath/ath_hw.c b/src/drivers/net/ath/ath_hw.c index 8e3128868..0a044ea50 100644 --- a/src/drivers/net/ath/ath_hw.c +++ b/src/drivers/net/ath/ath_hw.c @@ -17,6 +17,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +FILE_SECBOOT ( FORBIDDEN ); + #include #include "ath.h" diff --git a/src/drivers/net/ath/ath_key.c b/src/drivers/net/ath/ath_key.c index d269a45ac..217e98ef4 100644 --- a/src/drivers/net/ath/ath_key.c +++ b/src/drivers/net/ath/ath_key.c @@ -18,6 +18,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +FILE_SECBOOT ( FORBIDDEN ); + #include "ath.h" #include "reg.h" diff --git a/src/drivers/net/ath/ath_regd.c b/src/drivers/net/ath/ath_regd.c index 190b1f9f5..0dba257bc 100644 --- a/src/drivers/net/ath/ath_regd.c +++ b/src/drivers/net/ath/ath_regd.c @@ -17,6 +17,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +FILE_SECBOOT ( FORBIDDEN ); + #include "regd.h" #include "regd_common.h" diff --git a/src/drivers/net/ath/reg.h b/src/drivers/net/ath/reg.h index 7982f4344..c4833a515 100644 --- a/src/drivers/net/ath/reg.h +++ b/src/drivers/net/ath/reg.h @@ -21,6 +21,7 @@ #define ATH_REGISTERS_H FILE_LICENCE ( BSD2 ); +FILE_SECBOOT ( FORBIDDEN ); #define AR_MIBC 0x0040 #define AR_MIBC_COW 0x00000001 diff --git a/src/drivers/net/ath/regd.h b/src/drivers/net/ath/regd.h index fd09a0c8d..a0634cd73 100644 --- a/src/drivers/net/ath/regd.h +++ b/src/drivers/net/ath/regd.h @@ -21,6 +21,7 @@ #define REGD_H FILE_LICENCE ( BSD2 ); +FILE_SECBOOT ( FORBIDDEN ); #include "ath.h" diff --git a/src/drivers/net/ath/regd_common.h b/src/drivers/net/ath/regd_common.h index ee1ac3f40..1e219c1dd 100644 --- a/src/drivers/net/ath/regd_common.h +++ b/src/drivers/net/ath/regd_common.h @@ -20,6 +20,8 @@ #ifndef REGD_COMMON_H #define REGD_COMMON_H +FILE_SECBOOT ( FORBIDDEN ); + enum EnumRd { NO_ENUMRD = 0x00, NULL1_WORLD = 0x03, diff --git a/src/drivers/net/rtl818x/rtl8180.c b/src/drivers/net/rtl818x/rtl8180.c index b3f685419..d92c8ea67 100644 --- a/src/drivers/net/rtl818x/rtl8180.c +++ b/src/drivers/net/rtl818x/rtl8180.c @@ -1,6 +1,7 @@ /* Realtek 8180 card: rtl818x driver + rtl8180 RF modules */ FILE_LICENCE(GPL2_OR_LATER); +FILE_SECBOOT(FORBIDDEN); #include #include "rtl818x.h" diff --git a/src/drivers/net/rtl818x/rtl8180_grf5101.c b/src/drivers/net/rtl818x/rtl8180_grf5101.c index 2b995030c..9e017fd4f 100644 --- a/src/drivers/net/rtl818x/rtl8180_grf5101.c +++ b/src/drivers/net/rtl818x/rtl8180_grf5101.c @@ -27,6 +27,7 @@ #include "rtl818x.h" FILE_LICENCE(GPL2_ONLY); +FILE_SECBOOT(FORBIDDEN); #define GRF5101_ANTENNA 0xA3 diff --git a/src/drivers/net/rtl818x/rtl8180_max2820.c b/src/drivers/net/rtl818x/rtl8180_max2820.c index ab380fcc7..d3cb15454 100644 --- a/src/drivers/net/rtl818x/rtl8180_max2820.c +++ b/src/drivers/net/rtl818x/rtl8180_max2820.c @@ -27,6 +27,7 @@ #include "rtl818x.h" FILE_LICENCE(GPL2_ONLY); +FILE_SECBOOT(FORBIDDEN); #define MAXIM_ANTENNA 0xb3 diff --git a/src/drivers/net/rtl818x/rtl8180_sa2400.c b/src/drivers/net/rtl818x/rtl8180_sa2400.c index 9bd62bed8..d86e52aac 100644 --- a/src/drivers/net/rtl818x/rtl8180_sa2400.c +++ b/src/drivers/net/rtl818x/rtl8180_sa2400.c @@ -27,6 +27,7 @@ #include "rtl818x.h" FILE_LICENCE(GPL2_ONLY); +FILE_SECBOOT(FORBIDDEN); #define SA2400_ANTENNA 0x91 #define SA2400_DIG_ANAPARAM_PWR1_ON 0x8 diff --git a/src/drivers/net/rtl818x/rtl8185.c b/src/drivers/net/rtl818x/rtl8185.c index 234978cea..beaf62566 100644 --- a/src/drivers/net/rtl818x/rtl8185.c +++ b/src/drivers/net/rtl818x/rtl8185.c @@ -1,6 +1,7 @@ /* Realtek 8185 card: rtl818x driver + rtl8185_rtl8225 RF module */ FILE_LICENCE(GPL2_OR_LATER); +FILE_SECBOOT(FORBIDDEN); #include #include "rtl818x.h" diff --git a/src/drivers/net/rtl818x/rtl8185_rtl8225.c b/src/drivers/net/rtl818x/rtl8185_rtl8225.c index 31a740e64..f810215ca 100644 --- a/src/drivers/net/rtl818x/rtl8185_rtl8225.c +++ b/src/drivers/net/rtl818x/rtl8185_rtl8225.c @@ -23,6 +23,7 @@ #include "rtl818x.h" FILE_LICENCE(GPL2_ONLY); +FILE_SECBOOT(FORBIDDEN); #define RTL8225_ANAPARAM_ON 0xa0000b59 #define RTL8225_ANAPARAM2_ON 0x860dec11 diff --git a/src/drivers/net/rtl818x/rtl818x.c b/src/drivers/net/rtl818x/rtl818x.c index 3bae8a797..81592a7db 100644 --- a/src/drivers/net/rtl818x/rtl818x.c +++ b/src/drivers/net/rtl818x/rtl818x.c @@ -18,6 +18,7 @@ */ FILE_LICENCE(GPL2_ONLY); +FILE_SECBOOT(FORBIDDEN); #include #include diff --git a/src/drivers/net/rtl818x/rtl818x.h b/src/drivers/net/rtl818x/rtl818x.h index ae4b8a96f..f8d19604e 100644 --- a/src/drivers/net/rtl818x/rtl818x.h +++ b/src/drivers/net/rtl818x/rtl818x.h @@ -22,6 +22,7 @@ #include FILE_LICENCE(GPL2_ONLY); +FILE_SECBOOT(FORBIDDEN); struct rtl818x_csr { u8 MAC[6]; diff --git a/src/net/80211/net80211.c b/src/net/80211/net80211.c index 482000102..4391b4296 100644 --- a/src/net/80211/net80211.c +++ b/src/net/80211/net80211.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( FORBIDDEN ); #include #include diff --git a/src/net/80211/rc80211.c b/src/net/80211/rc80211.c index eea3bc908..d416867fa 100644 --- a/src/net/80211/rc80211.c +++ b/src/net/80211/rc80211.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( FORBIDDEN ); #include #include diff --git a/src/net/80211/sec80211.c b/src/net/80211/sec80211.c index d1bc75e90..500dec9f5 100644 --- a/src/net/80211/sec80211.c +++ b/src/net/80211/sec80211.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( FORBIDDEN ); #include #include diff --git a/src/net/80211/wep.c b/src/net/80211/wep.c index e22ac8998..053cf1417 100644 --- a/src/net/80211/wep.c +++ b/src/net/80211/wep.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( FORBIDDEN ); #include #include diff --git a/src/net/80211/wpa.c b/src/net/80211/wpa.c index 17c11b8ed..33358221b 100644 --- a/src/net/80211/wpa.c +++ b/src/net/80211/wpa.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( FORBIDDEN ); #include #include diff --git a/src/net/80211/wpa_ccmp.c b/src/net/80211/wpa_ccmp.c index 0abd217e7..f4906d473 100644 --- a/src/net/80211/wpa_ccmp.c +++ b/src/net/80211/wpa_ccmp.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( FORBIDDEN ); #include #include diff --git a/src/net/80211/wpa_psk.c b/src/net/80211/wpa_psk.c index 71190b139..d86204026 100644 --- a/src/net/80211/wpa_psk.c +++ b/src/net/80211/wpa_psk.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( FORBIDDEN ); #include #include diff --git a/src/net/80211/wpa_tkip.c b/src/net/80211/wpa_tkip.c index 3bd651512..39a6391a8 100644 --- a/src/net/80211/wpa_tkip.c +++ b/src/net/80211/wpa_tkip.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( FORBIDDEN ); #include #include diff --git a/src/net/oncrpc/mount.c b/src/net/oncrpc/mount.c index 8838a147c..32279cc25 100644 --- a/src/net/oncrpc/mount.c +++ b/src/net/oncrpc/mount.c @@ -17,6 +17,8 @@ * 02110-1301, USA. */ +FILE_SECBOOT ( FORBIDDEN ); + #include #include #include diff --git a/src/net/oncrpc/nfs.c b/src/net/oncrpc/nfs.c index b6118f91a..3a3a894f0 100644 --- a/src/net/oncrpc/nfs.c +++ b/src/net/oncrpc/nfs.c @@ -17,6 +17,8 @@ * 02110-1301, USA. */ +FILE_SECBOOT ( FORBIDDEN ); + #include #include #include diff --git a/src/net/oncrpc/nfs_open.c b/src/net/oncrpc/nfs_open.c index c0dceb82f..d83991255 100644 --- a/src/net/oncrpc/nfs_open.c +++ b/src/net/oncrpc/nfs_open.c @@ -17,6 +17,8 @@ * 02110-1301, USA. */ +FILE_SECBOOT ( FORBIDDEN ); + #include #include #include diff --git a/src/net/oncrpc/nfs_uri.c b/src/net/oncrpc/nfs_uri.c index c4c3f21e9..b97fb91f9 100644 --- a/src/net/oncrpc/nfs_uri.c +++ b/src/net/oncrpc/nfs_uri.c @@ -17,6 +17,8 @@ * 02110-1301, USA. */ +FILE_SECBOOT ( FORBIDDEN ); + #include #include #include diff --git a/src/net/oncrpc/oncrpc_iob.c b/src/net/oncrpc/oncrpc_iob.c index be51805e7..04bb20edd 100644 --- a/src/net/oncrpc/oncrpc_iob.c +++ b/src/net/oncrpc/oncrpc_iob.c @@ -17,6 +17,8 @@ * 02110-1301, USA. */ +FILE_SECBOOT ( FORBIDDEN ); + #include #include #include diff --git a/src/net/oncrpc/portmap.c b/src/net/oncrpc/portmap.c index df62221dc..be11c42da 100644 --- a/src/net/oncrpc/portmap.c +++ b/src/net/oncrpc/portmap.c @@ -17,6 +17,8 @@ * 02110-1301, USA. */ +FILE_SECBOOT ( FORBIDDEN ); + #include #include #include -- cgit v1.2.3-55-g7522 From 6cccb3bdc00359068c07125258d71ce24db5118a Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 14 Jan 2026 13:25:34 +0000 Subject: [build] Mark core files as permitted for UEFI Secure Boot Mark all files used in a standard build of bin-x86_64-efi/snponly.efi as permitted for UEFI Secure Boot. These files represent the core functionality of iPXE that is guaranteed to have been included in every binary that was previously subject to a security review and signed by Microsoft. It is therefore legitimate to assume that at least these files have already been reviewed to the required standard multiple times. Signed-off-by: Michael Brown --- src/arch/x86/core/cpuid.c | 1 + src/arch/x86/core/x86_string.c | 1 + src/arch/x86/core/x86_tcpip.c | 1 + src/arch/x86/hci/commands/cpuid_cmd.c | 1 + src/arch/x86/include/bits/acpi.h | 1 + src/arch/x86/include/bits/endian.h | 1 + src/arch/x86/include/bits/errfile.h | 1 + src/arch/x86/include/bits/io.h | 1 + src/arch/x86/include/bits/iomap.h | 1 + src/arch/x86/include/bits/memmap.h | 1 + src/arch/x86/include/bits/nap.h | 1 + src/arch/x86/include/bits/pci_io.h | 1 + src/arch/x86/include/bits/reboot.h | 1 + src/arch/x86/include/bits/sanboot.h | 1 + src/arch/x86/include/bits/smbios.h | 1 + src/arch/x86/include/bits/string.h | 1 + src/arch/x86/include/bits/tcpip.h | 1 + src/arch/x86/include/bits/time.h | 1 + src/arch/x86/include/ipxe/bios_nap.h | 1 + src/arch/x86/include/ipxe/bios_reboot.h | 1 + src/arch/x86/include/ipxe/bios_sanboot.h | 1 + src/arch/x86/include/ipxe/bios_smbios.h | 1 + src/arch/x86/include/ipxe/cpuid.h | 1 + src/arch/x86/include/ipxe/int15.h | 1 + src/arch/x86/include/ipxe/iomap_pages.h | 1 + src/arch/x86/include/ipxe/pcibios.h | 1 + src/arch/x86/include/ipxe/pcidirect.h | 1 + src/arch/x86/include/ipxe/rsdp.h | 1 + src/arch/x86/include/ipxe/rtc_time.h | 1 + src/arch/x86/include/ipxe/x86_io.h | 1 + src/arch/x86_64/include/bits/byteswap.h | 1 + src/arch/x86_64/include/bits/compiler.h | 1 + src/arch/x86_64/include/bits/profile.h | 1 + src/arch/x86_64/include/bits/stdint.h | 1 + src/arch/x86_64/include/bits/strings.h | 1 + src/arch/x86_64/include/ipxe/efi/dhcparch.h | 1 + src/arch/x86_64/include/limits.h | 1 + src/config/branding.h | 1 + src/config/colour.h | 1 + src/config/config.c | 1 + src/config/config_eap.c | 1 + src/config/config_efi.c | 1 + src/config/config_ethernet.c | 1 + src/config/config_http.c | 1 + src/config/config_pci.c | 1 + src/config/config_route.c | 1 + src/config/config_timer.c | 1 + src/config/console.h | 1 + src/config/defaults.h | 1 + src/config/defaults/efi.h | 1 + src/config/dhcp.h | 1 + src/config/fault.h | 1 + src/config/general.h | 1 + src/config/ioapi.h | 1 + src/config/named.h | 1 + src/config/nap.h | 1 + src/config/reboot.h | 1 + src/config/sanboot.h | 1 + src/config/settings.h | 1 + src/config/sideband.h | 1 + src/config/time.h | 1 + src/config/timer.h | 1 + src/config/umalloc.h | 1 + src/core/acpi.c | 1 + src/core/ansicol.c | 1 + src/core/ansiesc.c | 1 + src/core/asprintf.c | 1 + src/core/base16.c | 1 + src/core/base64.c | 1 + src/core/basename.c | 1 + src/core/bitmap.c | 1 + src/core/blockdev.c | 1 + src/core/blocktrans.c | 1 + src/core/cachedhcp.c | 1 + src/core/console.c | 1 + src/core/cpio.c | 1 + src/core/ctype.c | 1 + src/core/cwuri.c | 1 + src/core/debug.c | 1 + src/core/device.c | 1 + src/core/dma.c | 1 + src/core/downloader.c | 1 + src/core/dynui.c | 1 + src/core/edd.c | 1 + src/core/errno.c | 1 + src/core/exec.c | 1 + src/core/getkey.c | 1 + src/core/getopt.c | 1 + src/core/image.c | 1 + src/core/init.c | 1 + src/core/interface.c | 1 + src/core/iobuf.c | 1 + src/core/job.c | 1 + src/core/keymap.c | 1 + src/core/linebuf.c | 1 + src/core/list.c | 1 + src/core/main.c | 1 + src/core/malloc.c | 1 + src/core/monojob.c | 1 + src/core/nvo.c | 1 + src/core/open.c | 1 + src/core/params.c | 1 + src/core/parseopt.c | 1 + src/core/pending.c | 1 + src/core/pool.c | 1 + src/core/process.c | 1 + src/core/quiesce.c | 1 + src/core/random.c | 1 + src/core/refcnt.c | 1 + src/core/resolv.c | 1 + src/core/sanboot.c | 1 + src/core/settings.c | 1 + src/core/string.c | 1 + src/core/time.c | 1 + src/core/timer.c | 1 + src/core/uri.c | 1 + src/core/utf8.c | 1 + src/core/uuid.c | 1 + src/core/version.c | 1 + src/core/vsprintf.c | 1 + src/core/wchar.c | 1 + src/core/xfer.c | 1 + src/core/xferbuf.c | 1 + src/crypto/chap.c | 1 + src/crypto/crc32.c | 1 + src/crypto/md5.c | 1 + src/drivers/block/ata.c | 1 + src/drivers/block/ibft.c | 1 + src/drivers/block/scsi.c | 1 + src/drivers/bus/pci.c | 1 + src/drivers/bus/pci_settings.c | 1 + src/drivers/net/efi/mnpnet.c | 1 + src/drivers/net/efi/nii.c | 1 + src/drivers/net/efi/nii.h | 1 + src/drivers/net/efi/snpnet.c | 1 + src/drivers/net/efi/snpnet.h | 1 + src/drivers/net/efi/snponly.c | 1 + src/drivers/nvs/nvs.c | 1 + src/hci/commands/autoboot_cmd.c | 1 + src/hci/commands/config_cmd.c | 1 + src/hci/commands/dhcp_cmd.c | 1 + src/hci/commands/dynui_cmd.c | 1 + src/hci/commands/ifmgmt_cmd.c | 1 + src/hci/commands/image_cmd.c | 1 + src/hci/commands/login_cmd.c | 1 + src/hci/commands/nvo_cmd.c | 1 + src/hci/commands/reboot_cmd.c | 1 + src/hci/commands/route_cmd.c | 1 + src/hci/commands/sanboot_cmd.c | 1 + src/hci/commands/shim_cmd.c | 1 + src/hci/commands/sync_cmd.c | 1 + src/hci/editstring.c | 1 + src/hci/jumpscroll.c | 1 + src/hci/mucurses/ansi_screen.c | 1 + src/hci/mucurses/clear.c | 1 + src/hci/mucurses/cursor.h | 1 + src/hci/mucurses/mucurses.c | 1 + src/hci/mucurses/mucurses.h | 1 + src/hci/mucurses/print.c | 1 + src/hci/mucurses/widgets/editbox.c | 1 + src/hci/mucurses/winattrs.c | 1 + src/hci/mucurses/wininit.c | 1 + src/hci/readline.c | 1 + src/hci/shell.c | 1 + src/hci/strerror.c | 1 + src/hci/tui/form_ui.c | 1 + src/hci/tui/login_ui.c | 1 + src/hci/tui/menu_ui.c | 1 + src/hci/tui/message.c | 1 + src/hci/tui/settings_ui.c | 1 + src/image/efi_image.c | 1 + src/image/embedded.c | 1 + src/image/script.c | 1 + src/include/assert.h | 1 + src/include/bits/dma.h | 1 + src/include/bits/uaccess.h | 1 + src/include/bits/umalloc.h | 1 + src/include/bits/virt_offset.h | 1 + src/include/byteswap.h | 1 + src/include/ctype.h | 1 + src/include/curses.h | 1 + src/include/endian.h | 1 + src/include/errno.h | 1 + src/include/getopt.h | 1 + src/include/hci/ifmgmt_cmd.h | 1 + src/include/ipxe/acpi.h | 1 + src/include/ipxe/ansicol.h | 1 + src/include/ipxe/ansiesc.h | 1 + src/include/ipxe/aoe.h | 1 + src/include/ipxe/api.h | 1 + src/include/ipxe/arp.h | 1 + src/include/ipxe/asn1.h | 1 + src/include/ipxe/ata.h | 1 + src/include/ipxe/base16.h | 1 + src/include/ipxe/base64.h | 1 + src/include/ipxe/bitmap.h | 1 + src/include/ipxe/blockdev.h | 1 + src/include/ipxe/blocktrans.h | 1 + src/include/ipxe/cachedhcp.h | 1 + src/include/ipxe/chap.h | 1 + src/include/ipxe/command.h | 1 + src/include/ipxe/console.h | 1 + src/include/ipxe/cpio.h | 1 + src/include/ipxe/crc32.h | 1 + src/include/ipxe/crypto.h | 1 + src/include/ipxe/device.h | 1 + src/include/ipxe/dhcp.h | 1 + src/include/ipxe/dhcparch.h | 1 + src/include/ipxe/dhcpopts.h | 1 + src/include/ipxe/dhcppkt.h | 1 + src/include/ipxe/dhcpv6.h | 1 + src/include/ipxe/dma.h | 1 + src/include/ipxe/dns.h | 1 + src/include/ipxe/downloader.h | 1 + src/include/ipxe/dummy_sanboot.h | 1 + src/include/ipxe/dynui.h | 1 + src/include/ipxe/eap.h | 1 + src/include/ipxe/eapol.h | 1 + src/include/ipxe/ecam_io.h | 1 + src/include/ipxe/edd.h | 1 + src/include/ipxe/editbox.h | 1 + src/include/ipxe/editstring.h | 1 + src/include/ipxe/efi/ProcessorBind.h | 1 + src/include/ipxe/efi/Protocol/AppleNetBoot.h | 1 + src/include/ipxe/efi/Protocol/ShimLock.h | 1 + src/include/ipxe/efi/efi.h | 1 + src/include/ipxe/efi/efi_acpi.h | 1 + src/include/ipxe/efi/efi_autoboot.h | 1 + src/include/ipxe/efi/efi_autoexec.h | 1 + src/include/ipxe/efi/efi_block.h | 1 + src/include/ipxe/efi/efi_cachedhcp.h | 1 + src/include/ipxe/efi/efi_cmdline.h | 1 + src/include/ipxe/efi/efi_download.h | 1 + src/include/ipxe/efi/efi_driver.h | 1 + src/include/ipxe/efi/efi_fdt.h | 1 + src/include/ipxe/efi/efi_file.h | 1 + src/include/ipxe/efi/efi_hii.h | 1 + src/include/ipxe/efi/efi_image.h | 1 + src/include/ipxe/efi/efi_nap.h | 1 + src/include/ipxe/efi/efi_null.h | 1 + src/include/ipxe/efi/efi_path.h | 1 + src/include/ipxe/efi/efi_pci.h | 1 + src/include/ipxe/efi/efi_pci_api.h | 1 + src/include/ipxe/efi/efi_pxe.h | 1 + src/include/ipxe/efi/efi_reboot.h | 1 + src/include/ipxe/efi/efi_service.h | 1 + src/include/ipxe/efi/efi_shim.h | 1 + src/include/ipxe/efi/efi_smbios.h | 1 + src/include/ipxe/efi/efi_snp.h | 1 + src/include/ipxe/efi/efi_strings.h | 1 + src/include/ipxe/efi/efi_table.h | 1 + src/include/ipxe/efi/efi_time.h | 1 + src/include/ipxe/efi/efi_umalloc.h | 1 + src/include/ipxe/efi/efi_utils.h | 1 + src/include/ipxe/efi/efi_veto.h | 1 + src/include/ipxe/efi/efi_watchdog.h | 1 + src/include/ipxe/efi/efi_wrap.h | 1 + src/include/ipxe/efi/mnpnet.h | 1 + src/include/ipxe/errfile.h | 1 + src/include/ipxe/errno/efi.h | 1 + src/include/ipxe/errortab.h | 1 + src/include/ipxe/eth_slow.h | 1 + src/include/ipxe/ethernet.h | 1 + src/include/ipxe/fakedhcp.h | 1 + src/include/ipxe/fault.h | 1 + src/include/ipxe/fc.h | 1 + src/include/ipxe/fcels.h | 1 + src/include/ipxe/fcp.h | 1 + src/include/ipxe/fdtmem.h | 1 + src/include/ipxe/features.h | 1 + src/include/ipxe/fragment.h | 1 + src/include/ipxe/http.h | 1 + src/include/ipxe/ib_mad.h | 1 + src/include/ipxe/ib_packet.h | 1 + src/include/ipxe/ib_srp.h | 1 + src/include/ipxe/ibft.h | 1 + src/include/ipxe/icmp.h | 1 + src/include/ipxe/icmpv6.h | 1 + src/include/ipxe/if_arp.h | 1 + src/include/ipxe/if_ether.h | 1 + src/include/ipxe/image.h | 1 + src/include/ipxe/in.h | 1 + src/include/ipxe/infiniband.h | 1 + src/include/ipxe/init.h | 1 + src/include/ipxe/initrd.h | 1 + src/include/ipxe/interface.h | 1 + src/include/ipxe/io.h | 1 + src/include/ipxe/iobuf.h | 1 + src/include/ipxe/iomap.h | 1 + src/include/ipxe/iomap_virt.h | 1 + src/include/ipxe/ip.h | 1 + src/include/ipxe/ipstat.h | 1 + src/include/ipxe/ipv6.h | 1 + src/include/ipxe/iscsi.h | 1 + src/include/ipxe/iso9660.h | 1 + src/include/ipxe/job.h | 1 + src/include/ipxe/jumpscroll.h | 1 + src/include/ipxe/keymap.h | 1 + src/include/ipxe/keys.h | 1 + src/include/ipxe/linebuf.h | 1 + src/include/ipxe/linux/linux_acpi.h | 1 + src/include/ipxe/linux/linux_nap.h | 1 + src/include/ipxe/linux/linux_pci.h | 1 + src/include/ipxe/linux/linux_smbios.h | 1 + src/include/ipxe/linux/linux_time.h | 1 + src/include/ipxe/linux/linux_uaccess.h | 1 + src/include/ipxe/linux/linux_umalloc.h | 1 + src/include/ipxe/list.h | 1 + src/include/ipxe/lldp.h | 1 + src/include/ipxe/login_ui.h | 1 + src/include/ipxe/malloc.h | 1 + src/include/ipxe/md5.h | 1 + src/include/ipxe/memmap.h | 1 + src/include/ipxe/message.h | 1 + src/include/ipxe/monojob.h | 1 + src/include/ipxe/nap.h | 1 + src/include/ipxe/ndp.h | 1 + src/include/ipxe/neighbour.h | 1 + src/include/ipxe/netdevice.h | 1 + src/include/ipxe/ntlm.h | 1 + src/include/ipxe/null_acpi.h | 1 + src/include/ipxe/null_memmap.h | 1 + src/include/ipxe/null_nap.h | 1 + src/include/ipxe/null_pci.h | 1 + src/include/ipxe/null_reboot.h | 1 + src/include/ipxe/null_sanboot.h | 1 + src/include/ipxe/null_smbios.h | 1 + src/include/ipxe/null_time.h | 1 + src/include/ipxe/nvo.h | 1 + src/include/ipxe/nvs.h | 1 + src/include/ipxe/open.h | 1 + src/include/ipxe/params.h | 1 + src/include/ipxe/parseopt.h | 1 + src/include/ipxe/pci.h | 1 + src/include/ipxe/pci_io.h | 1 + src/include/ipxe/pcicloud.h | 1 + src/include/ipxe/pending.h | 1 + src/include/ipxe/ping.h | 1 + src/include/ipxe/pool.h | 1 + src/include/ipxe/process.h | 1 + src/include/ipxe/profile.h | 1 + src/include/ipxe/quiesce.h | 1 + src/include/ipxe/reboot.h | 1 + src/include/ipxe/refcnt.h | 1 + src/include/ipxe/resolv.h | 1 + src/include/ipxe/retry.h | 1 + src/include/ipxe/rotate.h | 1 + src/include/ipxe/sanboot.h | 1 + src/include/ipxe/sbat.h | 1 + src/include/ipxe/script.h | 1 + src/include/ipxe/scsi.h | 1 + src/include/ipxe/settings.h | 1 + src/include/ipxe/settings_ui.h | 1 + src/include/ipxe/shell.h | 1 + src/include/ipxe/smbios.h | 1 + src/include/ipxe/socket.h | 1 + src/include/ipxe/srp.h | 1 + src/include/ipxe/stp.h | 1 + src/include/ipxe/string.h | 1 + src/include/ipxe/tables.h | 1 + src/include/ipxe/tcp.h | 1 + src/include/ipxe/tcpip.h | 1 + src/include/ipxe/tftp.h | 1 + src/include/ipxe/time.h | 1 + src/include/ipxe/timer.h | 1 + src/include/ipxe/uaccess.h | 1 + src/include/ipxe/udp.h | 1 + src/include/ipxe/uheap.h | 1 + src/include/ipxe/umalloc.h | 1 + src/include/ipxe/uri.h | 1 + src/include/ipxe/usb.h | 1 + src/include/ipxe/utf8.h | 1 + src/include/ipxe/uuid.h | 1 + src/include/ipxe/version.h | 1 + src/include/ipxe/virt_offset.h | 1 + src/include/ipxe/vlan.h | 1 + src/include/ipxe/vsprintf.h | 1 + src/include/ipxe/widget.h | 1 + src/include/ipxe/xfer.h | 1 + src/include/ipxe/xferbuf.h | 1 + src/include/libgen.h | 1 + src/include/readline/readline.h | 1 + src/include/stdarg.h | 1 + src/include/stdbool.h | 1 + src/include/stddef.h | 1 + src/include/stdint.h | 1 + src/include/stdio.h | 1 + src/include/stdlib.h | 1 + src/include/string.h | 1 + src/include/strings.h | 1 + src/include/sys/time.h | 1 + src/include/syslog.h | 1 + src/include/time.h | 1 + src/include/unistd.h | 1 + src/include/usr/autoboot.h | 1 + src/include/usr/dhcpmgmt.h | 1 + src/include/usr/ifmgmt.h | 1 + src/include/usr/imgmgmt.h | 1 + src/include/usr/prompt.h | 1 + src/include/usr/route.h | 1 + src/include/usr/shimmgmt.h | 1 + src/include/usr/sync.h | 1 + src/include/valgrind/memcheck.h | 1 + src/include/valgrind/valgrind.h | 1 + src/include/wchar.h | 1 + src/interface/efi/efi_acpi.c | 1 + src/interface/efi/efi_autoboot.c | 1 + src/interface/efi/efi_autoexec.c | 1 + src/interface/efi/efi_block.c | 1 + src/interface/efi/efi_cachedhcp.c | 1 + src/interface/efi/efi_cmdline.c | 1 + src/interface/efi/efi_connect.c | 1 + src/interface/efi/efi_console.c | 1 + src/interface/efi/efi_download.c | 1 + src/interface/efi/efi_driver.c | 1 + src/interface/efi/efi_file.c | 1 + src/interface/efi/efi_guid.c | 1 + src/interface/efi/efi_hii.c | 1 + src/interface/efi/efi_init.c | 1 + src/interface/efi/efi_local.c | 1 + src/interface/efi/efi_nap.c | 1 + src/interface/efi/efi_null.c | 1 + src/interface/efi/efi_open.c | 1 + src/interface/efi/efi_path.c | 1 + src/interface/efi/efi_pci.c | 1 + src/interface/efi/efi_pxe.c | 1 + src/interface/efi/efi_reboot.c | 1 + src/interface/efi/efi_service.c | 1 + src/interface/efi/efi_settings.c | 1 + src/interface/efi/efi_shim.c | 2 ++ src/interface/efi/efi_smbios.c | 1 + src/interface/efi/efi_snp.c | 1 + src/interface/efi/efi_snp_hii.c | 1 + src/interface/efi/efi_strings.c | 1 + src/interface/efi/efi_table.c | 1 + src/interface/efi/efi_time.c | 1 + src/interface/efi/efi_timer.c | 1 + src/interface/efi/efi_umalloc.c | 1 + src/interface/efi/efi_utils.c | 1 + src/interface/efi/efi_veto.c | 1 + src/interface/efi/efi_watchdog.c | 1 + src/interface/efi/efi_wrap.c | 1 + src/interface/efi/efiprefix.c | 1 + src/interface/smbios/smbios.c | 1 + src/interface/smbios/smbios_settings.c | 1 + src/net/aoe.c | 1 + src/net/arp.c | 1 + src/net/dhcpopts.c | 1 + src/net/dhcppkt.c | 1 + src/net/eap.c | 1 + src/net/eap_md5.c | 1 + src/net/eapol.c | 1 + src/net/eth_slow.c | 1 + src/net/ethernet.c | 1 + src/net/fakedhcp.c | 1 + src/net/fragment.c | 1 + src/net/icmp.c | 1 + src/net/icmpv4.c | 1 + src/net/icmpv6.c | 1 + src/net/iobpad.c | 1 + src/net/ipv4.c | 1 + src/net/ipv6.c | 1 + src/net/lldp.c | 1 + src/net/ndp.c | 1 + src/net/neighbour.c | 1 + src/net/netdev_settings.c | 1 + src/net/netdevice.c | 1 + src/net/nullnet.c | 1 + src/net/retry.c | 1 + src/net/socket.c | 1 + src/net/stp.c | 1 + src/net/tcp.c | 1 + src/net/tcp/http.c | 1 + src/net/tcp/httpauth.c | 1 + src/net/tcp/httpbasic.c | 1 + src/net/tcp/httpblock.c | 1 + src/net/tcp/httpconn.c | 1 + src/net/tcp/httpcore.c | 1 + src/net/tcp/httpdigest.c | 1 + src/net/tcp/iscsi.c | 1 + src/net/tcpip.c | 1 + src/net/udp.c | 1 + src/net/udp/dhcp.c | 1 + src/net/udp/dhcpv6.c | 1 + src/net/udp/dns.c | 1 + src/net/udp/tftp.c | 1 + src/net/vlan.c | 1 + src/usr/autoboot.c | 1 + src/usr/dhcpmgmt.c | 1 + src/usr/ifmgmt.c | 1 + src/usr/imgmgmt.c | 1 + src/usr/prompt.c | 1 + src/usr/route.c | 1 + src/usr/route_ipv4.c | 1 + src/usr/route_ipv6.c | 1 + src/usr/shimmgmt.c | 1 + src/usr/sync.c | 1 + 497 files changed, 498 insertions(+) (limited to 'src/drivers') diff --git a/src/arch/x86/core/cpuid.c b/src/arch/x86/core/cpuid.c index b7d9fb6c6..0461b846e 100644 --- a/src/arch/x86/core/cpuid.c +++ b/src/arch/x86/core/cpuid.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/arch/x86/core/x86_string.c b/src/arch/x86/core/x86_string.c index 1a1e79dac..923552f66 100644 --- a/src/arch/x86/core/x86_string.c +++ b/src/arch/x86/core/x86_string.c @@ -28,6 +28,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/arch/x86/core/x86_tcpip.c b/src/arch/x86/core/x86_tcpip.c index ed323d5d0..b3bfe2546 100644 --- a/src/arch/x86/core/x86_tcpip.c +++ b/src/arch/x86/core/x86_tcpip.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/arch/x86/hci/commands/cpuid_cmd.c b/src/arch/x86/hci/commands/cpuid_cmd.c index b1978d5f2..f4d7305e8 100644 --- a/src/arch/x86/hci/commands/cpuid_cmd.c +++ b/src/arch/x86/hci/commands/cpuid_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/arch/x86/include/bits/acpi.h b/src/arch/x86/include/bits/acpi.h index a6ff90804..287bdafeb 100644 --- a/src/arch/x86/include/bits/acpi.h +++ b/src/arch/x86/include/bits/acpi.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/arch/x86/include/bits/endian.h b/src/arch/x86/include/bits/endian.h index 85718cfdd..72279117d 100644 --- a/src/arch/x86/include/bits/endian.h +++ b/src/arch/x86/include/bits/endian.h @@ -2,6 +2,7 @@ #define _BITS_ENDIAN_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #define __BYTE_ORDER __LITTLE_ENDIAN diff --git a/src/arch/x86/include/bits/errfile.h b/src/arch/x86/include/bits/errfile.h index 4fa9acef6..e7aec6f39 100644 --- a/src/arch/x86/include/bits/errfile.h +++ b/src/arch/x86/include/bits/errfile.h @@ -2,6 +2,7 @@ #define _BITS_ERRFILE_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @addtogroup errfile Error file identifiers diff --git a/src/arch/x86/include/bits/io.h b/src/arch/x86/include/bits/io.h index 95673ad8d..cde0b6829 100644 --- a/src/arch/x86/include/bits/io.h +++ b/src/arch/x86/include/bits/io.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** Page shift */ #define PAGE_SHIFT 12 diff --git a/src/arch/x86/include/bits/iomap.h b/src/arch/x86/include/bits/iomap.h index d6fff257e..d524bd805 100644 --- a/src/arch/x86/include/bits/iomap.h +++ b/src/arch/x86/include/bits/iomap.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/arch/x86/include/bits/memmap.h b/src/arch/x86/include/bits/memmap.h index 8f821563c..e68550fb8 100644 --- a/src/arch/x86/include/bits/memmap.h +++ b/src/arch/x86/include/bits/memmap.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/arch/x86/include/bits/nap.h b/src/arch/x86/include/bits/nap.h index b7dea736d..52c8d81ba 100644 --- a/src/arch/x86/include/bits/nap.h +++ b/src/arch/x86/include/bits/nap.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/arch/x86/include/bits/pci_io.h b/src/arch/x86/include/bits/pci_io.h index b41e562ee..b6c01e5c4 100644 --- a/src/arch/x86/include/bits/pci_io.h +++ b/src/arch/x86/include/bits/pci_io.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/arch/x86/include/bits/reboot.h b/src/arch/x86/include/bits/reboot.h index e702dd3d0..8d8d0b40e 100644 --- a/src/arch/x86/include/bits/reboot.h +++ b/src/arch/x86/include/bits/reboot.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/arch/x86/include/bits/sanboot.h b/src/arch/x86/include/bits/sanboot.h index 1b9924e64..ff7b88d14 100644 --- a/src/arch/x86/include/bits/sanboot.h +++ b/src/arch/x86/include/bits/sanboot.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/arch/x86/include/bits/smbios.h b/src/arch/x86/include/bits/smbios.h index 9977c87ac..2be98d887 100644 --- a/src/arch/x86/include/bits/smbios.h +++ b/src/arch/x86/include/bits/smbios.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/arch/x86/include/bits/string.h b/src/arch/x86/include/bits/string.h index c26fe30d5..8b2b3070b 100644 --- a/src/arch/x86/include/bits/string.h +++ b/src/arch/x86/include/bits/string.h @@ -25,6 +25,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/arch/x86/include/bits/tcpip.h b/src/arch/x86/include/bits/tcpip.h index 0ac55b1a0..52d032427 100644 --- a/src/arch/x86/include/bits/tcpip.h +++ b/src/arch/x86/include/bits/tcpip.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern uint16_t tcpip_continue_chksum ( uint16_t partial, const void *data, size_t len ); diff --git a/src/arch/x86/include/bits/time.h b/src/arch/x86/include/bits/time.h index 556d96f64..a4aa8cc6e 100644 --- a/src/arch/x86/include/bits/time.h +++ b/src/arch/x86/include/bits/time.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/arch/x86/include/ipxe/bios_nap.h b/src/arch/x86/include/ipxe/bios_nap.h index c9b82c1e5..7d94b3c4a 100644 --- a/src/arch/x86/include/ipxe/bios_nap.h +++ b/src/arch/x86/include/ipxe/bios_nap.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef NAP_PCBIOS #define NAP_PREFIX_pcbios diff --git a/src/arch/x86/include/ipxe/bios_reboot.h b/src/arch/x86/include/ipxe/bios_reboot.h index 3f6df9073..bd1bb42cc 100644 --- a/src/arch/x86/include/ipxe/bios_reboot.h +++ b/src/arch/x86/include/ipxe/bios_reboot.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef REBOOT_PCBIOS #define REBOOT_PREFIX_pcbios diff --git a/src/arch/x86/include/ipxe/bios_sanboot.h b/src/arch/x86/include/ipxe/bios_sanboot.h index 85d698039..d28339e4e 100644 --- a/src/arch/x86/include/ipxe/bios_sanboot.h +++ b/src/arch/x86/include/ipxe/bios_sanboot.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef SANBOOT_PCBIOS #define SANBOOT_PREFIX_pcbios diff --git a/src/arch/x86/include/ipxe/bios_smbios.h b/src/arch/x86/include/ipxe/bios_smbios.h index 9f7f9c8ff..1815e3617 100644 --- a/src/arch/x86/include/ipxe/bios_smbios.h +++ b/src/arch/x86/include/ipxe/bios_smbios.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef SMBIOS_PCBIOS #define SMBIOS_PREFIX_pcbios diff --git a/src/arch/x86/include/ipxe/cpuid.h b/src/arch/x86/include/ipxe/cpuid.h index 99b91c5c8..1851a859b 100644 --- a/src/arch/x86/include/ipxe/cpuid.h +++ b/src/arch/x86/include/ipxe/cpuid.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/arch/x86/include/ipxe/int15.h b/src/arch/x86/include/ipxe/int15.h index e8aa9e2f5..590c0e9a7 100644 --- a/src/arch/x86/include/ipxe/int15.h +++ b/src/arch/x86/include/ipxe/int15.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef MEMMAP_INT15 #define MEMMAP_PREFIX_int15 diff --git a/src/arch/x86/include/ipxe/iomap_pages.h b/src/arch/x86/include/ipxe/iomap_pages.h index 18e0a3002..e74dabd90 100644 --- a/src/arch/x86/include/ipxe/iomap_pages.h +++ b/src/arch/x86/include/ipxe/iomap_pages.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef IOMAP_PAGES #define IOMAP_PREFIX_pages diff --git a/src/arch/x86/include/ipxe/pcibios.h b/src/arch/x86/include/ipxe/pcibios.h index b62b470f0..2fd03198e 100644 --- a/src/arch/x86/include/ipxe/pcibios.h +++ b/src/arch/x86/include/ipxe/pcibios.h @@ -10,6 +10,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef PCIAPI_PCBIOS #define PCIAPI_PREFIX_pcbios diff --git a/src/arch/x86/include/ipxe/pcidirect.h b/src/arch/x86/include/ipxe/pcidirect.h index 1515b20d4..5863b4d16 100644 --- a/src/arch/x86/include/ipxe/pcidirect.h +++ b/src/arch/x86/include/ipxe/pcidirect.h @@ -2,6 +2,7 @@ #define _PCIDIRECT_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/arch/x86/include/ipxe/rsdp.h b/src/arch/x86/include/ipxe/rsdp.h index daaa43077..f371d9a20 100644 --- a/src/arch/x86/include/ipxe/rsdp.h +++ b/src/arch/x86/include/ipxe/rsdp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef ACPI_RSDP #define ACPI_PREFIX_rsdp diff --git a/src/arch/x86/include/ipxe/rtc_time.h b/src/arch/x86/include/ipxe/rtc_time.h index cb8c7f49e..49c6313ed 100644 --- a/src/arch/x86/include/ipxe/rtc_time.h +++ b/src/arch/x86/include/ipxe/rtc_time.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef TIME_RTC #define TIME_PREFIX_rtc diff --git a/src/arch/x86/include/ipxe/x86_io.h b/src/arch/x86/include/ipxe/x86_io.h index eeb3f8454..164b57e92 100644 --- a/src/arch/x86/include/ipxe/x86_io.h +++ b/src/arch/x86/include/ipxe/x86_io.h @@ -16,6 +16,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef IOAPI_X86 #define IOAPI_PREFIX_x86 diff --git a/src/arch/x86_64/include/bits/byteswap.h b/src/arch/x86_64/include/bits/byteswap.h index d8c5098ef..7c48a27ca 100644 --- a/src/arch/x86_64/include/bits/byteswap.h +++ b/src/arch/x86_64/include/bits/byteswap.h @@ -10,6 +10,7 @@ #include FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); static inline __attribute__ (( always_inline, const )) uint16_t __bswap_variable_16 ( uint16_t x ) { diff --git a/src/arch/x86_64/include/bits/compiler.h b/src/arch/x86_64/include/bits/compiler.h index 1c04a7b30..99185b058 100644 --- a/src/arch/x86_64/include/bits/compiler.h +++ b/src/arch/x86_64/include/bits/compiler.h @@ -2,6 +2,7 @@ #define _BITS_COMPILER_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** Dummy relocation type */ #define RELOC_TYPE_NONE R_X86_64_NONE diff --git a/src/arch/x86_64/include/bits/profile.h b/src/arch/x86_64/include/bits/profile.h index c85b6fe5c..c8e0a21f1 100644 --- a/src/arch/x86_64/include/bits/profile.h +++ b/src/arch/x86_64/include/bits/profile.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/arch/x86_64/include/bits/stdint.h b/src/arch/x86_64/include/bits/stdint.h index fe1f9946a..e75bed502 100644 --- a/src/arch/x86_64/include/bits/stdint.h +++ b/src/arch/x86_64/include/bits/stdint.h @@ -2,6 +2,7 @@ #define _BITS_STDINT_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); typedef __SIZE_TYPE__ size_t; typedef signed long ssize_t; diff --git a/src/arch/x86_64/include/bits/strings.h b/src/arch/x86_64/include/bits/strings.h index 3b7911f3b..6da8f1350 100644 --- a/src/arch/x86_64/include/bits/strings.h +++ b/src/arch/x86_64/include/bits/strings.h @@ -2,6 +2,7 @@ #define _BITS_STRINGS_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * Find first (i.e. least significant) set bit diff --git a/src/arch/x86_64/include/ipxe/efi/dhcparch.h b/src/arch/x86_64/include/ipxe/efi/dhcparch.h index ccf0f46a0..f75bf9145 100644 --- a/src/arch/x86_64/include/ipxe/efi/dhcparch.h +++ b/src/arch/x86_64/include/ipxe/efi/dhcparch.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/arch/x86_64/include/limits.h b/src/arch/x86_64/include/limits.h index a1374a17f..e75461acb 100644 --- a/src/arch/x86_64/include/limits.h +++ b/src/arch/x86_64/include/limits.h @@ -2,6 +2,7 @@ #define LIMITS_H 1 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /* Number of bits in a `char' */ #define CHAR_BIT 8 diff --git a/src/config/branding.h b/src/config/branding.h index 454bf0c03..f28e1b5d2 100644 --- a/src/config/branding.h +++ b/src/config/branding.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/colour.h b/src/config/colour.h index 98198f12f..bde6f9719 100644 --- a/src/config/colour.h +++ b/src/config/colour.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #define COLOR_NORMAL_FG COLOR_WHITE #define COLOR_NORMAL_BG COLOR_BLUE diff --git a/src/config/config.c b/src/config/config.c index e49f236a3..c32bcee88 100644 --- a/src/config/config.c +++ b/src/config/config.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/config/config_eap.c b/src/config/config_eap.c index e18c48cae..0c9b7b687 100644 --- a/src/config/config_eap.c +++ b/src/config/config_eap.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/config_efi.c b/src/config/config_efi.c index 92678d12d..8daaa4329 100644 --- a/src/config/config_efi.c +++ b/src/config/config_efi.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/config/config_ethernet.c b/src/config/config_ethernet.c index c1b35bfe6..03ed371a7 100644 --- a/src/config/config_ethernet.c +++ b/src/config/config_ethernet.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/config_http.c b/src/config/config_http.c index 4373ea2c0..ee0643c91 100644 --- a/src/config/config_http.c +++ b/src/config/config_http.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/config_pci.c b/src/config/config_pci.c index b2adae995..c6c9b92a5 100644 --- a/src/config/config_pci.c +++ b/src/config/config_pci.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/config/config_route.c b/src/config/config_route.c index c0b4ee91d..59d8f3550 100644 --- a/src/config/config_route.c +++ b/src/config/config_route.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/config_timer.c b/src/config/config_timer.c index a4fe69b00..12b806129 100644 --- a/src/config/config_timer.c +++ b/src/config/config_timer.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/console.h b/src/config/console.h index 0ff328b7c..028021fa2 100644 --- a/src/config/console.h +++ b/src/config/console.h @@ -11,6 +11,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/defaults.h b/src/config/defaults.h index 32d6dbcce..767b67fdf 100644 --- a/src/config/defaults.h +++ b/src/config/defaults.h @@ -2,6 +2,7 @@ #define CONFIG_DEFAULTS_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #define CONFIG_DEFAULTS(_platform) diff --git a/src/config/defaults/efi.h b/src/config/defaults/efi.h index 4c9ba9d2a..524b2b0ea 100644 --- a/src/config/defaults/efi.h +++ b/src/config/defaults/efi.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #define UACCESS_FLAT #define IOMAP_VIRT diff --git a/src/config/dhcp.h b/src/config/dhcp.h index adfa74a15..65180c38c 100644 --- a/src/config/dhcp.h +++ b/src/config/dhcp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/fault.h b/src/config/fault.h index 5912ae1a6..ab5503fa2 100644 --- a/src/config/fault.h +++ b/src/config/fault.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/general.h b/src/config/general.h index 683c02ffb..f77248836 100644 --- a/src/config/general.h +++ b/src/config/general.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/ioapi.h b/src/config/ioapi.h index a1498482d..d4ef91f76 100644 --- a/src/config/ioapi.h +++ b/src/config/ioapi.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/named.h b/src/config/named.h index ddde6f0a6..f46524f81 100644 --- a/src/config/named.h +++ b/src/config/named.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /* config//
.h */ #ifdef CONFIG diff --git a/src/config/nap.h b/src/config/nap.h index e4fe97964..55ff64116 100644 --- a/src/config/nap.h +++ b/src/config/nap.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/reboot.h b/src/config/reboot.h index 2d1648e7b..a7f90ead1 100644 --- a/src/config/reboot.h +++ b/src/config/reboot.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/sanboot.h b/src/config/sanboot.h index ccc4bda1f..962caec40 100644 --- a/src/config/sanboot.h +++ b/src/config/sanboot.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/settings.h b/src/config/settings.h index 7b4af4fdf..bba8c631a 100644 --- a/src/config/settings.h +++ b/src/config/settings.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/sideband.h b/src/config/sideband.h index dd704f9bb..039d28df0 100644 --- a/src/config/sideband.h +++ b/src/config/sideband.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); //#define CONFIG_BOFM /* IBM's BladeCenter Open Fabric Manager */ diff --git a/src/config/time.h b/src/config/time.h index 678f6f864..f938f3aa7 100644 --- a/src/config/time.h +++ b/src/config/time.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/timer.h b/src/config/timer.h index 5a54d398c..d2368a13a 100644 --- a/src/config/timer.h +++ b/src/config/timer.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/umalloc.h b/src/config/umalloc.h index 832dd21d1..87fb34527 100644 --- a/src/config/umalloc.h +++ b/src/config/umalloc.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/core/acpi.c b/src/core/acpi.c index 3fbf25bd1..d8c1903f3 100644 --- a/src/core/acpi.c +++ b/src/core/acpi.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/ansicol.c b/src/core/ansicol.c index ddf9ba77c..d53ebeeb6 100644 --- a/src/core/ansicol.c +++ b/src/core/ansicol.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/ansiesc.c b/src/core/ansiesc.c index 7f545db0e..57a2345d7 100644 --- a/src/core/ansiesc.c +++ b/src/core/ansiesc.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/asprintf.c b/src/core/asprintf.c index 00edf8e11..17a65c715 100644 --- a/src/core/asprintf.c +++ b/src/core/asprintf.c @@ -5,6 +5,7 @@ #include FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * Write a formatted string to newly allocated memory. diff --git a/src/core/base16.c b/src/core/base16.c index 47e35f414..0c597480f 100644 --- a/src/core/base16.c +++ b/src/core/base16.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/base64.c b/src/core/base64.c index ec11be261..fe7198c42 100644 --- a/src/core/base64.c +++ b/src/core/base64.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/basename.c b/src/core/basename.c index f4f929517..7a903c25f 100644 --- a/src/core/basename.c +++ b/src/core/basename.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/core/bitmap.c b/src/core/bitmap.c index 2aac33870..e3570c629 100644 --- a/src/core/bitmap.c +++ b/src/core/bitmap.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/blockdev.c b/src/core/blockdev.c index 3513caafa..ff0f3b68b 100644 --- a/src/core/blockdev.c +++ b/src/core/blockdev.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/blocktrans.c b/src/core/blocktrans.c index b793185fe..d9c24582c 100644 --- a/src/core/blocktrans.c +++ b/src/core/blocktrans.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/core/cachedhcp.c b/src/core/cachedhcp.c index eeb2fca58..3f6564efd 100644 --- a/src/core/cachedhcp.c +++ b/src/core/cachedhcp.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/console.c b/src/core/console.c index 2b90809bf..240dde3d6 100644 --- a/src/core/console.c +++ b/src/core/console.c @@ -6,6 +6,7 @@ /** @file */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** Current console usage */ int console_usage = CONSOLE_USAGE_STDOUT; diff --git a/src/core/cpio.c b/src/core/cpio.c index 15e33d206..d2f9d0c2d 100644 --- a/src/core/cpio.c +++ b/src/core/cpio.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/core/ctype.c b/src/core/ctype.c index 891af71ea..d7de060e3 100644 --- a/src/core/ctype.c +++ b/src/core/ctype.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/core/cwuri.c b/src/core/cwuri.c index 612f0b179..36475b159 100644 --- a/src/core/cwuri.c +++ b/src/core/cwuri.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/debug.c b/src/core/debug.c index 9b2a823f5..3f7661dda 100644 --- a/src/core/debug.c +++ b/src/core/debug.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/device.c b/src/core/device.c index efe4eb687..2ab5fa117 100644 --- a/src/core/device.c +++ b/src/core/device.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/dma.c b/src/core/dma.c index 3f3023c4d..dc266545b 100644 --- a/src/core/dma.c +++ b/src/core/dma.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/downloader.c b/src/core/downloader.c index 1c638f502..aa81e7365 100644 --- a/src/core/downloader.c +++ b/src/core/downloader.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/dynui.c b/src/core/dynui.c index 3d139c02a..c2af95f86 100644 --- a/src/core/dynui.c +++ b/src/core/dynui.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/core/edd.c b/src/core/edd.c index a50b74ab1..4fcccf117 100644 --- a/src/core/edd.c +++ b/src/core/edd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/errno.c b/src/core/errno.c index 5de15bb92..7afa40859 100644 --- a/src/core/errno.c +++ b/src/core/errno.c @@ -1,6 +1,7 @@ #include FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/core/exec.c b/src/core/exec.c index 534fb9993..4db1248b0 100644 --- a/src/core/exec.c +++ b/src/core/exec.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/getkey.c b/src/core/getkey.c index 0c280d23b..c952e0aea 100644 --- a/src/core/getkey.c +++ b/src/core/getkey.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/getopt.c b/src/core/getopt.c index e6c3948d1..cb4cbf118 100644 --- a/src/core/getopt.c +++ b/src/core/getopt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/image.c b/src/core/image.c index b2bd0956b..7df125971 100644 --- a/src/core/image.c +++ b/src/core/image.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/init.c b/src/core/init.c index 406d22d7b..2a32f5795 100644 --- a/src/core/init.c +++ b/src/core/init.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/interface.c b/src/core/interface.c index ea0606893..0ebcc8e51 100644 --- a/src/core/interface.c +++ b/src/core/interface.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/iobuf.c b/src/core/iobuf.c index 78fa23924..7e9a4156d 100644 --- a/src/core/iobuf.c +++ b/src/core/iobuf.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/job.c b/src/core/job.c index 65df80056..f83ce0552 100644 --- a/src/core/job.c +++ b/src/core/job.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/keymap.c b/src/core/keymap.c index 36db7bd4c..e2244fdcb 100644 --- a/src/core/keymap.c +++ b/src/core/keymap.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/linebuf.c b/src/core/linebuf.c index c197e383c..8995dca66 100644 --- a/src/core/linebuf.c +++ b/src/core/linebuf.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/core/list.c b/src/core/list.c index 5175c84ec..8d38d690a 100644 --- a/src/core/list.c +++ b/src/core/list.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/core/main.c b/src/core/main.c index 3db836491..95e16132f 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -13,6 +13,7 @@ Literature dealing with the network protocols: **************************************************************************/ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/malloc.c b/src/core/malloc.c index 877687d81..3a9f23ee4 100644 --- a/src/core/malloc.c +++ b/src/core/malloc.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/monojob.c b/src/core/monojob.c index 2f066331c..ff22b4ac8 100644 --- a/src/core/monojob.c +++ b/src/core/monojob.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/nvo.c b/src/core/nvo.c index d2c9b5e73..8e500f816 100644 --- a/src/core/nvo.c +++ b/src/core/nvo.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/open.c b/src/core/open.c index f9198c9d9..8daa90f55 100644 --- a/src/core/open.c +++ b/src/core/open.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/params.c b/src/core/params.c index 58c829f62..d3fffc312 100644 --- a/src/core/params.c +++ b/src/core/params.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/core/parseopt.c b/src/core/parseopt.c index b657c3fce..b920a7d84 100644 --- a/src/core/parseopt.c +++ b/src/core/parseopt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/pending.c b/src/core/pending.c index 96d0cf197..4a1dd6a34 100644 --- a/src/core/pending.c +++ b/src/core/pending.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/pool.c b/src/core/pool.c index 0163405f7..daf761aa3 100644 --- a/src/core/pool.c +++ b/src/core/pool.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/core/process.c b/src/core/process.c index c944b6f50..883469dc5 100644 --- a/src/core/process.c +++ b/src/core/process.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/quiesce.c b/src/core/quiesce.c index 5d2a919d0..9c4e37849 100644 --- a/src/core/quiesce.c +++ b/src/core/quiesce.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/core/random.c b/src/core/random.c index e3251964b..e8fbe6966 100644 --- a/src/core/random.c +++ b/src/core/random.c @@ -5,6 +5,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/refcnt.c b/src/core/refcnt.c index 47c975a0b..a66511291 100644 --- a/src/core/refcnt.c +++ b/src/core/refcnt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/resolv.c b/src/core/resolv.c index fab8def4b..0fc02ccf4 100644 --- a/src/core/resolv.c +++ b/src/core/resolv.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/sanboot.c b/src/core/sanboot.c index e90c5ef1d..45cd5eff3 100644 --- a/src/core/sanboot.c +++ b/src/core/sanboot.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/core/settings.c b/src/core/settings.c index 05e495dcf..129620e00 100644 --- a/src/core/settings.c +++ b/src/core/settings.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/string.c b/src/core/string.c index 364c4cf0e..2af19b7fe 100644 --- a/src/core/string.c +++ b/src/core/string.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/time.c b/src/core/time.c index c353ac5bd..6d33f6caf 100644 --- a/src/core/time.c +++ b/src/core/time.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/core/timer.c b/src/core/timer.c index d45797adb..db0f32cf1 100644 --- a/src/core/timer.c +++ b/src/core/timer.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/uri.c b/src/core/uri.c index b82472ef0..9da5e298b 100644 --- a/src/core/uri.c +++ b/src/core/uri.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/core/utf8.c b/src/core/utf8.c index 4ee01baf9..871044fec 100644 --- a/src/core/utf8.c +++ b/src/core/utf8.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/uuid.c b/src/core/uuid.c index b6600af71..0f93e9f8f 100644 --- a/src/core/uuid.c +++ b/src/core/uuid.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/version.c b/src/core/version.c index cd69a8762..75f3160db 100644 --- a/src/core/version.c +++ b/src/core/version.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/core/vsprintf.c b/src/core/vsprintf.c index 9d3a97c2d..f6032014a 100644 --- a/src/core/vsprintf.c +++ b/src/core/vsprintf.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/wchar.c b/src/core/wchar.c index b06cf452a..27a608bf4 100644 --- a/src/core/wchar.c +++ b/src/core/wchar.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/core/xfer.c b/src/core/xfer.c index 269359e15..5ab303bc7 100644 --- a/src/core/xfer.c +++ b/src/core/xfer.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/xferbuf.c b/src/core/xferbuf.c index d93526577..ca3baaab5 100644 --- a/src/core/xferbuf.c +++ b/src/core/xferbuf.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/chap.c b/src/crypto/chap.c index c90c16def..008229133 100644 --- a/src/crypto/chap.c +++ b/src/crypto/chap.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/crc32.c b/src/crypto/crc32.c index cfef68c02..9ab4899c6 100644 --- a/src/crypto/crc32.c +++ b/src/crypto/crc32.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/crypto/md5.c b/src/crypto/md5.c index 5c62513e2..9418b006c 100644 --- a/src/crypto/md5.c +++ b/src/crypto/md5.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/drivers/block/ata.c b/src/drivers/block/ata.c index cf98d7c9f..ee2acdebb 100644 --- a/src/drivers/block/ata.c +++ b/src/drivers/block/ata.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/block/ibft.c b/src/drivers/block/ibft.c index ca5fad9ff..6120b37dd 100644 --- a/src/drivers/block/ibft.c +++ b/src/drivers/block/ibft.c @@ -26,6 +26,7 @@ */ FILE_LICENCE ( BSD2 ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/block/scsi.c b/src/drivers/block/scsi.c index 251210d4f..67bf48201 100644 --- a/src/drivers/block/scsi.c +++ b/src/drivers/block/scsi.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/bus/pci.c b/src/drivers/bus/pci.c index 3908871b8..30163300a 100644 --- a/src/drivers/bus/pci.c +++ b/src/drivers/bus/pci.c @@ -25,6 +25,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/bus/pci_settings.c b/src/drivers/bus/pci_settings.c index fc73c651e..3e320da43 100644 --- a/src/drivers/bus/pci_settings.c +++ b/src/drivers/bus/pci_settings.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/efi/mnpnet.c b/src/drivers/net/efi/mnpnet.c index 902eb91f3..fe0ebaadb 100644 --- a/src/drivers/net/efi/mnpnet.c +++ b/src/drivers/net/efi/mnpnet.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/drivers/net/efi/nii.c b/src/drivers/net/efi/nii.c index c60d4ca18..d1adf3d44 100644 --- a/src/drivers/net/efi/nii.c +++ b/src/drivers/net/efi/nii.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/efi/nii.h b/src/drivers/net/efi/nii.h index df7ab7dbe..e0b07f0a5 100644 --- a/src/drivers/net/efi/nii.h +++ b/src/drivers/net/efi/nii.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); struct efi_device; diff --git a/src/drivers/net/efi/snpnet.c b/src/drivers/net/efi/snpnet.c index 8427b6ce3..6046f0a1e 100644 --- a/src/drivers/net/efi/snpnet.c +++ b/src/drivers/net/efi/snpnet.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/efi/snpnet.h b/src/drivers/net/efi/snpnet.h index 507350210..a361a99c0 100644 --- a/src/drivers/net/efi/snpnet.h +++ b/src/drivers/net/efi/snpnet.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); struct efi_device; diff --git a/src/drivers/net/efi/snponly.c b/src/drivers/net/efi/snponly.c index 876479133..b7231ce01 100644 --- a/src/drivers/net/efi/snponly.c +++ b/src/drivers/net/efi/snponly.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/nvs/nvs.c b/src/drivers/nvs/nvs.c index af7c466c4..42b54123e 100644 --- a/src/drivers/nvs/nvs.c +++ b/src/drivers/nvs/nvs.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/commands/autoboot_cmd.c b/src/hci/commands/autoboot_cmd.c index 010c6fcb0..a61333a9d 100644 --- a/src/hci/commands/autoboot_cmd.c +++ b/src/hci/commands/autoboot_cmd.c @@ -30,6 +30,7 @@ #include FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/hci/commands/config_cmd.c b/src/hci/commands/config_cmd.c index 39272196a..cc21ad3fe 100644 --- a/src/hci/commands/config_cmd.c +++ b/src/hci/commands/config_cmd.c @@ -31,6 +31,7 @@ #include FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/hci/commands/dhcp_cmd.c b/src/hci/commands/dhcp_cmd.c index 33c23fc6e..ccc115b87 100644 --- a/src/hci/commands/dhcp_cmd.c +++ b/src/hci/commands/dhcp_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/commands/dynui_cmd.c b/src/hci/commands/dynui_cmd.c index 56a4acd06..9d1ea0e93 100644 --- a/src/hci/commands/dynui_cmd.c +++ b/src/hci/commands/dynui_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/hci/commands/ifmgmt_cmd.c b/src/hci/commands/ifmgmt_cmd.c index 2906d1d45..f4b9fef3a 100644 --- a/src/hci/commands/ifmgmt_cmd.c +++ b/src/hci/commands/ifmgmt_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/commands/image_cmd.c b/src/hci/commands/image_cmd.c index 179256862..aaed0ea9b 100644 --- a/src/hci/commands/image_cmd.c +++ b/src/hci/commands/image_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/commands/login_cmd.c b/src/hci/commands/login_cmd.c index 005d40342..f8cd73f23 100644 --- a/src/hci/commands/login_cmd.c +++ b/src/hci/commands/login_cmd.c @@ -28,6 +28,7 @@ #include FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/hci/commands/nvo_cmd.c b/src/hci/commands/nvo_cmd.c index 69ab97dca..70086afce 100644 --- a/src/hci/commands/nvo_cmd.c +++ b/src/hci/commands/nvo_cmd.c @@ -34,6 +34,7 @@ #include FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/hci/commands/reboot_cmd.c b/src/hci/commands/reboot_cmd.c index c5b71c045..daef92dc0 100644 --- a/src/hci/commands/reboot_cmd.c +++ b/src/hci/commands/reboot_cmd.c @@ -27,6 +27,7 @@ #include FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/hci/commands/route_cmd.c b/src/hci/commands/route_cmd.c index a33754399..ff841ec15 100644 --- a/src/hci/commands/route_cmd.c +++ b/src/hci/commands/route_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/commands/sanboot_cmd.c b/src/hci/commands/sanboot_cmd.c index 122bee527..7bc60e641 100644 --- a/src/hci/commands/sanboot_cmd.c +++ b/src/hci/commands/sanboot_cmd.c @@ -32,6 +32,7 @@ #include FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/hci/commands/shim_cmd.c b/src/hci/commands/shim_cmd.c index a53bb3fde..1566af4e9 100644 --- a/src/hci/commands/shim_cmd.c +++ b/src/hci/commands/shim_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/commands/sync_cmd.c b/src/hci/commands/sync_cmd.c index 9d6e6a284..e3b97298c 100644 --- a/src/hci/commands/sync_cmd.c +++ b/src/hci/commands/sync_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/editstring.c b/src/hci/editstring.c index be9ca06a5..f88b81f7f 100644 --- a/src/hci/editstring.c +++ b/src/hci/editstring.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/jumpscroll.c b/src/hci/jumpscroll.c index 641f781a0..c6ee5bda0 100644 --- a/src/hci/jumpscroll.c +++ b/src/hci/jumpscroll.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * Jump scrolling diff --git a/src/hci/mucurses/ansi_screen.c b/src/hci/mucurses/ansi_screen.c index 1cf3309dd..7c607b5cc 100644 --- a/src/hci/mucurses/ansi_screen.c +++ b/src/hci/mucurses/ansi_screen.c @@ -4,6 +4,7 @@ #include FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); static void ansiscr_reset(struct _curses_screen *scr) __nonnull; static void ansiscr_movetoyx(struct _curses_screen *scr, diff --git a/src/hci/mucurses/clear.c b/src/hci/mucurses/clear.c index 2054f72cc..d93e9630e 100644 --- a/src/hci/mucurses/clear.c +++ b/src/hci/mucurses/clear.c @@ -9,6 +9,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * Clear a window to the bottom from current cursor position diff --git a/src/hci/mucurses/cursor.h b/src/hci/mucurses/cursor.h index 2e0c896a6..6f47becae 100644 --- a/src/hci/mucurses/cursor.h +++ b/src/hci/mucurses/cursor.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); struct cursor_pos { unsigned int y, x; diff --git a/src/hci/mucurses/mucurses.c b/src/hci/mucurses/mucurses.c index 98a8a2c59..7f1779e8f 100644 --- a/src/hci/mucurses/mucurses.c +++ b/src/hci/mucurses/mucurses.c @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); static void _wupdcurs ( WINDOW *win ) __nonnull; void _wputch ( WINDOW *win, chtype ch, int wrap ) __nonnull; diff --git a/src/hci/mucurses/mucurses.h b/src/hci/mucurses/mucurses.h index 270394787..dc6187741 100644 --- a/src/hci/mucurses/mucurses.h +++ b/src/hci/mucurses/mucurses.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #define WRAP 0 #define NOWRAP 1 diff --git a/src/hci/mucurses/print.c b/src/hci/mucurses/print.c index e8831c58f..f7e0c8483 100644 --- a/src/hci/mucurses/print.c +++ b/src/hci/mucurses/print.c @@ -11,6 +11,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * Add a single-byte character and rendition to a window and advance diff --git a/src/hci/mucurses/widgets/editbox.c b/src/hci/mucurses/widgets/editbox.c index c024688ab..5dab3ac5c 100644 --- a/src/hci/mucurses/widgets/editbox.c +++ b/src/hci/mucurses/widgets/editbox.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/mucurses/winattrs.c b/src/hci/mucurses/winattrs.c index 97a5a18b3..e78025543 100644 --- a/src/hci/mucurses/winattrs.c +++ b/src/hci/mucurses/winattrs.c @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * Get the background rendition attributes for a window diff --git a/src/hci/mucurses/wininit.c b/src/hci/mucurses/wininit.c index dd84d2f1d..1b651123e 100644 --- a/src/hci/mucurses/wininit.c +++ b/src/hci/mucurses/wininit.c @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * Initialise console environment diff --git a/src/hci/readline.c b/src/hci/readline.c index 5b46413e9..3d0330a62 100644 --- a/src/hci/readline.c +++ b/src/hci/readline.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/shell.c b/src/hci/shell.c index 7e2ecaab6..cc7910eb8 100644 --- a/src/hci/shell.c +++ b/src/hci/shell.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/strerror.c b/src/hci/strerror.c index 1bba8c620..48091b413 100644 --- a/src/hci/strerror.c +++ b/src/hci/strerror.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * Find error description diff --git a/src/hci/tui/form_ui.c b/src/hci/tui/form_ui.c index 6cc28c369..2bce952fa 100644 --- a/src/hci/tui/form_ui.c +++ b/src/hci/tui/form_ui.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/hci/tui/login_ui.c b/src/hci/tui/login_ui.c index 02552f0d2..31069b154 100644 --- a/src/hci/tui/login_ui.c +++ b/src/hci/tui/login_ui.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/hci/tui/menu_ui.c b/src/hci/tui/menu_ui.c index c7fad4a6b..f789a298f 100644 --- a/src/hci/tui/menu_ui.c +++ b/src/hci/tui/menu_ui.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/hci/tui/message.c b/src/hci/tui/message.c index e3331d655..89c6f7703 100644 --- a/src/hci/tui/message.c +++ b/src/hci/tui/message.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/hci/tui/settings_ui.c b/src/hci/tui/settings_ui.c index 57ff9e9a0..a069c527d 100644 --- a/src/hci/tui/settings_ui.c +++ b/src/hci/tui/settings_ui.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/image/efi_image.c b/src/image/efi_image.c index e7b19c4ce..2631530e7 100644 --- a/src/image/efi_image.c +++ b/src/image/efi_image.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/image/embedded.c b/src/image/embedded.c index 652cfc85f..22d3738cc 100644 --- a/src/image/embedded.c +++ b/src/image/embedded.c @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/image/script.c b/src/image/script.c index 257e59a09..57662b788 100644 --- a/src/image/script.c +++ b/src/image/script.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/include/assert.h b/src/include/assert.h index 5affab2db..30277f9a9 100644 --- a/src/include/assert.h +++ b/src/include/assert.h @@ -11,6 +11,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifndef ASSERTING #ifdef NDEBUG diff --git a/src/include/bits/dma.h b/src/include/bits/dma.h index e9cb84942..c44b3e456 100644 --- a/src/include/bits/dma.h +++ b/src/include/bits/dma.h @@ -11,5 +11,6 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #endif /* _BITS_DMA_H */ diff --git a/src/include/bits/uaccess.h b/src/include/bits/uaccess.h index 09f5f46c8..e3f8b1412 100644 --- a/src/include/bits/uaccess.h +++ b/src/include/bits/uaccess.h @@ -11,5 +11,6 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #endif /* _BITS_UACCESS_H */ diff --git a/src/include/bits/umalloc.h b/src/include/bits/umalloc.h index 4927f0d00..689755b00 100644 --- a/src/include/bits/umalloc.h +++ b/src/include/bits/umalloc.h @@ -11,5 +11,6 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #endif /* _BITS_UMALLOC_H */ diff --git a/src/include/bits/virt_offset.h b/src/include/bits/virt_offset.h index 5f026284c..a67b6941e 100644 --- a/src/include/bits/virt_offset.h +++ b/src/include/bits/virt_offset.h @@ -11,5 +11,6 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #endif /* _BITS_VIRT_OFFSET_H */ diff --git a/src/include/byteswap.h b/src/include/byteswap.h index d1028c579..0910e4e2c 100644 --- a/src/include/byteswap.h +++ b/src/include/byteswap.h @@ -2,6 +2,7 @@ #define BYTESWAP_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ctype.h b/src/include/ctype.h index 6fefd5d77..15109ff9d 100644 --- a/src/include/ctype.h +++ b/src/include/ctype.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * Check if character is ASCII diff --git a/src/include/curses.h b/src/include/curses.h index cf8cc53c9..bbc437a4e 100644 --- a/src/include/curses.h +++ b/src/include/curses.h @@ -13,6 +13,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #undef ERR #define ERR (-1) diff --git a/src/include/endian.h b/src/include/endian.h index bdae9de45..5565673ca 100644 --- a/src/include/endian.h +++ b/src/include/endian.h @@ -2,6 +2,7 @@ #define _ENDIAN_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** Constant representing little-endian byte order * diff --git a/src/include/errno.h b/src/include/errno.h index ac012a691..8900cdb34 100644 --- a/src/include/errno.h +++ b/src/include/errno.h @@ -25,6 +25,7 @@ #define ERRNO_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/include/getopt.h b/src/include/getopt.h index db3de1786..4087c332f 100644 --- a/src/include/getopt.h +++ b/src/include/getopt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/hci/ifmgmt_cmd.h b/src/include/hci/ifmgmt_cmd.h index 5debf85c2..f1008e14f 100644 --- a/src/include/hci/ifmgmt_cmd.h +++ b/src/include/hci/ifmgmt_cmd.h @@ -25,6 +25,7 @@ #define _IFMGMT_CMD_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/acpi.h b/src/include/ipxe/acpi.h index 5e9fb5eba..c423aa584 100644 --- a/src/include/ipxe/acpi.h +++ b/src/include/ipxe/acpi.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/ansicol.h b/src/include/ipxe/ansicol.h index 2b54ecaca..9c34d596b 100644 --- a/src/include/ipxe/ansicol.h +++ b/src/include/ipxe/ansicol.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include /* For COLOR_RED etc. */ diff --git a/src/include/ipxe/ansiesc.h b/src/include/ipxe/ansiesc.h index 80bc83308..280f51066 100644 --- a/src/include/ipxe/ansiesc.h +++ b/src/include/ipxe/ansiesc.h @@ -27,6 +27,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); struct ansiesc_context; diff --git a/src/include/ipxe/aoe.h b/src/include/ipxe/aoe.h index 14d11c5cb..c548f42a2 100644 --- a/src/include/ipxe/aoe.h +++ b/src/include/ipxe/aoe.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/api.h b/src/include/ipxe/api.h index d05d3b07a..ab61f4f14 100644 --- a/src/include/ipxe/api.h +++ b/src/include/ipxe/api.h @@ -12,6 +12,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @defgroup Single-implementation APIs * diff --git a/src/include/ipxe/arp.h b/src/include/ipxe/arp.h index 674423c54..c70ea7eff 100644 --- a/src/include/ipxe/arp.h +++ b/src/include/ipxe/arp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/asn1.h b/src/include/ipxe/asn1.h index 86ebb890f..c5dcccb99 100644 --- a/src/include/ipxe/asn1.h +++ b/src/include/ipxe/asn1.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/ata.h b/src/include/ipxe/ata.h index cd78cd795..eea086c13 100644 --- a/src/include/ipxe/ata.h +++ b/src/include/ipxe/ata.h @@ -11,6 +11,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * An ATA Logical Block Address diff --git a/src/include/ipxe/base16.h b/src/include/ipxe/base16.h index c9e430e7e..b2cf42eb4 100644 --- a/src/include/ipxe/base16.h +++ b/src/include/ipxe/base16.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/base64.h b/src/include/ipxe/base64.h index 0c70d8382..f93039901 100644 --- a/src/include/ipxe/base64.h +++ b/src/include/ipxe/base64.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/bitmap.h b/src/include/ipxe/bitmap.h index 38aca694b..7533d1bf9 100644 --- a/src/include/ipxe/bitmap.h +++ b/src/include/ipxe/bitmap.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/blockdev.h b/src/include/ipxe/blockdev.h index ef6fc8d5a..7e4d48ce4 100644 --- a/src/include/ipxe/blockdev.h +++ b/src/include/ipxe/blockdev.h @@ -9,6 +9,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/blocktrans.h b/src/include/ipxe/blocktrans.h index 1eb388854..66a7e353c 100644 --- a/src/include/ipxe/blocktrans.h +++ b/src/include/ipxe/blocktrans.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/cachedhcp.h b/src/include/ipxe/cachedhcp.h index 5b19bc59e..100e5e098 100644 --- a/src/include/ipxe/cachedhcp.h +++ b/src/include/ipxe/cachedhcp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/chap.h b/src/include/ipxe/chap.h index 7c693e29d..965143095 100644 --- a/src/include/ipxe/chap.h +++ b/src/include/ipxe/chap.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/command.h b/src/include/ipxe/command.h index 331536313..cbd5fb665 100644 --- a/src/include/ipxe/command.h +++ b/src/include/ipxe/command.h @@ -2,6 +2,7 @@ #define _IPXE_COMMAND_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/console.h b/src/include/ipxe/console.h index 1b764aaca..5e652a974 100644 --- a/src/include/ipxe/console.h +++ b/src/include/ipxe/console.h @@ -17,6 +17,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); struct pixel_buffer; diff --git a/src/include/ipxe/cpio.h b/src/include/ipxe/cpio.h index 744dbd269..f1752ab0a 100644 --- a/src/include/ipxe/cpio.h +++ b/src/include/ipxe/cpio.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/crc32.h b/src/include/ipxe/crc32.h index 30d2fe66c..7fe7ec88e 100644 --- a/src/include/ipxe/crc32.h +++ b/src/include/ipxe/crc32.h @@ -2,6 +2,7 @@ #define _IPXE_CRC32_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/crypto.h b/src/include/ipxe/crypto.h index dd567fb2c..f458d7f30 100644 --- a/src/include/ipxe/crypto.h +++ b/src/include/ipxe/crypto.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/device.h b/src/include/ipxe/device.h index 89e6e4f31..ca12d2c07 100644 --- a/src/include/ipxe/device.h +++ b/src/include/ipxe/device.h @@ -9,6 +9,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/dhcp.h b/src/include/ipxe/dhcp.h index 43729d0c5..bdbe3b741 100644 --- a/src/include/ipxe/dhcp.h +++ b/src/include/ipxe/dhcp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/dhcparch.h b/src/include/ipxe/dhcparch.h index 89ecfb31e..ff611331c 100644 --- a/src/include/ipxe/dhcparch.h +++ b/src/include/ipxe/dhcparch.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /* Include platform-specific client architecture definitions */ #define PLATFORM_DHCPARCH(_platform) diff --git a/src/include/ipxe/dhcpopts.h b/src/include/ipxe/dhcpopts.h index 707fda4a8..9fe7bb110 100644 --- a/src/include/ipxe/dhcpopts.h +++ b/src/include/ipxe/dhcpopts.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/dhcppkt.h b/src/include/ipxe/dhcppkt.h index 86075960a..7d0153107 100644 --- a/src/include/ipxe/dhcppkt.h +++ b/src/include/ipxe/dhcppkt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/dhcpv6.h b/src/include/ipxe/dhcpv6.h index 065e9c376..45b36724a 100644 --- a/src/include/ipxe/dhcpv6.h +++ b/src/include/ipxe/dhcpv6.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/dma.h b/src/include/ipxe/dma.h index a6e41c1ab..e6e7a4793 100644 --- a/src/include/ipxe/dma.h +++ b/src/include/ipxe/dma.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/dns.h b/src/include/ipxe/dns.h index 738dea6e4..e7fc32c25 100644 --- a/src/include/ipxe/dns.h +++ b/src/include/ipxe/dns.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/downloader.h b/src/include/ipxe/downloader.h index ccb1abfef..f87a8ea78 100644 --- a/src/include/ipxe/downloader.h +++ b/src/include/ipxe/downloader.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); struct interface; struct image; diff --git a/src/include/ipxe/dummy_sanboot.h b/src/include/ipxe/dummy_sanboot.h index 9c9d942aa..991a2545a 100644 --- a/src/include/ipxe/dummy_sanboot.h +++ b/src/include/ipxe/dummy_sanboot.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef SANBOOT_DUMMY #define SANBOOT_PREFIX_dummy diff --git a/src/include/ipxe/dynui.h b/src/include/ipxe/dynui.h index f47f5cb36..e50c6ab49 100644 --- a/src/include/ipxe/dynui.h +++ b/src/include/ipxe/dynui.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/eap.h b/src/include/ipxe/eap.h index a44f01e0a..2b3770138 100644 --- a/src/include/ipxe/eap.h +++ b/src/include/ipxe/eap.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/eapol.h b/src/include/ipxe/eapol.h index dcf392946..2d44750ec 100644 --- a/src/include/ipxe/eapol.h +++ b/src/include/ipxe/eapol.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/ecam_io.h b/src/include/ipxe/ecam_io.h index b2c232013..f31ccdc53 100644 --- a/src/include/ipxe/ecam_io.h +++ b/src/include/ipxe/ecam_io.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/edd.h b/src/include/ipxe/edd.h index 1914fd0b0..9529da475 100644 --- a/src/include/ipxe/edd.h +++ b/src/include/ipxe/edd.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/editbox.h b/src/include/ipxe/editbox.h index 1f62485fe..85d5919c9 100644 --- a/src/include/ipxe/editbox.h +++ b/src/include/ipxe/editbox.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/editstring.h b/src/include/ipxe/editstring.h index 7ad8fb304..48dc34f18 100644 --- a/src/include/ipxe/editstring.h +++ b/src/include/ipxe/editstring.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** An editable string */ struct edit_string { diff --git a/src/include/ipxe/efi/ProcessorBind.h b/src/include/ipxe/efi/ProcessorBind.h index 21b873163..9fb8012f7 100644 --- a/src/include/ipxe/efi/ProcessorBind.h +++ b/src/include/ipxe/efi/ProcessorBind.h @@ -2,6 +2,7 @@ #define _IPXE_EFI_PROCESSOR_BIND_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /* * EFI header files rely on having the CPU architecture directory diff --git a/src/include/ipxe/efi/Protocol/AppleNetBoot.h b/src/include/ipxe/efi/Protocol/AppleNetBoot.h index 5946524fd..417730bc3 100644 --- a/src/include/ipxe/efi/Protocol/AppleNetBoot.h +++ b/src/include/ipxe/efi/Protocol/AppleNetBoot.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( BSD3 ); +FILE_SECBOOT ( PERMITTED ); #define EFI_APPLE_NET_BOOT_PROTOCOL_GUID \ { 0x78ee99fb, 0x6a5e, 0x4186, \ diff --git a/src/include/ipxe/efi/Protocol/ShimLock.h b/src/include/ipxe/efi/Protocol/ShimLock.h index b31365173..8fd3c3bc8 100644 --- a/src/include/ipxe/efi/Protocol/ShimLock.h +++ b/src/include/ipxe/efi/Protocol/ShimLock.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( BSD3 ); +FILE_SECBOOT ( PERMITTED ); #define EFI_SHIM_LOCK_PROTOCOL_GUID \ { 0x605dab50, 0xe046, 0x4300, \ diff --git a/src/include/ipxe/efi/efi.h b/src/include/ipxe/efi/efi.h index 3085704b0..9554a6ad7 100644 --- a/src/include/ipxe/efi/efi.h +++ b/src/include/ipxe/efi/efi.h @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); /* EFI headers rudely redefine NULL */ #undef NULL diff --git a/src/include/ipxe/efi/efi_acpi.h b/src/include/ipxe/efi/efi_acpi.h index 68f9c5be7..d11ae95b1 100644 --- a/src/include/ipxe/efi/efi_acpi.h +++ b/src/include/ipxe/efi/efi_acpi.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef ACPI_EFI #define ACPI_PREFIX_efi diff --git a/src/include/ipxe/efi/efi_autoboot.h b/src/include/ipxe/efi/efi_autoboot.h index 94fd2d766..29b80fd86 100644 --- a/src/include/ipxe/efi/efi_autoboot.h +++ b/src/include/ipxe/efi/efi_autoboot.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/efi/efi_autoexec.h b/src/include/ipxe/efi/efi_autoexec.h index 18bc4200c..1e68daeee 100644 --- a/src/include/ipxe/efi/efi_autoexec.h +++ b/src/include/ipxe/efi/efi_autoexec.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern int efi_autoexec_load ( void ); diff --git a/src/include/ipxe/efi/efi_block.h b/src/include/ipxe/efi/efi_block.h index f8cf7fc13..b010d71a3 100644 --- a/src/include/ipxe/efi/efi_block.h +++ b/src/include/ipxe/efi/efi_block.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef SANBOOT_EFI #define SANBOOT_PREFIX_efi diff --git a/src/include/ipxe/efi/efi_cachedhcp.h b/src/include/ipxe/efi/efi_cachedhcp.h index 5968a1ea2..86164f463 100644 --- a/src/include/ipxe/efi/efi_cachedhcp.h +++ b/src/include/ipxe/efi/efi_cachedhcp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/efi/efi_cmdline.h b/src/include/ipxe/efi/efi_cmdline.h index 45abd5493..ed43d71a7 100644 --- a/src/include/ipxe/efi/efi_cmdline.h +++ b/src/include/ipxe/efi/efi_cmdline.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/efi/efi_download.h b/src/include/ipxe/efi/efi_download.h index 740fcadf5..ca96efae2 100644 --- a/src/include/ipxe/efi/efi_download.h +++ b/src/include/ipxe/efi/efi_download.h @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/include/ipxe/efi/efi_driver.h b/src/include/ipxe/efi/efi_driver.h index 5ab2d011a..f373e47d3 100644 --- a/src/include/ipxe/efi/efi_driver.h +++ b/src/include/ipxe/efi/efi_driver.h @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/efi/efi_fdt.h b/src/include/ipxe/efi/efi_fdt.h index d18676d7e..644e6ddf9 100644 --- a/src/include/ipxe/efi/efi_fdt.h +++ b/src/include/ipxe/efi/efi_fdt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/efi/efi_file.h b/src/include/ipxe/efi/efi_file.h index 79c073cf1..bf14297a1 100644 --- a/src/include/ipxe/efi/efi_file.h +++ b/src/include/ipxe/efi/efi_file.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern int efi_file_install ( EFI_HANDLE handle ); extern void efi_file_uninstall ( EFI_HANDLE handle ); diff --git a/src/include/ipxe/efi/efi_hii.h b/src/include/ipxe/efi/efi_hii.h index bbec31194..8a001723f 100644 --- a/src/include/ipxe/efi/efi_hii.h +++ b/src/include/ipxe/efi/efi_hii.h @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/efi/efi_image.h b/src/include/ipxe/efi/efi_image.h index 0fc0402b1..7fd2e2894 100644 --- a/src/include/ipxe/efi/efi_image.h +++ b/src/include/ipxe/efi/efi_image.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/efi/efi_nap.h b/src/include/ipxe/efi/efi_nap.h index 1ffb05569..6c01072c3 100644 --- a/src/include/ipxe/efi/efi_nap.h +++ b/src/include/ipxe/efi/efi_nap.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef NAP_EFI #define NAP_PREFIX_efi diff --git a/src/include/ipxe/efi/efi_null.h b/src/include/ipxe/efi/efi_null.h index d23d36349..e81545485 100644 --- a/src/include/ipxe/efi/efi_null.h +++ b/src/include/ipxe/efi/efi_null.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/efi/efi_path.h b/src/include/ipxe/efi/efi_path.h index a37d7b9d7..f68d782fb 100644 --- a/src/include/ipxe/efi/efi_path.h +++ b/src/include/ipxe/efi/efi_path.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/efi/efi_pci.h b/src/include/ipxe/efi/efi_pci.h index f8d1e3e40..670fb7d7a 100644 --- a/src/include/ipxe/efi/efi_pci.h +++ b/src/include/ipxe/efi/efi_pci.h @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/efi/efi_pci_api.h b/src/include/ipxe/efi/efi_pci_api.h index 956795254..474555871 100644 --- a/src/include/ipxe/efi/efi_pci_api.h +++ b/src/include/ipxe/efi/efi_pci_api.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef PCIAPI_EFI #define PCIAPI_PREFIX_efi diff --git a/src/include/ipxe/efi/efi_pxe.h b/src/include/ipxe/efi/efi_pxe.h index b356f3789..d9aac455c 100644 --- a/src/include/ipxe/efi/efi_pxe.h +++ b/src/include/ipxe/efi/efi_pxe.h @@ -10,6 +10,7 @@ #include FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern int efi_pxe_install ( EFI_HANDLE handle, struct net_device *netdev ); extern void efi_pxe_uninstall ( EFI_HANDLE handle ); diff --git a/src/include/ipxe/efi/efi_reboot.h b/src/include/ipxe/efi/efi_reboot.h index 249cae8c5..8eb38f271 100644 --- a/src/include/ipxe/efi/efi_reboot.h +++ b/src/include/ipxe/efi/efi_reboot.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef REBOOT_EFI #define REBOOT_PREFIX_efi diff --git a/src/include/ipxe/efi/efi_service.h b/src/include/ipxe/efi/efi_service.h index ca4c7b2a4..2c5bc8fe9 100644 --- a/src/include/ipxe/efi/efi_service.h +++ b/src/include/ipxe/efi/efi_service.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/efi/efi_shim.h b/src/include/ipxe/efi/efi_shim.h index 21f24315a..d205dec6d 100644 --- a/src/include/ipxe/efi/efi_shim.h +++ b/src/include/ipxe/efi/efi_shim.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/efi/efi_smbios.h b/src/include/ipxe/efi/efi_smbios.h index d890d5460..23af651a8 100644 --- a/src/include/ipxe/efi/efi_smbios.h +++ b/src/include/ipxe/efi/efi_smbios.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef SMBIOS_EFI #define SMBIOS_PREFIX_efi diff --git a/src/include/ipxe/efi/efi_snp.h b/src/include/ipxe/efi/efi_snp.h index 1095b19e3..0822466db 100644 --- a/src/include/ipxe/efi/efi_snp.h +++ b/src/include/ipxe/efi/efi_snp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/efi/efi_strings.h b/src/include/ipxe/efi/efi_strings.h index a7adff827..36f5a7eb0 100644 --- a/src/include/ipxe/efi/efi_strings.h +++ b/src/include/ipxe/efi/efi_strings.h @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/efi/efi_table.h b/src/include/ipxe/efi/efi_table.h index 9a41d8723..714069e15 100644 --- a/src/include/ipxe/efi/efi_table.h +++ b/src/include/ipxe/efi/efi_table.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/efi/efi_time.h b/src/include/ipxe/efi/efi_time.h index 099994b57..8b2addc0f 100644 --- a/src/include/ipxe/efi/efi_time.h +++ b/src/include/ipxe/efi/efi_time.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/efi/efi_umalloc.h b/src/include/ipxe/efi/efi_umalloc.h index 4eb2a5f9b..4d5c706ca 100644 --- a/src/include/ipxe/efi/efi_umalloc.h +++ b/src/include/ipxe/efi/efi_umalloc.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef UMALLOC_EFI #define UMALLOC_PREFIX_efi diff --git a/src/include/ipxe/efi/efi_utils.h b/src/include/ipxe/efi/efi_utils.h index 98659b150..29dc171d2 100644 --- a/src/include/ipxe/efi/efi_utils.h +++ b/src/include/ipxe/efi/efi_utils.h @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/efi/efi_veto.h b/src/include/ipxe/efi/efi_veto.h index c9ecbb05c..be48441ad 100644 --- a/src/include/ipxe/efi/efi_veto.h +++ b/src/include/ipxe/efi/efi_veto.h @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern void efi_veto ( void ); diff --git a/src/include/ipxe/efi/efi_watchdog.h b/src/include/ipxe/efi/efi_watchdog.h index 4a56b9a29..1801c6d6c 100644 --- a/src/include/ipxe/efi/efi_watchdog.h +++ b/src/include/ipxe/efi/efi_watchdog.h @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern struct retry_timer efi_watchdog; diff --git a/src/include/ipxe/efi/efi_wrap.h b/src/include/ipxe/efi/efi_wrap.h index 1cae3d2db..7801c77d0 100644 --- a/src/include/ipxe/efi/efi_wrap.h +++ b/src/include/ipxe/efi/efi_wrap.h @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/efi/mnpnet.h b/src/include/ipxe/efi/mnpnet.h index 99d6cf083..1f2d0d1f6 100644 --- a/src/include/ipxe/efi/mnpnet.h +++ b/src/include/ipxe/efi/mnpnet.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); struct efi_device; struct net_device; diff --git a/src/include/ipxe/errfile.h b/src/include/ipxe/errfile.h index d97c5eca6..8379adb13 100644 --- a/src/include/ipxe/errfile.h +++ b/src/include/ipxe/errfile.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/errno/efi.h b/src/include/ipxe/errno/efi.h index 9f010f5fb..2db2d5cb6 100644 --- a/src/include/ipxe/errno/efi.h +++ b/src/include/ipxe/errno/efi.h @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/errortab.h b/src/include/ipxe/errortab.h index 4fe81a6be..6c63bb6d1 100644 --- a/src/include/ipxe/errortab.h +++ b/src/include/ipxe/errortab.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/eth_slow.h b/src/include/ipxe/eth_slow.h index 754ea6e1f..757bb83f0 100644 --- a/src/include/ipxe/eth_slow.h +++ b/src/include/ipxe/eth_slow.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** Slow protocols header */ struct eth_slow_header { diff --git a/src/include/ipxe/ethernet.h b/src/include/ipxe/ethernet.h index dd04e00ce..f1eb21dd0 100644 --- a/src/include/ipxe/ethernet.h +++ b/src/include/ipxe/ethernet.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/fakedhcp.h b/src/include/ipxe/fakedhcp.h index d016b5237..f23a98f2d 100644 --- a/src/include/ipxe/fakedhcp.h +++ b/src/include/ipxe/fakedhcp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/fault.h b/src/include/ipxe/fault.h index 356296c35..251567226 100644 --- a/src/include/ipxe/fault.h +++ b/src/include/ipxe/fault.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/fc.h b/src/include/ipxe/fc.h index 840d11f62..8c2bbe5e5 100644 --- a/src/include/ipxe/fc.h +++ b/src/include/ipxe/fc.h @@ -9,6 +9,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/fcels.h b/src/include/ipxe/fcels.h index 02f755115..8aa086106 100644 --- a/src/include/ipxe/fcels.h +++ b/src/include/ipxe/fcels.h @@ -9,6 +9,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/fcp.h b/src/include/ipxe/fcp.h index d86afab42..96aae37db 100644 --- a/src/include/ipxe/fcp.h +++ b/src/include/ipxe/fcp.h @@ -9,6 +9,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/fdtmem.h b/src/include/ipxe/fdtmem.h index 8d7ebfe7e..1bbc38ff9 100644 --- a/src/include/ipxe/fdtmem.h +++ b/src/include/ipxe/fdtmem.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/features.h b/src/include/ipxe/features.h index e86a2d226..2d1ef3b7b 100644 --- a/src/include/ipxe/features.h +++ b/src/include/ipxe/features.h @@ -12,6 +12,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @defgroup featurecat Feature categories diff --git a/src/include/ipxe/fragment.h b/src/include/ipxe/fragment.h index 0069e5e08..474ad5e1c 100644 --- a/src/include/ipxe/fragment.h +++ b/src/include/ipxe/fragment.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/http.h b/src/include/ipxe/http.h index fc3e7b7a1..e84a75237 100644 --- a/src/include/ipxe/http.h +++ b/src/include/ipxe/http.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/ib_mad.h b/src/include/ipxe/ib_mad.h index 134274026..dcc432558 100644 --- a/src/include/ipxe/ib_mad.h +++ b/src/include/ipxe/ib_mad.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/ib_packet.h b/src/include/ipxe/ib_packet.h index 747f96399..087e86d5a 100644 --- a/src/include/ipxe/ib_packet.h +++ b/src/include/ipxe/ib_packet.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); struct ib_device; struct ib_queue_pair; diff --git a/src/include/ipxe/ib_srp.h b/src/include/ipxe/ib_srp.h index 4b6df8d3b..9bd272a3b 100644 --- a/src/include/ipxe/ib_srp.h +++ b/src/include/ipxe/ib_srp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( BSD2 ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/ibft.h b/src/include/ipxe/ibft.h index 51ce781a6..9534c1e8a 100644 --- a/src/include/ipxe/ibft.h +++ b/src/include/ipxe/ibft.h @@ -29,6 +29,7 @@ */ FILE_LICENCE ( BSD2 ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/include/ipxe/icmp.h b/src/include/ipxe/icmp.h index 803f8e019..a62e63ee8 100644 --- a/src/include/ipxe/icmp.h +++ b/src/include/ipxe/icmp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/icmpv6.h b/src/include/ipxe/icmpv6.h index 0474ddca8..7d0c5ba14 100644 --- a/src/include/ipxe/icmpv6.h +++ b/src/include/ipxe/icmpv6.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/if_arp.h b/src/include/ipxe/if_arp.h index 9d7b03fe8..31d7d8b73 100644 --- a/src/include/ipxe/if_arp.h +++ b/src/include/ipxe/if_arp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/if_ether.h b/src/include/ipxe/if_ether.h index c1168b10e..a7d0e55f9 100644 --- a/src/include/ipxe/if_ether.h +++ b/src/include/ipxe/if_ether.h @@ -2,6 +2,7 @@ #define _IPXE_IF_ETHER_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/image.h b/src/include/ipxe/image.h index e0e70f360..d9abe11ec 100644 --- a/src/include/ipxe/image.h +++ b/src/include/ipxe/image.h @@ -9,6 +9,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/in.h b/src/include/ipxe/in.h index 05a8122ef..f91ab306a 100644 --- a/src/include/ipxe/in.h +++ b/src/include/ipxe/in.h @@ -2,6 +2,7 @@ #define _IPXE_IN_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/infiniband.h b/src/include/ipxe/infiniband.h index 379bc109e..8022ab606 100644 --- a/src/include/ipxe/infiniband.h +++ b/src/include/ipxe/infiniband.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/init.h b/src/include/ipxe/init.h index da01b2953..00946fe83 100644 --- a/src/include/ipxe/init.h +++ b/src/include/ipxe/init.h @@ -2,6 +2,7 @@ #define _IPXE_INIT_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/initrd.h b/src/include/ipxe/initrd.h index 0b955a381..50788597b 100644 --- a/src/include/ipxe/initrd.h +++ b/src/include/ipxe/initrd.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/interface.h b/src/include/ipxe/interface.h index d2fa8190c..87fd3c62f 100644 --- a/src/include/ipxe/interface.h +++ b/src/include/ipxe/interface.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/io.h b/src/include/ipxe/io.h index ee2b7e156..1bb49370c 100644 --- a/src/include/ipxe/io.h +++ b/src/include/ipxe/io.h @@ -17,6 +17,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/iobuf.h b/src/include/ipxe/iobuf.h index 46b350458..2ff24e50f 100644 --- a/src/include/ipxe/iobuf.h +++ b/src/include/ipxe/iobuf.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/iomap.h b/src/include/ipxe/iomap.h index 7d1547d9c..23153641e 100644 --- a/src/include/ipxe/iomap.h +++ b/src/include/ipxe/iomap.h @@ -10,6 +10,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/iomap_virt.h b/src/include/ipxe/iomap_virt.h index 3dd66bd75..a2564ec76 100644 --- a/src/include/ipxe/iomap_virt.h +++ b/src/include/ipxe/iomap_virt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/ip.h b/src/include/ipxe/ip.h index e2cd512ac..3a5c3e175 100644 --- a/src/include/ipxe/ip.h +++ b/src/include/ipxe/ip.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/ipstat.h b/src/include/ipxe/ipstat.h index b34ed5fcf..b02673dcd 100644 --- a/src/include/ipxe/ipstat.h +++ b/src/include/ipxe/ipstat.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/ipv6.h b/src/include/ipxe/ipv6.h index 4dd43f16d..bd7181e69 100644 --- a/src/include/ipxe/ipv6.h +++ b/src/include/ipxe/ipv6.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/iscsi.h b/src/include/ipxe/iscsi.h index a25eec257..e890e62ad 100644 --- a/src/include/ipxe/iscsi.h +++ b/src/include/ipxe/iscsi.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/iso9660.h b/src/include/ipxe/iso9660.h index 34cb8f0a1..6727c7721 100644 --- a/src/include/ipxe/iso9660.h +++ b/src/include/ipxe/iso9660.h @@ -9,6 +9,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/job.h b/src/include/ipxe/job.h index c01bd1740..088012ba7 100644 --- a/src/include/ipxe/job.h +++ b/src/include/ipxe/job.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/jumpscroll.h b/src/include/ipxe/jumpscroll.h index 470f08e71..0eec1b47b 100644 --- a/src/include/ipxe/jumpscroll.h +++ b/src/include/ipxe/jumpscroll.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/keymap.h b/src/include/ipxe/keymap.h index 49a8915ef..cdb83e03b 100644 --- a/src/include/ipxe/keymap.h +++ b/src/include/ipxe/keymap.h @@ -9,6 +9,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/keys.h b/src/include/ipxe/keys.h index 38ebd7d1a..b2a62744e 100644 --- a/src/include/ipxe/keys.h +++ b/src/include/ipxe/keys.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /* * Symbolic names for some standard ASCII characters diff --git a/src/include/ipxe/linebuf.h b/src/include/ipxe/linebuf.h index 630278a04..b46168415 100644 --- a/src/include/ipxe/linebuf.h +++ b/src/include/ipxe/linebuf.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/linux/linux_acpi.h b/src/include/ipxe/linux/linux_acpi.h index a2c33ce2c..f6dbc9252 100644 --- a/src/include/ipxe/linux/linux_acpi.h +++ b/src/include/ipxe/linux/linux_acpi.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef ACPI_LINUX #define ACPI_PREFIX_linux diff --git a/src/include/ipxe/linux/linux_nap.h b/src/include/ipxe/linux/linux_nap.h index d072886c7..329124e52 100644 --- a/src/include/ipxe/linux/linux_nap.h +++ b/src/include/ipxe/linux/linux_nap.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef NAP_LINUX #define NAP_PREFIX_linux diff --git a/src/include/ipxe/linux/linux_pci.h b/src/include/ipxe/linux/linux_pci.h index f9cd98819..b0fddc41a 100644 --- a/src/include/ipxe/linux/linux_pci.h +++ b/src/include/ipxe/linux/linux_pci.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef PCIAPI_LINUX #define PCIAPI_PREFIX_linux diff --git a/src/include/ipxe/linux/linux_smbios.h b/src/include/ipxe/linux/linux_smbios.h index 16c6d8acd..32f006b66 100644 --- a/src/include/ipxe/linux/linux_smbios.h +++ b/src/include/ipxe/linux/linux_smbios.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef SMBIOS_LINUX #define SMBIOS_PREFIX_linux diff --git a/src/include/ipxe/linux/linux_time.h b/src/include/ipxe/linux/linux_time.h index 872ef5ade..cf02452d7 100644 --- a/src/include/ipxe/linux/linux_time.h +++ b/src/include/ipxe/linux/linux_time.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef TIME_LINUX #define TIME_PREFIX_linux diff --git a/src/include/ipxe/linux/linux_uaccess.h b/src/include/ipxe/linux/linux_uaccess.h index 7770ea90e..c3119a60e 100644 --- a/src/include/ipxe/linux/linux_uaccess.h +++ b/src/include/ipxe/linux/linux_uaccess.h @@ -13,6 +13,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef UACCESS_LINUX #define UACCESS_PREFIX_linux diff --git a/src/include/ipxe/linux/linux_umalloc.h b/src/include/ipxe/linux/linux_umalloc.h index 1811d0bc6..c1669b42a 100644 --- a/src/include/ipxe/linux/linux_umalloc.h +++ b/src/include/ipxe/linux/linux_umalloc.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef UMALLOC_LINUX #define UMALLOC_PREFIX_linux diff --git a/src/include/ipxe/list.h b/src/include/ipxe/list.h index 2f02e71f0..4282d8455 100644 --- a/src/include/ipxe/list.h +++ b/src/include/ipxe/list.h @@ -10,6 +10,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/lldp.h b/src/include/ipxe/lldp.h index 9951d3b8f..7d4e7f6cf 100644 --- a/src/include/ipxe/lldp.h +++ b/src/include/ipxe/lldp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/login_ui.h b/src/include/ipxe/login_ui.h index 313e07349..2924a2f63 100644 --- a/src/include/ipxe/login_ui.h +++ b/src/include/ipxe/login_ui.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern int login_ui ( void ); diff --git a/src/include/ipxe/malloc.h b/src/include/ipxe/malloc.h index d3f056c15..fac46bd00 100644 --- a/src/include/ipxe/malloc.h +++ b/src/include/ipxe/malloc.h @@ -10,6 +10,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /* * Prototypes for the standard functions (malloc() et al) are in diff --git a/src/include/ipxe/md5.h b/src/include/ipxe/md5.h index 527ad3658..275e63824 100644 --- a/src/include/ipxe/md5.h +++ b/src/include/ipxe/md5.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/memmap.h b/src/include/ipxe/memmap.h index c16e25daa..4a768f867 100644 --- a/src/include/ipxe/memmap.h +++ b/src/include/ipxe/memmap.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/message.h b/src/include/ipxe/message.h index e2e783740..997135d70 100644 --- a/src/include/ipxe/message.h +++ b/src/include/ipxe/message.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern void msg ( unsigned int row, const char *fmt, ... ); extern void clearmsg ( unsigned int row ); diff --git a/src/include/ipxe/monojob.h b/src/include/ipxe/monojob.h index 1661d91c2..cda27616a 100644 --- a/src/include/ipxe/monojob.h +++ b/src/include/ipxe/monojob.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); struct interface; diff --git a/src/include/ipxe/nap.h b/src/include/ipxe/nap.h index 8d5d8e3df..eff5ad5b9 100644 --- a/src/include/ipxe/nap.h +++ b/src/include/ipxe/nap.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/ndp.h b/src/include/ipxe/ndp.h index d06672ec1..0c8a9a27d 100644 --- a/src/include/ipxe/ndp.h +++ b/src/include/ipxe/ndp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/neighbour.h b/src/include/ipxe/neighbour.h index e0701f6e3..d400bb93a 100644 --- a/src/include/ipxe/neighbour.h +++ b/src/include/ipxe/neighbour.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/netdevice.h b/src/include/ipxe/netdevice.h index 17695d5b6..62f0dd1f7 100644 --- a/src/include/ipxe/netdevice.h +++ b/src/include/ipxe/netdevice.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/ntlm.h b/src/include/ipxe/ntlm.h index b0436c9ac..867f5ddc3 100644 --- a/src/include/ipxe/ntlm.h +++ b/src/include/ipxe/ntlm.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/null_acpi.h b/src/include/ipxe/null_acpi.h index 18f059964..dd3992630 100644 --- a/src/include/ipxe/null_acpi.h +++ b/src/include/ipxe/null_acpi.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/null_memmap.h b/src/include/ipxe/null_memmap.h index 0933d45be..122280d14 100644 --- a/src/include/ipxe/null_memmap.h +++ b/src/include/ipxe/null_memmap.h @@ -10,6 +10,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef MEMMAP_NULL #define MEMMAP_PREFIX_null diff --git a/src/include/ipxe/null_nap.h b/src/include/ipxe/null_nap.h index 17145b48b..3f4fc13ae 100644 --- a/src/include/ipxe/null_nap.h +++ b/src/include/ipxe/null_nap.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef NAP_NULL #define NAP_PREFIX_null diff --git a/src/include/ipxe/null_pci.h b/src/include/ipxe/null_pci.h index 0cdcdc109..1e7b4da60 100644 --- a/src/include/ipxe/null_pci.h +++ b/src/include/ipxe/null_pci.h @@ -10,6 +10,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef PCIAPI_NULL #define PCIAPI_PREFIX_null diff --git a/src/include/ipxe/null_reboot.h b/src/include/ipxe/null_reboot.h index 5de38afc0..47539300a 100644 --- a/src/include/ipxe/null_reboot.h +++ b/src/include/ipxe/null_reboot.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef REBOOT_NULL #define REBOOT_PREFIX_null diff --git a/src/include/ipxe/null_sanboot.h b/src/include/ipxe/null_sanboot.h index b0e36b8b0..d455edbd6 100644 --- a/src/include/ipxe/null_sanboot.h +++ b/src/include/ipxe/null_sanboot.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef SANBOOT_NULL #define SANBOOT_PREFIX_null diff --git a/src/include/ipxe/null_smbios.h b/src/include/ipxe/null_smbios.h index c430dd089..474398b3c 100644 --- a/src/include/ipxe/null_smbios.h +++ b/src/include/ipxe/null_smbios.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef SMBIOS_NULL #define SMBIOS_PREFIX_null diff --git a/src/include/ipxe/null_time.h b/src/include/ipxe/null_time.h index c670a5fce..db85769f7 100644 --- a/src/include/ipxe/null_time.h +++ b/src/include/ipxe/null_time.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef TIME_NULL #define TIME_PREFIX_null diff --git a/src/include/ipxe/nvo.h b/src/include/ipxe/nvo.h index 7a3c7a3db..39e3a707d 100644 --- a/src/include/ipxe/nvo.h +++ b/src/include/ipxe/nvo.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/nvs.h b/src/include/ipxe/nvs.h index 5789f4c0d..1b02acea6 100644 --- a/src/include/ipxe/nvs.h +++ b/src/include/ipxe/nvs.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/open.h b/src/include/ipxe/open.h index 64e12d177..f429cadbe 100644 --- a/src/include/ipxe/open.h +++ b/src/include/ipxe/open.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/params.h b/src/include/ipxe/params.h index 61e46e029..64008380e 100644 --- a/src/include/ipxe/params.h +++ b/src/include/ipxe/params.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/parseopt.h b/src/include/ipxe/parseopt.h index 5c449cd42..dec230b0f 100644 --- a/src/include/ipxe/parseopt.h +++ b/src/include/ipxe/parseopt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/pci.h b/src/include/ipxe/pci.h index 2728cbd45..44095afe2 100644 --- a/src/include/ipxe/pci.h +++ b/src/include/ipxe/pci.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/pci_io.h b/src/include/ipxe/pci_io.h index 7ac09efb0..e67832fec 100644 --- a/src/include/ipxe/pci_io.h +++ b/src/include/ipxe/pci_io.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/pcicloud.h b/src/include/ipxe/pcicloud.h index 52268908c..19d5147be 100644 --- a/src/include/ipxe/pcicloud.h +++ b/src/include/ipxe/pcicloud.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef PCIAPI_CLOUD #define PCIAPI_PREFIX_cloud diff --git a/src/include/ipxe/pending.h b/src/include/ipxe/pending.h index be6ed05a1..1ed10df18 100644 --- a/src/include/ipxe/pending.h +++ b/src/include/ipxe/pending.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** A pending operation */ struct pending_operation { diff --git a/src/include/ipxe/ping.h b/src/include/ipxe/ping.h index c55bd1ab2..7a45f1ab7 100644 --- a/src/include/ipxe/ping.h +++ b/src/include/ipxe/ping.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/pool.h b/src/include/ipxe/pool.h index 81ff57d75..fbd8567a9 100644 --- a/src/include/ipxe/pool.h +++ b/src/include/ipxe/pool.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/process.h b/src/include/ipxe/process.h index d5e13aa04..0ec94f9bc 100644 --- a/src/include/ipxe/process.h +++ b/src/include/ipxe/process.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/profile.h b/src/include/ipxe/profile.h index fd45b3cdc..c7e6d54f2 100644 --- a/src/include/ipxe/profile.h +++ b/src/include/ipxe/profile.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/quiesce.h b/src/include/ipxe/quiesce.h index 00b530b83..a43628de0 100644 --- a/src/include/ipxe/quiesce.h +++ b/src/include/ipxe/quiesce.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/reboot.h b/src/include/ipxe/reboot.h index cfd5b546d..361988ff1 100644 --- a/src/include/ipxe/reboot.h +++ b/src/include/ipxe/reboot.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/refcnt.h b/src/include/ipxe/refcnt.h index 7f489abc9..dff67bf58 100644 --- a/src/include/ipxe/refcnt.h +++ b/src/include/ipxe/refcnt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/resolv.h b/src/include/ipxe/resolv.h index ff48d35ca..3f26577c6 100644 --- a/src/include/ipxe/resolv.h +++ b/src/include/ipxe/resolv.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/retry.h b/src/include/ipxe/retry.h index 76d45fbd0..6817bf4c9 100644 --- a/src/include/ipxe/retry.h +++ b/src/include/ipxe/retry.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/rotate.h b/src/include/ipxe/rotate.h index 4dea09aeb..77a87dffd 100644 --- a/src/include/ipxe/rotate.h +++ b/src/include/ipxe/rotate.h @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/sanboot.h b/src/include/ipxe/sanboot.h index 9d5fceee0..ea44191c2 100644 --- a/src/include/ipxe/sanboot.h +++ b/src/include/ipxe/sanboot.h @@ -10,6 +10,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/sbat.h b/src/include/ipxe/sbat.h index 4b74670ed..b708215c1 100644 --- a/src/include/ipxe/sbat.h +++ b/src/include/ipxe/sbat.h @@ -19,6 +19,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * A single line within an SBAT CSV file diff --git a/src/include/ipxe/script.h b/src/include/ipxe/script.h index 7e7a9a3a4..59a42c66f 100644 --- a/src/include/ipxe/script.h +++ b/src/include/ipxe/script.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/scsi.h b/src/include/ipxe/scsi.h index 9bb38a059..858f63547 100644 --- a/src/include/ipxe/scsi.h +++ b/src/include/ipxe/scsi.h @@ -11,6 +11,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** Maximum block for READ/WRITE (10) commands */ #define SCSI_MAX_BLOCK_10 0xffffffffULL diff --git a/src/include/ipxe/settings.h b/src/include/ipxe/settings.h index 689e011d3..1582aaa8f 100644 --- a/src/include/ipxe/settings.h +++ b/src/include/ipxe/settings.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/settings_ui.h b/src/include/ipxe/settings_ui.h index 0bf21935d..41e3351bc 100644 --- a/src/include/ipxe/settings_ui.h +++ b/src/include/ipxe/settings_ui.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); struct settings; diff --git a/src/include/ipxe/shell.h b/src/include/ipxe/shell.h index 0d574e028..cbea7b319 100644 --- a/src/include/ipxe/shell.h +++ b/src/include/ipxe/shell.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** Shell stop states */ enum shell_stop_state { diff --git a/src/include/ipxe/smbios.h b/src/include/ipxe/smbios.h index d9e2c38ed..5e431504a 100644 --- a/src/include/ipxe/smbios.h +++ b/src/include/ipxe/smbios.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/socket.h b/src/include/ipxe/socket.h index 8c70ea4c0..f0e80a712 100644 --- a/src/include/ipxe/socket.h +++ b/src/include/ipxe/socket.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/srp.h b/src/include/ipxe/srp.h index 1f66a22b2..c2450038f 100644 --- a/src/include/ipxe/srp.h +++ b/src/include/ipxe/srp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( BSD2 ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/stp.h b/src/include/ipxe/stp.h index 3d85e5ba4..b30e09d20 100644 --- a/src/include/ipxe/stp.h +++ b/src/include/ipxe/stp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/string.h b/src/include/ipxe/string.h index a8cbe8faa..593ced230 100644 --- a/src/include/ipxe/string.h +++ b/src/include/ipxe/string.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern unsigned int digit_value ( unsigned int digit ); diff --git a/src/include/ipxe/tables.h b/src/include/ipxe/tables.h index ac17f4b4b..d0f88cf56 100644 --- a/src/include/ipxe/tables.h +++ b/src/include/ipxe/tables.h @@ -2,6 +2,7 @@ #define _IPXE_TABLES_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @page ifdef_harmful #ifdef considered harmful * diff --git a/src/include/ipxe/tcp.h b/src/include/ipxe/tcp.h index a1e89f718..14e8169e0 100644 --- a/src/include/ipxe/tcp.h +++ b/src/include/ipxe/tcp.h @@ -10,6 +10,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/tcpip.h b/src/include/ipxe/tcpip.h index 414daad53..cfee7aa1e 100644 --- a/src/include/ipxe/tcpip.h +++ b/src/include/ipxe/tcpip.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/tftp.h b/src/include/ipxe/tftp.h index e3661e1ac..fa029e234 100644 --- a/src/include/ipxe/tftp.h +++ b/src/include/ipxe/tftp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/time.h b/src/include/ipxe/time.h index 89bf90e03..1b6f5daff 100644 --- a/src/include/ipxe/time.h +++ b/src/include/ipxe/time.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/timer.h b/src/include/ipxe/timer.h index a6dffaf1c..72ddc9d28 100644 --- a/src/include/ipxe/timer.h +++ b/src/include/ipxe/timer.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/uaccess.h b/src/include/ipxe/uaccess.h index d97db95be..1b0dc9de7 100644 --- a/src/include/ipxe/uaccess.h +++ b/src/include/ipxe/uaccess.h @@ -9,6 +9,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/udp.h b/src/include/ipxe/udp.h index 7b0de4dc0..693b2a422 100644 --- a/src/include/ipxe/udp.h +++ b/src/include/ipxe/udp.h @@ -10,6 +10,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/uheap.h b/src/include/ipxe/uheap.h index d356786d3..0d37a649a 100644 --- a/src/include/ipxe/uheap.h +++ b/src/include/ipxe/uheap.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef UMALLOC_UHEAP #define UMALLOC_PREFIX_uheap diff --git a/src/include/ipxe/umalloc.h b/src/include/ipxe/umalloc.h index da6c34143..c2a13dfdf 100644 --- a/src/include/ipxe/umalloc.h +++ b/src/include/ipxe/umalloc.h @@ -9,6 +9,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/uri.h b/src/include/ipxe/uri.h index a94b525e1..0de0135e4 100644 --- a/src/include/ipxe/uri.h +++ b/src/include/ipxe/uri.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/usb.h b/src/include/ipxe/usb.h index d9891b757..9b8c7ae00 100644 --- a/src/include/ipxe/usb.h +++ b/src/include/ipxe/usb.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/utf8.h b/src/include/ipxe/utf8.h index 299c25511..10b2fcbd6 100644 --- a/src/include/ipxe/utf8.h +++ b/src/include/ipxe/utf8.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/uuid.h b/src/include/ipxe/uuid.h index 4874b7382..d0120741d 100644 --- a/src/include/ipxe/uuid.h +++ b/src/include/ipxe/uuid.h @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/version.h b/src/include/ipxe/version.h index a43a33425..6be6096dc 100644 --- a/src/include/ipxe/version.h +++ b/src/include/ipxe/version.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/virt_offset.h b/src/include/ipxe/virt_offset.h index 2762acb40..31c434fc5 100644 --- a/src/include/ipxe/virt_offset.h +++ b/src/include/ipxe/virt_offset.h @@ -47,6 +47,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef UACCESS_OFFSET #define UACCESS_PREFIX_offset diff --git a/src/include/ipxe/vlan.h b/src/include/ipxe/vlan.h index 20bbc891d..a1cd76182 100644 --- a/src/include/ipxe/vlan.h +++ b/src/include/ipxe/vlan.h @@ -9,6 +9,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/vsprintf.h b/src/include/ipxe/vsprintf.h index 9e6297715..8b25422d8 100644 --- a/src/include/ipxe/vsprintf.h +++ b/src/include/ipxe/vsprintf.h @@ -32,6 +32,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/widget.h b/src/include/ipxe/widget.h index 945b4672a..6e61a8ca8 100644 --- a/src/include/ipxe/widget.h +++ b/src/include/ipxe/widget.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/xfer.h b/src/include/ipxe/xfer.h index 3a35fa924..c35be31d9 100644 --- a/src/include/ipxe/xfer.h +++ b/src/include/ipxe/xfer.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/xferbuf.h b/src/include/ipxe/xferbuf.h index 04fcf2286..aa0b2471f 100644 --- a/src/include/ipxe/xferbuf.h +++ b/src/include/ipxe/xferbuf.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/libgen.h b/src/include/libgen.h index ae0861270..b686b15ac 100644 --- a/src/include/libgen.h +++ b/src/include/libgen.h @@ -2,6 +2,7 @@ #define _LIBGEN_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern char * basename ( char *path ); extern char * dirname ( char *path ); diff --git a/src/include/readline/readline.h b/src/include/readline/readline.h index 3caf28b47..a2a1d950a 100644 --- a/src/include/readline/readline.h +++ b/src/include/readline/readline.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** A readline history entry */ struct readline_history_entry { diff --git a/src/include/stdarg.h b/src/include/stdarg.h index 89e94ce22..a981ea24a 100644 --- a/src/include/stdarg.h +++ b/src/include/stdarg.h @@ -2,6 +2,7 @@ #define _STDARG_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); typedef __builtin_va_list va_list; #define va_start( ap, last ) __builtin_va_start ( ap, last ) diff --git a/src/include/stdbool.h b/src/include/stdbool.h index c49a7f192..6afd038db 100644 --- a/src/include/stdbool.h +++ b/src/include/stdbool.h @@ -2,6 +2,7 @@ #define _STDBOOL_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #define bool _Bool #define true 1 diff --git a/src/include/stddef.h b/src/include/stddef.h index fb01c489d..7f46a7729 100644 --- a/src/include/stddef.h +++ b/src/include/stddef.h @@ -2,6 +2,7 @@ #define STDDEF_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/stdint.h b/src/include/stdint.h index 0a239a517..2fcd184fa 100644 --- a/src/include/stdint.h +++ b/src/include/stdint.h @@ -2,6 +2,7 @@ #define _STDINT_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /* * This is a standard predefined macro on all gcc's I've seen. It's diff --git a/src/include/stdio.h b/src/include/stdio.h index ac17da83d..5dfa67865 100644 --- a/src/include/stdio.h +++ b/src/include/stdio.h @@ -2,6 +2,7 @@ #define _STDIO_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/stdlib.h b/src/include/stdlib.h index d7748a07e..8a531110e 100644 --- a/src/include/stdlib.h +++ b/src/include/stdlib.h @@ -2,6 +2,7 @@ #define STDLIB_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/string.h b/src/include/string.h index 4ee9c7344..3affe8e86 100644 --- a/src/include/string.h +++ b/src/include/string.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/strings.h b/src/include/strings.h index d7e9d6971..8eac3e5e4 100644 --- a/src/include/strings.h +++ b/src/include/strings.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/sys/time.h b/src/include/sys/time.h index 6e2a24447..e49df570f 100644 --- a/src/include/sys/time.h +++ b/src/include/sys/time.h @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/syslog.h b/src/include/syslog.h index 748a4faec..09c0112fd 100644 --- a/src/include/syslog.h +++ b/src/include/syslog.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/time.h b/src/include/time.h index ab93a3dbb..5ef67ece2 100644 --- a/src/include/time.h +++ b/src/include/time.h @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/unistd.h b/src/include/unistd.h index 6c31c0601..56431d15e 100644 --- a/src/include/unistd.h +++ b/src/include/unistd.h @@ -2,6 +2,7 @@ #define _UNISTD_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/usr/autoboot.h b/src/include/usr/autoboot.h index a081a70df..fbc8b10e9 100644 --- a/src/include/usr/autoboot.h +++ b/src/include/usr/autoboot.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/usr/dhcpmgmt.h b/src/include/usr/dhcpmgmt.h index ed669eb9d..2440b1713 100644 --- a/src/include/usr/dhcpmgmt.h +++ b/src/include/usr/dhcpmgmt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); struct net_device; diff --git a/src/include/usr/ifmgmt.h b/src/include/usr/ifmgmt.h index 8d8a6bb56..3b489c02a 100644 --- a/src/include/usr/ifmgmt.h +++ b/src/include/usr/ifmgmt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); struct net_device; struct net_device_configurator; diff --git a/src/include/usr/imgmgmt.h b/src/include/usr/imgmgmt.h index 506c3eb14..f98af7984 100644 --- a/src/include/usr/imgmgmt.h +++ b/src/include/usr/imgmgmt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/usr/prompt.h b/src/include/usr/prompt.h index 8d3eeee3c..22c39105f 100644 --- a/src/include/usr/prompt.h +++ b/src/include/usr/prompt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern int prompt ( const char *text, unsigned long timeout, int key ); diff --git a/src/include/usr/route.h b/src/include/usr/route.h index 7ec4a3509..7503c8c55 100644 --- a/src/include/usr/route.h +++ b/src/include/usr/route.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/usr/shimmgmt.h b/src/include/usr/shimmgmt.h index 0c59f54a8..0ed85c468 100644 --- a/src/include/usr/shimmgmt.h +++ b/src/include/usr/shimmgmt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/usr/sync.h b/src/include/usr/sync.h index b6f12ad6e..b24ab32fb 100644 --- a/src/include/usr/sync.h +++ b/src/include/usr/sync.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern int sync ( unsigned long timeout ); diff --git a/src/include/valgrind/memcheck.h b/src/include/valgrind/memcheck.h index 7d4b56d31..e7fae01ed 100644 --- a/src/include/valgrind/memcheck.h +++ b/src/include/valgrind/memcheck.h @@ -61,6 +61,7 @@ #define __MEMCHECK_H FILE_LICENCE ( BSD3 ); +FILE_SECBOOT ( PERMITTED ); /* This file is for inclusion into client (your!) code. diff --git a/src/include/valgrind/valgrind.h b/src/include/valgrind/valgrind.h index d48bbccae..1a907cbbf 100644 --- a/src/include/valgrind/valgrind.h +++ b/src/include/valgrind/valgrind.h @@ -74,6 +74,7 @@ #define __VALGRIND_H FILE_LICENCE ( BSD3 ); +FILE_SECBOOT ( PERMITTED ); /* ------------------------------------------------------------------ */ diff --git a/src/include/wchar.h b/src/include/wchar.h index a7e9de4f2..427bfff7a 100644 --- a/src/include/wchar.h +++ b/src/include/wchar.h @@ -2,6 +2,7 @@ #define WCHAR_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/interface/efi/efi_acpi.c b/src/interface/efi/efi_acpi.c index a2021a4f6..cb8b4a5d0 100644 --- a/src/interface/efi/efi_acpi.c +++ b/src/interface/efi/efi_acpi.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/interface/efi/efi_autoboot.c b/src/interface/efi/efi_autoboot.c index e52c857d8..9e0c3e42e 100644 --- a/src/interface/efi/efi_autoboot.c +++ b/src/interface/efi/efi_autoboot.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_autoexec.c b/src/interface/efi/efi_autoexec.c index 73ba5df33..b63ac1602 100644 --- a/src/interface/efi/efi_autoexec.c +++ b/src/interface/efi/efi_autoexec.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_block.c b/src/interface/efi/efi_block.c index 10952ef8a..0da92307b 100644 --- a/src/interface/efi/efi_block.c +++ b/src/interface/efi/efi_block.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/interface/efi/efi_cachedhcp.c b/src/interface/efi/efi_cachedhcp.c index 6bba4173a..2f33fcefb 100644 --- a/src/interface/efi/efi_cachedhcp.c +++ b/src/interface/efi/efi_cachedhcp.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_cmdline.c b/src/interface/efi/efi_cmdline.c index 8b9d8efde..f5844f2ad 100644 --- a/src/interface/efi/efi_cmdline.c +++ b/src/interface/efi/efi_cmdline.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/interface/efi/efi_connect.c b/src/interface/efi/efi_connect.c index 5aa8dc689..f4747cf6b 100644 --- a/src/interface/efi/efi_connect.c +++ b/src/interface/efi/efi_connect.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/interface/efi/efi_console.c b/src/interface/efi/efi_console.c index e896c5d88..afbd722ab 100644 --- a/src/interface/efi/efi_console.c +++ b/src/interface/efi/efi_console.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_download.c b/src/interface/efi/efi_download.c index 8d12bd57c..1c2f13573 100644 --- a/src/interface/efi/efi_download.c +++ b/src/interface/efi/efi_download.c @@ -17,6 +17,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_driver.c b/src/interface/efi/efi_driver.c index b1ff404be..cb07af401 100644 --- a/src/interface/efi/efi_driver.c +++ b/src/interface/efi/efi_driver.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_file.c b/src/interface/efi/efi_file.c index 1909dea10..2f49b1a99 100644 --- a/src/interface/efi/efi_file.c +++ b/src/interface/efi/efi_file.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/interface/efi/efi_guid.c b/src/interface/efi/efi_guid.c index 135eeb881..c989aebfe 100644 --- a/src/interface/efi/efi_guid.c +++ b/src/interface/efi/efi_guid.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_hii.c b/src/interface/efi/efi_hii.c index 66f58affe..fd65ae122 100644 --- a/src/interface/efi/efi_hii.c +++ b/src/interface/efi/efi_hii.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_init.c b/src/interface/efi/efi_init.c index 69aea0d50..ac62ea747 100644 --- a/src/interface/efi/efi_init.c +++ b/src/interface/efi/efi_init.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_local.c b/src/interface/efi/efi_local.c index 4564470fc..58a5f689f 100644 --- a/src/interface/efi/efi_local.c +++ b/src/interface/efi/efi_local.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_nap.c b/src/interface/efi/efi_nap.c index 2bb47627f..9d97dae6e 100644 --- a/src/interface/efi/efi_nap.c +++ b/src/interface/efi/efi_nap.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_null.c b/src/interface/efi/efi_null.c index d0f0428cc..fb9ee1780 100644 --- a/src/interface/efi/efi_null.c +++ b/src/interface/efi/efi_null.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_open.c b/src/interface/efi/efi_open.c index 8f8af4ea0..679d1946e 100644 --- a/src/interface/efi/efi_open.c +++ b/src/interface/efi/efi_open.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/interface/efi/efi_path.c b/src/interface/efi/efi_path.c index dd0df67e5..37558c36e 100644 --- a/src/interface/efi/efi_path.c +++ b/src/interface/efi/efi_path.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_pci.c b/src/interface/efi/efi_pci.c index f4853c234..4bf3977c5 100644 --- a/src/interface/efi/efi_pci.c +++ b/src/interface/efi/efi_pci.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_pxe.c b/src/interface/efi/efi_pxe.c index 4ba057019..2d1a6fd73 100644 --- a/src/interface/efi/efi_pxe.c +++ b/src/interface/efi/efi_pxe.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_reboot.c b/src/interface/efi/efi_reboot.c index 7ed9f5c84..cc35ef7ad 100644 --- a/src/interface/efi/efi_reboot.c +++ b/src/interface/efi/efi_reboot.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/interface/efi/efi_service.c b/src/interface/efi/efi_service.c index f10733b24..4e2f2e951 100644 --- a/src/interface/efi/efi_service.c +++ b/src/interface/efi/efi_service.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/interface/efi/efi_settings.c b/src/interface/efi/efi_settings.c index 5ddbe12f1..95fe2c03c 100644 --- a/src/interface/efi/efi_settings.c +++ b/src/interface/efi/efi_settings.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/interface/efi/efi_shim.c b/src/interface/efi/efi_shim.c index 4bb6df79f..553cb2721 100644 --- a/src/interface/efi/efi_shim.c +++ b/src/interface/efi/efi_shim.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include @@ -40,6 +41,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * Require use of a third party loader binary diff --git a/src/interface/efi/efi_smbios.c b/src/interface/efi/efi_smbios.c index 5d0e69d6b..c10ba1440 100644 --- a/src/interface/efi/efi_smbios.c +++ b/src/interface/efi/efi_smbios.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_snp.c b/src/interface/efi/efi_snp.c index 86ad87bde..dad8b33df 100644 --- a/src/interface/efi/efi_snp.c +++ b/src/interface/efi/efi_snp.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_snp_hii.c b/src/interface/efi/efi_snp_hii.c index 8b65c8a78..25287673a 100644 --- a/src/interface/efi/efi_snp_hii.c +++ b/src/interface/efi/efi_snp_hii.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/interface/efi/efi_strings.c b/src/interface/efi/efi_strings.c index 765b23ca6..3dae22e41 100644 --- a/src/interface/efi/efi_strings.c +++ b/src/interface/efi/efi_strings.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_table.c b/src/interface/efi/efi_table.c index 3c3f35a4b..da5966a13 100644 --- a/src/interface/efi/efi_table.c +++ b/src/interface/efi/efi_table.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_time.c b/src/interface/efi/efi_time.c index 983a0ef5c..a4c77da20 100644 --- a/src/interface/efi/efi_time.c +++ b/src/interface/efi/efi_time.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_timer.c b/src/interface/efi/efi_timer.c index 6427eb1d8..ffb899c86 100644 --- a/src/interface/efi/efi_timer.c +++ b/src/interface/efi/efi_timer.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_umalloc.c b/src/interface/efi/efi_umalloc.c index 419d9b294..257b27bec 100644 --- a/src/interface/efi/efi_umalloc.c +++ b/src/interface/efi/efi_umalloc.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_utils.c b/src/interface/efi/efi_utils.c index 51da06172..a7008afd4 100644 --- a/src/interface/efi/efi_utils.c +++ b/src/interface/efi/efi_utils.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_veto.c b/src/interface/efi/efi_veto.c index da585db60..788515dd1 100644 --- a/src/interface/efi/efi_veto.c +++ b/src/interface/efi/efi_veto.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_watchdog.c b/src/interface/efi/efi_watchdog.c index dcc9a5668..5e4eb626c 100644 --- a/src/interface/efi/efi_watchdog.c +++ b/src/interface/efi/efi_watchdog.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/interface/efi/efi_wrap.c b/src/interface/efi/efi_wrap.c index 320a32f02..572d05aac 100644 --- a/src/interface/efi/efi_wrap.c +++ b/src/interface/efi/efi_wrap.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/interface/efi/efiprefix.c b/src/interface/efi/efiprefix.c index 64122185a..3c095afdc 100644 --- a/src/interface/efi/efiprefix.c +++ b/src/interface/efi/efiprefix.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/smbios/smbios.c b/src/interface/smbios/smbios.c index 3a1a98b17..a23d9bfa2 100644 --- a/src/interface/smbios/smbios.c +++ b/src/interface/smbios/smbios.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/smbios/smbios_settings.c b/src/interface/smbios/smbios_settings.c index 6358a4709..d0ef49d5f 100644 --- a/src/interface/smbios/smbios_settings.c +++ b/src/interface/smbios/smbios_settings.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/aoe.c b/src/net/aoe.c index b484bdd33..edeb81867 100644 --- a/src/net/aoe.c +++ b/src/net/aoe.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/arp.c b/src/net/arp.c index c9b4109a9..2bf3c12ec 100644 --- a/src/net/arp.c +++ b/src/net/arp.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/dhcpopts.c b/src/net/dhcpopts.c index cdb632b46..844a94d62 100644 --- a/src/net/dhcpopts.c +++ b/src/net/dhcpopts.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/dhcppkt.c b/src/net/dhcppkt.c index 4e64f85e4..a9b454695 100644 --- a/src/net/dhcppkt.c +++ b/src/net/dhcppkt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/eap.c b/src/net/eap.c index 87327d723..040566b57 100644 --- a/src/net/eap.c +++ b/src/net/eap.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/eap_md5.c b/src/net/eap_md5.c index 0664174f9..1e263c8ec 100644 --- a/src/net/eap_md5.c +++ b/src/net/eap_md5.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/eapol.c b/src/net/eapol.c index 0c573d198..d83d63386 100644 --- a/src/net/eapol.c +++ b/src/net/eapol.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/eth_slow.c b/src/net/eth_slow.c index 1103a49f3..fb4e0d972 100644 --- a/src/net/eth_slow.c +++ b/src/net/eth_slow.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/ethernet.c b/src/net/ethernet.c index 3fcdafe6d..60219b98f 100644 --- a/src/net/ethernet.c +++ b/src/net/ethernet.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/fakedhcp.c b/src/net/fakedhcp.c index 009b12c56..0020d8225 100644 --- a/src/net/fakedhcp.c +++ b/src/net/fakedhcp.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/fragment.c b/src/net/fragment.c index 781b9bc60..4976167ed 100644 --- a/src/net/fragment.c +++ b/src/net/fragment.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/icmp.c b/src/net/icmp.c index 5371277e4..740b42440 100644 --- a/src/net/icmp.c +++ b/src/net/icmp.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/icmpv4.c b/src/net/icmpv4.c index 0858ff37f..ffcc4b375 100644 --- a/src/net/icmpv4.c +++ b/src/net/icmpv4.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/icmpv6.c b/src/net/icmpv6.c index 8555aaf0b..5331b81e8 100644 --- a/src/net/icmpv6.c +++ b/src/net/icmpv6.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/iobpad.c b/src/net/iobpad.c index 936b4bde4..6366efb5e 100644 --- a/src/net/iobpad.c +++ b/src/net/iobpad.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/net/ipv4.c b/src/net/ipv4.c index 21abfccec..f3dd44384 100644 --- a/src/net/ipv4.c +++ b/src/net/ipv4.c @@ -49,6 +49,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /* Unique IP datagram identification number (high byte) */ static uint8_t next_ident_high = 0; diff --git a/src/net/ipv6.c b/src/net/ipv6.c index b12d6577e..7e908dd2a 100644 --- a/src/net/ipv6.c +++ b/src/net/ipv6.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/lldp.c b/src/net/lldp.c index 2b707c874..d0e990f23 100644 --- a/src/net/lldp.c +++ b/src/net/lldp.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/net/ndp.c b/src/net/ndp.c index 3c555f4a3..6d96270c1 100644 --- a/src/net/ndp.c +++ b/src/net/ndp.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/neighbour.c b/src/net/neighbour.c index ac79041e3..fa8fba5cd 100644 --- a/src/net/neighbour.c +++ b/src/net/neighbour.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/netdev_settings.c b/src/net/netdev_settings.c index 90b804c6c..8bc8ce57b 100644 --- a/src/net/netdev_settings.c +++ b/src/net/netdev_settings.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/netdevice.c b/src/net/netdevice.c index c89585708..0af916ff5 100644 --- a/src/net/netdevice.c +++ b/src/net/netdevice.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/nullnet.c b/src/net/nullnet.c index 2948b38c0..c665b203a 100644 --- a/src/net/nullnet.c +++ b/src/net/nullnet.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/retry.c b/src/net/retry.c index 734567be5..c13ecb6b1 100644 --- a/src/net/retry.c +++ b/src/net/retry.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/socket.c b/src/net/socket.c index 2009ab237..6fed73128 100644 --- a/src/net/socket.c +++ b/src/net/socket.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/stp.c b/src/net/stp.c index 3d78400af..d1b0d4862 100644 --- a/src/net/stp.c +++ b/src/net/stp.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/tcp.c b/src/net/tcp.c index 2e52cf480..f08db5250 100644 --- a/src/net/tcp.c +++ b/src/net/tcp.c @@ -28,6 +28,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** A TCP connection */ struct tcp_connection { diff --git a/src/net/tcp/http.c b/src/net/tcp/http.c index b000ed80f..16cfd035e 100644 --- a/src/net/tcp/http.c +++ b/src/net/tcp/http.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/net/tcp/httpauth.c b/src/net/tcp/httpauth.c index 2c57e3d48..d682c5f8f 100644 --- a/src/net/tcp/httpauth.c +++ b/src/net/tcp/httpauth.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/net/tcp/httpbasic.c b/src/net/tcp/httpbasic.c index 52a67063d..4dffc7e0f 100644 --- a/src/net/tcp/httpbasic.c +++ b/src/net/tcp/httpbasic.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/net/tcp/httpblock.c b/src/net/tcp/httpblock.c index 8eff1942c..14398869e 100644 --- a/src/net/tcp/httpblock.c +++ b/src/net/tcp/httpblock.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/net/tcp/httpconn.c b/src/net/tcp/httpconn.c index 538c4dcf6..4b99209f0 100644 --- a/src/net/tcp/httpconn.c +++ b/src/net/tcp/httpconn.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/net/tcp/httpcore.c b/src/net/tcp/httpcore.c index 8fee0421c..912bea407 100644 --- a/src/net/tcp/httpcore.c +++ b/src/net/tcp/httpcore.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/net/tcp/httpdigest.c b/src/net/tcp/httpdigest.c index 4074078c7..8ff6dbfa5 100644 --- a/src/net/tcp/httpdigest.c +++ b/src/net/tcp/httpdigest.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/net/tcp/iscsi.c b/src/net/tcp/iscsi.c index b7b33a51a..0d1f0f645 100644 --- a/src/net/tcp/iscsi.c +++ b/src/net/tcp/iscsi.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/tcpip.c b/src/net/tcpip.c index cc7d02005..5ed3d68a9 100644 --- a/src/net/tcpip.c +++ b/src/net/tcpip.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * Process a received TCP/IP packet diff --git a/src/net/udp.c b/src/net/udp.c index 2c0b343dc..41aba2fca 100644 --- a/src/net/udp.c +++ b/src/net/udp.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * A UDP connection diff --git a/src/net/udp/dhcp.c b/src/net/udp/dhcp.c index daa37b96b..59b7c663d 100644 --- a/src/net/udp/dhcp.c +++ b/src/net/udp/dhcp.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/udp/dhcpv6.c b/src/net/udp/dhcpv6.c index a49109894..43a569d6e 100644 --- a/src/net/udp/dhcpv6.c +++ b/src/net/udp/dhcpv6.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/udp/dns.c b/src/net/udp/dns.c index f46eeb5c8..3f534b99f 100644 --- a/src/net/udp/dns.c +++ b/src/net/udp/dns.c @@ -25,6 +25,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/udp/tftp.c b/src/net/udp/tftp.c index 2ee01862a..760af10e9 100644 --- a/src/net/udp/tftp.c +++ b/src/net/udp/tftp.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/vlan.c b/src/net/vlan.c index c61bb850e..f7697a9be 100644 --- a/src/net/vlan.c +++ b/src/net/vlan.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/autoboot.c b/src/usr/autoboot.c index 4b64ca82b..3d46e65e0 100644 --- a/src/usr/autoboot.c +++ b/src/usr/autoboot.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/dhcpmgmt.c b/src/usr/dhcpmgmt.c index dcb360b23..2a0a8c718 100644 --- a/src/usr/dhcpmgmt.c +++ b/src/usr/dhcpmgmt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/ifmgmt.c b/src/usr/ifmgmt.c index d87ffff27..80f350ee4 100644 --- a/src/usr/ifmgmt.c +++ b/src/usr/ifmgmt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/imgmgmt.c b/src/usr/imgmgmt.c index 65b52fd3a..bad056f0e 100644 --- a/src/usr/imgmgmt.c +++ b/src/usr/imgmgmt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/prompt.c b/src/usr/prompt.c index fca0a157c..ea233e2ed 100644 --- a/src/usr/prompt.c +++ b/src/usr/prompt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/usr/route.c b/src/usr/route.c index 690ba3b6b..77c68eeb3 100644 --- a/src/usr/route.c +++ b/src/usr/route.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/route_ipv4.c b/src/usr/route_ipv4.c index f79c0ad8f..21b0820da 100644 --- a/src/usr/route_ipv4.c +++ b/src/usr/route_ipv4.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/route_ipv6.c b/src/usr/route_ipv6.c index 9e94b4a15..9d773ec60 100644 --- a/src/usr/route_ipv6.c +++ b/src/usr/route_ipv6.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/shimmgmt.c b/src/usr/shimmgmt.c index 6ac1ac35e..fb063ad51 100644 --- a/src/usr/shimmgmt.c +++ b/src/usr/shimmgmt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/sync.c b/src/usr/sync.c index f599588ae..1e740bd4c 100644 --- a/src/usr/sync.c +++ b/src/usr/sync.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include -- cgit v1.2.3-55-g7522 From adcaaf9b93f9de14ba93bea54aecef103fe16b5f Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 14 Jan 2026 14:36:49 +0000 Subject: [build] Mark known reviewed files as permitted for UEFI Secure Boot Some past security reviews carried out for UEFI Secure Boot signing submissions have covered specific drivers or functional areas of iPXE. Mark all of the files comprising these areas as permitted for UEFI Secure Boot. Signed-off-by: Michael Brown --- src/arch/x86/core/cpuid_settings.c | 1 + src/arch/x86/core/rdrand.c | 1 + src/arch/x86/include/bits/bigint.h | 1 + src/arch/x86/include/bits/bitops.h | 1 + src/arch/x86/include/bits/xen.h | 1 + src/config/config_archive.c | 1 + src/config/config_asn1.c | 1 + src/config/config_certs.c | 1 + src/config/config_crypto.c | 1 + src/config/config_digest_cmd.c | 1 + src/config/config_entropy.c | 1 + src/config/config_fc.c | 1 + src/config/config_fdt.c | 1 + src/config/config_infiniband.c | 1 + src/config/config_pixbuf.c | 1 + src/config/config_usb.c | 1 + src/config/crypto.h | 1 + src/config/entropy.h | 1 + src/config/fdt.h | 1 + src/config/usb.h | 1 + src/core/acpi_settings.c | 1 + src/core/acpimac.c | 1 + src/core/ansicoldef.c | 1 + src/core/fbcon.c | 1 + src/core/fdt.c | 1 + src/core/isqrt.c | 1 + src/core/lineconsole.c | 1 + src/core/netbios.c | 1 + src/core/pinger.c | 1 + src/core/pixbuf.c | 1 + src/core/profile.c | 1 + src/crypto/aes.c | 1 + src/crypto/asn1.c | 1 + src/crypto/bigint.c | 1 + src/crypto/cbc.c | 1 + src/crypto/certstore.c | 1 + src/crypto/cms.c | 1 + src/crypto/crypto_null.c | 1 + src/crypto/deflate.c | 1 + src/crypto/dhe.c | 1 + src/crypto/drbg.c | 1 + src/crypto/ecb.c | 1 + src/crypto/ecdhe.c | 1 + src/crypto/ecdsa.c | 1 + src/crypto/entropy.c | 1 + src/crypto/gcm.c | 1 + src/crypto/hash_df.c | 1 + src/crypto/hmac.c | 1 + src/crypto/hmac_drbg.c | 1 + src/crypto/md4.c | 1 + src/crypto/mishmash/cmd_sha224.c | 1 + src/crypto/mishmash/cmd_sha256.c | 1 + src/crypto/mishmash/cmd_sha384.c | 1 + src/crypto/mishmash/cmd_sha512.c | 1 + src/crypto/mishmash/dhe_rsa_aes_cbc_sha1.c | 1 + src/crypto/mishmash/dhe_rsa_aes_cbc_sha256.c | 1 + src/crypto/mishmash/dhe_rsa_aes_gcm_sha256.c | 1 + src/crypto/mishmash/dhe_rsa_aes_gcm_sha384.c | 1 + src/crypto/mishmash/ecdhe_ecdsa_aes_cbc_sha1.c | 1 + src/crypto/mishmash/ecdhe_ecdsa_aes_cbc_sha256.c | 1 + src/crypto/mishmash/ecdhe_ecdsa_aes_cbc_sha384.c | 1 + src/crypto/mishmash/ecdhe_ecdsa_aes_gcm_sha256.c | 1 + src/crypto/mishmash/ecdhe_ecdsa_aes_gcm_sha384.c | 1 + src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha1.c | 1 + src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha256.c | 1 + src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha384.c | 1 + src/crypto/mishmash/ecdhe_rsa_aes_gcm_sha256.c | 1 + src/crypto/mishmash/ecdhe_rsa_aes_gcm_sha384.c | 1 + src/crypto/mishmash/ecdsa_sha224.c | 1 + src/crypto/mishmash/ecdsa_sha256.c | 1 + src/crypto/mishmash/ecdsa_sha384.c | 1 + src/crypto/mishmash/ecdsa_sha512.c | 1 + src/crypto/mishmash/oid_aes_cbc.c | 1 + src/crypto/mishmash/oid_aes_gcm.c | 1 + src/crypto/mishmash/oid_p256.c | 1 + src/crypto/mishmash/oid_p384.c | 1 + src/crypto/mishmash/oid_rsa.c | 1 + src/crypto/mishmash/oid_sha1.c | 1 + src/crypto/mishmash/oid_sha224.c | 1 + src/crypto/mishmash/oid_sha256.c | 1 + src/crypto/mishmash/oid_sha384.c | 1 + src/crypto/mishmash/oid_sha512.c | 1 + src/crypto/mishmash/oid_sha512_224.c | 1 + src/crypto/mishmash/oid_sha512_256.c | 1 + src/crypto/mishmash/oid_x25519.c | 1 + src/crypto/mishmash/rsa_aes_cbc_sha1.c | 1 + src/crypto/mishmash/rsa_aes_cbc_sha256.c | 1 + src/crypto/mishmash/rsa_aes_gcm_sha256.c | 1 + src/crypto/mishmash/rsa_aes_gcm_sha384.c | 1 + src/crypto/mishmash/rsa_sha1.c | 1 + src/crypto/mishmash/rsa_sha224.c | 1 + src/crypto/mishmash/rsa_sha256.c | 1 + src/crypto/mishmash/rsa_sha384.c | 1 + src/crypto/mishmash/rsa_sha512.c | 1 + src/crypto/ntlm.c | 1 + src/crypto/ocsp.c | 1 + src/crypto/p256.c | 1 + src/crypto/p384.c | 1 + src/crypto/privkey.c | 1 + src/crypto/random_nz.c | 1 + src/crypto/rbg.c | 1 + src/crypto/rootcert.c | 1 + src/crypto/rsa.c | 1 + src/crypto/sha1.c | 1 + src/crypto/sha224.c | 1 + src/crypto/sha256.c | 1 + src/crypto/sha384.c | 1 + src/crypto/sha512.c | 1 + src/crypto/sha512_224.c | 1 + src/crypto/sha512_256.c | 1 + src/crypto/weierstrass.c | 1 + src/crypto/x25519.c | 1 + src/crypto/x509.c | 1 + src/drivers/bus/cdc.c | 1 + src/drivers/bus/pcibackup.c | 1 + src/drivers/bus/pciextra.c | 1 + src/drivers/bus/pcimsix.c | 1 + src/drivers/bus/usb.c | 1 + src/drivers/bus/usb_settings.c | 1 + src/drivers/net/acm.c | 1 + src/drivers/net/acm.h | 1 + src/drivers/net/axge.c | 1 + src/drivers/net/axge.h | 1 + src/drivers/net/dm96xx.c | 1 + src/drivers/net/dm96xx.h | 1 + src/drivers/net/ecm.c | 1 + src/drivers/net/ecm.h | 1 + src/drivers/net/ice.c | 1 + src/drivers/net/ice.h | 1 + src/drivers/net/intel.c | 1 + src/drivers/net/intel.h | 1 + src/drivers/net/intelvf.c | 1 + src/drivers/net/intelvf.h | 1 + src/drivers/net/intelx.c | 1 + src/drivers/net/intelx.h | 1 + src/drivers/net/intelxl.c | 1 + src/drivers/net/intelxl.h | 1 + src/drivers/net/intelxlvf.c | 1 + src/drivers/net/intelxlvf.h | 1 + src/drivers/net/intelxvf.c | 1 + src/drivers/net/intelxvf.h | 1 + src/drivers/net/iphone.c | 1 + src/drivers/net/iphone.h | 1 + src/drivers/net/lan78xx.c | 1 + src/drivers/net/lan78xx.h | 1 + src/drivers/net/mii.c | 1 + src/drivers/net/ncm.c | 1 + src/drivers/net/ncm.h | 1 + src/drivers/net/netfront.c | 1 + src/drivers/net/netfront.h | 1 + src/drivers/net/smsc75xx.c | 1 + src/drivers/net/smsc75xx.h | 1 + src/drivers/net/smsc95xx.c | 1 + src/drivers/net/smsc95xx.h | 1 + src/drivers/net/smscusb.c | 1 + src/drivers/net/smscusb.h | 1 + src/drivers/net/vmxnet3.c | 1 + src/drivers/net/vmxnet3.h | 1 + src/drivers/usb/ehci.c | 1 + src/drivers/usb/ehci.h | 1 + src/drivers/usb/uhci.c | 1 + src/drivers/usb/uhci.h | 1 + src/drivers/usb/usbblk.c | 1 + src/drivers/usb/usbblk.h | 1 + src/drivers/usb/usbhub.c | 1 + src/drivers/usb/usbhub.h | 1 + src/drivers/usb/usbnet.c | 1 + src/drivers/usb/xhci.c | 1 + src/hci/commands/cert_cmd.c | 1 + src/hci/commands/console_cmd.c | 1 + src/hci/commands/digest_cmd.c | 1 + src/hci/commands/image_trust_cmd.c | 1 + src/hci/commands/ipstat_cmd.c | 1 + src/hci/commands/neighbour_cmd.c | 1 + src/hci/commands/nslookup_cmd.c | 1 + src/hci/commands/ntp_cmd.c | 1 + src/hci/commands/param_cmd.c | 1 + src/hci/commands/ping_cmd.c | 1 + src/hci/commands/poweroff_cmd.c | 1 + src/hci/commands/profstat_cmd.c | 1 + src/hci/commands/vlan_cmd.c | 1 + src/image/der.c | 1 + src/image/efi_siglist.c | 1 + src/image/pem.c | 1 + src/image/png.c | 1 + src/include/hci/digest_cmd.h | 1 + src/include/ipxe/acpimac.h | 1 + src/include/ipxe/aes.h | 1 + src/include/ipxe/bigint.h | 1 + src/include/ipxe/bitops.h | 1 + src/include/ipxe/cbc.h | 1 + src/include/ipxe/cdc.h | 1 + src/include/ipxe/certstore.h | 1 + src/include/ipxe/cms.h | 1 + src/include/ipxe/deflate.h | 1 + src/include/ipxe/der.h | 1 + src/include/ipxe/dhe.h | 1 + src/include/ipxe/drbg.h | 1 + src/include/ipxe/ecb.h | 1 + src/include/ipxe/ecdhe.h | 1 + src/include/ipxe/ecdsa.h | 1 + src/include/ipxe/efi/efi_siglist.h | 1 + src/include/ipxe/efi/efi_usb.h | 3 +++ src/include/ipxe/entropy.h | 1 + src/include/ipxe/fbcon.h | 1 + src/include/ipxe/fdt.h | 1 + src/include/ipxe/gcm.h | 1 + src/include/ipxe/hash_df.h | 1 + src/include/ipxe/hmac.h | 1 + src/include/ipxe/hmac_drbg.h | 1 + src/include/ipxe/isqrt.h | 1 + src/include/ipxe/lineconsole.h | 1 + src/include/ipxe/md4.h | 1 + src/include/ipxe/mii.h | 1 + src/include/ipxe/netbios.h | 1 + src/include/ipxe/ntp.h | 1 + src/include/ipxe/ocsp.h | 1 + src/include/ipxe/p256.h | 1 + src/include/ipxe/p384.h | 1 + src/include/ipxe/pccrc.h | 1 + src/include/ipxe/pccrd.h | 1 + src/include/ipxe/pccrr.h | 1 + src/include/ipxe/pcibackup.h | 1 + src/include/ipxe/pcimsix.h | 1 + src/include/ipxe/peerblk.h | 1 + src/include/ipxe/peerdisc.h | 1 + src/include/ipxe/peermux.h | 1 + src/include/ipxe/pem.h | 1 + src/include/ipxe/pinger.h | 1 + src/include/ipxe/pixbuf.h | 1 + src/include/ipxe/png.h | 1 + src/include/ipxe/privkey.h | 1 + src/include/ipxe/random_nz.h | 1 + src/include/ipxe/rbg.h | 1 + src/include/ipxe/rndis.h | 1 + src/include/ipxe/rootcert.h | 1 + src/include/ipxe/rsa.h | 1 + src/include/ipxe/sha1.h | 1 + src/include/ipxe/sha256.h | 1 + src/include/ipxe/sha512.h | 1 + src/include/ipxe/syslog.h | 1 + src/include/ipxe/tls.h | 1 + src/include/ipxe/usbnet.h | 1 + src/include/ipxe/validator.h | 1 + src/include/ipxe/weierstrass.h | 1 + src/include/ipxe/x25519.h | 1 + src/include/ipxe/x509.h | 1 + src/include/ipxe/xen.h | 1 + src/include/ipxe/xenbus.h | 1 + src/include/ipxe/xenevent.h | 1 + src/include/ipxe/xengrant.h | 1 + src/include/ipxe/xenstore.h | 1 + src/include/ipxe/xhci.h | 1 + src/include/mii.h | 1 + src/include/usr/certmgmt.h | 1 + src/include/usr/imgtrust.h | 1 + src/include/usr/ipstat.h | 1 + src/include/usr/neighmgmt.h | 1 + src/include/usr/nslookup.h | 1 + src/include/usr/ntpmgmt.h | 1 + src/include/usr/pingmgmt.h | 1 + src/include/usr/profstat.h | 1 + src/include/xen/arch-x86/xen-x86_64.h | 1 + src/include/xen/arch-x86/xen.h | 1 + src/include/xen/event_channel.h | 1 + src/include/xen/grant_table.h | 1 + src/include/xen/io/netif.h | 1 + src/include/xen/io/ring.h | 1 + src/include/xen/io/xenbus.h | 1 + src/include/xen/io/xs_wire.h | 1 + src/include/xen/xen-compat.h | 1 + src/include/xen/xen.h | 1 + src/interface/efi/efi_cacert.c | 1 + src/interface/efi/efi_entropy.c | 1 + src/interface/efi/efi_fbcon.c | 1 + src/interface/efi/efi_fdt.c | 1 + src/interface/efi/efi_rng.c | 1 + src/interface/efi/efi_usb.c | 1 + src/interface/xen/xenbus.c | 1 + src/interface/xen/xengrant.c | 1 + src/interface/xen/xenstore.c | 1 + src/net/pccrc.c | 1 + src/net/pccrd.c | 1 + src/net/peerblk.c | 1 + src/net/peerdisc.c | 1 + src/net/peerdist.c | 1 + src/net/peermux.c | 1 + src/net/ping.c | 1 + src/net/rndis.c | 1 + src/net/tcp/httpntlm.c | 1 + src/net/tcp/https.c | 1 + src/net/tcp/syslogs.c | 1 + src/net/tls.c | 1 + src/net/udp/ntp.c | 1 + src/net/udp/syslog.c | 1 + src/net/validator.c | 1 + src/usr/certmgmt.c | 1 + src/usr/imgtrust.c | 1 + src/usr/ipstat.c | 1 + src/usr/neighmgmt.c | 1 + src/usr/nslookup.c | 1 + src/usr/ntpmgmt.c | 1 + src/usr/pingmgmt.c | 1 + src/usr/profstat.c | 1 + 304 files changed, 306 insertions(+) (limited to 'src/drivers') diff --git a/src/arch/x86/core/cpuid_settings.c b/src/arch/x86/core/cpuid_settings.c index 44d38debc..ef0164069 100644 --- a/src/arch/x86/core/cpuid_settings.c +++ b/src/arch/x86/core/cpuid_settings.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/arch/x86/core/rdrand.c b/src/arch/x86/core/rdrand.c index 850ab1f11..05fc3cd23 100644 --- a/src/arch/x86/core/rdrand.c +++ b/src/arch/x86/core/rdrand.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/arch/x86/include/bits/bigint.h b/src/arch/x86/include/bits/bigint.h index c6f097a34..21cffa0cf 100644 --- a/src/arch/x86/include/bits/bigint.h +++ b/src/arch/x86/include/bits/bigint.h @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/arch/x86/include/bits/bitops.h b/src/arch/x86/include/bits/bitops.h index f697b8c8f..cdbc3b0a2 100644 --- a/src/arch/x86/include/bits/bitops.h +++ b/src/arch/x86/include/bits/bitops.h @@ -14,6 +14,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/arch/x86/include/bits/xen.h b/src/arch/x86/include/bits/xen.h index 3433cea1f..313bec254 100644 --- a/src/arch/x86/include/bits/xen.h +++ b/src/arch/x86/include/bits/xen.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /* Hypercall registers */ #ifdef __x86_64__ diff --git a/src/config/config_archive.c b/src/config/config_archive.c index 746fc7e44..71c883dcc 100644 --- a/src/config/config_archive.c +++ b/src/config/config_archive.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/config_asn1.c b/src/config/config_asn1.c index 107f99c1d..ad3e95b96 100644 --- a/src/config/config_asn1.c +++ b/src/config/config_asn1.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/config_certs.c b/src/config/config_certs.c index a325d132c..ad5a2f708 100644 --- a/src/config/config_certs.c +++ b/src/config/config_certs.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/config_crypto.c b/src/config/config_crypto.c index 4bba147e5..724b95d02 100644 --- a/src/config/config_crypto.c +++ b/src/config/config_crypto.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/config_digest_cmd.c b/src/config/config_digest_cmd.c index 5a8752ae1..1c4d8dca1 100644 --- a/src/config/config_digest_cmd.c +++ b/src/config/config_digest_cmd.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/config_entropy.c b/src/config/config_entropy.c index 92aa97884..494b19f20 100644 --- a/src/config/config_entropy.c +++ b/src/config/config_entropy.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/config_fc.c b/src/config/config_fc.c index 33fc9462a..3aea9b080 100644 --- a/src/config/config_fc.c +++ b/src/config/config_fc.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/config_fdt.c b/src/config/config_fdt.c index e8d425933..a6fb6f332 100644 --- a/src/config/config_fdt.c +++ b/src/config/config_fdt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/config_infiniband.c b/src/config/config_infiniband.c index 4da8fe219..9e0826169 100644 --- a/src/config/config_infiniband.c +++ b/src/config/config_infiniband.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/config_pixbuf.c b/src/config/config_pixbuf.c index f8ff59daf..b2dbd869a 100644 --- a/src/config/config_pixbuf.c +++ b/src/config/config_pixbuf.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/config_usb.c b/src/config/config_usb.c index 10dec221a..b3fd412e9 100644 --- a/src/config/config_usb.c +++ b/src/config/config_usb.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/config/crypto.h b/src/config/crypto.h index a0774390b..e28ba2777 100644 --- a/src/config/crypto.h +++ b/src/config/crypto.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** Minimum TLS version */ #define TLS_VERSION_MIN TLS_VERSION_TLS_1_1 diff --git a/src/config/entropy.h b/src/config/entropy.h index c79060fd5..db180c61a 100644 --- a/src/config/entropy.h +++ b/src/config/entropy.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/fdt.h b/src/config/fdt.h index 4d13e0535..7f3d39768 100644 --- a/src/config/fdt.h +++ b/src/config/fdt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/usb.h b/src/config/usb.h index 4252ec229..09e0b82e6 100644 --- a/src/config/usb.h +++ b/src/config/usb.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/core/acpi_settings.c b/src/core/acpi_settings.c index 63f271855..8dc2a7fd8 100644 --- a/src/core/acpi_settings.c +++ b/src/core/acpi_settings.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/core/acpimac.c b/src/core/acpimac.c index 11ac3243e..04fd98836 100644 --- a/src/core/acpimac.c +++ b/src/core/acpimac.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/ansicoldef.c b/src/core/ansicoldef.c index 6d8598e11..4555c4e36 100644 --- a/src/core/ansicoldef.c +++ b/src/core/ansicoldef.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/fbcon.c b/src/core/fbcon.c index ef158aec7..e07605470 100644 --- a/src/core/fbcon.c +++ b/src/core/fbcon.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/core/fdt.c b/src/core/fdt.c index 08adb166e..8ac781b05 100644 --- a/src/core/fdt.c +++ b/src/core/fdt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/isqrt.c b/src/core/isqrt.c index c4d0571e7..b553c0935 100644 --- a/src/core/isqrt.c +++ b/src/core/isqrt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/core/lineconsole.c b/src/core/lineconsole.c index 0a72d1434..25eae39dd 100644 --- a/src/core/lineconsole.c +++ b/src/core/lineconsole.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/core/netbios.c b/src/core/netbios.c index 0d4e2086f..299e0d599 100644 --- a/src/core/netbios.c +++ b/src/core/netbios.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/core/pinger.c b/src/core/pinger.c index 0ff7bb9f2..bbfa83f8d 100644 --- a/src/core/pinger.c +++ b/src/core/pinger.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/pixbuf.c b/src/core/pixbuf.c index 506a28c38..df187f93d 100644 --- a/src/core/pixbuf.c +++ b/src/core/pixbuf.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/core/profile.c b/src/core/profile.c index 3655108ea..27d481d45 100644 --- a/src/core/profile.c +++ b/src/core/profile.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/aes.c b/src/crypto/aes.c index 5200e7760..fe6ccb222 100644 --- a/src/crypto/aes.c +++ b/src/crypto/aes.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/asn1.c b/src/crypto/asn1.c index dd0b954e1..98d5b638f 100644 --- a/src/crypto/asn1.c +++ b/src/crypto/asn1.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/bigint.c b/src/crypto/bigint.c index 9ccd9ff88..5d2f7b560 100644 --- a/src/crypto/bigint.c +++ b/src/crypto/bigint.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/cbc.c b/src/crypto/cbc.c index 0ba17ee48..ddba7abd9 100644 --- a/src/crypto/cbc.c +++ b/src/crypto/cbc.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/certstore.c b/src/crypto/certstore.c index aad874297..8472a2eed 100644 --- a/src/crypto/certstore.c +++ b/src/crypto/certstore.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/cms.c b/src/crypto/cms.c index 7775e581b..4c0f3f5a6 100644 --- a/src/crypto/cms.c +++ b/src/crypto/cms.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/crypto_null.c b/src/crypto/crypto_null.c index e80f2707f..8637987b1 100644 --- a/src/crypto/crypto_null.c +++ b/src/crypto/crypto_null.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/crypto/deflate.c b/src/crypto/deflate.c index 5d0101184..1d54749e0 100644 --- a/src/crypto/deflate.c +++ b/src/crypto/deflate.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/dhe.c b/src/crypto/dhe.c index a249f9b40..2785a500b 100644 --- a/src/crypto/dhe.c +++ b/src/crypto/dhe.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/drbg.c b/src/crypto/drbg.c index a3366e806..c4dc7646d 100644 --- a/src/crypto/drbg.c +++ b/src/crypto/drbg.c @@ -34,6 +34,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/ecb.c b/src/crypto/ecb.c index 3c9cf340c..73eef09c2 100644 --- a/src/crypto/ecb.c +++ b/src/crypto/ecb.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/ecdhe.c b/src/crypto/ecdhe.c index 6c86b1c90..016253457 100644 --- a/src/crypto/ecdhe.c +++ b/src/crypto/ecdhe.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/ecdsa.c b/src/crypto/ecdsa.c index cd06d5578..6f10a1a0f 100644 --- a/src/crypto/ecdsa.c +++ b/src/crypto/ecdsa.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/entropy.c b/src/crypto/entropy.c index 419007159..ac0e92c42 100644 --- a/src/crypto/entropy.c +++ b/src/crypto/entropy.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/gcm.c b/src/crypto/gcm.c index b93925d07..b9c9d3a39 100644 --- a/src/crypto/gcm.c +++ b/src/crypto/gcm.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/hash_df.c b/src/crypto/hash_df.c index dc0dc0ce8..ec4bcaebc 100644 --- a/src/crypto/hash_df.c +++ b/src/crypto/hash_df.c @@ -34,6 +34,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/hmac.c b/src/crypto/hmac.c index 7109bbf6a..ed4cefaad 100644 --- a/src/crypto/hmac.c +++ b/src/crypto/hmac.c @@ -34,6 +34,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/crypto/hmac_drbg.c b/src/crypto/hmac_drbg.c index 57bde4d1d..bd831e239 100644 --- a/src/crypto/hmac_drbg.c +++ b/src/crypto/hmac_drbg.c @@ -34,6 +34,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/md4.c b/src/crypto/md4.c index dcd86a428..a9184aa57 100644 --- a/src/crypto/md4.c +++ b/src/crypto/md4.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/mishmash/cmd_sha224.c b/src/crypto/mishmash/cmd_sha224.c index 3975a37c5..fd8095937 100644 --- a/src/crypto/mishmash/cmd_sha224.c +++ b/src/crypto/mishmash/cmd_sha224.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/cmd_sha256.c b/src/crypto/mishmash/cmd_sha256.c index 8076e8dbf..259ae3eac 100644 --- a/src/crypto/mishmash/cmd_sha256.c +++ b/src/crypto/mishmash/cmd_sha256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/cmd_sha384.c b/src/crypto/mishmash/cmd_sha384.c index ed7265ab9..c31154d24 100644 --- a/src/crypto/mishmash/cmd_sha384.c +++ b/src/crypto/mishmash/cmd_sha384.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/cmd_sha512.c b/src/crypto/mishmash/cmd_sha512.c index 96b8ade88..b6207f86d 100644 --- a/src/crypto/mishmash/cmd_sha512.c +++ b/src/crypto/mishmash/cmd_sha512.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/dhe_rsa_aes_cbc_sha1.c b/src/crypto/mishmash/dhe_rsa_aes_cbc_sha1.c index 05e409f7a..ec2155001 100644 --- a/src/crypto/mishmash/dhe_rsa_aes_cbc_sha1.c +++ b/src/crypto/mishmash/dhe_rsa_aes_cbc_sha1.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/dhe_rsa_aes_cbc_sha256.c b/src/crypto/mishmash/dhe_rsa_aes_cbc_sha256.c index 6ce428642..4e6226e87 100644 --- a/src/crypto/mishmash/dhe_rsa_aes_cbc_sha256.c +++ b/src/crypto/mishmash/dhe_rsa_aes_cbc_sha256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/dhe_rsa_aes_gcm_sha256.c b/src/crypto/mishmash/dhe_rsa_aes_gcm_sha256.c index dc5cad9f8..6bbe4d00d 100644 --- a/src/crypto/mishmash/dhe_rsa_aes_gcm_sha256.c +++ b/src/crypto/mishmash/dhe_rsa_aes_gcm_sha256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/dhe_rsa_aes_gcm_sha384.c b/src/crypto/mishmash/dhe_rsa_aes_gcm_sha384.c index 0448255f3..336feb195 100644 --- a/src/crypto/mishmash/dhe_rsa_aes_gcm_sha384.c +++ b/src/crypto/mishmash/dhe_rsa_aes_gcm_sha384.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/ecdhe_ecdsa_aes_cbc_sha1.c b/src/crypto/mishmash/ecdhe_ecdsa_aes_cbc_sha1.c index d6eaf8b0a..0d9fcd15d 100644 --- a/src/crypto/mishmash/ecdhe_ecdsa_aes_cbc_sha1.c +++ b/src/crypto/mishmash/ecdhe_ecdsa_aes_cbc_sha1.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/ecdhe_ecdsa_aes_cbc_sha256.c b/src/crypto/mishmash/ecdhe_ecdsa_aes_cbc_sha256.c index 0fc486fbd..4b7cf1620 100644 --- a/src/crypto/mishmash/ecdhe_ecdsa_aes_cbc_sha256.c +++ b/src/crypto/mishmash/ecdhe_ecdsa_aes_cbc_sha256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/ecdhe_ecdsa_aes_cbc_sha384.c b/src/crypto/mishmash/ecdhe_ecdsa_aes_cbc_sha384.c index 5106c18ce..85373911a 100644 --- a/src/crypto/mishmash/ecdhe_ecdsa_aes_cbc_sha384.c +++ b/src/crypto/mishmash/ecdhe_ecdsa_aes_cbc_sha384.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/ecdhe_ecdsa_aes_gcm_sha256.c b/src/crypto/mishmash/ecdhe_ecdsa_aes_gcm_sha256.c index 2b118e7a5..5aeb2f3d9 100644 --- a/src/crypto/mishmash/ecdhe_ecdsa_aes_gcm_sha256.c +++ b/src/crypto/mishmash/ecdhe_ecdsa_aes_gcm_sha256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/ecdhe_ecdsa_aes_gcm_sha384.c b/src/crypto/mishmash/ecdhe_ecdsa_aes_gcm_sha384.c index b4946df88..3dc6149d7 100644 --- a/src/crypto/mishmash/ecdhe_ecdsa_aes_gcm_sha384.c +++ b/src/crypto/mishmash/ecdhe_ecdsa_aes_gcm_sha384.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha1.c b/src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha1.c index c23f65cc0..46b42ac1e 100644 --- a/src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha1.c +++ b/src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha1.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha256.c b/src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha256.c index 431e2e304..dd524ec78 100644 --- a/src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha256.c +++ b/src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha384.c b/src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha384.c index c52976809..7524d1ccc 100644 --- a/src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha384.c +++ b/src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha384.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/ecdhe_rsa_aes_gcm_sha256.c b/src/crypto/mishmash/ecdhe_rsa_aes_gcm_sha256.c index 4f4e38c69..978be2a4c 100644 --- a/src/crypto/mishmash/ecdhe_rsa_aes_gcm_sha256.c +++ b/src/crypto/mishmash/ecdhe_rsa_aes_gcm_sha256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/ecdhe_rsa_aes_gcm_sha384.c b/src/crypto/mishmash/ecdhe_rsa_aes_gcm_sha384.c index 0bc7c305f..5ca6f0457 100644 --- a/src/crypto/mishmash/ecdhe_rsa_aes_gcm_sha384.c +++ b/src/crypto/mishmash/ecdhe_rsa_aes_gcm_sha384.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/ecdsa_sha224.c b/src/crypto/mishmash/ecdsa_sha224.c index ab42658cb..92aa881cd 100644 --- a/src/crypto/mishmash/ecdsa_sha224.c +++ b/src/crypto/mishmash/ecdsa_sha224.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/ecdsa_sha256.c b/src/crypto/mishmash/ecdsa_sha256.c index 12cbec80c..025d6ec73 100644 --- a/src/crypto/mishmash/ecdsa_sha256.c +++ b/src/crypto/mishmash/ecdsa_sha256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/ecdsa_sha384.c b/src/crypto/mishmash/ecdsa_sha384.c index b52621311..d7a0ca5d6 100644 --- a/src/crypto/mishmash/ecdsa_sha384.c +++ b/src/crypto/mishmash/ecdsa_sha384.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/ecdsa_sha512.c b/src/crypto/mishmash/ecdsa_sha512.c index 420c685e7..15391abf2 100644 --- a/src/crypto/mishmash/ecdsa_sha512.c +++ b/src/crypto/mishmash/ecdsa_sha512.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/oid_aes_cbc.c b/src/crypto/mishmash/oid_aes_cbc.c index b5f716574..d5b81541a 100644 --- a/src/crypto/mishmash/oid_aes_cbc.c +++ b/src/crypto/mishmash/oid_aes_cbc.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/oid_aes_gcm.c b/src/crypto/mishmash/oid_aes_gcm.c index af1432d8e..6be1a132d 100644 --- a/src/crypto/mishmash/oid_aes_gcm.c +++ b/src/crypto/mishmash/oid_aes_gcm.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/oid_p256.c b/src/crypto/mishmash/oid_p256.c index d473df09f..81ae1d11e 100644 --- a/src/crypto/mishmash/oid_p256.c +++ b/src/crypto/mishmash/oid_p256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/oid_p384.c b/src/crypto/mishmash/oid_p384.c index 968fb45c1..a7d36aee4 100644 --- a/src/crypto/mishmash/oid_p384.c +++ b/src/crypto/mishmash/oid_p384.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/oid_rsa.c b/src/crypto/mishmash/oid_rsa.c index 582022628..02bb59edb 100644 --- a/src/crypto/mishmash/oid_rsa.c +++ b/src/crypto/mishmash/oid_rsa.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/oid_sha1.c b/src/crypto/mishmash/oid_sha1.c index 5dae6d27c..5ddd2aba8 100644 --- a/src/crypto/mishmash/oid_sha1.c +++ b/src/crypto/mishmash/oid_sha1.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/oid_sha224.c b/src/crypto/mishmash/oid_sha224.c index ee7ed22e4..6658bda56 100644 --- a/src/crypto/mishmash/oid_sha224.c +++ b/src/crypto/mishmash/oid_sha224.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/oid_sha256.c b/src/crypto/mishmash/oid_sha256.c index 963fddb63..8da40a70b 100644 --- a/src/crypto/mishmash/oid_sha256.c +++ b/src/crypto/mishmash/oid_sha256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/oid_sha384.c b/src/crypto/mishmash/oid_sha384.c index 81ff48bbf..57c1ab53b 100644 --- a/src/crypto/mishmash/oid_sha384.c +++ b/src/crypto/mishmash/oid_sha384.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/oid_sha512.c b/src/crypto/mishmash/oid_sha512.c index 78bae48b4..73d7cb78f 100644 --- a/src/crypto/mishmash/oid_sha512.c +++ b/src/crypto/mishmash/oid_sha512.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/oid_sha512_224.c b/src/crypto/mishmash/oid_sha512_224.c index 6f61f9cac..a6291097b 100644 --- a/src/crypto/mishmash/oid_sha512_224.c +++ b/src/crypto/mishmash/oid_sha512_224.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/oid_sha512_256.c b/src/crypto/mishmash/oid_sha512_256.c index bce4762e4..d36199372 100644 --- a/src/crypto/mishmash/oid_sha512_256.c +++ b/src/crypto/mishmash/oid_sha512_256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/oid_x25519.c b/src/crypto/mishmash/oid_x25519.c index 30b7905ea..2907eb461 100644 --- a/src/crypto/mishmash/oid_x25519.c +++ b/src/crypto/mishmash/oid_x25519.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/rsa_aes_cbc_sha1.c b/src/crypto/mishmash/rsa_aes_cbc_sha1.c index 0862fb5ac..35f5f6eb7 100644 --- a/src/crypto/mishmash/rsa_aes_cbc_sha1.c +++ b/src/crypto/mishmash/rsa_aes_cbc_sha1.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/rsa_aes_cbc_sha256.c b/src/crypto/mishmash/rsa_aes_cbc_sha256.c index e5928db82..22705df7e 100644 --- a/src/crypto/mishmash/rsa_aes_cbc_sha256.c +++ b/src/crypto/mishmash/rsa_aes_cbc_sha256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/rsa_aes_gcm_sha256.c b/src/crypto/mishmash/rsa_aes_gcm_sha256.c index b18bbd844..d3fd00f1e 100644 --- a/src/crypto/mishmash/rsa_aes_gcm_sha256.c +++ b/src/crypto/mishmash/rsa_aes_gcm_sha256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/rsa_aes_gcm_sha384.c b/src/crypto/mishmash/rsa_aes_gcm_sha384.c index 06558aaed..908db086a 100644 --- a/src/crypto/mishmash/rsa_aes_gcm_sha384.c +++ b/src/crypto/mishmash/rsa_aes_gcm_sha384.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/rsa_sha1.c b/src/crypto/mishmash/rsa_sha1.c index 264f871f1..8907ac08a 100644 --- a/src/crypto/mishmash/rsa_sha1.c +++ b/src/crypto/mishmash/rsa_sha1.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/rsa_sha224.c b/src/crypto/mishmash/rsa_sha224.c index 1465a033d..b676d41f3 100644 --- a/src/crypto/mishmash/rsa_sha224.c +++ b/src/crypto/mishmash/rsa_sha224.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/rsa_sha256.c b/src/crypto/mishmash/rsa_sha256.c index 7283c3e29..8a6a7a5cf 100644 --- a/src/crypto/mishmash/rsa_sha256.c +++ b/src/crypto/mishmash/rsa_sha256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/rsa_sha384.c b/src/crypto/mishmash/rsa_sha384.c index 6f8c29b29..cc1878bd4 100644 --- a/src/crypto/mishmash/rsa_sha384.c +++ b/src/crypto/mishmash/rsa_sha384.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/rsa_sha512.c b/src/crypto/mishmash/rsa_sha512.c index bb4463a5a..9c995e1c8 100644 --- a/src/crypto/mishmash/rsa_sha512.c +++ b/src/crypto/mishmash/rsa_sha512.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/ntlm.c b/src/crypto/ntlm.c index fb120f8db..f9ce51bde 100644 --- a/src/crypto/ntlm.c +++ b/src/crypto/ntlm.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/ocsp.c b/src/crypto/ocsp.c index 1712d614e..5d6acb605 100644 --- a/src/crypto/ocsp.c +++ b/src/crypto/ocsp.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/p256.c b/src/crypto/p256.c index 2ba66e72c..a513555b3 100644 --- a/src/crypto/p256.c +++ b/src/crypto/p256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/p384.c b/src/crypto/p384.c index a53a9ce9d..bdd23d460 100644 --- a/src/crypto/p384.c +++ b/src/crypto/p384.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/privkey.c b/src/crypto/privkey.c index cbe8deff3..c67a4400b 100644 --- a/src/crypto/privkey.c +++ b/src/crypto/privkey.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/random_nz.c b/src/crypto/random_nz.c index 5fe576e05..96b12359c 100644 --- a/src/crypto/random_nz.c +++ b/src/crypto/random_nz.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/rbg.c b/src/crypto/rbg.c index 5e1c25f53..17914542e 100644 --- a/src/crypto/rbg.c +++ b/src/crypto/rbg.c @@ -34,6 +34,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/rootcert.c b/src/crypto/rootcert.c index b198c1d95..6eb08256a 100644 --- a/src/crypto/rootcert.c +++ b/src/crypto/rootcert.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/rsa.c b/src/crypto/rsa.c index 9c0982cf6..be055d881 100644 --- a/src/crypto/rsa.c +++ b/src/crypto/rsa.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/sha1.c b/src/crypto/sha1.c index 8eecc75b3..023becec6 100644 --- a/src/crypto/sha1.c +++ b/src/crypto/sha1.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/sha224.c b/src/crypto/sha224.c index e54a0abb0..7e0cfd34e 100644 --- a/src/crypto/sha224.c +++ b/src/crypto/sha224.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/sha256.c b/src/crypto/sha256.c index c30300eb4..742393612 100644 --- a/src/crypto/sha256.c +++ b/src/crypto/sha256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/sha384.c b/src/crypto/sha384.c index f1af6fc6f..3e5e98a31 100644 --- a/src/crypto/sha384.c +++ b/src/crypto/sha384.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/sha512.c b/src/crypto/sha512.c index d7d44b284..724cb71a5 100644 --- a/src/crypto/sha512.c +++ b/src/crypto/sha512.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/sha512_224.c b/src/crypto/sha512_224.c index b6728726c..3b256a3b9 100644 --- a/src/crypto/sha512_224.c +++ b/src/crypto/sha512_224.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/sha512_256.c b/src/crypto/sha512_256.c index 8163631e0..04df3f5bc 100644 --- a/src/crypto/sha512_256.c +++ b/src/crypto/sha512_256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/weierstrass.c b/src/crypto/weierstrass.c index bb9b50bf8..a64626c85 100644 --- a/src/crypto/weierstrass.c +++ b/src/crypto/weierstrass.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/x25519.c b/src/crypto/x25519.c index 4b4c489da..95c42ea13 100644 --- a/src/crypto/x25519.c +++ b/src/crypto/x25519.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/x509.c b/src/crypto/x509.c index 1206e4023..6a3fe423b 100644 --- a/src/crypto/x509.c +++ b/src/crypto/x509.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/bus/cdc.c b/src/drivers/bus/cdc.c index 373a03072..c3a2a450b 100644 --- a/src/drivers/bus/cdc.c +++ b/src/drivers/bus/cdc.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/bus/pcibackup.c b/src/drivers/bus/pcibackup.c index 4cf126f83..81fcb7e05 100644 --- a/src/drivers/bus/pcibackup.c +++ b/src/drivers/bus/pcibackup.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/bus/pciextra.c b/src/drivers/bus/pciextra.c index 3654a2d1c..f769a3172 100644 --- a/src/drivers/bus/pciextra.c +++ b/src/drivers/bus/pciextra.c @@ -1,4 +1,5 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/bus/pcimsix.c b/src/drivers/bus/pcimsix.c index f55488ad7..008c1c22f 100644 --- a/src/drivers/bus/pcimsix.c +++ b/src/drivers/bus/pcimsix.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/bus/usb.c b/src/drivers/bus/usb.c index b3b361b0d..30c288df9 100644 --- a/src/drivers/bus/usb.c +++ b/src/drivers/bus/usb.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/bus/usb_settings.c b/src/drivers/bus/usb_settings.c index bb01f34d5..e34c79126 100644 --- a/src/drivers/bus/usb_settings.c +++ b/src/drivers/bus/usb_settings.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/acm.c b/src/drivers/net/acm.c index 16dab4be8..0cb2713b2 100644 --- a/src/drivers/net/acm.c +++ b/src/drivers/net/acm.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/acm.h b/src/drivers/net/acm.h index d4944967b..3f10f0fa2 100644 --- a/src/drivers/net/acm.h +++ b/src/drivers/net/acm.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/axge.c b/src/drivers/net/axge.c index fb274d24f..922c94d91 100644 --- a/src/drivers/net/axge.c +++ b/src/drivers/net/axge.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/axge.h b/src/drivers/net/axge.h index e22e0ec47..c30ca5950 100644 --- a/src/drivers/net/axge.h +++ b/src/drivers/net/axge.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/dm96xx.c b/src/drivers/net/dm96xx.c index 61b957be9..193980a40 100644 --- a/src/drivers/net/dm96xx.c +++ b/src/drivers/net/dm96xx.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/dm96xx.h b/src/drivers/net/dm96xx.h index 43a1a4e30..33e404e17 100644 --- a/src/drivers/net/dm96xx.h +++ b/src/drivers/net/dm96xx.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/ecm.c b/src/drivers/net/ecm.c index 7b3e92b9b..9a13b68a5 100644 --- a/src/drivers/net/ecm.c +++ b/src/drivers/net/ecm.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/ecm.h b/src/drivers/net/ecm.h index a7d03cf94..d77b0c64f 100644 --- a/src/drivers/net/ecm.h +++ b/src/drivers/net/ecm.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/ice.c b/src/drivers/net/ice.c index b5d66f1bb..1abc8ecd0 100644 --- a/src/drivers/net/ice.c +++ b/src/drivers/net/ice.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/ice.h b/src/drivers/net/ice.h index 26291a7a1..c4b7b95be 100644 --- a/src/drivers/net/ice.h +++ b/src/drivers/net/ice.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include "intelxl.h" diff --git a/src/drivers/net/intel.c b/src/drivers/net/intel.c index 845ba3e7f..57c0151a4 100644 --- a/src/drivers/net/intel.c +++ b/src/drivers/net/intel.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/intel.h b/src/drivers/net/intel.h index 29cf3a7d8..bfd250f00 100644 --- a/src/drivers/net/intel.h +++ b/src/drivers/net/intel.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/intelvf.c b/src/drivers/net/intelvf.c index 0d48b4178..e99b67626 100644 --- a/src/drivers/net/intelvf.c +++ b/src/drivers/net/intelvf.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/intelvf.h b/src/drivers/net/intelvf.h index ffb18e040..378f9b075 100644 --- a/src/drivers/net/intelvf.h +++ b/src/drivers/net/intelvf.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include "intel.h" diff --git a/src/drivers/net/intelx.c b/src/drivers/net/intelx.c index 343d01374..ceb687e4f 100644 --- a/src/drivers/net/intelx.c +++ b/src/drivers/net/intelx.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/intelx.h b/src/drivers/net/intelx.h index d7f3b78e8..d68f50082 100644 --- a/src/drivers/net/intelx.h +++ b/src/drivers/net/intelx.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/intelxl.c b/src/drivers/net/intelxl.c index 76b9ff48f..f8d325ead 100644 --- a/src/drivers/net/intelxl.c +++ b/src/drivers/net/intelxl.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/intelxl.h b/src/drivers/net/intelxl.h index d23acf96e..4481300d3 100644 --- a/src/drivers/net/intelxl.h +++ b/src/drivers/net/intelxl.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/intelxlvf.c b/src/drivers/net/intelxlvf.c index 083195513..ab4df4c47 100644 --- a/src/drivers/net/intelxlvf.c +++ b/src/drivers/net/intelxlvf.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/intelxlvf.h b/src/drivers/net/intelxlvf.h index 95ddf9474..63ed0b202 100644 --- a/src/drivers/net/intelxlvf.h +++ b/src/drivers/net/intelxlvf.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include "intelxl.h" diff --git a/src/drivers/net/intelxvf.c b/src/drivers/net/intelxvf.c index d50bac698..70ed8efe3 100644 --- a/src/drivers/net/intelxvf.c +++ b/src/drivers/net/intelxvf.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/intelxvf.h b/src/drivers/net/intelxvf.h index 4663272aa..1dac98699 100644 --- a/src/drivers/net/intelxvf.h +++ b/src/drivers/net/intelxvf.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include "intelvf.h" diff --git a/src/drivers/net/iphone.c b/src/drivers/net/iphone.c index 11f763553..b58017560 100644 --- a/src/drivers/net/iphone.c +++ b/src/drivers/net/iphone.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/iphone.h b/src/drivers/net/iphone.h index 2db6da7bd..3448af37f 100644 --- a/src/drivers/net/iphone.h +++ b/src/drivers/net/iphone.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/lan78xx.c b/src/drivers/net/lan78xx.c index 3f4f21b60..32333e787 100644 --- a/src/drivers/net/lan78xx.c +++ b/src/drivers/net/lan78xx.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/lan78xx.h b/src/drivers/net/lan78xx.h index 39422aec0..ea6d7ce52 100644 --- a/src/drivers/net/lan78xx.h +++ b/src/drivers/net/lan78xx.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include "smscusb.h" #include "smsc75xx.h" diff --git a/src/drivers/net/mii.c b/src/drivers/net/mii.c index 87605f0cb..85749b941 100644 --- a/src/drivers/net/mii.c +++ b/src/drivers/net/mii.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/ncm.c b/src/drivers/net/ncm.c index 2c0f91e21..48f9856b0 100644 --- a/src/drivers/net/ncm.c +++ b/src/drivers/net/ncm.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/ncm.h b/src/drivers/net/ncm.h index 6b0d21cdb..53e96cf72 100644 --- a/src/drivers/net/ncm.h +++ b/src/drivers/net/ncm.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/netfront.c b/src/drivers/net/netfront.c index 12713c5b4..ba6a20002 100644 --- a/src/drivers/net/netfront.c +++ b/src/drivers/net/netfront.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/netfront.h b/src/drivers/net/netfront.h index de16d5291..0520a0b2a 100644 --- a/src/drivers/net/netfront.h +++ b/src/drivers/net/netfront.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/smsc75xx.c b/src/drivers/net/smsc75xx.c index 861669edf..8ae65e42a 100644 --- a/src/drivers/net/smsc75xx.c +++ b/src/drivers/net/smsc75xx.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/smsc75xx.h b/src/drivers/net/smsc75xx.h index 72339df03..51330993d 100644 --- a/src/drivers/net/smsc75xx.h +++ b/src/drivers/net/smsc75xx.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include "smscusb.h" diff --git a/src/drivers/net/smsc95xx.c b/src/drivers/net/smsc95xx.c index 0210e9240..16086b33e 100644 --- a/src/drivers/net/smsc95xx.c +++ b/src/drivers/net/smsc95xx.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/smsc95xx.h b/src/drivers/net/smsc95xx.h index 0cdf38248..0cb6ab4c7 100644 --- a/src/drivers/net/smsc95xx.h +++ b/src/drivers/net/smsc95xx.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include "smscusb.h" diff --git a/src/drivers/net/smscusb.c b/src/drivers/net/smscusb.c index 93007e386..486b5953b 100644 --- a/src/drivers/net/smscusb.c +++ b/src/drivers/net/smscusb.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/smscusb.h b/src/drivers/net/smscusb.h index e866bb747..e4ad61915 100644 --- a/src/drivers/net/smscusb.h +++ b/src/drivers/net/smscusb.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/vmxnet3.c b/src/drivers/net/vmxnet3.c index 2cc6738f2..95e4f79c2 100644 --- a/src/drivers/net/vmxnet3.c +++ b/src/drivers/net/vmxnet3.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/vmxnet3.h b/src/drivers/net/vmxnet3.h index 5e1e0cb6e..b6c3bc50d 100644 --- a/src/drivers/net/vmxnet3.h +++ b/src/drivers/net/vmxnet3.h @@ -25,6 +25,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/drivers/usb/ehci.c b/src/drivers/usb/ehci.c index 77022a47d..9f9d94175 100644 --- a/src/drivers/usb/ehci.c +++ b/src/drivers/usb/ehci.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/usb/ehci.h b/src/drivers/usb/ehci.h index 42e282e92..a0166bc63 100644 --- a/src/drivers/usb/ehci.h +++ b/src/drivers/usb/ehci.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/usb/uhci.c b/src/drivers/usb/uhci.c index 47474bdc7..2c70a11bd 100644 --- a/src/drivers/usb/uhci.c +++ b/src/drivers/usb/uhci.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/usb/uhci.h b/src/drivers/usb/uhci.h index ba4c28f7e..629f6ae3b 100644 --- a/src/drivers/usb/uhci.h +++ b/src/drivers/usb/uhci.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/usb/usbblk.c b/src/drivers/usb/usbblk.c index cb377efb0..b42c70645 100644 --- a/src/drivers/usb/usbblk.c +++ b/src/drivers/usb/usbblk.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/usb/usbblk.h b/src/drivers/usb/usbblk.h index 65d0705e3..1fa0ebad8 100644 --- a/src/drivers/usb/usbblk.h +++ b/src/drivers/usb/usbblk.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/usb/usbhub.c b/src/drivers/usb/usbhub.c index 28d6cb33d..1d7b03e77 100644 --- a/src/drivers/usb/usbhub.c +++ b/src/drivers/usb/usbhub.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/usb/usbhub.h b/src/drivers/usb/usbhub.h index a5f123acc..9768b81a9 100644 --- a/src/drivers/usb/usbhub.h +++ b/src/drivers/usb/usbhub.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/usb/usbnet.c b/src/drivers/usb/usbnet.c index 0fac00b56..e773ab882 100644 --- a/src/drivers/usb/usbnet.c +++ b/src/drivers/usb/usbnet.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/usb/xhci.c b/src/drivers/usb/xhci.c index 440c347c8..f812ed338 100644 --- a/src/drivers/usb/xhci.c +++ b/src/drivers/usb/xhci.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/commands/cert_cmd.c b/src/hci/commands/cert_cmd.c index efa4c3c12..ebd9a25cd 100644 --- a/src/hci/commands/cert_cmd.c +++ b/src/hci/commands/cert_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/commands/console_cmd.c b/src/hci/commands/console_cmd.c index 19d19ef1b..29347bbba 100644 --- a/src/hci/commands/console_cmd.c +++ b/src/hci/commands/console_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/hci/commands/digest_cmd.c b/src/hci/commands/digest_cmd.c index a7f43f69e..4d7da0385 100644 --- a/src/hci/commands/digest_cmd.c +++ b/src/hci/commands/digest_cmd.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/commands/image_trust_cmd.c b/src/hci/commands/image_trust_cmd.c index 314aa0998..a8ec5784e 100644 --- a/src/hci/commands/image_trust_cmd.c +++ b/src/hci/commands/image_trust_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/commands/ipstat_cmd.c b/src/hci/commands/ipstat_cmd.c index 488016e3a..fc454c57d 100644 --- a/src/hci/commands/ipstat_cmd.c +++ b/src/hci/commands/ipstat_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/commands/neighbour_cmd.c b/src/hci/commands/neighbour_cmd.c index 520d5aa06..870024ee0 100644 --- a/src/hci/commands/neighbour_cmd.c +++ b/src/hci/commands/neighbour_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/hci/commands/nslookup_cmd.c b/src/hci/commands/nslookup_cmd.c index dc9d61704..b13127dd4 100644 --- a/src/hci/commands/nslookup_cmd.c +++ b/src/hci/commands/nslookup_cmd.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/commands/ntp_cmd.c b/src/hci/commands/ntp_cmd.c index fed126f4c..d7604227a 100644 --- a/src/hci/commands/ntp_cmd.c +++ b/src/hci/commands/ntp_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/commands/param_cmd.c b/src/hci/commands/param_cmd.c index 0924df597..ed57c5eaa 100644 --- a/src/hci/commands/param_cmd.c +++ b/src/hci/commands/param_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/hci/commands/ping_cmd.c b/src/hci/commands/ping_cmd.c index 4e86ae1c0..e132fb457 100644 --- a/src/hci/commands/ping_cmd.c +++ b/src/hci/commands/ping_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/commands/poweroff_cmd.c b/src/hci/commands/poweroff_cmd.c index 2c6f1369a..63aeb3d5b 100644 --- a/src/hci/commands/poweroff_cmd.c +++ b/src/hci/commands/poweroff_cmd.c @@ -29,6 +29,7 @@ #include FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/hci/commands/profstat_cmd.c b/src/hci/commands/profstat_cmd.c index da01068b2..3303ebcf3 100644 --- a/src/hci/commands/profstat_cmd.c +++ b/src/hci/commands/profstat_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/commands/vlan_cmd.c b/src/hci/commands/vlan_cmd.c index 636e5927f..69aef9f3c 100644 --- a/src/hci/commands/vlan_cmd.c +++ b/src/hci/commands/vlan_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/image/der.c b/src/image/der.c index 67117d43b..ace106b84 100644 --- a/src/image/der.c +++ b/src/image/der.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/image/efi_siglist.c b/src/image/efi_siglist.c index b264ac558..71d597006 100644 --- a/src/image/efi_siglist.c +++ b/src/image/efi_siglist.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/image/pem.c b/src/image/pem.c index caff822ad..0fea5fbea 100644 --- a/src/image/pem.c +++ b/src/image/pem.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/image/png.c b/src/image/png.c index b7864f770..ab279eae5 100644 --- a/src/image/png.c +++ b/src/image/png.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/hci/digest_cmd.h b/src/include/hci/digest_cmd.h index 0986f775e..9cb4fde1a 100644 --- a/src/include/hci/digest_cmd.h +++ b/src/include/hci/digest_cmd.h @@ -25,6 +25,7 @@ #define _DIGEST_CMD_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/acpimac.h b/src/include/ipxe/acpimac.h index de673eb28..074165a92 100644 --- a/src/include/ipxe/acpimac.h +++ b/src/include/ipxe/acpimac.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern int acpi_mac ( uint8_t *hw_addr ); diff --git a/src/include/ipxe/aes.h b/src/include/ipxe/aes.h index 8731de6ba..1c0024ccb 100644 --- a/src/include/ipxe/aes.h +++ b/src/include/ipxe/aes.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/bigint.h b/src/include/ipxe/bigint.h index 9eab89d25..9c31f4540 100644 --- a/src/include/ipxe/bigint.h +++ b/src/include/ipxe/bigint.h @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/bitops.h b/src/include/ipxe/bitops.h index 7366cd9f1..59a4fb442 100644 --- a/src/include/ipxe/bitops.h +++ b/src/include/ipxe/bitops.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/cbc.h b/src/include/ipxe/cbc.h index f02e51937..154fc5666 100644 --- a/src/include/ipxe/cbc.h +++ b/src/include/ipxe/cbc.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/cdc.h b/src/include/ipxe/cdc.h index b8b4a59d9..a61fe61ea 100644 --- a/src/include/ipxe/cdc.h +++ b/src/include/ipxe/cdc.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/certstore.h b/src/include/ipxe/certstore.h index e276d6792..293f6dec7 100644 --- a/src/include/ipxe/certstore.h +++ b/src/include/ipxe/certstore.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/cms.h b/src/include/ipxe/cms.h index 084cd81f8..d2e426c5c 100644 --- a/src/include/ipxe/cms.h +++ b/src/include/ipxe/cms.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/deflate.h b/src/include/ipxe/deflate.h index 67292d77e..7e5ae01b9 100644 --- a/src/include/ipxe/deflate.h +++ b/src/include/ipxe/deflate.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/der.h b/src/include/ipxe/der.h index 512bc0853..17e96405e 100644 --- a/src/include/ipxe/der.h +++ b/src/include/ipxe/der.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/dhe.h b/src/include/ipxe/dhe.h index 3cd24a880..f89e7bd02 100644 --- a/src/include/ipxe/dhe.h +++ b/src/include/ipxe/dhe.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/drbg.h b/src/include/ipxe/drbg.h index ed2b3757a..0512f0833 100644 --- a/src/include/ipxe/drbg.h +++ b/src/include/ipxe/drbg.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/ecb.h b/src/include/ipxe/ecb.h index db22d996d..c29602fca 100644 --- a/src/include/ipxe/ecb.h +++ b/src/include/ipxe/ecb.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/ecdhe.h b/src/include/ipxe/ecdhe.h index 36fc0a1ee..c6575678c 100644 --- a/src/include/ipxe/ecdhe.h +++ b/src/include/ipxe/ecdhe.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/ecdsa.h b/src/include/ipxe/ecdsa.h index f55af3973..fdf8c6159 100644 --- a/src/include/ipxe/ecdsa.h +++ b/src/include/ipxe/ecdsa.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/efi/efi_siglist.h b/src/include/ipxe/efi/efi_siglist.h index cbc835dc0..f2a2fcfd0 100644 --- a/src/include/ipxe/efi/efi_siglist.h +++ b/src/include/ipxe/efi/efi_siglist.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/efi/efi_usb.h b/src/include/ipxe/efi/efi_usb.h index 06baff529..cbcef0e52 100644 --- a/src/include/ipxe/efi/efi_usb.h +++ b/src/include/ipxe/efi/efi_usb.h @@ -7,6 +7,9 @@ * */ +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); + #include #include #include diff --git a/src/include/ipxe/entropy.h b/src/include/ipxe/entropy.h index 82bb11826..8ec8f1047 100644 --- a/src/include/ipxe/entropy.h +++ b/src/include/ipxe/entropy.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/fbcon.h b/src/include/ipxe/fbcon.h index 5233b4d0e..75cda3390 100644 --- a/src/include/ipxe/fbcon.h +++ b/src/include/ipxe/fbcon.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/fdt.h b/src/include/ipxe/fdt.h index e951aea59..6aa078ff6 100644 --- a/src/include/ipxe/fdt.h +++ b/src/include/ipxe/fdt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/gcm.h b/src/include/ipxe/gcm.h index 2c785a977..5635a1031 100644 --- a/src/include/ipxe/gcm.h +++ b/src/include/ipxe/gcm.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/hash_df.h b/src/include/ipxe/hash_df.h index e57682446..61c3420ce 100644 --- a/src/include/ipxe/hash_df.h +++ b/src/include/ipxe/hash_df.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/hmac.h b/src/include/ipxe/hmac.h index cf9d08677..12312c540 100644 --- a/src/include/ipxe/hmac.h +++ b/src/include/ipxe/hmac.h @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/hmac_drbg.h b/src/include/ipxe/hmac_drbg.h index a0f22da75..e9113807c 100644 --- a/src/include/ipxe/hmac_drbg.h +++ b/src/include/ipxe/hmac_drbg.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/isqrt.h b/src/include/ipxe/isqrt.h index 68255d1bc..4308cebd2 100644 --- a/src/include/ipxe/isqrt.h +++ b/src/include/ipxe/isqrt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern unsigned long isqrt ( unsigned long value ); diff --git a/src/include/ipxe/lineconsole.h b/src/include/ipxe/lineconsole.h index 31117e73c..b02822dcf 100644 --- a/src/include/ipxe/lineconsole.h +++ b/src/include/ipxe/lineconsole.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/md4.h b/src/include/ipxe/md4.h index 9f6cb8a5f..60512993b 100644 --- a/src/include/ipxe/md4.h +++ b/src/include/ipxe/md4.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/mii.h b/src/include/ipxe/mii.h index 89fc92a4a..061aeb24e 100644 --- a/src/include/ipxe/mii.h +++ b/src/include/ipxe/mii.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/netbios.h b/src/include/ipxe/netbios.h index c11552556..80f791738 100644 --- a/src/include/ipxe/netbios.h +++ b/src/include/ipxe/netbios.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern const char * netbios_domain ( char **username ); diff --git a/src/include/ipxe/ntp.h b/src/include/ipxe/ntp.h index f5b3d2326..7f83c6d4f 100644 --- a/src/include/ipxe/ntp.h +++ b/src/include/ipxe/ntp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/ocsp.h b/src/include/ipxe/ocsp.h index a973f6f5e..9302506f8 100644 --- a/src/include/ipxe/ocsp.h +++ b/src/include/ipxe/ocsp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/p256.h b/src/include/ipxe/p256.h index 0c4e81665..14d429cd9 100644 --- a/src/include/ipxe/p256.h +++ b/src/include/ipxe/p256.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/p384.h b/src/include/ipxe/p384.h index f4631b5f2..2fdd8d13c 100644 --- a/src/include/ipxe/p384.h +++ b/src/include/ipxe/p384.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/pccrc.h b/src/include/ipxe/pccrc.h index bec2b271a..6d0e3f194 100644 --- a/src/include/ipxe/pccrc.h +++ b/src/include/ipxe/pccrc.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/pccrd.h b/src/include/ipxe/pccrd.h index 3daa92f29..453ef666d 100644 --- a/src/include/ipxe/pccrd.h +++ b/src/include/ipxe/pccrd.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** PeerDist discovery port */ #define PEERDIST_DISCOVERY_PORT 3702 diff --git a/src/include/ipxe/pccrr.h b/src/include/ipxe/pccrr.h index 4de94fda3..92522d0b7 100644 --- a/src/include/ipxe/pccrr.h +++ b/src/include/ipxe/pccrr.h @@ -10,6 +10,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/pcibackup.h b/src/include/ipxe/pcibackup.h index e5249df99..a25421d7d 100644 --- a/src/include/ipxe/pcibackup.h +++ b/src/include/ipxe/pcibackup.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/pcimsix.h b/src/include/ipxe/pcimsix.h index b40c6c357..a7a6899a9 100644 --- a/src/include/ipxe/pcimsix.h +++ b/src/include/ipxe/pcimsix.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/peerblk.h b/src/include/ipxe/peerblk.h index f16f207b0..596c78b57 100644 --- a/src/include/ipxe/peerblk.h +++ b/src/include/ipxe/peerblk.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/peerdisc.h b/src/include/ipxe/peerdisc.h index 45d592e76..9a8f13ecf 100644 --- a/src/include/ipxe/peerdisc.h +++ b/src/include/ipxe/peerdisc.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/peermux.h b/src/include/ipxe/peermux.h index 54acbfec9..849488d0a 100644 --- a/src/include/ipxe/peermux.h +++ b/src/include/ipxe/peermux.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/pem.h b/src/include/ipxe/pem.h index d9ca017d5..95c55408b 100644 --- a/src/include/ipxe/pem.h +++ b/src/include/ipxe/pem.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/pinger.h b/src/include/ipxe/pinger.h index 227f002dc..ade12ec12 100644 --- a/src/include/ipxe/pinger.h +++ b/src/include/ipxe/pinger.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/pixbuf.h b/src/include/ipxe/pixbuf.h index 47ea0065e..e2cbcdca7 100644 --- a/src/include/ipxe/pixbuf.h +++ b/src/include/ipxe/pixbuf.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/png.h b/src/include/ipxe/png.h index 3505eefc8..31cac0534 100644 --- a/src/include/ipxe/png.h +++ b/src/include/ipxe/png.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/privkey.h b/src/include/ipxe/privkey.h index a65cf6106..56f23143e 100644 --- a/src/include/ipxe/privkey.h +++ b/src/include/ipxe/privkey.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/random_nz.h b/src/include/ipxe/random_nz.h index 4c433fa38..2de1a1a33 100644 --- a/src/include/ipxe/random_nz.h +++ b/src/include/ipxe/random_nz.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/rbg.h b/src/include/ipxe/rbg.h index 4bf3055d1..0b65a408c 100644 --- a/src/include/ipxe/rbg.h +++ b/src/include/ipxe/rbg.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/rndis.h b/src/include/ipxe/rndis.h index e8ece1e85..bd64eddfe 100644 --- a/src/include/ipxe/rndis.h +++ b/src/include/ipxe/rndis.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/rootcert.h b/src/include/ipxe/rootcert.h index d1a69723d..f07c612ff 100644 --- a/src/include/ipxe/rootcert.h +++ b/src/include/ipxe/rootcert.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/rsa.h b/src/include/ipxe/rsa.h index e36a75edf..c5ae919ae 100644 --- a/src/include/ipxe/rsa.h +++ b/src/include/ipxe/rsa.h @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/sha1.h b/src/include/ipxe/sha1.h index 9cbbebdee..33b07ecc3 100644 --- a/src/include/ipxe/sha1.h +++ b/src/include/ipxe/sha1.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/sha256.h b/src/include/ipxe/sha256.h index f226ad07b..e8a81b889 100644 --- a/src/include/ipxe/sha256.h +++ b/src/include/ipxe/sha256.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/sha512.h b/src/include/ipxe/sha512.h index 82a9e4e69..74cdb413c 100644 --- a/src/include/ipxe/sha512.h +++ b/src/include/ipxe/sha512.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/syslog.h b/src/include/ipxe/syslog.h index 138440d66..67f45fdb4 100644 --- a/src/include/ipxe/syslog.h +++ b/src/include/ipxe/syslog.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/tls.h b/src/include/ipxe/tls.h index 1a1d9c982..b4a92a044 100644 --- a/src/include/ipxe/tls.h +++ b/src/include/ipxe/tls.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/usbnet.h b/src/include/ipxe/usbnet.h index a7276eba5..937a26d9a 100644 --- a/src/include/ipxe/usbnet.h +++ b/src/include/ipxe/usbnet.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/validator.h b/src/include/ipxe/validator.h index 367e4045d..4d95766fa 100644 --- a/src/include/ipxe/validator.h +++ b/src/include/ipxe/validator.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/weierstrass.h b/src/include/ipxe/weierstrass.h index 15dd9ce03..ced99b4fc 100644 --- a/src/include/ipxe/weierstrass.h +++ b/src/include/ipxe/weierstrass.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/x25519.h b/src/include/ipxe/x25519.h index d570282c5..ef294f7b2 100644 --- a/src/include/ipxe/x25519.h +++ b/src/include/ipxe/x25519.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/x509.h b/src/include/ipxe/x509.h index 4903eb656..360e2b19a 100644 --- a/src/include/ipxe/x509.h +++ b/src/include/ipxe/x509.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/xen.h b/src/include/ipxe/xen.h index 382901ff3..9ddfcdf81 100644 --- a/src/include/ipxe/xen.h +++ b/src/include/ipxe/xen.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /* Define Xen interface version before including any Xen header files */ #define __XEN_INTERFACE_VERSION__ 0x00040400 diff --git a/src/include/ipxe/xenbus.h b/src/include/ipxe/xenbus.h index ec5782eed..d73f29781 100644 --- a/src/include/ipxe/xenbus.h +++ b/src/include/ipxe/xenbus.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/xenevent.h b/src/include/ipxe/xenevent.h index f0bd3465e..8be9e2b2f 100644 --- a/src/include/ipxe/xenevent.h +++ b/src/include/ipxe/xenevent.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/xengrant.h b/src/include/ipxe/xengrant.h index fcb7a7157..8af27f3e3 100644 --- a/src/include/ipxe/xengrant.h +++ b/src/include/ipxe/xengrant.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/xenstore.h b/src/include/ipxe/xenstore.h index 892640755..c2079cec5 100644 --- a/src/include/ipxe/xenstore.h +++ b/src/include/ipxe/xenstore.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/xhci.h b/src/include/ipxe/xhci.h index 586d5d320..2f5c256a0 100644 --- a/src/include/ipxe/xhci.h +++ b/src/include/ipxe/xhci.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/mii.h b/src/include/mii.h index 515ba224d..9d6b2b3b7 100644 --- a/src/include/mii.h +++ b/src/include/mii.h @@ -12,6 +12,7 @@ */ FILE_LICENCE ( GPL2_ONLY ); +FILE_SECBOOT ( PERMITTED ); /* Generic MII registers. */ #define MII_BMCR 0x00 /* Basic mode control register */ diff --git a/src/include/usr/certmgmt.h b/src/include/usr/certmgmt.h index 4363b03e1..ff646236b 100644 --- a/src/include/usr/certmgmt.h +++ b/src/include/usr/certmgmt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/usr/imgtrust.h b/src/include/usr/imgtrust.h index 414e07a80..1e43f5d3d 100644 --- a/src/include/usr/imgtrust.h +++ b/src/include/usr/imgtrust.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/usr/ipstat.h b/src/include/usr/ipstat.h index 803254bcb..2399446eb 100644 --- a/src/include/usr/ipstat.h +++ b/src/include/usr/ipstat.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern void ipstat ( void ); diff --git a/src/include/usr/neighmgmt.h b/src/include/usr/neighmgmt.h index 06f03716e..5ed5829c4 100644 --- a/src/include/usr/neighmgmt.h +++ b/src/include/usr/neighmgmt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern void nstat ( void ); diff --git a/src/include/usr/nslookup.h b/src/include/usr/nslookup.h index d34649e9f..3b2bb504d 100644 --- a/src/include/usr/nslookup.h +++ b/src/include/usr/nslookup.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); extern int nslookup ( const char *name, const char *setting_name ); diff --git a/src/include/usr/ntpmgmt.h b/src/include/usr/ntpmgmt.h index 284e668e6..6d90ec749 100644 --- a/src/include/usr/ntpmgmt.h +++ b/src/include/usr/ntpmgmt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern int ntp ( const char *hostname ); diff --git a/src/include/usr/pingmgmt.h b/src/include/usr/pingmgmt.h index c7a8434be..d15a748d8 100644 --- a/src/include/usr/pingmgmt.h +++ b/src/include/usr/pingmgmt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/usr/profstat.h b/src/include/usr/profstat.h index b7812ca7f..c5d545a86 100644 --- a/src/include/usr/profstat.h +++ b/src/include/usr/profstat.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern void profstat ( void ); diff --git a/src/include/xen/arch-x86/xen-x86_64.h b/src/include/xen/arch-x86/xen-x86_64.h index 8287fd20f..618bf07d7 100644 --- a/src/include/xen/arch-x86/xen-x86_64.h +++ b/src/include/xen/arch-x86/xen-x86_64.h @@ -11,6 +11,7 @@ #define __XEN_PUBLIC_ARCH_X86_XEN_X86_64_H__ FILE_LICENCE ( MIT ); +FILE_SECBOOT ( PERMITTED ); /* * Hypercall interface: diff --git a/src/include/xen/arch-x86/xen.h b/src/include/xen/arch-x86/xen.h index 2b7afb2f4..7df850650 100644 --- a/src/include/xen/arch-x86/xen.h +++ b/src/include/xen/arch-x86/xen.h @@ -13,6 +13,7 @@ #define __XEN_PUBLIC_ARCH_X86_XEN_H__ FILE_LICENCE ( MIT ); +FILE_SECBOOT ( PERMITTED ); /* Structural guest handles introduced in 0x00030201. */ #if __XEN_INTERFACE_VERSION__ >= 0x00030201 diff --git a/src/include/xen/event_channel.h b/src/include/xen/event_channel.h index 0c3752723..a3145d76f 100644 --- a/src/include/xen/event_channel.h +++ b/src/include/xen/event_channel.h @@ -11,6 +11,7 @@ #define __XEN_PUBLIC_EVENT_CHANNEL_H__ FILE_LICENCE ( MIT ); +FILE_SECBOOT ( PERMITTED ); #include "xen.h" diff --git a/src/include/xen/grant_table.h b/src/include/xen/grant_table.h index f0ae17c41..141a17f56 100644 --- a/src/include/xen/grant_table.h +++ b/src/include/xen/grant_table.h @@ -12,6 +12,7 @@ #define __XEN_PUBLIC_GRANT_TABLE_H__ FILE_LICENCE ( MIT ); +FILE_SECBOOT ( PERMITTED ); #include "xen.h" diff --git a/src/include/xen/io/netif.h b/src/include/xen/io/netif.h index bec61ab3e..59887a80f 100644 --- a/src/include/xen/io/netif.h +++ b/src/include/xen/io/netif.h @@ -11,6 +11,7 @@ #define __XEN_PUBLIC_IO_NETIF_H__ FILE_LICENCE ( MIT ); +FILE_SECBOOT ( PERMITTED ); #include "ring.h" #include "../grant_table.h" diff --git a/src/include/xen/io/ring.h b/src/include/xen/io/ring.h index 41b50e2cf..3451bbb52 100644 --- a/src/include/xen/io/ring.h +++ b/src/include/xen/io/ring.h @@ -11,6 +11,7 @@ #define __XEN_PUBLIC_IO_RING_H__ FILE_LICENCE ( MIT ); +FILE_SECBOOT ( PERMITTED ); /* * When #include'ing this header, you need to provide the following diff --git a/src/include/xen/io/xenbus.h b/src/include/xen/io/xenbus.h index 473f538b8..3bf417c3a 100644 --- a/src/include/xen/io/xenbus.h +++ b/src/include/xen/io/xenbus.h @@ -11,6 +11,7 @@ #define _XEN_PUBLIC_IO_XENBUS_H FILE_LICENCE ( MIT ); +FILE_SECBOOT ( PERMITTED ); /* * The state of either end of the Xenbus, i.e. the current communication diff --git a/src/include/xen/io/xs_wire.h b/src/include/xen/io/xs_wire.h index cffd75cde..99dc91781 100644 --- a/src/include/xen/io/xs_wire.h +++ b/src/include/xen/io/xs_wire.h @@ -10,6 +10,7 @@ #define _XS_WIRE_H FILE_LICENCE ( MIT ); +FILE_SECBOOT ( PERMITTED ); enum xsd_sockmsg_type { diff --git a/src/include/xen/xen-compat.h b/src/include/xen/xen-compat.h index 8b2361807..8e4ed2434 100644 --- a/src/include/xen/xen-compat.h +++ b/src/include/xen/xen-compat.h @@ -11,6 +11,7 @@ #define __XEN_PUBLIC_XEN_COMPAT_H__ FILE_LICENCE ( MIT ); +FILE_SECBOOT ( PERMITTED ); #define __XEN_LATEST_INTERFACE_VERSION__ 0x00040e00 diff --git a/src/include/xen/xen.h b/src/include/xen/xen.h index c35008aa0..6d8192f8d 100644 --- a/src/include/xen/xen.h +++ b/src/include/xen/xen.h @@ -11,6 +11,7 @@ #define __XEN_PUBLIC_XEN_H__ FILE_LICENCE ( MIT ); +FILE_SECBOOT ( PERMITTED ); #include "xen-compat.h" diff --git a/src/interface/efi/efi_cacert.c b/src/interface/efi/efi_cacert.c index 64bb0bae2..3e941ddc5 100644 --- a/src/interface/efi/efi_cacert.c +++ b/src/interface/efi/efi_cacert.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/interface/efi/efi_entropy.c b/src/interface/efi/efi_entropy.c index cda1c3640..b6bd12ccc 100644 --- a/src/interface/efi/efi_entropy.c +++ b/src/interface/efi/efi_entropy.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_fbcon.c b/src/interface/efi/efi_fbcon.c index 9c5d7063d..3896fd4d1 100644 --- a/src/interface/efi/efi_fbcon.c +++ b/src/interface/efi/efi_fbcon.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/interface/efi/efi_fdt.c b/src/interface/efi/efi_fdt.c index 3c249693e..cd8580fcb 100644 --- a/src/interface/efi/efi_fdt.c +++ b/src/interface/efi/efi_fdt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_rng.c b/src/interface/efi/efi_rng.c index 058f0ee7d..66b37fe89 100644 --- a/src/interface/efi/efi_rng.c +++ b/src/interface/efi/efi_rng.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_usb.c b/src/interface/efi/efi_usb.c index b09272f58..a3b153c88 100644 --- a/src/interface/efi/efi_usb.c +++ b/src/interface/efi/efi_usb.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/xen/xenbus.c b/src/interface/xen/xenbus.c index 8b5ee0a0d..95bfdf7da 100644 --- a/src/interface/xen/xenbus.c +++ b/src/interface/xen/xenbus.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/xen/xengrant.c b/src/interface/xen/xengrant.c index 269cd5836..b0a15010b 100644 --- a/src/interface/xen/xengrant.c +++ b/src/interface/xen/xengrant.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/xen/xenstore.c b/src/interface/xen/xenstore.c index caeb4e934..a076cd046 100644 --- a/src/interface/xen/xenstore.c +++ b/src/interface/xen/xenstore.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/pccrc.c b/src/net/pccrc.c index 0db6e3cb5..4bf2f441e 100644 --- a/src/net/pccrc.c +++ b/src/net/pccrc.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/pccrd.c b/src/net/pccrd.c index 04b5dd86c..a7182c8ee 100644 --- a/src/net/pccrd.c +++ b/src/net/pccrd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/peerblk.c b/src/net/peerblk.c index 58b185102..6efd4ebf6 100644 --- a/src/net/peerblk.c +++ b/src/net/peerblk.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/peerdisc.c b/src/net/peerdisc.c index 86ff94a87..2ba733697 100644 --- a/src/net/peerdisc.c +++ b/src/net/peerdisc.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/peerdist.c b/src/net/peerdist.c index 3210ac0ec..8e0f5dc13 100644 --- a/src/net/peerdist.c +++ b/src/net/peerdist.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/peermux.c b/src/net/peermux.c index 5c814b03e..7160d1c43 100644 --- a/src/net/peermux.c +++ b/src/net/peermux.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/ping.c b/src/net/ping.c index f0729e159..5782813e1 100644 --- a/src/net/ping.c +++ b/src/net/ping.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/rndis.c b/src/net/rndis.c index a3b562bc2..f04bc775f 100644 --- a/src/net/rndis.c +++ b/src/net/rndis.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/net/tcp/httpntlm.c b/src/net/tcp/httpntlm.c index 25187bd19..a7e44d5f6 100644 --- a/src/net/tcp/httpntlm.c +++ b/src/net/tcp/httpntlm.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/net/tcp/https.c b/src/net/tcp/https.c index 85f1f124f..bccfafe15 100644 --- a/src/net/tcp/https.c +++ b/src/net/tcp/https.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/net/tcp/syslogs.c b/src/net/tcp/syslogs.c index 5676f3e3e..eff53ea94 100644 --- a/src/net/tcp/syslogs.c +++ b/src/net/tcp/syslogs.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/net/tls.c b/src/net/tls.c index 6140ca58a..4f8ea2692 100644 --- a/src/net/tls.c +++ b/src/net/tls.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/net/udp/ntp.c b/src/net/udp/ntp.c index 559233575..b3056184d 100644 --- a/src/net/udp/ntp.c +++ b/src/net/udp/ntp.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/udp/syslog.c b/src/net/udp/syslog.c index 198c86ef7..07ab3ed0c 100644 --- a/src/net/udp/syslog.c +++ b/src/net/udp/syslog.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/net/validator.c b/src/net/validator.c index e1371d2e6..c1f353b2a 100644 --- a/src/net/validator.c +++ b/src/net/validator.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/certmgmt.c b/src/usr/certmgmt.c index e6bf51fd8..9056a917c 100644 --- a/src/usr/certmgmt.c +++ b/src/usr/certmgmt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/imgtrust.c b/src/usr/imgtrust.c index e60854c9f..fa8282da0 100644 --- a/src/usr/imgtrust.c +++ b/src/usr/imgtrust.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/ipstat.c b/src/usr/ipstat.c index b9c5e02a7..c0d9739fa 100644 --- a/src/usr/ipstat.c +++ b/src/usr/ipstat.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/neighmgmt.c b/src/usr/neighmgmt.c index fcdcbbfbb..79f62e6d3 100644 --- a/src/usr/neighmgmt.c +++ b/src/usr/neighmgmt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/nslookup.c b/src/usr/nslookup.c index eb2b08b42..e4386e2c0 100644 --- a/src/usr/nslookup.c +++ b/src/usr/nslookup.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/ntpmgmt.c b/src/usr/ntpmgmt.c index 765c6dc9e..8b61662a0 100644 --- a/src/usr/ntpmgmt.c +++ b/src/usr/ntpmgmt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/pingmgmt.c b/src/usr/pingmgmt.c index bb33c5d47..fee6b438b 100644 --- a/src/usr/pingmgmt.c +++ b/src/usr/pingmgmt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/profstat.c b/src/usr/profstat.c index d80fa26b2..7fafd7b5f 100644 --- a/src/usr/profstat.c +++ b/src/usr/profstat.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include -- cgit v1.2.3-55-g7522