summaryrefslogtreecommitdiff
path: root/lib/librte_rawdev
diff options
context:
space:
mode:
authorShreyansh Jain <shreyansh.jain@nxp.com>2018-01-31 14:43:10 +0530
committerThomas Monjalon <thomas@monjalon.net>2018-01-31 15:35:18 +0100
commit919be8321e1ad80fc2f9e52100a8a65037196028 (patch)
tree4edca8035cf779f992dde3911de43f977ab06eb1 /lib/librte_rawdev
parentc88b3f2558ed09738d29913169bb865531dcb067 (diff)
downloaddpdk-919be8321e1ad80fc2f9e52100a8a65037196028.zip
dpdk-919be8321e1ad80fc2f9e52100a8a65037196028.tar.gz
dpdk-919be8321e1ad80fc2f9e52100a8a65037196028.tar.xz
rawdev: add attribute get and set
A rawdevice can have various attributes. This patch introduce support for transparently setting attribute value or getting current attribute state. This is done by allowing an opaque set of key and value to be passed through rawdev library. Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
Diffstat (limited to 'lib/librte_rawdev')
-rw-r--r--lib/librte_rawdev/rte_rawdev.c28
-rw-r--r--lib/librte_rawdev/rte_rawdev.h43
-rw-r--r--lib/librte_rawdev/rte_rawdev_pmd.h42
-rw-r--r--lib/librte_rawdev/rte_rawdev_version.map2
4 files changed, 115 insertions, 0 deletions
diff --git a/lib/librte_rawdev/rte_rawdev.c b/lib/librte_rawdev/rte_rawdev.c
index 46353a4..08dd982 100644
--- a/lib/librte_rawdev/rte_rawdev.c
+++ b/lib/librte_rawdev/rte_rawdev.c
@@ -176,6 +176,34 @@ rte_rawdev_queue_release(uint16_t dev_id, uint16_t queue_id)
}
int __rte_experimental
+rte_rawdev_get_attr(uint16_t dev_id,
+ const char *attr_name,
+ uint64_t *attr_value)
+{
+ struct rte_rawdev *dev;
+
+ RTE_RAWDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
+ dev = &rte_rawdevs[dev_id];
+
+ RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->attr_get, -ENOTSUP);
+ return (*dev->dev_ops->attr_get)(dev, attr_name, attr_value);
+}
+
+int __rte_experimental
+rte_rawdev_set_attr(uint16_t dev_id,
+ const char *attr_name,
+ const uint64_t attr_value)
+{
+ struct rte_rawdev *dev;
+
+ RTE_RAWDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
+ dev = &rte_rawdevs[dev_id];
+
+ RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->attr_set, -ENOTSUP);
+ return (*dev->dev_ops->attr_set)(dev, attr_name, attr_value);
+}
+
+int __rte_experimental
rte_rawdev_dump(uint16_t dev_id, FILE *f)
{
struct rte_rawdev *dev;
diff --git a/lib/librte_rawdev/rte_rawdev.h b/lib/librte_rawdev/rte_rawdev.h
index 76a533e..a58abc3 100644
--- a/lib/librte_rawdev/rte_rawdev.h
+++ b/lib/librte_rawdev/rte_rawdev.h
@@ -319,6 +319,49 @@ struct rte_rawdev_buf {
int __rte_experimental
rte_rawdev_dump(uint16_t dev_id, FILE *f);
+/**
+ * Get an attribute value from implementation.
+ * Attribute is an opaque handle agreed upon between application and PMD.
+ *
+ * Implementations are expected to maintain an array of attribute-value pairs
+ * based on application calls. Memory management for this structure is
+ * shared responsibility of implementation and application.
+ *
+ * @param dev_id
+ * The identifier of the device to configure.
+ * @param attr_name
+ * Opaque object representing an attribute in implementation.
+ * @param attr_value [out]
+ * Opaque response to the attribute value. In case of error, this remains
+ * untouched. This is double pointer of void type.
+ * @return
+ * 0 for success
+ * !0 Error; attr_value remains untouched in case of error.
+ */
+int __rte_experimental
+rte_rawdev_get_attr(uint16_t dev_id,
+ const char *attr_name,
+ uint64_t *attr_value);
+
+/**
+ * Set an attribute value.
+ * Attribute is an opaque handle agreed upon between application and PMD.
+ *
+ * @param dev_id
+ * The identifier of the device to configure.
+ * @param attr_name
+ * Opaque object representing an attribute in implementation.
+ * @param attr_value
+ * Value of the attribute represented by attr_name
+ * @return
+ * 0 for success
+ * !0 Error
+ */
+int __rte_experimental
+rte_rawdev_set_attr(uint16_t dev_id,
+ const char *attr_name,
+ const uint64_t attr_value);
+
#ifdef __cplusplus
}
#endif
diff --git a/lib/librte_rawdev/rte_rawdev_pmd.h b/lib/librte_rawdev/rte_rawdev_pmd.h
index aeb3711..3e64369 100644
--- a/lib/librte_rawdev/rte_rawdev_pmd.h
+++ b/lib/librte_rawdev/rte_rawdev_pmd.h
@@ -264,6 +264,43 @@ typedef int (*rawdev_queue_release_t)(struct rte_rawdev *dev,
*/
typedef int (*rawdev_dump_t)(struct rte_rawdev *dev, FILE *f);
+/**
+ * Get an attribute value from implementation.
+ * Attribute is an opaque handle agreed upon between application and PMD.
+ *
+ * @param dev
+ * Raw device pointer
+ * @param attr_name
+ * Opaque object representing an attribute in implementation.
+ * @param attr_value [out]
+ * Opaque response to the attribute value. In case of error, this remains
+ * untouched. This is double pointer of void type.
+ * @return
+ * 0 for success
+ * !0 Error; attr_value remains untouched in case of error.
+ */
+typedef int (*rawdev_get_attr_t)(struct rte_rawdev *dev,
+ const char *attr_name,
+ uint64_t *attr_value);
+
+/**
+ * Set an attribute value.
+ * Attribute is an opaque handle agreed upon between application and PMD.
+ *
+ * @param dev
+ * Raw device pointer
+ * @param attr_name
+ * Opaque object representing an attribute in implementation.
+ * @param attr_value
+ * Value of the attribute represented by attr_name
+ * @return
+ * 0 for success
+ * !0 Error
+ */
+typedef int (*rawdev_set_attr_t)(struct rte_rawdev *dev,
+ const char *attr_name,
+ const uint64_t attr_value);
+
/** Rawdevice operations function pointer table */
struct rte_rawdev_ops {
/**< Get device info. */
@@ -288,6 +325,11 @@ struct rte_rawdev_ops {
/* Dump internal information */
rawdev_dump_t dump;
+
+ /**< Get an attribute managed by the implementation */
+ rawdev_get_attr_t attr_get;
+ /**< Set an attribute managed by the implementation */
+ rawdev_set_attr_t attr_set;
};
/**
diff --git a/lib/librte_rawdev/rte_rawdev_version.map b/lib/librte_rawdev/rte_rawdev_version.map
index 64e60d9..d63476e 100644
--- a/lib/librte_rawdev/rte_rawdev_version.map
+++ b/lib/librte_rawdev/rte_rawdev_version.map
@@ -4,6 +4,7 @@ EXPERIMENTAL {
rte_rawdev_close;
rte_rawdev_configure;
rte_rawdev_count;
+ rte_rawdev_get_attr;
rte_rawdev_get_dev_id;
rte_rawdev_info_get;
rte_rawdev_pmd_allocate;
@@ -12,6 +13,7 @@ EXPERIMENTAL {
rte_rawdev_queue_setup;
rte_rawdev_queue_release;
rte_rawdev_reset;
+ rte_rawdev_set_attr;
rte_rawdev_socket_id;
rte_rawdev_start;
rte_rawdev_stop;