aboutsummaryrefslogtreecommitdiffstats
path: root/ctrl/sysrepo-plugins/hicn-plugin/plugin
diff options
context:
space:
mode:
Diffstat (limited to 'ctrl/sysrepo-plugins/hicn-plugin/plugin')
-rw-r--r--ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_plugin.h23
-rw-r--r--ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_vpp_comm.c9
-rw-r--r--ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_vpp_comm.h40
-rw-r--r--ctrl/sysrepo-plugins/hicn-plugin/plugin/mainpage.dox245
-rw-r--r--ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c144
-rw-r--r--ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.h91
-rw-r--r--ctrl/sysrepo-plugins/hicn-plugin/plugin/model/tlock.h37
7 files changed, 450 insertions, 139 deletions
diff --git a/ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_plugin.h b/ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_plugin.h
index 4e48c8c29..0890c3f03 100644
--- a/ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_plugin.h
+++ b/ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_plugin.h
@@ -13,13 +13,34 @@
* limitations under the License.
*/
+/**
+ * @file hicn_plugin.h
+ * @brief This file contains init and cleanup for the sysrepo.
+ */
+
#ifndef __HICN_PLUGIN_H__
#define __HICN_PLUGIN_H__
#include "hicn_vpp_comm.h"
-// functions that sysrepo-plugin need
+
+/**
+ * @brief initialize function for sysrepo plugin,
+ * In this function we connect to vpp from one side
+ * and subscribe for all hICN events as well as interface events (if any)
+ * @param session pointer to the sesssion context
+ * @param private_ctx pointer to the context
+ * @return in success the function returns SR_ERR_OK otherwise it pass error
+ */
int sr_plugin_init_cb(sr_session_ctx_t *session, void **private_ctx);
+
+/**
+ * @brief cleanup function for sysrepo,
+ * In this function we connect to vpp from one side
+ * and and unsubscribe for all hICN events as well as interface events (if any)
+ * @param session pointer to the sesssion context
+ * @param private_ctx pointer to the context
+ */
void sr_plugin_cleanup_cb(sr_session_ctx_t *session, void *private_ctx);
#endif //__HICN_PLUGIN_H__ \ No newline at end of file
diff --git a/ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_vpp_comm.c b/ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_vpp_comm.c
index 52ae6ee90..73eab66ea 100644
--- a/ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_vpp_comm.c
+++ b/ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_vpp_comm.c
@@ -18,11 +18,16 @@
#define APP_NAME "hicn_plugin"
#define MAX_OUTSTANDING_REQUESTS 4
#define RESPONSE_QUEUE_SIZE 2
-vapi_ctx_t g_vapi_ctx_instance = NULL;
-// Use VAPI macros to define symbols
+
+vapi_ctx_t g_vapi_ctx_instance=NULL;
+
+
+
+
int hicn_connect_vpp() {
+
if (g_vapi_ctx_instance == NULL) {
vapi_error_e rv = vapi_ctx_alloc(&g_vapi_ctx_instance);
rv = vapi_connect(g_vapi_ctx_instance, APP_NAME, NULL,
diff --git a/ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_vpp_comm.h b/ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_vpp_comm.h
index 720bd6835..9abe4e5d4 100644
--- a/ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_vpp_comm.h
+++ b/ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_vpp_comm.h
@@ -13,6 +13,13 @@
* limitations under the License.
*/
+
+/**
+ * @file hicn_vpp_comm.h
+ * @brief This file contains binary api to connect to the VPP.
+ */
+
+
#ifndef __HICN_VPP_COMMM_H__
#define __HICN_VPP_COMMM_H__
#include <sysrepo.h>
@@ -27,15 +34,25 @@
#endif
#endif
-// ctx vpp connect
+/**
+ * @brief This is the context to connect to the vpp
+ */
+
extern vapi_ctx_t g_vapi_ctx_instance;
-//Here it is the definition
+/**
+ * @brief This macro is interface.c to communicate with vpp
+ */
#define VPP_INTFC_NAME_LEN 64
#define VPP_MAC_ADDRESS_LEN 8
#define VPP_IP6_ADDRESS_LEN 16
+
+
+/**
+ * @brief This macro checks the arg is NULL or not, if the arg is NULL it returns retval
+ */
#define ARG_CHECK(retval, arg) \
do { \
if (NULL == (arg)) { \
@@ -45,21 +62,30 @@ extern vapi_ctx_t g_vapi_ctx_instance;
} while (0)
-
+/**
+ * @brief Please check ARG_CHECK
+ */
#define ARG_CHECK2(retval, arg1, arg2) \
ARG_CHECK(retval, arg1); \
ARG_CHECK(retval, arg2)
-#define ARG_CHECK7(retval, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
+/**
+ * @brief This Macro is the multiple check of ARG_CHECK
+ */
+#define ARG_CHECK5(retval, arg1, arg2, arg3, arg4, arg5) \
ARG_CHECK(retval, arg1); \
ARG_CHECK(retval, arg2); \
ARG_CHECK(retval, arg3); \
ARG_CHECK(retval, arg4); \
- ARG_CHECK(retval, arg5); \
- ARG_CHECK(retval, arg6); \
- ARG_CHECK(retval, arg7)
+ ARG_CHECK(retval, arg5)
+/**
+ * @brief This function is used to connect to the vpp
+ */
int hicn_connect_vpp();
+/**
+ * @brief This function is used to close the connection of the vpp
+ */
int hicn_disconnect_vpp();
#endif //__HICN_VPP_COMMM_H__
diff --git a/ctrl/sysrepo-plugins/hicn-plugin/plugin/mainpage.dox b/ctrl/sysrepo-plugins/hicn-plugin/plugin/mainpage.dox
new file mode 100644
index 000000000..dc4289379
--- /dev/null
+++ b/ctrl/sysrepo-plugins/hicn-plugin/plugin/mainpage.dox
@@ -0,0 +1,245 @@
+/** @mainpage About hICN sysrepo plugin
+*This plugin serves as a data management agent. It provides yang models via
+*NETCONF to allow the management of hicn-plugin which runs in VPP instance from out-of-box.
+
+*The following sections contain more details:
+*- @subpage subp1 "hICN yang model"
+*- @subpage subp2 "User Guide"
+*- @subpage subp3 "Developer Guide"
+*/
+
+/** @page subp1
+*hicn.yang consists of one container for providing the state data (i.e., hicn-state).
+*It consists of state, route, and face-ip-params
+*nodes with the corresponding leaves. In the hicn model a variety of RPCs are provided
+*to allow controller to communicate with the hicn-plugin as well as update the state
+*data in hicn-state. You can install the yang model using the following bash script:
+
+```
+EXIT_CODE=0
+command -v sysrepoctl > /dev/null
+if [ $? != 0 ]; then
+ echo "Could not find command \"sysrepoctl\"."
+ exit ${EXIT_CODE}
+else
+sysrepoctl --install path_to_hicn_yang_model
+fi
+```
+
+*Here you can find different examples to run RPC in the yang-model.
+
+```
+<face-ip-add xmlns="urn:sysrepo:hicn">
+ <lip4>192.168.1.10</lip4>
+ <lip6>-1</lip6>
+ <rip4>192.168.1.1</rip4>
+ <rip6>-1</rip6>
+ <swif>0</swif>
+</face-ip-add>
+
+<route-nhops-add xmlns="urn:sysrepo:hicn">
+ <ip4>192.168.1.1</ip4>
+ <ip6>-1</ip6>
+ <len>24</len>
+ <face_ids0>0</face_ids0>
+ <face_ids1>0</face_ids1>
+ <face_ids2>0</face_ids2>
+ <face_ids3>0</face_ids3>
+ <face_ids4>0</face_ids4>
+ <face_ids5>0</face_ids5>
+ <face_ids6>0</face_ids6>
+ <n_faces>1</n_faces>
+</route-nhops-add>
+
+<route-nhops-del xmlns="urn:sysrepo:hicn">
+ <ip4>192.168.1.1</ip4>
+ <ip6>-1</ip6>
+ <len>24</len>
+ <faceid>0</faceid>
+</route-nhops-del>
+
+
+<face-ip-del xmlns="urn:sysrepo:hicn">
+ <faceid>0</faceid>
+</face-ip-del>
+
+
+<punting-del-ip xmlns="urn:sysrepo:hicn">
+ <ip4>192.168.0.1</ip4>
+ <ip6>-1</ip6>
+ <len>24</len>
+ <swif>0</swif>
+</punting-del-ip>
+```
+ */
+
+/** @page subp2
+
+*Firstly, verify the plugin and binary libraries are located correctly, then run
+*the vpp through (service vpp start). Next, run the sysrepo plugin (sysrepo-plugind),
+*for debug mode: sysrep-plugind -d -v 4 which
+*runs with high verbosity. When the hicn sysrepo plugin is loaded, run the
+*netopeer2-server which serves as NETCONF server.
+
+
+*## Connect from netopeer2-cli
+
+*In order to connect through the netopeer client run the netopeer2-cli. Then, follow these steps:
+```
+*- connect --host XXX --login XXX
+*- get (you can get the configuration and operational data)
+*- user-rpc (you can call one of the rpc proposed by hicn model but it needs an xml input)
+```
+
+*## Connect from OpenDaylight (ODL) controller
+
+
+*In order to connect through the OpenDaylight follow these procedure:
+
+*- run karaf distribution (./opendayligh_installation_folder/bin/karaf)
+*- install the required feature list in DOL (feature:install odl-netconf-server
+* odl-netconf-connector odl-restconf-all odl-netconf-topology or
+* odl-netconf-clustered-topology)
+*- run a rest client program (e.g., postman or RESTClient)
+*- mount the remote netopeer2-server to the OpenDaylight by the following REST API:
+
+*PUT http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/hicn-node
+
+* with the following body
+```
+ <node xmlns="urn:TBD:params:xml:ns:yang:network-topology">
+ <node-id>hicn-node</node-id>
+ <host xmlns="urn:opendaylight:netconf-node-topology">Remote_NETCONF_SERVER_IP</host>
+ <port xmlns="urn:opendaylight:netconf-node-topology">830</port>
+ <username xmlns="urn:opendaylight:netconf-node-topology">username</username>
+ <password xmlns="urn:opendaylight:netconf-node-topology">password</password>
+ <tcp-only xmlns="urn:opendaylight:netconf-node-topology">false</tcp-only>
+ <keepalive-delay xmlns="urn:opendaylight:netconf-node-topology">1</keepalive-delay>
+ </node>
+```
+*Note that the header files must be set to Content-Type: application/xml, Accept: application/xml.
+
+*- send the operation through the following REST API:
+
+*POST http://localhost:8181/restconf/operations/network-topology:network-topology/topology/topology-netconf/node/hicn-node/yang-ext:mount/ietf-netconf:edit-config
+
+*The body can be used the same as edit-config in netopeer2-cli.
+
+*## Connect from Network Services Orchestrator (NSO)
+
+*To connect NSO to the netopeer2-server, first, you need to write a NED package
+*for your device. The procedure to create NED for hicn is explained in the following:
+
+*Place hicn.yang model in a folder called hicn-yang-model, and follow these steps:
+
+*- ncs-make-package --netconf-ned ./hicn-yang-model ./hicn-nso
+*- cd hicn-nso/src; make
+*- ncs-setup --ned-package ./hicn-nso --dest ./hicn-nso-project
+*- cd hicn-nso-project
+*- ncs
+*- ncs_cli -C -u admin
+*- configure
+*- devices authgroups group authhicn default-map remote-name user_name remote-password password
+*- devices device hicn address IP_device port 830 authgroup authhicn device-type netconf
+*- state admin-state unlocked
+*- commit
+*- ssh fetch-host-keys
+
+
+*At this point, we are able to connect to the remote device.
+
+
+ */
+
+ /** @page subp3
+
+*This guide contains information intended for developers that need to extend/modify the hICN yang model.
+
+*# Adding configuration data
+*In order to add configuration data, firstly it requires to update yang model and define the configuration paramters
+*through a container and define the leaves. Once the yang model is updated in the sysrepo plugin you need to subscribe
+*for ```sr_module_change_subscribe``` and provide the appropriate callback.
+*
+*
+*# Adding new RPC
+*
+*In order to add RPC call, firstly it requires to update the yang model by new ```rpc``` statements and define the input to them.
+
+
+*# Adding new operational data
+*
+*In order to add operational data, firstly it requires to add operational data in yang model by adding ```confg false``` to the container.
+*Then, update the sysrepo plugin by the adding the ```sr_oper_get_items_subscribe```.
+
+ Example:
+I have a switch with two ports. I am going to write an RPC call to switch them on/off
+, moreover I need to read operational data from each port. So, the following yang model can be proposed:
+
+```
+module switch {
+namespace "urn:sysrepo:switch";
+prefix swtch;
+
+revision 2019-12-08{
+ description "Initial revision.";
+}
+
+
+grouping status-reply{
+ list port{
+ key portid;
+ leaf portid {
+ description "the port id.";
+ type uint32;
+ }
+ leaf status {
+ description "the status of the port.";
+ type boolean;
+ }
+
+}
+}
+
+rpc power {
+ description "Operation to power on/off switch.";
+ input {
+ leaf turned-on {
+ description "indicating on or off.";
+ type boolean;
+ default false;
+ }
+ }
+}
+
+
+container switch-state {
+
+ config false;
+ description "operational data container for the switch.";
+ container status{
+ uses status-reply;
+ }
+```
+Afterwards, the following subscribes are required in the sysrepo plugin.
+
+```
+sr_rpc_subscribe(session, "/switch:power", callback,
+ session, 100,SR_SUBSCR_CTX_REUSE, subscription);
+
+```
+
+session is the opened session with sysrepo, xpath is the path in the yang model, callback is the function
+when RPC arrives, private context passed to the callback function, priprity which is set to 100 here indicates the priority if there re multiple RPCs,
+options can alter the normal behaviour, and subscription is the subscribtion when initialize the connection towards the sysrepo
+
+
+```
+ rc = sr_oper_get_items_subscribe(session, "switch","/switch:switch-state/status",
+ callback, NULL, SR_SUBSCR_CTX_REUSE,
+ subscription);
+```
+session is the opened session with sysrepo, xpath is the path in the yang model, callback is the function
+when RPC arrives, private context passed to the callback which is NULL here,
+options can alter the normal behaviour, and subscription is the subscribtion when initialize the connection towards the sysrepo
+
+*/ \ No newline at end of file
diff --git a/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c b/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c
index 8db0a6238..d73e6145a 100644
--- a/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c
+++ b/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c
@@ -13,6 +13,13 @@
* limitations under the License.
*/
+
+
+/** @file hicn_model.c
+ * @brief This file contains implementations of the main calls
+ */
+
+
#define _GNU_SOURCE
#include <stdio.h>
@@ -39,14 +46,29 @@ DEFINE_VAPI_MSG_IDS_HICN_API_JSON
// Shared local variables between state and RPCs
+/**
+ * @brief this shared variable keeps the hicn state
+ */
volatile hicn_state_t * hicn_state = NULL;
-volatile hicn_strategy_t * hicn_strategy = NULL;
+/**
+ * @brief this shared variable keeps hicn strategies
+ */
volatile hicn_strategies_t * hicn_strategies =NULL;
-volatile hicn_route_t * hicn_route = NULL;
-volatile hicn_face_ip_params_t * hicn_face_ip_params = NULL;
+/**
+ * @brief this shared variable keeps statistics of hicn faces
+ */
volatile hicn_faces_t * hicn_faces = NULL;
+/**
+ * @brief this shared variable keeps routes information in hicn
+ */
volatile hicn_routes_t * hicn_routes = NULL;
+/**
+ * @brief this shared variable is the link list to maintain all the faces (up to MAX_FACES)
+ */
struct hicn_faces_s * fcurrent = NULL;
+/**
+ * @brief this shared variable is the link list to maintain all the routes
+ */
struct hicn_routes_s * rcurrent = NULL;
@@ -55,15 +77,9 @@ static int init_buffer(void){
hicn_state = memalign(MEM_ALIGN, sizeof(hicn_state_t) );
memset((hicn_state_t *)hicn_state, 0 , sizeof(hicn_state_t) );
- hicn_strategy = memalign(MEM_ALIGN, sizeof(hicn_strategy_t) );
- memset((hicn_strategy_t *) hicn_strategy, 0 , sizeof(hicn_strategy_t) );
-
hicn_strategies = memalign(MEM_ALIGN, sizeof(hicn_strategies_t) );
memset((hicn_strategies_t *) hicn_strategies, 0 , sizeof(hicn_strategies_t) );
- hicn_route = memalign(MEM_ALIGN, sizeof(hicn_route_t) );
- memset((hicn_route_t *) hicn_route, 0 , sizeof(hicn_route_t) );
-
hicn_faces = memalign(MEM_ALIGN, sizeof(hicn_faces_t) );
hicn_faces->next=memalign(MEM_ALIGN, sizeof(struct hicn_faces_s));
fcurrent=hicn_faces->next;
@@ -75,7 +91,7 @@ static int init_buffer(void){
int retval=-1;
- ARG_CHECK7(retval, hicn_state, hicn_strategy, hicn_strategies, hicn_route, fcurrent, hicn_faces, hicn_routes);
+ ARG_CHECK5(retval, hicn_state, hicn_strategies, fcurrent, hicn_faces, hicn_routes);
hicn_routes->nroute=0;
hicn_faces->nface=0;
retval=0;
@@ -83,7 +99,6 @@ static int init_buffer(void){
return retval;
}
-
static int init_face_pool(struct hicn_faces_s * head){
for(int i=0; i<MAX_FACE_POOL; i++){
@@ -96,7 +111,6 @@ static int init_face_pool(struct hicn_faces_s * head){
}
-
static int init_route_pool(struct hicn_routes_s * head){
for(int i=0; i<MAX_ROUTE_POOL; i++){
@@ -111,20 +125,7 @@ static int init_route_pool(struct hicn_routes_s * head){
/* VAPI CALLBACKS */
-vapi_error_e call_hicn_api_strategy_get(struct vapi_ctx_s *ctx,
- void *callback_ctx,
- vapi_error_e rv,
- bool is_last,
- vapi_payload_hicn_api_node_params_set_reply *reply){
-if(!reply->retval){
- SRP_LOG_DBGMSG("Successfully done");
- return VAPI_OK;
- }else
- return VAPI_EUSER;
-}
-
-
-vapi_error_e call_hicn_api_strategies_get(struct vapi_ctx_s *ctx,
+static vapi_error_e call_hicn_api_strategies_get(struct vapi_ctx_s *ctx,
void *callback_ctx,
vapi_error_e rv,
bool is_last,
@@ -136,20 +137,7 @@ if(!reply->retval){
return VAPI_EUSER;
}
-vapi_error_e call_hicn_api_route_get_hton(struct vapi_ctx_s *ctx,
- void *callback_ctx,
- vapi_error_e rv,
- bool is_last,
- vapi_payload_hicn_api_strategies_get_reply *reply){
-if(!reply->retval){
- SRP_LOG_DBGMSG("Successfully done");
- return VAPI_OK;
- }else
- return VAPI_EUSER;
-}
-
-
-vapi_error_e call_hicn_api_route_nhops_add(struct vapi_ctx_s *ctx,
+static vapi_error_e call_hicn_api_route_nhops_add(struct vapi_ctx_s *ctx,
void *callback_ctx,
vapi_error_e rv,
bool is_last,
@@ -161,7 +149,7 @@ if(!reply->retval){
return VAPI_EUSER;
}
-vapi_error_e call_hicn_api_route_del(struct vapi_ctx_s *ctx,
+static vapi_error_e call_hicn_api_route_del(struct vapi_ctx_s *ctx,
void *callback_ctx,
vapi_error_e rv,
bool is_last,
@@ -174,7 +162,7 @@ if(!reply->retval){
return VAPI_EUSER;
}
-vapi_error_e call_hicn_api_face_ip_params_get(struct vapi_ctx_s *ctx,
+static vapi_error_e call_hicn_api_face_ip_params_get(struct vapi_ctx_s *ctx,
void *callback_ctx,
vapi_error_e rv,
bool is_last,
@@ -190,8 +178,7 @@ if(!reply->retval){
return VAPI_EUSER;
}
-
-vapi_error_e call_hicn_api_punting_add(struct vapi_ctx_s *ctx,
+static vapi_error_e call_hicn_api_punting_add(struct vapi_ctx_s *ctx,
void *callback_ctx,
vapi_error_e rv,
bool is_last,
@@ -204,7 +191,7 @@ if(!reply->retval){
}
-vapi_error_e call_hicn_api_route_nhop_del(struct vapi_ctx_s *ctx,
+static vapi_error_e call_hicn_api_route_nhop_del(struct vapi_ctx_s *ctx,
void *callback_ctx,
vapi_error_e rv,
bool is_last,
@@ -216,8 +203,7 @@ if(!reply->retval){
return VAPI_EUSER;
}
-
-vapi_error_e call_hicn_api_punting_del(struct vapi_ctx_s *ctx,
+static vapi_error_e call_hicn_api_punting_del(struct vapi_ctx_s *ctx,
void *callback_ctx,
vapi_error_e rv,
bool is_last,
@@ -230,7 +216,7 @@ if(!reply->retval){
}
-vapi_error_e call_hicn_api_face_ip_del(struct vapi_ctx_s *ctx,
+static vapi_error_e call_hicn_api_face_ip_del(struct vapi_ctx_s *ctx,
void *callback_ctx,
vapi_error_e rv,
bool is_last,
@@ -243,7 +229,7 @@ if(!reply->retval){
}
-vapi_error_e call_hicn_api_face_ip_add(struct vapi_ctx_s *ctx,
+static vapi_error_e call_hicn_api_face_ip_add(struct vapi_ctx_s *ctx,
void *callback_ctx,
vapi_error_e rv,
bool is_last,
@@ -256,7 +242,7 @@ if(!reply->retval){
}
-vapi_error_e call_vapi_hicn_api_node_stats_get(struct vapi_ctx_s *ctx,
+static vapi_error_e call_vapi_hicn_api_node_stats_get(struct vapi_ctx_s *ctx,
void *callback_ctx,
vapi_error_e rv,
bool is_last,
@@ -283,21 +269,9 @@ if(!reply->retval){
return VAPI_EUSER;
}
-vapi_error_e call_hicn_api_node_params_set(struct vapi_ctx_s *ctx,
- void *callback_ctx,
- vapi_error_e rv,
- bool is_last,
- vapi_payload_hicn_api_node_params_set_reply *reply){
- if(!reply->retval){
- SRP_LOG_DBGMSG("Successfully done");
- return VAPI_OK;
- }else
- return VAPI_EUSER;
-}
-
static inline void state_update(sr_val_t * vals, struct lyd_node **parent, sr_session_ctx_t *session){
char buf[20];
- //struct ly_ctx *ly_ctx = sr_get_context(sr_session_get_connection(session));
+
sr_val_set_xpath(&vals[0], "/hicn:hicn-state/states/pkts_processed");
vals[0].type = SR_UINT64_T;
vals[0].data.uint64_val = hicn_state->pkts_processed;
@@ -463,8 +437,6 @@ static inline int faces_update(sr_val_t * vals, uint32_t nleaves, struct lyd_no
for(int count=0; count<nleaves; count++){
-
- // This part must be removed once the faceid is provided by the dump msg
vapi_msg_hicn_api_face_ip_params_get *msg;
msg = vapi_alloc_hicn_api_face_ip_params_get(g_vapi_ctx_instance);
@@ -661,9 +633,6 @@ static int hicn_state_route_cb(sr_session_ctx_t *session, const char *module_nam
}
-/**
-* @brief API to get hicn strategies in vpp.
-*/
static int hicn_strategies_get_cb(sr_session_ctx_t *session, const char *path, const sr_val_t *input, const size_t input_cnt,
sr_event_t event, uint32_t request_id, sr_val_t **output, size_t *output_cnt, void *private_data) {
@@ -680,9 +649,6 @@ return SR_ERR_OK;
}
-/**
-* @brief API to add hicn route nhops in vpp.
-*/
static int hicn_route_nhops_add_cb(sr_session_ctx_t *session, const char *path, const sr_val_t *input, const size_t input_cnt,
sr_event_t event, uint32_t request_id, sr_val_t **output, size_t *output_cnt, void *private_data) {
@@ -730,9 +696,6 @@ if(vapi_hicn_api_route_nhops_add(g_vapi_ctx_instance,msg,call_hicn_api_route_nho
return SR_ERR_OK;
}
-/**
-* @brief API to del hicn route in vpp.
-*/
static int hicn_route_del_cb(sr_session_ctx_t *session, const char *path, const sr_val_t *input, const size_t input_cnt,
sr_event_t event, uint32_t request_id, sr_val_t **output, size_t *output_cnt, void *private_data) {
@@ -774,9 +737,6 @@ if(vapi_hicn_api_route_del(g_vapi_ctx_instance,msg,call_hicn_api_route_del,NULL)
return SR_ERR_OK;
}
-/**
-* @brief API to get face ip params in hicn in vpp.
-*/
static int hicn_face_ip_params_get_cb(sr_session_ctx_t *session, const char *path, const sr_val_t *input, const size_t input_cnt,
sr_event_t event, uint32_t request_id, sr_val_t **output, size_t *output_cnt, void *private_data) {
@@ -794,9 +754,6 @@ if (vapi_hicn_api_face_ip_params_get(g_vapi_ctx_instance,msg,call_hicn_api_face_
return SR_ERR_OK;
}
-/**
-* @brief API to get face ip params in hicn in vpp.
-*/
static int hicn_punting_add_ip_cb(sr_session_ctx_t *session, const char *path, const sr_val_t *input, const size_t input_cnt,
sr_event_t event, uint32_t request_id, sr_val_t **output, size_t *output_cnt, void *private_data) {
@@ -842,9 +799,6 @@ if (vapi_hicn_api_punting_add(g_vapi_ctx_instance, msg, call_hicn_api_punting_ad
return SR_ERR_OK;
}
-/**
-* @brief API to del hicn route nhops in vpp.
-*/
static int hicn_route_nhops_del_cb(sr_session_ctx_t *session, const char *path, const sr_val_t *input, const size_t input_cnt,
sr_event_t event, uint32_t request_id, sr_val_t **output, size_t *output_cnt, void *private_data) {
@@ -890,9 +844,6 @@ if (vapi_hicn_api_route_nhop_del(g_vapi_ctx_instance, msg, call_hicn_api_route_n
return SR_ERR_OK;
}
-/**
-* @brief API to del hicn punting in vpp.
-*/
static int hicn_punting_del_cb(sr_session_ctx_t *session, const char *path, const sr_val_t *input, const size_t input_cnt,
sr_event_t event, uint32_t request_id, sr_val_t **output, size_t *output_cnt, void *private_data) {
@@ -939,9 +890,7 @@ return SR_ERR_OK;
}
-/**
-* @brief API to del hicn face ip in vpp.
-*/
+
static int hicn_face_ip_del_cb(sr_session_ctx_t *session, const char *path, const sr_val_t *input, const size_t input_cnt,
sr_event_t event, uint32_t request_id, sr_val_t **output, size_t *output_cnt, void *private_data) {
@@ -960,9 +909,7 @@ if(vapi_hicn_api_face_ip_del(g_vapi_ctx_instance,msg, call_hicn_api_face_ip_del,
return SR_ERR_OK;
}
-/**
-* @brief API to del hicn face ip in vpp.
-*/
+
static int hicn_face_ip_add_cb(sr_session_ctx_t *session, const char *path, const sr_val_t *input, const size_t input_cnt,
sr_event_t event, uint32_t request_id, sr_val_t **output, size_t *output_cnt, void *private_data) {
@@ -1024,7 +971,7 @@ if(vapi_hicn_api_face_ip_add(g_vapi_ctx_instance,msg,call_hicn_api_face_ip_add,N
return SR_ERR_OK;
}
- vapi_error_e
+static vapi_error_e
hicn_api_routes_dump_cb(struct vapi_ctx_s *ctx, void *callback_ctx,
vapi_error_e rv, bool is_last,
vapi_payload_hicn_api_routes_details *reply)
@@ -1060,7 +1007,6 @@ hicn_api_routes_dump_cb(struct vapi_ctx_s *ctx, void *callback_ctx,
}
-
static vapi_error_e
hicn_api_face_stats_dump_cb(struct vapi_ctx_s *ctx, void *callback_ctx,
vapi_error_e rv, bool is_last,
@@ -1099,9 +1045,7 @@ hicn_api_face_stats_dump_cb(struct vapi_ctx_s *ctx, void *callback_ctx,
return SR_ERR_OK;
}
-/**
-* @brief Thread to update the state
-*/
+
static void *state_thread(void *arg) {
// mapping can be retrieved by cpuinfo
@@ -1154,9 +1098,7 @@ static void *state_thread(void *arg) {
return NULL;
}
-/**
-* @brief helper function for subscribing all hicn APIs.
-*/
+
int hicn_subscribe_events(sr_session_ctx_t *session,
sr_subscription_ctx_t **subscription) {
int rc = SR_ERR_OK;
@@ -1279,7 +1221,7 @@ int hicn_subscribe_events(sr_session_ctx_t *session,
goto error;
}
- rc = sr_rpc_subscribe(session, "/hicn:punting-del", hicn_punting_del_cb,
+ rc = sr_rpc_subscribe(session, "/hicn:punting-del-ip", hicn_punting_del_cb,
session, 89,SR_SUBSCR_CTX_REUSE, subscription);
if (rc != SR_ERR_OK) {
SRP_LOG_DBGMSG("Problem in subscription punting-del\n");
diff --git a/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.h b/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.h
index 9c5d9df9a..62fb15340 100644
--- a/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.h
+++ b/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.h
@@ -13,38 +13,84 @@
* limitations under the License.
*/
+/**
+ * @file hicn_model.h
+ * @brief This file contains main calls for hICN events coresponding to the hICN yang models
+ */
+
#ifndef __IETF_HICN_H__
#define __IETF_HICN_H__
#include "../hicn_vpp_comm.h"
#include <vapi/hicn.api.vapi.h>
+/**
+ * @brief Align memory to one page boundary
+ */
#define MEM_ALIGN 4096
+
+/**
+ * @brief 32 bits = 4 bytes
+ */
#define B32 4
+/**
+ * @brief 64bits = 8 bytes
+ */
#define B64 8
+/**
+ * @brief 128 bits = 16 bytes
+ */
#define B128 16
-// Number of locks is equal to number of nodes in hicn-state
-// It is a coarse grain approach later can be changed to fine grained
-// better to initialize the lock by 0
+/**
+ * @brief set number of lock to 5
+ */
#define NLOCKS 5
-#define LOCK_INIT 0
+/**
+ * @brief initialize all locks by 0, better to initialize by 0 :)
+ */
+#define LOCK_INIT 0
+/**
+ * @brief enumeration for the locks
+ */
enum locks_name {lstate, lstrategy, lstrategies, lroute, lfaces};
+
+// It is a coarse grain approach later can be changed to fine grained
+
+
+/**
+ * @brief This indicates the number of leaves for the hICN state
+ */
#define NSTATE_LEAVES 15
+/**
+ * @brief This indicates the number of leaves for strategy
+ */
#define NSTRATEGY_LEAVES 1
+/**
+ * @brief This indicates the number of leaves for strategies
+ */
#define NSTRATEGIES_LEAVES 2
+/**
+ * @brief This indicates the maximum faces which can be read as operational data
+ */
#define MAX_FACE_POOL 100
+/**
+ * @brief This indicates the maximum routes which can be read as operational data
+ */
#define MAX_ROUTE_POOL 100
-
+/**
+ * @brief This indicates the number of leaves for faces
+ */
#define FACES_CHILDREN 9 /*this is the number of children of each leave in face except the key*/
+/**
+ * @brief This indicates the number of leaves for routes
+ */
#define ROUTES_CHILDREN 2 /*this is the number of children of each leave in face except the key*/
typedef struct __attribute__ ((__packed__)) {
-
-
int32_t retval;
uint64_t pkts_processed;
uint64_t pkts_interest_count;
@@ -61,14 +107,8 @@ typedef struct __attribute__ ((__packed__)) {
uint64_t pit_entries_count;
uint64_t cs_entries_count;
uint64_t cs_entries_ntw_count;
-
} hicn_state_t;
-typedef struct __attribute__ ((__packed__)) {
- uint8_t description[200];
- int32_t retval;
-} hicn_strategy_t;
-
typedef struct __attribute__ ((__packed__)) {
@@ -77,18 +117,6 @@ typedef struct __attribute__ ((__packed__)) {
int32_t retval;
} hicn_strategies_t;
-typedef struct __attribute__ ((__packed__)) {
- uint32_t faceids[1000];
- uint32_t strategy_id;
- int32_t retval;
-} hicn_route_t;
-
-typedef struct __attribute__ ((__packed__)) {
- uint64_t nh_addr[2];
- uint32_t swif;
- uint32_t flags;
- int32_t retval;
-} hicn_face_ip_params_t;
typedef struct __attribute__ ((__packed__)) {
uint32_t faceid;
@@ -103,6 +131,7 @@ typedef struct __attribute__ ((__packed__)) {
uint64_t dtx_bytes;
} hicn_face_inf_t;
+
typedef struct __attribute__ ((__packed__)) {
u32 route_id;
vapi_type_prefix prefix;
@@ -111,17 +140,23 @@ typedef struct __attribute__ ((__packed__)) {
u32 strategy_id;
} hicn_route_inf_t;
-
+/**
+ * @brief This is the link list to maintain the statistics of the faces
+ */
struct hicn_faces_s{
hicn_face_inf_t face;
struct hicn_faces_s * next;
};
+
typedef struct __attribute__ ((__packed__)) {
uint32_t nface;
struct hicn_faces_s * next;
} hicn_faces_t;
+/**
+ * @brief This is the link list to maintain the route informations
+ */
struct hicn_routes_s{
hicn_route_inf_t route;
struct hicn_routes_s * next;
@@ -133,6 +168,10 @@ typedef struct __attribute__ ((__packed__)) {
struct hicn_routes_s * next;
} hicn_routes_t;
+/**
+ * @brief This function subscribes the hICN evens consisting of all RPCs
+ * as well as operational data
+ */
int hicn_subscribe_events(sr_session_ctx_t *session,
sr_subscription_ctx_t **subscription);
diff --git a/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/tlock.h b/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/tlock.h
index 8cdfc8b5b..a871705a3 100644
--- a/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/tlock.h
+++ b/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/tlock.h
@@ -14,18 +14,51 @@
*/
+
+/**
+ * @file tlock.h
+ * @brief This file contains ticket lock APIs.
+ */
+
#ifndef __TLOCK_H__
#define __TLOCK_H__
-// limit on the number of locks: it shoud be matched with the number of hicn-state leaves
+/**
+
+ * @brief limit the number of locks: it shoud be matched with the
+ * number of hicn-state leaves
+ */
#define MAX_LOCK_SIZE 5
-volatile long int En[MAX_LOCK_SIZE] , De[MAX_LOCK_SIZE] ; // For Ticket Algorithm
+/**
+ * @brief Ticket lock counters
+ */
+volatile long int En[MAX_LOCK_SIZE] ;
+
+/**
+ * @brief Ticket lock counters
+ */
+volatile long int De[MAX_LOCK_SIZE] ;
+/**
+ * @brief This function initialize the ticket lock
+ * @param Lock_Number describes the number of locks need to be initialized
+ * @param init describes the init number
+ */
void ticket_init ( int Lock_Number , long int init );
+/**
+ * @brief this function acquire the lock
+ * Description of what the function does. This part may refer to the parameters
+ * @param Lock_Number pass the lock
+ */
void tlock(int Lock_Number );
+/**
+ * @briefthis function release the lock
+ * @param Lock_Number lock number
+
+ */
void tunlock(int Lock_Number );
#endif /* __IETF_HICN_H__ */ \ No newline at end of file