#
246aa273 |
|
23-Oct-2023 |
Osama Abboud <osamaabb@amazon.com> |
ena: Update the license dating to 2023 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.
|
#
2835752e |
|
11-Sep-2023 |
Osama Abboud <osamaabb@amazon.com> |
ena: Remove CQ tail pointer update API 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.
|
#
685dc743 |
|
16-Aug-2023 |
Warner Losh <imp@FreeBSD.org> |
sys: Remove $FreeBSD$: one-line .c pattern Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
|
#
7583c633 |
|
13-Jan-2023 |
Justin Hibbits <jhibbits@FreeBSD.org> |
Mechanically convert ena(4) to DrvAPI Reviewed by: mw Differential Revision: https://reviews.freebsd.org/D37837
|
#
79770fda |
|
10-Jun-2022 |
Michal Krawczyk <mk@semihalf.com> |
ena: Fix invalid KASSERT test in netmap code The KASSERT was originally added to ensure that the netmap Rx ring is not NULL, however, it was checking for the opposite. Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc.
|
#
8f15f8a7 |
|
10-Jun-2022 |
Dawid Gorecki <dgr@semihalf.com> |
ena: Align names of constants 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.
|
#
82e558ea |
|
10-Jun-2022 |
Dawid Gorecki <dgr@semihalf.com> |
ena: Fix styling issues Align code style with FreeBSD style(9) guidelines. Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc.
|
#
a9c39b03 |
|
10-Jun-2022 |
Dawid Gorecki <dgr@semihalf.com> |
ena: Extend debug prints for invalid req_id resets Print information about qid if req_id is invalid. Add information about qid and req_id if mbuf is invalid. Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc.
|
#
3501d4f1 |
|
10-Jun-2022 |
Dawid Gorecki <dgr@semihalf.com> |
ena: Add ena_ring_tx_doorbell() function Add ena_ring_tx_doorbell function to remove code duplication. Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc.
|
#
4dab99b9 |
|
06-Apr-2022 |
John Baldwin <jhb@FreeBSD.org> |
ena: Remove unused variable.
|
#
07aff471 |
|
12-Aug-2021 |
Artur Rojek <ar@semihalf.com> |
ena: Share ena_global_lock between driver instances 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.
|
#
a8314668 |
|
12-Aug-2021 |
Artur Rojek <ar@semihalf.com> |
ena: Disable meta descriptor caching for netmap If LLQ is being used, `ena_tx_ctx.meta_valid` must stay enabled. This fixes netmap support on latest generation ENA HW and aligns it with the core driver behavior. As netmap doesn't support any csum offloads, the `adapter->disable_meta_caching` value can be simply passed to the HW. Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc.
|
#
36130d29 |
|
12-Aug-2021 |
Artur Rojek <ar@semihalf.com> |
ena: Trigger reset on ena_com_prepare_tx failure All ena_com_prepare_tx errors other than ENA_COM_NO_MEM are fatal and require device reset. Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc.
|
#
3fc5d816 |
|
24-Jun-2021 |
Marcin Wojtas <mw@FreeBSD.org> |
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.
|
#
0835cc78 |
|
18-Nov-2020 |
Marcin Wojtas <mw@FreeBSD.org> |
Add SPDX license tag to the ENA driver files Refering to guide: https://wiki.freebsd.org/SPDX the SPDX tag should not replace the standard license text, however it should be added over the standard license text to make the automation easier. Because of that, the old license was kept, but the SPDX tag was added on top of every ENA driver file. Submited by: Michal Krawczyk <mk@semihalf.com> Obtained from: Semihalf Sponsored by: Amazon, Inc MFC after: 1 week Differential revision: https://reviews.freebsd.org/D27117 |
#
9eb1615f |
|
18-Nov-2020 |
Marcin Wojtas <mw@FreeBSD.org> |
Adjust ENA driver files to latest ena-com changes * Use the new API of ena_trace_* * Fix typo syndrom --> syndrome * Remove validation of the Rx req ID (already performed in the ena-com) * Remove usage of deprecated ENA_ASSERT macro Submitted by: Ido Segev <idose@amazon.com> Submitted by: Michal Krawczyk <mk@semihalf.com> Obtained from: Semihalf Sponsored by: Amazon, Inc MFC after: 1 week Differential revision: https://reviews.freebsd.org/D27115
|
#
2287afd8 |
|
26-May-2020 |
Marcin Wojtas <mw@FreeBSD.org> |
Update ENA driver version to v2.2.0 Driver version upgrade is connected with support for the new device fetures, like Tx drops reporting or disabling meta caching. Moreover, the driver configuration from the sysctl was reworked to provide safer and better flow for configuring: * number of IO queues (new feature), * drbr size on Tx, * Rx queue size. Moreover, a lot of minor bug fixes and improvements were added. Copyright date in the license of the modified files in this release was updated to 2020. Submitted by: Michal Krawczyk <mk@semihalf.com> Obtained from: Semihalf Sponsored by: Amazon, Inc. |
#
9762a033 |
|
26-May-2020 |
Marcin Wojtas <mw@FreeBSD.org> |
Create ENA IO queues with optional backoff If requested size of IO queues is not supported try to decrease it until finding the highest value that can be satisfied. Submitted by: Maciej Bielski <mba@semihalf.com> Obtained from: Semihalf Sponsored by: Amazon, Inc. |
#
7d8c4fee |
|
26-May-2020 |
Marcin Wojtas <mw@FreeBSD.org> |
Rework ENA Rx queue size configuration This patch reworks how the Rx queue size is being reconfigured and how the information from the device is being processed. Reconfiguration of the queues and reset of the device in order to make the changes alive isn't the best approach. It can be done synchronously and it will let to pass information if the reconfiguration was successful to the user. It now is done in the ena_update_queue_size() function. To avoid reallocation of the ring buffer, statistic counters and the reinitialization of the mutexes when only new size has to be assigned, the io queues initialization function has been split into 2 stages: basic, which is just copying appropriate fields and the advanced, which allocates and inits more advanced structures for the IO rings. Moreover, now the max allowed Rx and Tx ring size is being kept statically in the adapter and the size of the variables holding those values has been changed to uint32_t everywhere. Information about IO queues size is now being logged in the up routine instead of the attach. Submitted by: Michal Krawczyk <mk@semihalf.com> Obtained from: Semihalf Sponsored by: Amazon, Inc. |
#
6959869e |
|
26-May-2020 |
Marcin Wojtas <mw@FreeBSD.org> |
Use single global lock in the ENA driver Currently, the driver had 2 global locks - one was sx lock used for up/down synchronization and the second one was mutex, which was used for link configuration and timer service callout. It is better to have single lock for that. We cannot use mutex, as it can sleep and cause witness errors in up/down configuration, so sx lock seems to be the only choice. Callout cannot use sx lock, but the timer service is MP safe, so we just need to avoid race between ena_down() and ena_detach(). It can be avoided by acquiring sx lock. Simple macros were added that are encapsulating implementation of the lock and makes the code cleaner. Submitted by: Michal Krawczyk <mk@semihalf.com> Obtained from: Semihalf Sponsored by: Amazon, Inc. |
#
7926bc44 |
|
26-May-2020 |
Marcin Wojtas <mw@FreeBSD.org> |
Add trigger reset function in the ENA driver As the reset triggering is no longer a simple macro that was just setting appropriate flag, the new function for triggering reset was added. It improves code readability a lot, as we are avoiding additional indentation. Submitted by: Michal Krawczyk <mk@semihalf.com> Obtained from: Semihalf Sponsored by: Amazon, Inc. |
#
8483b844 |
|
26-May-2020 |
Marcin Wojtas <mw@FreeBSD.org> |
Adjust ENA driver to the new HAL * Removed adaptive interrupt moderation (not suported on FreeBSD). * Use ena_com_free_q_entries instead of ena_com_free_desc. * Don't use ENA_MEM_FREE outside of the ena_com. * Don't use barriers before calling doorbells as it's already done in the HAL. * Add function that generates random RSS key, common for all driver's interfaces. * Change admin stats sysctls to U64. Submitted by: Michal Krawczyk <mk@semihalf.com> Obtained from: Semihalf Sponsored by: Amazon, Inc.
|
#
358bcc4c |
|
31-Oct-2019 |
Marcin Wojtas <mw@FreeBSD.org> |
Add support for ENA NETMAP partial initialization In NETMAP mode not all queues need to be allocated to NETMAP. Some of them could be left to the kernel. Configuration is managed by the flags nr_mode and nr_pending_mode provided per each NETMAP kring. ENA driver checks those flags and perform proper rings initialization. Differential Revision: https://reviews.freebsd.org/D21937 Submitted by: Rafal Kozik <rk@semihalf.com> Michal Krawczyk <mk@semihalf.com> Obtained from: Semihalf Sponsored by: Amazon, Inc. |
#
6f2128c7 |
|
31-Oct-2019 |
Marcin Wojtas <mw@FreeBSD.org> |
Add support for ENA NETMAP Tx Two new tables are added to ena_tx_buffer structure: * netmap_map_seg stores DMA mapping structures, * netmap_buf_idx stores buff indexes taken from the slots. When Tx resources are being set, the new mapping structures are created and netmap Tx rings are being reset. When Tx resources are being released, used netmap bufs are unmapped from DMA and then mapping structures are destroyed. When Tx interrupt occurrs, ena_netmap_tx_irq is called. ena_netmap_txsync callback signalizes that there are new packets which should be transmitted. First, it fills ena_netmap_ctx. Then it performs two actions: * ena_netmap_tx_frames moves packets from netmap ring to NIC, * ena_netmap_tx_cleanup restores buffers from NIC and gives them back to the userspace app. 0 is returned in case of Tx error that could be handled by the driver. ena_netmap_tx_frames checks if there are packets ready for transmission. Then, for each of them, ena_netmap_tx_frame is called. If error occurs, transmitting is stopped, but if the error was cause due to HW ring being full, information about that is not propagated to the userspace app. When all packets are ready, doorbell is written to NIC and netmap ring state is updated. Parsing of one packet is done by the ena_netmap_tx_frame function. First, it checks if number of slots does not exceed NIC limit. Invalid packets are being dropped and the error is propagated to the upper layer. As each netmap buffer has equal size, which is typically greater then 2KiB, there shouldn't be any packets which contain too many slots. Then, the ena_com_tx_ctx structure is being filled. As netmap does not support any hardware offloads, ena_com_tx_meta structure is set to zero. After that, ena_netmap_map_slots maps all memory slots for DMA. If the device works in the LLQ mode, the push header is being determined by checking if the header fits within the first socket. If so, the portion of data is being copied directly from the slot. In other case, the data is copied to the intermediate buffer. First slots are treated the same as as the others, because DMA mapping has no impact on LLQ mode. Index of each netmap buffer is taken from slot and stored in netmap_buf_idx array. In case of mapping error, memory is unmapped and packets are put back to the netmap ring. ena_netmap_tx_cleanup performs out of order cleanup of sent buffers. First, req_id is taken and is validated. As validate_tx_req_id from ena.c is specific to kernels mbuf, another implementation is provided. Each req_id is cleaned up by ena_netmap_tx_clean_one function. Buffers are being unmaped from DMA and put back to netmap ring. In the end, state of netmap and NIC rings are being updated. Differential Revision: https://reviews.freebsd.org/D21936 Submitted by: Rafal Kozik <rk@semihalf.com> Michal Krawczyk <mk@semihalf.com> Obtained from: Semihalf Sponsored by: Amazon, Inc. |
#
9a0f2079 |
|
31-Oct-2019 |
Marcin Wojtas <mw@FreeBSD.org> |
Add support for ENA NETMAP Rx Most of code used for Rx ring initialization could be reused in NETMAP. Reset of NETMAP ring and new alloc method was added. Driver decides if use kernels mbufs or NETMAPs slots based on IFCAP_NETMAP flag. It allows to reuse ena_refill_rx_bufs, which provides proper handling of Rx out of order completion. ena_netmap_alloc_rx_slot takes exactly the same arguments as ena_alloc_rx_mbuf, but instead of allocating one mbuf it takes one slot from NETMAP ring. Based on queue id proper netmap_ring is found. As NETMAP provides the "partial opening" feature not all of the rings are avaiable. Not used points to invalid ring. If there is available slot, it is taken from the ring. Its buffer is mapped to DMA and its index is stored in ena_rx_buffer field in ena_rx_buffer structure. Then ena_buf is filled with addresses and ring state is updated. Cleanup is handled by ena_netmap_free_rx_slot. It unmaps DMA and returns buffer to ring. As we could not return more bufs than we have taken and we should not override occupied slots, buf_index should be 0. It is being checked by assertion. ena_netmap_rxsync callback puts received packets back to NETMAP ring and passes them to user space by updating ring pointers. First it fills ena_netmap_ctx. Then it performs two actions: * ena_netmap_rx_frames moves received frames from NIC to NETMAP ring, * ena_netmap_rx_cleanup fills NIC ring with slots released by userspace app. In case of Rx error that could be handled by NIC driver (for example by performing reset) rx sync should return 0. ena_netmap_rx_frames first checks if NETMAP ring is in consistent state and then in the loop receives new frames. When all available frames are taken nr_hwtail is updated. Receiving one frame is handled by ena_netmap_rx_frame. If no error occurrs, each Descriptor is loaded by ena_netmap_rx_load_desc function. If packets take more than one segments NS_MOREFRAG flag must be set in all, but not last slot. In case of wrong req_id packet is removed from NETMAP ring. If packet is successful received counters are updated. Refiling of NIC ring is performed by ena_netmap_rx_cleanup function. It calculates number of available slots and call ena_refill_rx_bufs with proper number. Differential Revision: https://reviews.freebsd.org/D21935 Submitted by: Rafal Kozik <rk@semihalf.com> Michal Krawczyk <mk@semihalf.com> Obtained from: Semihalf Sponsored by: Amazon, Inc. |
#
d17b7d87 |
|
31-Oct-2019 |
Marcin Wojtas <mw@FreeBSD.org> |
Introduce NETMAP support in ENA Mock implementation of NETMAP routines is located in ena_netmap.c/.h files. All code is protected under the DEV_NETMAP macro. Makefile was updated with files and flag. As ENA driver provide own implementations of (un)likely it must be undefined before including NETMAP headers. ena_netmap_attach function is called on the end of NIC attach. It fills structure with NIC configuration and callbacks. Then provides it to netmap_attach. Similarly netmap_detach is called during ena_detach. Three callbacks are used. nm_register is implemented by ena_netmap_reg. It is called when user space application open or close NIC in NETMAP mode. Current action is recognized based on onoff parameter: true means on and false off. As NICs rings need to be reconfigured ena_down and ena_up are reused. When user space application wants to receive new packets from NIC nm_rxsync is called, and when there are new packets ready for Tx nm_txsync is called. Differential Revision: https://reviews.freebsd.org/D21934 Submitted by: Rafal Kozik <rk@semihalf.com> Michal Krawczyk <mk@semihalf.com> Obtained from: Semihalf Sponsored by: Amazon, Inc. |
#
0835cc78 |
|
18-Nov-2020 |
Marcin Wojtas <mw@FreeBSD.org> |
Add SPDX license tag to the ENA driver files Refering to guide: https://wiki.freebsd.org/SPDX the SPDX tag should not replace the standard license text, however it should be added over the standard license text to make the automation easier. Because of that, the old license was kept, but the SPDX tag was added on top of every ENA driver file. Submited by: Michal Krawczyk <mk@semihalf.com> Obtained from: Semihalf Sponsored by: Amazon, Inc MFC after: 1 week Differential revision: https://reviews.freebsd.org/D27117
|
#
2287afd8 |
|
26-May-2020 |
Marcin Wojtas <mw@FreeBSD.org> |
Update ENA driver version to v2.2.0 Driver version upgrade is connected with support for the new device fetures, like Tx drops reporting or disabling meta caching. Moreover, the driver configuration from the sysctl was reworked to provide safer and better flow for configuring: * number of IO queues (new feature), * drbr size on Tx, * Rx queue size. Moreover, a lot of minor bug fixes and improvements were added. Copyright date in the license of the modified files in this release was updated to 2020. Submitted by: Michal Krawczyk <mk@semihalf.com> Obtained from: Semihalf Sponsored by: Amazon, Inc.
|
#
9762a033 |
|
26-May-2020 |
Marcin Wojtas <mw@FreeBSD.org> |
Create ENA IO queues with optional backoff If requested size of IO queues is not supported try to decrease it until finding the highest value that can be satisfied. Submitted by: Maciej Bielski <mba@semihalf.com> Obtained from: Semihalf Sponsored by: Amazon, Inc.
|
#
7d8c4fee |
|
26-May-2020 |
Marcin Wojtas <mw@FreeBSD.org> |
Rework ENA Rx queue size configuration This patch reworks how the Rx queue size is being reconfigured and how the information from the device is being processed. Reconfiguration of the queues and reset of the device in order to make the changes alive isn't the best approach. It can be done synchronously and it will let to pass information if the reconfiguration was successful to the user. It now is done in the ena_update_queue_size() function. To avoid reallocation of the ring buffer, statistic counters and the reinitialization of the mutexes when only new size has to be assigned, the io queues initialization function has been split into 2 stages: basic, which is just copying appropriate fields and the advanced, which allocates and inits more advanced structures for the IO rings. Moreover, now the max allowed Rx and Tx ring size is being kept statically in the adapter and the size of the variables holding those values has been changed to uint32_t everywhere. Information about IO queues size is now being logged in the up routine instead of the attach. Submitted by: Michal Krawczyk <mk@semihalf.com> Obtained from: Semihalf Sponsored by: Amazon, Inc.
|
#
6959869e |
|
26-May-2020 |
Marcin Wojtas <mw@FreeBSD.org> |
Use single global lock in the ENA driver Currently, the driver had 2 global locks - one was sx lock used for up/down synchronization and the second one was mutex, which was used for link configuration and timer service callout. It is better to have single lock for that. We cannot use mutex, as it can sleep and cause witness errors in up/down configuration, so sx lock seems to be the only choice. Callout cannot use sx lock, but the timer service is MP safe, so we just need to avoid race between ena_down() and ena_detach(). It can be avoided by acquiring sx lock. Simple macros were added that are encapsulating implementation of the lock and makes the code cleaner. Submitted by: Michal Krawczyk <mk@semihalf.com> Obtained from: Semihalf Sponsored by: Amazon, Inc.
|
#
7926bc44 |
|
26-May-2020 |
Marcin Wojtas <mw@FreeBSD.org> |
Add trigger reset function in the ENA driver As the reset triggering is no longer a simple macro that was just setting appropriate flag, the new function for triggering reset was added. It improves code readability a lot, as we are avoiding additional indentation. Submitted by: Michal Krawczyk <mk@semihalf.com> Obtained from: Semihalf Sponsored by: Amazon, Inc.
|
#
358bcc4c |
|
31-Oct-2019 |
Marcin Wojtas <mw@FreeBSD.org> |
Add support for ENA NETMAP partial initialization In NETMAP mode not all queues need to be allocated to NETMAP. Some of them could be left to the kernel. Configuration is managed by the flags nr_mode and nr_pending_mode provided per each NETMAP kring. ENA driver checks those flags and perform proper rings initialization. Differential Revision: https://reviews.freebsd.org/D21937 Submitted by: Rafal Kozik <rk@semihalf.com> Michal Krawczyk <mk@semihalf.com> Obtained from: Semihalf Sponsored by: Amazon, Inc.
|
#
6f2128c7 |
|
31-Oct-2019 |
Marcin Wojtas <mw@FreeBSD.org> |
Add support for ENA NETMAP Tx Two new tables are added to ena_tx_buffer structure: * netmap_map_seg stores DMA mapping structures, * netmap_buf_idx stores buff indexes taken from the slots. When Tx resources are being set, the new mapping structures are created and netmap Tx rings are being reset. When Tx resources are being released, used netmap bufs are unmapped from DMA and then mapping structures are destroyed. When Tx interrupt occurrs, ena_netmap_tx_irq is called. ena_netmap_txsync callback signalizes that there are new packets which should be transmitted. First, it fills ena_netmap_ctx. Then it performs two actions: * ena_netmap_tx_frames moves packets from netmap ring to NIC, * ena_netmap_tx_cleanup restores buffers from NIC and gives them back to the userspace app. 0 is returned in case of Tx error that could be handled by the driver. ena_netmap_tx_frames checks if there are packets ready for transmission. Then, for each of them, ena_netmap_tx_frame is called. If error occurs, transmitting is stopped, but if the error was cause due to HW ring being full, information about that is not propagated to the userspace app. When all packets are ready, doorbell is written to NIC and netmap ring state is updated. Parsing of one packet is done by the ena_netmap_tx_frame function. First, it checks if number of slots does not exceed NIC limit. Invalid packets are being dropped and the error is propagated to the upper layer. As each netmap buffer has equal size, which is typically greater then 2KiB, there shouldn't be any packets which contain too many slots. Then, the ena_com_tx_ctx structure is being filled. As netmap does not support any hardware offloads, ena_com_tx_meta structure is set to zero. After that, ena_netmap_map_slots maps all memory slots for DMA. If the device works in the LLQ mode, the push header is being determined by checking if the header fits within the first socket. If so, the portion of data is being copied directly from the slot. In other case, the data is copied to the intermediate buffer. First slots are treated the same as as the others, because DMA mapping has no impact on LLQ mode. Index of each netmap buffer is taken from slot and stored in netmap_buf_idx array. In case of mapping error, memory is unmapped and packets are put back to the netmap ring. ena_netmap_tx_cleanup performs out of order cleanup of sent buffers. First, req_id is taken and is validated. As validate_tx_req_id from ena.c is specific to kernels mbuf, another implementation is provided. Each req_id is cleaned up by ena_netmap_tx_clean_one function. Buffers are being unmaped from DMA and put back to netmap ring. In the end, state of netmap and NIC rings are being updated. Differential Revision: https://reviews.freebsd.org/D21936 Submitted by: Rafal Kozik <rk@semihalf.com> Michal Krawczyk <mk@semihalf.com> Obtained from: Semihalf Sponsored by: Amazon, Inc.
|
#
9a0f2079 |
|
31-Oct-2019 |
Marcin Wojtas <mw@FreeBSD.org> |
Add support for ENA NETMAP Rx Most of code used for Rx ring initialization could be reused in NETMAP. Reset of NETMAP ring and new alloc method was added. Driver decides if use kernels mbufs or NETMAPs slots based on IFCAP_NETMAP flag. It allows to reuse ena_refill_rx_bufs, which provides proper handling of Rx out of order completion. ena_netmap_alloc_rx_slot takes exactly the same arguments as ena_alloc_rx_mbuf, but instead of allocating one mbuf it takes one slot from NETMAP ring. Based on queue id proper netmap_ring is found. As NETMAP provides the "partial opening" feature not all of the rings are avaiable. Not used points to invalid ring. If there is available slot, it is taken from the ring. Its buffer is mapped to DMA and its index is stored in ena_rx_buffer field in ena_rx_buffer structure. Then ena_buf is filled with addresses and ring state is updated. Cleanup is handled by ena_netmap_free_rx_slot. It unmaps DMA and returns buffer to ring. As we could not return more bufs than we have taken and we should not override occupied slots, buf_index should be 0. It is being checked by assertion. ena_netmap_rxsync callback puts received packets back to NETMAP ring and passes them to user space by updating ring pointers. First it fills ena_netmap_ctx. Then it performs two actions: * ena_netmap_rx_frames moves received frames from NIC to NETMAP ring, * ena_netmap_rx_cleanup fills NIC ring with slots released by userspace app. In case of Rx error that could be handled by NIC driver (for example by performing reset) rx sync should return 0. ena_netmap_rx_frames first checks if NETMAP ring is in consistent state and then in the loop receives new frames. When all available frames are taken nr_hwtail is updated. Receiving one frame is handled by ena_netmap_rx_frame. If no error occurrs, each Descriptor is loaded by ena_netmap_rx_load_desc function. If packets take more than one segments NS_MOREFRAG flag must be set in all, but not last slot. In case of wrong req_id packet is removed from NETMAP ring. If packet is successful received counters are updated. Refiling of NIC ring is performed by ena_netmap_rx_cleanup function. It calculates number of available slots and call ena_refill_rx_bufs with proper number. Differential Revision: https://reviews.freebsd.org/D21935 Submitted by: Rafal Kozik <rk@semihalf.com> Michal Krawczyk <mk@semihalf.com> Obtained from: Semihalf Sponsored by: Amazon, Inc.
|
#
d17b7d87 |
|
31-Oct-2019 |
Marcin Wojtas <mw@FreeBSD.org> |
Introduce NETMAP support in ENA Mock implementation of NETMAP routines is located in ena_netmap.c/.h files. All code is protected under the DEV_NETMAP macro. Makefile was updated with files and flag. As ENA driver provide own implementations of (un)likely it must be undefined before including NETMAP headers. ena_netmap_attach function is called on the end of NIC attach. It fills structure with NIC configuration and callbacks. Then provides it to netmap_attach. Similarly netmap_detach is called during ena_detach. Three callbacks are used. nm_register is implemented by ena_netmap_reg. It is called when user space application open or close NIC in NETMAP mode. Current action is recognized based on onoff parameter: true means on and false off. As NICs rings need to be reconfigured ena_down and ena_up are reused. When user space application wants to receive new packets from NIC nm_rxsync is called, and when there are new packets ready for Tx nm_txsync is called. Differential Revision: https://reviews.freebsd.org/D21934 Submitted by: Rafal Kozik <rk@semihalf.com> Michal Krawczyk <mk@semihalf.com> Obtained from: Semihalf Sponsored by: Amazon, Inc.
|