diff mbox

[RFC,2/2] api: classification: add odp_cls_context routines for stateful classification

Message ID 1435240349-29763-3-git-send-email-bill.fischofer@linaro.org
State New
Headers show

Commit Message

Bill Fischofer June 25, 2015, 1:52 p.m. UTC
Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
---
 include/odp/api/classification.h | 87 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 86 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/include/odp/api/classification.h b/include/odp/api/classification.h
index f597b26..3f7b1b7 100644
--- a/include/odp/api/classification.h
+++ b/include/odp/api/classification.h
@@ -24,6 +24,16 @@  extern "C" {
  *  @{
  */
 
+/**
+ * @typedef odp_cls_context_t
+ * Context for classification rule chains
+ */
+
+/**
+ * @def ODP_CLS_CONTEXT_INVALID
+ * This value is the "null context" used to represent
+ * no context.
+ */
 
 /**
  * @typedef odp_cos_t
@@ -43,7 +53,7 @@  extern "C" {
  */
 
 /**
- * @def ODP_COS_NAME_LEN
+  * @def ODP_COS_NAME_LEN
  * Maximum ClassOfService name length in chars
  */
 
@@ -60,6 +70,48 @@  extern "C" {
  */
 
 /**
+ * Create a classification context
+ *
+ * @param  name Name for context lookup, or NULL for anonymous
+ *
+ * @return ctx      Classification context handle
+ * @retval          ODP_CLS_CONTEXT_INVALID on failure
+ */
+odp_cls_context_t odp_cls_context_create(const char *name);
+
+/**
+ * Destroy a classification context
+ *
+ * @param ctx       Classification context handle
+ * @retval          0 on success
+ * @retval          <0 on failure
+ */
+int odp_cls_context_destroy(odp_cls_context_t ctx);
+
+/**
+ * Lookup a classification context
+ *
+ * @param name  String name of the context to be retrieved
+ *
+ * @return ctx      Classification context handle
+ * @retval          ODP_CLS_CONTEXT_INVALID on lookup failure
+ */
+odp_cls_context_t odp_cls_context_lookup(const char *name);
+
+/**
+ * Get printable value for an odp_cls_context_t
+ *
+ * @param ctx   Handle to be printed
+ * @return      uint64_t value that can be used to print/display
+ *              this handle
+ *
+ * @note This routine is intended to be used for diagnostic purposes
+ * to enable applications to generate a printable value that represents
+ * an odp_cls_context_t handle.
+ */
+uint64_t odp_cls_context_to_u64(odp_cls_context_t ctx);
+
+/**
  * Class-of-service packet drop policies
  */
 typedef enum odp_cos_drop {
@@ -263,6 +315,39 @@  int odp_pktio_pmr_cos(odp_pmr_t pmr_id,
 		      odp_pktio_t src_pktio, odp_cos_t dst_cos);
 
 /**
+ * Apply a PMR to a classification context to assign a CoS.
+ *
+ * @param[in]   ctx             Classification context to which
+ *                              this PMR is to be applied
+ * @param[in]	pmr_id		PMR to be activated
+ * @param[in]	dst_cos		CoS to be assigned by this PMR
+ *
+ * @retval		0 on success
+ * @retval		<0 on failure
+ */
+int odp_cls_context_pmr_cos(odp_cls_context_t ctx,
+			    odp_pmr_t pmr_id, odp_cos_t dst_cos);
+
+/**
+ * Apply a classification context to a pktio to make it active
+ *
+ * @param      src_pktio   pktio to which this context is to be applies
+ * @param      new_ctx     context to be applied to this pktio
+ * @param[out] old_ctx     prior context that was applied to this pktio
+ *
+ * @retval                 0 on success
+ * @retval                 <0 on failure
+ *
+ * @note Applying a classification context to a pktio that has no current
+ * context returns ODP_CLS_CONTEXT_INVALID as the old_ctx. Similarly, to
+ * remove a classification context from a pktio use ODP_CLS_CONTEXT_INVALID
+ * as the new_ctx.
+ */
+int odp_pktio_cls_context_swap(odp_pktio_t src_pktio,
+			       odp_cls_context_t new_ctx,
+			       odp_cls_context_t *old_ctx);
+
+/**
  * Cascade a PMR to refine packets from one CoS to another.
  *
  * @param[in]	pmr_id		PMR to be activated