aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-plugin/src
diff options
context:
space:
mode:
authorAlberto Compagno <acompagn+fdio@cisco.com>2019-05-03 15:11:28 +0200
committerAlberto Compagno <acompagn+fdio@cisco.com>2019-05-07 14:35:59 +0200
commit3ba9071c6899d64b36e910943f109ddc7c7e0809 (patch)
treedbfe4c6f2b10c4b7c824cc8b4c6d4003ba5422b3 /hicn-plugin/src
parentcd48bbd9685f042a2f1f90678f8fa98a5175ea4d (diff)
[HICN-181] Added round robin strategy
Change-Id: I301ffaeed6f43b7db6701810167f02947439d20c Signed-off-by: Alberto Compagno <acompagn+fdio@cisco.com>
Diffstat (limited to 'hicn-plugin/src')
-rw-r--r--hicn-plugin/src/error.h2
-rw-r--r--hicn-plugin/src/strategies/dpo_rr.c312
-rw-r--r--hicn-plugin/src/strategies/dpo_rr.h135
-rw-r--r--hicn-plugin/src/strategies/strategy_mw.c6
-rw-r--r--hicn-plugin/src/strategies/strategy_mw_cli.c2
-rw-r--r--hicn-plugin/src/strategies/strategy_rr.c169
-rw-r--r--hicn-plugin/src/strategies/strategy_rr.h31
-rw-r--r--hicn-plugin/src/strategy_dpo_manager.c2
8 files changed, 654 insertions, 5 deletions
diff --git a/hicn-plugin/src/error.h b/hicn-plugin/src/error.h
index 978c7f2ca..0abcce96c 100644
--- a/hicn-plugin/src/error.h
+++ b/hicn-plugin/src/error.h
@@ -74,7 +74,7 @@
_(APPFACE_FEATURE, -181, "Error while enabling app face feature") \
_(APPFACE_NOT_FOUND, -182, "Application face not found") \
_(APPFACE_PROD_PREFIX_NULL, -183, "Prefix must not be null for producer face") \
- _(MW_STRATEGY_NH_NOT_FOUND, -184, "Next hop not found") \
+ _(STRATEGY_NH_NOT_FOUND, -184, "Next hop not found") \
_(MW_STRATEGY_SET, -185, "Error while setting weight for next hop") \
_(STRATEGY_NOT_FOUND, -186, "Strategy not found")
diff --git a/hicn-plugin/src/strategies/dpo_rr.c b/hicn-plugin/src/strategies/dpo_rr.c
new file mode 100644
index 000000000..c9ec50445
--- /dev/null
+++ b/hicn-plugin/src/strategies/dpo_rr.c
@@ -0,0 +1,312 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "../strategy_dpo_ctx.h"
+#include "dpo_rr.h"
+#include "strategy_rr.h"
+#include "../strategy_dpo_manager.h"
+
+hicn_strategy_rr_ctx_t *hicn_strategy_rr_ctx_pool;
+
+const static char *const hicn_ip6_nodes[] = {
+ "hicn-rr-strategy", // this is the name you give your node in VLIB_REGISTER_NODE
+ NULL,
+};
+
+const static char *const hicn_ip4_nodes[] = {
+ "hicn-rr-strategy", // this is the name you give your node in VLIB_REGISTER_NODE
+ NULL,
+};
+
+const static char *const *const hicn_nodes_rr[DPO_PROTO_NUM] = {
+ [DPO_PROTO_IP6] = hicn_ip6_nodes,
+ [DPO_PROTO_IP4] = hicn_ip4_nodes,
+};
+
+/**
+ * @brief DPO type value for the rr_strategy
+ */
+static dpo_type_t hicn_dpo_type_rr;
+
+static const hicn_dpo_vft_t hicn_dpo_rr_vft = {
+ .hicn_dpo_get_ctx = &hicn_strategy_rr_ctx_get,
+ .hicn_dpo_is_type = &hicn_dpo_is_type_strategy_rr,
+ .hicn_dpo_get_type = &hicn_dpo_strategy_rr_get_type,
+ .hicn_dpo_module_init = &hicn_dpo_strategy_rr_module_init,
+ .hicn_dpo_create = &hicn_strategy_rr_ctx_create,
+ .hicn_dpo_add_update_nh = &hicn_strategy_rr_ctx_add_nh,
+ .hicn_dpo_del_nh = &hicn_strategy_rr_ctx_del_nh,
+ .hicn_dpo_lock_dpo_ctx = &hicn_strategy_rr_ctx_lock,
+ .hicn_dpo_unlock_dpo_ctx = hicn_strategy_rr_ctx_unlock,
+ .format_hicn_dpo = &format_hicn_dpo_strategy_rr
+};
+
+int
+hicn_dpo_is_type_strategy_rr (const dpo_id_t * dpo)
+{
+ return dpo->dpoi_type == hicn_dpo_type_rr;
+}
+
+void
+hicn_dpo_strategy_rr_module_init (void)
+{
+ pool_validate_index (hicn_strategy_rr_ctx_pool, 0);
+ /*
+ * Register our type of dpo
+ */
+ hicn_dpo_type_rr =
+ hicn_dpo_register_new_type (hicn_nodes_rr, &hicn_dpo_rr_vft,
+ hicn_rr_strategy_get_vft (),
+ &dpo_strategy_rr_ctx_vft);
+}
+
+u8 *
+format_hicn_dpo_strategy_rr (u8 * s, va_list * ap)
+{
+
+ u32 indent = va_arg (*ap, u32);
+ s =
+ format (s,
+ "Round Robin: next hop is chosen ciclying between all the available next hops, one after the other.\n",
+ indent);
+ return (s);
+}
+
+dpo_type_t
+hicn_dpo_strategy_rr_get_type (void)
+{
+ return hicn_dpo_type_rr;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+void
+hicn_strategy_rr_ctx_lock (dpo_id_t * dpo)
+{
+ if (dpo->dpoi_index != 0)
+ {
+ hicn_strategy_rr_ctx_t *hicn_strategy_rr_ctx =
+ (hicn_strategy_rr_ctx_t *) hicn_strategy_rr_ctx_get (dpo->dpoi_index);
+ hicn_strategy_rr_ctx->default_ctx.locks++;
+ }
+}
+
+void
+hicn_strategy_rr_ctx_unlock (dpo_id_t * dpo)
+{
+ if (dpo->dpoi_index != 0)
+ {
+ hicn_strategy_rr_ctx_t *hicn_strategy_rr_ctx =
+ (hicn_strategy_rr_ctx_t *) hicn_strategy_rr_ctx_get (dpo->dpoi_index);
+ hicn_strategy_rr_ctx->default_ctx.locks--;
+
+ if (0 == hicn_strategy_rr_ctx->default_ctx.locks)
+ {
+ pool_put (hicn_strategy_rr_ctx_pool, hicn_strategy_rr_ctx);
+ }
+ }
+}
+
+u8 *
+format_hicn_strategy_rr_ctx (u8 * s, va_list * ap)
+{
+ int i = 0;
+ index_t index = va_arg (*ap, index_t);
+ hicn_strategy_rr_ctx_t *dpo = NULL;
+ dpo_id_t *next_hop = NULL;
+ hicn_face_vft_t *face_vft = NULL;
+ u32 indent = va_arg (*ap, u32);;
+
+ dpo = (hicn_strategy_rr_ctx_t *) hicn_strategy_rr_ctx_get (index);
+
+ s =
+ format (s, "hicn-rr, next hop Face %d",
+ dpo->default_ctx.next_hops[dpo->current_nhop].dpoi_index);
+ for (i = 0; i < HICN_PARAM_FIB_ENTRY_NHOPS_MAX; i++)
+ {
+ next_hop = &dpo->default_ctx.next_hops[i];
+ face_vft = hicn_face_get_vft (next_hop->dpoi_type);
+ if (face_vft != NULL)
+ {
+ s = format (s, "\n");
+ s =
+ format (s, "%U ", face_vft->format_face, next_hop->dpoi_index,
+ indent);
+ }
+ }
+
+ return (s);
+}
+
+static index_t
+hicn_strategy_rr_ctx_get_index (hicn_strategy_rr_ctx_t * cd)
+{
+ return (cd - hicn_strategy_rr_ctx_pool);
+}
+
+int
+hicn_strategy_rr_ctx_create (dpo_proto_t proto, const dpo_id_t * next_hop,
+ int nh_len, index_t * dpo_idx)
+{
+ hicn_strategy_rr_ctx_t *hicn_strategy_rr_ctx;
+ int ret = HICN_ERROR_NONE, i;
+ dpo_id_t invalid = NEXT_HOP_INVALID;
+
+ /* Allocate a hicn_dpo_ctx on the vpp pool and initialize it */
+ pool_get (hicn_strategy_rr_ctx_pool, hicn_strategy_rr_ctx);
+
+ *dpo_idx = hicn_strategy_rr_ctx_get_index (hicn_strategy_rr_ctx);
+ for (int i = 0; i < HICN_PARAM_FIB_ENTRY_NHOPS_MAX; i++)
+ {
+ hicn_strategy_rr_ctx->default_ctx.next_hops[i] = invalid;
+ }
+
+ hicn_strategy_rr_ctx->default_ctx.entry_count = 0;
+ hicn_strategy_rr_ctx->default_ctx.locks = 0;
+
+ for (i = 0; i < HICN_PARAM_FIB_ENTRY_NHOPS_MAX && i < nh_len; i++)
+ {
+ clib_memcpy (&hicn_strategy_rr_ctx->default_ctx.next_hops[i],
+ &next_hop[i], sizeof (dpo_id_t));
+ hicn_strategy_rr_ctx->default_ctx.entry_count++;
+ }
+
+ hicn_strategy_rr_ctx->current_nhop = 0;
+
+ return ret;
+}
+
+hicn_dpo_ctx_t *
+hicn_strategy_rr_ctx_get (index_t index)
+{
+ hicn_strategy_rr_ctx_t *hicn_strategy_rr_ctx = NULL;
+ if (!pool_is_free_index (hicn_strategy_rr_ctx_pool, index))
+ {
+ hicn_strategy_rr_ctx =
+ (pool_elt_at_index (hicn_strategy_rr_ctx_pool, index));
+ }
+ return &hicn_strategy_rr_ctx->default_ctx;
+}
+
+int
+hicn_strategy_rr_ctx_add_nh (const dpo_id_t * nh, index_t dpo_idx)
+{
+ hicn_strategy_rr_ctx_t *hicn_strategy_rr_ctx =
+ (hicn_strategy_rr_ctx_t *) hicn_strategy_rr_ctx_get (dpo_idx);
+
+ if (hicn_strategy_rr_ctx != NULL)
+ {
+
+ int empty = hicn_strategy_rr_ctx->default_ctx.entry_count;
+
+ /* Iterate through the list of faces to add new faces */
+ for (int i = 0; i < hicn_strategy_rr_ctx->default_ctx.entry_count; i++)
+ {
+ if (!memcmp
+ (nh, &hicn_strategy_rr_ctx->default_ctx.next_hops[i],
+ sizeof (dpo_id_t)))
+ {
+ /* If face is marked as deleted, ignore it */
+ hicn_face_t *face =
+ hicn_dpoi_get_from_idx (hicn_strategy_rr_ctx->
+ default_ctx.next_hops[i].dpoi_index);
+ if (face->shared.flags & HICN_FACE_FLAGS_DELETED)
+ {
+ continue;
+ }
+ return HICN_ERROR_DPO_CTX_NHOPS_EXISTS;
+ }
+ }
+
+ /* Get an empty place */
+ if (empty > HICN_PARAM_FIB_ENTRY_NHOPS_MAX)
+ {
+ return HICN_ERROR_DPO_CTX_NHOPS_NS;
+ }
+ if (PREDICT_FALSE (empty > HICN_PARAM_FIB_ENTRY_NHOPS_MAX))
+ {
+ return HICN_ERROR_DPO_CTX_NHOPS_NS;
+ }
+ clib_memcpy (&hicn_strategy_rr_ctx->default_ctx.next_hops[empty], nh,
+ sizeof (dpo_id_t));
+ hicn_strategy_rr_ctx->default_ctx.entry_count++;
+
+ return HICN_ERROR_NONE;
+ }
+ return HICN_ERROR_DPO_CTX_NOT_FOUND;
+}
+
+int
+hicn_strategy_rr_ctx_del_nh (hicn_face_id_t face_id, index_t dpo_idx,
+ fib_prefix_t * fib_pfx)
+{
+ hicn_strategy_rr_ctx_t *hicn_strategy_rr_ctx =
+ (hicn_strategy_rr_ctx_t *) hicn_strategy_rr_ctx_get (dpo_idx);
+ int ret = HICN_ERROR_NONE;
+ int nh_id = ~0;
+ dpo_id_t invalid = NEXT_HOP_INVALID;
+
+ if (hicn_strategy_rr_ctx != NULL)
+ {
+ for (int i = 0; i < hicn_strategy_rr_ctx->default_ctx.entry_count; i++)
+ {
+ if (hicn_strategy_rr_ctx->default_ctx.next_hops[i].dpoi_index ==
+ face_id)
+ {
+ nh_id = i;
+ hicn_face_unlock (&hicn_strategy_rr_ctx->default_ctx.
+ next_hops[i]);
+ hicn_strategy_rr_ctx->default_ctx.next_hops[i] = invalid;
+ hicn_strategy_rr_ctx->default_ctx.entry_count--;
+ }
+ }
+
+ if (0 == hicn_strategy_rr_ctx->default_ctx.entry_count)
+ {
+ fib_table_entry_special_remove (HICN_FIB_TABLE, fib_pfx,
+ FIB_SOURCE_PLUGIN_HI);
+ }
+ }
+ else
+ {
+ ret = HICN_ERROR_DPO_CTX_NOT_FOUND;
+ }
+
+ /*
+ * Remove any possible hole in the arrays of dpos
+ */
+ if (hicn_strategy_rr_ctx->default_ctx.entry_count > 0 && nh_id != ~0
+ && nh_id < hicn_strategy_rr_ctx->default_ctx.entry_count - 1)
+ {
+ int i;
+ for (i = nh_id; i < hicn_strategy_rr_ctx->default_ctx.entry_count; i++)
+ {
+ clib_memcpy (&hicn_strategy_rr_ctx->default_ctx.next_hops[i],
+ &hicn_strategy_rr_ctx->default_ctx.next_hops[i + 1],
+ sizeof (dpo_id_t));
+ }
+ /* Set as invalid the last dpo */
+ hicn_strategy_rr_ctx->default_ctx.next_hops[i] = invalid;
+ }
+ return ret;
+}
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/hicn-plugin/src/strategies/dpo_rr.h b/hicn-plugin/src/strategies/dpo_rr.h
new file mode 100644
index 000000000..a12183653
--- /dev/null
+++ b/hicn-plugin/src/strategies/dpo_rr.h
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __HICN_DPO_RR_H__
+#define __HICN_DPO_RR_H__
+
+#include <vnet/dpo/dpo.h>
+#include "../strategy_dpo_ctx.h"
+
+/**
+ * Context for the Round Robin strategy
+ */
+
+typedef struct hicn_strategy_rr_ctx_s
+{
+ hicn_dpo_ctx_t default_ctx;
+
+ u8 current_nhop;
+} hicn_strategy_rr_ctx_t;
+
+/**
+ * @brief Lock the round robin ctx
+ *
+ * @param dpo Identifier of the dpo of the rr ctx
+ */
+void hicn_strategy_rr_ctx_lock (dpo_id_t * dpo);
+
+/**
+ * @brief Unlock the round robin ctx
+ *
+ * @param dpo Identifier of the dpo of the rr ctx
+ */
+void hicn_strategy_rr_ctx_unlock (dpo_id_t * dpo);
+
+/**
+ * @brief Format the dpo ctx for a human-readable string
+ *
+ * @param s String to which to append the formatted dpo ctx
+ * @param ap List of parameters for the formatting
+ *
+ * @result The string with the formatted dpo ctx
+ */
+u8 *format_hicn_strategy_rr_ctx (u8 * s, va_list * ap);
+
+const static dpo_vft_t dpo_strategy_rr_ctx_vft = {
+ .dv_lock = hicn_strategy_rr_ctx_lock,
+ .dv_unlock = hicn_strategy_rr_ctx_unlock,
+ .dv_format = format_hicn_strategy_rr_ctx,
+};
+
+/**
+ * @brief Retrieve an hicn_strategy_rr_ctx object
+ *
+ * @param indext Index of the hicn_dpo_ctx to retrieve
+ * @return The hicn_dpo_ctx object or NULL
+ */
+hicn_dpo_ctx_t *hicn_strategy_rr_ctx_get (index_t index);
+
+/**
+ * @brief Create a new round robin ctx
+ *
+ * @param proto The protocol to which the dpo is meant for (see vpp docs)
+ * @param next_hop A list of next hops to be inserted in the dpo ctx
+ * @param nh_len Size of the list
+ * @param dpo_idx index_t that will hold the index of the created dpo ctx
+ * @return HICN_ERROR_NONE if the creation was fine, otherwise EINVAL
+ */
+int
+hicn_strategy_rr_ctx_create (dpo_proto_t proto, const dpo_id_t * next_hop,
+ int nh_len, index_t * dpo_idx);
+
+/**
+ * @brief Add or update a next hop in the dpo ctx.
+ *
+ * This function is meant to be used in the control plane and not in the data plane,
+ * as it is not optimized for the latter.
+ *
+ * @param nh Next hop to insert in the dpo ctx
+ * @param dpo_idx Index of the dpo ctx to update with the new or updated next
+ * hop
+ * @return HICN_ERROR_NONE if the update or insert was fine,
+ * otherwise HICN_ERROR_DPO_CTX_NOT_FOUND
+ */
+int hicn_strategy_rr_ctx_add_nh (const dpo_id_t * nh, index_t dpo_idx);
+
+/**
+ * @brief Delete a next hop in the dpo ctx.
+ *
+ * @param face_id Face identifier of the next hop
+ * @param dpo_idx Index of the dpo ctx to update with the new or updated next
+ * hop
+ * @return HICN_ERROR_NONE if the update or insert was fine,
+ * otherwise HICN_ERROR_DPO_CTS_NOT_FOUND
+ */
+int
+hicn_strategy_rr_ctx_del_nh (hicn_face_id_t face_id, index_t dpo_idx,
+ fib_prefix_t * fib_pfx);
+
+/**
+ * @brief Prefetch a dpo
+ *
+ * @param dpo_idx Index of the dpo ctx to prefetch
+ */
+void hicn_strategy_rr_ctx_prefetch (index_t dpo_idx);
+
+int hicn_dpo_is_type_strategy_rr (const dpo_id_t * dpo);
+
+void hicn_dpo_strategy_rr_module_init (void);
+
+dpo_type_t hicn_dpo_strategy_rr_get_type (void);
+
+u8 *format_hicn_dpo_strategy_rr (u8 * s, va_list * ap);
+
+
+#endif // __HICN_DPO_RR_H__
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/hicn-plugin/src/strategies/strategy_mw.c b/hicn-plugin/src/strategies/strategy_mw.c
index 77a7d16a8..3efddc0ce 100644
--- a/hicn-plugin/src/strategies/strategy_mw.c
+++ b/hicn-plugin/src/strategies/strategy_mw.c
@@ -88,11 +88,11 @@ hicn_select_next_hop_mw (index_t dpo_idx, int *nh_idx, dpo_id_t ** outface)
if (!dpo_id_is_valid
(&hicn_strategy_mw_ctx->default_ctx.next_hops[next_hop_index]))
- return HICN_ERROR_MW_STRATEGY_NH_NOT_FOUND;
+ return HICN_ERROR_STRATEGY_NH_NOT_FOUND;
*outface =
- (dpo_id_t *) & hicn_strategy_mw_ctx->
- default_ctx.next_hops[next_hop_index];
+ (dpo_id_t *) & hicn_strategy_mw_ctx->default_ctx.
+ next_hops[next_hop_index];
return HICN_ERROR_NONE;
}
diff --git a/hicn-plugin/src/strategies/strategy_mw_cli.c b/hicn-plugin/src/strategies/strategy_mw_cli.c
index ff4125258..689bce470 100644
--- a/hicn-plugin/src/strategies/strategy_mw_cli.c
+++ b/hicn-plugin/src/strategies/strategy_mw_cli.c
@@ -111,7 +111,7 @@ hicn_mw_strategy_cli_set_weight_command_fn (vlib_main_t * vm,
cl_err =
clib_error_return (0,
get_error_string
- (HICN_ERROR_MW_STRATEGY_NH_NOT_FOUND));
+ (HICN_ERROR_STRATEGY_NH_NOT_FOUND));
goto done;
}
diff --git a/hicn-plugin/src/strategies/strategy_rr.c b/hicn-plugin/src/strategies/strategy_rr.c
new file mode 100644
index 000000000..53b9b688f
--- /dev/null
+++ b/hicn-plugin/src/strategies/strategy_rr.c
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <vlib/vlib.h>
+#include <vnet/vnet.h>
+
+#include "../strategy.h"
+#include "../strategy_dpo_ctx.h"
+#include "dpo_rr.h"
+#include "../faces/face.h"
+#include "../route.h"
+#include "../pcs.h"
+#include "../strategy_dpo_manager.h"
+
+/* Simple strategy that chooses the next hop with the maximum weight */
+/* It does not require to exend the hicn_dpo */
+void hicn_receive_data_rr (index_t dpo_idx, int nh_idx);
+void hicn_add_interest_rr (index_t dpo_idx, hicn_hash_entry_t * pit_entry);
+void hicn_on_interest_timeout_rr (index_t dpo_idx);
+u32 hicn_select_next_hop_rr (index_t dpo_idx, int *nh_idx,
+ dpo_id_t ** outface);
+u32 get_strategy_node_index_rr (void);
+
+static hicn_strategy_vft_t hicn_strategy_rr_vft = {
+ .hicn_receive_data = &hicn_receive_data_rr,
+ .hicn_add_interest = &hicn_add_interest_rr,
+ .hicn_on_interest_timeout = &hicn_on_interest_timeout_rr,
+ .hicn_select_next_hop = &hicn_select_next_hop_rr,
+ .get_strategy_node_index = get_strategy_node_index_rr
+};
+
+/* Stats string values */
+static char *hicn_strategy_error_strings[] = {
+#define _(sym, string) string,
+ foreach_hicnfwd_error
+#undef _
+};
+
+/*
+ * Return the vft of the strategy.
+ */
+hicn_strategy_vft_t *
+hicn_rr_strategy_get_vft (void)
+{
+ return &hicn_strategy_rr_vft;
+}
+
+/* Registration struct for a graph node */
+vlib_node_registration_t hicn_rr_strategy_node;
+
+u32
+get_strategy_node_index_rr (void)
+{
+ return hicn_rr_strategy_node.index;
+}
+
+/* DPO should be give in input as it containes all the information to calculate the next hops*/
+u32
+hicn_select_next_hop_rr (index_t dpo_idx, int *nh_idx, dpo_id_t ** outface)
+{
+ hicn_strategy_rr_ctx_t *hicn_strategy_rr_ctx =
+ (hicn_strategy_rr_ctx_t *) hicn_strategy_rr_ctx_get (dpo_idx);
+
+ if (dpo_id_is_valid
+ (&hicn_strategy_rr_ctx->default_ctx.
+ next_hops[hicn_strategy_rr_ctx->current_nhop]))
+ {
+ *outface =
+ (dpo_id_t *) & hicn_strategy_rr_ctx->default_ctx.
+ next_hops[hicn_strategy_rr_ctx->current_nhop];
+
+ }
+ else
+ return HICN_ERROR_STRATEGY_NH_NOT_FOUND;
+
+ hicn_strategy_rr_ctx->current_nhop =
+ (hicn_strategy_rr_ctx->current_nhop +
+ 1) % hicn_strategy_rr_ctx->default_ctx.entry_count;
+
+ return HICN_ERROR_NONE;
+}
+
+uword
+hicn_rr_strategy_node_fn (vlib_main_t * vm,
+ vlib_node_runtime_t * node, vlib_frame_t * frame)
+{
+ return hicn_forward_interest_fn (vm, node, frame, &hicn_strategy_rr_vft,
+ hicn_dpo_strategy_rr_get_type (),
+ &hicn_rr_strategy_node);
+}
+
+void
+hicn_add_interest_rr (index_t dpo_ctx_idx, hicn_hash_entry_t * hash_entry)
+{
+ hash_entry->dpo_ctx_id = dpo_ctx_idx;
+ dpo_id_t hicn_dpo_id =
+ { hicn_dpo_strategy_rr_get_type (), 0, 0, dpo_ctx_idx };
+ hicn_strategy_rr_ctx_lock (&hicn_dpo_id);
+ hash_entry->vft_id = hicn_dpo_get_vft_id (&hicn_dpo_id);
+}
+
+void
+hicn_on_interest_timeout_rr (index_t dpo_idx)
+{
+ /* Nothign to do in the rr strategy when we receive an interest */
+}
+
+void
+hicn_receive_data_rr (index_t dpo_idx, int nh_idx)
+{
+}
+
+
+/* packet trace format function */
+static u8 *
+hicn_strategy_format_trace_rr (u8 * s, va_list * args)
+{
+ CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
+ CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
+ hicn_strategy_trace_t *t = va_arg (*args, hicn_strategy_trace_t *);
+
+ s = format (s, "Strategy_rr: pkt: %d, sw_if_index %d, next index %d",
+ (int) t->pkt_type, t->sw_if_index, t->next_index);
+ return (s);
+}
+
+/*
+ * Node registration for the forwarder node
+ */
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE (hicn_rr_strategy_node) =
+{
+ .name = "hicn-rr-strategy",
+ .function = hicn_rr_strategy_node_fn,
+ .vector_size = sizeof (u32),
+ .runtime_data_bytes = sizeof (int) + sizeof(hicn_pit_cs_t *),
+ .format_trace = hicn_strategy_format_trace_rr,
+ .type = VLIB_NODE_TYPE_INTERNAL,
+ .n_errors = ARRAY_LEN (hicn_strategy_error_strings),
+ .error_strings = hicn_strategy_error_strings,
+ .n_next_nodes = HICN_STRATEGY_N_NEXT,
+ .next_nodes = {
+ [HICN_STRATEGY_NEXT_INTEREST_HITPIT] = "hicn-interest-hitpit",
+ [HICN_STRATEGY_NEXT_INTEREST_HITCS] = "hicn-interest-hitcs",
+ [HICN_STRATEGY_NEXT_ERROR_DROP] = "error-drop",
+ [HICN_STRATEGY_NEXT_EMPTY] = "ip4-lookup",
+ },
+};
+/* *INDENT-ON* */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/hicn-plugin/src/strategies/strategy_rr.h b/hicn-plugin/src/strategies/strategy_rr.h
new file mode 100644
index 000000000..84149c36f
--- /dev/null
+++ b/hicn-plugin/src/strategies/strategy_rr.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __HICN_STRATEGY_RR_H__
+#define __HICN_STRATEGY_RR_H__
+
+#include "../strategy.h"
+
+hicn_strategy_vft_t *hicn_rr_strategy_get_vft (void);
+
+#endif // __HICN_STRATEGY_RR_H__
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/hicn-plugin/src/strategy_dpo_manager.c b/hicn-plugin/src/strategy_dpo_manager.c
index c1723eccc..470d8d185 100644
--- a/hicn-plugin/src/strategy_dpo_manager.c
+++ b/hicn-plugin/src/strategy_dpo_manager.c
@@ -17,6 +17,7 @@
#include "strategy_dpo_manager.h"
#include "strategies/dpo_mw.h"
+#include "strategies/dpo_rr.h"
#include "strategy.h"
#include "faces/face.h"
@@ -94,6 +95,7 @@ void
hicn_dpos_init (void)
{
hicn_dpo_strategy_mw_module_init ();
+ hicn_dpo_strategy_rr_module_init ();
default_dpo.hicn_dpo_get_ctx = &hicn_strategy_mw_ctx_get;
default_dpo.hicn_dpo_is_type = &hicn_dpo_is_type_strategy_mw;