#include <stdint.h>
#include <string.h>
+#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <assert.h>
******************************************************************************
*/
+/**
+ * Get operating mode name (for debugging)
+ *
+ * @v mode Operating mode
+ * @ret name Mode name
+ */
+static inline const char * gve_mode_name ( unsigned int mode ) {
+ static char buf[ 8 /* "XXX-XXX" + NUL */ ];
+
+ snprintf ( buf, sizeof ( buf ), "%s-%s",
+ ( ( mode & GVE_MODE_DQO ) ? "DQO" : "GQI" ),
+ ( ( mode & GVE_MODE_QPL ) ? "QPL" : "RDA" ) );
+ return buf;
+}
+
/**
* Allocate admin queue
*
}
DBGC ( gve, "GVE %p supports options %#08x\n", gve, gve->options );
+ /* Select preferred operating mode */
+ gve->mode = GVE_MODE_QPL;
+ DBGC ( gve, "GVE %p using %s mode\n",
+ gve, gve_mode_name ( gve->mode ) );
+
return 0;
}
cmd->conf.num_events = cpu_to_be32 ( events->count );
cmd->conf.num_irqs = cpu_to_be32 ( GVE_IRQ_COUNT );
cmd->conf.irq_stride = cpu_to_be32 ( sizeof ( irqs->irq[0] ) );
+ cmd->conf.format = GVE_FORMAT ( gve->mode );
/* Issue command */
if ( ( rc = gve_admin ( gve ) ) != 0 )
uint32_t num_irqs;
/** IRQ doorbell stride */
uint32_t irq_stride;
+ /** MSI-X base index */
+ uint32_t msix_base;
+ /** Descriptor queue format */
+ uint8_t format;
+ /** Reserved */
+ uint8_t reserved[7];
} __attribute__ (( packed ));
+/** Descriptor queue format */
+#define GVE_FORMAT( mode ) ( (mode) + 1 )
+
/** Register page list command */
#define GVE_ADMIN_REGISTER 0x0003
struct gve_scratch scratch;
/** Supported options */
uint32_t options;
+ /** Operating mode */
+ unsigned int mode;
/** Transmit queue */
struct gve_queue tx;
uint32_t activity;
};
+/** Operating mode
+ *
+ * These values are chosen to allow for easy transformation to a queue
+ * format identifier as used for the "Configure device resources"
+ * command.
+ */
+#define GVE_MODE_QPL 0x01 /**< Use registered queue pages */
+#define GVE_MODE_DQO 0x02 /**< Use out-of-order queues */
+
/** Maximum time to wait for admin queue commands */
#define GVE_ADMIN_MAX_WAIT_MS 500