aboutsummaryrefslogtreecommitdiffstats
path: root/utils/sysrepo-plugins/hicn-light/plugin/model
diff options
context:
space:
mode:
Diffstat (limited to 'utils/sysrepo-plugins/hicn-light/plugin/model')
-rw-r--r--utils/sysrepo-plugins/hicn-light/plugin/model/hicn_model.c33
-rw-r--r--utils/sysrepo-plugins/hicn-light/plugin/model/hicn_model.h44
-rw-r--r--utils/sysrepo-plugins/hicn-light/plugin/model/tlock.c21
-rw-r--r--utils/sysrepo-plugins/hicn-light/plugin/model/tlock.h31
4 files changed, 129 insertions, 0 deletions
diff --git a/utils/sysrepo-plugins/hicn-light/plugin/model/hicn_model.c b/utils/sysrepo-plugins/hicn-light/plugin/model/hicn_model.c
new file mode 100644
index 000000000..0c34325d6
--- /dev/null
+++ b/utils/sysrepo-plugins/hicn-light/plugin/model/hicn_model.c
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 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 <stdio.h>
+#include <malloc.h>
+#include <sysrepo/xpath.h>
+
+/* Hicn headers */
+
+#include "hicn_model.h"
+#include "tlock.h"
+#include "../hicn_light.h"
+
+
+
+int hicn_subscribe_events(sr_session_ctx_t *session,
+ sr_subscription_ctx_t **subscription) {
+
+ SRP_LOG_INF_MSG("hicn light plugin initialized successfully.");
+ return SR_ERR_OK;
+
+} \ No newline at end of file
diff --git a/utils/sysrepo-plugins/hicn-light/plugin/model/hicn_model.h b/utils/sysrepo-plugins/hicn-light/plugin/model/hicn_model.h
new file mode 100644
index 000000000..59befe68c
--- /dev/null
+++ b/utils/sysrepo-plugins/hicn-light/plugin/model/hicn_model.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 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 __IETF_HICN_H__
+#define __IETF_HICN_H__
+
+#include "../hicn_light_comm.h"
+
+
+#define MEM_ALIGN 4096
+
+// 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
+#define NLOCKS 5
+#define LOCK_INIT 0
+
+
+enum locks_name {lstate, lstrategy, lstrategies, lroute, lface_ip_params};
+
+#define NSTATE_LEAVES 15
+#define NSTRATEGY_LEAVES 1
+#define NSTRATEGIES_LEAVES 2
+#define NROUTE_LEAVES 2
+#define NFACE_IP_PARAMS_LEAVES 3
+
+
+
+int hicn_subscribe_events(sr_session_ctx_t *session,
+ sr_subscription_ctx_t **subscription);
+
+#endif /* __IETF_HICN_H__ */ \ No newline at end of file
diff --git a/utils/sysrepo-plugins/hicn-light/plugin/model/tlock.c b/utils/sysrepo-plugins/hicn-light/plugin/model/tlock.c
new file mode 100644
index 000000000..2f7b11efa
--- /dev/null
+++ b/utils/sysrepo-plugins/hicn-light/plugin/model/tlock.c
@@ -0,0 +1,21 @@
+#include"tlock.h"
+
+
+void Ticket_init ( int Lock_Number , long int init ){
+
+__atomic_store( &En[Lock_Number] , &init , __ATOMIC_SEQ_CST );
+__atomic_store( &De[Lock_Number] , &init , __ATOMIC_SEQ_CST );
+//En[Lock_Number]=init;
+//De[Lock_Number]=init;
+}
+
+void Ticket_Lock(int Lock_Number ){
+
+ int my_ticket = __sync_fetch_and_add(&En[Lock_Number] , 1 );
+ while ( my_ticket != De[ Lock_Number ] ) {};
+
+}
+
+void Ticket_Unlock(int Lock_Number ){
+De[Lock_Number]++;
+}
diff --git a/utils/sysrepo-plugins/hicn-light/plugin/model/tlock.h b/utils/sysrepo-plugins/hicn-light/plugin/model/tlock.h
new file mode 100644
index 000000000..36698115a
--- /dev/null
+++ b/utils/sysrepo-plugins/hicn-light/plugin/model/tlock.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 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 __TLOCK_H__
+#define __TLOCK_H__
+
+
+// limit on 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
+
+
+void Ticket_init ( int Lock_Number , long int init );
+void Ticket_Lock(int Lock_Number );
+void Ticket_Unlock(int Lock_Number );
+
+#endif /* __IETF_HICN_H__ */ \ No newline at end of file