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

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



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

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

diff --git a/lib/ukconsdev/consdev.c b/lib/ukconsdev/consdev.c
index f58a3266..d61d42a8 100644
--- a/lib/ukconsdev/consdev.c
+++ b/lib/ukconsdev/consdev.c
@@ -45,6 +45,45 @@ 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_rx_info_get(struct uk_consdev *dev,
+               struct uk_consdev_ring_info *ring_info)
+{
+       UK_ASSERT(dev);
+       UK_ASSERT(dev->ops);
+       UK_ASSERT(dev->ops->rx_info_get);
+       UK_ASSERT(ring_info);
+
+       /* Clear values before querying driver ring specifications */
+       memset(ring_info, 0, sizeof(*ring_info));
+       return dev->ops->rx_info_get(dev, ring_info);
+}
+
+int uk_consdev_tx_info_get(struct uk_consdev *dev,
+               struct uk_consdev_ring_info *ring_info)
+{
+       UK_ASSERT(dev);
+       UK_ASSERT(dev->ops);
+       UK_ASSERT(dev->ops->tx_info_get);
+       UK_ASSERT(ring_info);
+
+       /* Clear values before querying driver for ring specifications */
+       memset(ring_info, 0, sizeof(*ring_info));
+       return dev->ops->tx_info_get(dev, ring_info);
+}
+
 unsigned int uk_consdev_count(void)
 {
        return (unsigned int) consdev_count;
@@ -112,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->rx_info_get);
+       UK_ASSERT(dev->ops->tx_info_get);
        UK_ASSERT(dev->ops->close);
 
        dev->_data = _alloc_data(a, consdev_count, drv_name);
diff --git a/lib/ukconsdev/exportsyms.uk b/lib/ukconsdev/exportsyms.uk
index 60dd37ee..f456b117 100644
--- a/lib/ukconsdev/exportsyms.uk
+++ b/lib/ukconsdev/exportsyms.uk
@@ -1,3 +1,6 @@
+uk_consdev_info_get
+uk_consdev_rx_info_get
+uk_consdev_tx_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 0e7af23b..3d98e5cc 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 ring capabilities.
+ * Information that is useful for device ring initialization (e.g.,
+ * maximum number of supported descriptors on RX).
+ *
+ * @param dev
+ *   The Unikraft Console Device in configured state.
+ * @param ring_info
+ *   A pointer to a structure of type *uk_consdev_ring_info* to be filled out
+ * @return
+ *   - (0): Success, ring_info is filled out.
+ *   - (<0): Error code of the drivers function.
+ */
+int uk_consdev_rx_info_get(struct uk_consdev *dev,
+               struct uk_consdev_ring_info *ring_info);
+
+/**
+ * Query receive device ring capabilities.
+ * Information that is useful for device ring initialization (e.g.,
+ * maximum number of supported descriptors on TX).
+ *
+ * @param dev
+ *   The Unikraft Console Device in configured state.
+ * @param ring_info
+ *   A pointer to a structure of type *uk_consdev_ring_info* to be filled out
+ * @return
+ *   - (0): Success, ring_info is filled out.
+ *   - (<0): Error code of the drivers function.
+ */
+int uk_consdev_tx_info_get(struct uk_consdev *dev,
+               struct uk_consdev_ring_info *ring_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 3694f2be..5edc159a 100644
--- a/lib/ukconsdev/include/uk/consdev_core.h
+++ b/lib/ukconsdev/include/uk/consdev_core.h
@@ -71,10 +71,52 @@ enum uk_consdev_state {
        UK_CONSDEV_RUNNING,
 };
 
+/**
+ * Structure used to describe console device capabilities.
+ */
+struct uk_consdev_info {
+
+};
+
+/**
+ * Structure used to describe device descriptor ring limitations.
+ */
+struct uk_consdev_ring_info {
+       /* Max allowed number of descriptors. */
+       uint16_t nb_max;
+       /* Min allowed number of descriptors. */
+       uint16_t nb_min;
+       /* Number should be a multiple of nb_align. */
+       uint16_t nb_align;
+       /* Number should be a power of two. */
+       int nb_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 ring limitations,
+ *  used for configuring the RX ring later
+ */
+typedef int (*uk_consdev_rx_info_t) (struct uk_consdev *dev,
+               struct uk_consdev_ring_info *ring_info);
+
+/** Driver callback type to retrieve TX ring limitations,
+ *  used for configuring the TX ring later
+ */
+typedef int (*uk_consdev_tx_info_t) (struct uk_consdev *dev,
+               struct uk_consdev_ring_info *ring_info);
+
 /** Driver callback type to close an Unikraft console device. */
 typedef void (*uk_consdev_close_t)(struct uk_consdev *dev);
 
 struct uk_consdev_ops {
+       uk_consdev_info_t                   info_get;
+       uk_consdev_rx_info_t                rx_info_get;
+       uk_consdev_tx_info_t                tx_info_get;
        uk_consdev_close_t                  close;
 };
 
-- 
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®.