aboutsummaryrefslogtreecommitdiffstats
path: root/src/drivers/net/intel.c
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2020-11-25 15:52:00 +0000
committerMichael Brown <mcb30@ipxe.org>2020-11-25 16:15:55 +0000
commitcf12a41703a8b2292e5d2d7528c2733c37869681 (patch)
tree72e60b6240cdd10816b7dce5fcc98822ae94e957 /src/drivers/net/intel.c
parent24ef743778fb47958441d8891e5104135ac4c168 (diff)
downloadipxe-cf12a41703a8b2292e5d2d7528c2733c37869681.tar.gz
[dma] Modify DMA API to simplify calculation of medial addresses
Redefine the value stored within a DMA mapping to be the offset between physical addresses and DMA addresses within the mapped region. Provide a dma() wrapper function to calculate the DMA address for any pointer within a mapped region, thereby simplifying the use cases when a device needs to be given addresses other than the region start address. On a platform using the "flat" DMA implementation the DMA offset for any mapped region is always zero, with the result that dma_map() can be optimised away completely and dma() reduces to a straightforward call to virt_to_phys(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/drivers/net/intel.c')
-rw-r--r--src/drivers/net/intel.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/drivers/net/intel.c b/src/drivers/net/intel.c
index 408101bad..5c6dc2143 100644
--- a/src/drivers/net/intel.c
+++ b/src/drivers/net/intel.c
@@ -513,7 +513,7 @@ int intel_create_ring ( struct intel_nic *intel, struct intel_ring *ring ) {
memset ( ring->desc, 0, ring->len );
/* Program ring address */
- address = ring->map.addr;
+ address = dma ( &ring->map, ring->desc );
writel ( ( address & 0xffffffffUL ),
( intel->regs + ring->reg + INTEL_xDBAL ) );
if ( sizeof ( physaddr_t ) > sizeof ( uint32_t ) ) {
@@ -571,7 +571,6 @@ void intel_refill_rx ( struct intel_nic *intel ) {
struct dma_mapping *map;
unsigned int rx_idx;
unsigned int rx_tail;
- physaddr_t address;
unsigned int refilled = 0;
/* Refill ring */
@@ -596,8 +595,7 @@ void intel_refill_rx ( struct intel_nic *intel ) {
intel->rx.ring.prod++;
/* Populate receive descriptor */
- address = map->addr;
- intel->rx.ring.describe ( rx, address, 0 );
+ intel->rx.ring.describe ( rx, dma ( map, iobuf->data ), 0 );
DBGC2 ( intel, "INTEL %p RX %d is [%lx,%lx)\n",
intel, rx_idx, virt_to_phys ( iobuf->data ),
@@ -762,7 +760,6 @@ int intel_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) {
struct dma_mapping *map;
unsigned int tx_idx;
unsigned int tx_tail;
- physaddr_t address;
size_t len;
int rc;
@@ -783,9 +780,8 @@ int intel_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) {
intel->tx.ring.prod++;
/* Populate transmit descriptor */
- address = map->addr;
len = iob_len ( iobuf );
- intel->tx.ring.describe ( tx, address, len );
+ intel->tx.ring.describe ( tx, dma ( map, iobuf->data ), len );
wmb();
/* Notify card that there are packets ready to transmit */