[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT PATCH v2 3/7] lib/ukconsdev: Get console device info/capabilities/etc



This patch queries for the console capabilities,
such as rx/tx size.

Signed-off-by: Birlea Costin <costin.birlea@xxxxxxxxx>
---
 lib/ukconsdev/consdev.c                 | 41 ++++++++++++++++++++++++++++
 lib/ukconsdev/exportsyms.uk             |  3 +++
 lib/ukconsdev/include/uk/consdev.h      | 48 +++++++++++++++++++++++++++++++++
 lib/ukconsdev/include/uk/consdev_core.h | 43 +++++++++++++++++++++++++++++
 4 files changed, 135 insertions(+)

diff --git a/lib/ukconsdev/consdev.c b/lib/ukconsdev/consdev.c
index eaf430bf..1b155190 100644
--- a/lib/ukconsdev/consdev.c
+++ b/lib/ukconsdev/consdev.c
@@ -45,6 +45,44 @@ struct uk_consdev_list uk_consdev_list =
 
 static uint16_t consdev_count;
 
+void uk_consdev_info_get(struct uk_consdev *dev,
+               struct uk_consdev_info *dev_info)
+{
+       UK_ASSERT(dev);
+       UK_ASSERT(dev->ops);
+       UK_ASSERT(dev->ops->info_get);
+       UK_ASSERT(dev_info);
+
+       /* Clear values before querying driver for capabilities */
+       memset(dev_info, 0, sizeof(*dev_info));
+       dev->ops->info_get(dev, dev_info);
+}
+
+int uk_consdev_rxq_info_get(struct uk_consdev *dev,
+               struct uk_consdev_queue_info *queue_info)
+{
+       UK_ASSERT(dev);
+       UK_ASSERT(dev->ops);
+       UK_ASSERT(dev->ops->rxq_info_get);
+       UK_ASSERT(queue_info);
+
+       /* Clear values before querying driver for queue specifications */
+       memset(queue_info, 0, sizeof(*queue_info));
+       return dev->ops->rxq_info_get(dev, queue_info);
+}
+
+int uk_consdev_txq_info_get(struct uk_consdev *dev,
+               struct uk_consdev_queue_info *queue_info)
+{
+       UK_ASSERT(dev);
+       UK_ASSERT(dev->ops);
+       UK_ASSERT(dev->ops->txq_info_get);
+       UK_ASSERT(queue_info);
+
+       /* Clear values before querying driver for queue specifications */
+       memset(queue_info, 0, sizeof(*queue_info));
+       return dev->ops->txq_info_get(dev, queue_info);
+}
 
 unsigned int uk_consdev_count(void)
 {
@@ -113,6 +151,9 @@ int uk_consdev_drv_register(struct uk_consdev *dev, struct 
uk_alloc *a,
        UK_ASSERT(PTRISERR(dev->_data));
        /* Assert mandatory configuration. */
        UK_ASSERT(dev->ops);
+       UK_ASSERT(dev->ops->info_get);
+       UK_ASSERT(dev->ops->rxq_info_get);
+       UK_ASSERT(dev->ops->txq_info_get);
        dev->_data = _alloc_data(a, consdev_count, drv_name);
        if (!dev->_data)
                return -ENOMEM;
diff --git a/lib/ukconsdev/exportsyms.uk b/lib/ukconsdev/exportsyms.uk
index 5e2d914d..3e8944d1 100644
--- a/lib/ukconsdev/exportsyms.uk
+++ b/lib/ukconsdev/exportsyms.uk
@@ -1,3 +1,6 @@
+uk_consdev_info_get
+uk_consdev_rxq_info_get
+uk_consdev_txq_info_get
 uk_consdev_count
 uk_consdev_get
 uk_consdev_id_get
diff --git a/lib/ukconsdev/include/uk/consdev.h 
b/lib/ukconsdev/include/uk/consdev.h
index 78910293..2b61dcf0 100644
--- a/lib/ukconsdev/include/uk/consdev.h
+++ b/lib/ukconsdev/include/uk/consdev.h
@@ -76,6 +76,54 @@ extern "C" {
 #endif
 
 /**
+ * Query device capabilities.
+ * Information that is useful for device initialization
+ *
+ * @param dev
+ *     The Unikraft Console Device.
+ * @param dev_info
+ *     A pointer to a structure of type *uk_consdev_info* to be filled with
+ *     the contextual information of a console device.
+ * @return
+ *     - (0): Success
+ *     - (<0): Error in driver
+ */
+void uk_consdev_info_get(struct uk_consdev *dev,
+               struct uk_consdev_info *dev_info);
+
+/**
+ * Query receive device queue capabilities.
+ * Information that is useful for device queue initialization (e.g.,
+ * size of RX/maximum number of supported descriptors on RX).
+ *
+ * @param dev
+ *   The Unikraft Console Device.
+ * @param queue_info
+ *   A pointer to a structure of type *uk_consdev_queue_info* to be filled out
+ * @return
+ *   - (0): Success, queue_info is filled out.
+ *   - (<0): Error code of the drivers function.
+ */
+int uk_consdev_rxq_info_get(struct uk_consdev *dev,
+               struct uk_consdev_queue_info *queue_info);
+
+/**
+ * Query receive device queue capabilities.
+ * Information that is useful for device queue initialization (e.g.,
+ * size of TX/maximum number of supported descriptors on TX).
+ *
+ * @param dev
+ *   The Unikraft Console Device.
+ * @param queue_info
+ *   A pointer to a structure of type *uk_consdev_queue_info* to be filled out
+ * @return
+ *   - (0): Success, queue_info is filled out.
+ *   - (<0): Error code of the drivers function.
+ */
+int uk_consdev_txq_info_get(struct uk_consdev *dev,
+               struct uk_consdev_queue_info *queue_info);
+
+/**
  * Get the number of available Unikraft Console devices.
  *
  * @return
diff --git a/lib/ukconsdev/include/uk/consdev_core.h 
b/lib/ukconsdev/include/uk/consdev_core.h
index 7227d39e..d3e8409b 100644
--- a/lib/ukconsdev/include/uk/consdev_core.h
+++ b/lib/ukconsdev/include/uk/consdev_core.h
@@ -71,7 +71,50 @@ enum uk_consdev_state {
        UK_CONSDEV_RUNNING,
 };
 
+/**
+ * Structure used to describe console device capabilities.
+ */
+struct uk_consdev_info {
+
+};
+
+/**
+ * Structure used to describe device queue limitations.
+ */
+struct uk_consdev_queue_info {
+       /* Max allowed size of queue. */
+       uint16_t size_max;
+       /* Min allowed size of queue. */
+       uint16_t size_min;
+       /* Size should be a multiple of size_align. */
+       uint16_t size_align;
+       /* Size should be a power of two. */
+       int size_is_power_of_two;
+};
+
+/** Driver callback type to read device/driver capabilities,
+ *  used for configuring the device
+ */
+typedef void (*uk_consdev_info_t) (struct uk_consdev *dev,
+               struct uk_consdev_info *dev_info);
+
+/** Driver callback type to retrieve RX queue limitations,
+ *  used for configuring the RX queue later
+ */
+typedef int (*uk_consdev_rxq_info_t) (struct uk_consdev *dev,
+               struct uk_consdev_queue_info *queue_info);
+
+/** Driver callback type to retrieve TX queue limitations,
+ *  used for configuring the TX queue later
+ */
+typedef int (*uk_consdev_txq_info_t) (struct uk_consdev *dev,
+               struct uk_consdev_queue_info *queue_info);
+
+
 struct uk_consdev_ops {
+       uk_consdev_info_t                   info_get;
+       uk_consdev_rxq_info_t               rxq_info_get;
+       uk_consdev_txq_info_t               txq_info_get;
 
 };
 
-- 
2.11.0


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.