]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[gve] Add concept of a queue page list base device address
authorMichael Brown <mcb30@ipxe.org>
Mon, 29 Sep 2025 11:04:13 +0000 (12:04 +0100)
committerMichael Brown <mcb30@ipxe.org>
Mon, 29 Sep 2025 14:13:55 +0000 (15:13 +0100)
Allow for the existence of a queue page list where the base device
address is non-zero, as will be the case for the raw DMA addressing
(RDA) operating mode.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/drivers/net/gve.c
src/drivers/net/gve.h

index 62e02f05042ace9045f8b534c01fcb1a34554d02..d1f129e2e40924926c15e28dc0a380e8d7b8abdb 100644 (file)
@@ -848,14 +848,14 @@ static void gve_free_qpl ( struct gve_nic *nic __unused,
 }
 
 /**
- * Get buffer address (within queue page list address space)
+ * Get buffer offset (within queue page list allocation)
  *
  * @v queue            Descriptor queue
  * @v index            Buffer index
  * @ret addr           Buffer address within queue page list address space
  */
 static inline __attribute__ (( always_inline)) size_t
-gve_address ( struct gve_queue *queue, unsigned int index ) {
+gve_offset ( struct gve_queue *queue, unsigned int index ) {
 
        /* We allocate sufficient pages for the maximum fill level of
         * buffers, and reuse the pages in strict rotation as we
@@ -864,6 +864,20 @@ gve_address ( struct gve_queue *queue, unsigned int index ) {
        return ( ( index & ( queue->fill - 1 ) ) * GVE_BUF_SIZE );
 }
 
+/**
+ * Get buffer address (within queue page list address space)
+ *
+ * @v queue            Descriptor queue
+ * @v index            Buffer index
+ * @ret addr           Buffer address within queue page list address space
+ */
+static inline __attribute__ (( always_inline)) physaddr_t
+gve_address ( struct gve_queue *queue, unsigned int index ) {
+
+       /* Pages are allocated as a single contiguous block */
+       return ( queue->qpl.base + gve_offset ( queue, index ) );
+}
+
 /**
  * Get buffer address
  *
@@ -874,8 +888,8 @@ gve_address ( struct gve_queue *queue, unsigned int index ) {
 static inline __attribute__ (( always_inline )) void *
 gve_buffer ( struct gve_queue *queue, unsigned int index ) {
 
-       /* Pages are currently allocated as a single contiguous block */
-       return ( queue->qpl.data + gve_address ( queue, index ) );
+       /* Pages are allocated as a single contiguous block */
+       return ( queue->qpl.data + gve_offset ( queue, index ) );
 }
 
 /**
@@ -1326,7 +1340,7 @@ static int gve_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) {
                DBGC2 ( gve, "GVE %p TX %#04x %#02x:%#02x len %#04x/%#04x at "
                        "%#08zx\n", gve, index, desc->type, desc->count,
                        be16_to_cpu ( desc->len ), be16_to_cpu ( desc->total ),
-                       gve_address ( tx, index ) );
+                       gve_offset ( tx, index ) );
        }
        assert ( ( tx->prod - tx->cons ) <= tx->fill );
 
@@ -1401,7 +1415,7 @@ static void gve_poll_rx ( struct net_device *netdev ) {
                len = be16_to_cpu ( cmplt->len );
                DBGC2 ( gve, "GVE %p RX %#04x %#02x:%#02x len %#04zx at "
                        "%#08zx\n", gve, index, cmplt->seq, cmplt->flags,
-                       len, gve_address ( rx, index ) );
+                       len, gve_offset ( rx, index ) );
 
                /* Accumulate a complete packet */
                if ( cmplt->flags & GVE_RXF_ERROR ) {
index 333839be6a3f803454ed4a1ebbb687e5b948c2b2..e3d6c3f76b4ef2547d1e1cef856f7abd86371633 100644 (file)
@@ -524,6 +524,13 @@ struct gve_qpl {
        unsigned int count;
        /** Queue page list ID */
        unsigned int id;
+       /** Queue page list base device address
+        *
+        * This will be zero if queue page list addressing is in use,
+        * or the DMA address of the first page if raw DMA addressing
+        * is in use.
+        */
+       physaddr_t base;
 };
 
 /**