Date: Tue, 26 Jul 2022 19:30:57 GMT From: Marcin Wojtas <mw@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: cbbecd257ed6 - stable/13 - ena: Fix styling issues Message-ID: <202207261930.26QJUvoa029739@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=cbbecd257ed6a7585b470fb1070f4e86ab2911fc commit cbbecd257ed6a7585b470fb1070f4e86ab2911fc Author: Dawid Gorecki <dgr@semihalf.com> AuthorDate: 2022-06-10 09:18:11 +0000 Commit: Marcin Wojtas <mw@FreeBSD.org> CommitDate: 2022-07-26 19:30:16 +0000 ena: Fix styling issues Align code style with FreeBSD style(9) guidelines. Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit 82e558eacf222ac497bc11fa9f2c7778e97fbc7a) --- sys/dev/ena/ena.c | 593 ++++++++++++++++++++++----------------------- sys/dev/ena/ena.h | 103 ++++---- sys/dev/ena/ena_datapath.c | 116 +++++---- sys/dev/ena/ena_datapath.h | 12 +- sys/dev/ena/ena_netmap.c | 140 +++++------ sys/dev/ena/ena_netmap.h | 20 +- sys/dev/ena/ena_rss.c | 22 +- sys/dev/ena/ena_rss.h | 18 +- sys/dev/ena/ena_sysctl.c | 198 +++++++-------- sys/dev/ena/ena_sysctl.h | 4 +- 10 files changed, 591 insertions(+), 635 deletions(-) diff --git a/sys/dev/ena/ena.c b/sys/dev/ena/ena.c index dc8acb80c5e6..a57c608c8897 100644 --- a/sys/dev/ena/ena.c +++ b/sys/dev/ena/ena.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include <sys/systm.h> #include <sys/bus.h> #include <sys/endian.h> +#include <sys/eventhandler.h> #include <sys/kernel.h> #include <sys/kthread.h> #include <sys/malloc.h> @@ -48,41 +49,39 @@ __FBSDID("$FreeBSD$"); #include <sys/sysctl.h> #include <sys/taskqueue.h> #include <sys/time.h> -#include <sys/eventhandler.h> + +#include <vm/vm.h> +#include <vm/pmap.h> #include <machine/atomic.h> #include <machine/bus.h> -#include <machine/resource.h> #include <machine/in_cksum.h> +#include <machine/resource.h> + +#include <dev/pci/pcireg.h> +#include <dev/pci/pcivar.h> #include <net/bpf.h> #include <net/ethernet.h> #include <net/if.h> -#include <net/if_var.h> #include <net/if_arp.h> #include <net/if_dl.h> #include <net/if_media.h> #include <net/if_types.h> +#include <net/if_var.h> #include <net/if_vlan_var.h> - -#include <netinet/in_systm.h> #include <netinet/in.h> +#include <netinet/in_systm.h> #include <netinet/if_ether.h> #include <netinet/ip.h> #include <netinet/ip6.h> #include <netinet/tcp.h> #include <netinet/udp.h> -#include <dev/pci/pcivar.h> -#include <dev/pci/pcireg.h> - -#include <vm/vm.h> -#include <vm/pmap.h> - -#include "ena_datapath.h" #include "ena.h" -#include "ena_sysctl.h" +#include "ena_datapath.h" #include "ena_rss.h" +#include "ena_sysctl.h" #ifdef DEV_NETMAP #include "ena_netmap.h" @@ -91,96 +90,95 @@ __FBSDID("$FreeBSD$"); /********************************************************* * Function prototypes *********************************************************/ -static int ena_probe(device_t); -static void ena_intr_msix_mgmnt(void *); -static void ena_free_pci_resources(struct ena_adapter *); -static int ena_change_mtu(if_t, int); +static int ena_probe(device_t); +static void ena_intr_msix_mgmnt(void *); +static void ena_free_pci_resources(struct ena_adapter *); +static int ena_change_mtu(if_t, int); static inline void ena_alloc_counters(counter_u64_t *, int); static inline void ena_free_counters(counter_u64_t *, int); static inline void ena_reset_counters(counter_u64_t *, int); -static void ena_init_io_rings_common(struct ena_adapter *, - struct ena_ring *, uint16_t); -static void ena_init_io_rings_basic(struct ena_adapter *); -static void ena_init_io_rings_advanced(struct ena_adapter *); -static void ena_init_io_rings(struct ena_adapter *); -static void ena_free_io_ring_resources(struct ena_adapter *, unsigned int); -static void ena_free_all_io_rings_resources(struct ena_adapter *); -static int ena_setup_tx_dma_tag(struct ena_adapter *); -static int ena_free_tx_dma_tag(struct ena_adapter *); -static int ena_setup_rx_dma_tag(struct ena_adapter *); -static int ena_free_rx_dma_tag(struct ena_adapter *); -static void ena_release_all_tx_dmamap(struct ena_ring *); -static int ena_setup_tx_resources(struct ena_adapter *, int); -static void ena_free_tx_resources(struct ena_adapter *, int); -static int ena_setup_all_tx_resources(struct ena_adapter *); -static void ena_free_all_tx_resources(struct ena_adapter *); -static int ena_setup_rx_resources(struct ena_adapter *, unsigned int); -static void ena_free_rx_resources(struct ena_adapter *, unsigned int); -static int ena_setup_all_rx_resources(struct ena_adapter *); -static void ena_free_all_rx_resources(struct ena_adapter *); +static void ena_init_io_rings_common(struct ena_adapter *, struct ena_ring *, + uint16_t); +static void ena_init_io_rings_basic(struct ena_adapter *); +static void ena_init_io_rings_advanced(struct ena_adapter *); +static void ena_init_io_rings(struct ena_adapter *); +static void ena_free_io_ring_resources(struct ena_adapter *, unsigned int); +static void ena_free_all_io_rings_resources(struct ena_adapter *); +static int ena_setup_tx_dma_tag(struct ena_adapter *); +static int ena_free_tx_dma_tag(struct ena_adapter *); +static int ena_setup_rx_dma_tag(struct ena_adapter *); +static int ena_free_rx_dma_tag(struct ena_adapter *); +static void ena_release_all_tx_dmamap(struct ena_ring *); +static int ena_setup_tx_resources(struct ena_adapter *, int); +static void ena_free_tx_resources(struct ena_adapter *, int); +static int ena_setup_all_tx_resources(struct ena_adapter *); +static void ena_free_all_tx_resources(struct ena_adapter *); +static int ena_setup_rx_resources(struct ena_adapter *, unsigned int); +static void ena_free_rx_resources(struct ena_adapter *, unsigned int); +static int ena_setup_all_rx_resources(struct ena_adapter *); +static void ena_free_all_rx_resources(struct ena_adapter *); static inline int ena_alloc_rx_mbuf(struct ena_adapter *, struct ena_ring *, struct ena_rx_buffer *); -static void ena_free_rx_mbuf(struct ena_adapter *, struct ena_ring *, +static void ena_free_rx_mbuf(struct ena_adapter *, struct ena_ring *, struct ena_rx_buffer *); -static void ena_free_rx_bufs(struct ena_adapter *, unsigned int); -static void ena_refill_all_rx_bufs(struct ena_adapter *); -static void ena_free_all_rx_bufs(struct ena_adapter *); -static void ena_free_tx_bufs(struct ena_adapter *, unsigned int); -static void ena_free_all_tx_bufs(struct ena_adapter *); -static void ena_destroy_all_tx_queues(struct ena_adapter *); -static void ena_destroy_all_rx_queues(struct ena_adapter *); -static void ena_destroy_all_io_queues(struct ena_adapter *); -static int ena_create_io_queues(struct ena_adapter *); -static int ena_handle_msix(void *); -static int ena_enable_msix(struct ena_adapter *); -static void ena_setup_mgmnt_intr(struct ena_adapter *); -static int ena_setup_io_intr(struct ena_adapter *); -static int ena_request_mgmnt_irq(struct ena_adapter *); -static int ena_request_io_irq(struct ena_adapter *); -static void ena_free_mgmnt_irq(struct ena_adapter *); -static void ena_free_io_irq(struct ena_adapter *); -static void ena_free_irqs(struct ena_adapter*); -static void ena_disable_msix(struct ena_adapter *); -static void ena_unmask_all_io_irqs(struct ena_adapter *); -static int ena_up_complete(struct ena_adapter *); -static uint64_t ena_get_counter(if_t, ift_counter); -static int ena_media_change(if_t); -static void ena_media_status(if_t, struct ifmediareq *); -static void ena_init(void *); -static int ena_ioctl(if_t, u_long, caddr_t); -static int ena_get_dev_offloads(struct ena_com_dev_get_features_ctx *); -static void ena_update_host_info(struct ena_admin_host_info *, if_t); -static void ena_update_hwassist(struct ena_adapter *); -static int ena_setup_ifnet(device_t, struct ena_adapter *, +static void ena_free_rx_bufs(struct ena_adapter *, unsigned int); +static void ena_refill_all_rx_bufs(struct ena_adapter *); +static void ena_free_all_rx_bufs(struct ena_adapter *); +static void ena_free_tx_bufs(struct ena_adapter *, unsigned int); +static void ena_free_all_tx_bufs(struct ena_adapter *); +static void ena_destroy_all_tx_queues(struct ena_adapter *); +static void ena_destroy_all_rx_queues(struct ena_adapter *); +static void ena_destroy_all_io_queues(struct ena_adapter *); +static int ena_create_io_queues(struct ena_adapter *); +static int ena_handle_msix(void *); +static int ena_enable_msix(struct ena_adapter *); +static void ena_setup_mgmnt_intr(struct ena_adapter *); +static int ena_setup_io_intr(struct ena_adapter *); +static int ena_request_mgmnt_irq(struct ena_adapter *); +static int ena_request_io_irq(struct ena_adapter *); +static void ena_free_mgmnt_irq(struct ena_adapter *); +static void ena_free_io_irq(struct ena_adapter *); +static void ena_free_irqs(struct ena_adapter *); +static void ena_disable_msix(struct ena_adapter *); +static void ena_unmask_all_io_irqs(struct ena_adapter *); +static int ena_up_complete(struct ena_adapter *); +static uint64_t ena_get_counter(if_t, ift_counter); +static int ena_media_change(if_t); +static void ena_media_status(if_t, struct ifmediareq *); +static void ena_init(void *); +static int ena_ioctl(if_t, u_long, caddr_t); +static int ena_get_dev_offloads(struct ena_com_dev_get_features_ctx *); +static void ena_update_host_info(struct ena_admin_host_info *, if_t); +static void ena_update_hwassist(struct ena_adapter *); +static int ena_setup_ifnet(device_t, struct ena_adapter *, struct ena_com_dev_get_features_ctx *); -static int ena_enable_wc(device_t, struct resource *); -static int ena_set_queues_placement_policy(device_t, struct ena_com_dev *, +static int ena_enable_wc(device_t, struct resource *); +static int ena_set_queues_placement_policy(device_t, struct ena_com_dev *, struct ena_admin_feature_llq_desc *, struct ena_llq_configurations *); -static int ena_map_llq_mem_bar(device_t, struct ena_com_dev *); -static uint32_t ena_calc_max_io_queue_num(device_t, struct ena_com_dev *, +static int ena_map_llq_mem_bar(device_t, struct ena_com_dev *); +static uint32_t ena_calc_max_io_queue_num(device_t, struct ena_com_dev *, struct ena_com_dev_get_features_ctx *); -static int ena_calc_io_queue_size(struct ena_calc_queue_size_ctx *); -static void ena_config_host_info(struct ena_com_dev *, device_t); -static int ena_attach(device_t); -static int ena_detach(device_t); -static int ena_device_init(struct ena_adapter *, device_t, +static int ena_calc_io_queue_size(struct ena_calc_queue_size_ctx *); +static void ena_config_host_info(struct ena_com_dev *, device_t); +static int ena_attach(device_t); +static int ena_detach(device_t); +static int ena_device_init(struct ena_adapter *, device_t, struct ena_com_dev_get_features_ctx *, int *); -static int ena_enable_msix_and_set_admin_interrupts(struct ena_adapter *); +static int ena_enable_msix_and_set_admin_interrupts(struct ena_adapter *); static void ena_update_on_link_change(void *, struct ena_admin_aenq_entry *); -static void unimplemented_aenq_handler(void *, - struct ena_admin_aenq_entry *); -static int ena_copy_eni_metrics(struct ena_adapter *); -static void ena_timer_service(void *); +static void unimplemented_aenq_handler(void *, struct ena_admin_aenq_entry *); +static int ena_copy_eni_metrics(struct ena_adapter *); +static void ena_timer_service(void *); static char ena_version[] = DEVICE_NAME DRV_MODULE_NAME " v" DRV_MODULE_VERSION; static ena_vendor_info_t ena_vendor_info_array[] = { - { PCI_VENDOR_ID_AMAZON, PCI_DEV_ID_ENA_PF, 0}, - { PCI_VENDOR_ID_AMAZON, PCI_DEV_ID_ENA_PF_RSERV0, 0}, - { PCI_VENDOR_ID_AMAZON, PCI_DEV_ID_ENA_VF, 0}, - { PCI_VENDOR_ID_AMAZON, PCI_DEV_ID_ENA_VF_RSERV0, 0}, - /* Last entry */ - { 0, 0, 0 } + { PCI_VENDOR_ID_AMAZON, PCI_DEV_ID_ENA_PF, 0 }, + { PCI_VENDOR_ID_AMAZON, PCI_DEV_ID_ENA_PF_RSERV0, 0 }, + { PCI_VENDOR_ID_AMAZON, PCI_DEV_ID_ENA_VF, 0 }, + { PCI_VENDOR_ID_AMAZON, PCI_DEV_ID_ENA_VF_RSERV0, 0 }, + /* Last entry */ + { 0, 0, 0 } }; struct sx ena_global_lock; @@ -195,14 +193,14 @@ ena_dmamap_callback(void *arg, bus_dma_segment_t *segs, int nseg, int error) { if (error != 0) return; - *(bus_addr_t *) arg = segs[0].ds_addr; + *(bus_addr_t *)arg = segs[0].ds_addr; } int -ena_dma_alloc(device_t dmadev, bus_size_t size, - ena_mem_handle_t *dma, int mapflags, bus_size_t alignment, int domain) +ena_dma_alloc(device_t dmadev, bus_size_t size, ena_mem_handle_t *dma, + int mapflags, bus_size_t alignment, int domain) { - struct ena_adapter* adapter = device_get_softc(dmadev); + struct ena_adapter *adapter = device_get_softc(dmadev); device_t pdev = adapter->pdev; uint32_t maxsize; uint64_t dma_space_addr; @@ -215,16 +213,16 @@ ena_dma_alloc(device_t dmadev, bus_size_t size, dma_space_addr = BUS_SPACE_MAXADDR; error = bus_dma_tag_create(bus_get_dma_tag(dmadev), /* parent */ - alignment, 0, /* alignment, bounds */ - dma_space_addr, /* lowaddr of exclusion window */ - BUS_SPACE_MAXADDR,/* highaddr of exclusion window */ - NULL, NULL, /* filter, filterarg */ - maxsize, /* maxsize */ - 1, /* nsegments */ - maxsize, /* maxsegsize */ - BUS_DMA_ALLOCNOW, /* flags */ - NULL, /* lockfunc */ - NULL, /* lockarg */ + alignment, 0, /* alignment, bounds */ + dma_space_addr, /* lowaddr of exclusion window */ + BUS_SPACE_MAXADDR, /* highaddr of exclusion window */ + NULL, NULL, /* filter, filterarg */ + maxsize, /* maxsize */ + 1, /* nsegments */ + maxsize, /* maxsegsize */ + BUS_DMA_ALLOCNOW, /* flags */ + NULL, /* lockfunc */ + NULL, /* lockarg */ &dma->tag); if (unlikely(error != 0)) { ena_log(pdev, ERR, "bus_dma_tag_create failed: %d\n", error); @@ -238,7 +236,7 @@ ena_dma_alloc(device_t dmadev, bus_size_t size, goto fail_map_create; } - error = bus_dmamem_alloc(dma->tag, (void**) &dma->vaddr, + error = bus_dmamem_alloc(dma->tag, (void **)&dma->vaddr, BUS_DMA_COHERENT | BUS_DMA_ZERO, &dma->map); if (unlikely(error != 0)) { ena_log(pdev, ERR, "bus_dmamem_alloc(%ju) failed: %d\n", @@ -247,8 +245,8 @@ ena_dma_alloc(device_t dmadev, bus_size_t size, } dma->paddr = 0; - error = bus_dmamap_load(dma->tag, dma->map, dma->vaddr, - size, ena_dmamap_callback, &dma->paddr, mapflags); + error = bus_dmamap_load(dma->tag, dma->map, dma->vaddr, size, + ena_dmamap_callback, &dma->paddr, mapflags); if (unlikely((error != 0) || (dma->paddr == 0))) { ena_log(pdev, ERR, "bus_dmamap_load failed: %d\n", error); goto fail_map_load; @@ -287,8 +285,8 @@ ena_free_pci_resources(struct ena_adapter *adapter) } if (adapter->msix != NULL) { - bus_release_resource(pdev, SYS_RES_MEMORY, - adapter->msix_rid, adapter->msix); + bus_release_resource(pdev, SYS_RES_MEMORY, adapter->msix_rid, + adapter->msix); } } @@ -296,8 +294,8 @@ static int ena_probe(device_t dev) { ena_vendor_info_t *ent; - uint16_t pci_vendor_id = 0; - uint16_t pci_device_id = 0; + uint16_t pci_vendor_id = 0; + uint16_t pci_device_id = 0; pci_vendor_id = pci_get_vendor(dev); pci_device_id = pci_get_device(dev); @@ -306,15 +304,14 @@ ena_probe(device_t dev) while (ent->vendor_id != 0) { if ((pci_vendor_id == ent->vendor_id) && (pci_device_id == ent->device_id)) { - ena_log_raw(DBG, "vendor=%x device=%x\n", - pci_vendor_id, pci_device_id); + ena_log_raw(DBG, "vendor=%x device=%x\n", pci_vendor_id, + pci_device_id); device_set_desc(dev, DEVICE_DESC); return (BUS_PROBE_DEFAULT); } ent++; - } return (ENXIO); @@ -328,8 +325,7 @@ ena_change_mtu(if_t ifp, int new_mtu) int rc; if ((new_mtu > adapter->max_mtu) || (new_mtu < ENA_MIN_MTU)) { - ena_log(pdev, ERR, "Invalid MTU setting. " - "new_mtu: %d max mtu: %d min mtu: %d\n", + ena_log(pdev, ERR, "Invalid MTU setting. new_mtu: %d max mtu: %d min mtu: %d\n", new_mtu, adapter->max_mtu, ENA_MIN_MTU); return (EINVAL); } @@ -376,7 +372,6 @@ static void ena_init_io_rings_common(struct ena_adapter *adapter, struct ena_ring *ring, uint16_t qid) { - ring->qid = qid; ring->adapter = adapter; ring->ena_dev = adapter->ena_dev; @@ -432,8 +427,8 @@ ena_init_io_rings_advanced(struct ena_adapter *adapter) /* Allocate a buf ring */ txr->buf_ring_size = adapter->buf_ring_size; - txr->br = buf_ring_alloc(txr->buf_ring_size, M_DEVBUF, - M_WAITOK, &txr->ring_mtx); + txr->br = buf_ring_alloc(txr->buf_ring_size, M_DEVBUF, M_WAITOK, + &txr->ring_mtx); /* Allocate Tx statistics. */ ena_alloc_counters((counter_u64_t *)&txr->tx_stats, @@ -492,7 +487,6 @@ ena_free_all_io_rings_resources(struct ena_adapter *adapter) for (i = 0; i < adapter->num_io_queues; i++) ena_free_io_ring_resources(adapter, i); - } static int @@ -504,7 +498,7 @@ ena_setup_tx_dma_tag(struct ena_adapter *adapter) ret = bus_dma_tag_create(bus_get_dma_tag(adapter->pdev), 1, 0, /* alignment, bounds */ ENA_DMA_BIT_MASK(adapter->dma_width), /* lowaddr of excl window */ - BUS_SPACE_MAXADDR, /* highaddr of excl window */ + BUS_SPACE_MAXADDR, /* highaddr of excl window */ NULL, NULL, /* filter, filterarg */ ENA_TSO_MAXSIZE, /* maxsize */ adapter->max_tx_sgl_size - 1, /* nsegments */ @@ -539,7 +533,7 @@ ena_setup_rx_dma_tag(struct ena_adapter *adapter) ret = bus_dma_tag_create(bus_get_dma_tag(adapter->pdev), /* parent */ 1, 0, /* alignment, bounds */ ENA_DMA_BIT_MASK(adapter->dma_width), /* lowaddr of excl window */ - BUS_SPACE_MAXADDR, /* highaddr of excl window */ + BUS_SPACE_MAXADDR, /* highaddr of excl window */ NULL, NULL, /* filter, filterarg */ ena_mbuf_sz, /* maxsize */ adapter->max_rx_sgl_size, /* nsegments */ @@ -570,7 +564,7 @@ ena_release_all_tx_dmamap(struct ena_ring *tx_ring) { struct ena_adapter *adapter = tx_ring->adapter; struct ena_tx_buffer *tx_info; - bus_dma_tag_t tx_tag = adapter->tx_buf_tag;; + bus_dma_tag_t tx_tag = adapter->tx_buf_tag; int i; #ifdef DEV_NETMAP struct ena_netmap_tx_info *nm_info; @@ -661,8 +655,7 @@ ena_setup_tx_resources(struct ena_adapter *adapter, int qid) &tx_ring->tx_buffer_info[i].dmamap); if (unlikely(err != 0)) { ena_log(pdev, ERR, - "Unable to create Tx DMA map for buffer %d\n", - i); + "Unable to create Tx DMA map for buffer %d\n", i); goto err_map_release; } @@ -674,8 +667,8 @@ ena_setup_tx_resources(struct ena_adapter *adapter, int qid) &map[j]); if (unlikely(err != 0)) { ena_log(pdev, ERR, - "Unable to create " - "Tx DMA for buffer %d %d\n", i, j); + "Unable to create Tx DMA for buffer %d %d\n", + i, j); goto err_map_release; } } @@ -737,8 +730,7 @@ ena_free_tx_resources(struct ena_adapter *adapter, int qid) int j; #endif /* DEV_NETMAP */ - while (taskqueue_cancel(tx_ring->enqueue_tq, &tx_ring->enqueue_task, - NULL)) + while (taskqueue_cancel(tx_ring->enqueue_tq, &tx_ring->enqueue_task, NULL)) taskqueue_drain(tx_ring->enqueue_tq, &tx_ring->enqueue_task); taskqueue_free(tx_ring->enqueue_tq); @@ -995,8 +987,8 @@ ena_free_all_rx_resources(struct ena_adapter *adapter) } static inline int -ena_alloc_rx_mbuf(struct ena_adapter *adapter, - struct ena_ring *rx_ring, struct ena_rx_buffer *rx_info) +ena_alloc_rx_mbuf(struct ena_adapter *adapter, struct ena_ring *rx_ring, + struct ena_rx_buffer *rx_info) { device_t pdev = adapter->pdev; struct ena_com_buf *ena_buf; @@ -1027,8 +1019,9 @@ ena_alloc_rx_mbuf(struct ena_adapter *adapter, rx_info->mbuf->m_pkthdr.len = rx_info->mbuf->m_len = mlen; /* Map packets for DMA */ - ena_log(pdev, DBG, "Using tag %p for buffers' DMA mapping, mbuf %p len: %d\n", - adapter->rx_buf_tag,rx_info->mbuf, rx_info->mbuf->m_len); + ena_log(pdev, DBG, + "Using tag %p for buffers' DMA mapping, mbuf %p len: %d\n", + adapter->rx_buf_tag, rx_info->mbuf, rx_info->mbuf->m_len); error = bus_dmamap_load_mbuf_sg(adapter->rx_buf_tag, rx_info->map, rx_info->mbuf, segs, &nsegs, BUS_DMA_NOWAIT); if (unlikely((error != 0) || (nsegs != 1))) { @@ -1036,7 +1029,6 @@ ena_alloc_rx_mbuf(struct ena_adapter *adapter, "failed to map mbuf, error: %d, nsegs: %d\n", error, nsegs); counter_u64_add(rx_ring->rx_stats.dma_mapping_err, 1); goto exit; - } bus_dmamap_sync(adapter->rx_buf_tag, rx_info->map, BUS_DMASYNC_PREREAD); @@ -1045,8 +1037,9 @@ ena_alloc_rx_mbuf(struct ena_adapter *adapter, ena_buf->paddr = segs[0].ds_addr; ena_buf->len = mlen; - ena_log(pdev, DBG, "ALLOC RX BUF: mbuf %p, rx_info %p, len %d, paddr %#jx\n", - rx_info->mbuf, rx_info,ena_buf->len, (uintmax_t)ena_buf->paddr); + ena_log(pdev, DBG, + "ALLOC RX BUF: mbuf %p, rx_info %p, len %d, paddr %#jx\n", + rx_info->mbuf, rx_info, ena_buf->len, (uintmax_t)ena_buf->paddr); return (0); @@ -1060,7 +1053,6 @@ static void ena_free_rx_mbuf(struct ena_adapter *adapter, struct ena_ring *rx_ring, struct ena_rx_buffer *rx_info) { - if (rx_info->mbuf == NULL) { ena_log(adapter->pdev, WARN, "Trying to free unallocated buffer\n"); @@ -1103,7 +1095,8 @@ ena_refill_rx_bufs(struct ena_ring *rx_ring, uint32_t num) rx_info = &rx_ring->rx_buffer_info[req_id]; #ifdef DEV_NETMAP if (ena_rx_ring_in_netmap(adapter, rx_ring->qid)) - rc = ena_netmap_alloc_rx_slot(adapter, rx_ring, rx_info); + rc = ena_netmap_alloc_rx_slot(adapter, rx_ring, + rx_info); else #endif /* DEV_NETMAP */ rc = ena_alloc_rx_mbuf(adapter, rx_ring, rx_info); @@ -1128,8 +1121,8 @@ ena_refill_rx_bufs(struct ena_ring *rx_ring, uint32_t num) if (unlikely(i < num)) { counter_u64_add(rx_ring->rx_stats.refil_partial, 1); ena_log_io(pdev, WARN, - "refilled rx qid %d with only %d mbufs (from %d)\n", - rx_ring->qid, i, num); + "refilled rx qid %d with only %d mbufs (from %d)\n", + rx_ring->qid, i, num); } if (likely(i != 0)) @@ -1177,7 +1170,6 @@ ena_update_buf_ring_size(struct ena_adapter *adapter, ENA_FLAG_SET_ATOMIC(ENA_FLAG_DEV_UP_BEFORE_RESET, adapter); ena_trigger_reset(adapter, ENA_REGS_RESET_OS_TRIGGER); - } } @@ -1326,7 +1318,8 @@ ena_refill_all_rx_bufs(struct ena_adapter *adapter) if (unlikely(rc != bufs_num)) ena_log_io(adapter->pdev, WARN, "refilling Queue %d failed. " - "Allocated %d buffers from: %d\n", i, rc, bufs_num); + "Allocated %d buffers from: %d\n", + i, rc, bufs_num); #ifdef DEV_NETMAP rx_ring->initialized = true; #endif /* DEV_NETMAP */ @@ -1362,13 +1355,13 @@ ena_free_tx_bufs(struct ena_adapter *adapter, unsigned int qid) if (print_once) { ena_log(adapter->pdev, WARN, - "free uncompleted tx mbuf qid %d idx 0x%x\n", - qid, i); + "free uncompleted tx mbuf qid %d idx 0x%x\n", qid, + i); print_once = false; } else { ena_log(adapter->pdev, DBG, - "free uncompleted tx mbuf qid %d idx 0x%x\n", - qid, i); + "free uncompleted tx mbuf qid %d idx 0x%x\n", qid, + i); } bus_dmamap_sync(adapter->tx_buf_tag, tx_info->dmamap, @@ -1384,7 +1377,6 @@ ena_free_tx_bufs(struct ena_adapter *adapter, unsigned int qid) static void ena_free_all_tx_bufs(struct ena_adapter *adapter) { - for (int i = 0; i < adapter->num_io_queues; i++) ena_free_tx_bufs(adapter, i); } @@ -1421,10 +1413,8 @@ ena_destroy_all_io_queues(struct ena_adapter *adapter) for (i = 0; i < adapter->num_io_queues; i++) { queue = &adapter->que[i]; - while (taskqueue_cancel(queue->cleanup_tq, - &queue->cleanup_task, NULL)) - taskqueue_drain(queue->cleanup_tq, - &queue->cleanup_task); + while (taskqueue_cancel(queue->cleanup_tq, &queue->cleanup_task, NULL)) + taskqueue_drain(queue->cleanup_tq, &queue->cleanup_task); taskqueue_free(queue->cleanup_tq); } @@ -1463,12 +1453,12 @@ ena_create_io_queues(struct ena_adapter *adapter) } ring = &adapter->tx_ring[i]; rc = ena_com_get_io_handlers(ena_dev, ena_qid, - &ring->ena_com_io_sq, - &ring->ena_com_io_cq); + &ring->ena_com_io_sq, &ring->ena_com_io_cq); if (rc != 0) { ena_log(adapter->pdev, ERR, "Failed to get TX queue handlers. TX queue num" - " %d rc: %d\n", i, rc); + " %d rc: %d\n", + i, rc); ena_com_destroy_io_queue(ena_dev, ena_qid); goto err_tx; } @@ -1499,12 +1489,12 @@ ena_create_io_queues(struct ena_adapter *adapter) ring = &adapter->rx_ring[i]; rc = ena_com_get_io_handlers(ena_dev, ena_qid, - &ring->ena_com_io_sq, - &ring->ena_com_io_cq); + &ring->ena_com_io_sq, &ring->ena_com_io_cq); if (unlikely(rc != 0)) { ena_log(adapter->pdev, ERR, "Failed to get RX queue handlers. RX queue num" - " %d rc: %d\n", i, rc); + " %d rc: %d\n", + i, rc); ena_com_destroy_io_queue(ena_dev, ena_qid); goto err_rx; } @@ -1526,8 +1516,7 @@ ena_create_io_queues(struct ena_adapter *adapter) cpu_mask = &queue->cpu_mask; #endif taskqueue_start_threads_cpuset(&queue->cleanup_tq, 1, PI_NET, - cpu_mask, - "%s queue %d cleanup", + cpu_mask, "%s queue %d cleanup", device_get_nameunit(adapter->pdev), i); } @@ -1601,8 +1590,7 @@ ena_enable_msix(struct ena_adapter *adapter) adapter->msix_entries = malloc(msix_vecs * sizeof(struct msix_entry), M_DEVBUF, M_WAITOK | M_ZERO); - ena_log(dev, DBG, "trying to enable MSI-X, vectors: %d\n", - msix_vecs); + ena_log(dev, DBG, "trying to enable MSI-X, vectors: %d\n", msix_vecs); for (i = 0; i < msix_vecs; i++) { adapter->msix_entries[i].entry = i; @@ -1613,8 +1601,8 @@ ena_enable_msix(struct ena_adapter *adapter) msix_req = msix_vecs; rc = pci_alloc_msix(dev, &msix_vecs); if (unlikely(rc != 0)) { - ena_log(dev, ERR, - "Failed to enable MSIX, vectors %d rc %d\n", msix_vecs, rc); + ena_log(dev, ERR, "Failed to enable MSIX, vectors %d rc %d\n", + msix_vecs, rc); rc = ENOSPC; goto err_msix_free; @@ -1629,8 +1617,10 @@ ena_enable_msix(struct ena_adapter *adapter) rc = ENOSPC; goto err_msix_free; } - ena_log(dev, ERR, "Enable only %d MSI-x (out of %d), reduce " - "the number of queues\n", msix_vecs, msix_req); + ena_log(dev, ERR, + "Enable only %d MSI-x (out of %d), reduce " + "the number of queues\n", + msix_vecs, msix_req); } adapter->msix_vecs = msix_vecs; @@ -1648,10 +1638,8 @@ err_msix_free: static void ena_setup_mgmnt_intr(struct ena_adapter *adapter) { - - snprintf(adapter->irq_tbl[ENA_MGMNT_IRQ_IDX].name, - ENA_IRQNAME_SIZE, "ena-mgmnt@pci:%s", - device_get_nameunit(adapter->pdev)); + snprintf(adapter->irq_tbl[ENA_MGMNT_IRQ_IDX].name, ENA_IRQNAME_SIZE, + "ena-mgmnt@pci:%s", device_get_nameunit(adapter->pdev)); /* * Handler is NULL on purpose, it will be set * when mgmnt interrupt is acquired @@ -1736,11 +1724,11 @@ ena_request_mgmnt_irq(struct ena_adapter *adapter) } rc = bus_setup_intr(adapter->pdev, irq->res, - INTR_TYPE_NET | INTR_MPSAFE, NULL, ena_intr_msix_mgmnt, - irq->data, &irq->cookie); + INTR_TYPE_NET | INTR_MPSAFE, NULL, ena_intr_msix_mgmnt, irq->data, + &irq->cookie); if (unlikely(rc != 0)) { - ena_log(pdev, ERR, "failed to register " - "interrupt handler for irq %ju: %d\n", + ena_log(pdev, ERR, + "failed to register interrupt handler for irq %ju: %d\n", rman_get_start(irq->res), rc); goto err_res_free; } @@ -1750,11 +1738,12 @@ ena_request_mgmnt_irq(struct ena_adapter *adapter) err_res_free: ena_log(pdev, INFO, "releasing resource for irq %d\n", irq->vector); - rcc = bus_release_resource(adapter->pdev, SYS_RES_IRQ, - irq->vector, irq->res); + rcc = bus_release_resource(adapter->pdev, SYS_RES_IRQ, irq->vector, + irq->res); if (unlikely(rcc != 0)) - ena_log(pdev, ERR, "dev has no parent while " - "releasing res for irq: %d\n", irq->vector); + ena_log(pdev, ERR, + "dev has no parent while releasing res for irq: %d\n", + irq->vector); irq->res = NULL; return (rc); @@ -1786,17 +1775,17 @@ ena_request_io_irq(struct ena_adapter *adapter) &irq->vector, flags); if (unlikely(irq->res == NULL)) { rc = ENOMEM; - ena_log(pdev, ERR, "could not allocate irq vector: %d\n", - irq->vector); + ena_log(pdev, ERR, + "could not allocate irq vector: %d\n", irq->vector); goto err; } rc = bus_setup_intr(adapter->pdev, irq->res, - INTR_TYPE_NET | INTR_MPSAFE, irq->handler, NULL, - irq->data, &irq->cookie); - if (unlikely(rc != 0)) { - ena_log(pdev, ERR, "failed to register " - "interrupt handler for irq %ju: %d\n", + INTR_TYPE_NET | INTR_MPSAFE, irq->handler, NULL, irq->data, + &irq->cookie); + if (unlikely(rc != 0)) { + ena_log(pdev, ERR, + "failed to register interrupt handler for irq %ju: %d\n", rman_get_start(irq->res), rc); goto err; } @@ -1805,8 +1794,8 @@ ena_request_io_irq(struct ena_adapter *adapter) #ifdef RSS rc = bus_bind_intr(adapter->pdev, irq->res, irq->cpu); if (unlikely(rc != 0)) { - ena_log(pdev, ERR, "failed to bind " - "interrupt handler for irq %ju to cpu %d: %d\n", + ena_log(pdev, ERR, + "failed to bind interrupt handler for irq %ju to cpu %d: %d\n", rman_get_start(irq->res), irq->cpu, rc); goto err; } @@ -1827,9 +1816,11 @@ err: /* Once we entered err: section and irq->requested is true we free both intr and resources */ if (irq->requested) - rcc = bus_teardown_intr(adapter->pdev, irq->res, irq->cookie); + rcc = bus_teardown_intr(adapter->pdev, irq->res, + irq->cookie); if (unlikely(rcc != 0)) - ena_log(pdev, ERR, "could not release irq: %d, error: %d\n", + ena_log(pdev, ERR, + "could not release irq: %d, error: %d\n", irq->vector, rcc); /* If we entered err: section without irq->requested set we know @@ -1842,8 +1833,9 @@ err: irq->vector, irq->res); } if (unlikely(rcc != 0)) - ena_log(pdev, ERR, "dev has no parent while " - "releasing res for irq: %d\n", irq->vector); + ena_log(pdev, ERR, + "dev has no parent while releasing res for irq: %d\n", + irq->vector); irq->requested = false; irq->res = NULL; } @@ -1874,8 +1866,9 @@ ena_free_mgmnt_irq(struct ena_adapter *adapter) irq->vector, irq->res); irq->res = NULL; if (unlikely(rc != 0)) - ena_log(pdev, ERR, "dev has no parent while " - "releasing res for irq: %d\n", irq->vector); + ena_log(pdev, ERR, + "dev has no parent while releasing res for irq: %d\n", + irq->vector); } } @@ -1893,7 +1886,8 @@ ena_free_io_irq(struct ena_adapter *adapter) rc = bus_teardown_intr(adapter->pdev, irq->res, irq->cookie); if (unlikely(rc != 0)) { - ena_log(pdev, ERR, "failed to tear down irq: %d\n", + ena_log(pdev, ERR, + "failed to tear down irq: %d\n", irq->vector); } irq->requested = 0; @@ -1906,8 +1900,8 @@ ena_free_io_irq(struct ena_adapter *adapter) irq->vector, irq->res); irq->res = NULL; if (unlikely(rc != 0)) { - ena_log(pdev, ERR, "dev has no parent" - " while releasing res for irq: %d\n", + ena_log(pdev, ERR, + "dev has no parent while releasing res for irq: %d\n", irq->vector); } } @@ -1915,9 +1909,8 @@ ena_free_io_irq(struct ena_adapter *adapter) } static void -ena_free_irqs(struct ena_adapter* adapter) +ena_free_irqs(struct ena_adapter *adapter) { - ena_free_io_irq(adapter); ena_free_mgmnt_irq(adapter); ena_disable_msix(adapter); @@ -1926,7 +1919,6 @@ ena_free_irqs(struct ena_adapter* adapter) static void ena_disable_msix(struct ena_adapter *adapter) { - if (ENA_FLAG_ISSET(ENA_FLAG_MSIX_ENABLED, adapter)) { ENA_FLAG_CLEAR_ATOMIC(ENA_FLAG_MSIX_ENABLED, adapter); pci_release_msi(adapter->pdev); @@ -1940,7 +1932,7 @@ ena_disable_msix(struct ena_adapter *adapter) static void ena_unmask_all_io_irqs(struct ena_adapter *adapter) { - struct ena_com_io_cq* io_cq; + struct ena_com_io_cq *io_cq; struct ena_eth_io_intr_reg intr_reg; struct ena_ring *tx_ring; uint16_t ena_qid; @@ -1983,8 +1975,7 @@ ena_up_complete(struct ena_adapter *adapter) } static void -set_io_rings_size(struct ena_adapter *adapter, int new_tx_size, - int new_rx_size) +set_io_rings_size(struct ena_adapter *adapter, int new_tx_size, int new_rx_size) { int i; @@ -2027,8 +2018,7 @@ create_queues_with_size_backoff(struct ena_adapter *adapter) /* Create IO queues for Rx & Tx */ rc = ena_create_io_queues(adapter); if (unlikely(rc != 0)) { - ena_log(pdev, ERR, - "create IO queues failed\n"); + ena_log(pdev, ERR, "create IO queues failed\n"); goto err_io_que; } @@ -2060,8 +2050,8 @@ err_setup_tx: new_rx_ring_size = cur_rx_ring_size; /* - * Decrease the size of a larger queue, or decrease both if they are - * the same size. + * Decrease the size of a larger queue, or decrease both if they + * are the same size. */ if (cur_rx_ring_size <= cur_tx_ring_size) new_tx_ring_size = cur_tx_ring_size / 2; @@ -2115,13 +2105,12 @@ ena_up(struct ena_adapter *adapter) } ena_log(adapter->pdev, INFO, - "Creating %u IO queues. Rx queue size: %d, Tx queue size: %d, " - "LLQ is %s\n", + "Creating %u IO queues. Rx queue size: %d, Tx queue size: %d, LLQ is %s\n", adapter->num_io_queues, adapter->requested_rx_ring_size, adapter->requested_tx_ring_size, (adapter->ena_dev->tx_mem_queue_type == - ENA_ADMIN_PLACEMENT_POLICY_DEV) ? "ENABLED" : "DISABLED"); + ENA_ADMIN_PLACEMENT_POLICY_DEV) ? "ENABLED" : "DISABLED"); rc = create_queues_with_size_backoff(adapter); if (unlikely(rc != 0)) { @@ -2141,8 +2130,7 @@ ena_up(struct ena_adapter *adapter) ena_update_hwassist(adapter); - if_setdrvflagbits(adapter->ifp, IFF_DRV_RUNNING, - IFF_DRV_OACTIVE); + if_setdrvflagbits(adapter->ifp, IFF_DRV_RUNNING, IFF_DRV_OACTIVE); ENA_FLAG_SET_ATOMIC(ENA_FLAG_DEV_UP, adapter); @@ -2259,8 +2247,8 @@ ena_ioctl(if_t ifp, u_long command, caddr_t data) case SIOCSIFFLAGS: if ((ifp->if_flags & IFF_UP) != 0) { if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) { - if ((ifp->if_flags & (IFF_PROMISC | - IFF_ALLMULTI)) != 0) { + if ((ifp->if_flags & + (IFF_PROMISC | IFF_ALLMULTI)) != 0) { ena_log(adapter->pdev, INFO, "ioctl promisc/allmulti\n"); } @@ -2330,12 +2318,10 @@ ena_get_dev_offloads(struct ena_com_dev_get_features_ctx *feat) ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV6_CSUM_PART_MASK)) != 0) caps |= IFCAP_TXCSUM_IPV6; - if ((feat->offload.tx & - ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_IPV4_MASK) != 0) + if ((feat->offload.tx & ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_IPV4_MASK) != 0) caps |= IFCAP_TSO4; - if ((feat->offload.tx & - ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_IPV6_MASK) != 0) + if ((feat->offload.tx & ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_IPV6_MASK) != 0) caps |= IFCAP_TSO6; if ((feat->offload.rx_supported & @@ -2355,9 +2341,7 @@ ena_get_dev_offloads(struct ena_com_dev_get_features_ctx *feat) static void ena_update_host_info(struct ena_admin_host_info *host_info, if_t ifp) { - - host_info->supported_network_features[0] = - (uint32_t)if_getcapabilities(ifp); + host_info->supported_network_features[0] = (uint32_t)if_getcapabilities(ifp); } static void @@ -2408,8 +2392,8 @@ ena_setup_ifnet(device_t pdev, struct ena_adapter *adapter, if_setdev(ifp, pdev); if_setsoftc(ifp, adapter); - if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST | - IFF_KNOWSEPOCH); + if_setflags(ifp, + IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST | IFF_KNOWSEPOCH); if_setinitfn(ifp, ena_init); if_settransmitfn(ifp, ena_mq_start); if_setqflushfn(ifp, ena_qflush); @@ -2441,8 +2425,8 @@ ena_setup_ifnet(device_t pdev, struct ena_adapter *adapter, * Specify the media types supported by this adapter and register * callbacks to update media and link information */ - ifmedia_init(&adapter->media, IFM_IMASK, - ena_media_change, ena_media_status); + ifmedia_init(&adapter->media, IFM_IMASK, ena_media_change, + ena_media_status); ifmedia_add(&adapter->media, IFM_ETHER | IFM_AUTO, 0, NULL); ifmedia_set(&adapter->media, IFM_ETHER | IFM_AUTO); @@ -2464,17 +2448,14 @@ ena_down(struct ena_adapter *adapter) ena_log(adapter->pdev, INFO, "device is going DOWN\n"); ENA_FLAG_CLEAR_ATOMIC(ENA_FLAG_DEV_UP, adapter); - if_setdrvflagbits(adapter->ifp, IFF_DRV_OACTIVE, - IFF_DRV_RUNNING); + if_setdrvflagbits(adapter->ifp, IFF_DRV_OACTIVE, IFF_DRV_RUNNING); ena_free_io_irq(adapter); if (ENA_FLAG_ISSET(ENA_FLAG_TRIGGER_RESET, adapter)) { - rc = ena_com_dev_reset(adapter->ena_dev, - adapter->reset_reason); + rc = ena_com_dev_reset(adapter->ena_dev, adapter->reset_reason); if (unlikely(rc != 0)) - ena_log(adapter->pdev, ERR, - "Device reset failed\n"); + ena_log(adapter->pdev, ERR, "Device reset failed\n"); } ena_destroy_all_io_queues(adapter); @@ -2498,7 +2479,7 @@ ena_calc_max_io_queue_num(device_t pdev, struct ena_com_dev *ena_dev, struct ena_admin_queue_ext_feature_fields *max_queue_ext = &get_feat_ctx->max_queue_ext.max_queue_ext; io_rx_num = min_t(int, max_queue_ext->max_rx_sq_num, - max_queue_ext->max_rx_cq_num); + max_queue_ext->max_rx_cq_num); *** 1646 LINES SKIPPED ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202207261930.26QJUvoa029739>