[COMMIT osv master] ena: adapt driver admin/setup implementation to OSv

1 view
Skip to first unread message

Commit Bot

unread,
Jan 11, 2024, 12:43:18 PMJan 11
to osv...@googlegroups.com, Waldemar Kozaczuk
From: Waldemar Kozaczuk <jwkoz...@gmail.com>
Committer: WALDEMAR KOZACZUK <jwkoz...@gmail.com>
Branch: master

ena: adapt driver admin/setup implementation to OSv

This patch adapts the middle layer of the admin and device setup/teardown
handling logic to make it work in OSv. It is also the last patch
to complete the porting work of FreeBSD ena driver code to work in
OSv.

The code in ena.cc mostly implements the logic to probe, attach
and detach the device and involves interacting with lower-level admin
API of ena_com/ena_com.cc to submit commands to Admin Queue (AQ) and
receive and process completions from Admin Completion Queue (ACQ).
It also implements interrupt handlers and worker threads to process I/O.
For more details read
https://github.com/amzn/amzn-drivers/tree/master/kernel/fbsd/ena#management-interface.

In particular this patch addresses following:

- change FreeBSD header include paths to match OSv source tree

- eliminate most DMA-related functions ena_*dma_*()

- eliminate metrics task code for now

- eliminate LLQ, RSS and DEV_NETMAP related code

- deactivate counters (aka statistics collection) code

- rewrite ena_dma_alloc() to use OSv memory::alloc_phys_contiguous_aligned()
and mmu::virt_to_phys() (it probably should not have *dma* in name)

- rewrite the functions that setup MSI/X and implement other PCI-related
functionality to use OSv PCI code from drivers/pci-* and arch/*/msi.** -
ena_free_pci_resources(), ena_probe(), ena_enable_msix(),
ena_setup_mgmnt_intr(), ena_setup_io_intr(), ena_request_mgmnt_irq(),
ena_request_io_irq(), ena_free_io_irq(), ena_disable_msix()

- replace the calls to drbr_*() functions with buf_ring_*() equivalent ones

- implement the main function of the enqueue worker thread -
enqueue_work(); this function is used when setting TX resource in
ena_setup_tx_resources() and replaces FreeBSD version of it -
enqueue_tq and enqueue_task

- simplify ena_alloc_rx_mbuf() by mostly not using the DMA-related code

- eliminate ena_update_buf_ring_size(), ena_update_queue_size(),
ena_update_io_rings(), ena_update_io_queue_nb() which are not needed
as OSv will not support changing ring and queue size (see for example
https://github.com/amzn/amzn-drivers/tree/master/kernel/fbsd/ena#size-of-the-tx-buffer-ring-drbr)
through ioctl()

- simplify ena_ioctl()

- implement the main function of the cleanup worker thread -
cleanup_work(); this function is used when setting I/O queues
in ena_create_io_queues() and replaces FreeBSD version of it -
cleanup_tq and cleanup_task

- adjust CSUM_* constant to match the version of OSv version of FreeBSD
headers

- replace if_set*() function calls with equivalent code directly setting
fields of if_t structure (for example if_settransmitfn(ifp,
ena_mq_start) => ifp->if_transmit = ena_mq_start)

- hardcode TX queue memory type to ENA_ADMIN_PLACEMENT_POLICY_HOST (we
do not support LLQ)

- eliminate LLQ-related code - ena_map_llq_mem_bar(),
set_default_llq_configurations() and any ifs testing ENA_ADMIN_PLACEMENT_POLICY_DEV

- adapt code reading current boot time to use osv::clock::uptime::now()

- adapt ena_handle_msix() and other places to use OSV wake_with_irq_or_preemption_disabled()
instead of taskqueue_enqueue()

- add remaining *cc files to the Makefile - everything should compile

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>

---
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -587,6 +587,7 @@ bsd += bsd/sys/kern/uipc_sockbuf.o
bsd += bsd/sys/kern/uipc_socket.o
bsd += bsd/sys/kern/uipc_syscalls.o
bsd += bsd/sys/kern/uipc_syscalls_wrap.o
+bsd += bsd/sys/kern/subr_bufring.o
bsd += bsd/sys/kern/subr_sbuf.o
bsd += bsd/sys/kern/subr_eventhandler.o
bsd += bsd/sys/kern/subr_hash.o
@@ -678,6 +679,10 @@ bsd += bsd/sys/dev/hyperv/vmbus/hyperv.o
endif
ifeq ($(conf_drivers_ena),1)
bsd += bsd/sys/contrib/ena_com/ena_eth_com.o
+bsd += bsd/sys/contrib/ena_com/ena_com.o
+bsd += bsd/sys/dev/ena/ena_datapath.o
+bsd += bsd/sys/dev/ena/ena.o
+$(out)/bsd/sys/dev/ena/%.o: CXXFLAGS += -Ibsd/sys/contrib
endif
endif

diff --git a/bsd/sys/dev/ena/ena.cc b/bsd/sys/dev/ena/ena.cc
--- a/bsd/sys/dev/ena/ena.cc
+++ b/bsd/sys/dev/ena/ena.cc
null
diff --git a/conf/profiles/x64/all.mk b/conf/profiles/x64/all.mk
--- a/conf/profiles/x64/all.mk
+++ b/conf/profiles/x64/all.mk
@@ -6,3 +6,4 @@ include conf/profiles/$(arch)/vmware.mk
include conf/profiles/$(arch)/xen.mk

conf_drivers_vga?=1
+conf_drivers_ena?=1
Reply all
Reply to author
Forward
0 new messages