summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasvinder Singh <jasvinder.singh@intel.com>2018-03-29 19:31:21 +0100
committerCristian Dumitrescu <cristian.dumitrescu@intel.com>2018-04-04 12:21:23 +0200
commit406a2bc0c6cf318f1172e0ee0ae2ed2f8e83837c (patch)
treef776005d35f5c8506157fc22154fdb60da0494c1
parent654dd411125475a15a91769aa12bd39667838dde (diff)
downloaddpdk-406a2bc0c6cf318f1172e0ee0ae2ed2f8e83837c.zip
dpdk-406a2bc0c6cf318f1172e0ee0ae2ed2f8e83837c.tar.gz
dpdk-406a2bc0c6cf318f1172e0ee0ae2ed2f8e83837c.tar.xz
pipeline: get table action params
Add API to specify action related parameters such as action handler, table entry data size, etc. for the pipeline table. Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
-rw-r--r--lib/librte_pipeline/rte_pipeline_version.map1
-rw-r--r--lib/librte_pipeline/rte_table_action.c130
-rw-r--r--lib/librte_pipeline/rte_table_action.h14
3 files changed, 145 insertions, 0 deletions
diff --git a/lib/librte_pipeline/rte_pipeline_version.map b/lib/librte_pipeline/rte_pipeline_version.map
index 4bc414c..13337de 100644
--- a/lib/librte_pipeline/rte_pipeline_version.map
+++ b/lib/librte_pipeline/rte_pipeline_version.map
@@ -56,5 +56,6 @@ EXPERIMENTAL {
rte_table_action_profile_create;
rte_table_action_profile_free;
rte_table_action_profile_freeze;
+ rte_table_action_table_params_get;
} DPDK_16.04;
diff --git a/lib/librte_pipeline/rte_table_action.c b/lib/librte_pipeline/rte_table_action.c
index f15847c..09f26f5 100644
--- a/lib/librte_pipeline/rte_table_action.c
+++ b/lib/librte_pipeline/rte_table_action.c
@@ -267,6 +267,136 @@ rte_table_action_apply(struct rte_table_action *action,
}
}
+static __rte_always_inline uint64_t
+pkt_work(struct rte_mbuf *mbuf __rte_unused,
+ struct rte_pipeline_table_entry *table_entry __rte_unused,
+ uint64_t time __rte_unused,
+ struct rte_table_action *action __rte_unused,
+ struct ap_config *cfg __rte_unused)
+{
+ return 0;
+}
+
+static __rte_always_inline uint64_t
+pkt4_work(struct rte_mbuf **mbufs __rte_unused,
+ struct rte_pipeline_table_entry **table_entries __rte_unused,
+ uint64_t time __rte_unused,
+ struct rte_table_action *action __rte_unused,
+ struct ap_config *cfg __rte_unused)
+{
+ return 0;
+}
+
+static __rte_always_inline int
+ah(struct rte_pipeline *p,
+ struct rte_mbuf **pkts,
+ uint64_t pkts_mask,
+ struct rte_pipeline_table_entry **entries,
+ struct rte_table_action *action,
+ struct ap_config *cfg)
+{
+ uint64_t pkts_drop_mask = 0;
+ uint64_t time = 0;
+
+ if ((pkts_mask & (pkts_mask + 1)) == 0) {
+ uint64_t n_pkts = __builtin_popcountll(pkts_mask);
+ uint32_t i;
+
+ for (i = 0; i < (n_pkts & (~0x3LLU)); i += 4) {
+ uint64_t drop_mask;
+
+ drop_mask = pkt4_work(&pkts[i],
+ &entries[i],
+ time,
+ action,
+ cfg);
+
+ pkts_drop_mask |= drop_mask << i;
+ }
+
+ for ( ; i < n_pkts; i++) {
+ uint64_t drop_mask;
+
+ drop_mask = pkt_work(pkts[i],
+ entries[i],
+ time,
+ action,
+ cfg);
+
+ pkts_drop_mask |= drop_mask << i;
+ }
+ } else
+ for ( ; pkts_mask; ) {
+ uint32_t pos = __builtin_ctzll(pkts_mask);
+ uint64_t pkt_mask = 1LLU << pos;
+ uint64_t drop_mask;
+
+ drop_mask = pkt_work(pkts[pos],
+ entries[pos],
+ time,
+ action,
+ cfg);
+
+ pkts_mask &= ~pkt_mask;
+ pkts_drop_mask |= drop_mask << pos;
+ }
+
+ rte_pipeline_ah_packet_drop(p, pkts_drop_mask);
+
+ return 0;
+}
+
+static int
+ah_default(struct rte_pipeline *p,
+ struct rte_mbuf **pkts,
+ uint64_t pkts_mask,
+ struct rte_pipeline_table_entry **entries,
+ void *arg)
+{
+ struct rte_table_action *action = arg;
+
+ return ah(p,
+ pkts,
+ pkts_mask,
+ entries,
+ action,
+ &action->cfg);
+}
+
+static rte_pipeline_table_action_handler_hit
+ah_selector(struct rte_table_action *action)
+{
+ if (action->cfg.action_mask == (1LLU << RTE_TABLE_ACTION_FWD))
+ return NULL;
+
+ return ah_default;
+}
+
+int
+rte_table_action_table_params_get(struct rte_table_action *action,
+ struct rte_pipeline_table_params *params)
+{
+ rte_pipeline_table_action_handler_hit f_action_hit;
+ uint32_t total_size;
+
+ /* Check input arguments */
+ if ((action == NULL) ||
+ (params == NULL))
+ return -EINVAL;
+
+ f_action_hit = ah_selector(action);
+ total_size = rte_align32pow2(action->data.total_size);
+
+ /* Fill in params */
+ params->f_action_hit = f_action_hit;
+ params->f_action_miss = NULL;
+ params->arg_ah = (f_action_hit) ? action : NULL;
+ params->action_data_size = total_size -
+ sizeof(struct rte_pipeline_table_entry);
+
+ return 0;
+}
+
int
rte_table_action_free(struct rte_table_action *action)
{
diff --git a/lib/librte_pipeline/rte_table_action.h b/lib/librte_pipeline/rte_table_action.h
index da7f12c..03b77ca 100644
--- a/lib/librte_pipeline/rte_table_action.h
+++ b/lib/librte_pipeline/rte_table_action.h
@@ -194,6 +194,20 @@ int __rte_experimental
rte_table_action_free(struct rte_table_action *action);
/**
+ * Table action table params get.
+ *
+ * @param[in] action
+ * Handle to table action object (needs to be valid).
+ * @param[inout] params
+ * Pipeline table parameters (needs to be pre-allocated).
+ * @return
+ * Zero on success, non-zero error code otherwise.
+ */
+int __rte_experimental
+rte_table_action_table_params_get(struct rte_table_action *action,
+ struct rte_pipeline_table_params *params);
+
+/**
* Table action apply.
*
* @param[in] action