git: 87ffe5947071 - stable/13 - Upgrade ENA to v2.4.0
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 07 Oct 2021 16:11:14 UTC
The branch stable/13 has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=87ffe594707105711e7cbc1fa8d5b4a5a8a67165 commit 87ffe594707105711e7cbc1fa8d5b4a5a8a67165 Author: Marcin Wojtas <mw@FreeBSD.org> AuthorDate: 2021-06-14 08:57:45 +0000 Commit: Marcin Wojtas <mw@FreeBSD.org> CommitDate: 2021-10-07 16:10:21 +0000 Upgrade ENA to v2.4.0 ena: change ENA C++-style comment into C-style According to man style(9), only C-style comments should be used. Submitted by: Michal Krawczyk <mk@semihalf.com> Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit 438c9e3cf89403628ec237cfecdd0538f208087b) ena: add support for the large LLQ headers in ENA Default LLQ (Low-latency queue) maximum header size is 96 bytes and can be too small for some types of packets - like IPv6 packets with multiple extension. This can be fixed, by using large LLQ headers. If the device supports larger LLQ headers, the user can activate this feature by setting sysctl tunable 'hw.ena.force_large_llq_header' to '1' in the /boot/loader.conf file. In case the device isn't supporting this feature, the default value (96B) will be used. Submitted by: Michal Krawczyk <mk@semihalf.com> Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit beaadec9eaec8e6b266faff3b0880a141728fcef) ena: remove surplus NULL checks when freeing ENA resources Calling free on a NULL pointer is valid, as appropriate check is already done internally: /* free(NULL, ...) does nothing */ if (addr == NULL) return; Submitted by: Artur Rojek <ar@semihalf.com> Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit ddec69e6a796283497ebada0569f34bd41bbdf37) ena: hide sysctl nodes for unused ENA queues IO queue related attributes are registered statically at driver attach with the rest of the ENA specific sysctl nodes. However, the number of queues can be changed at runtime via the `ena_sysctl_io_queues_nb` request, leading to a potential exposure of attributes for non-existing queues. Introduce a new `ena_sysctl_update_queue_node_nb` function, which updates the sysctl nodes after the number of queues is altered. This happens by either registering or unregistering node specific oids, based on a delta between the previous and current queue count. NOTE: All unregistered oids must be registered again before the driver detach, e.g. by another call to this function. Submitted by: Artur Rojek <ar@semihalf.com> Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit 0e7d31f63b9db869c91228d8ed1e984bdee2b931) 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. (cherry picked from commit 3fc5d816f8831d6fc2816ac97bd78dc486cd080c) Update ENA driver man page Bring the obsolete man page up to date: * update diagnostic error messages * add documentation of loader tunables * document netmap support * add a driver history section * update the contact information Submitted by: Artur Rojek <ar@semihalf.com> Submitted by: Michal Krawczyk <mk@semihalf.com> Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit e34856a2c44a45512463aed0d1794f34258c66ee) Update ENA version to v2.4.0 Some of the changes in this release: * Large LLQ headers, * Bug/stability fixes, * Change of the README/Documentation. Submitted by: Michal Krawczyk <mk@semihalf.com> Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit 93f0df457bf1d0e5f71839ab969c94d1f95813fb) --- share/man/man4/ena.4 | 271 +++++++++++++++--- sys/contrib/ena-com/ena_com.c | 37 +-- sys/contrib/ena-com/ena_com.h | 6 +- sys/contrib/ena-com/ena_defs/ena_admin_defs.h | 23 +- sys/contrib/ena-com/ena_defs/ena_gen_info.h | 6 +- sys/contrib/ena-com/ena_eth_com.c | 4 +- sys/contrib/ena-com/ena_fbsd_log.h | 74 +++++ sys/contrib/ena-com/ena_plat.h | 37 +-- sys/dev/ena/ena.c | 392 ++++++++++++++------------ sys/dev/ena/ena.h | 5 +- sys/dev/ena/ena_datapath.c | 85 +++--- sys/dev/ena/ena_netmap.c | 73 ++--- sys/dev/ena/ena_sysctl.c | 91 ++++-- sys/dev/ena/ena_sysctl.h | 7 +- 14 files changed, 743 insertions(+), 368 deletions(-) diff --git a/share/man/man4/ena.4 b/share/man/man4/ena.4 index e042ed0a2636..cd98fe2c84ba 100644 --- a/share/man/man4/ena.4 +++ b/share/man/man4/ena.4 @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 16, 2017 +.Dd June 4, 2021 .Dt ENA 4 .Os .Sh NAME @@ -86,7 +86,13 @@ debug logs. .Pp Some of the ENA devices support a working mode called Low-latency Queue (LLQ), which saves several more microseconds. -This feature will be implemented for driver in future releases. +.Pp +Support for the +.Xr netmap 4 +framework is provided by the +.Nm +driver. +Kernel must be built with the DEV_NETMAP option to be able to use this feature. .Sh HARDWARE Supported PCI vendor ID/device IDs: .Pp @@ -100,8 +106,172 @@ Supported PCI vendor ID/device IDs: .It 1d0f:ec21 - ENA VF with LLQ support .El +.Sh LOADER TUNABLES +The +.Nm +driver's behavior can be changed using run-time or boot-time sysctl +arguments. +The boot-time arguments can be set at the +.Xr loader 8 +prompt before booting the kernel, or stored in the +.Xr loader.conf 5 . +The run-time arguments can be set using the +.Xr sysctl 8 +command. +.Pp +Boot-time tunables: +.Bl -tag -width indent +.It Va hw.ena.enable_9k_mbufs +Use 9k mbufs for the Rx descriptors. +The default is 0. +If the node value is set to 1, 9k mbufs will be used for the Rx buffers. +If set to 0, page size mbufs will be used instead. +.Pp +Using 9k buffers for Rx can improve Rx throughput, but in low memory conditions +it might increase allocation time, as the system has to look for 3 contiguous +pages. +This can further lead to OS instability, together with ENA driver reset and NVMe +timeouts. +If network performance is critical and memory capacity is sufficient, the 9k +mbufs can be used. +.It Va hw.ena.force_large_llq_headers +Force the driver to use large LLQ headers (224 bytes). +The default is 0. +If the node value is set to 0, the regular size LLQ header will be used, which +is 96B. +In some cases, the packet header can be bigger than this (for example - +IPv6 with multiple extensions). +In such a situation, the large LLQ headers should be used by setting this node +value to 1. +This will take effect only if the device supports both LLQ and large LLQ +headers. +Otherwise, it will fallback to the no LLQ mode or regular header size. +.Pp +Increasing LLQ header size reduces the size of the Tx queue by half, so it may +affect the number of dropped Tx packets. +.El +.Pp +Run-time tunables: +.Bl -tag -width indent +.It Va hw.ena.log_level +Controls extra logging verbosity of the driver. +The default is 2. +The higher the logging level, the more logs will be printed out. 0 means all +extra logs are disabled and only error logs will be printed out. +Default value (2) reports errors, warnings and is verbose about driver +operation. +.Pp +The possible flags are: +.Pp +.Bl -bullet -compact +.It +0 - ENA_ERR - Enable driver error messages and ena_com error logs. +.It +1 - ENA_WARN - Enable logs for non-critical errors. +.It +2 - ENA_INFO - Make the driver more verbose about its actions. +.It +3 - ENA_DBG - Enable debug logs. +.El +.Pp +NOTE: In order to enable logging on the Tx/Rx data path, driver must be compiled +with ENA_LOG_IO_ENABLE compilation flag. +.Pp +Example: +To enable logs for errors and warnings, the following command should be used: +.Bd -literal -offset indent +sysctl hw.ena.log_level=1 +.Ed +.It Va dev.ena.X.io_queues_nb +Number of the currently allocated and used IO queues. +The default is max_num_io_queues. +Controls the number of IO queue pairs (Tx/Rx). As this call has to reallocate +the queues, it will reset the interface and restart all the queues - this means +that everything, which was currently held in the queue, will be lost, leading to +potential packet drops. +.Pp +This call can fail if the system isn't able to provide the driver with enough +resources. +In that situation, the driver will try to revert the previous number of the IO +queues. +If this also fails, the device reset will be triggered. +.Pp +Example: +To use only 2 Tx and Rx queues for the device ena1, the following command should +be used: +.Bd -literal -offset indent +sysctl dev.ena.1.io_queues_nb=2 +.Ed +.It Va dev.ena.X.rx_queue_size +Size of the Rx queue. +The default is 1024. +Controls the number of IO descriptors for each Rx queue. +The user may want to increase the Rx queue size if they observe a high number of +Rx drops in the driver's statistics. +For performance reasons, the Rx queue size must be a power of 2. +.Pp +This call can fail if the system isn't able to provide the driver with enough +resources. +In that situation, the driver will try to revert to the previous number of the +descriptors. +If this also fails, the device reset will be triggered. +.Pp +Example: +To increase Rx ring size to 8K descriptors for the device ena0, the following +command should be used: +.Bd -literal -offset indent +sysctl dev.ena.0.rx_queue_size=8192 +.Ed +.It Va dev.ena.X.buf_ring_size +Size of the Tx buffer ring (drbr). +The default is 4096. +Input must be a power of 2. +Controls the number of mbufs that can be held in the Tx buffer ring. +The drbr is used as a multiple-producer, single-consumer lockless ring for +buffering extra mbufs coming from the stack in case the Tx procedure is busy +sending the packets, or the Tx ring is full. +Increasing the size of the buffer ring may reduce the number of Tx packets being +dropped in case of a big Tx burst, which cannot be handled by the IO queue +immediately. +Each Tx queue has its own drbr. +.Pp +It is recommended to keep the drbr with at least the default value, but in case +the system lacks the resources, it can be reduced. +This call can fail if the system is not able to provide the driver with enough +resources. +In that situation, the driver will try to revert to the previous number of the +drbr and trigger the device reset. +.Pp +Example: +To set drbr size for interface ena0 to 2048, the following command should +be used: +.Bd -literal -offset indent +sysctl dev.ena.0.buf_ring_size=2048 +.Ed +.It Va dev.ena.X.eni_metrics.sample_interval +Interval in seconds for updating ENI metrics. +The default is 0. +Determines how often (if ever) the ENI metrics should be updated. +The ENI metrics are being updated asynchronously in a timer service in order to +avoid admin queue overload by sysctl node reading. +The value in this node controls the interval between issuing admin commands to +the device, which will update the ENI metrics values. +.Pp +If some application is periodically monitoring the eni_metrics, then the ENI +metrics interval can be adjusted accordingly. +Value 0 turns off the update completely. +Value 1 is the minimum interval and is equal to 1 second. +The maximum allowed update interval is 1 hour. +.Pp +Example: +To update ENI metrics for the device ena1 every 10 seconds, the following +command should be used: +.Bd -literal -offset indent +sysctl dev.ena.1.eni_metrics.sample_interval=10 +.Ed +.El .Sh DIAGNOSTICS -.Ss Device initialization phase: +.Ss Device initialization phase .Bl -diag .It ena%d: failed to init mmio read less .Pp @@ -116,7 +286,7 @@ Device may not be responding or is already during reset. Version of the controller is too old and it is not supported by the driver. .It ena%d: Invalid dma width value %d .Pp -The controller is able to request dma transaction width. +The controller is unable to request dma transaction width. .br Device stopped responding or it demanded invalid value. .It ena%d: Can not initialize ena admin queue with device @@ -132,33 +302,30 @@ Failed to get attributes of the device from the controller. .Pp Errors occurred when trying to configure AENQ groups. .El -.Ss Driver initialisation/shutdown phase: +.Ss Driver initialization/shutdown phase .Bl -diag .It ena%d: PCI resource allocation failed! -.It ena%d: allocating ena_dev failed .It ena%d: failed to pmap registers bar -.It ena%d: Error while setting up bufring -.It ena%d: Error with initialization of IO rings .It ena%d: can not allocate ifnet structure .It ena%d: Error with network interface setup .It ena%d: Failed to enable and set the admin interrupts -.It ena%d: Failed to allocate %d, vectors %d +.It ena%d: Error, MSI-X is already enabled .It ena%d: Failed to enable MSIX, vectors %d rc %d +.It ena%d: Not enough number of MSI-X allocated: %d .It ena%d: Error with MSI-X enablement .It ena%d: could not allocate irq vector: %d -.It ena%d: Unable to allocate bus resource: registers +.It ena%d: unable to allocate bus resource: registers! +.It ena%d: unable to allocate bus resource: msix! .Pp Resource allocation failed when initializing the device. .br Driver will not be attached. .It ena%d: ENA device init failed (err: %d) +.It ena%d: Cannot initialize device .Pp Device initialization failed. .br Driver will not be attached. -.It ena%d: could not activate irq vector: %d -.Pp -Error occurred when trying to activate interrupt vectors for Admin Queue. .It ena%d: failed to register interrupt handler for irq %ju: %d .Pp Error occurred when trying to register Admin Queue interrupt handler. @@ -181,8 +348,7 @@ VLANs must be detached first and then detach routine have to be called again. .It ena%d: Unmapped TX DMA tag associations .Pp Error occurred when trying to destroy RX/TX DMA tag. -.It ena%d: Cannot init RSS -.It ena%d: Cannot fill indirect table +.It ena%d: Cannot init indirect table .It ena%d: Cannot fill indirect table .It ena%d: Cannot fill hash function .It ena%d: Cannot fill hash control @@ -192,20 +358,30 @@ Error occurred during initialization of one of RSS resources. .br The device will work with reduced performance because all RX packets will be passed to queue 0 and there will be no hash information. +.It ena%d: LLQ is not supported. Fallback to host mode policy. +.It ena%d: Failed to configure the device mode. Fallback to host mode policy. +.It ena%d: unable to allocate LLQ bar resource. Fallback to host mode policy. +.Pp +Error occured during Low-latency Queue mode setup. +.br +The device will work, but without the LLQ performance gain. +.It ena%d: failed to enable write combining. +.Pp +Error occured while setting the Write Combining mode, required for the LLQ. .It ena%d: failed to tear down irq: %d .It ena%d: dev has no parent while releasing res for irq: %d Release of the interrupts failed. .El -.Ss Additional diagnostic: +.Ss Additional diagnostic .Bl -diag -.It ena%d: Cannot get attribute for ena device -.Pp -This message appears when trying to change MTU and driver is unable to get -attributes from the device. -.It ena%d: Invalid MTU setting. new_mtu: %d +.It ena%d: Invalid MTU setting. new_mtu: %d max_mtu: %d min mtu: %d .Pp Requested MTU value is not supported and will not be set. -.It ena%d: keep alive watchdog timeout +.It ena%d: Failed to set MTU to %d +.Pp +This message appears when either MTU change feature is not supported, or device +communication error has occured. +.It ena%d: Keep alive watchdog timeout. .Pp Device stopped responding and will be reset. .It ena%d: Found a Tx that wasn't completed on time, qid %d, index %d. @@ -215,18 +391,35 @@ Packet was pushed to the NIC but not sent within given time limit. It may be caused by hang of the IO queue. .It ena%d: The number of lost tx completion is aboce the threshold (%d > %d). Reset the device .Pp -If too many Tx wasn't completed on time the device is going to be reset. +If too many Tx weren't completed on time the device is going to be reset. .br It may be caused by hanged queue or device. -.It ena%d: trigger reset is on +.It ena%d: Trigger reset is on .Pp Device will be reset. .br Reset is triggered either by watchdog or if too many TX packets were not completed on time. -.It ena%d: invalid value recvd +.It ena%d: device reset scheduled but trigger_reset is off +.Pp +Reset task has been triggered, but the driver did not request it. +.br +Device reset will not be performed. +.It ena%d: Device reset failed +.Pp +Error occured while trying to reset the device. +.It ena%d: Cannot initialize device +.It ena%d: Error, mac address are different +.It ena%d: Error, device max mtu is smaller than ifp MTU +.It ena%d: Validation of device parameters failed +.It ena%d: Enable MSI-X failed +.It ena%d: Failed to create I/O queues +.It ena%d: Reset attempt failed. Can not reset the device +.Pp +Error occured while trying to restore the device after reset. +.It ena%d: Device reset completed successfully, Driver info: %s .Pp -Link status received from the device in the AENQ handler is invalid. +Device has been correctly restored after reset and is ready to use. .It ena%d: Allocation for Tx Queue %u failed .It ena%d: Allocation for Rx Queue %u failed .It ena%d: Unable to create Rx DMA map for buffer %d @@ -234,7 +427,6 @@ Link status received from the device in the AENQ handler is invalid. .It ena%d: Failed to get TX queue handlers. TX queue num %d rc: %d .It ena%d: Failed to create io RX queue[%d] rc: %d .It ena%d: Failed to get RX queue handlers. RX queue num %d rc: %d -.It ena%d: failed to request irq .It ena%d: could not allocate irq vector: %d .It ena%d: failed to register interrupt handler for irq %ju: %d .Pp @@ -246,12 +438,20 @@ Interface will not be brought up. Initialization of the LRO for the RX ring failed. .It ena%d: failed to alloc buffer for rx queue .It ena%d: failed to add buffer for rx queue %d -.It ena%d: refilled rx queue %d with %d pages only +.It ena%d: refilled rx qid %d with only %d mbufs (from %d) .Pp Allocation of resources used on RX path failed. .br If happened during initialization of the IO queue, the interface will not be brought up. +.It ena%d: NULL mbuf in rx_info +.Pp +Error occured while assembling mbuf from descriptors. +.It ena%d: tx_info doesn't have valid mbuf +.It ena%d: Invalid req_id: %hu +.It ena%d: failed to prepare tx bufs +.Pp +Error occured while preparing a packet for transmission. .It ena%d: ioctl promisc/allmulti .Pp IOCTL request for the device to work in promiscuous/allmulti mode. @@ -259,22 +459,23 @@ IOCTL request for the device to work in promiscuous/allmulti mode. See .Xr ifconfig 8 for more details. -.It ena%d: too many fragments. Last fragment: %d! -.Pp -Packet with unsupported number of segments was queued for sending to the -device. -.br -Packet will be dropped. .El .Sh SUPPORT If an issue is identified with the released source code with a supported adapter, please email the specific information related to the issue to -.Aq Mt mk@semihalf.com +.Aq Mt mk@semihalf.com , +.Aq Mt ar@semihalf.com and .Aq Mt mw@semihalf.com . .Sh SEE ALSO +.Xr netmap 4 , .Xr vlan 4 , .Xr ifconfig 8 +.Sh HISTORY +The +.Nm +driver first appeared in +.Fx 11.1 . .Sh AUTHORS The .Nm 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 680eb0e9d049..84d58c844332 100644 --- a/sys/dev/ena/ena.c +++ b/sys/dev/ena/ena.c @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. + * Copyright (c) 2015-2021 Amazon.com, Inc. or its affiliates. * All rights reserved. * *** 2302 LINES SKIPPED ***