opengnsys_ipxe/src
Michael Brown 8d337ecdae [dma] Move I/O buffer DMA operations to iobuf.h
Include a potential DMA mapping within the definition of an I/O
buffer, and move all I/O buffer DMA mapping functions from dma.h to
iobuf.h.  This avoids the need for drivers to maintain a separate list
of DMA mappings for each I/O buffer that they may handle.

Network device drivers typically do not keep track of transmit I/O
buffers, since the network device core already maintains a transmit
queue.  Drivers will typically call netdev_tx_complete_next() to
complete a transmission without first obtaining the relevant I/O
buffer pointer (and will rely on the network device core automatically
cancelling any pending transmissions when the device is closed).

To allow this driver design approach to be retained, update the
netdev_tx_complete() family of functions to automatically perform the
DMA unmapping operation if required.  For symmetry, also update the
netdev_rx() family of functions to behave the same way.

As a further convenience for drivers, allow the network device core to
automatically perform DMA mapping on the transmit datapath before
calling the driver's transmit() method.  This avoids the need to
introduce a mapping error handling code path into the typically
error-free transmit methods.

With these changes, the modifications required to update a typical
network device driver to use the new DMA API are fairly minimal:

- Allocate and free descriptor rings and similar coherent structures
  using dma_alloc()/dma_free() rather than malloc_phys()/free_phys()

- Allocate and free receive buffers using alloc_rx_iob()/free_rx_iob()
  rather than alloc_iob()/free_iob()

- Calculate DMA addresses using dma() or iob_dma() rather than
  virt_to_bus()

- Set a 64-bit DMA mask if needed using dma_set_mask_64bit() and
  thereafter eliminate checks on DMA address ranges

- Either record the DMA device in netdev->dma, or call iob_map_tx() as
  part of the transmit() method

- Ensure that debug messages use virt_to_phys() when displaying
  "hardware" addresses

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-11-28 20:26:28 +00:00
..
arch [malloc] Rename malloc_dma() to malloc_phys() 2020-11-05 19:13:52 +00:00
bin Rename .cvsignore files to .gitignore 2007-06-09 22:57:00 +01:00
config [dma] Define a DMA API to allow for non-flat device address spaces 2020-11-05 20:03:50 +00:00
core [dma] Move I/O buffer DMA operations to iobuf.h 2020-11-28 20:26:28 +00:00
crypto [deflate] Fix typo in comment describing length codes 2020-07-21 15:59:04 +01:00
doc [build] Rename gPXE to iPXE 2010-04-19 23:43:39 +01:00
drivers [dma] Move I/O buffer DMA operations to iobuf.h 2020-11-28 20:26:28 +00:00
hci [cmdline] Add "--timeout" parameter to "ifconf" command 2020-07-22 12:44:51 +01:00
image [efi] Split device path functions out to efi_path.c 2020-10-16 15:36:37 +01:00
include [dma] Move I/O buffer DMA operations to iobuf.h 2020-11-28 20:26:28 +00:00
interface [dma] Move I/O buffer DMA operations to iobuf.h 2020-11-28 20:26:28 +00:00
libgcc [libgcc] Change __divmoddi4 from int64 [unknown] to int64_t 2020-07-21 14:33:32 +01:00
net [dma] Move I/O buffer DMA operations to iobuf.h 2020-11-28 20:26:28 +00:00
scripts [efi] Centralise architecture-independent EFI Makefile and linker script 2016-03-12 21:47:13 +00:00
tests [libc] Fix memcmp() to return proper values 2020-07-21 15:29:18 +01:00
usr [cmdline] Add "--timeout" parameter to "ifconf" command 2020-07-22 12:44:51 +01:00
util [build] Fix default target in sdsk image 2020-07-21 14:29:12 +01:00
.gitignore [build] Add support for local configuration files 2010-03-26 19:07:22 +00:00
Makefile [bnxt] Add driver support for Broadcom NetXtreme-E Adapters 2020-05-06 15:41:45 +01:00
Makefile.efi [efi] Enable stack protection where possible 2020-06-24 16:23:21 +01:00
Makefile.housekeeping [build] Provide a testable platform macro alongside -DPLATFORM 2020-10-16 15:16:00 +01:00
doxygen.cfg [build] Remove PACKED macro 2010-05-29 23:49:47 +01:00