diff options
author | Marcin Wojtas <mw@FreeBSD.org> | 2021-06-24 14:07:33 +0000 |
---|---|---|
committer | Marcin Wojtas <mw@FreeBSD.org> | 2021-06-24 14:15:18 +0000 |
commit | 3fc5d816f8831d6fc2816ac97bd78dc486cd080c (patch) | |
tree | e5e911c1cb6d02269badccbd75224f7da69c60f7 | |
parent | 0e7d31f63b9db869c91228d8ed1e984bdee2b931 (diff) | |
parent | 1f4f67f52424ac53d07ff524af9762fdf2e2b210 (diff) | |
download | src-3fc5d816f8831d6fc2816ac97bd78dc486cd080c.tar.gz src-3fc5d816f8831d6fc2816ac97bd78dc486cd080c.zip |
Merge tag 'vendor/ena-com/2.4.0'
Update the driver in order not to break its compilation
and make use of the new ENA logging system
Migrate platform code to the new logging system provided by ena_com
layer.
Make ENA_INFO the new default log level.
Remove all explicit use of `device_printf`, all new logs requiring one
of the log macros to be used.
-rw-r--r-- | sys/contrib/ena-com/ena_com.c | 37 | ||||
-rw-r--r-- | sys/contrib/ena-com/ena_com.h | 6 | ||||
-rw-r--r-- | sys/contrib/ena-com/ena_defs/ena_admin_defs.h | 23 | ||||
-rw-r--r-- | sys/contrib/ena-com/ena_defs/ena_gen_info.h | 6 | ||||
-rw-r--r-- | sys/contrib/ena-com/ena_eth_com.c | 4 | ||||
-rw-r--r-- | sys/contrib/ena-com/ena_fbsd_log.h | 74 | ||||
-rw-r--r-- | sys/contrib/ena-com/ena_plat.h | 37 | ||||
-rw-r--r-- | sys/dev/ena/ena.c | 342 | ||||
-rw-r--r-- | sys/dev/ena/ena_datapath.c | 83 | ||||
-rw-r--r-- | sys/dev/ena/ena_netmap.c | 73 | ||||
-rw-r--r-- | sys/dev/ena/ena_sysctl.c | 30 |
11 files changed, 397 insertions, 318 deletions
diff --git a/sys/contrib/ena-com/ena_com.c b/sys/contrib/ena-com/ena_com.c index 8c63c1a03f76..3af3b14eca44 100644 --- a/sys/contrib/ena-com/ena_com.c +++ b/sys/contrib/ena-com/ena_com.c @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * - * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. + * Copyright (c) 2015-2021 Amazon.com, Inc. or its affiliates. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -694,7 +694,7 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev, } else { ena_trc_err(ena_dev, "Invalid header location control, supported: 0x%x\n", supported_feat); - return -EINVAL; + return ENA_COM_INVAL; } if (likely(llq_info->header_location_ctrl == ENA_ADMIN_INLINE_HEADER)) { @@ -709,7 +709,7 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev, } else { ena_trc_err(ena_dev, "Invalid desc_stride_ctrl, supported: 0x%x\n", supported_feat); - return -EINVAL; + return ENA_COM_INVAL; } ena_trc_err(ena_dev, "Default llq stride ctrl is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n", @@ -738,7 +738,7 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev, } else { ena_trc_err(ena_dev, "Invalid entry_size_ctrl, supported: 0x%x\n", supported_feat); - return -EINVAL; + return ENA_COM_INVAL; } ena_trc_err(ena_dev, "Default llq ring entry size is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n", @@ -752,7 +752,7 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev, */ ena_trc_err(ena_dev, "Illegal entry size %d\n", llq_info->desc_list_entry_size); - return -EINVAL; + return ENA_COM_INVAL; } if (llq_info->desc_stride_ctrl == ENA_ADMIN_MULTIPLE_DESCS_PER_ENTRY) @@ -776,7 +776,7 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev, } else { ena_trc_err(ena_dev, "Invalid descs_num_before_header, supported: 0x%x\n", supported_feat); - return -EINVAL; + return ENA_COM_INVAL; } ena_trc_err(ena_dev, "Default llq num descs before header is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n", @@ -1409,16 +1409,17 @@ int ena_com_execute_admin_command(struct ena_com_admin_queue *admin_queue, comp_ctx = ena_com_submit_admin_cmd(admin_queue, cmd, cmd_size, comp, comp_size); if (IS_ERR(comp_ctx)) { - if (comp_ctx == ERR_PTR(ENA_COM_NO_DEVICE)) + ret = PTR_ERR(comp_ctx); + if (ret == ENA_COM_NO_DEVICE) ena_trc_dbg(admin_queue->ena_dev, - "Failed to submit command [%ld]\n", - PTR_ERR(comp_ctx)); + "Failed to submit command [%d]\n", + ret); else ena_trc_err(admin_queue->ena_dev, - "Failed to submit command [%ld]\n", - PTR_ERR(comp_ctx)); + "Failed to submit command [%d]\n", + ret); - return (int)PTR_ERR(comp_ctx); + return ret; } ret = ena_com_wait_and_process_admin_cq(comp_ctx, admin_queue); @@ -2034,7 +2035,7 @@ int ena_com_get_dev_attr_feat(struct ena_com_dev *ena_dev, return rc; if (get_resp.u.max_queue_ext.version != ENA_FEATURE_MAX_QUEUE_EXT_VER) - return -EINVAL; + return ENA_COM_INVAL; memcpy(&get_feat_ctx->max_queue_ext, &get_resp.u.max_queue_ext, sizeof(get_resp.u.max_queue_ext)); @@ -2363,7 +2364,7 @@ done: } #endif -int ena_com_set_dev_mtu(struct ena_com_dev *ena_dev, int mtu) +int ena_com_set_dev_mtu(struct ena_com_dev *ena_dev, u32 mtu) { struct ena_com_admin_queue *admin_queue; struct ena_admin_set_feat_cmd cmd; @@ -2381,7 +2382,7 @@ int ena_com_set_dev_mtu(struct ena_com_dev *ena_dev, int mtu) cmd.aq_common_descriptor.opcode = ENA_ADMIN_SET_FEATURE; cmd.aq_common_descriptor.flags = 0; cmd.feat_common.feature_id = ENA_ADMIN_MTU; - cmd.u.mtu.mtu = (u32)mtu; + cmd.u.mtu.mtu = mtu; ret = ena_com_execute_admin_command(admin_queue, (struct ena_admin_aq_entry *)&cmd, @@ -2792,7 +2793,7 @@ int ena_com_indirect_table_set(struct ena_com_dev *ena_dev) return ret; } - cmd.control_buffer.length = (u32)(1ULL << rss->tbl_log_size) * + cmd.control_buffer.length = (1ULL << rss->tbl_log_size) * sizeof(struct ena_admin_rss_ind_table_entry); ret = ena_com_execute_admin_command(admin_queue, @@ -2814,7 +2815,7 @@ int ena_com_indirect_table_get(struct ena_com_dev *ena_dev, u32 *ind_tbl) u32 tbl_size; int i, rc; - tbl_size = (u32)(1ULL << rss->tbl_log_size) * + tbl_size = (1ULL << rss->tbl_log_size) * sizeof(struct ena_admin_rss_ind_table_entry); rc = ena_com_get_feature_ex(ena_dev, &get_resp, @@ -3098,7 +3099,7 @@ int ena_com_config_dev_mode(struct ena_com_dev *ena_dev, if (unlikely(ena_dev->tx_max_header_size == 0)) { ena_trc_err(ena_dev, "The size of the LLQ entry is smaller than needed\n"); - return -EINVAL; + return ENA_COM_INVAL; } ena_dev->tx_mem_queue_type = ENA_ADMIN_PLACEMENT_POLICY_DEV; diff --git a/sys/contrib/ena-com/ena_com.h b/sys/contrib/ena-com/ena_com.h index 414301bdaf91..7ff0e00c1f17 100644 --- a/sys/contrib/ena-com/ena_com.h +++ b/sys/contrib/ena-com/ena_com.h @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * - * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. + * Copyright (c) 2015-2021 Amazon.com, Inc. or its affiliates. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -51,8 +51,6 @@ #define ADMIN_CQ_SIZE(depth) ((depth) * sizeof(struct ena_admin_acq_entry)) #define ADMIN_AENQ_SIZE(depth) ((depth) * sizeof(struct ena_admin_aenq_entry)) -#define ENA_CDESC_RING_SIZE_ALIGNMENT (1 << 12) /* 4K */ - /*****************************************************************************/ /*****************************************************************************/ /* ENA adaptive interrupt moderation settings */ @@ -645,7 +643,7 @@ int ena_com_get_eni_stats(struct ena_com_dev *ena_dev, * * @return: 0 on Success and negative value otherwise. */ -int ena_com_set_dev_mtu(struct ena_com_dev *ena_dev, int mtu); +int ena_com_set_dev_mtu(struct ena_com_dev *ena_dev, u32 mtu); /* ena_com_get_offload_settings - Retrieve the device offloads capabilities * @ena_dev: ENA communication layer struct diff --git a/sys/contrib/ena-com/ena_defs/ena_admin_defs.h b/sys/contrib/ena-com/ena_defs/ena_admin_defs.h index edfdad3473d7..33010bd1a2e8 100644 --- a/sys/contrib/ena-com/ena_defs/ena_admin_defs.h +++ b/sys/contrib/ena-com/ena_defs/ena_admin_defs.h @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * - * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. + * Copyright (c) 2015-2021 Amazon.com, Inc. or its affiliates. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -853,7 +853,8 @@ enum ena_admin_os_type { ENA_ADMIN_OS_FREEBSD = 4, ENA_ADMIN_OS_IPXE = 5, ENA_ADMIN_OS_ESXI = 6, - ENA_ADMIN_OS_GROUPS_NUM = 6, + ENA_ADMIN_OS_MACOS = 7, + ENA_ADMIN_OS_GROUPS_NUM = 7, }; struct ena_admin_host_info { @@ -902,7 +903,9 @@ struct ena_admin_host_info { * 2 : interrupt_moderation * 3 : rx_buf_mirroring * 4 : rss_configurable_function_key - * 31:5 : reserved + * 5 : reserved + * 6 : rx_page_reuse + * 31:7 : reserved */ uint32_t driver_supported_features; }; @@ -1092,8 +1095,6 @@ enum ena_admin_aenq_group { }; enum ena_admin_aenq_notification_syndrome { - ENA_ADMIN_SUSPEND = 0, - ENA_ADMIN_RESUME = 1, ENA_ADMIN_UPDATE_HINTS = 2, }; @@ -1228,6 +1229,8 @@ struct ena_admin_ena_mmio_req_read_less_resp { #define ENA_ADMIN_HOST_INFO_RX_BUF_MIRRORING_MASK BIT(3) #define ENA_ADMIN_HOST_INFO_RSS_CONFIGURABLE_FUNCTION_KEY_SHIFT 4 #define ENA_ADMIN_HOST_INFO_RSS_CONFIGURABLE_FUNCTION_KEY_MASK BIT(4) +#define ENA_ADMIN_HOST_INFO_RX_PAGE_REUSE_SHIFT 6 +#define ENA_ADMIN_HOST_INFO_RX_PAGE_REUSE_MASK BIT(6) /* feature_rss_ind_table */ #define ENA_ADMIN_FEATURE_RSS_IND_TABLE_ONE_ENTRY_UPDATE_MASK BIT(0) @@ -1689,6 +1692,16 @@ static inline void set_ena_admin_host_info_rss_configurable_function_key(struct p->driver_supported_features |= (val << ENA_ADMIN_HOST_INFO_RSS_CONFIGURABLE_FUNCTION_KEY_SHIFT) & ENA_ADMIN_HOST_INFO_RSS_CONFIGURABLE_FUNCTION_KEY_MASK; } +static inline uint32_t get_ena_admin_host_info_rx_page_reuse(const struct ena_admin_host_info *p) +{ + return (p->driver_supported_features & ENA_ADMIN_HOST_INFO_RX_PAGE_REUSE_MASK) >> ENA_ADMIN_HOST_INFO_RX_PAGE_REUSE_SHIFT; +} + +static inline void set_ena_admin_host_info_rx_page_reuse(struct ena_admin_host_info *p, uint32_t val) +{ + p->driver_supported_features |= (val << ENA_ADMIN_HOST_INFO_RX_PAGE_REUSE_SHIFT) & ENA_ADMIN_HOST_INFO_RX_PAGE_REUSE_MASK; +} + static inline uint8_t get_ena_admin_feature_rss_ind_table_one_entry_update(const struct ena_admin_feature_rss_ind_table *p) { return p->flags & ENA_ADMIN_FEATURE_RSS_IND_TABLE_ONE_ENTRY_UPDATE_MASK; diff --git a/sys/contrib/ena-com/ena_defs/ena_gen_info.h b/sys/contrib/ena-com/ena_defs/ena_gen_info.h index 726750a67d4e..2797239f24ef 100644 --- a/sys/contrib/ena-com/ena_defs/ena_gen_info.h +++ b/sys/contrib/ena-com/ena_defs/ena_gen_info.h @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * - * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. + * Copyright (c) 2015-2021 Amazon.com, Inc. or its affiliates. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,5 +30,5 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#define ENA_GEN_DATE "Fri Sep 18 17:09:00 IDT 2020" -#define ENA_GEN_COMMIT "0f80d82" +#define ENA_GEN_DATE "Tue Jan 19 12:45:09 STD 2021" +#define ENA_GEN_COMMIT "f023ae8f" diff --git a/sys/contrib/ena-com/ena_eth_com.c b/sys/contrib/ena-com/ena_eth_com.c index 47ca4e4afdb6..2d66c34c0aa7 100644 --- a/sys/contrib/ena-com/ena_eth_com.c +++ b/sys/contrib/ena-com/ena_eth_com.c @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * - * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. + * Copyright (c) 2015-2021 Amazon.com, Inc. or its affiliates. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -178,7 +178,7 @@ static int ena_com_close_bounce_buffer(struct ena_com_io_sq *io_sq) return ENA_COM_OK; /* bounce buffer was used, so write it and get a new one */ - if (pkt_ctrl->idx) { + if (likely(pkt_ctrl->idx)) { rc = ena_com_write_bounce_buffer_to_dev(io_sq, pkt_ctrl->curr_bounce_buf); if (unlikely(rc)) { diff --git a/sys/contrib/ena-com/ena_fbsd_log.h b/sys/contrib/ena-com/ena_fbsd_log.h new file mode 100644 index 000000000000..311e2f0f280a --- /dev/null +++ b/sys/contrib/ena-com/ena_fbsd_log.h @@ -0,0 +1,74 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 2015-2021 Amazon.com, Inc. or its affiliates. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT + * OWNER 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 ENA_FBSD_LOG_H +#define ENA_FBSD_LOG_H + +enum ena_log_t { + ENA_ERR = 0, + ENA_WARN, + ENA_INFO, + ENA_DBG, +}; + +extern int ena_log_level; + +#define ena_log(dev, level, fmt, args...) \ + do { \ + if (ENA_ ## level <= ena_log_level) \ + device_printf((dev), fmt, ##args); \ + } while (0) + +#define ena_log_raw(level, fmt, args...) \ + do { \ + if (ENA_ ## level <= ena_log_level) \ + printf(fmt, ##args); \ + } while (0) + +#define ena_log_unused(dev, level, fmt, args...) \ + do { \ + (void)(dev); \ + } while (0) + +#ifdef ENA_LOG_IO_ENABLE +#define ena_log_io(dev, level, fmt, args...) \ + ena_log((dev), level, fmt, ##args) +#else +#define ena_log_io(dev, level, fmt, args...) \ + ena_log_unused((dev), level, fmt, ##args) +#endif + +#define ena_log_nm(dev, level, fmt, args...) \ + ena_log((dev), level, "[nm] " fmt, ##args) + +#endif /* !(ENA_FBSD_LOG_H) */ diff --git a/sys/contrib/ena-com/ena_plat.h b/sys/contrib/ena-com/ena_plat.h index 8fe1ec9aa731..b31821248398 100644 --- a/sys/contrib/ena-com/ena_plat.h +++ b/sys/contrib/ena-com/ena_plat.h @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * - * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. + * Copyright (c) 2015-2021 Amazon.com, Inc. or its affiliates. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -91,22 +91,12 @@ __FBSDID("$FreeBSD$"); #include <dev/pci/pcivar.h> #include <dev/pci/pcireg.h> -extern struct ena_bus_space ebs; +#include "ena_fbsd_log.h" -/* Levels */ -#define ENA_ALERT (1 << 0) /* Alerts are providing more error info. */ -#define ENA_WARNING (1 << 1) /* Driver output is more error sensitive. */ -#define ENA_INFO (1 << 2) /* Provides additional driver info. */ -#define ENA_DBG (1 << 3) /* Driver output for debugging. */ -/* Detailed info that will be printed with ENA_INFO or ENA_DEBUG flag. */ -#define ENA_TXPTH (1 << 4) /* Allows TX path tracing. */ -#define ENA_RXPTH (1 << 5) /* Allows RX path tracing. */ -#define ENA_RSC (1 << 6) /* Goes with TXPTH or RXPTH, free/alloc res. */ -#define ENA_IOQ (1 << 7) /* Detailed info about IO queues. */ -#define ENA_ADMQ (1 << 8) /* Detailed info about admin queue. */ -#define ENA_NETMAP (1 << 9) /* Detailed info about netmap. */ +extern struct ena_bus_space ebs; #define DEFAULT_ALLOC_ALIGNMENT 8 +#define ENA_CDESC_RING_SIZE_ALIGNMENT (1 << 12) /* 4K */ extern int ena_log_level; @@ -116,27 +106,18 @@ extern int ena_log_level; (type *)((uintptr_t)__p - offsetof(type, member)); \ }) -#define ena_trace_raw(ctx, level, fmt, args...) \ - do { \ - ((void)(ctx)); \ - if (((level) & ena_log_level) != (level)) \ - break; \ - printf(fmt, ##args); \ - } while (0) - #define ena_trace(ctx, level, fmt, args...) \ - ena_trace_raw(ctx, level, "%s() [TID:%d]: " \ + ena_log((ctx)->dmadev, level, "%s() [TID:%d]: " \ fmt, __func__, curthread->td_tid, ##args) - #define ena_trc_dbg(ctx, format, arg...) \ - ena_trace(ctx, ENA_DBG, format, ##arg) + ena_trace(ctx, DBG, format, ##arg) #define ena_trc_info(ctx, format, arg...) \ - ena_trace(ctx, ENA_INFO, format, ##arg) + ena_trace(ctx, INFO, format, ##arg) #define ena_trc_warn(ctx, format, arg...) \ - ena_trace(ctx, ENA_WARNING, format, ##arg) + ena_trace(ctx, WARN, format, ##arg) #define ena_trc_err(ctx, format, arg...) \ - ena_trace(ctx, ENA_ALERT, format, ##arg) + ena_trace(ctx, ERR, format, ##arg) #define unlikely(x) __predict_false(!!(x)) #define likely(x) __predict_true(!!(x)) diff --git a/sys/dev/ena/ena.c b/sys/dev/ena/ena.c index fbe32a7a930e..84d58c844332 100644 --- a/sys/dev/ena/ena.c +++ b/sys/dev/ena/ena.c @@ -155,7 +155,7 @@ 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(struct resource *); +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 uint32_t ena_calc_max_io_queue_num(device_t, struct ena_com_dev *, @@ -204,6 +204,7 @@ ena_dma_alloc(device_t dmadev, bus_size_t size, ena_mem_handle_t *dma, int mapflags, bus_size_t alignment) { struct ena_adapter* adapter = device_get_softc(dmadev); + device_t pdev = adapter->pdev; uint32_t maxsize; uint64_t dma_space_addr; int error; @@ -227,14 +228,14 @@ ena_dma_alloc(device_t dmadev, bus_size_t size, NULL, /* lockarg */ &dma->tag); if (unlikely(error != 0)) { - ena_trace(NULL, ENA_ALERT, "bus_dma_tag_create failed: %d\n", error); + ena_log(pdev, ERR, "bus_dma_tag_create failed: %d\n", error); goto fail_tag; } error = bus_dmamem_alloc(dma->tag, (void**) &dma->vaddr, BUS_DMA_COHERENT | BUS_DMA_ZERO, &dma->map); if (unlikely(error != 0)) { - ena_trace(NULL, ENA_ALERT, "bus_dmamem_alloc(%ju) failed: %d\n", + ena_log(pdev, ERR, "bus_dmamem_alloc(%ju) failed: %d\n", (uintmax_t)size, error); goto fail_map_create; } @@ -243,7 +244,7 @@ ena_dma_alloc(device_t dmadev, bus_size_t size, 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_trace(NULL, ENA_ALERT, ": bus_dmamap_load failed: %d\n", error); + ena_log(pdev, ERR, "bus_dmamap_load failed: %d\n", error); goto fail_map_load; } @@ -321,7 +322,7 @@ ena_probe(device_t dev) while (ent->vendor_id != 0) { if ((pci_vendor_id == ent->vendor_id) && (pci_device_id == ent->device_id)) { - ena_trace(NULL, ENA_DBG, "vendor=%x device=%x\n", + ena_log_raw(DBG, "vendor=%x device=%x\n", pci_vendor_id, pci_device_id); sprintf(adapter_name, DEVICE_DESC); @@ -340,10 +341,11 @@ static int ena_change_mtu(if_t ifp, int new_mtu) { struct ena_adapter *adapter = if_getsoftc(ifp); + device_t pdev = adapter->pdev; int rc; if ((new_mtu > adapter->max_mtu) || (new_mtu < ENA_MIN_MTU)) { - device_printf(adapter->pdev, "Invalid MTU setting. " + 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); @@ -351,11 +353,10 @@ ena_change_mtu(if_t ifp, int new_mtu) rc = ena_com_set_dev_mtu(adapter->ena_dev, new_mtu); if (likely(rc == 0)) { - ena_trace(NULL, ENA_DBG, "set MTU to %d\n", new_mtu); + ena_log(pdev, DBG, "set MTU to %d\n", new_mtu); if_setmtu(ifp, new_mtu); } else { - device_printf(adapter->pdev, "Failed to set MTU to %d\n", - new_mtu); + ena_log(pdev, ERR, "Failed to set MTU to %d\n", new_mtu); } return (rc); @@ -623,6 +624,7 @@ ena_release_all_tx_dmamap(struct ena_ring *tx_ring) static int ena_setup_tx_resources(struct ena_adapter *adapter, int qid) { + device_t pdev = adapter->pdev; struct ena_que *que = &adapter->que[qid]; struct ena_ring *tx_ring = que->tx_ring; int size, i, err; @@ -672,7 +674,7 @@ ena_setup_tx_resources(struct ena_adapter *adapter, int qid) err = bus_dmamap_create(adapter->tx_buf_tag, 0, &tx_ring->tx_buffer_info[i].dmamap); if (unlikely(err != 0)) { - ena_trace(NULL, ENA_ALERT, + ena_log(pdev, ERR, "Unable to create Tx DMA map for buffer %d\n", i); goto err_map_release; @@ -685,7 +687,8 @@ ena_setup_tx_resources(struct ena_adapter *adapter, int qid) err = bus_dmamap_create(adapter->tx_buf_tag, 0, &map[j]); if (unlikely(err != 0)) { - ena_trace(NULL, ENA_ALERT, "Unable to create " + ena_log(pdev, ERR, + "Unable to create " "Tx DMA for buffer %d %d\n", i, j); goto err_map_release; } @@ -699,7 +702,7 @@ ena_setup_tx_resources(struct ena_adapter *adapter, int qid) tx_ring->enqueue_tq = taskqueue_create_fast("ena_tx_enque", M_NOWAIT, taskqueue_thread_enqueue, &tx_ring->enqueue_tq); if (unlikely(tx_ring->enqueue_tq == NULL)) { - ena_trace(NULL, ENA_ALERT, + ena_log(pdev, ERR, "Unable to create taskqueue for enqueue task\n"); i = tx_ring->ring_size; goto err_map_release; @@ -807,7 +810,7 @@ ena_setup_all_tx_resources(struct ena_adapter *adapter) for (i = 0; i < adapter->num_io_queues; i++) { rc = ena_setup_tx_resources(adapter, i); if (rc != 0) { - device_printf(adapter->pdev, + ena_log(adapter->pdev, ERR, "Allocation for Tx Queue %u failed\n", i); goto err_setup_tx; } @@ -847,6 +850,7 @@ ena_free_all_tx_resources(struct ena_adapter *adapter) static int ena_setup_rx_resources(struct ena_adapter *adapter, unsigned int qid) { + device_t pdev = adapter->pdev; struct ena_que *que = &adapter->que[qid]; struct ena_ring *rx_ring = que->rx_ring; int size, err, i; @@ -884,7 +888,7 @@ ena_setup_rx_resources(struct ena_adapter *adapter, unsigned int qid) err = bus_dmamap_create(adapter->rx_buf_tag, 0, &(rx_ring->rx_buffer_info[i].map)); if (err != 0) { - ena_trace(NULL, ENA_ALERT, + ena_log(pdev, ERR, "Unable to create Rx DMA map for buffer %d\n", i); goto err_buf_info_unmap; } @@ -894,11 +898,11 @@ ena_setup_rx_resources(struct ena_adapter *adapter, unsigned int qid) if ((adapter->ifp->if_capenable & IFCAP_LRO) != 0) { int err = tcp_lro_init(&rx_ring->lro); if (err != 0) { - device_printf(adapter->pdev, - "LRO[%d] Initialization failed!\n", qid); + ena_log(pdev, ERR, "LRO[%d] Initialization failed!\n", + qid); } else { - ena_trace(NULL, ENA_INFO, - "RX Soft LRO[%d] Initialized\n", qid); + ena_log(pdev, DBG, "RX Soft LRO[%d] Initialized\n", + qid); rx_ring->lro.ifp = adapter->ifp; } } @@ -967,7 +971,7 @@ ena_setup_all_rx_resources(struct ena_adapter *adapter) for (i = 0; i < adapter->num_io_queues; i++) { rc = ena_setup_rx_resources(adapter, i); if (rc != 0) { - device_printf(adapter->pdev, + ena_log(adapter->pdev, ERR, "Allocation for Rx Queue %u failed\n", i); goto err_setup_rx; } @@ -1000,6 +1004,7 @@ static inline int 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; bus_dma_segment_t segs[1]; int nsegs, error; @@ -1028,14 +1033,13 @@ 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_trace(NULL, ENA_DBG | ENA_RSC | ENA_RXPTH, - "Using tag %p for buffers' DMA mapping, mbuf %p len: %d\n", + 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))) { - ena_trace(NULL, ENA_WARNING, "failed to map mbuf, error: %d, " - "nsegs: %d\n", error, nsegs); + ena_log(pdev, WARN, + "failed to map mbuf, error: %d, nsegs: %d\n", error, nsegs); counter_u64_add(rx_ring->rx_stats.dma_mapping_err, 1); goto exit; @@ -1047,8 +1051,7 @@ ena_alloc_rx_mbuf(struct ena_adapter *adapter, ena_buf->paddr = segs[0].ds_addr; ena_buf->len = mlen; - ena_trace(NULL, ENA_DBG | ENA_RSC | ENA_RXPTH, - "ALLOC RX BUF: mbuf %p, rx_info %p, len %d, paddr %#jx\n", + 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); @@ -1065,7 +1068,8 @@ ena_free_rx_mbuf(struct ena_adapter *adapter, struct ena_ring *rx_ring, { if (rx_info->mbuf == NULL) { - ena_trace(NULL, ENA_WARNING, "Trying to free unallocated buffer\n"); + ena_log(adapter->pdev, WARN, + "Trying to free unallocated buffer\n"); return; } @@ -1086,20 +1090,20 @@ int ena_refill_rx_bufs(struct ena_ring *rx_ring, uint32_t num) { struct ena_adapter *adapter = rx_ring->adapter; + device_t pdev = adapter->pdev; uint16_t next_to_use, req_id; uint32_t i; int rc; - ena_trace(NULL, ENA_DBG | ENA_RXPTH | ENA_RSC, "refill qid: %d\n", - rx_ring->qid); + ena_log_io(adapter->pdev, DBG, "refill qid: %d\n", rx_ring->qid); next_to_use = rx_ring->next_to_use; for (i = 0; i < num; i++) { struct ena_rx_buffer *rx_info; - ena_trace(NULL, ENA_DBG | ENA_RXPTH | ENA_RSC, - "RX buffer - next to use: %d\n", next_to_use); + ena_log_io(pdev, DBG, "RX buffer - next to use: %d\n", + next_to_use); req_id = rx_ring->free_rx_ids[next_to_use]; rx_info = &rx_ring->rx_buffer_info[req_id]; @@ -1110,7 +1114,7 @@ ena_refill_rx_bufs(struct ena_ring *rx_ring, uint32_t num) #endif /* DEV_NETMAP */ rc = ena_alloc_rx_mbuf(adapter, rx_ring, rx_info); if (unlikely(rc != 0)) { - ena_trace(NULL, ENA_WARNING, + ena_log_io(pdev, WARN, "failed to alloc buffer for rx queue %d\n", rx_ring->qid); break; @@ -1118,7 +1122,7 @@ ena_refill_rx_bufs(struct ena_ring *rx_ring, uint32_t num) rc = ena_com_add_single_rx_desc(rx_ring->ena_com_io_sq, &rx_info->ena_buf, req_id); if (unlikely(rc != 0)) { - ena_trace(NULL, ENA_WARNING, + ena_log_io(pdev, WARN, "failed to add buffer for rx queue %d\n", rx_ring->qid); break; @@ -1129,7 +1133,7 @@ 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_trace(NULL, ENA_WARNING, + ena_log_io(pdev, WARN, "refilled rx qid %d with only %d mbufs (from %d)\n", rx_ring->qid, i, num); } @@ -1169,7 +1173,7 @@ ena_update_buf_ring_size(struct ena_adapter *adapter, */ rc = ena_up(adapter); if (unlikely(rc != 0)) { - device_printf(adapter->pdev, + ena_log(adapter->pdev, ERR, "Failed to configure device after setting new drbr size: %u. Reverting old value: %u and triggering the reset\n", new_buf_ring_size, old_buf_ring_size); @@ -1213,7 +1217,7 @@ ena_update_queue_size(struct ena_adapter *adapter, uint32_t new_tx_size, if (dev_was_up) { rc = ena_up(adapter); if (unlikely(rc != 0)) { - device_printf(adapter->pdev, + ena_log(adapter->pdev, ERR, "Failed to configure device with the new sizes - Tx: %u Rx: %u. Reverting old values - Tx: %u Rx: %u\n", new_tx_size, new_rx_size, old_tx_size, old_rx_size); @@ -1225,7 +1229,7 @@ ena_update_queue_size(struct ena_adapter *adapter, uint32_t new_tx_size, /* And try again. */ rc = ena_up(adapter); if (unlikely(rc != 0)) { - device_printf(adapter->pdev, + ena_log(adapter->pdev, ERR, "Failed to revert old queue sizes. Triggering device reset.\n"); /* * If we've failed again, something had to go @@ -1275,7 +1279,7 @@ ena_update_io_queue_nb(struct ena_adapter *adapter, uint32_t new_num) if (dev_was_up) { rc = ena_up(adapter); if (unlikely(rc != 0)) { - device_printf(adapter->pdev, + ena_log(adapter->pdev, ERR, "Failed to configure device with %u IO queues. " "Reverting to previous value: %u\n", new_num, old_num); @@ -1284,7 +1288,7 @@ ena_update_io_queue_nb(struct ena_adapter *adapter, uint32_t new_num) rc = ena_up(adapter); if (unlikely(rc != 0)) { - device_printf(adapter->pdev, + ena_log(adapter->pdev, ERR, "Failed to revert to previous setup IO " "queues. Triggering device reset.\n"); ENA_FLAG_SET_ATOMIC( @@ -1338,7 +1342,8 @@ ena_refill_all_rx_bufs(struct ena_adapter *adapter) bufs_num = rx_ring->ring_size - 1; rc = ena_refill_rx_bufs(rx_ring, bufs_num); if (unlikely(rc != bufs_num)) - ena_trace(NULL, ENA_WARNING, "refilling Queue %d failed. " + ena_log_io(adapter->pdev, WARN, + "refilling Queue %d failed. " "Allocated %d buffers from: %d\n", i, rc, bufs_num); #ifdef DEV_NETMAP rx_ring->initialized = true; @@ -1374,12 +1379,12 @@ ena_free_tx_bufs(struct ena_adapter *adapter, unsigned int qid) continue; if (print_once) { - device_printf(adapter->pdev, + ena_log(adapter->pdev, WARN, "free uncompleted tx mbuf qid %d idx 0x%x\n", qid, i); print_once = false; } else { - ena_trace(NULL, ENA_DBG, + ena_log(adapter->pdev, DBG, "free uncompleted tx mbuf qid %d idx 0x%x\n", qid, i); } @@ -1467,7 +1472,7 @@ ena_create_io_queues(struct ena_adapter *adapter) ctx.qid = ena_qid; rc = ena_com_create_io_queue(ena_dev, &ctx); if (rc != 0) { - device_printf(adapter->pdev, + ena_log(adapter->pdev, ERR, "Failed to create io TX queue #%d rc: %d\n", i, rc); goto err_tx; } @@ -1476,7 +1481,7 @@ ena_create_io_queues(struct ena_adapter *adapter) &ring->ena_com_io_sq, &ring->ena_com_io_cq); if (rc != 0) { - device_printf(adapter->pdev, + ena_log(adapter->pdev, ERR, "Failed to get TX queue handlers. TX queue num" " %d rc: %d\n", i, rc); ena_com_destroy_io_queue(ena_dev, ena_qid); @@ -1495,7 +1500,7 @@ ena_create_io_queues(struct ena_adapter *adapter) ctx.qid = ena_qid; rc = ena_com_create_io_queue(ena_dev, &ctx); if (unlikely(rc != 0)) { - device_printf(adapter->pdev, + ena_log(adapter->pdev, ERR, "Failed to create io RX queue[%d] rc: %d\n", i, rc); goto err_rx; } @@ -1505,7 +1510,7 @@ ena_create_io_queues(struct ena_adapter *adapter) &ring->ena_com_io_sq, &ring->ena_com_io_cq); if (unlikely(rc != 0)) { - device_printf(adapter->pdev, + ena_log(adapter->pdev, ERR, "Failed to get RX queue handlers. RX queue num" " %d rc: %d\n", i, rc); ena_com_destroy_io_queue(ena_dev, ena_qid); @@ -1585,7 +1590,7 @@ ena_enable_msix(struct ena_adapter *adapter) int i, rc = 0; if (ENA_FLAG_ISSET(ENA_FLAG_MSIX_ENABLED, adapter)) { - device_printf(dev, "Error, MSI-X is already enabled\n"); + ena_log(dev, ERR, "Error, MSI-X is already enabled\n"); return (EINVAL); } @@ -1595,7 +1600,8 @@ ena_enable_msix(struct ena_adapter *adapter) adapter->msix_entries = malloc(msix_vecs * sizeof(struct msix_entry), M_DEVBUF, M_WAITOK | M_ZERO); - ena_trace(NULL, ENA_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; @@ -1606,7 +1612,7 @@ ena_enable_msix(struct ena_adapter *adapter) msix_req = msix_vecs; rc = pci_alloc_msix(dev, &msix_vecs); if (unlikely(rc != 0)) { - device_printf(dev, + ena_log(dev, ERR, "Failed to enable MSIX, vectors %d rc %d\n", msix_vecs, rc); rc = ENOSPC; @@ -1615,14 +1621,14 @@ ena_enable_msix(struct ena_adapter *adapter) if (msix_vecs != msix_req) { if (msix_vecs == ENA_ADMIN_MSIX_VEC) { - device_printf(dev, + ena_log(dev, ERR, "Not enough number of MSI-x allocated: %d\n", msix_vecs); pci_release_msi(dev); rc = ENOSPC; goto err_msix_free; } - device_printf(dev, "Enable only %d MSI-x (out of %d), reduce " + ena_log(dev, ERR, "Enable only %d MSI-x (out of %d), reduce " "the number of queues\n", msix_vecs, msix_req); } @@ -1673,7 +1679,7 @@ ena_setup_io_intr(struct ena_adapter *adapter) adapter->irq_tbl[irq_idx].data = &adapter->que[i]; adapter->irq_tbl[irq_idx].vector = adapter->msix_entries[irq_idx].vector; - ena_trace(NULL, ENA_INFO | ENA_IOQ, "ena_setup_io_intr vector: %d\n", + ena_log(adapter->pdev, DBG, "ena_setup_io_intr vector: %d\n", adapter->msix_entries[irq_idx].vector); /* @@ -1693,6 +1699,7 @@ ena_setup_io_intr(struct ena_adapter *adapter) static int ena_request_mgmnt_irq(struct ena_adapter *adapter) { + device_t pdev = adapter->pdev; struct ena_irq *irq; unsigned long flags; int rc, rcc; @@ -1704,8 +1711,8 @@ ena_request_mgmnt_irq(struct ena_adapter *adapter) &irq->vector, flags); if (unlikely(irq->res == NULL)) { - device_printf(adapter->pdev, "could not allocate " - "irq vector: %d\n", irq->vector); + ena_log(pdev, ERR, "could not allocate irq vector: %d\n", + irq->vector); return (ENXIO); } @@ -1713,7 +1720,7 @@ ena_request_mgmnt_irq(struct ena_adapter *adapter) INTR_TYPE_NET | INTR_MPSAFE, NULL, ena_intr_msix_mgmnt, irq->data, &irq->cookie); if (unlikely(rc != 0)) { - device_printf(adapter->pdev, "failed to register " + ena_log(pdev, ERR, "failed to register " "interrupt handler for irq %ju: %d\n", rman_get_start(irq->res), rc); goto err_res_free; @@ -1723,12 +1730,11 @@ ena_request_mgmnt_irq(struct ena_adapter *adapter) return (rc); err_res_free: - ena_trace(NULL, ENA_INFO | ENA_ADMQ, "releasing resource for irq %d\n", - irq->vector); + 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); if (unlikely(rcc != 0)) - device_printf(adapter->pdev, "dev has no parent while " + ena_log(pdev, ERR, "dev has no parent while " "releasing res for irq: %d\n", irq->vector); irq->res = NULL; @@ -1738,12 +1744,13 @@ err_res_free: static int ena_request_io_irq(struct ena_adapter *adapter) { + device_t pdev = adapter->pdev; struct ena_irq *irq; unsigned long flags = 0; int rc = 0, i, rcc; if (unlikely(!ENA_FLAG_ISSET(ENA_FLAG_MSIX_ENABLED, adapter))) { - device_printf(adapter->pdev, + ena_log(pdev, ERR, "failed to request I/O IRQ: MSI-X is not enabled\n"); return (EINVAL); } else { @@ -1760,8 +1767,8 @@ ena_request_io_irq(struct ena_adapter *adapter) &irq->vector, flags); if (unlikely(irq->res == NULL)) { rc = ENOMEM; - device_printf(adapter->pdev, "could not allocate " - "irq vector: %d\n", irq->vector); + ena_log(pdev, ERR, "could not allocate irq vector: %d\n", + irq->vector); goto err; } @@ -1769,15 +1776,12 @@ ena_request_io_irq(struct ena_adapter *adapter) INTR_TYPE_NET | INTR_MPSAFE, irq->handler, NULL, irq->data, &irq->cookie); if (unlikely(rc != 0)) { - device_printf(adapter->pdev, "failed to register " + ena_log(pdev, ERR, "failed to register " "interrupt handler for irq %ju: %d\n", rman_get_start(irq->res), rc); goto err; } irq->requested = true; - - ena_trace(NULL, ENA_INFO, "queue %d - cpu %d\n", - i - ENA_IO_IRQ_FIRST_IDX, irq->cpu); } return (rc); @@ -1793,8 +1797,8 @@ err: if (irq->requested) rcc = bus_teardown_intr(adapter->pdev, irq->res, irq->cookie); if (unlikely(rcc != 0)) - device_printf(adapter->pdev, "could not release" - " irq: %d, error: %d\n", irq->vector, rcc); + ena_log(pdev, ERR, "could not release irq: %d, error: %d\n", + irq->vector, rcc); /* If we entred err: section without irq->requested set we know it was bus_alloc_resource_any() that needs cleanup, provided @@ -1806,7 +1810,7 @@ err: irq->vector, irq->res); } if (unlikely(rcc != 0)) - device_printf(adapter->pdev, "dev has no parent while " + ena_log(pdev, ERR, "dev has no parent while " "releasing res for irq: %d\n", irq->vector); irq->requested = false; irq->res = NULL; @@ -1818,28 +1822,27 @@ err: static void ena_free_mgmnt_irq(struct ena_adapter *adapter) { + device_t pdev = adapter->pdev; struct ena_irq *irq; int rc; irq = &adapter->irq_tbl[ENA_MGMNT_IRQ_IDX]; if (irq->requested) { - ena_trace(NULL, ENA_INFO | ENA_ADMQ, "tear down irq: %d\n", - irq->vector); + ena_log(pdev, DBG, "tear down irq: %d\n", irq->vector); rc = bus_teardown_intr(adapter->pdev, irq->res, irq->cookie); if (unlikely(rc != 0)) - device_printf(adapter->pdev, "failed to tear " - "down irq: %d\n", irq->vector); + ena_log(pdev, ERR, "failed to tear down irq: %d\n", + irq->vector); irq->requested = 0; } if (irq->res != NULL) { - ena_trace(NULL, ENA_INFO | ENA_ADMQ, "release resource irq: %d\n", - irq->vector); + ena_log(pdev, DBG, "release resource irq: %d\n", irq->vector); rc = bus_release_resource(adapter->pdev, SYS_RES_IRQ, irq->vector, irq->res); irq->res = NULL; if (unlikely(rc != 0)) - device_printf(adapter->pdev, "dev has no parent while " + ena_log(pdev, ERR, "dev has no parent while " "releasing res for irq: %d\n", irq->vector); } } @@ -1847,31 +1850,31 @@ ena_free_mgmnt_irq(struct ena_adapter *adapter) static void ena_free_io_irq(struct ena_adapter *adapter) { + device_t pdev = adapter->pdev; struct ena_irq *irq; int rc; for (int i = ENA_IO_IRQ_FIRST_IDX; i < adapter->msix_vecs; i++) { irq = &adapter->irq_tbl[i]; if (irq->requested) { - ena_trace(NULL, ENA_INFO | ENA_IOQ, "tear down irq: %d\n", - irq->vector); + ena_log(pdev, DBG, "tear down irq: %d\n", irq->vector); rc = bus_teardown_intr(adapter->pdev, irq->res, irq->cookie); if (unlikely(rc != 0)) { - device_printf(adapter->pdev, "failed to tear " - "down irq: %d\n", irq->vector); + ena_log(pdev, ERR, "failed to tear down irq: %d\n", + irq->vector); } irq->requested = 0; } if (irq->res != NULL) { - ena_trace(NULL, ENA_INFO | ENA_IOQ, "release resource irq: %d\n", + ena_log(pdev, DBG, "release resource irq: %d\n", irq->vector); rc = bus_release_resource(adapter->pdev, SYS_RES_IRQ, irq->vector, irq->res); irq->res = NULL; if (unlikely(rc != 0)) { - device_printf(adapter->pdev, "dev has no parent" + ena_log(pdev, ERR, "dev has no parent" " while releasing res for irq: %d\n", irq->vector); } @@ -1930,7 +1933,7 @@ ena_rss_configure(struct ena_adapter *adapter) if (!ena_dev->rss.tbl_log_size) { rc = ena_rss_init_default(adapter); if (unlikely((rc != 0) && (rc != EOPNOTSUPP))) { - device_printf(adapter->pdev, + ena_log(adapter->pdev, ERR, "WARNING: RSS was not properly re-initialized," " it will affect bandwidth\n"); ENA_FLAG_CLEAR_ATOMIC(ENA_FLAG_RSS_ACTIVE, adapter); @@ -1964,7 +1967,7 @@ ena_up_complete(struct ena_adapter *adapter) if (likely(ENA_FLAG_ISSET(ENA_FLAG_RSS_ACTIVE, adapter))) { rc = ena_rss_configure(adapter); if (rc != 0) { - device_printf(adapter->pdev, + ena_log(adapter->pdev, ERR, "Failed to configure RSS\n"); return (rc); } @@ -1996,6 +1999,7 @@ set_io_rings_size(struct ena_adapter *adapter, int new_tx_size, static int create_queues_with_size_backoff(struct ena_adapter *adapter) { + device_t pdev = adapter->pdev; int rc; uint32_t cur_rx_ring_size, cur_tx_ring_size; uint32_t new_rx_ring_size, new_tx_ring_size; @@ -2011,21 +2015,21 @@ create_queues_with_size_backoff(struct ena_adapter *adapter) /* Allocate transmit descriptors */ rc = ena_setup_all_tx_resources(adapter); if (unlikely(rc != 0)) { - ena_trace(NULL, ENA_ALERT, "err_setup_tx\n"); + ena_log(pdev, ERR, "err_setup_tx\n"); goto err_setup_tx; } /* Allocate receive descriptors */ rc = ena_setup_all_rx_resources(adapter); if (unlikely(rc != 0)) { - ena_trace(NULL, ENA_ALERT, "err_setup_rx\n"); + ena_log(pdev, ERR, "err_setup_rx\n"); goto err_setup_rx; } /* Create IO queues for Rx & Tx */ rc = ena_create_io_queues(adapter); if (unlikely(rc != 0)) { - ena_trace(NULL, ENA_ALERT, + ena_log(pdev, ERR, "create IO queues failed\n"); goto err_io_que; } @@ -2042,7 +2046,7 @@ err_setup_tx: * error straightaway. */ if (unlikely(rc != ENOMEM)) { - ena_trace(NULL, ENA_ALERT, + ena_log(pdev, ERR, "Queue creation failed with error code: %d\n", rc); return (rc); } @@ -2050,7 +2054,7 @@ err_setup_tx: cur_tx_ring_size = adapter->tx_ring[0].ring_size; cur_rx_ring_size = adapter->rx_ring[0].ring_size; - device_printf(adapter->pdev, + ena_log(pdev, ERR, "Not enough memory to create queues with sizes TX=%d, RX=%d\n", cur_tx_ring_size, cur_rx_ring_size); @@ -2068,7 +2072,7 @@ err_setup_tx: if (new_tx_ring_size < ENA_MIN_RING_SIZE || new_rx_ring_size < ENA_MIN_RING_SIZE) { - device_printf(adapter->pdev, + ena_log(pdev, ERR, "Queue creation failed with the smallest possible queue size" "of %d for both queues. Not retrying with smaller queues\n", ENA_MIN_RING_SIZE); @@ -2085,28 +2089,28 @@ ena_up(struct ena_adapter *adapter) int rc = 0; if (unlikely(device_is_attached(adapter->pdev) == 0)) { - device_printf(adapter->pdev, "device is not attached!\n"); + ena_log(adapter->pdev, ERR, "device is not attached!\n"); return (ENXIO); } if (ENA_FLAG_ISSET(ENA_FLAG_DEV_UP, adapter)) return (0); - device_printf(adapter->pdev, "device is going UP\n"); + ena_log(adapter->pdev, INFO, "device is going UP\n"); /* setup interrupts for IO queues */ rc = ena_setup_io_intr(adapter); if (unlikely(rc != 0)) { - ena_trace(NULL, ENA_ALERT, "error setting up IO interrupt\n"); + ena_log(adapter->pdev, ERR, "error setting up IO interrupt\n"); goto error; } rc = ena_request_io_irq(adapter); if (unlikely(rc != 0)) { - ena_trace(NULL, ENA_ALERT, "err_req_irq\n"); + ena_log(adapter->pdev, ERR, "err_req_irq\n"); goto error; } - device_printf(adapter->pdev, + ena_log(adapter->pdev, INFO, "Creating %u IO queues. Rx queue size: %d, Tx queue size: %d, " "LLQ is %s\n", adapter->num_io_queues, @@ -2117,7 +2121,7 @@ ena_up(struct ena_adapter *adapter) rc = create_queues_with_size_backoff(adapter); if (unlikely(rc != 0)) { - ena_trace(NULL, ENA_ALERT, + ena_log(adapter->pdev, ERR, "error creating queues with size backoff\n"); goto err_create_queues_with_backoff; } @@ -2199,7 +2203,7 @@ static void ena_media_status(if_t ifp, struct ifmediareq *ifmr) { struct ena_adapter *adapter = if_getsoftc(ifp); - ena_trace(NULL, ENA_DBG, "enter\n"); + ena_log(adapter->pdev, DBG, "Media status update\n"); ENA_LOCK_LOCK(adapter); @@ -2208,7 +2212,7 @@ ena_media_status(if_t ifp, struct ifmediareq *ifmr) if (!ENA_FLAG_ISSET(ENA_FLAG_LINK_UP, adapter)) { ENA_LOCK_UNLOCK(adapter); - ena_trace(NULL, ENA_INFO, "Link is down\n"); + ena_log(adapter->pdev, INFO, "Link is down\n"); return; } @@ -2262,7 +2266,7 @@ ena_ioctl(if_t ifp, u_long command, caddr_t data) if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) { if ((ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI)) != 0) { - device_printf(adapter->pdev, + ena_log(adapter->pdev, INFO, "ioctl promisc/allmulti\n"); } } else { @@ -2402,7 +2406,7 @@ ena_setup_ifnet(device_t pdev, struct ena_adapter *adapter, ifp = adapter->ifp = if_gethandle(IFT_ETHER); if (unlikely(ifp == NULL)) { - ena_trace(NULL, ENA_ALERT, "can not allocate ifnet structure\n"); + ena_log(pdev, ERR, "can not allocate ifnet structure\n"); return (ENXIO); } if_initname(ifp, device_get_name(pdev), device_get_unit(pdev)); @@ -2460,7 +2464,7 @@ ena_down(struct ena_adapter *adapter) if (!ENA_FLAG_ISSET(ENA_FLAG_DEV_UP, adapter)) return; - device_printf(adapter->pdev, "device is going DOWN\n"); + ena_log(adapter->pdev, INFO, "device is going DOWN\n"); callout_drain(&adapter->timer_service); @@ -2474,7 +2478,7 @@ ena_down(struct ena_adapter *adapter) rc = ena_com_dev_reset(adapter->ena_dev, adapter->reset_reason); if (unlikely(rc != 0)) - device_printf(adapter->pdev, + ena_log(adapter->pdev, ERR, "Device reset failed\n"); } @@ -2527,7 +2531,7 @@ ena_calc_max_io_queue_num(device_t pdev, struct ena_com_dev *ena_dev, } static int -ena_enable_wc(struct resource *res) +ena_enable_wc(device_t pdev, struct resource *res) { #if defined(__i386) || defined(__amd64) || defined(__aarch64__) vm_offset_t va; @@ -2539,7 +2543,7 @@ ena_enable_wc(struct resource *res) /* Enable write combining */ rc = pmap_change_attr(va, len, VM_MEMATTR_WRITE_COMBINING); if (unlikely(rc != 0)) { - ena_trace(NULL, ENA_ALERT, "pmap_change_attr failed, %d\n", rc); + ena_log(pdev, ERR, "pmap_change_attr failed, %d\n", rc); return (rc); } @@ -2559,7 +2563,7 @@ ena_set_queues_placement_policy(device_t pdev, struct ena_com_dev *ena_dev, llq_feature_mask = 1 << ENA_ADMIN_LLQ; if (!(ena_dev->supported_features & llq_feature_mask)) { - device_printf(pdev, + ena_log(pdev, WARN, "LLQ is not supported. Fallback to host mode policy.\n"); ena_dev->tx_mem_queue_type = ENA_ADMIN_PLACEMENT_POLICY_HOST; return (0); @@ -2567,7 +2571,7 @@ ena_set_queues_placement_policy(device_t pdev, struct ena_com_dev *ena_dev, rc = ena_com_config_dev_mode(ena_dev, llq, llq_default_configurations); if (unlikely(rc != 0)) { - device_printf(pdev, "Failed to configure the device mode. " + ena_log(pdev, WARN, "Failed to configure the device mode. " "Fallback to host mode policy.\n"); ena_dev->tx_mem_queue_type = ENA_ADMIN_PLACEMENT_POLICY_HOST; return (0); @@ -2582,16 +2586,16 @@ ena_set_queues_placement_policy(device_t pdev, struct ena_com_dev *ena_dev, adapter->memory = bus_alloc_resource_any(pdev, SYS_RES_MEMORY, &rid, RF_ACTIVE); if (unlikely(adapter->memory == NULL)) { - device_printf(pdev, "unable to allocate LLQ bar resource. " + ena_log(pdev, WARN, "unable to allocate LLQ bar resource. " "Fallback to host mode policy.\n"); ena_dev->tx_mem_queue_type = ENA_ADMIN_PLACEMENT_POLICY_HOST; return (0); } /* Enable write combining for better LLQ performance */ - rc = ena_enable_wc(adapter->memory); + rc = ena_enable_wc(adapter->pdev, adapter->memory); if (unlikely(rc != 0)) { - device_printf(pdev, "failed to enable write combining.\n"); + ena_log(pdev, ERR, "failed to enable write combining.\n"); return (rc); } @@ -2693,11 +2697,11 @@ ena_calc_io_queue_size(struct ena_calc_queue_size_ctx *ctx) ena_dev->tx_mem_queue_type == ENA_ADMIN_PLACEMENT_POLICY_DEV) { max_tx_queue_size /= 2; - device_printf(ctx->pdev, + ena_log(ctx->pdev, INFO, "Forcing large headers and decreasing maximum Tx queue size to %d\n", max_tx_queue_size); } else { - device_printf(ctx->pdev, + ena_log(ctx->pdev, WARN, "Forcing large headers failed: LLQ is disabled or device does not support large headers\n"); } } @@ -2727,7 +2731,7 @@ ena_rss_init_default(struct ena_adapter *adapter) rc = ena_com_rss_init(ena_dev, ENA_RX_RSS_TABLE_LOG_SIZE); if (unlikely(rc != 0)) { - device_printf(dev, "Cannot init indirect table\n"); + ena_log(dev, ERR, "Cannot init indirect table\n"); return (rc); } @@ -2736,7 +2740,7 @@ ena_rss_init_default(struct ena_adapter *adapter) rc = ena_com_indirect_table_fill_entry(ena_dev, i, ENA_IO_RXQ_IDX(qid)); if (unlikely((rc != 0) && (rc != EOPNOTSUPP))) { - device_printf(dev, "Cannot fill indirect table\n"); + ena_log(dev, ERR, "Cannot fill indirect table\n"); goto err_rss_destroy; } } @@ -2754,13 +2758,13 @@ ena_rss_init_default(struct ena_adapter *adapter) rc = ena_com_fill_hash_function(ena_dev, ENA_ADMIN_CRC32, NULL, ENA_HASH_KEY_SIZE, 0xFFFFFFFF); if (unlikely((rc != 0) && (rc != EOPNOTSUPP))) { - device_printf(dev, "Cannot fill hash function\n"); + ena_log(dev, ERR, "Cannot fill hash function\n"); goto err_rss_destroy; } rc = ena_com_set_default_hash_ctrl(ena_dev); if (unlikely((rc != 0) && (rc != EOPNOTSUPP))) { - device_printf(dev, "Cannot fill hash control\n"); + ena_log(dev, ERR, "Cannot fill hash control\n"); goto err_rss_destroy; } @@ -2781,7 +2785,7 @@ ena_rss_init_default_deferred(void *arg) dc = devclass_find("ena"); if (unlikely(dc == NULL)) { - ena_trace(NULL, ENA_ALERT, "No devclass ena\n"); + ena_log_raw(ERR, "SYSINIT: %s: No devclass ena\n", __func__); return; } @@ -2792,7 +2796,7 @@ ena_rss_init_default_deferred(void *arg) rc = ena_rss_init_default(adapter); ENA_FLAG_SET_ATOMIC(ENA_FLAG_RSS_ACTIVE, adapter); if (unlikely(rc != 0)) { - device_printf(adapter->pdev, + ena_log(adapter->pdev, WARN, "WARNING: RSS was not properly initialized," " it will affect bandwidth\n"); ENA_FLAG_CLEAR_ATOMIC(ENA_FLAG_RSS_ACTIVE, adapter); @@ -2812,7 +2816,7 @@ ena_config_host_info(struct ena_com_dev *ena_dev, device_t dev) /* Allocate only the host info */ rc = ena_com_allocate_host_info(ena_dev); if (unlikely(rc != 0)) { - ena_trace(NULL, ENA_ALERT, "Cannot allocate host info\n"); + ena_log(dev, ERR, "Cannot allocate host info\n"); return; } @@ -2839,9 +2843,9 @@ ena_config_host_info(struct ena_com_dev *ena_dev, device_t dev) rc = ena_com_set_host_attributes(ena_dev); if (unlikely(rc != 0)) { if (rc == EOPNOTSUPP) - ena_trace(NULL, ENA_WARNING, "Cannot set host attributes\n"); + ena_log(dev, WARN, "Cannot set host attributes\n"); else - ena_trace(NULL, ENA_ALERT, "Cannot set host attributes\n"); + ena_log(dev, ERR, "Cannot set host attributes\n"); goto err; } @@ -2864,7 +2868,7 @@ ena_device_init(struct ena_adapter *adapter, device_t pdev, rc = ena_com_mmio_reg_read_request_init(ena_dev); if (unlikely(rc != 0)) { - device_printf(pdev, "failed to init mmio read less\n"); + ena_log(pdev, ERR, "failed to init mmio read less\n"); return (rc); } @@ -2877,19 +2881,19 @@ ena_device_init(struct ena_adapter *adapter, device_t pdev, rc = ena_com_dev_reset(ena_dev, ENA_REGS_RESET_NORMAL); if (unlikely(rc != 0)) { - device_printf(pdev, "Can not reset device\n"); + ena_log(pdev, ERR, "Can not reset device\n"); goto err_mmio_read_less; } rc = ena_com_validate_version(ena_dev); if (unlikely(rc != 0)) { - device_printf(pdev, "device version is too low\n"); + ena_log(pdev, ERR, "device version is too low\n"); goto err_mmio_read_less; } dma_width = ena_com_get_dma_width(ena_dev); if (unlikely(dma_width < 0)) { - device_printf(pdev, "Invalid dma width value %d", dma_width); + ena_log(pdev, ERR, "Invalid dma width value %d", dma_width); rc = dma_width; goto err_mmio_read_less; } @@ -2898,7 +2902,7 @@ ena_device_init(struct ena_adapter *adapter, device_t pdev, /* ENA admin level init */ rc = ena_com_admin_init(ena_dev, &aenq_handlers); if (unlikely(rc != 0)) { - device_printf(pdev, + ena_log(pdev, ERR, "Can not initialize ena admin queue with device\n"); goto err_mmio_read_less; } @@ -2915,7 +2919,7 @@ ena_device_init(struct ena_adapter *adapter, device_t pdev, /* Get Device Attributes */ rc = ena_com_get_dev_attr_feat(ena_dev, get_feat_ctx); if (unlikely(rc != 0)) { - device_printf(pdev, + ena_log(pdev, ERR, "Cannot get attribute for ena device rc: %d\n", rc); goto err_admin_init; } @@ -2929,7 +2933,7 @@ ena_device_init(struct ena_adapter *adapter, device_t pdev, aenq_groups &= get_feat_ctx->aenq.supported_groups; rc = ena_com_set_aenq_config(ena_dev, aenq_groups); if (unlikely(rc != 0)) { - device_printf(pdev, "Cannot configure aenq groups rc: %d\n", rc); + ena_log(pdev, ERR, "Cannot configure aenq groups rc: %d\n", rc); goto err_admin_init; } @@ -2953,7 +2957,7 @@ static int ena_enable_msix_and_set_admin_interrupts(struct ena_adapter *adapter) rc = ena_enable_msix(adapter); if (unlikely(rc != 0)) { - device_printf(adapter->pdev, "Error with MSI-X enablement\n"); + ena_log(adapter->pdev, ERR, "Error with MSI-X enablement\n"); return (rc); } @@ -2961,7 +2965,7 @@ static int ena_enable_msix_and_set_admin_interrupts(struct ena_adapter *adapter) rc = ena_request_mgmnt_irq(adapter); if (unlikely(rc != 0)) { - device_printf(adapter->pdev, "Cannot setup mgmnt queue intr\n"); + ena_log(adapter->pdev, ERR, "Cannot setup mgmnt queue intr\n"); goto err_disable_msix; } @@ -3014,8 +3018,7 @@ static void check_for_missing_keep_alive(struct ena_adapter *adapter) timestamp = atomic_load_acq_64(&adapter->keep_alive_timestamp); time = getsbinuptime() - timestamp; if (unlikely(time > adapter->keep_alive_timeout)) { - device_printf(adapter->pdev, - "Keep alive watchdog timeout.\n"); + ena_log(adapter->pdev, ERR, "Keep alive watchdog timeout.\n"); counter_u64_add(adapter->dev_stats.wd_expired, 1); ena_trigger_reset(adapter, ENA_REGS_RESET_KEEP_ALIVE_TO); } @@ -3026,7 +3029,7 @@ static void check_for_admin_com_state(struct ena_adapter *adapter) { if (unlikely(ena_com_get_admin_running_state(adapter->ena_dev) == false)) { - device_printf(adapter->pdev, + ena_log(adapter->pdev, ERR, "ENA admin queue is not in running state!\n"); counter_u64_add(adapter->dev_stats.admin_q_pause, 1); ena_trigger_reset(adapter, ENA_REGS_RESET_ADMIN_TO); @@ -3046,7 +3049,7 @@ check_for_rx_interrupt_queue(struct ena_adapter *adapter, rx_ring->no_interrupt_event_cnt++; if (rx_ring->no_interrupt_event_cnt == ENA_MAX_NO_INTERRUPT_ITERATIONS) { - device_printf(adapter->pdev, "Potential MSIX issue on Rx side " + ena_log(adapter->pdev, ERR, "Potential MSIX issue on Rx side " "Queue = %d. Reset the device\n", rx_ring->qid); ena_trigger_reset(adapter, ENA_REGS_RESET_MISS_INTERRUPT); return (EIO); @@ -3059,6 +3062,7 @@ static int check_missing_comp_in_tx_queue(struct ena_adapter *adapter, struct ena_ring *tx_ring) { + device_t pdev = adapter->pdev; struct bintime curtime, time; struct ena_tx_buffer *tx_buf; sbintime_t time_offset; @@ -3083,7 +3087,7 @@ check_missing_comp_in_tx_queue(struct ena_adapter *adapter, * If after graceful period interrupt is still not * received, we schedule a reset. */ - device_printf(adapter->pdev, + ena_log(pdev, ERR, "Potential MSIX issue on Tx side Queue = %d. " "Reset the device\n", tx_ring->qid); ena_trigger_reset(adapter, @@ -3095,7 +3099,7 @@ check_missing_comp_in_tx_queue(struct ena_adapter *adapter, if (unlikely(time_offset > adapter->missing_tx_timeout)) { if (!tx_buf->print_once) - ena_trace(NULL, ENA_WARNING, "Found a Tx that wasn't " + ena_log(pdev, WARN, "Found a Tx that wasn't " "completed on time, qid %d, index %d.\n", tx_ring->qid, i); @@ -3105,7 +3109,7 @@ check_missing_comp_in_tx_queue(struct ena_adapter *adapter, } if (unlikely(missed_tx > adapter->missing_tx_threshold)) { - device_printf(adapter->pdev, + ena_log(pdev, ERR, "The number of lost tx completion is above the threshold " "(%d > %d). Reset the device\n", missed_tx, adapter->missing_tx_threshold); @@ -3202,8 +3206,9 @@ check_for_empty_rx_ring(struct ena_adapter *adapter) counter_u64_add(rx_ring->rx_stats.empty_rx_ring, 1); - device_printf(adapter->pdev, - "trigger refill for ring %d\n", i); + ena_log(adapter->pdev, WARN, + "Rx ring %d is stalled. Triggering the refill function\n", + i); taskqueue_enqueue(rx_ring->que->cleanup_tq, &rx_ring->que->cleanup_task); @@ -3273,15 +3278,15 @@ ena_copy_eni_metrics(struct ena_adapter *adapter) if (rc != 0) { if (rc == ENA_COM_UNSUPPORTED) { if (print_once) { - device_printf(adapter->pdev, + ena_log(adapter->pdev, WARN, "Retrieving ENI metrics is not supported.\n"); print_once = false; } else { - ena_trace(NULL, ENA_DBG, + ena_log(adapter->pdev, DBG, "Retrieving ENI metrics is not supported.\n"); } } else { - device_printf(adapter->pdev, + ena_log(adapter->pdev, ERR, "Failed to get ENI metrics: %d\n", rc); } } @@ -3340,7 +3345,7 @@ ena_timer_service(void *data) ena_update_host_info(host_info, adapter->ifp); if (unlikely(ENA_FLAG_ISSET(ENA_FLAG_TRIGGER_RESET, adapter))) { - device_printf(adapter->pdev, "Trigger reset is on\n"); + ena_log(adapter->pdev, WARN, "Trigger reset is on\n"); taskqueue_enqueue(adapter->reset_tq, &adapter->reset_task); return; } @@ -3416,13 +3421,12 @@ ena_device_validate_params(struct ena_adapter *adapter, if (memcmp(get_feat_ctx->dev_attr.mac_addr, adapter->mac_addr, ETHER_ADDR_LEN) != 0) { - device_printf(adapter->pdev, - "Error, mac address are different\n"); + ena_log(adapter->pdev, ERR, "Error, mac addresses differ\n"); return (EINVAL); } if (get_feat_ctx->dev_attr.max_mtu < if_getmtu(adapter->ifp)) { - device_printf(adapter->pdev, + ena_log(adapter->pdev, ERR, "Error, device max mtu is smaller than ifp MTU\n"); return (EINVAL); } @@ -3444,7 +3448,7 @@ ena_restore_device(struct ena_adapter *adapter) rc = ena_device_init(adapter, dev, &get_feat_ctx, &wd_active); if (rc != 0) { - device_printf(dev, "Cannot initialize device\n"); + ena_log(dev, ERR, "Cannot initialize device\n"); goto err; } /* @@ -3456,7 +3460,7 @@ ena_restore_device(struct ena_adapter *adapter) rc = ena_device_validate_params(adapter, &get_feat_ctx); if (rc != 0) { - device_printf(dev, "Validation of device parameters failed\n"); + ena_log(dev, ERR, "Validation of device parameters failed\n"); goto err_device_destroy; } @@ -3467,7 +3471,7 @@ ena_restore_device(struct ena_adapter *adapter) rc = ena_enable_msix_and_set_admin_interrupts(adapter); if (rc != 0) { - device_printf(dev, "Enable MSI-X failed\n"); + ena_log(dev, ERR, "Enable MSI-X failed\n"); goto err_device_destroy; } @@ -3487,7 +3491,7 @@ ena_restore_device(struct ena_adapter *adapter) if (ENA_FLAG_ISSET(ENA_FLAG_DEV_UP_BEFORE_RESET, adapter)) { rc = ena_up(adapter); if (rc != 0) { - device_printf(dev, "Failed to create I/O queues\n"); + ena_log(dev, ERR, "Failed to create I/O queues\n"); goto err_disable_msix; } } @@ -3508,7 +3512,7 @@ ena_restore_device(struct ena_adapter *adapter) } ENA_FLAG_CLEAR_ATOMIC(ENA_FLAG_DEV_UP_BEFORE_RESET, adapter); - device_printf(dev, + ena_log(dev, INFO, "Device reset completed successfully, Driver info: %s\n", ena_version); return (rc); @@ -3525,7 +3529,7 @@ err_device_destroy: err: ENA_FLAG_CLEAR_ATOMIC(ENA_FLAG_DEVICE_RUNNING, adapter); ENA_FLAG_CLEAR_ATOMIC(ENA_FLAG_ONGOING_RESET, adapter); - device_printf(dev, "Reset attempt failed. Can not reset the device\n"); + ena_log(dev, ERR, "Reset attempt failed. Can not reset the device\n"); return (rc); } @@ -3536,7 +3540,7 @@ ena_reset_task(void *arg, int pending) struct ena_adapter *adapter = (struct ena_adapter *)arg; if (unlikely(!ENA_FLAG_ISSET(ENA_FLAG_TRIGGER_RESET, adapter))) { - device_printf(adapter->pdev, + ena_log(adapter->pdev, WARN, "device reset scheduled but trigger_reset is off\n"); return; } @@ -3586,7 +3590,7 @@ ena_attach(device_t pdev) adapter->missing_tx_threshold = DEFAULT_TX_CMP_THRESHOLD; if (version_printed++ == 0) - device_printf(pdev, "%s\n", ena_version); + ena_log(pdev, INFO, "%s\n", ena_version); /* Allocate memory for ena_dev structure */ ena_dev = malloc(sizeof(struct ena_com_dev), M_DEVBUF, @@ -3600,7 +3604,7 @@ ena_attach(device_t pdev) adapter->registers = bus_alloc_resource_any(pdev, SYS_RES_MEMORY, &rid, RF_ACTIVE); if (unlikely(adapter->registers == NULL)) { - device_printf(pdev, + ena_log(pdev, ERR, "unable to allocate bus resource: registers!\n"); rc = ENOMEM; goto err_dev_free; @@ -3612,7 +3616,7 @@ ena_attach(device_t pdev) adapter->msix = bus_alloc_resource_any(pdev, SYS_RES_MEMORY, &msix_rid, RF_ACTIVE); if (unlikely(adapter->msix == NULL)) { - device_printf(pdev, + ena_log(pdev, ERR, "unable to allocate bus resource: msix!\n"); rc = ENOMEM; goto err_pci_free; @@ -3630,7 +3634,7 @@ ena_attach(device_t pdev) rman_get_bushandle(adapter->registers); if (unlikely(((struct ena_bus*)(ena_dev->bus))->reg_bar_h == 0)) { - device_printf(pdev, "failed to pmap registers bar\n"); + ena_log(pdev, ERR, "failed to pmap registers bar\n"); rc = ENXIO; goto err_bus_free; } @@ -3643,7 +3647,7 @@ ena_attach(device_t pdev) /* Device initialization */ rc = ena_device_init(adapter, pdev, &get_feat_ctx, &adapter->wd_active); if (unlikely(rc != 0)) { - device_printf(pdev, "ENA device init failed! (err: %d)\n", rc); + ena_log(pdev, ERR, "ENA device init failed! (err: %d)\n", rc); rc = ENXIO; goto err_bus_free; } @@ -3653,7 +3657,7 @@ ena_attach(device_t pdev) rc = ena_set_queues_placement_policy(pdev, ena_dev, &get_feat_ctx.llq, &llq_config); if (unlikely(rc != 0)) { - device_printf(pdev, "failed to set placement policy\n"); + ena_log(pdev, ERR, "failed to set placement policy\n"); goto err_com_free; } @@ -3700,13 +3704,13 @@ ena_attach(device_t pdev) /* set up dma tags for rx and tx buffers */ rc = ena_setup_tx_dma_tag(adapter); if (unlikely(rc != 0)) { - device_printf(pdev, "Failed to create TX DMA tag\n"); + ena_log(pdev, ERR, "Failed to create TX DMA tag\n"); goto err_com_free; } rc = ena_setup_rx_dma_tag(adapter); if (unlikely(rc != 0)) { - device_printf(pdev, "Failed to create RX DMA tag\n"); + ena_log(pdev, ERR, "Failed to create RX DMA tag\n"); goto err_tx_tag_free; } @@ -3721,7 +3725,7 @@ ena_attach(device_t pdev) */ rc = ena_enable_msix_and_set_admin_interrupts(adapter); if (unlikely(rc != 0)) { - device_printf(pdev, + ena_log(pdev, ERR, "Failed to enable and set the admin interrupts\n"); goto err_io_free; } @@ -3734,7 +3738,7 @@ ena_attach(device_t pdev) /* setup network interface */ rc = ena_setup_ifnet(pdev, adapter, &get_feat_ctx); if (unlikely(rc != 0)) { - device_printf(pdev, "Error with network interface setup\n"); + ena_log(pdev, ERR, "Error with network interface setup\n"); goto err_msix_free; } @@ -3755,7 +3759,7 @@ ena_attach(device_t pdev) #ifdef DEV_NETMAP rc = ena_netmap_attach(adapter); if (rc != 0) { - device_printf(pdev, "netmap attach failed: %d\n", rc); + ena_log(pdev, ERR, "netmap attach failed: %d\n", rc); goto err_detach; } #endif /* DEV_NETMAP */ @@ -3809,7 +3813,7 @@ ena_detach(device_t pdev) /* Make sure VLANS are not using driver */ if (adapter->ifp->if_vlantrunk != NULL) { - device_printf(adapter->pdev ,"VLAN is in use, detach first\n"); + ena_log(adapter->pdev, ERR, "VLAN is in use, detach first\n"); return (EBUSY); } @@ -3845,12 +3849,12 @@ ena_detach(device_t pdev) rc = ena_free_rx_dma_tag(adapter); if (unlikely(rc != 0)) - device_printf(adapter->pdev, + ena_log(adapter->pdev, WARN, "Unmapped RX DMA tag associations\n"); rc = ena_free_tx_dma_tag(adapter); if (unlikely(rc != 0)) - device_printf(adapter->pdev, + ena_log(adapter->pdev, WARN, "Unmapped TX DMA tag associations\n"); ena_free_irqs(adapter); @@ -3895,12 +3899,12 @@ ena_update_on_link_change(void *adapter_data, ENA_ADMIN_AENQ_LINK_CHANGE_DESC_LINK_STATUS_MASK; if (status != 0) { - device_printf(adapter->pdev, "link is UP\n"); + ena_log(adapter->pdev, INFO, "link is UP\n"); ENA_FLAG_SET_ATOMIC(ENA_FLAG_LINK_UP, adapter); if (!ENA_FLAG_ISSET(ENA_FLAG_ONGOING_RESET, adapter)) if_link_state_change(ifp, LINK_STATE_UP); } else { - device_printf(adapter->pdev, "link is DOWN\n"); + ena_log(adapter->pdev, INFO, "link is DOWN\n"); if_link_state_change(ifp, LINK_STATE_DOWN); ENA_FLAG_CLEAR_ATOMIC(ENA_FLAG_LINK_UP, adapter); } @@ -3912,7 +3916,7 @@ static void ena_notification(void *adapter_data, struct ena_adapter *adapter = (struct ena_adapter *)adapter_data; struct ena_admin_ena_hw_hints *hints; - ENA_WARN(NULL, aenq_e->aenq_common_desc.group != ENA_ADMIN_NOTIFICATION, + ENA_WARN(aenq_e->aenq_common_desc.group != ENA_ADMIN_NOTIFICATION, adapter->ena_dev, "Invalid group(%x) expected %x\n", aenq_e->aenq_common_desc.group, ENA_ADMIN_NOTIFICATION); @@ -3923,7 +3927,7 @@ static void ena_notification(void *adapter_data, ena_update_hints(adapter, hints); break; default: - device_printf(adapter->pdev, + ena_log(adapter->pdev, ERR, "Invalid aenq notification link state %d\n", aenq_e->aenq_common_desc.syndrome); } @@ -3938,7 +3942,7 @@ unimplemented_aenq_handler(void *adapter_data, { struct ena_adapter *adapter = (struct ena_adapter *)adapter_data; - device_printf(adapter->pdev, + ena_log(adapter->pdev, ERR, "Unknown event was received or event with unimplemented handler\n"); } diff --git a/sys/dev/ena/ena_datapath.c b/sys/dev/ena/ena_datapath.c index 0dcc9d45a01c..15bd09c489cf 100644 --- a/sys/dev/ena/ena_datapath.c +++ b/sys/dev/ena/ena_datapath.c @@ -76,7 +76,7 @@ ena_cleanup(void *arg, int pending) if (unlikely((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0)) return; - ena_trace(NULL, ENA_DBG, "MSI-X TX/RX routine\n"); + ena_log_io(adapter->pdev, DBG, "MSI-X TX/RX routine\n"); tx_ring = que->tx_ring; rx_ring = que->rx_ring; @@ -194,11 +194,11 @@ validate_tx_req_id(struct ena_ring *tx_ring, uint16_t req_id) tx_info = &tx_ring->tx_buffer_info[req_id]; if (tx_info->mbuf != NULL) return (0); - device_printf(adapter->pdev, + ena_log(adapter->pdev, ERR, "tx_info doesn't have valid mbuf\n"); } - device_printf(adapter->pdev, "Invalid req_id: %hu\n", req_id); + ena_log(adapter->pdev, ERR, "Invalid req_id: %hu\n", req_id); counter_u64_add(tx_ring->tx_stats.bad_req_id, 1); /* Trigger device reset */ @@ -267,7 +267,7 @@ ena_tx_cleanup(struct ena_ring *tx_ring) bus_dmamap_unload(adapter->tx_buf_tag, tx_info->dmamap); - ena_trace(NULL, ENA_DBG | ENA_TXPTH, "tx: q %d mbuf %p completed\n", + ena_log_io(adapter->pdev, DBG, "tx: q %d mbuf %p completed\n", tx_ring->qid, mbuf); m_freem(mbuf); @@ -292,8 +292,8 @@ ena_tx_cleanup(struct ena_ring *tx_ring) work_done = TX_BUDGET - budget; - ena_trace(NULL, ENA_DBG | ENA_TXPTH, "tx: q %d done. total pkts: %d\n", - tx_ring->qid, work_done); + ena_log_io(adapter->pdev, DBG, "tx: q %d done. total pkts: %d\n", + tx_ring->qid, work_done); /* If there is still something to commit update ring state */ if (likely(commit != TX_COMMIT)) { @@ -408,22 +408,24 @@ ena_rx_mbuf(struct ena_ring *rx_ring, struct ena_com_rx_buf_info *ena_bufs, struct mbuf *mbuf; struct ena_rx_buffer *rx_info; struct ena_adapter *adapter; + device_t pdev; unsigned int descs = ena_rx_ctx->descs; uint16_t ntc, len, req_id, buf = 0; ntc = *next_to_clean; adapter = rx_ring->adapter; + pdev = adapter->pdev; len = ena_bufs[buf].len; req_id = ena_bufs[buf].req_id; rx_info = &rx_ring->rx_buffer_info[req_id]; if (unlikely(rx_info->mbuf == NULL)) { - device_printf(adapter->pdev, "NULL mbuf in rx_info"); + ena_log(pdev, ERR, "NULL mbuf in rx_info"); return (NULL); } - ena_trace(NULL, ENA_DBG | ENA_RXPTH, "rx_info %p, mbuf %p, paddr %jx\n", - rx_info, rx_info->mbuf, (uintmax_t)rx_info->ena_buf.paddr); + ena_log_io(pdev, DBG, "rx_info %p, mbuf %p, paddr %jx\n", rx_info, + rx_info->mbuf, (uintmax_t)rx_info->ena_buf.paddr); bus_dmamap_sync(adapter->rx_buf_tag, rx_info->map, BUS_DMASYNC_POSTREAD); @@ -433,15 +435,14 @@ ena_rx_mbuf(struct ena_ring *rx_ring, struct ena_com_rx_buf_info *ena_bufs, mbuf->m_len = len; /* Only for the first segment the data starts at specific offset */ mbuf->m_data = mtodo(mbuf, ena_rx_ctx->pkt_offset); - ena_trace(NULL, ENA_DBG | ENA_RXPTH, - "Mbuf data offset=%u\n", ena_rx_ctx->pkt_offset); + ena_log_io(pdev, DBG, "Mbuf data offset=%u\n", ena_rx_ctx->pkt_offset); mbuf->m_pkthdr.rcvif = rx_ring->que->adapter->ifp; /* Fill mbuf with hash key and it's interpretation for optimization */ ena_rx_hash_mbuf(rx_ring, ena_rx_ctx, mbuf); - ena_trace(NULL, ENA_DBG | ENA_RXPTH, "rx mbuf 0x%p, flags=0x%x, len: %d\n", - mbuf, mbuf->m_flags, mbuf->m_pkthdr.len); + ena_log_io(pdev, DBG, "rx mbuf 0x%p, flags=0x%x, len: %d\n", mbuf, + mbuf->m_flags, mbuf->m_pkthdr.len); /* DMA address is not needed anymore, unmap it */ bus_dmamap_unload(rx_ring->adapter->rx_buf_tag, rx_info->map); @@ -461,7 +462,7 @@ ena_rx_mbuf(struct ena_ring *rx_ring, struct ena_com_rx_buf_info *ena_bufs, rx_info = &rx_ring->rx_buffer_info[req_id]; if (unlikely(rx_info->mbuf == NULL)) { - device_printf(adapter->pdev, "NULL mbuf in rx_info"); + ena_log(pdev, ERR, "NULL mbuf in rx_info"); /* * If one of the required mbufs was not allocated yet, * we can break there. @@ -480,12 +481,12 @@ ena_rx_mbuf(struct ena_ring *rx_ring, struct ena_com_rx_buf_info *ena_bufs, BUS_DMASYNC_POSTREAD); if (unlikely(m_append(mbuf, len, rx_info->mbuf->m_data) == 0)) { counter_u64_add(rx_ring->rx_stats.mbuf_alloc_fail, 1); - ena_trace(NULL, ENA_WARNING, "Failed to append Rx mbuf %p\n", + ena_log_io(pdev, WARN, "Failed to append Rx mbuf %p\n", mbuf); } - ena_trace(NULL, ENA_DBG | ENA_RXPTH, - "rx mbuf updated. len %d\n", mbuf->m_pkthdr.len); + ena_log_io(pdev, DBG, "rx mbuf updated. len %d\n", + mbuf->m_pkthdr.len); /* Free already appended mbuf, it won't be useful anymore */ bus_dmamap_unload(rx_ring->adapter->rx_buf_tag, rx_info->map); @@ -508,6 +509,7 @@ static inline void ena_rx_checksum(struct ena_ring *rx_ring, struct ena_com_rx_ctx *ena_rx_ctx, struct mbuf *mbuf) { + device_t pdev = rx_ring->adapter->pdev; /* if IP and error */ if (unlikely((ena_rx_ctx->l3_proto == ENA_ETH_IO_L3_PROTO_IPV4) && @@ -515,7 +517,7 @@ ena_rx_checksum(struct ena_ring *rx_ring, struct ena_com_rx_ctx *ena_rx_ctx, /* ipv4 checksum error */ mbuf->m_pkthdr.csum_flags = 0; counter_u64_add(rx_ring->rx_stats.bad_csum, 1); - ena_trace(NULL, ENA_DBG, "RX IPv4 header checksum error\n"); + ena_log_io(pdev, DBG, "RX IPv4 header checksum error\n"); return; } @@ -526,7 +528,7 @@ ena_rx_checksum(struct ena_ring *rx_ring, struct ena_com_rx_ctx *ena_rx_ctx, /* TCP/UDP checksum error */ mbuf->m_pkthdr.csum_flags = 0; counter_u64_add(rx_ring->rx_stats.bad_csum, 1); - ena_trace(NULL, ENA_DBG, "RX L4 checksum error\n"); + ena_log_io(pdev, DBG, "RX L4 checksum error\n"); } else { mbuf->m_pkthdr.csum_flags = CSUM_IP_CHECKED; mbuf->m_pkthdr.csum_flags |= CSUM_IP_VALID; @@ -542,6 +544,7 @@ static int ena_rx_cleanup(struct ena_ring *rx_ring) { struct ena_adapter *adapter; + device_t pdev; struct mbuf *mbuf; struct ena_com_rx_ctx ena_rx_ctx; struct ena_com_io_cq* io_cq; @@ -561,6 +564,7 @@ ena_rx_cleanup(struct ena_ring *rx_ring) #endif /* DEV_NETMAP */ adapter = rx_ring->que->adapter; + pdev = adapter->pdev; ifp = adapter->ifp; qid = rx_ring->que->id; ena_qid = ENA_IO_RXQ_IDX(qid); @@ -573,7 +577,7 @@ ena_rx_cleanup(struct ena_ring *rx_ring) return (0); #endif /* DEV_NETMAP */ - ena_trace(NULL, ENA_DBG, "rx: qid %d\n", qid); + ena_log_io(pdev, DBG, "rx: qid %d\n", qid); do { ena_rx_ctx.ena_bufs = rx_ring->ena_bufs; @@ -601,7 +605,7 @@ ena_rx_cleanup(struct ena_ring *rx_ring) if (unlikely(ena_rx_ctx.descs == 0)) break; - ena_trace(NULL, ENA_DBG | ENA_RXPTH, "rx: q %d got packet from ena. " + ena_log_io(pdev, DBG, "rx: q %d got packet from ena. " "descs #: %d l3 proto %d l4 proto %d hash: %x\n", rx_ring->qid, ena_rx_ctx.descs, ena_rx_ctx.l3_proto, ena_rx_ctx.l4_proto, ena_rx_ctx.hash); @@ -654,8 +658,8 @@ ena_rx_cleanup(struct ena_ring *rx_ring) do_if_input = 0; } if (do_if_input != 0) { - ena_trace(NULL, ENA_DBG | ENA_RXPTH, - "calling if_input() with mbuf %p\n", mbuf); + ena_log_io(pdev, DBG, "calling if_input() with mbuf %p\n", + mbuf); (*ifp->if_input)(ifp, mbuf); } @@ -835,7 +839,7 @@ ena_tx_map_mbuf(struct ena_ring *tx_ring, struct ena_tx_buffer *tx_info, rc = bus_dmamap_load_mbuf_sg(adapter->tx_buf_tag, tx_info->dmamap, mbuf, segs, &nsegs, BUS_DMA_NOWAIT); if (unlikely((rc != 0) || (nsegs == 0))) { - ena_trace(NULL, ENA_WARNING, + ena_log_io(adapter->pdev, WARN, "dmamap load failed! err: %d nsegs: %d\n", rc, nsegs); goto dma_error; } @@ -867,9 +871,8 @@ ena_tx_map_mbuf(struct ena_ring *tx_ring, struct ena_tx_buffer *tx_info, counter_u64_add(tx_ring->tx_stats.llq_buffer_copy, 1); } - ena_trace(NULL, ENA_DBG | ENA_TXPTH, - "mbuf: %p header_buf->vaddr: %p push_len: %d\n", - mbuf, *push_hdr, *header_len); + ena_log_io(adapter->pdev, DBG, "mbuf: %p ""header_buf->vaddr: %p " + "push_len: %d\n", mbuf, *push_hdr, *header_len); /* If packet is fitted in LLQ header, no need for DMA segments. */ if (mbuf->m_pkthdr.len <= tx_ring->tx_max_header_size) { @@ -926,6 +929,7 @@ static int ena_xmit_mbuf(struct ena_ring *tx_ring, struct mbuf **mbuf) { struct ena_adapter *adapter; + device_t pdev; struct ena_tx_buffer *tx_info; struct ena_com_tx_ctx ena_tx_ctx; struct ena_com_dev *ena_dev; @@ -940,17 +944,18 @@ ena_xmit_mbuf(struct ena_ring *tx_ring, struct mbuf **mbuf) ena_qid = ENA_IO_TXQ_IDX(tx_ring->que->id); adapter = tx_ring->que->adapter; + pdev = adapter->pdev; ena_dev = adapter->ena_dev; io_sq = &ena_dev->io_sq_queues[ena_qid]; rc = ena_check_and_collapse_mbuf(tx_ring, mbuf); if (unlikely(rc != 0)) { - ena_trace(NULL, ENA_WARNING, - "Failed to collapse mbuf! err: %d\n", rc); + ena_log_io(pdev, WARN, "Failed to collapse mbuf! err: %d\n", + rc); return (rc); } - ena_trace(NULL, ENA_DBG | ENA_TXPTH, "Tx: %d bytes\n", (*mbuf)->m_pkthdr.len); + ena_log_io(pdev, DBG, "Tx: %d bytes\n", (*mbuf)->m_pkthdr.len); next_to_use = tx_ring->next_to_use; req_id = tx_ring->free_tx_ids[next_to_use]; @@ -959,7 +964,7 @@ ena_xmit_mbuf(struct ena_ring *tx_ring, struct mbuf **mbuf) rc = ena_tx_map_mbuf(tx_ring, tx_info, *mbuf, &push_hdr, &header_len); if (unlikely(rc != 0)) { - ena_trace(NULL, ENA_WARNING, "Failed to map TX mbuf\n"); + ena_log_io(pdev, WARN, "Failed to map TX mbuf\n"); return (rc); } memset(&ena_tx_ctx, 0x0, sizeof(struct ena_com_tx_ctx)); @@ -974,7 +979,7 @@ ena_xmit_mbuf(struct ena_ring *tx_ring, struct mbuf **mbuf) if (tx_ring->acum_pkts == DB_THRESHOLD || ena_com_is_doorbell_needed(tx_ring->ena_com_io_sq, &ena_tx_ctx)) { - ena_trace(NULL, ENA_DBG | ENA_TXPTH, + ena_log_io(pdev, DBG, "llq tx max burst size of queue %d achieved, writing doorbell to send burst\n", tx_ring->que->id); ena_com_write_sq_doorbell(tx_ring->ena_com_io_sq); @@ -986,11 +991,10 @@ ena_xmit_mbuf(struct ena_ring *tx_ring, struct mbuf **mbuf) rc = ena_com_prepare_tx(io_sq, &ena_tx_ctx, &nb_hw_desc); if (unlikely(rc != 0)) { if (likely(rc == ENA_COM_NO_MEM)) { - ena_trace(NULL, ENA_DBG | ENA_TXPTH, - "tx ring[%d] if out of space\n", tx_ring->que->id); + ena_log_io(pdev, DBG, "tx ring[%d] is out of space\n", + tx_ring->que->id); } else { - device_printf(adapter->pdev, - "failed to prepare tx bufs\n"); + ena_log(pdev, ERR, "failed to prepare tx bufs\n"); } counter_u64_add(tx_ring->tx_stats.prepare_ctx_err, 1); goto dma_error; @@ -1019,8 +1023,7 @@ ena_xmit_mbuf(struct ena_ring *tx_ring, struct mbuf **mbuf) */ if (unlikely(!ena_com_sq_have_enough_space(tx_ring->ena_com_io_sq, adapter->max_tx_sgl_size + 2))) { - ena_trace(NULL, ENA_DBG | ENA_TXPTH, "Stop queue %d\n", - tx_ring->que->id); + ena_log_io(pdev, DBG, "Stop queue %d\n", tx_ring->que->id); tx_ring->running = false; counter_u64_add(tx_ring->tx_stats.queue_stop, 1); @@ -1072,8 +1075,8 @@ ena_start_xmit(struct ena_ring *tx_ring) io_sq = &adapter->ena_dev->io_sq_queues[ena_qid]; while ((mbuf = drbr_peek(adapter->ifp, tx_ring->br)) != NULL) { - ena_trace(NULL, ENA_DBG | ENA_TXPTH, "\ndequeued mbuf %p with flags %#x and" - " header csum flags %#jx\n", + ena_log_io(adapter->pdev, DBG, + "\ndequeued mbuf %p with flags %#x and header csum flags %#jx\n", mbuf, mbuf->m_flags, (uint64_t)mbuf->m_pkthdr.csum_flags); if (unlikely(!tx_ring->running)) { diff --git a/sys/dev/ena/ena_netmap.c b/sys/dev/ena/ena_netmap.c index 2f645a7fbd19..daed81986f13 100644 --- a/sys/dev/ena/ena_netmap.c +++ b/sys/dev/ena/ena_netmap.c @@ -88,7 +88,7 @@ ena_netmap_attach(struct ena_adapter *adapter) { struct netmap_adapter na; - ena_trace(NULL, ENA_NETMAP, "netmap attach\n"); + ena_log_nm(adapter->pdev, INFO, "netmap attach\n"); bzero(&na, sizeof(na)); na.na_flags = NAF_MOREFRAG; @@ -126,31 +126,31 @@ ena_netmap_alloc_rx_slot(struct ena_adapter *adapter, nm_i = kring->nr_hwcur; head = kring->rhead; - ena_trace(NULL, ENA_NETMAP | ENA_DBG, "nr_hwcur: %d, nr_hwtail: %d, " + ena_log_nm(adapter->pdev, DBG, "nr_hwcur: %d, nr_hwtail: %d, " "rhead: %d, rcur: %d, rtail: %d\n", kring->nr_hwcur, kring->nr_hwtail, kring->rhead, kring->rcur, kring->rtail); if ((nm_i == head) && rx_ring->initialized) { - ena_trace(NULL, ENA_NETMAP, "No free slots in netmap ring\n"); + ena_log_nm(adapter->pdev, ERR, "No free slots in netmap ring\n"); return (ENOMEM); } ring = kring->ring; if (ring == NULL) { - device_printf(adapter->pdev, "Rx ring %d is NULL\n", qid); + ena_log_nm(adapter->pdev, ERR, "Rx ring %d is NULL\n", qid); return (EFAULT); } slot = &ring->slot[nm_i]; addr = PNMB(na, slot, &paddr); if (addr == NETMAP_BUF_BASE(na)) { - device_printf(adapter->pdev, "Bad buff in slot\n"); + ena_log_nm(adapter->pdev, ERR, "Bad buff in slot\n"); return (EFAULT); } rc = netmap_load_map(na, adapter->rx_buf_tag, rx_info->map, addr); if (rc != 0) { - ena_trace(NULL, ENA_WARNING, "DMA mapping error\n"); + ena_log_nm(adapter->pdev, WARN, "DMA mapping error\n"); return (rc); } bus_dmamap_sync(adapter->rx_buf_tag, rx_info->map, BUS_DMASYNC_PREREAD); @@ -179,19 +179,19 @@ ena_netmap_free_rx_slot(struct ena_adapter *adapter, na = NA(adapter->ifp); if (na == NULL) { - device_printf(adapter->pdev, "netmap adapter is NULL\n"); + ena_log_nm(adapter->pdev, ERR, "netmap adapter is NULL\n"); return; } if (na->rx_rings == NULL) { - device_printf(adapter->pdev, "netmap rings are NULL\n"); + ena_log_nm(adapter->pdev, ERR, "netmap rings are NULL\n"); return; } qid = rx_ring->qid; kring = na->rx_rings[qid]; if (kring == NULL) { - device_printf(adapter->pdev, + ena_log_nm(adapter->pdev, ERR, "netmap kernel ring %d is NULL\n", qid); return; } @@ -210,7 +210,7 @@ ena_netmap_free_rx_slot(struct ena_adapter *adapter, slot = &kring->ring->slot[nm_i]; - ENA_WARN(slot->buf_idx != 0, NULL, "Overwrite slot buf\n"); + ENA_WARN(slot->buf_idx != 0, adapter->ena_dev, "Overwrite slot buf\n"); slot->buf_idx = rx_info->netmap_buf_idx; slot->flags = NS_BUF_CHANGED; @@ -252,7 +252,7 @@ ena_netmap_reset_ring(struct ena_adapter *adapter, int qid, enum txrx x) return; netmap_reset(NA(adapter->ifp), x, qid, 0); - ena_trace(NULL, ENA_NETMAP, "%s ring %d is in netmap mode\n", + ena_log_nm(adapter->pdev, INFO, "%s ring %d is in netmap mode\n", (x == NR_TX) ? "Tx" : "Rx", qid); } @@ -273,6 +273,7 @@ ena_netmap_reg(struct netmap_adapter *na, int onoff) { struct ifnet *ifp = na->ifp; struct ena_adapter* adapter = ifp->if_softc; + device_t pdev = adapter->pdev; struct netmap_kring *kring; enum txrx t; int rc, i; @@ -282,7 +283,7 @@ ena_netmap_reg(struct netmap_adapter *na, int onoff) ena_down(adapter); if (onoff) { - ena_trace(NULL, ENA_NETMAP, "netmap on\n"); + ena_log_nm(pdev, INFO, "netmap on\n"); for_rx_tx(t) { for (i = 0; i <= nma_get_nrings(na, t); i++) { kring = NMR(na, t)[i]; @@ -293,7 +294,7 @@ ena_netmap_reg(struct netmap_adapter *na, int onoff) } nm_set_native_flags(na); } else { - ena_trace(NULL, ENA_NETMAP, "netmap off\n"); + ena_log_nm(pdev, INFO, "netmap off\n"); nm_clear_native_flags(na); for_rx_tx(t) { for (i = 0; i <= nma_get_nrings(na, t); i++) { @@ -307,7 +308,7 @@ ena_netmap_reg(struct netmap_adapter *na, int onoff) rc = ena_up(adapter); if (rc != 0) { - ena_trace(NULL, ENA_WARNING, "ena_up failed with rc=%d\n", rc); + ena_log_nm(pdev, WARN, "ena_up failed with rc=%d\n", rc); adapter->reset_reason = ENA_REGS_RESET_DRIVER_INVALID_STATE; nm_clear_native_flags(na); ena_destroy_device(adapter, false); @@ -401,7 +402,7 @@ ena_netmap_tx_frame(struct ena_netmap_ctx *ctx) adapter = ctx->adapter; if (ena_netmap_count_slots(ctx) > adapter->max_tx_sgl_size) { - ena_trace(NULL, ENA_WARNING, "Too many slots per packet\n"); + ena_log_nm(adapter->pdev, WARN, "Too many slots per packet\n"); return (EINVAL); } @@ -415,7 +416,7 @@ ena_netmap_tx_frame(struct ena_netmap_ctx *ctx) rc = ena_netmap_tx_map_slots(ctx, tx_info, &push_hdr, &header_len, &packet_len); if (unlikely(rc != 0)) { - device_printf(adapter->pdev, "Failed to map Tx slot\n"); + ena_log_nm(adapter->pdev, ERR, "Failed to map Tx slot\n"); return (rc); } @@ -438,10 +439,10 @@ ena_netmap_tx_frame(struct ena_netmap_ctx *ctx) rc = ena_com_prepare_tx(ctx->io_sq, &ena_tx_ctx, &nb_hw_desc); if (unlikely(rc != 0)) { if (likely(rc == ENA_COM_NO_MEM)) { - ena_trace(NULL, ENA_NETMAP | ENA_DBG | ENA_TXPTH, + ena_log_nm(adapter->pdev, DBG, "Tx ring[%d] is out of space\n", tx_ring->que->id); } else { - device_printf(adapter->pdev, + ena_log_nm(adapter->pdev, ERR, "Failed to prepare Tx bufs\n"); } counter_u64_add(tx_ring->tx_stats.prepare_ctx_err, 1); @@ -528,17 +529,20 @@ static int ena_netmap_map_single_slot(struct netmap_adapter *na, struct netmap_slot *slot, bus_dma_tag_t dmatag, bus_dmamap_t dmamap, void **vaddr, uint64_t *paddr) { + device_t pdev; int rc; + pdev = ((struct ena_adapter *)na->ifp->if_softc)->pdev; + *vaddr = PNMB(na, slot, paddr); if (unlikely(vaddr == NULL)) { - ena_trace(NULL, ENA_ALERT, "Slot address is NULL\n"); + ena_log_nm(pdev, ERR, "Slot address is NULL\n"); return (EINVAL); } rc = netmap_load_map(na, dmatag, dmamap, *vaddr); if (unlikely(rc != 0)) { - ena_trace(NULL, ENA_ALERT, "Failed to map slot %d for DMA\n", + ena_log_nm(pdev, ERR, "Failed to map slot %d for DMA\n", slot->buf_idx); return (EINVAL); } @@ -599,7 +603,7 @@ ena_netmap_tx_map_slots(struct ena_netmap_ctx *ctx, if (likely(push_len <= slot_head_len)) { *push_hdr = NMB(ctx->na, slot); if (unlikely(push_hdr == NULL)) { - device_printf(adapter->pdev, + ena_log_nm(adapter->pdev, ERR, "Slot vaddress is NULL\n"); return (EINVAL); } @@ -615,7 +619,7 @@ ena_netmap_tx_map_slots(struct ena_netmap_ctx *ctx, push_len, tx_ring->push_buf_intermediate_buf); if (unlikely(rc)) { - device_printf(adapter->pdev, + ena_log_nm(adapter->pdev, ERR, "Failed to copy data from slots to push_buf\n"); return (EINVAL); } @@ -626,7 +630,7 @@ ena_netmap_tx_map_slots(struct ena_netmap_ctx *ctx, delta = push_len - slot_head_len; } - ena_trace(NULL, ENA_NETMAP | ENA_DBG | ENA_TXPTH, + ena_log_nm(adapter->pdev, DBG, "slot: %d header_buf->vaddr: %p push_len: %d\n", slot->buf_idx, *push_hdr, push_len); @@ -642,7 +646,7 @@ ena_netmap_tx_map_slots(struct ena_netmap_ctx *ctx, &vaddr, &paddr); if (unlikely(rc != 0)) { - device_printf(adapter->pdev, + ena_log_nm(adapter->pdev, ERR, "DMA mapping error\n"); return (rc); } @@ -695,7 +699,7 @@ ena_netmap_tx_map_slots(struct ena_netmap_ctx *ctx, &vaddr, &paddr); if (unlikely(rc != 0)) { - device_printf(adapter->pdev, + ena_log_nm(adapter->pdev, ERR, "DMA mapping error\n"); goto error_map; } @@ -744,7 +748,7 @@ ena_netmap_tx_map_slots(struct ena_netmap_ctx *ctx, &vaddr, &paddr); if (unlikely(rc != 0)) { - device_printf(adapter->pdev, + ena_log_nm(adapter->pdev, ERR, "DMA mapping error\n"); goto error_map; } @@ -860,8 +864,8 @@ ena_netmap_tx_clean_one(struct ena_netmap_ctx *ctx, uint16_t req_id) /* Next, retain the sockets back to the userspace */ for (n = 0; n < nm_info->sockets_used; n++) { ctx->nm_i = nm_next(ctx->nm_i, ctx->lim); - ENA_WARN(ctx->slots[ctx->nm_i].buf_idx != 0, NULL, - "Tx idx is not 0.\n"); + ENA_WARN(ctx->slots[ctx->nm_i].buf_idx != 0, + ctx->adapter->ena_dev, "Tx idx is not 0.\n"); ctx->slots[ctx->nm_i].buf_idx = nm_info->socket_buf_idx[n]; ctx->slots[ctx->nm_i].flags = NS_BUF_CHANGED; nm_info->socket_buf_idx[n] = 0; @@ -882,7 +886,7 @@ validate_tx_req_id(struct ena_ring *tx_ring, uint16_t req_id) if (likely(req_id < tx_ring->ring_size)) return (0); - ena_trace(NULL, ENA_WARNING, "Invalid req_id: %hu\n", req_id); + ena_log_nm(adapter->pdev, WARN, "Invalid req_id: %hu\n", req_id); counter_u64_add(tx_ring->tx_stats.bad_req_id, 1); ena_trigger_reset(adapter, ENA_REGS_RESET_INV_TX_REQ_ID); @@ -932,7 +936,7 @@ ena_netmap_rx_frames(struct ena_netmap_ctx *ctx) /* In case of multiple frames, it is not an error. */ rc = 0; if (frames_counter > ENA_MAX_FRAMES) { - device_printf(ctx->adapter->pdev, + ena_log_nm(ctx->adapter->pdev, ERR, "Driver is stuck in the Rx loop\n"); break; } @@ -960,7 +964,7 @@ ena_netmap_rx_frame(struct ena_netmap_ctx *ctx) rc = ena_com_rx_pkt(ctx->io_cq, ctx->io_sq, &ena_rx_ctx); if (unlikely(rc != 0)) { - ena_trace(NULL, ENA_ALERT, + ena_log_nm(ctx->adapter->pdev, ERR, "Failed to read pkt from the device with error: %d\n", rc); if (rc == ENA_COM_NO_SPACE) { counter_u64_add(ctx->ring->rx_stats.bad_desc_num, 1); @@ -975,7 +979,8 @@ ena_netmap_rx_frame(struct ena_netmap_ctx *ctx) if (unlikely(ena_rx_ctx.descs == 0)) return (ENA_NETMAP_NO_MORE_FRAMES); - ena_trace(NULL, ENA_NETMAP | ENA_DBG, "Rx: q %d got packet from ena. descs #:" + ena_log_nm(ctx->adapter->pdev, DBG, + "Rx: q %d got packet from ena. descs #:" " %d l3 proto %d l4 proto %d hash: %x\n", ctx->ring->qid, ena_rx_ctx.descs, ena_rx_ctx.l3_proto, ena_rx_ctx.l4_proto, ena_rx_ctx.hash); @@ -1031,7 +1036,7 @@ ena_netmap_rx_load_desc(struct ena_netmap_ctx *ctx, uint16_t buf, int *len) BUS_DMASYNC_POSTREAD); netmap_unload_map(ctx->na, ctx->adapter->rx_buf_tag, rx_info->map); - ENA_WARN(ctx->slots[ctx->nm_i].buf_idx != 0, NULL, + ENA_WARN(ctx->slots[ctx->nm_i].buf_idx != 0, ctx->adapter->ena_dev, "Rx idx is not 0.\n"); ctx->slots[ctx->nm_i].buf_idx = rx_info->netmap_buf_idx; @@ -1044,7 +1049,7 @@ ena_netmap_rx_load_desc(struct ena_netmap_ctx *ctx, uint16_t buf, int *len) ctx->slots[ctx->nm_i].len = ctx->ring->ena_bufs[buf].len; *len += ctx->slots[ctx->nm_i].len; ctx->ring->free_rx_ids[ctx->nt] = req_id; - ena_trace(NULL, ENA_DBG, "rx_info %p, buf_idx %d, paddr %jx, nm: %d\n", + ena_log_nm(ctx->adapter->pdev, DBG, "rx_info %p, buf_idx %d, paddr %jx, nm: %d\n", rx_info, ctx->slots[ctx->nm_i].buf_idx, (uintmax_t)rx_info->ena_buf.paddr, ctx->nm_i); diff --git a/sys/dev/ena/ena_sysctl.c b/sys/dev/ena/ena_sysctl.c index 0726771e5adc..c9a5419811a8 100644 --- a/sys/dev/ena/ena_sysctl.c +++ b/sys/dev/ena/ena_sysctl.c @@ -51,7 +51,7 @@ static SYSCTL_NODE(_hw, OID_AUTO, ena, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, /* * Logging level for changing verbosity of the output */ -int ena_log_level = ENA_ALERT | ENA_WARNING; +int ena_log_level = ENA_INFO; SYSCTL_INT(_hw_ena, OID_AUTO, log_level, CTLFLAG_RWTUN, &ena_log_level, 0, "Logging level indicating verbosity of the logs"); @@ -452,20 +452,20 @@ ena_sysctl_buf_ring_size(SYSCTL_HANDLER_ARGS) return (error); if (!powerof2(val) || val == 0) { - device_printf(adapter->pdev, + ena_log(adapter->pdev, ERR, "Requested new Tx buffer ring size (%u) is not a power of 2\n", val); return (EINVAL); } if (val != adapter->buf_ring_size) { - device_printf(adapter->pdev, + ena_log(adapter->pdev, INFO, "Requested new Tx buffer ring size: %d. Old size: %d\n", val, adapter->buf_ring_size); error = ena_update_buf_ring_size(adapter, val); } else { - device_printf(adapter->pdev, + ena_log(adapter->pdev, ERR, "New Tx buffer ring size is the same as already used: %u\n", adapter->buf_ring_size); } @@ -490,7 +490,7 @@ ena_sysctl_rx_queue_size(SYSCTL_HANDLER_ARGS) return (error); if (val < ENA_MIN_RING_SIZE || val > adapter->max_rx_ring_size) { - device_printf(adapter->pdev, + ena_log(adapter->pdev, ERR, "Requested new Rx queue size (%u) is out of range: [%u, %u]\n", val, ENA_MIN_RING_SIZE, adapter->max_rx_ring_size); return (EINVAL); @@ -498,21 +498,21 @@ ena_sysctl_rx_queue_size(SYSCTL_HANDLER_ARGS) /* Check if the parameter is power of 2 */ if (!powerof2(val)) { - device_printf(adapter->pdev, + ena_log(adapter->pdev, ERR, "Requested new Rx queue size (%u) is not a power of 2\n", val); return (EINVAL); } if (val != adapter->requested_rx_ring_size) { - device_printf(adapter->pdev, + ena_log(adapter->pdev, INFO, "Requested new Rx queue size: %u. Old size: %u\n", val, adapter->requested_rx_ring_size); error = ena_update_queue_size(adapter, adapter->requested_tx_ring_size, val); } else { - device_printf(adapter->pdev, + ena_log(adapter->pdev, ERR, "New Rx queue size is the same as already used: %u\n", adapter->requested_rx_ring_size); } @@ -539,7 +539,7 @@ ena_sysctl_io_queues_nb(SYSCTL_HANDLER_ARGS) return (error); if (tmp == 0) { - device_printf(adapter->pdev, + ena_log(adapter->pdev, ERR, "Requested number of IO queues is zero\n"); return (EINVAL); } @@ -552,17 +552,17 @@ ena_sysctl_io_queues_nb(SYSCTL_HANDLER_ARGS) * device reset (`ena_destroy_device()` + `ena_restore_device()`). */ if (tmp > (adapter->msix_vecs - ENA_ADMIN_MSIX_VEC)) { - device_printf(adapter->pdev, + ena_log(adapter->pdev, ERR, "Requested number of IO queues is higher than maximum " "allowed (%u)\n", adapter->msix_vecs - ENA_ADMIN_MSIX_VEC); return (EINVAL); } if (tmp == adapter->num_io_queues) { - device_printf(adapter->pdev, + ena_log(adapter->pdev, ERR, "Requested number of IO queues is equal to current value " "(%u)\n", adapter->num_io_queues); } else { - device_printf(adapter->pdev, + ena_log(adapter->pdev, INFO, "Requested new number of IO queues: %u, current value: " "%u\n", tmp, adapter->num_io_queues); @@ -593,18 +593,18 @@ ena_sysctl_eni_metrics_interval(SYSCTL_HANDLER_ARGS) return (error); if (interval > ENI_METRICS_MAX_SAMPLE_INTERVAL) { - device_printf(adapter->pdev, + ena_log(adapter->pdev, ERR, "ENI metrics update interval is out of range - maximum allowed value: %d seconds\n", ENI_METRICS_MAX_SAMPLE_INTERVAL); return (EINVAL); } if (interval == 0) { - device_printf(adapter->pdev, + ena_log(adapter->pdev, INFO, "ENI metrics update is now turned off\n"); bzero(&adapter->eni_metrics, sizeof(adapter->eni_metrics)); } else { - device_printf(adapter->pdev, + ena_log(adapter->pdev, INFO, "ENI metrics update interval is set to: %"PRIu16" seconds\n", interval); } |