aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/ena/ena.c
Commit message (Collapse)AuthorAgeFilesLines
* ena: Fix misconfiguration when requesting regular LLQDavid Arinzon2025-04-291-11/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Patch 0a33c047a443 introduced new values to hw.ena.force_large_llq_header. The default value of 2 means no preference, while 0 and 1 act as the previous false and true respectively, which allowed forcefully setting regular or large LLQ. There are 2 ways to force the driver to select regular LLQ: 1. Setting hw.ena.force_large_llq_header = 0 via sysctl. 2. Turning on ena express, which makes the recommendation by the FW to be regular LLQ. When the device supports large LLQ but the driver is forced to regular LLQ, llq_config->llq_ring_entry_size_value is never initialized and since it is a variable allocated on the stack, it stays garbage. Since this variable is involved in calculating max_entries_in_tx_burst, it could cause the maximum burst size to be zero. This causes the driver to ignore the real maximum burst size of the device, leading to driver resets in devices that have a maximum burst size (Nitro v4 and on. see [1] for more information). In case the garbage value is 0, the calculation of max_entries_in_tx_burst divides by 0 and causes kernel panic. The patch modifies the logic to take into account all use-cases and ensure that the relevant fields are properly initialized. [1]: https://docs.aws.amazon.com/ec2/latest/instancetypes/ec2-nitro-instances.html Fixes: 0a33c047a443 ("ena: Support LLQ entry size recommendation from device") Approved by: cperciva (mentor) MFC after: 3 days Sponsored by: Amazon, Inc. Differential Revision: https://reviews.freebsd.org/D50040
* Check for errors when detaching children first, not lastJohn Baldwin2024-11-051-1/+5
| | | | | | | | | | | | These detach routines in these drivers all ended with 'return (bus_generic_detach())' meaning that if any child device failed to detach, the parent driver was left in a mostly destroyed state, but still marked attached. Instead, bus drivers should detach child drivers first and return errors before destroying driver state in the parent. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47387
* ena: Fix leaking ifmedia resources on detachOsama Abboud2024-10-151-0/+3
| | | | | | | | | | | | | | | | | | | ifmedia_add() allocates an ifmedia_entry during ena_attach. Current code doesn't release this memory during ena_detach() This commit calls ifmedia_removeall() to properly free the allocated memory during ena_detach(). Also, in case ena_attach fails, we need to detach ifmedia which was allocated within ena_setup_ifnet(). This bug was first described in: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=278100 Reviewed by: zlei Approved by: cperciva (mentor) MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Support max large LLQ depth from the deviceOsama Abboud2024-10-151-15/+21
| | | | | | | | | | | | | | | | | | | | | | | | | Large LLQ depth size is currently calculated by dividing the maximum possible size of LLQ by 2. In newer paltforms, starting from r8g the size of BAR2, which contains LLQ, will be increased, and the maximum depth of wide LLQ will be set according to a value set by the device, instead of hardcoded division by 2. The new value will be stored by the device in max_wide_llq_depth field for drivers that expose ENA_ADMIN_LLQ_FEATURE_VERSION_1 or higher to the device. There is an assumption that max_llq_depth >= max_wide_llq_depth, since they both use the same bar, and if it is possible to have a wide LLQ of size max_wide_llq_depth, it is possible to have a normal LLQ of the same size, since it will occupy half of the space. Also moved the large LLQ case calculation of max_tx_queue_size before its rounddown. Approved by: cperciva (mentor) MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Support LLQ entry size recommendation from deviceOsama Abboud2024-10-151-18/+21
| | | | | | | | | | | | | This commit adds support for receiving LLQ entry size recommendation from the device. The driver will use the recommended entry size, unless the user specifically chooses to use regular or large LLQ entry. Also added enum ena_llq_header_size_policy_t and llq_plociy field in order to support the new feature. Approved by: cperciva (mentor) MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Add support for device request reset message over AENQOsama Abboud2024-10-151-1/+12
| | | | | | | | | | | | This commit adds a handler for the new aenq message ENA_ADMIN_DEVICE_REQUEST_RESET, which in turn causes the driver to trigger reset of a new type: ENA_REGS_RESET_DEVICE_REQUEST. Also adds counting of such occurrences in a new statistic for it. Approved by: cperciva (mentor) MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Reinit netmap adapter struct upon sysctl changesOsama Abboud2024-10-151-1/+50
| | | | | | | | | | | | | | | | | | | | | When attaching ENA driver, ena_netmap_attach() is invoked which, in turn calls netmap_attach which, initializes a struct netmap_adapter, allocating the struct's netmap_ring and the struct selinfo. When we change the interface number of queues we need to reinit the netmap adapter struct as well, so we need to detach it in order to free the memory allocated by netmap_attach and allocate new memory based on the new parameters like number of rings, ring size etc... Without detaching and attaching the netmap interface, if we're to change the number of queues from 8 to 2 for example and try to enable netmap, the kernel will panic since the original netmap struct within the kernel's possession still thinks that the driver has 8 queues which will eventually cause a non-allocated virtual address access fault. Approved by: cperciva (mentor) MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Add differentiation for missing TX completions resetOsama Abboud2024-10-151-1/+44
| | | | | | | | | | | | | | | This commit adds differentiation for a reset caused by missing tx completions, by verifying if the driver didn't receive tx completions caused by missing interrupts. The cleanup_running field was added to ena_ring because cleanup_task.ta_pending is zeroed before ena_cleanup() runs. Also ena_increment_reset_counter() API was added in order to support only incrementing the reset counter. Approved by: cperciva (mentor) MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Set ena_min_poll_delay_us default valueosamaabb2024-10-151-0/+2
| | | | | | | | | | | | | | This commit sets the default value for ena_min_poll_delay_us to 100. This commit does not change the behavior of the driver, the delay is calculated as MAX(ENA_MIN_ADMIN_POLL_US, delay_us), where the first field is already defined as 100. The second parameter, delay_us is taken from ena_min_poll_delay_us which is currently unset - 0. Approved by: cperciva (mentor) MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Add reset reason for missing admin interruptOsama Abboud2024-10-151-2/+11
| | | | | | | | | | | There can be cases when we trigger reset if an admin interrupt is missing. In order to identify this use-case specifically, this commit adds a new reset reason. Approved by: cperciva (mentor) MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Add reset reason for corrupted TX cdescsOsama Abboud2024-10-151-0/+26
| | | | | | | | | | | TX completion descriptors may sometimes contain errors due to corruption. Upon identifying such a case, the driver will trigger a reset with an explicit reset reason ENA_REGS_RESET_TX_DESCRIPTOR_MALFORMED. Approved by: cperciva (mentor) MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Improve reset reason statisticsOsama Abboud2024-10-151-2/+0
| | | | | | | | | | | | | | | | The driver uses different reset reasons. Some of them are counted and presented in the driver statistics. There are cases where statistics are counted on a ring level, but these are zeroed after a reset procedure takes place. This commit makes the following changes: 1. Add statistics for the unrepresented reset reasons. 2. Add reset reasons which are counted on a ring level, to be also global for better tracking. Approved by: cperciva (mentor) MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Update license signatures to 2024Osama Abboud2024-10-151-1/+1
| | | | | | | | This commit updates all the license signatures to 2024. Approved by: cperciva (mentor) MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Add configuration notifications interface supportOsama Abboud2024-10-151-1/+29
| | | | | | | | | | | | | This commit is part of the effort of notifying the user of non-optimal or performance impacting practices. A new interface is serving as a communication channel between the device and the driver. One of the goals of this channel is to create a new mechanism of notifying the driver and user in case of sub-optimal configuration using a bitmap. Approved by: cperciva (mentor) MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Count all currently missing TX completions in checkOsama Abboud2024-10-151-4/+6
| | | | | | | | | | | | | | | | | Currently we count all of the newly added and already existing missing tx completions in each iteration of check_missing_comp_in_tx_queue() causing duplicate counts to missing_tx_comp stat. This commit adds a new counter new_missed_tx within the relevant function which only counts the newly added missing tx completions in each iteration of check_missing_comp_in_tx_queue(). This will allow us to update missing_tx_comp stat accurately without counting duplicates. Approved by: cperciva (mentor) MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Fix customer metrics deallocation statement placeOsama Abboud2024-10-151-1/+1
| | | | | | | | | | | | | | | | | | | Upstream commit [1] made if_alloc_domain() never fail, then also do the wrappers if_alloc(), if_alloc_dev(), and if_gethandle(). Upstream commit [2] removed the NULL check conducted by the driver. This commit also removes err_customer_metrics_alloc goto label. Commit [2] leaves behind a floating free() statement that deallocates customer_metrics_array. This commit places the deallocation statement where it belongs. [1] commit 4787572d0580 ("ifnet: make if_alloc_domain() never fail") [2] commit aa3860851b9f ("net: Remove unneeded NULL check for the allocated ifnet") Approved by: cperciva (mentor) MFC after: 2 weeks Sponsored by: Amazon, Inc.
* net: Remove unneeded NULL check for the allocated ifnetZhenlei Huang2024-06-281-14/+3
| | | | | | | | | | | Change 4787572d0580 made if_alloc_domain() never fail, then also do the wrappers if_alloc(), if_alloc_dev(), and if_gethandle(). No functional change intended. Reviewed by: kp, imp, glebius, stevek MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D45740
* ena: Update the license dating to 2023Osama Abboud2023-12-281-1/+1
| | | | | | | | | Some of the files are using outdated linceses. Update the license to be 2023. Approved by: cperciva (mentor) MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Support srd metrics with sysctlOsama Abboud2023-12-281-0/+10
| | | | | | | | | | This commit introduces SRD metrics through sysctl. The metrics can be queried using the following sysctl node: sysctl dev.ena.<device index>.ena_srd_info Approved by: cperciva (mentor) MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Support customer metric with sysctlOsama Abboud2023-12-281-2/+47
| | | | | | | | | | This commit adds sysctl support for customer metrics. Different customer metrics can be found in the following sysctl node: sysctl dev.ena.<device index>.customer_metrics Approved by: cperciva (mentor) MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Introduce shared sample interval for all statsOsama Abboud2023-12-281-6/+6
| | | | | | | | | | | | | | | | | Rename sample_interval node to stats_sample_interval and move it up in the sysctl tree to make it clear that it's relevant for all the stats and not only ENI metrics (Currently, sample interval node is found under eni_metrics node). Path to node: dev.ena.<device_index>.stats_sample_interval Once this parameter is set it will set the sample interval for all the stats node including SRD/customer metrics. Approved by: cperciva (mentor) MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Update ena_com_update_intr_reg API usageOsama Abboud2023-12-281-1/+1
| | | | | | | | | This commit fixes the usage of this function to be compatible with the new API introduced by ena-com update to v2.7.0 Approved by: cperciva (mentor) MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Change measurement unit of time since last tx cleanup to msArthur Kiyanovski2023-12-281-2/+2
| | | | | | | | | | This commit: 1. Sets the time since last cleanup to milliseconds. 2. Fixes incorrect indentations. Approved by: cperciva (mentor) MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Add sysctl support for spreading IRQsOsama Abboud2023-12-281-17/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit allows spreading IO IRQs over different CPUs through sysctl. Two sysctl nodes are introduced: 1- base_cpu: servers as the first CPU to which the first IO IRQ will be bound. 2- cpu_stride: sets the distance between every two CPUs to which every two consecutive IO IRQs are bound. For example for doing the following IO IRQs / CPU binding: IRQ idx | CPU ---------------- 1 | 0 2 | 2 3 | 4 4 | 6 Run the following commands: sysctl dev.ena.<device index>.irq_affinity.base_cpu=0 sysctl dev.ena.<device_index>.irq_affinity.cpu_stride=2 Also introduced rss_enabled field, which is intended to replace '#ifdef RSS' in multiple places, in order to prevent code duplication. We want to bind interrupts to CPUs in case of rss set OR in case the newly defined sysctl paremeter is set. This requires to remove a couple of '#ifdef RSS' as well in the structs, since we'll be using the relevant parameters in the CPU binding code. Approved by: cperciva (mentor) MFC after: 2 weeks Sponsored by: Amazon, Inc.
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-161-2/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* ena: Fix driver unload crashArthur Kiyanovski2023-07-041-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | When ena_detach is called, we first call ether_ifdetach(), which destroys internal addresses of ifp. One such address is ifp->if_addr->ifa_addr. Then during ena_destroy_device(), if_link_state_change() is called, eventually trying to access ifp->if_addr->ifa_addr->sa_family. This causes an access to garbage memory and crashes the kernel. Ticket [1] was opened to the FreeBSD community to add null check in the code of if_link_state_change(). A fix was submitted in commit [2], however it was noted that it is our driver's responsibilty to not call if_link_state_change() after calling ether_ifdetach(). This commit makes sure if_link_state_change() is not called after ether_ifdetach(). [1]: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=270813 [2]: https://reviews.freebsd.org/D39614 Fixes: 32f63fa7f975 ("Split ENA reset routine into restore and destroy stages") MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Initialize statistics before the interface is availableOsama Abboud2023-07-041-11/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In [1], the FBSD community exposed a bug in the fbsd/ena driver. Bug description: ---------------- Current function call order is as follows: 1. ena_attach() 1.1. ena_setup_ifnet() 1.1.1. Registration of ena_get_counter() 1.1.2. ether_ifattach(ifp, adapter->mac_addr); 1.2. Statistics allocation and initialization. At point 1.1.2, when ether_ifattach() returns, the interface is available, and stats can be read before they are allocated, leading to kernel panic. Also fixed a potential memory leak by freeing the stats since they were not freed in case the following calls failed. Fix: ---- This commit moves the statistics allocation and initialization to happen before ena_setup_ifnet() [1] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=268934 Fixes: 9b8d05b8ac78 ("Add support for Amazon Elastic Network Adapter (ENA) NIC") Fixes: 30217e2dff10 ("Rework counting of hardware statistics in ENA driver") MFC after: 2 weeks Sponsored by: Amazon, Inc.
* net: replace IFF_KNOWSEPOCH with IFF_NEEDSEPOCHGleb Smirnoff2023-04-171-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Expect that drivers call into the network stack with the net epoch entered. This has already been the fact since early 2020. The net interrupts, that are marked with INTR_TYPE_NET, were entering epoch since 511d1afb6bf. For the taskqueues there is NET_TASK_INIT() and all drivers that were known back in 2020 we marked with it in 6c3e93cb5a4. However in e87c4940156 we took conservative approach and preferred to opt-in rather than opt-out for the epoch. This change not only reverts e87c4940156 but adds a safety belt to avoid panicing with INVARIANTS if there is a missed driver. With INVARIANTS we will run in_epoch() check, print a warning and enter the net epoch. A driver that prints can be quickly fixed with the IFF_NEEDSEPOCH flag, but better be augmented to properly enter the epoch itself. Note on TCP LRO: it is a backdoor to enter the TCP stack bypassing some layers of net stack, ignoring either old IFF_KNOWSEPOCH or the new IFF_NEEDSEPOCH. But the tcp_lro_flush_all() asserts the presence of network epoch. Indeed, all NIC drivers that support LRO already provide the epoch, either with help of INTR_TYPE_NET or just running NET_EPOCH_ENTER() in their code. Reviewed by: zlei, gallatin, erj Differential Revision: https://reviews.freebsd.org/D39510
* Mechanically convert ena(4) to DrvAPIJustin Hibbits2023-01-131-18/+18
| | | | | Reviewed by: mw Differential Revision: https://reviews.freebsd.org/D37837
* ena: Remove timer service re-arm on ena_restore_device failureDavid Arinzon2023-01-131-2/+0
| | | | | | | | | | | | | | | | | | | | In case the reset sequence fails (ena_destroy_device() followed by ena_restore_device() calls) during ena_restore_device(), the driver resources are being freed. After the clean-up, the timer service is re-armed in order to try and re-initialize the driver state. But, such an attempt would fail given that the resources are freed. Moreover, this would actually cause either the system to fail or a panic. When the driver fails in ena_restore_device() procedure, the only recovery is either unloading and loading the driver or instance reboot. This change removes the timer service re-arm in case of failure in ena_restore_device(). MFC after: 2 weeks Sponsored by: Amazon, Inc. Fixes: 78554d0c707c ("ena: start timer service on attach")
* ena: Re-Enable per-packet missing tx completion printArthur Kiyanovski2023-01-131-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit [1] first added the ena_tx_buffer.print_once member, so that a message about a missing tx completion is printed only once per packet (and not every second when the watchdog runs). In this commit print_once is initialized to true, and is set back to false after detecting a missing tx completion and printing a warning about it to dmesg. Commit [2] incorrectly reverses the values assigned to print_once. The variable is initialized to be true but is checked to be false when a missing tx completion is detected. This is never true, and therefore the warning print for each missing tx completion is never printed since this commit. Commit [3] added time passed since last TX cleanup to the missing tx completions per-packet print. However, due to the issue in commit [2], this time is never printed. This commit reverses back the values assigned to ena_tx_buffer.print_once erroneously by commit [2], bringing back to life the missing tx completion per-packet print. Also add a space after "." in the missing tx completion print. [1] - 9b8d05b8ac78 ("Add support for Amazon Elastic Network Adapter (ENA) NIC") [2] - 74dba3ad7851 ("Split function checking for missing TX completion in ENA driver") [3] - d8aba82b5ca7 ("ena: Store ticks of last Tx cleanup") Fixes: 74dba3ad7851 ("Split function checking for missing TX completion in ENA driver") Fixes: d8aba82b5ca7 ("ena: Store ticks of last Tx cleanup") MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Fix LLQ descriptor reconfigurationMichal Krawczyk2022-07-061-19/+16
| | | | | | | | | | | | | | | | | | | After the device reset, the LLQ configuration descriptor wasn't passed to the hardware. On a 6-generation AWS instances (like C6gn), it is required to pass the LLQ descriptor after the device reset, otherwise the hardware will be missing the LLQ configuration resulting in performance degradation. This patch reconfigures the LLQ each time the ena_device_init() is called. This means that the LLQ descriptor will be passed during the initial configuration and after a reset. The ena_map_llq_mem_bar() function call was moved before the ena_device_init() call, to make sure that the mem bar is available. Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Make first_interrupt a uint8_tMark Johnston2022-07-011-1/+1
| | | | | | | | | | | | | | We do not have atomic(9) routines for bools, and it is not guaranteed that sizeof(bool) is 1. This fixes the KASAN and KMSAN kernel builds, which fail because the compiler refuses to silently cast a _Bool * to a uint8_t * when calling the atomic(9) sanitizer interceptors. Reviewed by: Dawid Górecki <dgr@semihalf.com> MFC after: 2 weeks Fixes: 0ac122c388d9 ("ena: Use atomic_load/store functions for first_interrupt variable") Differential Revision: https://reviews.freebsd.org/D35683
* ena: Align names of constantsDawid Gorecki2022-06-301-9/+10
| | | | | | | | | | Most of the constants in ena.h file were prefixed with ENA_*, while others did not have this prefix. Align the constants by prefixing the remaining constants with ENA. Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Fix styling issuesDawid Gorecki2022-06-301-306/+287
| | | | | | | | Align code style with FreeBSD style(9) guidelines. Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Use device_set_desc in probeDawid Gorecki2022-06-301-3/+1
| | | | | | | | | | | | During probe the driver created a temporary buffer to which the value of DEVICE_DESC constant was printed. This buffer was then copied to the device structure using device_set_desc_copy. Since the value of this string is exactly the same for every device using the ENA driver, using sprintf is unnecessary, and device_set_desc can be used instead. Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Move ena_copy_eni_metrics into separate taskDawid Gorecki2022-06-301-34/+23
| | | | | | | | | | | | | | | | | | | | | Copying ENI metrics was done in callout context, this caused the driver to panic when sample_interval was set to a value other than 0, as the admin queue call which was executed could sleep while waiting on a condition variable. Taskqueue, unlike callout, allows for sleeping, so moving the function to a separate taskqueue fixes the problem. ena_timer_service is still responsible for scheduling the taskqueue. Stop draining the callout during ena_up/ena_down. This was done to prevent a race between ena_up/down and ena_copy_eni_metrics admin queue calls. Since ena_metrics_task is protected by ENA_LOCK there is no possibility of a race between ena_up/down and ena_metrics_task. Remove a comment about locking in ena_timer_service. With ENI metrics in a separate task this comment became obsolete. Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Use atomic_load/store functions for first_interrupt variableDawid Gorecki2022-06-301-3/+4
| | | | | | | | | Surround cases of possible simultaneous access to the first_interrupt variable with atomic_load/store functions. Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Store ticks of last Tx cleanupDawid Gorecki2022-06-301-3/+14
| | | | | | | | | | Store timestamp of last cleanup in Tx ring structure. This does not change anything during normal operation of the driver but could be useful when the device fails for some reason. Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Prevent LLQ initialization when membar isn't exposedDawid Gorecki2022-06-301-6/+23
| | | | | | | | | | | | | | | | | The ena_com_config_dev_mode() function performs many LLQ related calculations and sends an admin command to configure LLQ in the device. All the LLQ related operations are unnecessary if the driver fails to find LLQ memory bar. Move LLQ memory bar allocation to separate helper function ena_map_llq_mem_bar and execute this function before LLQ configuration. If the LLQ memory bar cannot be allocated, then LLQ configuration is skipped. Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Move reset completion logging to the reset functionDawid Gorecki2022-06-301-3/+4
| | | | | | | | | | | While ena_restore_device is called from the reset task, it can also be called from other locations in the driver, for example in netmap specific code. Move the reset completion logging to reset task, so it better represents when the reset actually happened. Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena(4): Fix a typo in a source code commentGordon Bergling2022-06-041-1/+1
| | | | | | - s/entred/entered/ MFC after: 3 days
* ena: Remove unused devclass argument to DRIVER_MODULE.John Baldwin2022-05-091-2/+1
|
* ena(4): Remove a double word in a source code commentGordon Bergling2022-04-091-1/+1
| | | | | | - s/for for/for/ MFC after: 3 days
* ena: do not call reset if device is unresponsiveDawid Gorecki2022-01-231-0/+12
| | | | | | | | | | | | | | If the device becomes unresponsive, the driver will not be able to finish the reset process correctly. Timeout during version validation indicates that the device is currently not responding. In that case do not perform the reset and instead reschedule timer service. Because of that the driver will continue trying to reset the device until it succeeds or is detached. Submitted by: Dawid Gorecki <dgr@semihalf.com> Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: start timer service on attachDawid Gorecki2022-01-231-27/+37
| | | | | | | | | | | | | | | | | | | | | The timer service was started when the interface was brought up and it was stopped when it was brought down. Since ena_up requires the device to be responsive, triggering the reset would become impossible if the device became unresponsive with the interface down. Since most of the functions in timer service already perform the check to see if the device is running, this only requires starting the callout in attach and stopping it when bringing the interface up or down to avoid race between different admin queue calls. Since callout functions for timer service are always called with the same arguments, replace callout_{init,reset,drain} calls with ENA_TIMER_{INIT,RESET,DRAIN} macros. Submitted by: Dawid Gorecki <dgr@semihalf.com> Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: merge ena-com v2.5.0 upgradeMarcin Wojtas2022-01-231-3/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Merge commit '2530eb1fa01bf28fbcfcdda58bd41e055dcb2e4a' Adjust the driver to the upgraded ena-com part twofold: First update is related to the driver's NUMA awareness. Allocate I/O queue memory in NUMA domain local to the CPU bound to the given queue, improving data access time. Since this can result in performance hit for unaware users, this is done only when RSS option is enabled, for other cases the driver relies on kernel to allocate memory by itself. Information about first CPU bound is saved in adapter structure, so the binding persists after bringing the interface down and up again. If there are more buckets than interface queues, the driver will try to bind different interfaces to different CPUs using round-robin algorithm (but it will not bind queues to CPUs which do not have any RSS buckets associated with them). This is done to better utilize hardware resources by spreading the load. Add (read-only) per-queue sysctls in order to provide the following information: - queueN.domain: NUMA domain associated with the queue - queueN.cpu: CPU affinity of the queue The second change is for the CSUM_OFFLOAD constant, as ENA platform file has removed its definition. To align to that change, it has been added to the ena_datapath.h file. Submitted by: Artur Rojek <ar@semihalf.com> Submitted by: Dawid Gorecki <dgr@semihalf.com> Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Implement full RSS reconfigurationArtur Rojek2021-09-011-13/+49
| | | | | | | | | | | | | | | | | | | | | Bind RX/TX queues and MSI-X vectors to matching CPUs based on the RSS bucket entries. Introduce sysctls for the following RSS functionality: - rss.indir_table: indirection table mapping - rss.indir_table_size: indirection table size - rss.key: RSS hash key (if Toeplitz used) Said sysctls are only available when compiled without `option RSS`, as kernel-side RSS support currently doesn't offer RSS reconfiguration. Migrate the hash algorithm from CRC32 to Toeplitz and change the initial hash value to 0x0 in order to match the standard Toeplitz implementation. Provide helpers for hash key inversion required for HW operations. Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Add missing statisticsArtur Rojek2021-09-011-0/+3
| | | | | | | | | | | | | Provide the following sysctl statistics in order to stay aligned with the Linux driver: * rx_ring.csum_good * tx_ring.unmask_interrupt_num Also rename the 'bad_csum' statistic name to 'csum_bad' for alignment. Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Share ena_global_lock between driver instancesArtur Rojek2021-09-011-37/+37
| | | | | | | | | | | | | | | | | In order to use `ena_global_lock` in sysctl context, it must be kept outside the driver instance's software context, as sysctls can be called before attach and after detach, leading to lock use before sx_init and after sx_destroy otherwise. Solve this issue by turning `ena_global_lock` into a file scope variable, shared between all instances of the driver and associated sysctl context, and in turn initialized/destroyed in dedicated SYSINIT/SYSUNINIT functions. As a side effect, this change also fixes existing race in the reset routine, when simultaneously accessing sysctl exposed properties. Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc.