aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/ena
Commit message (Collapse)AuthorAgeFilesLines
* ena: Update driver version to v2.8.2Arthur Kiyanovski2026-03-101-1/+1
| | | | | | | | | | | | | | | Bug Fixes: * Verify that an ENA ring is in netmap only in native mode Minor Changes: * Move parenthesis to correct place in switch * Add comment * Reorder define MFC after: 2 weeks Sponsored by: Amazon, Inc. Reviewed by: cperciva Differential Revision: https://reviews.freebsd.org/D55698
* ena: Verify that an ENA ring is in netmap only in native modeDavid Arinzon2026-03-101-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | netmap operates in two modes: 1) Emulated - netmap handling is done by the network stack, the NIC driver operates transparently to netmap. 2) Native - netmap management is done by the NIC driver. When checking whether a specific ENA ring is running in netmap mode, only the following checks were done: 1. IFCAP_NETMAP - Check whether netmap capability is enabled on the device. 2. NKR_NETMAP_ON - Check whether netmap is actively using this ring. The above checks implied that the netmap mode is native and the ENA driver needs to handle the netmap logic. The code was missing an explicit check on whether native mode is actually on (NAF_NATIVE). This led to a case where though emulated mode was used and a netmap application was turned on, the ENA driver still managed netmap logic partially and caused missing buffers and lack of refill as part of the datapath. Note: Enabling netmap emulated mode is insufficient and there's a need to load a netmap program in order to trigger this use-case. Add an explicit check of whether NAF_NATIVE mode is set. The issue was reported in [1]. [1]: https://github.com/amzn/amzn-drivers/issues/361 Fixes: 358bcc4c6cde ("Add support for ENA NETMAP partial initialization") MFC after: 2 weeks Sponsored by: Amazon, Inc. Reviewed by: cperciva Differential Revision: https://reviews.freebsd.org/D55697
* ena: Minor changesArthur Kiyanovski2026-03-102-5/+3
| | | | | | | | | | | 1. Move parenthesis to correct place in switch and fix include order 2. Add comment at the end of an ifdef for clarity 3. Change include order. MFC after: 2 weeks Sponsored by: Amazon, Inc. Reviewed by: cperciva Differential Revision: https://reviews.freebsd.org/D55696
* ena: use newly exposed RSS hash key API rather than ad-hoc hashingAndrew Gallatin2025-11-223-8/+0
| | | | | Differential Revision: https://reviews.freebsd.org/D53100 Reviewed by: akiyano_amazon.com
* ena: Bump driver version to v2.8.1Arthur Kiyanovski2025-04-291-1/+1
| | | | | | | | | | | | | | | | Changes since 2.8.0: Bug Fixes: * Fix LLQ normal width misconfiguration * Check for errors when detaching children first, not last Minor Changes: * Remove \n from sysctl description Approved by: cperciva (mentor) MFC after: 3 days Sponsored by: Amazon, Inc. Differential Revision: https://reviews.freebsd.org/D50041
* 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
* ena: Remove \n from sysctl descriptionZhenlei Huang2024-11-261-1/+1
| | | | | | | sysctl(8) prints a newline after the description, no need for this extra newline. MFC after: 1 week
* 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: Update driver version to v2.8.0osamaabb2024-10-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Features: * Add support for device request reset message over AENQ * Support LLQ entry size recommendation from device * Support max large LLQ depth from the device * Expand PHC infrastructures * Configuration notification support Bug Fixes: * Fix leaking ifmedia resources on detach * Fix netmap socket chain unmapping issue * Properly reinit netmap structs upon sysctl changes * Correctly count missing TX completions Minor Changes: * Add reset reason for corrupted TX/RX completion descriptors * Add reset reason for missing admin interrupts * Improve reset reason statistics * Update licenses Approved by: cperciva (mentor) MFC after: 2 weeks Sponsored by: Amazon, Inc.
* 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-154-26/+40
| | | | | | | | | | | | | 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-153-1/+16
| | | | | | | | | | | | 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: Clear NS_MOREFRAG flag for last netmap slotOsama Abboud2024-10-151-1/+1
| | | | | | | | | | | | | | | | | | When processing packets within the rx-flow ena_netmap_rx_load_desc doesn't know the number of descriptors, so it sets NS_MOREFRAG to all the slots to indicate that there are more fragments for this packet. The code calls ena_netmap_rx_load_desc() for every descriptor in this packet to map the relevant buffer into the netmap shared memory. After ena_netmap_rx_load_desc() calls, we need to unset the NS_MOREFRAG for the last fragment to indicate that this is the last fragment, so we explicitly turn off NS_MOREFRAG flag. Current code overrides all other flags and sets NS_BUF_CHANGED. This patch unsets the relevant flag only. Approved by: cperciva (mentor) MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Handle wrap around for prefetch in netmapOsama Abboud2024-10-151-3/+3
| | | | | | | | | | | | | Netmap index wraps around based on the number of netmap kernel ring slots. Currently the driver prefetches the next slot using nm_i + 1 which may be wrong since it does not handle wrap around. This patch fixes that by using the kernel API for fetching the next netmap index. Approved by: cperciva (mentor) MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Properly unmap last socket chain in netmapOsama Abboud2024-10-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In case ena_com_prepare_tx() fails within the netmap tx flow, the driver will unmap the last socket chain. Currently, the driver unmaps the wrong socket within ena_netmap_unmap_last_socket_chain(). Illustration of the flow: 1- ena_netmap_tx_frames() 2- ena_netmap_tx_frame() 3- ena_netmap_tx_map_slots() 3.1- Map slot 3.2- Advance to the next socket 4- ena_com_prepare_tx() 4.1- ena_com_prepare_tx() fails 5- ena_netmap_unmap_last_socket_chain() In step 5, where the driver unmaps the socket, the netmap index already points at the next entry, meaning we're unmapping the wrong socket in case ena_com_prepare_tx() fails. In order to fix that, the driver should first update the netmap index to point at the previous entry and only then update the socket parameters. Approved by: cperciva (mentor) MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Make global counters style unifiedOsama Abboud2024-10-151-5/+4
| | | | | | | | | This commit changes the code so all global counters will have the same line break. Approved by: cperciva (mentor) MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Trigger reset when mbuf is NULL error happensOsama Abboud2024-10-151-2/+6
| | | | | | | | | | The mbuf is NULL issue happens when the device sends the driver a completion with a wrong request id. Trigger a reset whenever this happens. Approved by: cperciva (mentor) MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Add differentiation for missing TX completions resetOsama Abboud2024-10-153-18/+77
| | | | | | | | | | | | | | | 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-152-0/+4
| | | | | | | | | | | | | | 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-153-3/+19
| | | | | | | | | | | 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 RX cdescsOsama Abboud2024-10-154-0/+8
| | | | | | | | | | | RX 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_RX_DESCRIPTOR_MALFORMED. Approved by: cperciva (mentor) MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Add reset reason for corrupted TX cdescsOsama Abboud2024-10-155-41/+55
| | | | | | | | | | | 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-153-2/+58
| | | | | | | | | | | | | | | | 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-1510-10/+10
| | | | | | | | 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.
* ena(4): Stop checking for failures from malloc(M_WAITOK)Zhenlei Huang2024-09-031-4/+1
| | | | | MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D45852
* 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 driver version to v2.7.0Osama Abboud2023-12-281-2/+2
| | | | | | | | | | | | | | | | | Features: * Introduce customer and SRD metrics through sysctl * Introduce spreading IRQs to CPUs capability using sysctl * Upgrade ena-com to v2.7.0 Bug Fixes: * Remove outdated APIs Minor Changes: * Introduce a shared stats sample interval for all stats Approved by: cperciva (mentor) MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Update the license dating to 2023Osama Abboud2023-12-2810-10/+10
| | | | | | | | | 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-283-1/+86
| | | | | | | | | | 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-284-3/+135
| | | | | | | | | | 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-283-29/+29
| | | | | | | | | | | | | | | | | 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: Remove CQ tail pointer update APIOsama Abboud2023-12-282-4/+0
| | | | | | | | | This commit removes the usage of this API from the freebsd driver since the relevant functionality is not supported by the device. Approved by: cperciva (mentor) MFC after: 2 weeks Sponsored by: Amazon, Inc.
* ena: Update ena_com_update_intr_reg API usageOsama Abboud2023-12-282-2/+2
| | | | | | | | | 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-283-22/+263
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Automated cleanup of cdefs and other formattingWarner Losh2023-11-271-1/+1
| | | | | | | | | | | | | | | | Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-165-10/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* sys: Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-166-12/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
* ena: Update driver version to v2.6.3Arthur Kiyanovski2023-07-041-1/+1
| | | | | | | | | | | | | Bug Fixes: * Initialize statistics before the interface is available * Fix driver unload crash Minor Changes: * Mechanically convert ena(4) to DrvAPI * Remove usage of IFF_KNOWSEPOCH MFC after: 2 weeks Sponsored by: Amazon, Inc.
* 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-133-30/+30
| | | | | Reviewed by: mw Differential Revision: https://reviews.freebsd.org/D37837
* ena: Update driver version to v2.6.2Arthur Kiyanovski2023-01-131-1/+1
| | | | | | | | | | | | | Bug Fixes: * Remove timer service re-arm on ena_restore_device failure. * Re-Enable per-packet missing tx completion print Minor Changes: * Switch driver owners from Semihalf to Amazon in man file. MFC after: 2 weeks Sponsored by: Amazon, Inc. Pull Request: https://github.com/freebsd/freebsd-src/pull/637
* 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")