Commit 501ae74c authored by frtabu's avatar frtabu

first set of cppcheck fixes

parent 52754797
...@@ -166,6 +166,7 @@ int config_check_unknown_cmdlineopt(char *prefix) { ...@@ -166,6 +166,7 @@ int config_check_unknown_cmdlineopt(char *prefix) {
int unknowndetected=0; int unknowndetected=0;
char testprefix[CONFIG_MAXOPTLENGTH]; char testprefix[CONFIG_MAXOPTLENGTH];
int finalcheck = 0; int finalcheck = 0;
memset(testprefix,0,sizeof(testprefix));
memset(testprefix,0,sizeof(testprefix)); memset(testprefix,0,sizeof(testprefix));
if (prefix != NULL) { if (prefix != NULL) {
......
...@@ -28,16 +28,32 @@ ...@@ -28,16 +28,32 @@
//------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------
char* hashtable_rc_code2string(hashtable_rc_t rcP) char *hashtable_rc_code2string(hashtable_rc_t rcP)
//------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------
{ {
switch (rcP) { switch (rcP) {
case HASH_TABLE_OK: return "HASH_TABLE_OK";break; case HASH_TABLE_OK:
case HASH_TABLE_INSERT_OVERWRITTEN_DATA: return "HASH_TABLE_INSERT_OVERWRITTEN_DATA";break; return "HASH_TABLE_OK";
case HASH_TABLE_KEY_NOT_EXISTS: return "HASH_TABLE_KEY_NOT_EXISTS";break; break;
case HASH_TABLE_KEY_ALREADY_EXISTS: return "HASH_TABLE_KEY_ALREADY_EXISTS";break;
case HASH_TABLE_BAD_PARAMETER_HASHTABLE: return "HASH_TABLE_BAD_PARAMETER_HASHTABLE";break; case HASH_TABLE_INSERT_OVERWRITTEN_DATA:
default: return "UNKNOWN hashtable_rc_t"; return "HASH_TABLE_INSERT_OVERWRITTEN_DATA";
break;
case HASH_TABLE_KEY_NOT_EXISTS:
return "HASH_TABLE_KEY_NOT_EXISTS";
break;
case HASH_TABLE_KEY_ALREADY_EXISTS:
return "HASH_TABLE_KEY_ALREADY_EXISTS";
break;
case HASH_TABLE_BAD_PARAMETER_HASHTABLE:
return "HASH_TABLE_BAD_PARAMETER_HASHTABLE";
break;
default:
return "UNKNOWN hashtable_rc_t";
} }
} }
//------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------
...@@ -46,7 +62,7 @@ char* hashtable_rc_code2string(hashtable_rc_t rcP) ...@@ -46,7 +62,7 @@ char* hashtable_rc_code2string(hashtable_rc_t rcP)
* hash_free_int_func() is used when this hashtable is used to store int values as data (pointer = value). * hash_free_int_func() is used when this hashtable is used to store int values as data (pointer = value).
*/ */
void hash_free_int_func(void* memoryP){} void hash_free_int_func(void *memoryP) {}
//------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------
/* /*
...@@ -55,8 +71,7 @@ void hash_free_int_func(void* memoryP){} ...@@ -55,8 +71,7 @@ void hash_free_int_func(void* memoryP){}
* This is a simple/naive hash function which adds the key's ASCII char values. It will probably generate lots of collisions on large hash tables. * This is a simple/naive hash function which adds the key's ASCII char values. It will probably generate lots of collisions on large hash tables.
*/ */
static hash_size_t def_hashfunc(const uint64_t keyP) static hash_size_t def_hashfunc(const uint64_t keyP) {
{
return (hash_size_t)keyP; return (hash_size_t)keyP;
} }
...@@ -67,15 +82,14 @@ static hash_size_t def_hashfunc(const uint64_t keyP) ...@@ -67,15 +82,14 @@ static hash_size_t def_hashfunc(const uint64_t keyP)
* The user can also specify a hash function. If the hashfunc argument is NULL, a default hash function is used. * The user can also specify a hash function. If the hashfunc argument is NULL, a default hash function is used.
* If an error occurred, NULL is returned. All other values in the returned hash_table_t pointer should be released with hashtable_destroy(). * If an error occurred, NULL is returned. All other values in the returned hash_table_t pointer should be released with hashtable_destroy().
*/ */
hash_table_t *hashtable_create(const hash_size_t sizeP, hash_size_t (*hashfuncP)(const hash_key_t ), void (*freefuncP)(void*)) hash_table_t *hashtable_create(const hash_size_t sizeP, hash_size_t (*hashfuncP)(const hash_key_t ), void (*freefuncP)(void *)) {
{
hash_table_t *hashtbl = NULL; hash_table_t *hashtbl = NULL;
if(!(hashtbl=malloc(sizeof(hash_table_t)))) { if(!(hashtbl=malloc(sizeof(hash_table_t)))) {
return NULL; return NULL;
} }
if(!(hashtbl->nodes=calloc(sizeP, sizeof(hash_node_t*)))) { if(!(hashtbl->nodes=calloc(sizeP, sizeof(hash_node_t *)))) {
free(hashtbl); free(hashtbl);
return NULL; return NULL;
} }
...@@ -95,33 +109,36 @@ hash_table_t *hashtable_create(const hash_size_t sizeP, hash_size_t (*hashfuncP) ...@@ -95,33 +109,36 @@ hash_table_t *hashtable_create(const hash_size_t sizeP, hash_size_t (*hashfuncP)
* Cleanup * Cleanup
* The hashtable_destroy() walks through the linked lists for each possible hash value, and releases the elements. It also releases the nodes array and the hash_table_t. * The hashtable_destroy() walks through the linked lists for each possible hash value, and releases the elements. It also releases the nodes array and the hash_table_t.
*/ */
hashtable_rc_t hashtable_destroy(hash_table_t * hashtblP) hashtable_rc_t hashtable_destroy(hash_table_t **hashtblP) {
{
hash_size_t n; hash_size_t n;
hash_node_t *node, *oldnode; hash_node_t *node, *oldnode;
if (hashtblP == NULL) { if (*hashtblP == NULL) {
return HASH_TABLE_BAD_PARAMETER_HASHTABLE; return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
} }
for(n=0; n<hashtblP->size; ++n) { for(n=0; n<(*hashtblP)->size; ++n) {
node=hashtblP->nodes[n]; node=(*hashtblP)->nodes[n];
while(node) { while(node) {
oldnode=node; oldnode=node;
node=node->next; node=node->next;
if (oldnode->data) { if (oldnode->data) {
hashtblP->freefunc(oldnode->data); (*hashtblP)->freefunc(oldnode->data);
} }
free(oldnode); free(oldnode);
} }
} }
free(hashtblP->nodes);
free(hashtblP); free((*hashtblP)->nodes);
hashtblP=NULL; free((*hashtblP));
*hashtblP=NULL;
return HASH_TABLE_OK; return HASH_TABLE_OK;
} }
//------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------
hashtable_rc_t hashtable_is_key_exists (const hash_table_t * const hashtblP, const hash_key_t keyP) hashtable_rc_t hashtable_is_key_exists (const hash_table_t *const hashtblP, const hash_key_t keyP)
//------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------
{ {
hash_node_t *node = NULL; hash_node_t *node = NULL;
...@@ -133,43 +150,52 @@ hashtable_rc_t hashtable_is_key_exists (const hash_table_t * const hashtblP, con ...@@ -133,43 +150,52 @@ hashtable_rc_t hashtable_is_key_exists (const hash_table_t * const hashtblP, con
hash=hashtblP->hashfunc(keyP)%hashtblP->size; hash=hashtblP->hashfunc(keyP)%hashtblP->size;
node=hashtblP->nodes[hash]; node=hashtblP->nodes[hash];
while(node) { while(node) {
if(node->key == keyP) { if(node->key == keyP) {
return HASH_TABLE_OK; return HASH_TABLE_OK;
} }
node=node->next; node=node->next;
} }
return HASH_TABLE_KEY_NOT_EXISTS; return HASH_TABLE_KEY_NOT_EXISTS;
} }
//------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------
hashtable_rc_t hashtable_apply_funct_on_elements (hash_table_t *const hashtblP, void functP(hash_key_t keyP, void* dataP, void* parameterP), void* parameterP) hashtable_rc_t hashtable_apply_funct_on_elements (hash_table_t *const hashtblP, void functP(hash_key_t keyP, void *dataP, void *parameterP), void *parameterP)
//------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------
{ {
hash_node_t *node = NULL; hash_node_t *node = NULL;
unsigned int i = 0; unsigned int i = 0;
unsigned int num_elements = 0; unsigned int num_elements = 0;
if (hashtblP == NULL) { if (hashtblP == NULL) {
return HASH_TABLE_BAD_PARAMETER_HASHTABLE; return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
} }
while ((num_elements < hashtblP->num_elements) && (i < hashtblP->size)) { while ((num_elements < hashtblP->num_elements) && (i < hashtblP->size)) {
if (hashtblP->nodes[i] != NULL) { if (hashtblP->nodes[i] != NULL) {
node=hashtblP->nodes[i]; node=hashtblP->nodes[i];
while(node) { while(node) {
num_elements += 1; num_elements += 1;
functP(node->key, node->data, parameterP); functP(node->key, node->data, parameterP);
node=node->next; node=node->next;
} }
} }
i += 1; i += 1;
} }
return HASH_TABLE_OK; return HASH_TABLE_OK;
} }
//------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------
hashtable_rc_t hashtable_dump_content (const hash_table_t * const hashtblP, char * const buffer_pP, int * const remaining_bytes_in_buffer_pP ) hashtable_rc_t hashtable_dump_content (const hash_table_t *const hashtblP, char *const buffer_pP, int *const remaining_bytes_in_buffer_pP )
//------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------
{ {
hash_node_t *node = NULL; hash_node_t *node = NULL;
unsigned int i = 0; unsigned int i = 0;
if (hashtblP == NULL) { if (hashtblP == NULL) {
*remaining_bytes_in_buffer_pP = snprintf( *remaining_bytes_in_buffer_pP = snprintf(
buffer_pP, buffer_pP,
...@@ -177,9 +203,11 @@ hashtable_rc_t hashtable_dump_content (const hash_table_t * const hashtblP, char ...@@ -177,9 +203,11 @@ hashtable_rc_t hashtable_dump_content (const hash_table_t * const hashtblP, char
"HASH_TABLE_BAD_PARAMETER_HASHTABLE"); "HASH_TABLE_BAD_PARAMETER_HASHTABLE");
return HASH_TABLE_BAD_PARAMETER_HASHTABLE; return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
} }
while ((i < hashtblP->size) && (*remaining_bytes_in_buffer_pP > 0)) { while ((i < hashtblP->size) && (*remaining_bytes_in_buffer_pP > 0)) {
if (hashtblP->nodes[i] != NULL) { if (hashtblP->nodes[i] != NULL) {
node=hashtblP->nodes[i]; node=hashtblP->nodes[i];
while(node) { while(node) {
*remaining_bytes_in_buffer_pP = snprintf( *remaining_bytes_in_buffer_pP = snprintf(
buffer_pP, buffer_pP,
...@@ -190,8 +218,10 @@ hashtable_rc_t hashtable_dump_content (const hash_table_t * const hashtblP, char ...@@ -190,8 +218,10 @@ hashtable_rc_t hashtable_dump_content (const hash_table_t * const hashtblP, char
node=node->next; node=node->next;
} }
} }
i += 1; i += 1;
} }
return HASH_TABLE_OK; return HASH_TABLE_OK;
} }
...@@ -200,34 +230,41 @@ hashtable_rc_t hashtable_dump_content (const hash_table_t * const hashtblP, char ...@@ -200,34 +230,41 @@ hashtable_rc_t hashtable_dump_content (const hash_table_t * const hashtblP, char
* Adding a new element * Adding a new element
* To make sure the hash value is not bigger than size, the result of the user provided hash function is used modulo size. * To make sure the hash value is not bigger than size, the result of the user provided hash function is used modulo size.
*/ */
hashtable_rc_t hashtable_insert(hash_table_t * const hashtblP, const hash_key_t keyP, void *dataP) hashtable_rc_t hashtable_insert(hash_table_t *const hashtblP, const hash_key_t keyP, void *dataP) {
{
hash_node_t *node = NULL; hash_node_t *node = NULL;
hash_size_t hash = 0; hash_size_t hash = 0;
if (hashtblP == NULL) { if (hashtblP == NULL) {
return HASH_TABLE_BAD_PARAMETER_HASHTABLE; return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
} }
hash=hashtblP->hashfunc(keyP)%hashtblP->size;
hash=hashtblP->hashfunc(keyP)%hashtblP->size;
node=hashtblP->nodes[hash]; node=hashtblP->nodes[hash];
while(node) { while(node) {
if(node->key == keyP) { if(node->key == keyP) {
if (node->data) { if (node->data) {
hashtblP->freefunc(node->data); hashtblP->freefunc(node->data);
} }
node->data=dataP; node->data=dataP;
return HASH_TABLE_INSERT_OVERWRITTEN_DATA; return HASH_TABLE_INSERT_OVERWRITTEN_DATA;
} }
node=node->next; node=node->next;
} }
if(!(node=malloc(sizeof(hash_node_t)))) return -1; if(!(node=malloc(sizeof(hash_node_t)))) return -1;
node->key=keyP; node->key=keyP;
node->data=dataP; node->data=dataP;
if (hashtblP->nodes[hash]) { if (hashtblP->nodes[hash]) {
node->next=hashtblP->nodes[hash]; node->next=hashtblP->nodes[hash];
} else { } else {
node->next = NULL; node->next = NULL;
} }
hashtblP->nodes[hash]=node; hashtblP->nodes[hash]=node;
hashtblP->num_elements += 1; hashtblP->num_elements += 1;
return HASH_TABLE_OK; return HASH_TABLE_OK;
...@@ -237,30 +274,35 @@ hashtable_rc_t hashtable_insert(hash_table_t * const hashtblP, const hash_key_t ...@@ -237,30 +274,35 @@ hashtable_rc_t hashtable_insert(hash_table_t * const hashtblP, const hash_key_t
* To remove an element from the hash table, we just search for it in the linked list for that hash value, * To remove an element from the hash table, we just search for it in the linked list for that hash value,
* and remove it if it is found. If it was not found, it is an error and -1 is returned. * and remove it if it is found. If it was not found, it is an error and -1 is returned.
*/ */
hashtable_rc_t hashtable_remove(hash_table_t * const hashtblP, const hash_key_t keyP) hashtable_rc_t hashtable_remove(hash_table_t *const hashtblP, const hash_key_t keyP) {
{
hash_node_t *node, *prevnode=NULL; hash_node_t *node, *prevnode=NULL;
hash_size_t hash = 0; hash_size_t hash = 0;
if (hashtblP == NULL) { if (hashtblP == NULL) {
return HASH_TABLE_BAD_PARAMETER_HASHTABLE; return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
} }
hash=hashtblP->hashfunc(keyP)%hashtblP->size; hash=hashtblP->hashfunc(keyP)%hashtblP->size;
node=hashtblP->nodes[hash]; node=hashtblP->nodes[hash];
while(node) { while(node) {
if(node->key == keyP) { if(node->key == keyP) {
if(prevnode) prevnode->next=node->next; if(prevnode) prevnode->next=node->next;
else hashtblP->nodes[hash]=node->next; else hashtblP->nodes[hash]=node->next;
if (node->data) { if (node->data) {
hashtblP->freefunc(node->data); hashtblP->freefunc(node->data);
} }
free(node); free(node);
hashtblP->num_elements -= 1; hashtblP->num_elements -= 1;
return HASH_TABLE_OK; return HASH_TABLE_OK;
} }
prevnode=node; prevnode=node;
node=node->next; node=node->next;
} }
return HASH_TABLE_KEY_NOT_EXISTS; return HASH_TABLE_KEY_NOT_EXISTS;
} }
//------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------
...@@ -268,8 +310,7 @@ hashtable_rc_t hashtable_remove(hash_table_t * const hashtblP, const hash_key_t ...@@ -268,8 +310,7 @@ hashtable_rc_t hashtable_remove(hash_table_t * const hashtblP, const hash_key_t
* Searching for an element is easy. We just search through the linked list for the corresponding hash value. * Searching for an element is easy. We just search through the linked list for the corresponding hash value.
* NULL is returned if we didn't find it. * NULL is returned if we didn't find it.
*/ */
hashtable_rc_t hashtable_get(const hash_table_t * const hashtblP, const hash_key_t keyP, void** dataP) hashtable_rc_t hashtable_get(const hash_table_t *const hashtblP, const hash_key_t keyP, void **dataP) {
{
hash_node_t *node = NULL; hash_node_t *node = NULL;
hash_size_t hash = 0; hash_size_t hash = 0;
...@@ -277,9 +318,9 @@ hashtable_rc_t hashtable_get(const hash_table_t * const hashtblP, const hash_key ...@@ -277,9 +318,9 @@ hashtable_rc_t hashtable_get(const hash_table_t * const hashtblP, const hash_key
*dataP = NULL; *dataP = NULL;
return HASH_TABLE_BAD_PARAMETER_HASHTABLE; return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
} }
hash=hashtblP->hashfunc(keyP)%hashtblP->size;
/* fprintf(stderr, "hashtable_get() key=%s, hash=%d\n", key, hash);*/
hash=hashtblP->hashfunc(keyP)%hashtblP->size;
/* fprintf(stderr, "hashtable_get() key=%s, hash=%d\n", key, hash);*/
node=hashtblP->nodes[hash]; node=hashtblP->nodes[hash];
while(node) { while(node) {
...@@ -287,8 +328,10 @@ hashtable_rc_t hashtable_get(const hash_table_t * const hashtblP, const hash_key ...@@ -287,8 +328,10 @@ hashtable_rc_t hashtable_get(const hash_table_t * const hashtblP, const hash_key
*dataP = node->data; *dataP = node->data;
return HASH_TABLE_OK; return HASH_TABLE_OK;
} }
node=node->next; node=node->next;
} }
*dataP = NULL; *dataP = NULL;
return HASH_TABLE_KEY_NOT_EXISTS; return HASH_TABLE_KEY_NOT_EXISTS;
} }
...@@ -304,8 +347,7 @@ hashtable_rc_t hashtable_get(const hash_table_t * const hashtblP, const hash_key ...@@ -304,8 +347,7 @@ hashtable_rc_t hashtable_get(const hash_table_t * const hashtblP, const hash_key
* After that, we can just free the old table and copy the elements from newtbl to hashtbl. * After that, we can just free the old table and copy the elements from newtbl to hashtbl.
*/ */
hashtable_rc_t hashtable_resize(hash_table_t * const hashtblP, const hash_size_t sizeP) hashtable_rc_t hashtable_resize(hash_table_t *const hashtblP, const hash_size_t sizeP) {
{
hash_table_t newtbl; hash_table_t newtbl;
hash_size_t n; hash_size_t n;
hash_node_t *node,*next; hash_node_t *node,*next;
...@@ -317,7 +359,7 @@ hashtable_rc_t hashtable_resize(hash_table_t * const hashtblP, const hash_size_t ...@@ -317,7 +359,7 @@ hashtable_rc_t hashtable_resize(hash_table_t * const hashtblP, const hash_size_t
newtbl.size = sizeP; newtbl.size = sizeP;
newtbl.hashfunc = hashtblP->hashfunc; newtbl.hashfunc = hashtblP->hashfunc;
if(!(newtbl.nodes=calloc(sizeP, sizeof(hash_node_t*)))) return -1; if(!(newtbl.nodes=calloc(sizeP, sizeof(hash_node_t *)))) return -1;
for(n=0; n<hashtblP->size; ++n) { for(n=0; n<hashtblP->size; ++n) {
for(node=hashtblP->nodes[n]; node; node=next) { for(node=hashtblP->nodes[n]; node; node=next) {
...@@ -325,14 +367,12 @@ hashtable_rc_t hashtable_resize(hash_table_t * const hashtblP, const hash_size_t ...@@ -325,14 +367,12 @@ hashtable_rc_t hashtable_resize(hash_table_t * const hashtblP, const hash_size_t
hashtable_insert(&newtbl, node->key, node->data); hashtable_insert(&newtbl, node->key, node->data);
// Lionel GAUTHIER: BAD CODE TO BE REWRITTEN // Lionel GAUTHIER: BAD CODE TO BE REWRITTEN
hashtable_remove(hashtblP, node->key); hashtable_remove(hashtblP, node->key);
} }
} }
free(hashtblP->nodes); free(hashtblP->nodes);
hashtblP->size=newtbl.size; hashtblP->size=newtbl.size;
hashtblP->nodes=newtbl.nodes; hashtblP->nodes=newtbl.nodes;
return HASH_TABLE_OK; return HASH_TABLE_OK;
} }
......
...@@ -52,20 +52,20 @@ typedef struct hash_table_s { ...@@ -52,20 +52,20 @@ typedef struct hash_table_s {
hash_size_t num_elements; hash_size_t num_elements;
struct hash_node_s **nodes; struct hash_node_s **nodes;
hash_size_t (*hashfunc)(const hash_key_t); hash_size_t (*hashfunc)(const hash_key_t);
void (*freefunc)(void*); void (*freefunc)(void *);
} hash_table_t; } hash_table_t;
char* hashtable_rc_code2string(hashtable_rc_t rcP); char *hashtable_rc_code2string(hashtable_rc_t rcP);
void hash_free_int_func(void* memoryP); void hash_free_int_func(void *memoryP);
hash_table_t *hashtable_create (const hash_size_t size, hash_size_t (*hashfunc)(const hash_key_t ), void (*freefunc)(void*)); hash_table_t *hashtable_create (const hash_size_t size, hash_size_t (*hashfunc)(const hash_key_t ), void (*freefunc)(void *));
hashtable_rc_t hashtable_destroy(hash_table_t * const hashtbl); hashtable_rc_t hashtable_destroy(hash_table_t **hashtbl);
hashtable_rc_t hashtable_is_key_exists (const hash_table_t * const hashtbl, const uint64_t key); hashtable_rc_t hashtable_is_key_exists (const hash_table_t *const hashtbl, const uint64_t key);
hashtable_rc_t hashtable_apply_funct_on_elements (hash_table_t * const hashtblP, void funct(hash_key_t keyP, void* dataP, void* parameterP), void* parameterP); hashtable_rc_t hashtable_apply_funct_on_elements (hash_table_t *const hashtblP, void funct(hash_key_t keyP, void *dataP, void *parameterP), void *parameterP);
hashtable_rc_t hashtable_dump_content (const hash_table_t * const hashtblP, char * const buffer_pP, int * const remaining_bytes_in_buffer_pP ); hashtable_rc_t hashtable_dump_content (const hash_table_t *const hashtblP, char *const buffer_pP, int *const remaining_bytes_in_buffer_pP );
hashtable_rc_t hashtable_insert (hash_table_t * const hashtbl, const hash_key_t key, void *data); hashtable_rc_t hashtable_insert (hash_table_t *const hashtbl, const hash_key_t key, void *data);
hashtable_rc_t hashtable_remove (hash_table_t * const hashtbl, const hash_key_t key); hashtable_rc_t hashtable_remove (hash_table_t *const hashtbl, const hash_key_t key);
hashtable_rc_t hashtable_get (const hash_table_t * const hashtbl, const hash_key_t key, void **dataP); hashtable_rc_t hashtable_get (const hash_table_t *const hashtbl, const hash_key_t key, void **dataP);
hashtable_rc_t hashtable_resize (hash_table_t * const hashtbl, const hash_size_t size); hashtable_rc_t hashtable_resize (hash_table_t *const hashtbl, const hash_size_t size);
......
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
#include "memory_pools.h" #include "memory_pools.h"
#if T_TRACER #if T_TRACER
#include <string.h> #include <string.h>
#include "T.h" #include "T.h"
#endif #endif
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
...@@ -35,7 +35,7 @@ const static int mp_debug = 0; ...@@ -35,7 +35,7 @@ const static int mp_debug = 0;
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
#ifndef CHARS_TO_UINT32 #ifndef CHARS_TO_UINT32
#define CHARS_TO_UINT32(c1, c2, c3, c4) (((c1) << 24) | ((c2) << 16) | ((c3) << 8) | (c4)) #define CHARS_TO_UINT32(c1, c2, c3, c4) (((c1) << 24) | ((c2) << 16) | ((c3) << 8) | (c4))
#endif #endif
#define MEMORY_POOL_ITEM_INFO_NUMBER 2 #define MEMORY_POOL_ITEM_INFO_NUMBER 2
...@@ -129,33 +129,25 @@ static const pool_start_mark_t POOL_START_MARK = CHARS_TO_UINT32 ('P' ...@@ -129,33 +129,25 @@ static const pool_start_mark_t POOL_START_MARK = CHARS_TO_UINT32 ('P'
static const pools_start_mark_t POOLS_START_MARK = CHARS_TO_UINT32 ('P', 'S', 's', 't'); static const pools_start_mark_t POOLS_START_MARK = CHARS_TO_UINT32 ('P', 'S', 's', 't');
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
static inline uint32_t items_group_number_items (items_group_t *items_group) static inline uint32_t items_group_number_items (items_group_t *items_group) {
{
return items_group->number_plus_one - 1; return items_group->number_plus_one - 1;
} }
static inline uint32_t items_group_free_items (items_group_t *items_group) static inline uint32_t items_group_free_items (items_group_t *items_group) {
{
items_group_positions_t positions; items_group_positions_t positions;
uint32_t free_items; uint32_t free_items;
positions.all = items_group->positions.all; positions.all = items_group->positions.all;
free_items = items_group->number_plus_one + positions.ind.put - positions.ind.get; free_items = items_group->number_plus_one + positions.ind.put - positions.ind.get;
free_items %= items_group->number_plus_one; free_items %= items_group->number_plus_one;
return free_items; return free_items;
} }
static inline items_group_index_t items_group_get_free_item (items_group_t *items_group) static inline items_group_index_t items_group_get_free_item (items_group_t *items_group) {
{
items_group_position_t get_raw; items_group_position_t get_raw;
items_group_position_t put; items_group_position_t put;
items_group_position_t get; items_group_position_t get;
items_group_position_t free_items; items_group_position_t free_items;
items_group_index_t index = ITEMS_GROUP_INDEX_INVALID; items_group_index_t index = ITEMS_GROUP_INDEX_INVALID;
/* Get current put position */ /* Get current put position */
put = items_group->positions.ind.put % items_group->number_plus_one; put = items_group->positions.ind.put % items_group->number_plus_one;
/* Get current get position and increase it */ /* Get current get position and increase it */
...@@ -193,11 +185,9 @@ static inline items_group_index_t items_group_get_free_item (items_group_t *item ...@@ -193,11 +185,9 @@ static inline items_group_index_t items_group_get_free_item (items_group_t *item
return (index); return (index);
} }
static inline int items_group_put_free_item (items_group_t *items_group, items_group_index_t index) static inline int items_group_put_free_item (items_group_t *items_group, items_group_index_t index) {
{
items_group_position_t put_raw; items_group_position_t put_raw;
items_group_position_t put; items_group_position_t put;
/* Get current put position and increase it */ /* Get current put position and increase it */
put_raw = __sync_fetch_and_add (&items_group->positions.ind.put, 1); put_raw = __sync_fetch_and_add (&items_group->positions.ind.put, 1);
put = put_raw % items_group->number_plus_one; put = put_raw % items_group->number_plus_one;
...@@ -209,70 +199,54 @@ static inline int items_group_put_free_item (items_group_t *items_group, items_g ...@@ -209,70 +199,54 @@ static inline int items_group_put_free_item (items_group_t *items_group, items_g
AssertError (items_group->indexes[put] <= ITEMS_GROUP_INDEX_INVALID, return (EXIT_FAILURE), AssertError (items_group->indexes[put] <= ITEMS_GROUP_INDEX_INVALID, return (EXIT_FAILURE),
"Index at current put position (%d) is not marked as free (%d)!\n", put, items_group->number_plus_one); "Index at current put position (%d) is not marked as free (%d)!\n", put, items_group->number_plus_one);
/* Save freed item index at current put position */ /* Save freed item index at current put position */
items_group->indexes[put] = index; items_group->indexes[put] = index;
return (EXIT_SUCCESS); return (EXIT_SUCCESS);
} }
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
static inline memory_pools_t *memory_pools_from_handler (memory_pools_handle_t memory_pools_handle) static inline memory_pools_t *memory_pools_from_handler (memory_pools_handle_t memory_pools_handle) {
{
memory_pools_t *memory_pools; memory_pools_t *memory_pools;
/* Recover memory_pools */ /* Recover memory_pools */
memory_pools = (memory_pools_t *) memory_pools_handle; memory_pools = (memory_pools_t *) memory_pools_handle;
/* Sanity check on passed handle */ /* Sanity check on passed handle */
AssertError (memory_pools->start_mark == POOLS_START_MARK, memory_pools = NULL, AssertError (memory_pools->start_mark == POOLS_START_MARK, memory_pools = NULL,
"Handle %p is not a valid memory pools handle, start mark is missing!\n", memory_pools_handle); "Handle %p is not a valid memory pools handle, start mark is missing!\n", memory_pools_handle);
return (memory_pools); return (memory_pools);
} }
static inline memory_pool_item_t *memory_pool_item_from_handler (memory_pool_item_handle_t memory_pool_item_handle) static inline memory_pool_item_t *memory_pool_item_from_handler (memory_pool_item_handle_t memory_pool_item_handle) {
{
void *address; void *address;
memory_pool_item_t *memory_pool_item; memory_pool_item_t *memory_pool_item;
/* Recover memory_pools */ /* Recover memory_pools */
address = memory_pool_item_handle - sizeof(memory_pool_item_start_t); address = memory_pool_item_handle - sizeof(memory_pool_item_start_t);
memory_pool_item = (memory_pool_item_t *) address; memory_pool_item = (memory_pool_item_t *) address;
/* Sanity check on passed handle */ /* Sanity check on passed handle */
AssertError (memory_pool_item->start.start_mark == POOL_ITEM_START_MARK, memory_pool_item = NULL, AssertError (memory_pool_item->start.start_mark == POOL_ITEM_START_MARK, memory_pool_item = NULL,
"Handle %p is not a valid memory pool item handle, start mark is missing!\n", memory_pool_item); "Handle %p is not a valid memory pool item handle, start mark is missing!\n", memory_pool_item);
return (memory_pool_item); return (memory_pool_item);
} }
static inline memory_pool_item_t *memory_pool_item_from_index (memory_pool_t *memory_pool, items_group_index_t index) static inline memory_pool_item_t *memory_pool_item_from_index (memory_pool_t *memory_pool, items_group_index_t index) {
{
void *address; void *address;
address = (void *) memory_pool->items; address = (void *) memory_pool->items;
address += index * memory_pool->pool_item_size; address += index * memory_pool->pool_item_size;
return (address); return (address);
} }
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
memory_pools_handle_t memory_pools_create (uint32_t pools_number) memory_pools_handle_t memory_pools_create (uint32_t pools_number) {
{
memory_pools_t *memory_pools; memory_pools_t *memory_pools;
pool_id_t pool; pool_id_t pool;
AssertFatal (pools_number <= MAX_POOLS_NUMBER, "Too many memory pools requested (%d/%d)!\n", pools_number, MAX_POOLS_NUMBER); /* Limit to a reasonable number of pools */ AssertFatal (pools_number <= MAX_POOLS_NUMBER, "Too many memory pools requested (%d/%d)!\n", pools_number, MAX_POOLS_NUMBER); /* Limit to a reasonable number of pools */
/* Allocate memory_pools */ /* Allocate memory_pools */
memory_pools = malloc (sizeof(memory_pools_t)); memory_pools = malloc (sizeof(memory_pools_t));
AssertFatal (memory_pools != NULL, "Memory pools structure allocation failed!\n"); AssertFatal (memory_pools != NULL, "Memory pools structure allocation failed!\n");
/* Initialize memory_pools */ /* Initialize memory_pools */
{ {
memory_pools->start_mark = POOLS_START_MARK; memory_pools->start_mark = POOLS_START_MARK;
memory_pools->pools_number = pools_number; memory_pools->pools_number = pools_number;
memory_pools->pools_defined = 0; memory_pools->pools_defined = 0;
/* Allocate pools */ /* Allocate pools */
memory_pools->pools = calloc (pools_number, sizeof(memory_pool_t)); memory_pools->pools = calloc (pools_number, sizeof(memory_pool_t));
AssertFatal (memory_pools->pools != NULL, "Memory pools allocation failed!\n"); AssertFatal (memory_pools->pools != NULL, "Memory pools allocation failed!\n");
...@@ -282,12 +256,10 @@ memory_pools_handle_t memory_pools_create (uint32_t pools_number) ...@@ -282,12 +256,10 @@ memory_pools_handle_t memory_pools_create (uint32_t pools_number)
memory_pools->pools[pool].start_mark = POOL_START_MARK; memory_pools->pools[pool].start_mark = POOL_START_MARK;
} }
} }
return ((memory_pools_handle_t) memory_pools); return ((memory_pools_handle_t) memory_pools);
} }
char *memory_pools_statistics(memory_pools_handle_t memory_pools_handle) char *memory_pools_statistics(memory_pools_handle_t memory_pools_handle) {
{
memory_pools_t *memory_pools; memory_pools_t *memory_pools;
pool_id_t pool; pool_id_t pool;
char *statistics; char *statistics;
...@@ -296,13 +268,10 @@ char *memory_pools_statistics(memory_pools_handle_t memory_pools_handle) ...@@ -296,13 +268,10 @@ char *memory_pools_statistics(memory_pools_handle_t memory_pools_handle)
uint32_t allocated_pools_memory = 0; uint32_t allocated_pools_memory = 0;
items_group_t *items_group; items_group_t *items_group;
uint32_t pool_items_size; uint32_t pool_items_size;
/* Recover memory_pools */ /* Recover memory_pools */
memory_pools = memory_pools_from_handler (memory_pools_handle); memory_pools = memory_pools_from_handler (memory_pools_handle);
AssertFatal (memory_pools != NULL, "Failed to retrieve memory pool for handle %p!\n", memory_pools_handle); AssertFatal (memory_pools != NULL, "Failed to retrieve memory pool for handle %p!\n", memory_pools_handle);
statistics = malloc(memory_pools->pools_defined * 200); statistics = malloc(memory_pools->pools_defined * 200);
printed_chars = sprintf (&statistics[0], "Pool: size, number, minimum, free, address space and memory used in Kbytes\n"); printed_chars = sprintf (&statistics[0], "Pool: size, number, minimum, free, address space and memory used in Kbytes\n");
for (pool = 0; pool < memory_pools->pools_defined; pool++) { for (pool = 0; pool < memory_pools->pools_defined; pool++) {
...@@ -321,32 +290,25 @@ char *memory_pools_statistics(memory_pools_handle_t memory_pools_handle) ...@@ -321,32 +290,25 @@ char *memory_pools_statistics(memory_pools_handle_t memory_pools_handle)
} }
printed_chars = sprintf (&statistics[printed_chars], "Pools memory %u Kbytes\n", allocated_pools_memory / (1024)); printed_chars = sprintf (&statistics[printed_chars], "Pools memory %u Kbytes\n", allocated_pools_memory / (1024));
return (statistics); return (statistics);
} }
int memory_pools_add_pool (memory_pools_handle_t memory_pools_handle, uint32_t pool_items_number, uint32_t pool_item_size) int memory_pools_add_pool (memory_pools_handle_t memory_pools_handle, uint32_t pool_items_number, uint32_t pool_item_size) {
{
memory_pools_t *memory_pools; memory_pools_t *memory_pools;
memory_pool_t *memory_pool; memory_pool_t *memory_pool;
pool_id_t pool; pool_id_t pool;
items_group_index_t item_index; items_group_index_t item_index;
memory_pool_item_t *memory_pool_item; memory_pool_item_t *memory_pool_item;
AssertFatal (pool_items_number <= MAX_POOL_ITEMS_NUMBER, "Too many items for a memory pool (%u/%d)!\n", pool_items_number, MAX_POOL_ITEMS_NUMBER); /* Limit to a reasonable number of items */ AssertFatal (pool_items_number <= MAX_POOL_ITEMS_NUMBER, "Too many items for a memory pool (%u/%d)!\n", pool_items_number, MAX_POOL_ITEMS_NUMBER); /* Limit to a reasonable number of items */
AssertFatal (pool_item_size <= MAX_POOL_ITEM_SIZE, "Item size is too big for memory pool items (%u/%d)!\n", pool_item_size, MAX_POOL_ITEM_SIZE); /* Limit to a reasonable item size */ AssertFatal (pool_item_size <= MAX_POOL_ITEM_SIZE, "Item size is too big for memory pool items (%u/%d)!\n", pool_item_size, MAX_POOL_ITEM_SIZE); /* Limit to a reasonable item size */
/* Recover memory_pools */ /* Recover memory_pools */
memory_pools = memory_pools_from_handler (memory_pools_handle); memory_pools = memory_pools_from_handler (memory_pools_handle);
AssertFatal (memory_pools != NULL, "Failed to retrieve memory pool for handle %p!\n", memory_pools_handle); AssertFatal (memory_pools != NULL, "Failed to retrieve memory pool for handle %p!\n", memory_pools_handle);
/* Check number of already created pools */ /* Check number of already created pools */
AssertFatal (memory_pools->pools_defined < memory_pools->pools_number, "Can not allocate more memory pool (%d)!\n", memory_pools->pools_number); AssertFatal (memory_pools->pools_defined < memory_pools->pools_number, "Can not allocate more memory pool (%d)!\n", memory_pools->pools_number);
/* Select pool */ /* Select pool */
pool = memory_pools->pools_defined; pool = memory_pools->pools_defined;
memory_pool = &memory_pools->pools[pool]; memory_pool = &memory_pools->pools[pool];
/* Initialize pool */ /* Initialize pool */
{ {
memory_pool->pool_id = pool; memory_pool->pool_id = pool;
...@@ -357,7 +319,6 @@ int memory_pools_add_pool (memory_pools_handle_t memory_pools_handle, uint32_t p ...@@ -357,7 +319,6 @@ int memory_pools_add_pool (memory_pools_handle_t memory_pools_handle, uint32_t p
memory_pool->items_group_free.minimum = pool_items_number; memory_pool->items_group_free.minimum = pool_items_number;
memory_pool->items_group_free.positions.ind.put = pool_items_number; memory_pool->items_group_free.positions.ind.put = pool_items_number;
memory_pool->items_group_free.positions.ind.get = 0; memory_pool->items_group_free.positions.ind.get = 0;
/* Allocate free indexes */ /* Allocate free indexes */
memory_pool->items_group_free.indexes = malloc(memory_pool->items_group_free.number_plus_one * sizeof(items_group_index_t)); memory_pool->items_group_free.indexes = malloc(memory_pool->items_group_free.number_plus_one * sizeof(items_group_index_t));
AssertFatal (memory_pool->items_group_free.indexes != NULL, "Memory pool indexes allocation failed!\n"); AssertFatal (memory_pool->items_group_free.indexes != NULL, "Memory pool indexes allocation failed!\n");
...@@ -369,7 +330,6 @@ int memory_pools_add_pool (memory_pools_handle_t memory_pools_handle, uint32_t p ...@@ -369,7 +330,6 @@ int memory_pools_add_pool (memory_pools_handle_t memory_pools_handle, uint32_t p
/* Last index is not allocated */ /* Last index is not allocated */
memory_pool->items_group_free.indexes[item_index] = ITEMS_GROUP_INDEX_INVALID; memory_pool->items_group_free.indexes[item_index] = ITEMS_GROUP_INDEX_INVALID;
/* Allocate items */ /* Allocate items */
memory_pool->items = calloc (pool_items_number, memory_pool->pool_item_size); memory_pool->items = calloc (pool_items_number, memory_pool->pool_item_size);
AssertFatal (memory_pool->items != NULL, "Memory pool items allocation failed!\n"); AssertFatal (memory_pool->items != NULL, "Memory pool items allocation failed!\n");
...@@ -383,20 +343,16 @@ int memory_pools_add_pool (memory_pools_handle_t memory_pools_handle, uint32_t p ...@@ -383,20 +343,16 @@ int memory_pools_add_pool (memory_pools_handle_t memory_pools_handle, uint32_t p
memory_pool_item->data[memory_pool->item_data_number] = POOL_ITEM_END_MARK; memory_pool_item->data[memory_pool->item_data_number] = POOL_ITEM_END_MARK;
} }
} }
memory_pools->pools_defined ++; memory_pools->pools_defined ++;
return (0); return (0);
} }
memory_pool_item_handle_t memory_pools_allocate (memory_pools_handle_t memory_pools_handle, uint32_t item_size, uint16_t info_0, uint16_t info_1) memory_pool_item_handle_t memory_pools_allocate (memory_pools_handle_t memory_pools_handle, uint32_t item_size, uint16_t info_0, uint16_t info_1) {
{
memory_pools_t *memory_pools; memory_pools_t *memory_pools;
memory_pool_item_t *memory_pool_item; memory_pool_item_t *memory_pool_item;
memory_pool_item_handle_t memory_pool_item_handle = NULL; memory_pool_item_handle_t memory_pool_item_handle = NULL;
pool_id_t pool; pool_id_t pool;
items_group_index_t item_index = ITEMS_GROUP_INDEX_INVALID; items_group_index_t item_index = ITEMS_GROUP_INDEX_INVALID;
/* Recover memory_pools */ /* Recover memory_pools */
memory_pools = memory_pools_from_handler (memory_pools_handle); memory_pools = memory_pools_from_handler (memory_pools_handle);
AssertError (memory_pools != NULL, {}, "Failed to retrieve memory pool for handle %p!\n", memory_pools_handle); AssertError (memory_pools != NULL, {}, "Failed to retrieve memory pool for handle %p!\n", memory_pools_handle);
...@@ -424,12 +380,10 @@ memory_pool_item_handle_t memory_pools_allocate (memory_pools_handle_t memory_po ...@@ -424,12 +380,10 @@ memory_pool_item_handle_t memory_pools_allocate (memory_pools_handle_t memory_po
/* Sanity check on item status, must be free */ /* Sanity check on item status, must be free */
AssertFatal (memory_pool_item->start.item_status == ITEM_STATUS_FREE, "Item status is not set to free (%d) in pool %u, item %d!\n", AssertFatal (memory_pool_item->start.item_status == ITEM_STATUS_FREE, "Item status is not set to free (%d) in pool %u, item %d!\n",
memory_pool_item->start.item_status, pool, item_index); memory_pool_item->start.item_status, pool, item_index);
memory_pool_item->start.item_status = ITEM_STATUS_ALLOCATED; memory_pool_item->start.item_status = ITEM_STATUS_ALLOCATED;
memory_pool_item->start.info[0] = info_0; memory_pool_item->start.info[0] = info_0;
memory_pool_item->start.info[1] = info_1; memory_pool_item->start.info[1] = info_1;
memory_pool_item_handle = memory_pool_item->data; memory_pool_item_handle = memory_pool_item->data;
MP_DEBUG(" Alloc [%2u][%6d]{%6d}, %3u %3u, %6u, %p, %p, %p\n", MP_DEBUG(" Alloc [%2u][%6d]{%6d}, %3u %3u, %6u, %p, %p, %p\n",
pool, item_index, pool, item_index,
items_group_free_items (&memory_pools->pools[pool].items_group_free), items_group_free_items (&memory_pools->pools[pool].items_group_free),
...@@ -445,8 +399,7 @@ memory_pool_item_handle_t memory_pools_allocate (memory_pools_handle_t memory_po ...@@ -445,8 +399,7 @@ memory_pool_item_handle_t memory_pools_allocate (memory_pools_handle_t memory_po
return memory_pool_item_handle; return memory_pool_item_handle;
} }
int memory_pools_free (memory_pools_handle_t memory_pools_handle, memory_pool_item_handle_t memory_pool_item_handle, uint16_t info_0) int memory_pools_free (memory_pools_handle_t memory_pools_handle, memory_pool_item_handle_t memory_pool_item_handle, uint16_t info_0) {
{
memory_pools_t *memory_pools; memory_pools_t *memory_pools;
memory_pool_item_t *memory_pool_item; memory_pool_item_t *memory_pool_item;
pool_id_t pool; pool_id_t pool;
...@@ -455,36 +408,29 @@ int memory_pools_free (memory_pools_handle_t memory_pools_handle, memory_pool_it ...@@ -455,36 +408,29 @@ int memory_pools_free (memory_pools_handle_t memory_pools_handle, memory_pool_it
uint32_t pool_item_size; uint32_t pool_item_size;
uint16_t info_1; uint16_t info_1;
int result; int result;
/* Recover memory_pools */ /* Recover memory_pools */
memory_pools = memory_pools_from_handler (memory_pools_handle); memory_pools = memory_pools_from_handler (memory_pools_handle);
AssertError (memory_pools != NULL, return (EXIT_FAILURE), "Failed to retrieve memory pools for handle %p!\n", memory_pools_handle); AssertError (memory_pools != NULL, return (EXIT_FAILURE), "Failed to retrieve memory pools for handle %p!\n", memory_pools_handle);
/* Recover memory pool item */ /* Recover memory pool item */
memory_pool_item = memory_pool_item_from_handler (memory_pool_item_handle); memory_pool_item = memory_pool_item_from_handler (memory_pool_item_handle);
AssertError (memory_pool_item != NULL, return (EXIT_FAILURE), "Failed to retrieve memory pool item for handle %p!\n", memory_pool_item_handle); AssertError (memory_pool_item != NULL, return (EXIT_FAILURE), "Failed to retrieve memory pool item for handle %p!\n", memory_pool_item_handle);
info_1 = memory_pool_item->start.info[1]; info_1 = memory_pool_item->start.info[1];
/* Recover pool index */ /* Recover pool index */
pool = memory_pool_item->start.pool_id; pool = memory_pool_item->start.pool_id;
AssertFatal (pool < memory_pools->pools_defined, "Pool index is invalid (%u/%u)!\n", pool, memory_pools->pools_defined); AssertFatal (pool < memory_pools->pools_defined, "Pool index is invalid (%u/%u)!\n", pool, memory_pools->pools_defined);
item_size = memory_pools->pools[pool].item_data_number; item_size = memory_pools->pools[pool].item_data_number;
pool_item_size = memory_pools->pools[pool].pool_item_size; pool_item_size = memory_pools->pools[pool].pool_item_size;
item_index = (((void *) memory_pool_item) - ((void *) memory_pools->pools[pool].items)) / pool_item_size; item_index = (((void *) memory_pool_item) - ((void *) memory_pools->pools[pool].items)) / pool_item_size;
MP_DEBUG(" Free [%2u][%6d]{%6d}, %3u %3u, %p, %p, %p, %u\n", MP_DEBUG(" Free [%2u][%6d]{%6d}, %3u %3u, %p, %p, %p, %u\n",
pool, item_index, pool, item_index,
items_group_free_items (&memory_pools->pools[pool].items_group_free), items_group_free_items (&memory_pools->pools[pool].items_group_free),
memory_pool_item->start.info[0], info_1, memory_pool_item->start.info[0], info_1,
memory_pool_item_handle, memory_pool_item, memory_pool_item_handle, memory_pool_item,
memory_pools->pools[pool].items, ((uint32_t) (item_size * sizeof(memory_pool_data_t)))); memory_pools->pools[pool].items, ((uint32_t) (item_size * sizeof(memory_pool_data_t))));
/* Sanity check on calculated item index */ /* Sanity check on calculated item index */
AssertFatal (memory_pool_item == memory_pool_item_from_index(&memory_pools->pools[pool], item_index), AssertFatal (memory_pool_item == memory_pool_item_from_index(&memory_pools->pools[pool], item_index),
"Incorrect memory pool item address (%p, %p) for pool %u, item %d!\n", "Incorrect memory pool item address (%p, %p) for pool %u, item %d!\n",
memory_pool_item, memory_pool_item_from_index(&memory_pools->pools[pool], item_index), pool, item_index); memory_pool_item,(void *)memory_pool_item_from_index(&memory_pools->pools[pool], item_index), pool, item_index);
/* Sanity check on end marker, must still be present (no write overflow) */ /* Sanity check on end marker, must still be present (no write overflow) */
AssertFatal (memory_pool_item->data[item_size] == POOL_ITEM_END_MARK, AssertFatal (memory_pool_item->data[item_size] == POOL_ITEM_END_MARK,
"Memory pool item is corrupted, end mark is not present for pool %u, item %d!\n", pool, item_index); "Memory pool item is corrupted, end mark is not present for pool %u, item %d!\n", pool, item_index);
...@@ -492,31 +438,23 @@ int memory_pools_free (memory_pools_handle_t memory_pools_handle, memory_pool_it ...@@ -492,31 +438,23 @@ int memory_pools_free (memory_pools_handle_t memory_pools_handle, memory_pool_it
AssertFatal (memory_pool_item->start.item_status == ITEM_STATUS_ALLOCATED, AssertFatal (memory_pool_item->start.item_status == ITEM_STATUS_ALLOCATED,
"Trying to free a non allocated (%x) memory pool item (pool %u, item %d)!\n", "Trying to free a non allocated (%x) memory pool item (pool %u, item %d)!\n",
memory_pool_item->start.item_status, pool, item_index); memory_pool_item->start.item_status, pool, item_index);
memory_pool_item->start.item_status = ITEM_STATUS_FREE; memory_pool_item->start.item_status = ITEM_STATUS_FREE;
result = items_group_put_free_item(&memory_pools->pools[pool].items_group_free, item_index); result = items_group_put_free_item(&memory_pools->pools[pool].items_group_free, item_index);
AssertError (result == EXIT_SUCCESS, {}, "Failed to free memory pool item (pool %u, item %d)!\n", pool, item_index); AssertError (result == EXIT_SUCCESS, {}, "Failed to free memory pool item (pool %u, item %d)!\n", pool, item_index);
return (result); return (result);
} }
void memory_pools_set_info (memory_pools_handle_t memory_pools_handle, memory_pool_item_handle_t memory_pool_item_handle, int index, uint16_t info) void memory_pools_set_info (memory_pools_handle_t memory_pools_handle, memory_pool_item_handle_t memory_pool_item_handle, int index, uint16_t info) {
{
memory_pools_t *memory_pools; memory_pools_t *memory_pools;
memory_pool_item_t *memory_pool_item; memory_pool_item_t *memory_pool_item;
pool_id_t pool; pool_id_t pool;
items_group_index_t item_index; items_group_index_t item_index;
uint32_t item_size; uint32_t item_size;
uint32_t pool_item_size; uint32_t pool_item_size;
AssertFatal (index < MEMORY_POOL_ITEM_INFO_NUMBER, "Incorrect info index (%d/%d)!\n", index, MEMORY_POOL_ITEM_INFO_NUMBER); AssertFatal (index < MEMORY_POOL_ITEM_INFO_NUMBER, "Incorrect info index (%d/%d)!\n", index, MEMORY_POOL_ITEM_INFO_NUMBER);
/* Recover memory pool item */ /* Recover memory pool item */
memory_pool_item = memory_pool_item_from_handler (memory_pool_item_handle); memory_pool_item = memory_pool_item_from_handler (memory_pool_item_handle);
AssertFatal (memory_pool_item != NULL, "Failed to retrieve memory pool item for handle %p!\n", memory_pool_item_handle); AssertFatal (memory_pool_item != NULL, "Failed to retrieve memory pool item for handle %p!\n", memory_pool_item_handle);
/* Set info[1] */ /* Set info[1] */
memory_pool_item->start.info[index] = info; memory_pool_item->start.info[index] = info;
...@@ -525,26 +463,22 @@ void memory_pools_set_info (memory_pools_handle_t memory_pools_handle, memory_po ...@@ -525,26 +463,22 @@ void memory_pools_set_info (memory_pools_handle_t memory_pools_handle, memory_po
/* Recover memory_pools */ /* Recover memory_pools */
memory_pools = memory_pools_from_handler (memory_pools_handle); memory_pools = memory_pools_from_handler (memory_pools_handle);
AssertFatal (memory_pools != NULL, "Failed to retrieve memory pool for handle %p!\n", memory_pools_handle); AssertFatal (memory_pools != NULL, "Failed to retrieve memory pool for handle %p!\n", memory_pools_handle);
/* Recover pool index */ /* Recover pool index */
pool = memory_pool_item->start.pool_id; pool = memory_pool_item->start.pool_id;
AssertFatal (pool < memory_pools->pools_defined, "Pool index is invalid (%u/%u)!\n", pool, memory_pools->pools_defined); AssertFatal (pool < memory_pools->pools_defined, "Pool index is invalid (%u/%u)!\n", pool, memory_pools->pools_defined);
item_size = memory_pools->pools[pool].item_data_number; item_size = memory_pools->pools[pool].item_data_number;
pool_item_size = memory_pools->pools[pool].pool_item_size; pool_item_size = memory_pools->pools[pool].pool_item_size;
item_index = (((void *) memory_pool_item) - ((void *) memory_pools->pools[pool].items)) / pool_item_size; item_index = (((void *) memory_pool_item) - ((void *) memory_pools->pools[pool].items)) / pool_item_size;
MP_DEBUG(" Info [%2u][%6d]{%6d}, %3u %3u, %p, %p, %p, %u\n", MP_DEBUG(" Info [%2u][%6d]{%6d}, %3u %3u, %p, %p, %p, %u\n",
pool, item_index, pool, item_index,
items_group_free_items (&memory_pools->pools[pool].items_group_free), items_group_free_items (&memory_pools->pools[pool].items_group_free),
memory_pool_item->start.info[0], memory_pool_item->start.info[1], memory_pool_item->start.info[0], memory_pool_item->start.info[1],
memory_pool_item_handle, memory_pool_item, memory_pool_item_handle, memory_pool_item,
memory_pools->pools[pool].items, ((uint32_t) (item_size * sizeof(memory_pool_data_t)))); memory_pools->pools[pool].items, ((uint32_t) (item_size * sizeof(memory_pool_data_t))));
/* Sanity check on calculated item index */ /* Sanity check on calculated item index */
AssertFatal (memory_pool_item == memory_pool_item_from_index(&memory_pools->pools[pool], item_index), AssertFatal (memory_pool_item == memory_pool_item_from_index(&memory_pools->pools[pool], item_index),
"Incorrect memory pool item address (%p, %p) for pool %u, item %d!\n", "Incorrect memory pool item address (%p, %p) for pool %u, item %d!\n",
memory_pool_item, memory_pool_item_from_index(&memory_pools->pools[pool], item_index), pool, item_index); memory_pool_item, (void *)memory_pool_item_from_index(&memory_pools->pools[pool], item_index), pool, item_index);
/* Sanity check on end marker, must still be present (no write overflow) */ /* Sanity check on end marker, must still be present (no write overflow) */
AssertFatal (memory_pool_item->data[item_size] == POOL_ITEM_END_MARK, AssertFatal (memory_pool_item->data[item_size] == POOL_ITEM_END_MARK,
"Memory pool item is corrupted, end mark is not present for pool %u, item %d!\n", pool, item_index); "Memory pool item is corrupted, end mark is not present for pool %u, item %d!\n", pool, item_index);
......
...@@ -77,17 +77,17 @@ paramdef_t telnetoptions[] = { ...@@ -77,17 +77,17 @@ paramdef_t telnetoptions[] = {
/* configuration parameters for telnet utility */ /* configuration parameters for telnet utility */
/* optname helpstr paramflags XXXptr defXXXval type numelt */ /* optname helpstr paramflags XXXptr defXXXval type numelt */
/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
{"listenaddr", "<listen ip address>\n", 0, uptr:&telnetparams.listenaddr, defstrval:"0.0.0.0", TYPE_IPV4ADDR, 0 }, {"listenaddr", "<listen ip address>", 0, uptr:&telnetparams.listenaddr, defstrval:"0.0.0.0", TYPE_IPV4ADDR, 0 },
{"listenport", "<local port>\n", 0, uptr:&(telnetparams.listenport), defuintval:9090, TYPE_UINT, 0 }, {"listenport", "<local port>", 0, uptr:&(telnetparams.listenport), defuintval:9090, TYPE_UINT, 0 },
{"priority", "<scheduling policy (0-99)\n", 0, iptr:&telnetparams.priority, defuintval:0, TYPE_INT, 0 }, {"priority", "<scheduling policy (0-99)", 0, iptr:&telnetparams.priority, defuintval:0, TYPE_INT, 0 },
{"debug", "<debug level>\n", 0, uptr:NULL, defuintval:0, TYPE_UINT, 0 }, {"debug", "<debug level>", 0, uptr:NULL, defuintval:0, TYPE_UINT, 0 },
{"loopcount", "<loop command iterations>\n", 0, uptr:&(telnetparams.loopcount), defuintval:10, TYPE_UINT, 0 }, {"loopcount", "<loop command iterations>", 0, uptr:&(telnetparams.loopcount), defuintval:10, TYPE_UINT, 0 },
{"loopdelay", "<loop command delay (ms)>\n", 0, uptr:&(telnetparams.loopdelay), defuintval:5000, TYPE_UINT, 0 }, {"loopdelay", "<loop command delay (ms)>", 0, uptr:&(telnetparams.loopdelay), defuintval:5000, TYPE_UINT, 0 },
{"histfile", "<history file name>\n", PARAMFLAG_NOFREE, strptr:&(telnetparams.histfile), defstrval:"oaitelnet.history", TYPE_STRING, 0 }, {"histfile", "<history file name>", PARAMFLAG_NOFREE, strptr:&(telnetparams.histfile), defstrval:"oaitelnet.history", TYPE_STRING, 0 },
{"histsize", "<history sizes>\n", 0, iptr:&(telnetparams.histsize), defuintval:50, TYPE_INT, 0 }, {"histsize", "<history sizes>", 0, iptr:&(telnetparams.histsize), defuintval:50, TYPE_INT, 0 },
{"phypbsize", "<phy dump buff size (bytes)>\n",0, uptr:&(telnetparams.phyprntbuff_size),defuintval:65000, TYPE_UINT, 0 }, {"phypbsize", "<phy dump buff size (bytes)>",0, uptr:&(telnetparams.phyprntbuff_size),defuintval:65000, TYPE_UINT, 0 },
{"staticmod", "<static modules selection>\n", 0, strlistptr:NULL, defstrlistval:telnet_defstatmod,TYPE_STRINGLIST,(sizeof(telnet_defstatmod)/sizeof(char *))}, {"staticmod", "<static modules selection>", 0, strlistptr:NULL, defstrlistval:telnet_defstatmod,TYPE_STRINGLIST,(sizeof(telnet_defstatmod)/sizeof(char *))},
{"shrmod", "<dynamic modules selection>\n", 0, strlistptr:NULL, defstrlistval:NULL,TYPE_STRINGLIST,0 } {"shrmod", "<dynamic modules selection>", 0, strlistptr:NULL, defstrlistval:NULL,TYPE_STRINGLIST,0 }
}; };
int get_phybsize(void) { int get_phybsize(void) {
...@@ -355,7 +355,8 @@ int setgetvar(int moduleindex,char getorset,char *params) { ...@@ -355,7 +355,8 @@ int setgetvar(int moduleindex,char getorset,char *params) {
char varname[TELNET_CMD_MAXSIZE]; char varname[TELNET_CMD_MAXSIZE];
char *varval=NULL; char *varval=NULL;
memset(varname,0,sizeof(varname)); memset(varname,0,sizeof(varname));
n = sscanf(params,"%s %ms",varname,&varval); n = sscanf(params,"%19s %ms",varname,&varval);
for ( i=0 ; telnetparams.CmdParsers[moduleindex].var[i].varvalptr != NULL ; i++) { for ( i=0 ; telnetparams.CmdParsers[moduleindex].var[i].varvalptr != NULL ; i++) {
if ( strncasecmp(telnetparams.CmdParsers[moduleindex].var[i].varname,varname,strlen(telnetparams.CmdParsers[moduleindex].var[i].varname)) == 0) { if ( strncasecmp(telnetparams.CmdParsers[moduleindex].var[i].varname,varname,strlen(telnetparams.CmdParsers[moduleindex].var[i].varname)) == 0) {
...@@ -475,7 +476,8 @@ int process_command(char *buf) { ...@@ -475,7 +476,8 @@ int process_command(char *buf) {
memset(cmdb,0,sizeof(cmdb)); memset(cmdb,0,sizeof(cmdb));
bufbck=strdup(buf); bufbck=strdup(buf);
rt=CMDSTATUS_NOTFOUND; rt=CMDSTATUS_NOTFOUND;
j = sscanf(buf,"%9s %9s %[^\t\n]",modulename,cmd,cmdb); j = sscanf(buf,"%9s %9s %2000[^\t\n]",modulename,cmd,cmdb);
if (telnetparams.telnetdbg > 0) if (telnetparams.telnetdbg > 0)
printf("process_command: %i words, module=%s cmd=%s, parameters= %s\n",j,modulename,cmd,cmdb); printf("process_command: %i words, module=%s cmd=%s, parameters= %s\n",j,modulename,cmd,cmdb);
......
...@@ -39,88 +39,74 @@ ...@@ -39,88 +39,74 @@
#define TELNETSRV_PHYCMD_MAIN #define TELNETSRV_PHYCMD_MAIN
#include "telnetsrv_phycmd.h" #include "telnetsrv_phycmd.h"
char *prnbuff; char *prnbuff;
extern int dump_eNB_stats(PHY_VARS_eNB *eNB, char* buffer, int length); extern int dump_eNB_l2_stats(char *buffer, int length);
void init_phytelnet(void) void init_phytelnet(void) {
{ prnbuff=malloc(get_phybsize() );
prnbuff=malloc(get_phybsize() );
if (prnbuff == NULL) if (prnbuff == NULL) {
{
fprintf(stderr,"Error %s on malloc in init_phytelnet()\n",strerror(errno)); fprintf(stderr,"Error %s on malloc in init_phytelnet()\n",strerror(errno));
} }
} }
void display_uestatshead( telnet_printfunc_t prnt) void display_uestatshead( telnet_printfunc_t prnt) {
{ prnt("cc ue rnti Dmcs Umcs tao tau Dbr Dtb \n");
prnt("cc ue rnti Dmcs Umcs tao tau Dbr Dtb \n");
} }
void dump_uestats(int debug, telnet_printfunc_t prnt, uint8_t prntflag) void dump_uestats(int debug, telnet_printfunc_t prnt, uint8_t prntflag) {
{ int p;
prnbuff=malloc(20480);
int p; p=dump_eNB_l2_stats( prnbuff, 20480);
p=dump_eNB_l2_stats( prnbuff, 0);
if(prntflag>=1) if(prntflag>=1)
prnt("%s\n",prnbuff); prnt("%s\n",prnbuff);
if(debug>=1) if(debug>=1)
prnt("%i bytes printed\n",p); prnt("%i bytes printed\n",p);
free(prnbuff);
} }
void display_uestats(int debug, telnet_printfunc_t prnt, int ue) void display_uestats(int debug, telnet_printfunc_t prnt, int ue) {
{ for (int cc=0; cc<1 ; cc++) {
for (int cc=0; cc<1 ; cc++)
{
} }
} }
void display_phycounters(char *buf, int debug, telnet_printfunc_t prnt) void display_phycounters(char *buf, int debug, telnet_printfunc_t prnt) {
{
prnt(" DLSCH kb DLSCH kb/s\n"); prnt(" DLSCH kb DLSCH kb/s\n");
dump_uestats(debug, prnt,0); dump_uestats(debug, prnt,0);
} }
int dump_phyvars(char *buf, int debug, telnet_printfunc_t prnt) int dump_phyvars(char *buf, int debug, telnet_printfunc_t prnt) {
{
if (debug > 0) if (debug > 0)
prnt("phy interface module received %s\n",buf); prnt("phy interface module received %s\n",buf);
if (strcasestr(buf,"phycnt") != NULL)
{ if (strcasestr(buf,"phycnt") != NULL) {
display_phycounters(buf, debug, prnt); display_phycounters(buf, debug, prnt);
} }
if (strcasestr(buf,"uestat") != NULL)
{ if (strcasestr(buf,"uestat") != NULL) {
char *cptr=strcasestr(buf+sizeof("uestat"),"UE"); char *cptr=strcasestr(buf+sizeof("uestat"),"UE");
display_uestatshead(prnt); display_uestatshead(prnt);
if (cptr != NULL)
{ if (cptr != NULL) {
int ueidx = strtol( cptr+sizeof("UE"), NULL, 10); int ueidx = strtol( cptr+sizeof("UE"), NULL, 10);
if (ueidx < NUMBER_OF_UE_MAX && ueidx >= 0)
{ if (ueidx < NUMBER_OF_UE_MAX && ueidx >= 0) {
display_uestats(debug, prnt,ueidx); display_uestats(debug, prnt,ueidx);
} }
} /* if cptr != NULL */ } /* if cptr != NULL */
else else {
{ for (int ue=0; ue<NUMBER_OF_UE_MAX ; ue++) {
for (int ue=0; ue<NUMBER_OF_UE_MAX ; ue++)
{
display_uestats(debug, prnt,ue); display_uestats(debug, prnt,ue);
} }
} /* else cptr != NULL */ } /* else cptr != NULL */
} /* uestat */ } /* uestat */
if (strcasestr(buf,"uedump") != NULL)
{ if (strcasestr(buf,"uedump") != NULL) {
dump_uestats(debug, prnt,1); dump_uestats(debug, prnt,1);
} }
return 0; return 0;
} }
...@@ -134,9 +120,7 @@ telnetshell_cmddef_t phy_cmdarray[] = { ...@@ -134,9 +120,7 @@ telnetshell_cmddef_t phy_cmdarray[] = {
/*-------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------*/
void add_phy_cmds(void) void add_phy_cmds(void) {
{
init_phytelnet(); init_phytelnet();
add_telnetcmd("phy", phy_vardef, phy_cmdarray); add_telnetcmd("phy", phy_vardef, phy_cmdarray);
} }
...@@ -61,7 +61,7 @@ typedef struct { ...@@ -61,7 +61,7 @@ typedef struct {
char local_addr[80]; char local_addr[80];
int local_port; int local_port;
char* remote_addr; char *remote_addr;
int remote_port; int remote_port;
uint8_t duplex_mode; uint8_t duplex_mode;
...@@ -127,12 +127,12 @@ typedef struct mac mac_t; ...@@ -127,12 +127,12 @@ typedef struct mac mac_t;
typedef struct mac { typedef struct mac {
void* user_data; void *user_data;
void (*dl_config_req)(mac_t* mac, nfapi_dl_config_request_t* req); void (*dl_config_req)(mac_t *mac, nfapi_dl_config_request_t *req);
void (*ul_config_req)(mac_t* mac, nfapi_ul_config_request_t* req); void (*ul_config_req)(mac_t *mac, nfapi_ul_config_request_t *req);
void (*hi_dci0_req)(mac_t* mac, nfapi_hi_dci0_request_t* req); void (*hi_dci0_req)(mac_t *mac, nfapi_hi_dci0_request_t *req);
void (*tx_req)(mac_t* mac, nfapi_tx_request_t* req); void (*tx_req)(mac_t *mac, nfapi_tx_request_t *req);
} mac_t; } mac_t;
typedef struct { typedef struct {
...@@ -151,9 +151,9 @@ typedef struct { ...@@ -151,9 +151,9 @@ typedef struct {
uint8_t thread_started; uint8_t thread_started;
nfapi_vnf_p7_config_t* config; nfapi_vnf_p7_config_t *config;
mac_t* mac; mac_t *mac;
} vnf_p7_info; } vnf_p7_info;
...@@ -165,24 +165,27 @@ typedef struct { ...@@ -165,24 +165,27 @@ typedef struct {
} vnf_info; } vnf_info;
int vnf_pack_vendor_extension_tlv(void* ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* codec) { int vnf_pack_vendor_extension_tlv(void *ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *codec) {
//NFAPI_TRACE(NFAPI_TRACE_INFO, "vnf_pack_vendor_extension_tlv\n"); //NFAPI_TRACE(NFAPI_TRACE_INFO, "vnf_pack_vendor_extension_tlv\n");
nfapi_tl_t* tlv = (nfapi_tl_t*)ve; nfapi_tl_t *tlv = (nfapi_tl_t *)ve;
switch(tlv->tag) { switch(tlv->tag) {
case VENDOR_EXT_TLV_2_TAG: case VENDOR_EXT_TLV_2_TAG: {
{
//NFAPI_TRACE(NFAPI_TRACE_INFO, "Packing VENDOR_EXT_TLV_2\n"); //NFAPI_TRACE(NFAPI_TRACE_INFO, "Packing VENDOR_EXT_TLV_2\n");
vendor_ext_tlv_2* ve = (vendor_ext_tlv_2*)tlv; vendor_ext_tlv_2 *ve = (vendor_ext_tlv_2 *)tlv;
if(!push32(ve->dummy, ppWritePackedMsg, end)) if(!push32(ve->dummy, ppWritePackedMsg, end))
return 0; return 0;
return 1; return 1;
} }
break; break;
} }
return -1; return -1;
} }
int vnf_unpack_vendor_extension_tlv(nfapi_tl_t* tl, uint8_t **ppReadPackedMessage, uint8_t *end, void** ve, nfapi_p4_p5_codec_config_t* codec) { int vnf_unpack_vendor_extension_tlv(nfapi_tl_t *tl, uint8_t **ppReadPackedMessage, uint8_t *end, void **ve, nfapi_p4_p5_codec_config_t *codec) {
return -1; return -1;
} }
...@@ -192,17 +195,14 @@ extern void init_eNB_afterRU(void); ...@@ -192,17 +195,14 @@ extern void init_eNB_afterRU(void);
extern uint16_t sf_ahead; extern uint16_t sf_ahead;
void oai_create_enb(void) { void oai_create_enb(void) {
int bodge_counter=0; int bodge_counter=0;
PHY_VARS_eNB *eNB = RC.eNB[0][0]; PHY_VARS_eNB *eNB = RC.eNB[0][0];
printf("[VNF] RC.eNB[0][0]. Mod_id:%d CC_id:%d nb_CC[0]:%d abstraction_flag:%d single_thread_flag:%d if_inst:%p\n", eNB->Mod_id, eNB->CC_id, RC.nb_CC[0], eNB->abstraction_flag,
printf("[VNF] RC.eNB[0][0]. Mod_id:%d CC_id:%d nb_CC[0]:%d abstraction_flag:%d single_thread_flag:%d if_inst:%p\n", eNB->Mod_id, eNB->CC_id, RC.nb_CC[0], eNB->abstraction_flag, eNB->single_thread_flag, eNB->if_inst); eNB->single_thread_flag, eNB->if_inst);
eNB->Mod_id = bodge_counter; eNB->Mod_id = bodge_counter;
eNB->CC_id = bodge_counter; eNB->CC_id = bodge_counter;
eNB->abstraction_flag = 0; eNB->abstraction_flag = 0;
eNB->single_thread_flag = 0;//single_thread_flag; eNB->single_thread_flag = 0;//single_thread_flag;
RC.nb_CC[bodge_counter] = 1; RC.nb_CC[bodge_counter] = 1;
if (eNB->if_inst==0) { if (eNB->if_inst==0) {
...@@ -213,7 +213,6 @@ void oai_create_enb(void) { ...@@ -213,7 +213,6 @@ void oai_create_enb(void) {
// that will result in eNB->configured being set to TRUE. // that will result in eNB->configured being set to TRUE.
// See we need to wait for that to happen otherwise the NFAPI message exchanges won't contain the right parameter values // See we need to wait for that to happen otherwise the NFAPI message exchanges won't contain the right parameter values
if (RC.eNB[0][0]->if_inst==0 || RC.eNB[0][0]->if_inst->PHY_config_req==0 || RC.eNB[0][0]->if_inst->schedule_response==0) { if (RC.eNB[0][0]->if_inst==0 || RC.eNB[0][0]->if_inst->PHY_config_req==0 || RC.eNB[0][0]->if_inst->schedule_response==0) {
printf("RC.eNB[0][0]->if_inst->PHY_config_req is not installed - install it\n"); printf("RC.eNB[0][0]->if_inst->PHY_config_req is not installed - install it\n");
install_schedule_handlers(RC.eNB[0][0]->if_inst); install_schedule_handlers(RC.eNB[0][0]->if_inst);
} }
...@@ -227,17 +226,13 @@ void oai_create_enb(void) { ...@@ -227,17 +226,13 @@ void oai_create_enb(void) {
} }
void oai_enb_init(void) { void oai_enb_init(void) {
printf("%s() About to call init_eNB_afterRU()\n", __FUNCTION__); printf("%s() About to call init_eNB_afterRU()\n", __FUNCTION__);
init_eNB_afterRU(); init_eNB_afterRU();
} }
int pnf_connection_indication_cb(nfapi_vnf_config_t* config, int p5_idx) { int pnf_connection_indication_cb(nfapi_vnf_config_t *config, int p5_idx) {
printf("[VNF] pnf connection indication idx:%d\n", p5_idx); printf("[VNF] pnf connection indication idx:%d\n", p5_idx);
oai_create_enb(); oai_create_enb();
nfapi_pnf_param_request_t req; nfapi_pnf_param_request_t req;
memset(&req, 0, sizeof(req)); memset(&req, 0, sizeof(req));
req.header.message_id = NFAPI_PNF_PARAM_REQUEST; req.header.message_id = NFAPI_PNF_PARAM_REQUEST;
...@@ -245,40 +240,29 @@ int pnf_connection_indication_cb(nfapi_vnf_config_t* config, int p5_idx) { ...@@ -245,40 +240,29 @@ int pnf_connection_indication_cb(nfapi_vnf_config_t* config, int p5_idx) {
return 0; return 0;
} }
int pnf_disconnection_indication_cb(nfapi_vnf_config_t* config, int p5_idx) { int pnf_disconnection_indication_cb(nfapi_vnf_config_t *config, int p5_idx) {
printf("[VNF] pnf disconnection indication idx:%d\n", p5_idx); printf("[VNF] pnf disconnection indication idx:%d\n", p5_idx);
vnf_info *vnf = (vnf_info *)(config->user_data);
vnf_info* vnf = (vnf_info*)(config->user_data);
pnf_info *pnf = vnf->pnfs; pnf_info *pnf = vnf->pnfs;
phy_info *phy = pnf->phys; phy_info *phy = pnf->phys;
vnf_p7_info *p7_vnf = vnf->p7_vnfs;
vnf_p7_info* p7_vnf = vnf->p7_vnfs;
nfapi_vnf_p7_del_pnf((p7_vnf->config), phy->id); nfapi_vnf_p7_del_pnf((p7_vnf->config), phy->id);
return 0; return 0;
} }
int pnf_param_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_param_response_t* resp) { int pnf_param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_pnf_param_response_t *resp) {
printf("[VNF] pnf param response idx:%d error:%d\n", p5_idx, resp->error_code); printf("[VNF] pnf param response idx:%d error:%d\n", p5_idx, resp->error_code);
vnf_info *vnf = (vnf_info *)(config->user_data);
vnf_info* vnf = (vnf_info*)(config->user_data);
pnf_info *pnf = vnf->pnfs; pnf_info *pnf = vnf->pnfs;
for(int i = 0; i < resp->pnf_phy.number_of_phys; ++i) for(int i = 0; i < resp->pnf_phy.number_of_phys; ++i) {
{
phy_info phy; phy_info phy;
memset(&phy,0,sizeof(phy)); memset(&phy,0,sizeof(phy));
phy.index = resp->pnf_phy.phy[i].phy_config_index; phy.index = resp->pnf_phy.phy[i].phy_config_index;
printf("[VNF] (PHY:%d) phy_config_idx:%d\n", i, resp->pnf_phy.phy[i].phy_config_index); printf("[VNF] (PHY:%d) phy_config_idx:%d\n", i, resp->pnf_phy.phy[i].phy_config_index);
nfapi_vnf_allocate_phy(config, p5_idx, &(phy.id)); nfapi_vnf_allocate_phy(config, p5_idx, &(phy.id));
for(int j = 0; j < resp->pnf_phy.phy[i].number_of_rfs; ++j) for(int j = 0; j < resp->pnf_phy.phy[i].number_of_rfs; ++j) {
{
printf("[VNF] (PHY:%d) (RF%d) %d\n", i, j, resp->pnf_phy.phy[i].rf_config[j].rf_config_index); printf("[VNF] (PHY:%d) (RF%d) %d\n", i, j, resp->pnf_phy.phy[i].rf_config[j].rf_config_index);
phy.rfs[0] = resp->pnf_phy.phy[i].rf_config[j].rf_config_index; phy.rfs[0] = resp->pnf_phy.phy[i].rf_config[j].rf_config_index;
} }
...@@ -290,16 +274,13 @@ int pnf_param_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_param_re ...@@ -290,16 +274,13 @@ int pnf_param_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_param_re
rf_info rf; rf_info rf;
memset(&rf,0,sizeof(rf)); memset(&rf,0,sizeof(rf));
rf.index = resp->pnf_rf.rf[i].rf_config_index; rf.index = resp->pnf_rf.rf[i].rf_config_index;
printf("[VNF] (RF:%d) rf_config_idx:%d\n", i, resp->pnf_rf.rf[i].rf_config_index); printf("[VNF] (RF:%d) rf_config_idx:%d\n", i, resp->pnf_rf.rf[i].rf_config_index);
pnf->rfs[0] = rf; pnf->rfs[0] = rf;
} }
nfapi_pnf_config_request_t req; nfapi_pnf_config_request_t req;
memset(&req, 0, sizeof(req)); memset(&req, 0, sizeof(req));
req.header.message_id = NFAPI_PNF_CONFIG_REQUEST; req.header.message_id = NFAPI_PNF_CONFIG_REQUEST;
req.pnf_phy_rf_config.tl.tag = NFAPI_PNF_PHY_RF_TAG; req.pnf_phy_rf_config.tl.tag = NFAPI_PNF_PHY_RF_TAG;
req.pnf_phy_rf_config.number_phy_rf_config_info = 2; // DJP pnf.phys.size(); req.pnf_phy_rf_config.number_phy_rf_config_info = 2; // DJP pnf.phys.size();
printf("DJP:Hard coded num phy rf to 2\n"); printf("DJP:Hard coded num phy rf to 2\n");
...@@ -311,12 +292,10 @@ int pnf_param_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_param_re ...@@ -311,12 +292,10 @@ int pnf_param_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_param_re
} }
nfapi_vnf_pnf_config_req(config, p5_idx, &req); nfapi_vnf_pnf_config_req(config, p5_idx, &req);
return 0; return 0;
} }
int pnf_config_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_config_response_t* resp) { int pnf_config_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_pnf_config_response_t *resp) {
printf("[VNF] pnf config response idx:%d resp[header[phy_id:%u message_id:%02x message_length:%u]]\n", p5_idx, resp->header.phy_id, resp->header.message_id, resp->header.message_length); printf("[VNF] pnf config response idx:%d resp[header[phy_id:%u message_id:%02x message_length:%u]]\n", p5_idx, resp->header.phy_id, resp->header.message_id, resp->header.message_length);
if(1) { if(1) {
...@@ -329,7 +308,6 @@ int pnf_config_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_config_ ...@@ -329,7 +308,6 @@ int pnf_config_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_config_
// Rather than send the pnf_start_request we will demonstrate // Rather than send the pnf_start_request we will demonstrate
// sending a vendor extention message. The start request will be // sending a vendor extention message. The start request will be
// send when the vendor extension response is received // send when the vendor extension response is received
//vnf_info* vnf = (vnf_info*)(config->user_data); //vnf_info* vnf = (vnf_info*)(config->user_data);
vendor_ext_p5_req req; vendor_ext_p5_req req;
memset(&req, 0, sizeof(req)); memset(&req, 0, sizeof(req));
...@@ -338,22 +316,17 @@ int pnf_config_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_config_ ...@@ -338,22 +316,17 @@ int pnf_config_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_config_
req.dummy2 = 1977; req.dummy2 = 1977;
nfapi_vnf_vendor_extension(config, p5_idx, &req.header); nfapi_vnf_vendor_extension(config, p5_idx, &req.header);
} }
return 0; return 0;
} }
int wake_eNB_rxtx(PHY_VARS_eNB *eNB, uint16_t sfn, uint16_t sf) { int wake_eNB_rxtx(PHY_VARS_eNB *eNB, uint16_t sfn, uint16_t sf) {
L1_proc_t *proc=&eNB->proc; L1_proc_t *proc=&eNB->proc;
L1_rxtx_proc_t *L1_proc= (sf&1)? &proc->L1_proc : &proc->L1_proc_tx; L1_rxtx_proc_t *L1_proc= (sf&1)? &proc->L1_proc : &proc->L1_proc_tx;
LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms;
//printf("%s(eNB:%p, sfn:%d, sf:%d)\n", __FUNCTION__, eNB, sfn, sf); //printf("%s(eNB:%p, sfn:%d, sf:%d)\n", __FUNCTION__, eNB, sfn, sf);
//int i; //int i;
struct timespec wait; struct timespec wait;
wait.tv_sec=0; wait.tv_sec=0;
wait.tv_nsec=5000000L; wait.tv_nsec=5000000L;
...@@ -368,10 +341,8 @@ int wake_eNB_rxtx(PHY_VARS_eNB *eNB, uint16_t sfn, uint16_t sf) { ...@@ -368,10 +341,8 @@ int wake_eNB_rxtx(PHY_VARS_eNB *eNB, uint16_t sfn, uint16_t sf) {
{ {
static uint16_t old_sf = 0; static uint16_t old_sf = 0;
static uint16_t old_sfn = 0; static uint16_t old_sfn = 0;
proc->subframe_rx = old_sf; proc->subframe_rx = old_sf;
proc->frame_rx = old_sfn; proc->frame_rx = old_sfn;
// Try to be 1 frame back // Try to be 1 frame back
old_sf = sf; old_sf = sf;
old_sfn = sfn; old_sfn = sfn;
...@@ -380,9 +351,7 @@ int wake_eNB_rxtx(PHY_VARS_eNB *eNB, uint16_t sfn, uint16_t sf) { ...@@ -380,9 +351,7 @@ int wake_eNB_rxtx(PHY_VARS_eNB *eNB, uint16_t sfn, uint16_t sf) {
} }
++L1_proc->instance_cnt; ++L1_proc->instance_cnt;
//LOG_D( PHY,"[VNF-subframe_ind] sfn/sf:%d:%d proc[frame_rx:%d subframe_rx:%d] L1_proc->instance_cnt_rxtx:%d \n", sfn, sf, proc->frame_rx, proc->subframe_rx, L1_proc->instance_cnt_rxtx); //LOG_D( PHY,"[VNF-subframe_ind] sfn/sf:%d:%d proc[frame_rx:%d subframe_rx:%d] L1_proc->instance_cnt_rxtx:%d \n", sfn, sf, proc->frame_rx, proc->subframe_rx, L1_proc->instance_cnt_rxtx);
// We have just received and processed the common part of a subframe, say n. // We have just received and processed the common part of a subframe, say n.
// TS_rx is the last received timestamp (start of 1st slot), TS_tx is the desired // TS_rx is the last received timestamp (start of 1st slot), TS_tx is the desired
// transmitted timestamp of the next TX slot (first). // transmitted timestamp of the next TX slot (first).
...@@ -407,7 +376,6 @@ int wake_eNB_rxtx(PHY_VARS_eNB *eNB, uint16_t sfn, uint16_t sf) { ...@@ -407,7 +376,6 @@ int wake_eNB_rxtx(PHY_VARS_eNB *eNB, uint16_t sfn, uint16_t sf) {
//LOG_D(PHY,"%s() About to attempt pthread_mutex_unlock\n", __FUNCTION__); //LOG_D(PHY,"%s() About to attempt pthread_mutex_unlock\n", __FUNCTION__);
pthread_mutex_unlock( &L1_proc->mutex ); pthread_mutex_unlock( &L1_proc->mutex );
//LOG_D(PHY,"%s() UNLOCKED pthread_mutex_unlock\n", __FUNCTION__); //LOG_D(PHY,"%s() UNLOCKED pthread_mutex_unlock\n", __FUNCTION__);
return(0); return(0);
} }
...@@ -415,12 +383,10 @@ extern pthread_cond_t nfapi_sync_cond; ...@@ -415,12 +383,10 @@ extern pthread_cond_t nfapi_sync_cond;
extern pthread_mutex_t nfapi_sync_mutex; extern pthread_mutex_t nfapi_sync_mutex;
extern int nfapi_sync_var; extern int nfapi_sync_var;
int phy_sync_indication(struct nfapi_vnf_p7_config* config, uint8_t sync) { int phy_sync_indication(struct nfapi_vnf_p7_config *config, uint8_t sync) {
printf("[VNF] SYNC %s\n", sync==1 ? "ACHIEVED" : "LOST"); printf("[VNF] SYNC %s\n", sync==1 ? "ACHIEVED" : "LOST");
if (sync==1 && nfapi_sync_var!=0) { if (sync==1 && nfapi_sync_var!=0) {
printf("[VNF] Signal to OAI main code that it can go\n"); printf("[VNF] Signal to OAI main code that it can go\n");
pthread_mutex_lock(&nfapi_sync_mutex); pthread_mutex_lock(&nfapi_sync_mutex);
nfapi_sync_var=0; nfapi_sync_var=0;
...@@ -431,9 +397,9 @@ int phy_sync_indication(struct nfapi_vnf_p7_config* config, uint8_t sync) { ...@@ -431,9 +397,9 @@ int phy_sync_indication(struct nfapi_vnf_p7_config* config, uint8_t sync) {
return(0); return(0);
} }
int phy_subframe_indication(struct nfapi_vnf_p7_config* config, uint16_t phy_id, uint16_t sfn_sf) { int phy_subframe_indication(struct nfapi_vnf_p7_config *config, uint16_t phy_id, uint16_t sfn_sf) {
static uint8_t first_time = 1; static uint8_t first_time = 1;
if (first_time) { if (first_time) {
printf("[VNF] subframe indication %d\n", NFAPI_SFNSF2DEC(sfn_sf)); printf("[VNF] subframe indication %d\n", NFAPI_SFNSF2DEC(sfn_sf));
first_time = 0; first_time = 0;
...@@ -442,34 +408,27 @@ int phy_subframe_indication(struct nfapi_vnf_p7_config* config, uint16_t phy_id, ...@@ -442,34 +408,27 @@ int phy_subframe_indication(struct nfapi_vnf_p7_config* config, uint16_t phy_id,
if (RC.eNB && RC.eNB[0][0]->configured) { if (RC.eNB && RC.eNB[0][0]->configured) {
uint16_t sfn = NFAPI_SFNSF2SFN(sfn_sf); uint16_t sfn = NFAPI_SFNSF2SFN(sfn_sf);
uint16_t sf = NFAPI_SFNSF2SF(sfn_sf); uint16_t sf = NFAPI_SFNSF2SF(sfn_sf);
//LOG_D(PHY,"[VNF] subframe indication sfn_sf:%d sfn:%d sf:%d\n", sfn_sf, sfn, sf); //LOG_D(PHY,"[VNF] subframe indication sfn_sf:%d sfn:%d sf:%d\n", sfn_sf, sfn, sf);
wake_eNB_rxtx(RC.eNB[0][0], sfn, sf); wake_eNB_rxtx(RC.eNB[0][0], sfn, sf);
} else { } else {
printf("[VNF] %s() RC.eNB:%p\n", __FUNCTION__, RC.eNB); printf("[VNF] %s() RC.eNB:%p\n", __FUNCTION__, RC.eNB);
if (RC.eNB) printf("RC.eNB[0][0]->configured:%d\n", RC.eNB[0][0]->configured); if (RC.eNB) printf("RC.eNB[0][0]->configured:%d\n", RC.eNB[0][0]->configured);
} }
return 0; return 0;
} }
int phy_rach_indication(struct nfapi_vnf_p7_config* config, nfapi_rach_indication_t* ind) { int phy_rach_indication(struct nfapi_vnf_p7_config *config, nfapi_rach_indication_t *ind) {
LOG_D(MAC, "%s() NFAPI SFN/SF:%d number_of_preambles:%u\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rach_indication_body.number_of_preambles); LOG_D(MAC, "%s() NFAPI SFN/SF:%d number_of_preambles:%u\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rach_indication_body.number_of_preambles);
struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0];
printf("[VNF] RACH_IND eNB:%p sfn_sf:%d number_of_preambles:%d\n", eNB, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rach_indication_body.number_of_preambles); printf("[VNF] RACH_IND eNB:%p sfn_sf:%d number_of_preambles:%d\n", eNB, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rach_indication_body.number_of_preambles);
pthread_mutex_lock(&eNB->UL_INFO_mutex); pthread_mutex_lock(&eNB->UL_INFO_mutex);
eNB->UL_INFO.rach_ind = *ind; eNB->UL_INFO.rach_ind = *ind;
eNB->UL_INFO.rach_ind.rach_indication_body.preamble_list = eNB->preamble_list; eNB->UL_INFO.rach_ind.rach_indication_body.preamble_list = eNB->preamble_list;
for (int i=0;i<ind->rach_indication_body.number_of_preambles;i++) { for (int i=0; i<ind->rach_indication_body.number_of_preambles; i++) {
if (ind->rach_indication_body.preamble_list[i].preamble_rel8.tl.tag == NFAPI_PREAMBLE_REL8_TAG) { if (ind->rach_indication_body.preamble_list[i].preamble_rel8.tl.tag == NFAPI_PREAMBLE_REL8_TAG) {
printf("preamble[%d]: rnti:%02x preamble:%d timing_advance:%d\n", printf("preamble[%d]: rnti:%02x preamble:%d timing_advance:%d\n",
i, i,
ind->rach_indication_body.preamble_list[i].preamble_rel8.rnti, ind->rach_indication_body.preamble_list[i].preamble_rel8.rnti,
...@@ -484,21 +443,17 @@ int phy_rach_indication(struct nfapi_vnf_p7_config* config, nfapi_rach_indicatio ...@@ -484,21 +443,17 @@ int phy_rach_indication(struct nfapi_vnf_p7_config* config, nfapi_rach_indicatio
eNB->preamble_list[i] = ind->rach_indication_body.preamble_list[i]; eNB->preamble_list[i] = ind->rach_indication_body.preamble_list[i];
} }
pthread_mutex_unlock(&eNB->UL_INFO_mutex);
pthread_mutex_unlock(&eNB->UL_INFO_mutex);
// vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); // vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
//mac_rach_ind(p7_vnf->mac, ind); //mac_rach_ind(p7_vnf->mac, ind);
return 1; return 1;
} }
int phy_harq_indication(struct nfapi_vnf_p7_config* config, nfapi_harq_indication_t* ind) { int phy_harq_indication(struct nfapi_vnf_p7_config *config, nfapi_harq_indication_t *ind) {
struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0];
LOG_D(MAC, "%s() NFAPI SFN/SF:%d number_of_harqs:%u\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->harq_indication_body.number_of_harqs); LOG_D(MAC, "%s() NFAPI SFN/SF:%d number_of_harqs:%u\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->harq_indication_body.number_of_harqs);
pthread_mutex_lock(&eNB->UL_INFO_mutex); pthread_mutex_lock(&eNB->UL_INFO_mutex);
eNB->UL_INFO.harq_ind = *ind; eNB->UL_INFO.harq_ind = *ind;
eNB->UL_INFO.harq_ind.harq_indication_body.harq_pdu_list = eNB->harq_pdu_list; eNB->UL_INFO.harq_ind.harq_indication_body.harq_pdu_list = eNB->harq_pdu_list;
...@@ -507,33 +462,26 @@ int phy_harq_indication(struct nfapi_vnf_p7_config* config, nfapi_harq_indicatio ...@@ -507,33 +462,26 @@ int phy_harq_indication(struct nfapi_vnf_p7_config* config, nfapi_harq_indicatio
} }
pthread_mutex_unlock(&eNB->UL_INFO_mutex); pthread_mutex_unlock(&eNB->UL_INFO_mutex);
// vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); // vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
//mac_harq_ind(p7_vnf->mac, ind); //mac_harq_ind(p7_vnf->mac, ind);
return 1; return 1;
} }
int phy_crc_indication(struct nfapi_vnf_p7_config* config, nfapi_crc_indication_t* ind) { int phy_crc_indication(struct nfapi_vnf_p7_config *config, nfapi_crc_indication_t *ind) {
struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0];
pthread_mutex_lock(&eNB->UL_INFO_mutex); pthread_mutex_lock(&eNB->UL_INFO_mutex);
eNB->UL_INFO.crc_ind = *ind; eNB->UL_INFO.crc_ind = *ind;
nfapi_crc_indication_t *dest_ind = &eNB->UL_INFO.crc_ind; nfapi_crc_indication_t *dest_ind = &eNB->UL_INFO.crc_ind;
nfapi_crc_indication_pdu_t *dest_pdu_list = eNB->crc_pdu_list; nfapi_crc_indication_pdu_t *dest_pdu_list = eNB->crc_pdu_list;
*dest_ind = *ind; *dest_ind = *ind;
dest_ind->crc_indication_body.crc_pdu_list = dest_pdu_list; dest_ind->crc_indication_body.crc_pdu_list = dest_pdu_list;
if (ind->crc_indication_body.number_of_crcs==0) if (ind->crc_indication_body.number_of_crcs==0)
LOG_D(MAC, "%s() NFAPI SFN/SF:%d IND:number_of_crcs:%u UL_INFO:crcs:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->crc_indication_body.number_of_crcs, eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs); LOG_D(MAC, "%s() NFAPI SFN/SF:%d IND:number_of_crcs:%u UL_INFO:crcs:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->crc_indication_body.number_of_crcs,
eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs);
for (int i=0; i<ind->crc_indication_body.number_of_crcs; i++) { for (int i=0; i<ind->crc_indication_body.number_of_crcs; i++) {
memcpy(&dest_ind->crc_indication_body.crc_pdu_list[i], &ind->crc_indication_body.crc_pdu_list[i], sizeof(ind->crc_indication_body.crc_pdu_list[0])); memcpy(&dest_ind->crc_indication_body.crc_pdu_list[i], &ind->crc_indication_body.crc_pdu_list[i], sizeof(ind->crc_indication_body.crc_pdu_list[0]));
LOG_D(MAC, "%s() NFAPI SFN/SF:%d CRC_IND:number_of_crcs:%u UL_INFO:crcs:%d PDU[%d] rnti:%04x UL_INFO:rnti:%04x\n", LOG_D(MAC, "%s() NFAPI SFN/SF:%d CRC_IND:number_of_crcs:%u UL_INFO:crcs:%d PDU[%d] rnti:%04x UL_INFO:rnti:%04x\n",
__FUNCTION__, __FUNCTION__,
NFAPI_SFNSF2DEC(ind->sfn_sf), ind->crc_indication_body.number_of_crcs, eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->crc_indication_body.number_of_crcs, eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs,
...@@ -543,15 +491,12 @@ int phy_crc_indication(struct nfapi_vnf_p7_config* config, nfapi_crc_indication_ ...@@ -543,15 +491,12 @@ int phy_crc_indication(struct nfapi_vnf_p7_config* config, nfapi_crc_indication_
} }
pthread_mutex_unlock(&eNB->UL_INFO_mutex); pthread_mutex_unlock(&eNB->UL_INFO_mutex);
// vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); // vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
//mac_crc_ind(p7_vnf->mac, ind); //mac_crc_ind(p7_vnf->mac, ind);
return 1; return 1;
} }
int phy_rx_indication(struct nfapi_vnf_p7_config* config, nfapi_rx_indication_t* ind) { int phy_rx_indication(struct nfapi_vnf_p7_config *config, nfapi_rx_indication_t *ind) {
struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0];
if (ind->rx_indication_body.number_of_pdus==0) { if (ind->rx_indication_body.number_of_pdus==0) {
...@@ -559,24 +504,18 @@ int phy_rx_indication(struct nfapi_vnf_p7_config* config, nfapi_rx_indication_t* ...@@ -559,24 +504,18 @@ int phy_rx_indication(struct nfapi_vnf_p7_config* config, nfapi_rx_indication_t*
} }
pthread_mutex_lock(&eNB->UL_INFO_mutex); pthread_mutex_lock(&eNB->UL_INFO_mutex);
nfapi_rx_indication_t *dest_ind = &eNB->UL_INFO.rx_ind; nfapi_rx_indication_t *dest_ind = &eNB->UL_INFO.rx_ind;
nfapi_rx_indication_pdu_t *dest_pdu_list = eNB->rx_pdu_list; nfapi_rx_indication_pdu_t *dest_pdu_list = eNB->rx_pdu_list;
*dest_ind = *ind; *dest_ind = *ind;
dest_ind->rx_indication_body.rx_pdu_list = dest_pdu_list; dest_ind->rx_indication_body.rx_pdu_list = dest_pdu_list;
for(int i=0; i<ind->rx_indication_body.number_of_pdus; i++) { for(int i=0; i<ind->rx_indication_body.number_of_pdus; i++) {
nfapi_rx_indication_pdu_t *dest_pdu = &dest_ind->rx_indication_body.rx_pdu_list[i]; nfapi_rx_indication_pdu_t *dest_pdu = &dest_ind->rx_indication_body.rx_pdu_list[i];
nfapi_rx_indication_pdu_t *src_pdu = &ind->rx_indication_body.rx_pdu_list[i]; nfapi_rx_indication_pdu_t *src_pdu = &ind->rx_indication_body.rx_pdu_list[i];
memcpy(dest_pdu, src_pdu, sizeof(*src_pdu)); memcpy(dest_pdu, src_pdu, sizeof(*src_pdu));
// DJP - TODO FIXME - intentional memory leak // DJP - TODO FIXME - intentional memory leak
dest_pdu->data = malloc(dest_pdu->rx_indication_rel8.length); dest_pdu->data = malloc(dest_pdu->rx_indication_rel8.length);
memcpy(dest_pdu->data, src_pdu->data, dest_pdu->rx_indication_rel8.length); memcpy(dest_pdu->data, src_pdu->data, dest_pdu->rx_indication_rel8.length);
LOG_D(PHY, "%s() NFAPI SFN/SF:%d PDUs:%d [PDU:%d] handle:%d rnti:%04x length:%d offset:%d ul_cqi:%d ta:%d data:%p\n", LOG_D(PHY, "%s() NFAPI SFN/SF:%d PDUs:%d [PDU:%d] handle:%d rnti:%04x length:%d offset:%d ul_cqi:%d ta:%d data:%p\n",
__FUNCTION__, __FUNCTION__,
NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rx_indication_body.number_of_pdus, i, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rx_indication_body.number_of_pdus, i,
...@@ -591,166 +530,144 @@ int phy_rx_indication(struct nfapi_vnf_p7_config* config, nfapi_rx_indication_t* ...@@ -591,166 +530,144 @@ int phy_rx_indication(struct nfapi_vnf_p7_config* config, nfapi_rx_indication_t*
} }
pthread_mutex_unlock(&eNB->UL_INFO_mutex); pthread_mutex_unlock(&eNB->UL_INFO_mutex);
// vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); // vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
//mac_rx_ind(p7_vnf->mac, ind); //mac_rx_ind(p7_vnf->mac, ind);
return 1; return 1;
} }
int phy_srs_indication(struct nfapi_vnf_p7_config* config, nfapi_srs_indication_t* ind) { int phy_srs_indication(struct nfapi_vnf_p7_config *config, nfapi_srs_indication_t *ind) {
// vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); // vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
//mac_srs_ind(p7_vnf->mac, ind); //mac_srs_ind(p7_vnf->mac, ind);
return 1; return 1;
} }
int phy_sr_indication(struct nfapi_vnf_p7_config* config, nfapi_sr_indication_t* ind) { int phy_sr_indication(struct nfapi_vnf_p7_config *config, nfapi_sr_indication_t *ind) {
struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0];
LOG_D(MAC, "%s() NFAPI SFN/SF:%d srs:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->sr_indication_body.number_of_srs); LOG_D(MAC, "%s() NFAPI SFN/SF:%d srs:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->sr_indication_body.number_of_srs);
pthread_mutex_lock(&eNB->UL_INFO_mutex); pthread_mutex_lock(&eNB->UL_INFO_mutex);
nfapi_sr_indication_t *dest_ind = &eNB->UL_INFO.sr_ind; nfapi_sr_indication_t *dest_ind = &eNB->UL_INFO.sr_ind;
nfapi_sr_indication_pdu_t *dest_pdu_list = eNB->sr_pdu_list; nfapi_sr_indication_pdu_t *dest_pdu_list = eNB->sr_pdu_list;
*dest_ind = *ind; *dest_ind = *ind;
dest_ind->sr_indication_body.sr_pdu_list = dest_pdu_list; dest_ind->sr_indication_body.sr_pdu_list = dest_pdu_list;
LOG_D(MAC,"%s() eNB->UL_INFO.sr_ind.sr_indication_body.number_of_srs:%d\n", __FUNCTION__, eNB->UL_INFO.sr_ind.sr_indication_body.number_of_srs); LOG_D(MAC,"%s() eNB->UL_INFO.sr_ind.sr_indication_body.number_of_srs:%d\n", __FUNCTION__, eNB->UL_INFO.sr_ind.sr_indication_body.number_of_srs);
for (int i=0;i<eNB->UL_INFO.sr_ind.sr_indication_body.number_of_srs;i++) { for (int i=0; i<eNB->UL_INFO.sr_ind.sr_indication_body.number_of_srs; i++) {
nfapi_sr_indication_pdu_t *dest_pdu = &dest_ind->sr_indication_body.sr_pdu_list[i]; nfapi_sr_indication_pdu_t *dest_pdu = &dest_ind->sr_indication_body.sr_pdu_list[i];
nfapi_sr_indication_pdu_t *src_pdu = &ind->sr_indication_body.sr_pdu_list[i]; nfapi_sr_indication_pdu_t *src_pdu = &ind->sr_indication_body.sr_pdu_list[i];
LOG_D(MAC, "SR_IND[PDU:%d][rnti:%x cqi:%d channel:%d]\n", i, src_pdu->rx_ue_information.rnti, src_pdu->ul_cqi_information.ul_cqi, src_pdu->ul_cqi_information.channel); LOG_D(MAC, "SR_IND[PDU:%d][rnti:%x cqi:%d channel:%d]\n", i, src_pdu->rx_ue_information.rnti, src_pdu->ul_cqi_information.ul_cqi, src_pdu->ul_cqi_information.channel);
memcpy(dest_pdu, src_pdu, sizeof(*src_pdu)); memcpy(dest_pdu, src_pdu, sizeof(*src_pdu));
} }
pthread_mutex_unlock(&eNB->UL_INFO_mutex); pthread_mutex_unlock(&eNB->UL_INFO_mutex);
// vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); // vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
//mac_sr_ind(p7_vnf->mac, ind); //mac_sr_ind(p7_vnf->mac, ind);
return 1; return 1;
} }
int phy_cqi_indication(struct nfapi_vnf_p7_config* config, nfapi_cqi_indication_t* ind) { int phy_cqi_indication(struct nfapi_vnf_p7_config *config, nfapi_cqi_indication_t *ind) {
// vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); // vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
//mac_cqi_ind(p7_vnf->mac, ind); //mac_cqi_ind(p7_vnf->mac, ind);
struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0];
LOG_D(MAC, "%s() NFAPI SFN/SF:%d number_of_cqis:%u\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->cqi_indication_body.number_of_cqis); LOG_D(MAC, "%s() NFAPI SFN/SF:%d number_of_cqis:%u\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->cqi_indication_body.number_of_cqis);
pthread_mutex_lock(&eNB->UL_INFO_mutex); pthread_mutex_lock(&eNB->UL_INFO_mutex);
eNB->UL_INFO.cqi_ind = ind->cqi_indication_body; eNB->UL_INFO.cqi_ind = ind->cqi_indication_body;
pthread_mutex_unlock(&eNB->UL_INFO_mutex); pthread_mutex_unlock(&eNB->UL_INFO_mutex);
return 1; return 1;
} }
int phy_lbt_dl_indication(struct nfapi_vnf_p7_config* config, nfapi_lbt_dl_indication_t* ind) { int phy_lbt_dl_indication(struct nfapi_vnf_p7_config *config, nfapi_lbt_dl_indication_t *ind) {
// vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); // vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
//mac_lbt_dl_ind(p7_vnf->mac, ind); //mac_lbt_dl_ind(p7_vnf->mac, ind);
return 1; return 1;
} }
int phy_nb_harq_indication(struct nfapi_vnf_p7_config* config, nfapi_nb_harq_indication_t* ind) { int phy_nb_harq_indication(struct nfapi_vnf_p7_config *config, nfapi_nb_harq_indication_t *ind) {
// vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); // vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
//mac_nb_harq_ind(p7_vnf->mac, ind); //mac_nb_harq_ind(p7_vnf->mac, ind);
return 1; return 1;
} }
int phy_nrach_indication(struct nfapi_vnf_p7_config* config, nfapi_nrach_indication_t* ind) { int phy_nrach_indication(struct nfapi_vnf_p7_config *config, nfapi_nrach_indication_t *ind) {
// vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); // vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
//mac_nrach_ind(p7_vnf->mac, ind); //mac_nrach_ind(p7_vnf->mac, ind);
return 1; return 1;
} }
void* vnf_allocate(size_t size) { void *vnf_allocate(size_t size) {
//return (void*)memory_pool::allocate(size); //return (void*)memory_pool::allocate(size);
return (void*)malloc(size); return (void *)malloc(size);
} }
void vnf_deallocate(void* ptr) { void vnf_deallocate(void *ptr) {
//memory_pool::deallocate((uint8_t*)ptr); //memory_pool::deallocate((uint8_t*)ptr);
free(ptr); free(ptr);
} }
void vnf_trace(nfapi_trace_level_t nfapi_level, const char* message, ...) { void vnf_trace(nfapi_trace_level_t nfapi_level, const char *message, ...) {
va_list args; va_list args;
va_start(args, message); va_start(args, message);
nfapi_log("FILE>", "FUNC", 999, PHY, nfapitooai_level(nfapi_level), message, args); nfapi_log("FILE>", "FUNC", 999, PHY, nfapitooai_level(nfapi_level), message, args);
va_end(args); va_end(args);
} }
int phy_vendor_ext(struct nfapi_vnf_p7_config* config, nfapi_p7_message_header_t* msg) { int phy_vendor_ext(struct nfapi_vnf_p7_config *config, nfapi_p7_message_header_t *msg) {
if(msg->message_id == P7_VENDOR_EXT_IND) {
if(msg->message_id == P7_VENDOR_EXT_IND)
{
//vendor_ext_p7_ind* ind = (vendor_ext_p7_ind*)msg; //vendor_ext_p7_ind* ind = (vendor_ext_p7_ind*)msg;
//printf("[VNF] vendor_ext (error_code:%d)\n", ind->error_code); //printf("[VNF] vendor_ext (error_code:%d)\n", ind->error_code);
} } else {
else
{
printf("[VNF] unknown %02x\n", msg->message_id); printf("[VNF] unknown %02x\n", msg->message_id);
} }
return 0; return 0;
} }
nfapi_p7_message_header_t* phy_allocate_p7_vendor_ext(uint16_t message_id, uint16_t* msg_size) { nfapi_p7_message_header_t *phy_allocate_p7_vendor_ext(uint16_t message_id, uint16_t *msg_size) {
if(message_id == P7_VENDOR_EXT_IND) if(message_id == P7_VENDOR_EXT_IND) {
{
*msg_size = sizeof(vendor_ext_p7_ind); *msg_size = sizeof(vendor_ext_p7_ind);
return (nfapi_p7_message_header_t*)malloc(sizeof(vendor_ext_p7_ind)); return (nfapi_p7_message_header_t *)malloc(sizeof(vendor_ext_p7_ind));
} }
return 0; return 0;
} }
void phy_deallocate_p7_vendor_ext(nfapi_p7_message_header_t* header) { void phy_deallocate_p7_vendor_ext(nfapi_p7_message_header_t *header) {
free(header); free(header);
} }
int phy_unpack_vendor_extension_tlv(nfapi_tl_t* tl, uint8_t **ppReadPackedMessage, uint8_t *end, void** ve, nfapi_p7_codec_config_t* codec) { int phy_unpack_vendor_extension_tlv(nfapi_tl_t *tl, uint8_t **ppReadPackedMessage, uint8_t *end, void **ve, nfapi_p7_codec_config_t *codec) {
(void)tl; (void)tl;
(void)ppReadPackedMessage; (void)ppReadPackedMessage;
(void)ve; (void)ve;
return -1; return -1;
} }
int phy_pack_vendor_extension_tlv(void* ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* codec) { int phy_pack_vendor_extension_tlv(void *ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *codec) {
//NFAPI_TRACE(NFAPI_TRACE_INFO, "phy_pack_vendor_extension_tlv\n"); //NFAPI_TRACE(NFAPI_TRACE_INFO, "phy_pack_vendor_extension_tlv\n");
nfapi_tl_t *tlv = (nfapi_tl_t *)ve;
nfapi_tl_t* tlv = (nfapi_tl_t*)ve;
switch(tlv->tag) { switch(tlv->tag) {
case VENDOR_EXT_TLV_1_TAG: case VENDOR_EXT_TLV_1_TAG: {
{
//NFAPI_TRACE(NFAPI_TRACE_INFO, "Packing VENDOR_EXT_TLV_1\n"); //NFAPI_TRACE(NFAPI_TRACE_INFO, "Packing VENDOR_EXT_TLV_1\n");
vendor_ext_tlv_1* ve = (vendor_ext_tlv_1*)tlv; vendor_ext_tlv_1 *ve = (vendor_ext_tlv_1 *)tlv;
if(!push32(ve->dummy, ppWritePackedMsg, end)) if(!push32(ve->dummy, ppWritePackedMsg, end))
return 0; return 0;
return 1; return 1;
} }
break; break;
default: default:
return -1; return -1;
break; break;
} }
} }
int phy_unpack_p7_vendor_extension(nfapi_p7_message_header_t* header, uint8_t** ppReadPackedMessage, uint8_t *end, nfapi_p7_codec_config_t* config) { int phy_unpack_p7_vendor_extension(nfapi_p7_message_header_t *header, uint8_t **ppReadPackedMessage, uint8_t *end, nfapi_p7_codec_config_t *config) {
//NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__); //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__);
if(header->message_id == P7_VENDOR_EXT_IND) { if(header->message_id == P7_VENDOR_EXT_IND) {
vendor_ext_p7_ind* req = (vendor_ext_p7_ind*)(header); vendor_ext_p7_ind *req = (vendor_ext_p7_ind *)(header);
if(!pull16(ppReadPackedMessage, &req->error_code, end)) if(!pull16(ppReadPackedMessage, &req->error_code, end))
return 0; return 0;
} }
...@@ -758,54 +675,48 @@ int phy_unpack_p7_vendor_extension(nfapi_p7_message_header_t* header, uint8_t** ...@@ -758,54 +675,48 @@ int phy_unpack_p7_vendor_extension(nfapi_p7_message_header_t* header, uint8_t**
return 1; return 1;
} }
int phy_pack_p7_vendor_extension(nfapi_p7_message_header_t* header, uint8_t** ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) { int phy_pack_p7_vendor_extension(nfapi_p7_message_header_t *header, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config) {
//NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__); //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__);
if(header->message_id == P7_VENDOR_EXT_REQ) { if(header->message_id == P7_VENDOR_EXT_REQ) {
//NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__); //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__);
vendor_ext_p7_req* req = (vendor_ext_p7_req*)(header); vendor_ext_p7_req *req = (vendor_ext_p7_req *)(header);
if(!(push16(req->dummy1, ppWritePackedMsg, end) && if(!(push16(req->dummy1, ppWritePackedMsg, end) &&
push16(req->dummy2, ppWritePackedMsg, end))) push16(req->dummy2, ppWritePackedMsg, end)))
return 0; return 0;
} }
return 1; return 1;
} }
int vnf_pack_p4_p5_vendor_extension(nfapi_p4_p5_message_header_t* header, uint8_t** ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* codec) { int vnf_pack_p4_p5_vendor_extension(nfapi_p4_p5_message_header_t *header, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *codec) {
//NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__); //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__);
if(header->message_id == P5_VENDOR_EXT_REQ) { if(header->message_id == P5_VENDOR_EXT_REQ) {
vendor_ext_p5_req* req = (vendor_ext_p5_req*)(header); vendor_ext_p5_req *req = (vendor_ext_p5_req *)(header);
//NFAPI_TRACE(NFAPI_TRACE_INFO, "%s %d %d\n", __FUNCTION__, req->dummy1, req->dummy2); //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s %d %d\n", __FUNCTION__, req->dummy1, req->dummy2);
return (!(push16(req->dummy1, ppWritePackedMsg, end) && return (!(push16(req->dummy1, ppWritePackedMsg, end) &&
push16(req->dummy2, ppWritePackedMsg, end))); push16(req->dummy2, ppWritePackedMsg, end)));
} }
return 0; return 0;
} }
static pthread_t vnf_start_pthread; static pthread_t vnf_start_pthread;
static pthread_t vnf_p7_start_pthread; static pthread_t vnf_p7_start_pthread;
void* vnf_p7_start_thread(void *ptr) { void *vnf_p7_start_thread(void *ptr) {
printf("%s()\n", __FUNCTION__); printf("%s()\n", __FUNCTION__);
pthread_setname_np(pthread_self(), "VNF_P7"); pthread_setname_np(pthread_self(), "VNF_P7");
nfapi_vnf_p7_config_t *config = (nfapi_vnf_p7_config_t *)ptr;
nfapi_vnf_p7_config_t* config = (nfapi_vnf_p7_config_t*)ptr;
nfapi_vnf_p7_start(config); nfapi_vnf_p7_start(config);
return config; return config;
} }
void set_thread_priority(int priority); void set_thread_priority(int priority);
void* vnf_p7_thread_start(void* ptr) { void *vnf_p7_thread_start(void *ptr) {
set_thread_priority(79); set_thread_priority(79);
vnf_p7_info *p7_vnf = (vnf_p7_info *)ptr;
vnf_p7_info* p7_vnf = (vnf_p7_info*)ptr;
p7_vnf->config->port = p7_vnf->local_port; p7_vnf->config->port = p7_vnf->local_port;
p7_vnf->config->sync_indication = &phy_sync_indication; p7_vnf->config->sync_indication = &phy_sync_indication;
p7_vnf->config->subframe_indication = &phy_subframe_indication; p7_vnf->config->subframe_indication = &phy_subframe_indication;
...@@ -821,117 +732,87 @@ void* vnf_p7_thread_start(void* ptr) { ...@@ -821,117 +732,87 @@ void* vnf_p7_thread_start(void* ptr) {
p7_vnf->config->nrach_indication = &phy_nrach_indication; p7_vnf->config->nrach_indication = &phy_nrach_indication;
p7_vnf->config->malloc = &vnf_allocate; p7_vnf->config->malloc = &vnf_allocate;
p7_vnf->config->free = &vnf_deallocate; p7_vnf->config->free = &vnf_deallocate;
p7_vnf->config->trace = &vnf_trace; p7_vnf->config->trace = &vnf_trace;
p7_vnf->config->vendor_ext = &phy_vendor_ext; p7_vnf->config->vendor_ext = &phy_vendor_ext;
p7_vnf->config->user_data = p7_vnf; p7_vnf->config->user_data = p7_vnf;
p7_vnf->mac->user_data = p7_vnf; p7_vnf->mac->user_data = p7_vnf;
p7_vnf->config->codec_config.unpack_p7_vendor_extension = &phy_unpack_p7_vendor_extension; p7_vnf->config->codec_config.unpack_p7_vendor_extension = &phy_unpack_p7_vendor_extension;
p7_vnf->config->codec_config.pack_p7_vendor_extension = &phy_pack_p7_vendor_extension; p7_vnf->config->codec_config.pack_p7_vendor_extension = &phy_pack_p7_vendor_extension;
p7_vnf->config->codec_config.unpack_vendor_extension_tlv = &phy_unpack_vendor_extension_tlv; p7_vnf->config->codec_config.unpack_vendor_extension_tlv = &phy_unpack_vendor_extension_tlv;
p7_vnf->config->codec_config.pack_vendor_extension_tlv = &phy_pack_vendor_extension_tlv; p7_vnf->config->codec_config.pack_vendor_extension_tlv = &phy_pack_vendor_extension_tlv;
p7_vnf->config->codec_config.allocate = &vnf_allocate; p7_vnf->config->codec_config.allocate = &vnf_allocate;
p7_vnf->config->codec_config.deallocate = &vnf_deallocate; p7_vnf->config->codec_config.deallocate = &vnf_deallocate;
p7_vnf->config->allocate_p7_vendor_ext = &phy_allocate_p7_vendor_ext; p7_vnf->config->allocate_p7_vendor_ext = &phy_allocate_p7_vendor_ext;
p7_vnf->config->deallocate_p7_vendor_ext = &phy_deallocate_p7_vendor_ext; p7_vnf->config->deallocate_p7_vendor_ext = &phy_deallocate_p7_vendor_ext;
NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Creating VNF NFAPI start thread %s\n", __FUNCTION__); NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Creating VNF NFAPI start thread %s\n", __FUNCTION__);
pthread_create(&vnf_p7_start_pthread, NULL, &vnf_p7_start_thread, p7_vnf->config); pthread_create(&vnf_p7_start_pthread, NULL, &vnf_p7_start_thread, p7_vnf->config);
return 0; return 0;
} }
int pnf_start_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_start_response_t* resp) { int pnf_start_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_pnf_start_response_t *resp) {
vnf_info *vnf = (vnf_info *)(config->user_data);
vnf_info* vnf = (vnf_info*)(config->user_data);
vnf_p7_info *p7_vnf = vnf->p7_vnfs; vnf_p7_info *p7_vnf = vnf->p7_vnfs;
pnf_info *pnf = vnf->pnfs; pnf_info *pnf = vnf->pnfs;
nfapi_param_request_t req; nfapi_param_request_t req;
printf("[VNF] pnf start response idx:%d config:%p user_data:%p p7_vnf[config:%p thread_started:%d]\n", p5_idx, config, config->user_data, vnf->p7_vnfs[0].config, vnf->p7_vnfs[0].thread_started); printf("[VNF] pnf start response idx:%d config:%p user_data:%p p7_vnf[config:%p thread_started:%d]\n", p5_idx, config, config->user_data, vnf->p7_vnfs[0].config, vnf->p7_vnfs[0].thread_started);
if(p7_vnf->thread_started == 0) { if(p7_vnf->thread_started == 0) {
pthread_t vnf_p7_thread; pthread_t vnf_p7_thread;
pthread_create(&vnf_p7_thread, NULL, &vnf_p7_thread_start, p7_vnf); pthread_create(&vnf_p7_thread, NULL, &vnf_p7_thread_start, p7_vnf);
p7_vnf->thread_started = 1; p7_vnf->thread_started = 1;
} } else {
else
{
// P7 thread already running. // P7 thread already running.
} }
// start all the phys in the pnf. // start all the phys in the pnf.
printf("[VNF] Sending NFAPI_PARAM_REQUEST phy_id:%d\n", pnf->phys[0].id); printf("[VNF] Sending NFAPI_PARAM_REQUEST phy_id:%d\n", pnf->phys[0].id);
memset(&req, 0, sizeof(req)); memset(&req, 0, sizeof(req));
req.header.message_id = NFAPI_PARAM_REQUEST; req.header.message_id = NFAPI_PARAM_REQUEST;
req.header.phy_id = pnf->phys[0].id; req.header.phy_id = pnf->phys[0].id;
nfapi_vnf_param_req(config, p5_idx, &req); nfapi_vnf_param_req(config, p5_idx, &req);
return 0; return 0;
} }
extern uint32_t to_earfcn(int eutra_bandP,uint32_t dl_CarrierFreq,uint32_t bw); extern uint32_t to_earfcn(int eutra_bandP,uint32_t dl_CarrierFreq,uint32_t bw);
int param_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_param_response_t* resp) { int param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_param_response_t *resp) {
printf("[VNF] Received NFAPI_PARAM_RESP idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id); printf("[VNF] Received NFAPI_PARAM_RESP idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id);
vnf_info *vnf = (vnf_info *)(config->user_data);
vnf_info* vnf = (vnf_info*)(config->user_data);
vnf_p7_info *p7_vnf = vnf->p7_vnfs; vnf_p7_info *p7_vnf = vnf->p7_vnfs;
pnf_info *pnf = vnf->pnfs; pnf_info *pnf = vnf->pnfs;
phy_info *phy = pnf->phys; phy_info *phy = pnf->phys;
struct sockaddr_in pnf_p7_sockaddr; struct sockaddr_in pnf_p7_sockaddr;
nfapi_config_request_t *req = &RC.mac[0]->config[0]; nfapi_config_request_t *req = &RC.mac[0]->config[0];
phy->remote_port = resp->nfapi_config.p7_pnf_port.value; phy->remote_port = resp->nfapi_config.p7_pnf_port.value;
memcpy(&pnf_p7_sockaddr.sin_addr.s_addr, &(resp->nfapi_config.p7_pnf_address_ipv4.address[0]), 4); memcpy(&pnf_p7_sockaddr.sin_addr.s_addr, &(resp->nfapi_config.p7_pnf_address_ipv4.address[0]), 4);
phy->remote_addr = inet_ntoa(pnf_p7_sockaddr.sin_addr); phy->remote_addr = inet_ntoa(pnf_p7_sockaddr.sin_addr);
// for now just 1 // for now just 1
printf("[VNF] %d.%d pnf p7 %s:%d timing %u %u %u %u\n", p5_idx, phy->id, phy->remote_addr, phy->remote_port, p7_vnf->timing_window, p7_vnf->periodic_timing_period, p7_vnf->aperiodic_timing_enabled,
printf("[VNF] %d.%d pnf p7 %s:%d timing %u %u %u %u\n", p5_idx, phy->id, phy->remote_addr, phy->remote_port, p7_vnf->timing_window, p7_vnf->periodic_timing_period, p7_vnf->aperiodic_timing_enabled, p7_vnf->periodic_timing_period); p7_vnf->periodic_timing_period);
req->header.message_id = NFAPI_CONFIG_REQUEST; req->header.message_id = NFAPI_CONFIG_REQUEST;
req->header.phy_id = phy->id; req->header.phy_id = phy->id;
printf("[VNF] Send NFAPI_CONFIG_REQUEST\n"); printf("[VNF] Send NFAPI_CONFIG_REQUEST\n");
req->nfapi_config.p7_vnf_port.tl.tag = NFAPI_NFAPI_P7_VNF_PORT_TAG; req->nfapi_config.p7_vnf_port.tl.tag = NFAPI_NFAPI_P7_VNF_PORT_TAG;
req->nfapi_config.p7_vnf_port.value = p7_vnf->local_port; req->nfapi_config.p7_vnf_port.value = p7_vnf->local_port;
req->num_tlv++; req->num_tlv++;
printf("[VNF] DJP local_port:%d\n", p7_vnf->local_port); printf("[VNF] DJP local_port:%d\n", p7_vnf->local_port);
req->nfapi_config.p7_vnf_address_ipv4.tl.tag = NFAPI_NFAPI_P7_VNF_ADDRESS_IPV4_TAG; req->nfapi_config.p7_vnf_address_ipv4.tl.tag = NFAPI_NFAPI_P7_VNF_ADDRESS_IPV4_TAG;
struct sockaddr_in vnf_p7_sockaddr; struct sockaddr_in vnf_p7_sockaddr;
vnf_p7_sockaddr.sin_addr.s_addr = inet_addr(p7_vnf->local_addr); vnf_p7_sockaddr.sin_addr.s_addr = inet_addr(p7_vnf->local_addr);
memcpy(&(req->nfapi_config.p7_vnf_address_ipv4.address[0]), &vnf_p7_sockaddr.sin_addr.s_addr, 4); memcpy(&(req->nfapi_config.p7_vnf_address_ipv4.address[0]), &vnf_p7_sockaddr.sin_addr.s_addr, 4);
req->num_tlv++; req->num_tlv++;
printf("[VNF] DJP local_addr:%s\n", p7_vnf->local_addr); printf("[VNF] DJP local_addr:%s\n", p7_vnf->local_addr);
req->nfapi_config.timing_window.tl.tag = NFAPI_NFAPI_TIMING_WINDOW_TAG; req->nfapi_config.timing_window.tl.tag = NFAPI_NFAPI_TIMING_WINDOW_TAG;
req->nfapi_config.timing_window.value = p7_vnf->timing_window; req->nfapi_config.timing_window.value = p7_vnf->timing_window;
printf("[VNF] Timing window:%u\n", p7_vnf->timing_window); printf("[VNF] Timing window:%u\n", p7_vnf->timing_window);
req->num_tlv++; req->num_tlv++;
if(p7_vnf->periodic_timing_enabled || p7_vnf->aperiodic_timing_enabled) { if(p7_vnf->periodic_timing_enabled || p7_vnf->aperiodic_timing_enabled) {
req->nfapi_config.timing_info_mode.tl.tag = NFAPI_NFAPI_TIMING_INFO_MODE_TAG; req->nfapi_config.timing_info_mode.tl.tag = NFAPI_NFAPI_TIMING_INFO_MODE_TAG;
req->nfapi_config.timing_info_mode.value = (p7_vnf->aperiodic_timing_enabled << 1) | (p7_vnf->periodic_timing_enabled); req->nfapi_config.timing_info_mode.value = (p7_vnf->aperiodic_timing_enabled << 1) | (p7_vnf->periodic_timing_enabled);
req->num_tlv++; req->num_tlv++;
if(p7_vnf->periodic_timing_enabled) { if(p7_vnf->periodic_timing_enabled) {
req->nfapi_config.timing_info_period.tl.tag = NFAPI_NFAPI_TIMING_INFO_PERIOD_TAG; req->nfapi_config.timing_info_period.tl.tag = NFAPI_NFAPI_TIMING_INFO_PERIOD_TAG;
req->nfapi_config.timing_info_period.value = p7_vnf->periodic_timing_period; req->nfapi_config.timing_info_period.value = p7_vnf->periodic_timing_period;
req->num_tlv++; req->num_tlv++;
...@@ -943,58 +824,42 @@ int param_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_param_response_t ...@@ -943,58 +824,42 @@ int param_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_param_response_t
ve2.tl.tag = VENDOR_EXT_TLV_2_TAG; ve2.tl.tag = VENDOR_EXT_TLV_2_TAG;
ve2.dummy = 2016; ve2.dummy = 2016;
req->vendor_extension = &ve2.tl; req->vendor_extension = &ve2.tl;
nfapi_vnf_config_req(config, p5_idx, req); nfapi_vnf_config_req(config, p5_idx, req);
printf("[VNF] Sent NFAPI_CONFIG_REQ num_tlv:%u\n",req->num_tlv); printf("[VNF] Sent NFAPI_CONFIG_REQ num_tlv:%u\n",req->num_tlv);
return 0; return 0;
} }
int config_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_config_response_t* resp) { int config_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_config_response_t *resp) {
nfapi_start_request_t req; nfapi_start_request_t req;
printf("[VNF] Received NFAPI_CONFIG_RESP idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id); printf("[VNF] Received NFAPI_CONFIG_RESP idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id);
printf("[VNF] Calling oai_enb_init()\n"); printf("[VNF] Calling oai_enb_init()\n");
oai_enb_init(); oai_enb_init();
memset(&req, 0, sizeof(req)); memset(&req, 0, sizeof(req));
req.header.message_id = NFAPI_START_REQUEST; req.header.message_id = NFAPI_START_REQUEST;
req.header.phy_id = resp->header.phy_id; req.header.phy_id = resp->header.phy_id;
nfapi_vnf_start_req(config, p5_idx, &req); nfapi_vnf_start_req(config, p5_idx, &req);
printf("[VNF] Send NFAPI_START_REQUEST idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id); printf("[VNF] Send NFAPI_START_REQUEST idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id);
return 0; return 0;
} }
int start_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_start_response_t* resp) { int start_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_start_response_t *resp) {
printf("[VNF] Received NFAPI_START_RESP idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id); printf("[VNF] Received NFAPI_START_RESP idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id);
vnf_info *vnf = (vnf_info *)(config->user_data);
vnf_info* vnf = (vnf_info*)(config->user_data);
pnf_info *pnf = vnf->pnfs; pnf_info *pnf = vnf->pnfs;
phy_info *phy = pnf->phys; phy_info *phy = pnf->phys;
vnf_p7_info *p7_vnf = vnf->p7_vnfs; vnf_p7_info *p7_vnf = vnf->p7_vnfs;
nfapi_vnf_p7_add_pnf((p7_vnf->config), phy->remote_addr, phy->remote_port, phy->id); nfapi_vnf_p7_add_pnf((p7_vnf->config), phy->remote_addr, phy->remote_port, phy->id);
return 0; return 0;
} }
int vendor_ext_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_p4_p5_message_header_t* msg) { int vendor_ext_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_p4_p5_message_header_t *msg) {
printf("[VNF] %s\n", __FUNCTION__); printf("[VNF] %s\n", __FUNCTION__);
switch(msg->message_id) { switch(msg->message_id) {
case P5_VENDOR_EXT_RSP: case P5_VENDOR_EXT_RSP: {
{ vendor_ext_p5_rsp *rsp = (vendor_ext_p5_rsp *)msg;
vendor_ext_p5_rsp* rsp = (vendor_ext_p5_rsp*)msg;
printf("[VNF] P5_VENDOR_EXT_RSP error_code:%d\n", rsp->error_code); printf("[VNF] P5_VENDOR_EXT_RSP error_code:%d\n", rsp->error_code);
// send the start request // send the start request
nfapi_pnf_start_request_t req; nfapi_pnf_start_request_t req;
memset(&req, 0, sizeof(req)); memset(&req, 0, sizeof(req));
req.header.message_id = NFAPI_PNF_START_REQUEST; req.header.message_id = NFAPI_PNF_START_REQUEST;
...@@ -1006,79 +871,63 @@ int vendor_ext_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_p4_p5_message_he ...@@ -1006,79 +871,63 @@ int vendor_ext_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_p4_p5_message_he
return 0; return 0;
} }
int vnf_unpack_p4_p5_vendor_extension(nfapi_p4_p5_message_header_t* header, uint8_t** ppReadPackedMessage, uint8_t *end, nfapi_p4_p5_codec_config_t* codec) { int vnf_unpack_p4_p5_vendor_extension(nfapi_p4_p5_message_header_t *header, uint8_t **ppReadPackedMessage, uint8_t *end, nfapi_p4_p5_codec_config_t *codec) {
//NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__); //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__);
if(header->message_id == P5_VENDOR_EXT_RSP) if(header->message_id == P5_VENDOR_EXT_RSP) {
{ vendor_ext_p5_rsp *req = (vendor_ext_p5_rsp *)(header);
vendor_ext_p5_rsp* req = (vendor_ext_p5_rsp*)(header);
return(!pull16(ppReadPackedMessage, &req->error_code, end)); return(!pull16(ppReadPackedMessage, &req->error_code, end));
} }
return 0; return 0;
} }
nfapi_p4_p5_message_header_t* vnf_allocate_p4_p5_vendor_ext(uint16_t message_id, uint16_t* msg_size) { nfapi_p4_p5_message_header_t *vnf_allocate_p4_p5_vendor_ext(uint16_t message_id, uint16_t *msg_size) {
if(message_id == P5_VENDOR_EXT_RSP) { if(message_id == P5_VENDOR_EXT_RSP) {
*msg_size = sizeof(vendor_ext_p5_rsp); *msg_size = sizeof(vendor_ext_p5_rsp);
return (nfapi_p4_p5_message_header_t*)malloc(sizeof(vendor_ext_p5_rsp)); return (nfapi_p4_p5_message_header_t *)malloc(sizeof(vendor_ext_p5_rsp));
} }
return 0; return 0;
} }
void vnf_deallocate_p4_p5_vendor_ext(nfapi_p4_p5_message_header_t* header) { void vnf_deallocate_p4_p5_vendor_ext(nfapi_p4_p5_message_header_t *header) {
free(header); free(header);
} }
nfapi_vnf_config_t *config = 0; nfapi_vnf_config_t *config = 0;
void vnf_start_thread(void* ptr) { void vnf_start_thread(void *ptr) {
NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] VNF NFAPI thread - nfapi_vnf_start()%s\n", __FUNCTION__); NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] VNF NFAPI thread - nfapi_vnf_start()%s\n", __FUNCTION__);
pthread_setname_np(pthread_self(), "VNF"); pthread_setname_np(pthread_self(), "VNF");
config = (nfapi_vnf_config_t *)ptr;
config = (nfapi_vnf_config_t*)ptr;
nfapi_vnf_start(config); nfapi_vnf_start(config);
} }
static vnf_info vnf; static vnf_info vnf;
extern uint8_t nfapi_mode; extern uint8_t nfapi_mode;
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
void configure_nfapi_vnf(char *vnf_addr, int vnf_p5_port) void configure_nfapi_vnf(char *vnf_addr, int vnf_p5_port) {
{
nfapi_mode = 2; nfapi_mode = 2;
memset(&vnf, 0, sizeof(vnf)); memset(&vnf, 0, sizeof(vnf));
memset(vnf.p7_vnfs, 0, sizeof(vnf.p7_vnfs)); memset(vnf.p7_vnfs, 0, sizeof(vnf.p7_vnfs));
vnf.p7_vnfs[0].timing_window = 32; vnf.p7_vnfs[0].timing_window = 32;
vnf.p7_vnfs[0].periodic_timing_enabled = 1; vnf.p7_vnfs[0].periodic_timing_enabled = 1;
vnf.p7_vnfs[0].aperiodic_timing_enabled = 0; vnf.p7_vnfs[0].aperiodic_timing_enabled = 0;
vnf.p7_vnfs[0].periodic_timing_period = 10; vnf.p7_vnfs[0].periodic_timing_period = 10;
vnf.p7_vnfs[0].config = nfapi_vnf_p7_config_create(); vnf.p7_vnfs[0].config = nfapi_vnf_p7_config_create();
NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] %s() vnf.p7_vnfs[0].config:%p VNF ADDRESS:%s:%d\n", __FUNCTION__, vnf.p7_vnfs[0].config, vnf_addr, vnf_p5_port); NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] %s() vnf.p7_vnfs[0].config:%p VNF ADDRESS:%s:%d\n", __FUNCTION__, vnf.p7_vnfs[0].config, vnf_addr, vnf_p5_port);
strcpy(vnf.p7_vnfs[0].local_addr, vnf_addr); strcpy(vnf.p7_vnfs[0].local_addr, vnf_addr);
vnf.p7_vnfs[0].local_port = 50001; vnf.p7_vnfs[0].local_port = 50001;
vnf.p7_vnfs[0].mac = (mac_t*)malloc(sizeof(mac_t)); vnf.p7_vnfs[0].mac = (mac_t *)malloc(sizeof(mac_t));
nfapi_vnf_config_t *config = nfapi_vnf_config_create();
nfapi_vnf_config_t* config = nfapi_vnf_config_create();
config->malloc = malloc; config->malloc = malloc;
config->free = free; config->free = free;
config->trace = &vnf_trace; config->trace = &vnf_trace;
config->vnf_p5_port = vnf_p5_port; config->vnf_p5_port = vnf_p5_port;
config->vnf_ipv4 = 1; config->vnf_ipv4 = 1;
config->vnf_ipv6 = 0; config->vnf_ipv6 = 0;
config->pnf_list = 0; config->pnf_list = 0;
config->phy_list = 0; config->phy_list = 0;
config->pnf_connection_indication = &pnf_connection_indication_cb; config->pnf_connection_indication = &pnf_connection_indication_cb;
config->pnf_disconnect_indication = &pnf_disconnection_indication_cb; config->pnf_disconnect_indication = &pnf_disconnection_indication_cb;
config->pnf_param_resp = &pnf_param_resp_cb; config->pnf_param_resp = &pnf_param_resp_cb;
...@@ -1088,33 +937,26 @@ void configure_nfapi_vnf(char *vnf_addr, int vnf_p5_port) ...@@ -1088,33 +937,26 @@ void configure_nfapi_vnf(char *vnf_addr, int vnf_p5_port)
config->config_resp = &config_resp_cb; config->config_resp = &config_resp_cb;
config->start_resp = &start_resp_cb; config->start_resp = &start_resp_cb;
config->vendor_ext = &vendor_ext_cb; config->vendor_ext = &vendor_ext_cb;
config->user_data = &vnf; config->user_data = &vnf;
// To allow custom vendor extentions to be added to nfapi // To allow custom vendor extentions to be added to nfapi
config->codec_config.unpack_vendor_extension_tlv = &vnf_unpack_vendor_extension_tlv; config->codec_config.unpack_vendor_extension_tlv = &vnf_unpack_vendor_extension_tlv;
config->codec_config.pack_vendor_extension_tlv = &vnf_pack_vendor_extension_tlv; config->codec_config.pack_vendor_extension_tlv = &vnf_pack_vendor_extension_tlv;
config->codec_config.unpack_p4_p5_vendor_extension = &vnf_unpack_p4_p5_vendor_extension; config->codec_config.unpack_p4_p5_vendor_extension = &vnf_unpack_p4_p5_vendor_extension;
config->codec_config.pack_p4_p5_vendor_extension = &vnf_pack_p4_p5_vendor_extension; config->codec_config.pack_p4_p5_vendor_extension = &vnf_pack_p4_p5_vendor_extension;
config->allocate_p4_p5_vendor_ext = &vnf_allocate_p4_p5_vendor_ext; config->allocate_p4_p5_vendor_ext = &vnf_allocate_p4_p5_vendor_ext;
config->deallocate_p4_p5_vendor_ext = &vnf_deallocate_p4_p5_vendor_ext; config->deallocate_p4_p5_vendor_ext = &vnf_deallocate_p4_p5_vendor_ext;
config->codec_config.allocate = &vnf_allocate; config->codec_config.allocate = &vnf_allocate;
config->codec_config.deallocate = &vnf_deallocate; config->codec_config.deallocate = &vnf_deallocate;
NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Creating VNF NFAPI start thread %s\n", __FUNCTION__); NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Creating VNF NFAPI start thread %s\n", __FUNCTION__);
pthread_create(&vnf_start_pthread, NULL, (void*)&vnf_start_thread, config); pthread_create(&vnf_start_pthread, NULL, (void *)&vnf_start_thread, config);
NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Created VNF NFAPI start thread %s\n", __FUNCTION__); NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Created VNF NFAPI start thread %s\n", __FUNCTION__);
} }
int oai_nfapi_dl_config_req(nfapi_dl_config_request_t *dl_config_req) int oai_nfapi_dl_config_req(nfapi_dl_config_request_t *dl_config_req) {
{
nfapi_vnf_p7_config_t *p7_config = vnf.p7_vnfs[0].config; nfapi_vnf_p7_config_t *p7_config = vnf.p7_vnfs[0].config;
dl_config_req->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!! dl_config_req->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!!
dl_config_req->header.message_id = NFAPI_DL_CONFIG_REQUEST; dl_config_req->header.message_id = NFAPI_DL_CONFIG_REQUEST;
int retval = nfapi_vnf_p7_dl_config_req(p7_config, dl_config_req); int retval = nfapi_vnf_p7_dl_config_req(p7_config, dl_config_req);
dl_config_req->dl_config_request_body.number_pdcch_ofdm_symbols = 1; dl_config_req->dl_config_request_body.number_pdcch_ofdm_symbols = 1;
dl_config_req->dl_config_request_body.number_dci = 0; dl_config_req->dl_config_request_body.number_dci = 0;
dl_config_req->dl_config_request_body.number_pdu = 0; dl_config_req->dl_config_request_body.number_pdu = 0;
...@@ -1123,35 +965,31 @@ int oai_nfapi_dl_config_req(nfapi_dl_config_request_t *dl_config_req) ...@@ -1123,35 +965,31 @@ int oai_nfapi_dl_config_req(nfapi_dl_config_request_t *dl_config_req)
if (retval!=0) { if (retval!=0) {
LOG_E(PHY, "%s() Problem sending retval:%d\n", __FUNCTION__, retval); LOG_E(PHY, "%s() Problem sending retval:%d\n", __FUNCTION__, retval);
} }
return retval; return retval;
} }
int oai_nfapi_tx_req(nfapi_tx_request_t *tx_req) int oai_nfapi_tx_req(nfapi_tx_request_t *tx_req) {
{
nfapi_vnf_p7_config_t *p7_config = vnf.p7_vnfs[0].config; nfapi_vnf_p7_config_t *p7_config = vnf.p7_vnfs[0].config;
tx_req->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!! tx_req->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!!
tx_req->header.message_id = NFAPI_TX_REQUEST; tx_req->header.message_id = NFAPI_TX_REQUEST;
//LOG_D(PHY, "[VNF] %s() TX_REQ sfn_sf:%d number_of_pdus:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(tx_req->sfn_sf), tx_req->tx_request_body.number_of_pdus); //LOG_D(PHY, "[VNF] %s() TX_REQ sfn_sf:%d number_of_pdus:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(tx_req->sfn_sf), tx_req->tx_request_body.number_of_pdus);
int retval = nfapi_vnf_p7_tx_req(p7_config, tx_req); int retval = nfapi_vnf_p7_tx_req(p7_config, tx_req);
if (retval!=0) { if (retval!=0) {
LOG_E(PHY, "%s() Problem sending retval:%d\n", __FUNCTION__, retval); LOG_E(PHY, "%s() Problem sending retval:%d\n", __FUNCTION__, retval);
} else { } else {
tx_req->tx_request_body.number_of_pdus = 0; tx_req->tx_request_body.number_of_pdus = 0;
} }
return retval; return retval;
} }
int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req) { int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req) {
nfapi_vnf_p7_config_t *p7_config = vnf.p7_vnfs[0].config; nfapi_vnf_p7_config_t *p7_config = vnf.p7_vnfs[0].config;
hi_dci0_req->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!! hi_dci0_req->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!!
hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST; hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST;
//LOG_D(PHY, "[VNF] %s() HI_DCI0_REQ sfn_sf:%d dci:%d hi:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(hi_dci0_req->sfn_sf), hi_dci0_req->hi_dci0_request_body.number_of_dci, hi_dci0_req->hi_dci0_request_body.number_of_hi); //LOG_D(PHY, "[VNF] %s() HI_DCI0_REQ sfn_sf:%d dci:%d hi:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(hi_dci0_req->sfn_sf), hi_dci0_req->hi_dci0_request_body.number_of_dci, hi_dci0_req->hi_dci0_request_body.number_of_hi);
int retval = nfapi_vnf_p7_hi_dci0_req(p7_config, hi_dci0_req); int retval = nfapi_vnf_p7_hi_dci0_req(p7_config, hi_dci0_req);
if (retval!=0) { if (retval!=0) {
...@@ -1160,19 +998,16 @@ int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req) { ...@@ -1160,19 +998,16 @@ int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req) {
hi_dci0_req->hi_dci0_request_body.number_of_hi = 0; hi_dci0_req->hi_dci0_request_body.number_of_hi = 0;
hi_dci0_req->hi_dci0_request_body.number_of_dci = 0; hi_dci0_req->hi_dci0_request_body.number_of_dci = 0;
} }
return retval; return retval;
} }
int oai_nfapi_ul_config_req(nfapi_ul_config_request_t *ul_config_req) { int oai_nfapi_ul_config_req(nfapi_ul_config_request_t *ul_config_req) {
nfapi_vnf_p7_config_t *p7_config = vnf.p7_vnfs[0].config; nfapi_vnf_p7_config_t *p7_config = vnf.p7_vnfs[0].config;
ul_config_req->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!! ul_config_req->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!!
ul_config_req->header.message_id = NFAPI_UL_CONFIG_REQUEST; ul_config_req->header.message_id = NFAPI_UL_CONFIG_REQUEST;
//LOG_D(PHY, "[VNF] %s() header message_id:%02x\n", __FUNCTION__, ul_config_req->header.message_id); //LOG_D(PHY, "[VNF] %s() header message_id:%02x\n", __FUNCTION__, ul_config_req->header.message_id);
//LOG_D(PHY, "[VNF] %s() UL_CONFIG sfn_sf:%d PDUs:%d rach_prach_frequency_resources:%d srs_present:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ul_config_req->sfn_sf), ul_config_req->ul_config_request_body.number_of_pdus, ul_config_req->ul_config_request_body.rach_prach_frequency_resources, ul_config_req->ul_config_request_body.srs_present); //LOG_D(PHY, "[VNF] %s() UL_CONFIG sfn_sf:%d PDUs:%d rach_prach_frequency_resources:%d srs_present:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ul_config_req->sfn_sf), ul_config_req->ul_config_request_body.number_of_pdus, ul_config_req->ul_config_request_body.rach_prach_frequency_resources, ul_config_req->ul_config_request_body.srs_present);
int retval = nfapi_vnf_p7_ul_config_req(p7_config, ul_config_req); int retval = nfapi_vnf_p7_ul_config_req(p7_config, ul_config_req);
if (retval!=0) { if (retval!=0) {
...@@ -1183,5 +1018,6 @@ int oai_nfapi_ul_config_req(nfapi_ul_config_request_t *ul_config_req) { ...@@ -1183,5 +1018,6 @@ int oai_nfapi_ul_config_req(nfapi_ul_config_request_t *ul_config_req) {
ul_config_req->ul_config_request_body.rach_prach_frequency_resources = 0; ul_config_req->ul_config_request_body.rach_prach_frequency_resources = 0;
ul_config_req->ul_config_request_body.srs_present = 0; ul_config_req->ul_config_request_body.srs_present = 0;
} }
return retval; return retval;
} }
...@@ -34,11 +34,11 @@ ...@@ -34,11 +34,11 @@
#include "log_extern.h" #include "log_extern.h"
#include "assertions.h" #include "assertions.h"
#if defined(ENABLE_ITTI) #if defined(ENABLE_ITTI)
# include "intertask_interface.h" #include "intertask_interface.h"
# if defined(ENABLE_USE_MME) #if defined(ENABLE_USE_MME)
# include "s1ap_eNB.h" #include "s1ap_eNB.h"
# include "sctp_eNB_task.h" #include "sctp_eNB_task.h"
# endif #endif
#endif #endif
#include "SystemInformationBlockType2.h" #include "SystemInformationBlockType2.h"
...@@ -56,11 +56,10 @@ ...@@ -56,11 +56,10 @@
void RCconfig_NbIoTL1(void) { void RCconfig_NbIoTL1(void) {
paramdef_t NbIoT_L1_Params[] = L1PARAMS_DESC; paramdef_t NbIoT_L1_Params[] = L1PARAMS_DESC;
paramlist_def_t NbIoT_L1_ParamList = {NBIOT_L1LIST_CONFIG_STRING,NULL,0}; paramlist_def_t NbIoT_L1_ParamList = {NBIOT_L1LIST_CONFIG_STRING,NULL,0};
/* No component carrier for NbIoT, ignore number of CC */
/* No component carrier for NbIoT, ignore number of CC */ // NbIoT_L1_Params[L1_CC_IDX ].paramflags = PARAMFLAG_DONOTREAD;
// NbIoT_L1_Params[L1_CC_IDX ].paramflags = PARAMFLAG_DONOTREAD;
config_getlist( &NbIoT_L1_ParamList,NbIoT_L1_Params,sizeof(NbIoT_L1_Params)/sizeof(paramdef_t), NULL); config_getlist( &NbIoT_L1_ParamList,NbIoT_L1_Params,sizeof(NbIoT_L1_Params)/sizeof(paramdef_t), NULL);
if (NbIoT_L1_ParamList.numelt > 0) { if (NbIoT_L1_ParamList.numelt > 0) {
if (RC.L1_NB_IoT == NULL) { if (RC.L1_NB_IoT == NULL) {
RC.L1_NB_IoT = (PHY_VARS_eNB_NB_IoT **)malloc(RC.nb_nb_iot_L1_inst*sizeof(PHY_VARS_eNB_NB_IoT *)); RC.L1_NB_IoT = (PHY_VARS_eNB_NB_IoT **)malloc(RC.nb_nb_iot_L1_inst*sizeof(PHY_VARS_eNB_NB_IoT *));
...@@ -68,17 +67,15 @@ void RCconfig_NbIoTL1(void) { ...@@ -68,17 +67,15 @@ void RCconfig_NbIoTL1(void) {
memset(RC.L1_NB_IoT,0,RC.nb_nb_iot_L1_inst*sizeof(PHY_VARS_eNB_NB_IoT *)); memset(RC.L1_NB_IoT,0,RC.nb_nb_iot_L1_inst*sizeof(PHY_VARS_eNB_NB_IoT *));
} }
for(int j = 0; j <NbIoT_L1_ParamList.numelt ; j++) { for(int j = 0; j <NbIoT_L1_ParamList.numelt ; j++) {
if (RC.L1_NB_IoT[j] == NULL) { if (RC.L1_NB_IoT[j] == NULL) {
RC.L1_NB_IoT[j] = (PHY_VARS_eNB_NB_IoT *)malloc(sizeof(PHY_VARS_eNB_NB_IoT)); RC.L1_NB_IoT[j] = (PHY_VARS_eNB_NB_IoT *)malloc(sizeof(PHY_VARS_eNB_NB_IoT));
LOG_I(PHY,"RC.L1_NB_IoT[%d] = %p\n",j,RC.L1_NB_IoT[j]); LOG_I(PHY,"RC.L1_NB_IoT[%d] = %p\n",j,RC.L1_NB_IoT[j]);
memset(RC.L1_NB_IoT[j],0,sizeof(PHY_VARS_eNB_NB_IoT)); memset(RC.L1_NB_IoT[j],0,sizeof(PHY_VARS_eNB_NB_IoT));
} }
if (strcmp(*(NbIoT_L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "local_mac") == 0) {
} if (strcmp(*(NbIoT_L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "local_mac") == 0) {
else if (strcmp(*(NbIoT_L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "nfapi") == 0) { } else if (strcmp(*(NbIoT_L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "nfapi") == 0) {
RC.L1_NB_IoT[j]->eth_params_n.local_if_name = strdup(*(NbIoT_L1_ParamList.paramarray[j][L1_LOCAL_N_IF_NAME_IDX].strptr)); RC.L1_NB_IoT[j]->eth_params_n.local_if_name = strdup(*(NbIoT_L1_ParamList.paramarray[j][L1_LOCAL_N_IF_NAME_IDX].strptr));
RC.L1_NB_IoT[j]->eth_params_n.my_addr = strdup(*(NbIoT_L1_ParamList.paramarray[j][L1_LOCAL_N_ADDRESS_IDX].strptr)); RC.L1_NB_IoT[j]->eth_params_n.my_addr = strdup(*(NbIoT_L1_ParamList.paramarray[j][L1_LOCAL_N_ADDRESS_IDX].strptr));
RC.L1_NB_IoT[j]->eth_params_n.remote_addr = strdup(*(NbIoT_L1_ParamList.paramarray[j][L1_REMOTE_N_ADDRESS_IDX].strptr)); RC.L1_NB_IoT[j]->eth_params_n.remote_addr = strdup(*(NbIoT_L1_ParamList.paramarray[j][L1_REMOTE_N_ADDRESS_IDX].strptr));
...@@ -87,11 +84,10 @@ void RCconfig_NbIoTL1(void) { ...@@ -87,11 +84,10 @@ void RCconfig_NbIoTL1(void) {
RC.L1_NB_IoT[j]->eth_params_n.my_portd = *(NbIoT_L1_ParamList.paramarray[j][L1_LOCAL_N_PORTD_IDX].iptr); RC.L1_NB_IoT[j]->eth_params_n.my_portd = *(NbIoT_L1_ParamList.paramarray[j][L1_LOCAL_N_PORTD_IDX].iptr);
RC.L1_NB_IoT[j]->eth_params_n.remote_portd = *(NbIoT_L1_ParamList.paramarray[j][L1_REMOTE_N_PORTD_IDX].iptr); RC.L1_NB_IoT[j]->eth_params_n.remote_portd = *(NbIoT_L1_ParamList.paramarray[j][L1_REMOTE_N_PORTD_IDX].iptr);
RC.L1_NB_IoT[j]->eth_params_n.transp_preference = ETH_UDP_MODE; RC.L1_NB_IoT[j]->eth_params_n.transp_preference = ETH_UDP_MODE;
} } else { // other midhaul
else { // other midhaul
} }
}// j=0..num_inst }// j=0..num_inst
printf("Initializing northbound interface for NB-IoT L1\n"); printf("Initializing northbound interface for NB-IoT L1\n");
l1_north_init_NB_IoT(); l1_north_init_NB_IoT();
} else { } else {
...@@ -100,26 +96,18 @@ void RCconfig_NbIoTL1(void) { ...@@ -100,26 +96,18 @@ void RCconfig_NbIoTL1(void) {
} }
void RCconfig_NbIoTmacrlc(void) { void RCconfig_NbIoTmacrlc(void) {
paramdef_t NbIoT_MacRLC_Params[] = MACRLCPARAMS_DESC; paramdef_t NbIoT_MacRLC_Params[] = MACRLCPARAMS_DESC;
paramlist_def_t NbIoT_MacRLC_ParamList = {NBIOT_MACRLCLIST_CONFIG_STRING,NULL,0}; paramlist_def_t NbIoT_MacRLC_ParamList = {NBIOT_MACRLCLIST_CONFIG_STRING,NULL,0};
/* No component carrier for NbIoT, ignore number of CC */
// NbIoT_MacRLC_Params[MACRLC_CC_IDX ].paramflags = PARAMFLAG_DONOTREAD;
/* No component carrier for NbIoT, ignore number of CC */
// NbIoT_MacRLC_Params[MACRLC_CC_IDX ].paramflags = PARAMFLAG_DONOTREAD;
config_getlist( &NbIoT_MacRLC_ParamList,NbIoT_MacRLC_Params,sizeof(NbIoT_MacRLC_Params)/sizeof(paramdef_t), NULL); config_getlist( &NbIoT_MacRLC_ParamList,NbIoT_MacRLC_Params,sizeof(NbIoT_MacRLC_Params)/sizeof(paramdef_t), NULL);
if ( NbIoT_MacRLC_ParamList.numelt > 0) { if ( NbIoT_MacRLC_ParamList.numelt > 0) {
mac_top_init_eNB_NB_IoT(); mac_top_init_eNB_NB_IoT();
for (int j=0;j<RC.nb_nb_iot_macrlc_inst;j++) {
for (int j=0; j<RC.nb_nb_iot_macrlc_inst; j++) {
if (strcmp(*(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_N_PREFERENCE_IDX].strptr), "local_RRC") == 0) { if (strcmp(*(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_N_PREFERENCE_IDX].strptr), "local_RRC") == 0) {
// check number of instances is same as RRC/PDCP // check number of instances is same as RRC/PDCP
} else if (strcmp(*(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_N_PREFERENCE_IDX].strptr), "cudu") == 0) { } else if (strcmp(*(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_N_PREFERENCE_IDX].strptr), "cudu") == 0) {
RC.nb_iot_mac[j]->eth_params_n.local_if_name = strdup(*(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_IF_NAME_IDX].strptr)); RC.nb_iot_mac[j]->eth_params_n.local_if_name = strdup(*(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_IF_NAME_IDX].strptr));
RC.nb_iot_mac[j]->eth_params_n.my_addr = strdup(*(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_ADDRESS_IDX].strptr)); RC.nb_iot_mac[j]->eth_params_n.my_addr = strdup(*(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_ADDRESS_IDX].strptr));
...@@ -134,8 +122,6 @@ void RCconfig_NbIoTmacrlc(void) { ...@@ -134,8 +122,6 @@ void RCconfig_NbIoTmacrlc(void) {
} }
if (strcmp(*(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_S_PREFERENCE_IDX].strptr), "local_L1") == 0) { if (strcmp(*(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_S_PREFERENCE_IDX].strptr), "local_L1") == 0) {
} else if (strcmp(*(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_S_PREFERENCE_IDX].strptr), "nfapi") == 0) { } else if (strcmp(*(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_S_PREFERENCE_IDX].strptr), "nfapi") == 0) {
RC.nb_iot_mac[j]->eth_params_s.local_if_name = strdup(*(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_S_IF_NAME_IDX].strptr)); RC.nb_iot_mac[j]->eth_params_s.local_if_name = strdup(*(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_S_IF_NAME_IDX].strptr));
RC.nb_iot_mac[j]->eth_params_s.my_addr = strdup(*(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_S_ADDRESS_IDX].strptr)); RC.nb_iot_mac[j]->eth_params_s.my_addr = strdup(*(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_S_ADDRESS_IDX].strptr));
...@@ -159,30 +145,30 @@ void RCconfig_NbIoTmacrlc(void) { ...@@ -159,30 +145,30 @@ void RCconfig_NbIoTmacrlc(void) {
int RCconfig_NbIoTRRC(MessageDef *msg_p, int nbiotrrc_id,eNB_RRC_INST_NB_IoT *nbiotrrc) { int RCconfig_NbIoTRRC(MessageDef *msg_p, int nbiotrrc_id,eNB_RRC_INST_NB_IoT *nbiotrrc) {
char instprefix[MAX_OPTNAME_SIZE*3 + 32]; char instprefix[MAX_OPTNAME_SIZE*3 + 32];
checkedparam_t NBIoTCheckParams[] = NBIOT_RRCPARAMS_CHECK_DESC_0_14;
checkedparam_t NBIoTCheckParamsB[] = NBIOT_RRCPARAMS_CHECK_DESC_15_end;
checkedparam_t NBIoTCheckParams[] = NBIOT_RRCPARAMS_CHECK_DESC;
paramdef_t NBIoTParams[] = NBIOTRRCPARAMS_DESC; paramdef_t NBIoTParams[] = NBIOTRRCPARAMS_DESC;
paramdef_t NBIoTPrachParams[] = NBIOTRRC_NPRACH_PARAMS_DESC; paramdef_t NBIoTPrachParams[] = NBIOTRRC_NPRACH_PARAMS_DESC;
checkedparam_t NBIoTPrachCheckParams[] = NBIOT_RRCLIST_NPRACHPARAMSCHECK_DESC; checkedparam_t NBIoTPrachCheckParams[] = NBIOT_RRCLIST_NPRACHPARAMSCHECK_DESC;
paramdef_t NBIoTRRCRefParams[] = NBIOTRRCPARAMS_RRCREF_DESC; paramdef_t NBIoTRRCRefParams[] = NBIOTRRCPARAMS_RRCREF_DESC;
paramdef_t NBIoTLteCCParams[] = NBIOT_LTECCPARAMS_DESC; paramdef_t NBIoTLteCCParams[] = NBIOT_LTECCPARAMS_DESC;
checkedparam_t NBIoTLteCCCheckParams[] = NBIOT_LTECCPARAMS_CHECK_DESC; checkedparam_t NBIoTLteCCCheckParams[] = NBIOT_LTECCPARAMS_CHECK_DESC;
/* map parameter checking array instances to parameter definition array instances */
/* map parameter checking array instances to parameter definition array instances */
for (int i=0; (i<sizeof(NBIoTParams)/sizeof(paramdef_t)) && (i<sizeof(NBIoTCheckParams)/sizeof(checkedparam_t)); i++ ) { for (int i=0; (i<sizeof(NBIoTParams)/sizeof(paramdef_t)) && (i<sizeof(NBIoTCheckParams)/sizeof(checkedparam_t)); i++ ) {
NBIoTParams[i].chkPptr = &(NBIoTCheckParams[i]); NBIoTParams[i].chkPptr = &(NBIoTCheckParams[i]);
} }
for (int i=0; (i<sizeof(NBIoTParams)/sizeof(paramdef_t)) && (i<sizeof(NBIoTCheckParamsB)/sizeof(checkedparam_t)); i++ ) {
NBIoTParams[i+15].chkPptr = &(NBIoTCheckParamsB[i]);
}
for (int i=0; (i<sizeof(NBIoTPrachParams)/sizeof(paramdef_t)) && (i<sizeof(NBIoTPrachCheckParams)/sizeof(checkedparam_t)); i++ ) { for (int i=0; (i<sizeof(NBIoTPrachParams)/sizeof(paramdef_t)) && (i<sizeof(NBIoTPrachCheckParams)/sizeof(checkedparam_t)); i++ ) {
NBIoTPrachParams[i].chkPptr = &(NBIoTPrachCheckParams[i]); NBIoTPrachParams[i].chkPptr = &(NBIoTPrachCheckParams[i]);
} }
/* brut force itti message fields assignment, to be redesigned with itti replacement */ /* brut force itti message fields assignment, to be redesigned with itti replacement */
NBIoTParams[NBIOT_RACH_RARESPONSEWINDOWSIZE_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).rach_raResponseWindowSize_NB); NBIoTParams[NBIOT_RACH_RARESPONSEWINDOWSIZE_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).rach_raResponseWindowSize_NB);
NBIoTParams[NBIOT_RACH_MACCONTENTIONRESOLUTIONTIMER_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).rach_macContentionResolutionTimer_NB); NBIoTParams[NBIOT_RACH_MACCONTENTIONRESOLUTIONTIMER_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).rach_macContentionResolutionTimer_NB);
NBIoTParams[NBIOT_RACH_POWERRAMPINGSTEP_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).rach_powerRampingStep_NB); NBIoTParams[NBIOT_RACH_POWERRAMPINGSTEP_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).rach_powerRampingStep_NB);
...@@ -192,23 +178,16 @@ int RCconfig_NbIoTRRC(MessageDef *msg_p, int nbiotrrc_id,eNB_RRC_INST_NB_IoT *nb ...@@ -192,23 +178,16 @@ int RCconfig_NbIoTRRC(MessageDef *msg_p, int nbiotrrc_id,eNB_RRC_INST_NB_IoT *nb
NBIoTParams[NBIOT_PCCH_DEFAULTPAGINGCYCLE_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).pcch_defaultPagingCycle_NB); NBIoTParams[NBIOT_PCCH_DEFAULTPAGINGCYCLE_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).pcch_defaultPagingCycle_NB);
NBIoTParams[NBIOT_NPRACH_CP_LENGTH_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).nprach_CP_Length); NBIoTParams[NBIOT_NPRACH_CP_LENGTH_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).nprach_CP_Length);
NBIoTParams[NBIOT_NPRACH_RSRP_RANGE_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).nprach_rsrp_range); NBIoTParams[NBIOT_NPRACH_RSRP_RANGE_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).nprach_rsrp_range);
NBIoTParams[NBIOT_MAXNUMPREAMBLEATTEMPTCE_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).maxNumPreambleAttemptCE_NB); NBIoTParams[NBIOT_MAXNUMPREAMBLEATTEMPTCE_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).maxNumPreambleAttemptCE_NB);
NBIoTParams[NBIOT_NPDSCH_NRS_POWER_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).npdsch_nrs_Power); NBIoTParams[NBIOT_NPDSCH_NRS_POWER_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).npdsch_nrs_Power);
NBIoTParams[NBIOT_NPUSCH_ACK_NACK_NUMREPETITIONS_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p). npusch_ack_nack_numRepetitions_NB); NBIoTParams[NBIOT_NPUSCH_ACK_NACK_NUMREPETITIONS_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p). npusch_ack_nack_numRepetitions_NB);
NBIoTParams[NBIOT_NPUSCH_SRS_SUBFRAMECONFIG_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p). npusch_srs_SubframeConfig_NB); NBIoTParams[NBIOT_NPUSCH_SRS_SUBFRAMECONFIG_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p). npusch_srs_SubframeConfig_NB);
NBIoTParams[NBIOT_NPUSCH_THREETONE_CYCLICSHIFT_R13_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).npusch_threeTone_CyclicShift_r13); NBIoTParams[NBIOT_NPUSCH_THREETONE_CYCLICSHIFT_R13_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).npusch_threeTone_CyclicShift_r13);
NBIoTParams[NBIOT_NPUSCH_SIXTONE_CYCLICSHIFT_R13_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).npusch_sixTone_CyclicShift_r13); NBIoTParams[NBIOT_NPUSCH_SIXTONE_CYCLICSHIFT_R13_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).npusch_sixTone_CyclicShift_r13);
NBIoTParams[NBIOT_NPUSCH_GROUPASSIGNMENTNPUSCH_R13_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).npusch_groupAssignmentNPUSCH_r13); NBIoTParams[NBIOT_NPUSCH_GROUPASSIGNMENTNPUSCH_R13_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).npusch_groupAssignmentNPUSCH_r13);
NBIoTParams[NBIOT_DL_GAPTHRESHOLD_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).dl_GapThreshold_NB); NBIoTParams[NBIOT_DL_GAPTHRESHOLD_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).dl_GapThreshold_NB);
NBIoTParams[NBIOT_DL_GAPPERIODICITY_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).dl_GapPeriodicity_NB); NBIoTParams[NBIOT_DL_GAPPERIODICITY_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).dl_GapPeriodicity_NB);
NBIoTParams[NBIOT_NPUSCH_P0_NOMINALNPUSCH_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).npusch_p0_NominalNPUSCH); NBIoTParams[NBIOT_NPUSCH_P0_NOMINALNPUSCH_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).npusch_p0_NominalNPUSCH);
NBIoTParams[NBIOT_DELTAPREAMBLEMSG3_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).deltaPreambleMsg3); NBIoTParams[NBIOT_DELTAPREAMBLEMSG3_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).deltaPreambleMsg3);
NBIoTParams[NBIOT_UE_TIMERSANDCONSTANTS_T300_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t300_NB); NBIoTParams[NBIOT_UE_TIMERSANDCONSTANTS_T300_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t300_NB);
NBIoTParams[NBIOT_UE_TIMERSANDCONSTANTS_T301_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t301_NB); NBIoTParams[NBIOT_UE_TIMERSANDCONSTANTS_T301_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t301_NB);
...@@ -216,14 +195,13 @@ int RCconfig_NbIoTRRC(MessageDef *msg_p, int nbiotrrc_id,eNB_RRC_INST_NB_IoT *nb ...@@ -216,14 +195,13 @@ int RCconfig_NbIoTRRC(MessageDef *msg_p, int nbiotrrc_id,eNB_RRC_INST_NB_IoT *nb
NBIoTParams[NBIOT_UE_TIMERSANDCONSTANTS_T311_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t311_NB); NBIoTParams[NBIOT_UE_TIMERSANDCONSTANTS_T311_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t311_NB);
NBIoTParams[NBIOT_UE_TIMERSANDCONSTANTS_N310_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_n310_NB); NBIoTParams[NBIOT_UE_TIMERSANDCONSTANTS_N310_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_n310_NB);
NBIoTParams[NBIOT_UE_TIMERSANDCONSTANTS_N311_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_n311_NB); NBIoTParams[NBIOT_UE_TIMERSANDCONSTANTS_N311_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_n311_NB);
sprintf(instprefix, NBIOT_RRCLIST_CONFIG_STRING ".[%i]",nbiotrrc_id); sprintf(instprefix, NBIOT_RRCLIST_CONFIG_STRING ".[%i]",nbiotrrc_id);
config_get( NBIoTParams,sizeof(NBIoTParams)/sizeof(paramdef_t),instprefix); config_get( NBIoTParams,sizeof(NBIoTParams)/sizeof(paramdef_t),instprefix);
NBIOTRRC_CONFIGURATION_REQ (msg_p).nprach_SubcarrierMSG3_RangeStart = config_get_processedint( &(NBIoTParams[NBIOT_NPRACH_SUBCARRIERMSG3_RANGESTART_IDX]) ); NBIOTRRC_CONFIGURATION_REQ (msg_p).nprach_SubcarrierMSG3_RangeStart = config_get_processedint( &(NBIoTParams[NBIOT_NPRACH_SUBCARRIERMSG3_RANGESTART_IDX]) );
NBIOTRRC_CONFIGURATION_REQ (msg_p).npusch_groupHoppingEnabled = config_get_processedint( &(NBIoTParams[NBIOT_NPUSCH_GROUPHOPPINGENABLED_IDX] ) ); NBIOTRRC_CONFIGURATION_REQ (msg_p).npusch_groupHoppingEnabled = config_get_processedint( &(NBIoTParams[NBIOT_NPUSCH_GROUPHOPPINGENABLED_IDX] ) );
NBIOTRRC_CONFIGURATION_REQ (msg_p).dl_GapDurationCoeff_NB = config_get_processedint( &(NBIoTParams[NBIOT_DL_GAPDURATIONCOEFF_NB_IDX] ) ); NBIOTRRC_CONFIGURATION_REQ (msg_p).dl_GapDurationCoeff_NB = config_get_processedint( &(NBIoTParams[NBIOT_DL_GAPDURATIONCOEFF_NB_IDX] ) );
NBIOTRRC_CONFIGURATION_REQ (msg_p).npusch_alpha = config_get_processedint( &(NBIoTParams[NBIOT_NPUSCH_ALPHA_IDX] ) ); NBIOTRRC_CONFIGURATION_REQ (msg_p).npusch_alpha = config_get_processedint( &(NBIoTParams[NBIOT_NPUSCH_ALPHA_IDX] ) );
for (int i=0; i<MAX_NUM_NBIOT_CELEVELS; i++) { for (int i=0; i<MAX_NUM_NBIOT_CELEVELS; i++) {
char *tmpptr=NULL; char *tmpptr=NULL;
NBIoTPrachParams[NBIOT_NPRACH_PERIODICITY_IDX ].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).nprach_Periodicity[i]); NBIoTPrachParams[NBIOT_NPRACH_PERIODICITY_IDX ].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).nprach_Periodicity[i]);
...@@ -238,14 +216,13 @@ int RCconfig_NbIoTRRC(MessageDef *msg_p, int nbiotrrc_id,eNB_RRC_INST_NB_IoT *nb ...@@ -238,14 +216,13 @@ int RCconfig_NbIoTRRC(MessageDef *msg_p, int nbiotrrc_id,eNB_RRC_INST_NB_IoT *nb
config_get( NBIoTPrachParams,sizeof(NBIoTPrachParams)/sizeof(paramdef_t),instprefix); config_get( NBIoTPrachParams,sizeof(NBIoTPrachParams)/sizeof(paramdef_t),instprefix);
NBIOTRRC_CONFIGURATION_REQ (msg_p).npdcch_Offset_RA[i] = config_get_processedint( &(NBIoTPrachParams[NBIOT_NPDCCH_OFFSET_RA_IDX]) ); NBIOTRRC_CONFIGURATION_REQ (msg_p).npdcch_Offset_RA[i] = config_get_processedint( &(NBIoTPrachParams[NBIOT_NPDCCH_OFFSET_RA_IDX]) );
} }
/* get the LTE RRC and CC this NB-IoT RRC instance is attached to */
/* get the LTE RRC and CC this NB-IoT RRC instance is attached to */
sprintf(instprefix, NBIOT_RRCLIST_CONFIG_STRING ".[%i]." NBIOT_LTERRCREF_CONFIG_STRING, nbiotrrc_id ); sprintf(instprefix, NBIOT_RRCLIST_CONFIG_STRING ".[%i]." NBIOT_LTERRCREF_CONFIG_STRING, nbiotrrc_id );
config_get( NBIoTRRCRefParams,sizeof(NBIoTRRCRefParams)/sizeof(paramdef_t),instprefix); config_get( NBIoTRRCRefParams,sizeof(NBIoTRRCRefParams)/sizeof(paramdef_t),instprefix);
/* read SIB1 parameters in the LTE RRC and CC sections */
/* read SIB1 parameters in the LTE RRC and CC sections */
sprintf(instprefix, ENB_CONFIG_STRING_ENB_LIST ".[%i]." ENB_CONFIG_STRING_COMPONENT_CARRIERS ".[%i]", sprintf(instprefix, ENB_CONFIG_STRING_ENB_LIST ".[%i]." ENB_CONFIG_STRING_COMPONENT_CARRIERS ".[%i]",
*(NBIoTRRCRefParams[NBIOT_RRCINST_IDX].uptr), *(NBIoTRRCRefParams[NBIOT_CCINST_IDX].uptr)); *(NBIoTRRCRefParams[NBIOT_RRCINST_IDX].uptr), *(NBIoTRRCRefParams[NBIOT_CCINST_IDX].uptr));
NBIoTLteCCParams[LTECCPARAMS_TDD_CONFIG_IDX ].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).tdd_config); NBIoTLteCCParams[LTECCPARAMS_TDD_CONFIG_IDX ].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).tdd_config);
NBIoTLteCCParams[LTECCPARAMS_TDD_CONFIG_S_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).tdd_config_s); NBIoTLteCCParams[LTECCPARAMS_TDD_CONFIG_S_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).tdd_config_s);
NBIoTLteCCParams[LTECCPARAMS_EUTRA_BAND_IDX ].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).eutra_band); NBIoTLteCCParams[LTECCPARAMS_EUTRA_BAND_IDX ].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).eutra_band);
...@@ -257,30 +234,23 @@ int RCconfig_NbIoTRRC(MessageDef *msg_p, int nbiotrrc_id,eNB_RRC_INST_NB_IoT *nb ...@@ -257,30 +234,23 @@ int RCconfig_NbIoTRRC(MessageDef *msg_p, int nbiotrrc_id,eNB_RRC_INST_NB_IoT *nb
for (int i=0; (i<sizeof(NBIoTLteCCParams)/sizeof(paramdef_t)) && (i<sizeof(NBIoTLteCCCheckParams)/sizeof(checkedparam_t)); i++ ) { for (int i=0; (i<sizeof(NBIoTLteCCParams)/sizeof(paramdef_t)) && (i<sizeof(NBIoTLteCCCheckParams)/sizeof(checkedparam_t)); i++ ) {
NBIoTLteCCParams[i].chkPptr = &(NBIoTLteCCCheckParams[i]); NBIoTLteCCParams[i].chkPptr = &(NBIoTLteCCCheckParams[i]);
} }
config_get( NBIoTLteCCParams,sizeof(NBIoTLteCCParams)/sizeof(paramdef_t),instprefix); config_get( NBIoTLteCCParams,sizeof(NBIoTLteCCParams)/sizeof(paramdef_t),instprefix);
NBIOTRRC_CONFIGURATION_REQ (msg_p).frame_type = config_get_processedint( &(NBIoTLteCCParams[LTECCPARAMS_FRAME_TYPE_IDX]) ); NBIOTRRC_CONFIGURATION_REQ (msg_p).frame_type = config_get_processedint( &(NBIoTLteCCParams[LTECCPARAMS_FRAME_TYPE_IDX]) );
NBIOTRRC_CONFIGURATION_REQ (msg_p).prefix_type = config_get_processedint( &(NBIoTLteCCParams[LTECCPARAMS_PREFIX_TYPE_IDX]) ); NBIOTRRC_CONFIGURATION_REQ (msg_p).prefix_type = config_get_processedint( &(NBIoTLteCCParams[LTECCPARAMS_PREFIX_TYPE_IDX]) );
NBIOTRRC_CONFIGURATION_REQ (msg_p).prefix_type = config_get_processedint( &(NBIoTLteCCParams[LTECCPARAMS_PREFIX_TYPE_UL_IDX]) ); NBIOTRRC_CONFIGURATION_REQ (msg_p).prefix_type = config_get_processedint( &(NBIoTLteCCParams[LTECCPARAMS_PREFIX_TYPE_UL_IDX]) );
return 0; return 0;
} }
void RCConfig_NbIoT(RAN_CONTEXT_t *RC) { void RCConfig_NbIoT(RAN_CONTEXT_t *RC) {
paramlist_def_t NbIoT_MACRLCParamList = {NBIOT_MACRLCLIST_CONFIG_STRING,NULL,0}; paramlist_def_t NbIoT_MACRLCParamList = {NBIOT_MACRLCLIST_CONFIG_STRING,NULL,0};
paramlist_def_t NbIoT_L1ParamList = {NBIOT_L1LIST_CONFIG_STRING,NULL,0}; paramlist_def_t NbIoT_L1ParamList = {NBIOT_L1LIST_CONFIG_STRING,NULL,0};
paramlist_def_t NbIoT_ParamList = {NBIOT_RRCLIST_CONFIG_STRING,NULL,0}; paramlist_def_t NbIoT_ParamList = {NBIOT_RRCLIST_CONFIG_STRING,NULL,0};
config_getlist( &NbIoT_ParamList,NULL,0,NULL); config_getlist( &NbIoT_ParamList,NULL,0,NULL);
RC->nb_nb_iot_rrc_inst = NbIoT_ParamList.numelt; RC->nb_nb_iot_rrc_inst = NbIoT_ParamList.numelt;
config_getlist( &NbIoT_MACRLCParamList,NULL,0, NULL); config_getlist( &NbIoT_MACRLCParamList,NULL,0, NULL);
RC->nb_nb_iot_macrlc_inst = NbIoT_MACRLCParamList.numelt; RC->nb_nb_iot_macrlc_inst = NbIoT_MACRLCParamList.numelt;
// Get num L1 instances // Get num L1 instances
config_getlist( &NbIoT_L1ParamList,NULL,0, NULL); config_getlist( &NbIoT_L1ParamList,NULL,0, NULL);
RC->nb_nb_iot_L1_inst = NbIoT_L1ParamList.numelt; RC->nb_nb_iot_L1_inst = NbIoT_L1ParamList.numelt;
} }
...@@ -134,16 +134,16 @@ static const eutra_bandentry_t eutra_bandtable[] = { ...@@ -134,16 +134,16 @@ static const eutra_bandentry_t eutra_bandtable[] = {
{68, 6980, 7280, 7530, 7830, 67536} {68, 6980, 7280, 7530, 7830, 67536}
}; };
uint32_t to_earfcn(int eutra_bandP, uint32_t dl_CarrierFreq, uint32_t bw)
{
#define BANDTABLE_SIZE (sizeof(eutra_bandtable)/sizeof(eutra_bandentry_t))
uint32_t to_earfcn(int eutra_bandP, uint32_t dl_CarrierFreq, uint32_t bw) {
uint32_t dl_CarrierFreq_by_100k = dl_CarrierFreq / 100000; uint32_t dl_CarrierFreq_by_100k = dl_CarrierFreq / 100000;
int bw_by_100 = bw / 100; int bw_by_100 = bw / 100;
int i; int i;
AssertFatal(eutra_bandP < 69, "eutra_band %d > 68\n", eutra_bandP); AssertFatal(eutra_bandP < 69, "eutra_band %d > 68\n", eutra_bandP);
for (i = 0; i < 69 && eutra_bandtable[i].band != eutra_bandP; i++);
for (i = 0; i < BANDTABLE_SIZE && eutra_bandtable[i].band != eutra_bandP; i++);
AssertFatal(dl_CarrierFreq_by_100k >= eutra_bandtable[i].dl_min, AssertFatal(dl_CarrierFreq_by_100k >= eutra_bandtable[i].dl_min,
"Band %d, bw %u : DL carrier frequency %u Hz < %u\n", "Band %d, bw %u : DL carrier frequency %u Hz < %u\n",
...@@ -154,22 +154,17 @@ uint32_t to_earfcn(int eutra_bandP, uint32_t dl_CarrierFreq, uint32_t bw) ...@@ -154,22 +154,17 @@ uint32_t to_earfcn(int eutra_bandP, uint32_t dl_CarrierFreq, uint32_t bw)
"Band %d, bw %u: DL carrier frequency %u Hz > %d\n", "Band %d, bw %u: DL carrier frequency %u Hz > %d\n",
eutra_bandP, bw, dl_CarrierFreq, eutra_bandP, bw, dl_CarrierFreq,
eutra_bandtable[i].dl_max - bw_by_100); eutra_bandtable[i].dl_max - bw_by_100);
return (dl_CarrierFreq_by_100k - eutra_bandtable[i].dl_min + return (dl_CarrierFreq_by_100k - eutra_bandtable[i].dl_min +
(eutra_bandtable[i].N_OFFs_DL / 10)); (eutra_bandtable[i].N_OFFs_DL / 10));
} }
uint32_t to_earfcn_DL(int eutra_bandP, long long int dl_CarrierFreq, uint32_t bw) uint32_t to_earfcn_DL(int eutra_bandP, long long int dl_CarrierFreq, uint32_t bw) {
{
uint32_t dl_CarrierFreq_by_100k = dl_CarrierFreq / 100000; uint32_t dl_CarrierFreq_by_100k = dl_CarrierFreq / 100000;
int bw_by_100 = bw / 100; int bw_by_100 = bw / 100;
int i; int i;
AssertFatal(eutra_bandP < 69, "eutra_band %d > 68\n", eutra_bandP); AssertFatal(eutra_bandP < 69, "eutra_band %d > 68\n", eutra_bandP);
for (i = 0; i < 69 && eutra_bandtable[i].band != eutra_bandP; i++);
for (i = 0; i < BANDTABLE_SIZE && eutra_bandtable[i].band != eutra_bandP; i++);
AssertFatal(dl_CarrierFreq_by_100k >= eutra_bandtable[i].dl_min, AssertFatal(dl_CarrierFreq_by_100k >= eutra_bandtable[i].dl_min,
"Band %d, bw %u : DL carrier frequency %lld Hz < %u\n", "Band %d, bw %u : DL carrier frequency %lld Hz < %u\n",
...@@ -180,22 +175,17 @@ uint32_t to_earfcn_DL(int eutra_bandP, long long int dl_CarrierFreq, uint32_t bw ...@@ -180,22 +175,17 @@ uint32_t to_earfcn_DL(int eutra_bandP, long long int dl_CarrierFreq, uint32_t bw
"Band %d, bw %u : DL carrier frequency %lld Hz > %d\n", "Band %d, bw %u : DL carrier frequency %lld Hz > %d\n",
eutra_bandP, bw, dl_CarrierFreq, eutra_bandP, bw, dl_CarrierFreq,
eutra_bandtable[i].dl_max - bw_by_100); eutra_bandtable[i].dl_max - bw_by_100);
return (dl_CarrierFreq_by_100k - eutra_bandtable[i].dl_min + return (dl_CarrierFreq_by_100k - eutra_bandtable[i].dl_min +
(eutra_bandtable[i].N_OFFs_DL / 10)); (eutra_bandtable[i].N_OFFs_DL / 10));
} }
uint32_t to_earfcn_UL(int eutra_bandP, long long int ul_CarrierFreq, uint32_t bw) uint32_t to_earfcn_UL(int eutra_bandP, long long int ul_CarrierFreq, uint32_t bw) {
{
uint32_t ul_CarrierFreq_by_100k = ul_CarrierFreq / 100000; uint32_t ul_CarrierFreq_by_100k = ul_CarrierFreq / 100000;
int bw_by_100 = bw / 100; int bw_by_100 = bw / 100;
int i; int i;
AssertFatal(eutra_bandP < 69, "eutra_band %d > 68\n", eutra_bandP); AssertFatal(eutra_bandP < 69, "eutra_band %d > 68\n", eutra_bandP);
for (i = 0; i < 69 && eutra_bandtable[i].band != eutra_bandP; i++);
for (i = 0; i < BANDTABLE_SIZE && eutra_bandtable[i].band != eutra_bandP; i++);
AssertFatal(ul_CarrierFreq_by_100k >= eutra_bandtable[i].ul_min, AssertFatal(ul_CarrierFreq_by_100k >= eutra_bandtable[i].ul_min,
"Band %d, bw %u : UL carrier frequency %lld Hz < %u\n", "Band %d, bw %u : UL carrier frequency %lld Hz < %u\n",
...@@ -206,30 +196,26 @@ uint32_t to_earfcn_UL(int eutra_bandP, long long int ul_CarrierFreq, uint32_t bw ...@@ -206,30 +196,26 @@ uint32_t to_earfcn_UL(int eutra_bandP, long long int ul_CarrierFreq, uint32_t bw
"Band %d, bw %u : UL carrier frequency %lld Hz > %d\n", "Band %d, bw %u : UL carrier frequency %lld Hz > %d\n",
eutra_bandP, bw, ul_CarrierFreq, eutra_bandP, bw, ul_CarrierFreq,
eutra_bandtable[i].ul_max - bw_by_100); eutra_bandtable[i].ul_max - bw_by_100);
return (ul_CarrierFreq_by_100k - eutra_bandtable[i].ul_min + return (ul_CarrierFreq_by_100k - eutra_bandtable[i].ul_min +
((eutra_bandtable[i].N_OFFs_DL + 180000) / 10)); ((eutra_bandtable[i].N_OFFs_DL + 180000) / 10));
} }
uint32_t from_earfcn(int eutra_bandP, uint32_t dl_earfcn) uint32_t from_earfcn(int eutra_bandP, uint32_t dl_earfcn) {
{
int i; int i;
AssertFatal(eutra_bandP < 69, "eutra_band %d > 68\n", eutra_bandP); AssertFatal(eutra_bandP < 69, "eutra_band %d > 68\n", eutra_bandP);
for (i = 0; i < 69 && eutra_bandtable[i].band != eutra_bandP; i++);
for (i = 0; i < BANDTABLE_SIZE && eutra_bandtable[i].band != eutra_bandP; i++);
return (eutra_bandtable[i].dl_min + return (eutra_bandtable[i].dl_min +
(dl_earfcn - (eutra_bandtable[i].N_OFFs_DL / 10))) * 100000; (dl_earfcn - (eutra_bandtable[i].N_OFFs_DL / 10))) * 100000;
} }
int32_t get_uldl_offset(int eutra_bandP) int32_t get_uldl_offset(int eutra_bandP) {
{
int i; int i;
for (i = 0; i < 69 && eutra_bandtable[i].band != eutra_bandP; i++); for (i = 0; i < BANDTABLE_SIZE && eutra_bandtable[i].band != eutra_bandP; i++);
return (eutra_bandtable[i].dl_min - eutra_bandtable[i].ul_min); return (eutra_bandtable[i].dl_min - eutra_bandtable[i].ul_min);
} }
......
...@@ -51,35 +51,35 @@ ...@@ -51,35 +51,35 @@
#include "msc.h" #include "msc.h"
#include "targets/COMMON/openairinterface5g_limits.h" #include "targets/COMMON/openairinterface5g_limits.h"
#if defined(ENABLE_SECURITY) #if defined(ENABLE_SECURITY)
# include "UTIL/OSA/osa_defs.h" #include "UTIL/OSA/osa_defs.h"
#endif #endif
#if defined(ENABLE_ITTI) #if defined(ENABLE_ITTI)
# include "intertask_interface.h" #include "intertask_interface.h"
#endif #endif
#if defined(LINK_ENB_PDCP_TO_GTPV1U) #if defined(LINK_ENB_PDCP_TO_GTPV1U)
# include "gtpv1u_eNB_task.h" #include "gtpv1u_eNB_task.h"
# include "gtpv1u.h" #include "gtpv1u.h"
#endif #endif
extern int otg_enabled; extern int otg_enabled;
#if defined(ENABLE_USE_MME) #if defined(ENABLE_USE_MME)
extern uint8_t nfapi_mode; extern uint8_t nfapi_mode;
#endif #endif
#include "common/ran_context.h" #include "common/ran_context.h"
extern RAN_CONTEXT_t RC; extern RAN_CONTEXT_t RC;
hash_table_t *pdcp_coll_p = NULL; hash_table_t *pdcp_coll_p = NULL;
#ifdef MBMS_MULTICAST_OUT #ifdef MBMS_MULTICAST_OUT
# include <sys/types.h> #include <sys/types.h>
# include <sys/socket.h> #include <sys/socket.h>
# include <netinet/in.h> #include <netinet/in.h>
# include <netinet/ip.h> #include <netinet/ip.h>
# include <netinet/udp.h> #include <netinet/udp.h>
# include <unistd.h> #include <unistd.h>
static int mbms_socket = -1; static int mbms_socket = -1;
#endif #endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -91,7 +91,7 @@ static int mbms_socket = -1; ...@@ -91,7 +91,7 @@ static int mbms_socket = -1;
* code at targets/TEST/PDCP/test_pdcp.c:test_pdcp_data_req() * code at targets/TEST/PDCP/test_pdcp.c:test_pdcp_data_req()
*/ */
boolean_t pdcp_data_req( boolean_t pdcp_data_req(
protocol_ctxt_t* ctxt_pP, protocol_ctxt_t *ctxt_pP,
const srb_flag_t srb_flagP, const srb_flag_t srb_flagP,
const rb_id_t rb_idP, const rb_id_t rb_idP,
const mui_t muiP, const mui_t muiP,
...@@ -100,13 +100,12 @@ boolean_t pdcp_data_req( ...@@ -100,13 +100,12 @@ boolean_t pdcp_data_req(
unsigned char *const sdu_buffer_pP, unsigned char *const sdu_buffer_pP,
const pdcp_transmission_mode_t modeP const pdcp_transmission_mode_t modeP
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
,const uint32_t * const sourceL2Id ,const uint32_t *const sourceL2Id
,const uint32_t * const destinationL2Id ,const uint32_t *const destinationL2Id
#endif #endif
) )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
{ {
pdcp_t *pdcp_p = NULL; pdcp_t *pdcp_p = NULL;
uint8_t i = 0; uint8_t i = 0;
uint8_t pdcp_header_len = 0; uint8_t pdcp_header_len = 0;
...@@ -116,17 +115,17 @@ boolean_t pdcp_data_req( ...@@ -116,17 +115,17 @@ boolean_t pdcp_data_req(
mem_block_t *pdcp_pdu_p = NULL; mem_block_t *pdcp_pdu_p = NULL;
rlc_op_status_t rlc_status; rlc_op_status_t rlc_status;
boolean_t ret = TRUE; boolean_t ret = TRUE;
hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE;
hashtable_rc_t h_rc; hashtable_rc_t h_rc;
uint8_t rb_offset= (srb_flagP == 0) ? DTCH -1 : 0; uint8_t rb_offset= (srb_flagP == 0) ? DTCH -1 : 0;
uint16_t pdcp_uid=0; uint16_t pdcp_uid=0;
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_REQ,VCD_FUNCTION_IN); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_REQ,VCD_FUNCTION_IN);
CHECK_CTXT_ARGS(ctxt_pP); CHECK_CTXT_ARGS(ctxt_pP);
#if T_TRACER #if T_TRACER
if (ctxt_pP->enb_flag != ENB_FLAG_NO) if (ctxt_pP->enb_flag != ENB_FLAG_NO)
T(T_ENB_PDCP_DL, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->rnti), T_INT(rb_idP), T_INT(sdu_buffer_sizeP)); T(T_ENB_PDCP_DL, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->rnti), T_INT(rb_idP), T_INT(sdu_buffer_sizeP));
#endif #endif
if (sdu_buffer_sizeP == 0) { if (sdu_buffer_sizeP == 0) {
...@@ -151,7 +150,7 @@ boolean_t pdcp_data_req( ...@@ -151,7 +150,7 @@ boolean_t pdcp_data_req(
} }
key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP);
h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p);
if (h_rc != HASH_TABLE_OK) { if (h_rc != HASH_TABLE_OK) {
if (modeP != PDCP_TRANSMISSION_MODE_TRANSPARENT) { if (modeP != PDCP_TRANSMISSION_MODE_TRANSPARENT) {
...@@ -161,7 +160,7 @@ boolean_t pdcp_data_req( ...@@ -161,7 +160,7 @@ boolean_t pdcp_data_req(
ctxt_pP->configured=FALSE; ctxt_pP->configured=FALSE;
return FALSE; return FALSE;
} }
}else{ } else {
// instance for a given RB is configured // instance for a given RB is configured
ctxt_pP->configured=TRUE; ctxt_pP->configured=TRUE;
} }
...@@ -182,7 +181,7 @@ boolean_t pdcp_data_req( ...@@ -182,7 +181,7 @@ boolean_t pdcp_data_req(
memcpy(&pdcp_pdu_p->data[0], sdu_buffer_pP, sdu_buffer_sizeP); memcpy(&pdcp_pdu_p->data[0], sdu_buffer_pP, sdu_buffer_sizeP);
#if defined(DEBUG_PDCP_PAYLOAD) #if defined(DEBUG_PDCP_PAYLOAD)
rlc_util_print_hex_octets(PDCP, rlc_util_print_hex_octets(PDCP,
(unsigned char*)&pdcp_pdu_p->data[0], (unsigned char *)&pdcp_pdu_p->data[0],
sdu_buffer_sizeP); sdu_buffer_sizeP);
#endif #endif
LOG_D(PDCP, "Before rlc_data_req 1, srb_flagP: %d, rb_idP: %d \n", srb_flagP, rb_idP); LOG_D(PDCP, "Before rlc_data_req 1, srb_flagP: %d, rb_idP: %d \n", srb_flagP, rb_idP);
...@@ -212,13 +211,11 @@ boolean_t pdcp_data_req( ...@@ -212,13 +211,11 @@ boolean_t pdcp_data_req(
} }
pdcp_pdu_size = sdu_buffer_sizeP + pdcp_header_len + pdcp_tailer_len; pdcp_pdu_size = sdu_buffer_sizeP + pdcp_header_len + pdcp_tailer_len;
LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT"Data request notification pdu size %d (header%d, trailer%d)\n", LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT"Data request notification pdu size %d (header%d, trailer%d)\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p), PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p),
pdcp_pdu_size, pdcp_pdu_size,
pdcp_header_len, pdcp_header_len,
pdcp_tailer_len); pdcp_tailer_len);
/* /*
* Allocate a new block for the new PDU (i.e. PDU header and SDU payload) * Allocate a new block for the new PDU (i.e. PDU header and SDU payload)
*/ */
...@@ -230,7 +227,6 @@ boolean_t pdcp_data_req( ...@@ -230,7 +227,6 @@ boolean_t pdcp_data_req(
* *
* Place User Plane PDCP Data PDU header first * Place User Plane PDCP Data PDU header first
*/ */
if (srb_flagP) { // this Control plane PDCP Data PDU if (srb_flagP) { // this Control plane PDCP Data PDU
pdcp_control_plane_data_pdu_header pdu_header; pdcp_control_plane_data_pdu_header pdu_header;
pdu_header.sn = pdcp_get_next_tx_seq_number(pdcp_p); pdu_header.sn = pdcp_get_next_tx_seq_number(pdcp_p);
...@@ -238,7 +234,7 @@ boolean_t pdcp_data_req( ...@@ -238,7 +234,7 @@ boolean_t pdcp_data_req(
memset(&pdu_header.mac_i[0],0,PDCP_CONTROL_PLANE_DATA_PDU_MAC_I_SIZE); memset(&pdu_header.mac_i[0],0,PDCP_CONTROL_PLANE_DATA_PDU_MAC_I_SIZE);
memset(&pdcp_pdu_p->data[sdu_buffer_sizeP + pdcp_header_len],0,PDCP_CONTROL_PLANE_DATA_PDU_MAC_I_SIZE); memset(&pdcp_pdu_p->data[sdu_buffer_sizeP + pdcp_header_len],0,PDCP_CONTROL_PLANE_DATA_PDU_MAC_I_SIZE);
if (pdcp_serialize_control_plane_data_pdu_with_SRB_sn_buffer((unsigned char*)pdcp_pdu_p->data, &pdu_header) == FALSE) { if (pdcp_serialize_control_plane_data_pdu_with_SRB_sn_buffer((unsigned char *)pdcp_pdu_p->data, &pdu_header) == FALSE) {
LOG_E(PDCP, PROTOCOL_PDCP_CTXT_FMT" Cannot fill PDU buffer with relevant header fields!\n", LOG_E(PDCP, PROTOCOL_PDCP_CTXT_FMT" Cannot fill PDU buffer with relevant header fields!\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p)); PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p));
...@@ -257,12 +253,11 @@ boolean_t pdcp_data_req( ...@@ -257,12 +253,11 @@ boolean_t pdcp_data_req(
pdu_header.sn = pdcp_get_next_tx_seq_number(pdcp_p); pdu_header.sn = pdcp_get_next_tx_seq_number(pdcp_p);
current_sn = pdu_header.sn ; current_sn = pdu_header.sn ;
if (pdcp_serialize_user_plane_data_pdu_with_long_sn_buffer((unsigned char*)pdcp_pdu_p->data, &pdu_header) == FALSE) { if (pdcp_serialize_user_plane_data_pdu_with_long_sn_buffer((unsigned char *)pdcp_pdu_p->data, &pdu_header) == FALSE) {
LOG_E(PDCP, PROTOCOL_PDCP_CTXT_FMT" Cannot fill PDU buffer with relevant header fields!\n", LOG_E(PDCP, PROTOCOL_PDCP_CTXT_FMT" Cannot fill PDU buffer with relevant header fields!\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p)); PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p));
if (ctxt_pP->enb_flag == ENB_FLAG_YES) { if (ctxt_pP->enb_flag == ENB_FLAG_YES) {
stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].data_req); stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].data_req);
} else { } else {
stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].data_req); stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].data_req);
...@@ -281,7 +276,6 @@ boolean_t pdcp_data_req( ...@@ -281,7 +276,6 @@ boolean_t pdcp_data_req(
"There must be a problem with PDCP initialization, ignoring this PDU...\n", "There must be a problem with PDCP initialization, ignoring this PDU...\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p), PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p),
current_sn); current_sn);
free_mem_block(pdcp_pdu_p, __func__); free_mem_block(pdcp_pdu_p, __func__);
if (ctxt_pP->enb_flag == ENB_FLAG_YES) { if (ctxt_pP->enb_flag == ENB_FLAG_YES) {
...@@ -295,7 +289,6 @@ boolean_t pdcp_data_req( ...@@ -295,7 +289,6 @@ boolean_t pdcp_data_req(
} }
LOG_D(PDCP, "Sequence number %d is assigned to current PDU\n", current_sn); LOG_D(PDCP, "Sequence number %d is assigned to current PDU\n", current_sn);
/* Then append data... */ /* Then append data... */
memcpy(&pdcp_pdu_p->data[pdcp_header_len], sdu_buffer_pP, sdu_buffer_sizeP); memcpy(&pdcp_pdu_p->data[pdcp_header_len], sdu_buffer_pP, sdu_buffer_sizeP);
...@@ -311,7 +304,6 @@ boolean_t pdcp_data_req( ...@@ -311,7 +304,6 @@ boolean_t pdcp_data_req(
if ((pdcp_p->security_activated != 0) && if ((pdcp_p->security_activated != 0) &&
(((pdcp_p->cipheringAlgorithm) != 0) || (((pdcp_p->cipheringAlgorithm) != 0) ||
((pdcp_p->integrityProtAlgorithm) != 0))) { ((pdcp_p->integrityProtAlgorithm) != 0))) {
if (ctxt_pP->enb_flag == ENB_FLAG_YES) { if (ctxt_pP->enb_flag == ENB_FLAG_YES) {
start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].apply_security); start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].apply_security);
} else { } else {
...@@ -335,7 +327,6 @@ boolean_t pdcp_data_req( ...@@ -335,7 +327,6 @@ boolean_t pdcp_data_req(
} }
#endif #endif
/* Print octets of outgoing data in hexadecimal form */ /* Print octets of outgoing data in hexadecimal form */
LOG_D(PDCP, "Following content with size %d will be sent over RLC (PDCP PDU header is the first two bytes)\n", LOG_D(PDCP, "Following content with size %d will be sent over RLC (PDCP PDU header is the first two bytes)\n",
pdcp_pdu_size); pdcp_pdu_size);
...@@ -366,10 +357,8 @@ boolean_t pdcp_data_req( ...@@ -366,10 +357,8 @@ boolean_t pdcp_data_req(
* Ask sublayer to transmit data and check return value * Ask sublayer to transmit data and check return value
* to see if RLC succeeded * to see if RLC succeeded
*/ */
LOG_DUMPMSG(PDCP,DEBUG_PDCP,(char *)pdcp_pdu_p->data,pdcp_pdu_size, LOG_DUMPMSG(PDCP,DEBUG_PDCP,(char *)pdcp_pdu_p->data,pdcp_pdu_size,
"[MSG] PDCP DL %s PDU on rb_id %d\n",(srb_flagP)? "CONTROL" : "DATA", rb_idP); "[MSG] PDCP DL %s PDU on rb_id %d\n",(srb_flagP)? "CONTROL" : "DATA", rb_idP);
LOG_D(PDCP, "Before rlc_data_req 2, srb_flagP: %d, rb_idP: %d \n", srb_flagP, rb_idP); LOG_D(PDCP, "Before rlc_data_req 2, srb_flagP: %d, rb_idP: %d \n", srb_flagP, rb_idP);
rlc_status = rlc_data_req(ctxt_pP, srb_flagP, MBMS_FLAG_NO, rb_idP, muiP, confirmP, pdcp_pdu_size, pdcp_pdu_p rlc_status = rlc_data_req(ctxt_pP, srb_flagP, MBMS_FLAG_NO, rb_idP, muiP, confirmP, pdcp_pdu_size, pdcp_pdu_p
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
...@@ -377,7 +366,6 @@ boolean_t pdcp_data_req( ...@@ -377,7 +366,6 @@ boolean_t pdcp_data_req(
,destinationL2Id ,destinationL2Id
#endif #endif
); );
} }
switch (rlc_status) { switch (rlc_status) {
...@@ -418,7 +406,7 @@ boolean_t pdcp_data_req( ...@@ -418,7 +406,7 @@ boolean_t pdcp_data_req(
* so we return TRUE afterwards * so we return TRUE afterwards
*/ */
for (pdcp_uid=0; pdcp_uid< MAX_MOBILES_PER_ENB;pdcp_uid++){ for (pdcp_uid=0; pdcp_uid< MAX_MOBILES_PER_ENB; pdcp_uid++) {
if (pdcp_enb[ctxt_pP->module_id].rnti[pdcp_uid] == ctxt_pP->rnti ) if (pdcp_enb[ctxt_pP->module_id].rnti[pdcp_uid] == ctxt_pP->rnti )
break; break;
} }
...@@ -429,26 +417,23 @@ boolean_t pdcp_data_req( ...@@ -429,26 +417,23 @@ boolean_t pdcp_data_req(
Pdcp_stats_tx_bytes[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=sdu_buffer_sizeP; Pdcp_stats_tx_bytes[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=sdu_buffer_sizeP;
Pdcp_stats_tx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=sdu_buffer_sizeP; Pdcp_stats_tx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=sdu_buffer_sizeP;
Pdcp_stats_tx_sn[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=current_sn; Pdcp_stats_tx_sn[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=current_sn;
Pdcp_stats_tx_aiat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (pdcp_enb[ctxt_pP->module_id].sfn - Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); Pdcp_stats_tx_aiat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (pdcp_enb[ctxt_pP->module_id].sfn - Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]);
Pdcp_stats_tx_aiat_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (pdcp_enb[ctxt_pP->module_id].sfn - Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); Pdcp_stats_tx_aiat_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (pdcp_enb[ctxt_pP->module_id].sfn - Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]);
Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=pdcp_enb[ctxt_pP->module_id].sfn; Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=pdcp_enb[ctxt_pP->module_id].sfn;
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_REQ,VCD_FUNCTION_OUT); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_REQ,VCD_FUNCTION_OUT);
return ret; return ret;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
boolean_t boolean_t
pdcp_data_ind( pdcp_data_ind(
const protocol_ctxt_t* const ctxt_pP, const protocol_ctxt_t *const ctxt_pP,
const srb_flag_t srb_flagP, const srb_flag_t srb_flagP,
const MBMS_flag_t MBMS_flagP, const MBMS_flag_t MBMS_flagP,
const rb_id_t rb_idP, const rb_id_t rb_idP,
const sdu_size_t sdu_buffer_sizeP, const sdu_size_t sdu_buffer_sizeP,
mem_block_t* const sdu_buffer_pP mem_block_t *const sdu_buffer_pP
) )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
{ {
...@@ -470,16 +455,14 @@ pdcp_data_ind( ...@@ -470,16 +455,14 @@ pdcp_data_ind(
MessageDef *message_p = NULL; MessageDef *message_p = NULL;
uint8_t *gtpu_buffer_p = NULL; uint8_t *gtpu_buffer_p = NULL;
#endif #endif
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_IND,VCD_FUNCTION_IN); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_IND,VCD_FUNCTION_IN);
LOG_DUMPMSG(PDCP,DEBUG_PDCP,(char *)sdu_buffer_pP->data,sdu_buffer_sizeP, LOG_DUMPMSG(PDCP,DEBUG_PDCP,(char *)sdu_buffer_pP->data,sdu_buffer_sizeP,
"[MSG] PDCP UL %s PDU on rb_id %d\n", (srb_flagP)? "CONTROL" : "DATA", rb_idP); "[MSG] PDCP UL %s PDU on rb_id %d\n", (srb_flagP)? "CONTROL" : "DATA", rb_idP);
#if T_TRACER #if T_TRACER
if (ctxt_pP->enb_flag != ENB_FLAG_NO) if (ctxt_pP->enb_flag != ENB_FLAG_NO)
T(T_ENB_PDCP_UL, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->rnti), T_INT(rb_idP), T_INT(sdu_buffer_sizeP)); T(T_ENB_PDCP_UL, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->rnti), T_INT(rb_idP), T_INT(sdu_buffer_sizeP));
#endif #endif
if (MBMS_flagP) { if (MBMS_flagP) {
...@@ -498,7 +481,6 @@ pdcp_data_ind( ...@@ -498,7 +481,6 @@ pdcp_data_ind(
rb_idP, rb_idP,
sdu_buffer_sizeP, sdu_buffer_sizeP,
ctxt_pP->enb_flag); ctxt_pP->enb_flag);
} else { } else {
LOG_D(PDCP, "Data indication notification for PDCP entity from UE %x to eNB %u " LOG_D(PDCP, "Data indication notification for PDCP entity from UE %x to eNB %u "
"and radio bearer ID %d rlc sdu size %d ctxt_pP->enb_flag %d\n", "and radio bearer ID %d rlc sdu size %d ctxt_pP->enb_flag %d\n",
...@@ -508,7 +490,6 @@ pdcp_data_ind( ...@@ -508,7 +490,6 @@ pdcp_data_ind(
sdu_buffer_sizeP, sdu_buffer_sizeP,
ctxt_pP->enb_flag); ctxt_pP->enb_flag);
} }
} else { } else {
rb_id = rb_idP % LTE_maxDRB; rb_id = rb_idP % LTE_maxDRB;
AssertError (rb_id < LTE_maxDRB, return FALSE, "RB id is too high (%u/%d) %u UE %x!\n", AssertError (rb_id < LTE_maxDRB, return FALSE, "RB id is too high (%u/%d) %u UE %x!\n",
...@@ -522,7 +503,7 @@ pdcp_data_ind( ...@@ -522,7 +503,7 @@ pdcp_data_ind(
ctxt_pP->module_id, ctxt_pP->module_id,
ctxt_pP->rnti); ctxt_pP->rnti);
key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_id, srb_flagP); key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_id, srb_flagP);
h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p);
if (h_rc != HASH_TABLE_OK) { if (h_rc != HASH_TABLE_OK) {
LOG_W(PDCP, LOG_W(PDCP,
...@@ -557,16 +538,16 @@ pdcp_data_ind( ...@@ -557,16 +538,16 @@ pdcp_data_ind(
if (srb_flagP) { //SRB1/2 if (srb_flagP) { //SRB1/2
pdcp_header_len = PDCP_CONTROL_PLANE_DATA_PDU_SN_SIZE; pdcp_header_len = PDCP_CONTROL_PLANE_DATA_PDU_SN_SIZE;
pdcp_tailer_len = PDCP_CONTROL_PLANE_DATA_PDU_MAC_I_SIZE; pdcp_tailer_len = PDCP_CONTROL_PLANE_DATA_PDU_MAC_I_SIZE;
sequence_number = pdcp_get_sequence_number_of_pdu_with_SRB_sn((unsigned char*)sdu_buffer_pP->data); sequence_number = pdcp_get_sequence_number_of_pdu_with_SRB_sn((unsigned char *)sdu_buffer_pP->data);
} else { // DRB } else { // DRB
pdcp_tailer_len = 0; pdcp_tailer_len = 0;
if (pdcp_p->seq_num_size == PDCP_SN_7BIT) { if (pdcp_p->seq_num_size == PDCP_SN_7BIT) {
pdcp_header_len = PDCP_USER_PLANE_DATA_PDU_SHORT_SN_HEADER_SIZE; pdcp_header_len = PDCP_USER_PLANE_DATA_PDU_SHORT_SN_HEADER_SIZE;
sequence_number = pdcp_get_sequence_number_of_pdu_with_short_sn((unsigned char*)sdu_buffer_pP->data); sequence_number = pdcp_get_sequence_number_of_pdu_with_short_sn((unsigned char *)sdu_buffer_pP->data);
} else if (pdcp_p->seq_num_size == PDCP_SN_12BIT) { } else if (pdcp_p->seq_num_size == PDCP_SN_12BIT) {
pdcp_header_len = PDCP_USER_PLANE_DATA_PDU_LONG_SN_HEADER_SIZE; pdcp_header_len = PDCP_USER_PLANE_DATA_PDU_LONG_SN_HEADER_SIZE;
sequence_number = pdcp_get_sequence_number_of_pdu_with_long_sn((unsigned char*)sdu_buffer_pP->data); sequence_number = pdcp_get_sequence_number_of_pdu_with_long_sn((unsigned char *)sdu_buffer_pP->data);
} else { } else {
//sequence_number = 4095; //sequence_number = 4095;
LOG_E(PDCP, LOG_E(PDCP,
...@@ -658,10 +639,9 @@ pdcp_data_ind( ...@@ -658,10 +639,9 @@ pdcp_data_ind(
rrc_data_ind(ctxt_pP, rrc_data_ind(ctxt_pP,
rb_id, rb_id,
sdu_buffer_sizeP - pdcp_header_len - pdcp_tailer_len, sdu_buffer_sizeP - pdcp_header_len - pdcp_tailer_len,
(uint8_t*)&sdu_buffer_pP->data[pdcp_header_len]); (uint8_t *)&sdu_buffer_pP->data[pdcp_header_len]);
free_mem_block(sdu_buffer_pP, __func__); free_mem_block(sdu_buffer_pP, __func__);
// free_mem_block(new_sdu, __func__); // free_mem_block(new_sdu, __func__);
if (ctxt_pP->enb_flag) { if (ctxt_pP->enb_flag) {
stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].data_ind); stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].data_ind);
...@@ -701,7 +681,6 @@ pdcp_data_ind( ...@@ -701,7 +681,6 @@ pdcp_data_ind(
} else { } else {
stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].validate_security); stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].validate_security);
} }
} }
#endif #endif
...@@ -724,7 +703,6 @@ pdcp_data_ind( ...@@ -724,7 +703,6 @@ pdcp_data_ind(
} }
// XXX Decompression would be done at this point // XXX Decompression would be done at this point
/* /*
* After checking incoming sequence number PDCP header * After checking incoming sequence number PDCP header
* has to be stripped off so here we copy SDU buffer starting * has to be stripped off so here we copy SDU buffer starting
...@@ -761,20 +739,19 @@ pdcp_data_ind( ...@@ -761,20 +739,19 @@ pdcp_data_ind(
#else #else
packet_forwarded = FALSE; packet_forwarded = FALSE;
#endif #endif
#ifdef MBMS_MULTICAST_OUT #ifdef MBMS_MULTICAST_OUT
if ((MBMS_flagP != 0) && (mbms_socket != -1)) { if ((MBMS_flagP != 0) && (mbms_socket != -1)) {
struct iphdr *ip_header = (struct iphdr*)&sdu_buffer_pP->data[payload_offset]; struct iphdr *ip_header = (struct iphdr *)&sdu_buffer_pP->data[payload_offset];
struct udphdr *udp_header = (struct udphdr*)&sdu_buffer_pP->data[payload_offset + sizeof(struct iphdr)]; struct udphdr *udp_header = (struct udphdr *)&sdu_buffer_pP->data[payload_offset + sizeof(struct iphdr)];
struct sockaddr_in dest_addr; struct sockaddr_in dest_addr;
dest_addr.sin_family = AF_INET; dest_addr.sin_family = AF_INET;
dest_addr.sin_port = udp_header->dest; dest_addr.sin_port = udp_header->dest;
dest_addr.sin_addr.s_addr = ip_header->daddr; dest_addr.sin_addr.s_addr = ip_header->daddr;
sendto(mbms_socket, &sdu_buffer_pP->data[payload_offset], sdu_buffer_sizeP - payload_offset, MSG_DONTWAIT, (struct sockaddr *)&dest_addr, sizeof(dest_addr));
sendto(mbms_socket, &sdu_buffer_pP->data[payload_offset], sdu_buffer_sizeP - payload_offset, MSG_DONTWAIT, (struct sockaddr*)&dest_addr, sizeof(dest_addr));
packet_forwarded = TRUE; packet_forwarded = TRUE;
} }
#endif #endif
if (FALSE == packet_forwarded) { if (FALSE == packet_forwarded) {
...@@ -797,42 +774,40 @@ pdcp_data_ind( ...@@ -797,42 +774,40 @@ pdcp_data_ind(
if (ctxt_pP->enb_flag == ENB_FLAG_NO) { if (ctxt_pP->enb_flag == ENB_FLAG_NO) {
((pdcp_data_ind_header_t *) new_sdu_p->data)->rb_id = rb_id; ((pdcp_data_ind_header_t *) new_sdu_p->data)->rb_id = rb_id;
#if defined(ENABLE_USE_MME) #if defined(ENABLE_USE_MME)
/* for the UE compiled in S1 mode, we need 1 here /* for the UE compiled in S1 mode, we need 1 here
* for the UE compiled in noS1 mode, we need 0 * for the UE compiled in noS1 mode, we need 0
* TODO: be sure of this * TODO: be sure of this
*/ */
if (nfapi_mode == 3) { if (nfapi_mode == 3) {
#ifdef UESIM_EXPANSION #ifdef UESIM_EXPANSION
((pdcp_data_ind_header_t*) new_sdu_p->data)->inst = 0; ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = 0;
#else #else
((pdcp_data_ind_header_t*) new_sdu_p->data)->inst = ctxt_pP->module_id; ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = ctxt_pP->module_id;
#endif #endif
} else { } else {
((pdcp_data_ind_header_t*) new_sdu_p->data)->inst = 1; ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = 1;
} }
#endif #endif
} else { } else {
((pdcp_data_ind_header_t*) new_sdu_p->data)->rb_id = rb_id + (ctxt_pP->module_id * LTE_maxDRB); ((pdcp_data_ind_header_t *) new_sdu_p->data)->rb_id = rb_id + (ctxt_pP->module_id * LTE_maxDRB);
((pdcp_data_ind_header_t*) new_sdu_p->data)->inst = ctxt_pP->module_id; ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = ctxt_pP->module_id;
} }
// new_sdu_p->data->inst is set again in UE case so move to above. // new_sdu_p->data->inst is set again in UE case so move to above.
//Panos: Commented this out because it cancels the assignment in #if defined(ENABLE_USE_MME) case //Panos: Commented this out because it cancels the assignment in #if defined(ENABLE_USE_MME) case
//((pdcp_data_ind_header_t*) new_sdu_p->data)->inst = ctxt_pP->module_id; //((pdcp_data_ind_header_t*) new_sdu_p->data)->inst = ctxt_pP->module_id;
#ifdef DEBUG_PDCP_FIFO_FLUSH_SDU #ifdef DEBUG_PDCP_FIFO_FLUSH_SDU
static uint32_t pdcp_inst = 0; static uint32_t pdcp_inst = 0;
((pdcp_data_ind_header_t*) new_sdu_p->data)->inst = pdcp_inst++; ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = pdcp_inst++;
LOG_D(PDCP, "inst=%d size=%d\n", ((pdcp_data_ind_header_t*) new_sdu_p->data)->inst, ((pdcp_data_ind_header_t *) new_sdu_p->data)->data_size); LOG_D(PDCP, "inst=%d size=%d\n", ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst, ((pdcp_data_ind_header_t *) new_sdu_p->data)->data_size);
#endif #endif
//((pdcp_data_ind_header_t*) new_sdu_p->data)->inst = 1; //pdcp_inst++; //((pdcp_data_ind_header_t*) new_sdu_p->data)->inst = 1; //pdcp_inst++;
memcpy(&new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], \ memcpy(&new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], \
&sdu_buffer_pP->data[payload_offset], \ &sdu_buffer_pP->data[payload_offset], \
sdu_buffer_sizeP - payload_offset); sdu_buffer_sizeP - payload_offset);
list_add_tail_eurecom (new_sdu_p, sdu_list_p); list_add_tail_eurecom (new_sdu_p, sdu_list_p);
} }
/* Print octets of incoming data in hexadecimal form */ /* Print octets of incoming data in hexadecimal form */
...@@ -847,8 +822,8 @@ pdcp_data_ind( ...@@ -847,8 +822,8 @@ pdcp_data_ind(
* XXX Following two actions are identical, is there a merge error? * XXX Following two actions are identical, is there a merge error?
*/ */
for (pdcp_uid=0; pdcp_uid< MAX_MOBILES_PER_ENB;pdcp_uid++){ for (pdcp_uid=0; pdcp_uid< MAX_MOBILES_PER_ENB; pdcp_uid++) {
if (pdcp_enb[ctxt_pP->module_id].rnti[pdcp_uid] == ctxt_pP->rnti ){ if (pdcp_enb[ctxt_pP->module_id].rnti[pdcp_uid] == ctxt_pP->rnti ) {
break; break;
} }
} }
...@@ -857,7 +832,6 @@ pdcp_data_ind( ...@@ -857,7 +832,6 @@ pdcp_data_ind(
Pdcp_stats_rx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; Pdcp_stats_rx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++;
Pdcp_stats_rx_bytes[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(sdu_buffer_sizeP - payload_offset); Pdcp_stats_rx_bytes[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(sdu_buffer_sizeP - payload_offset);
Pdcp_stats_rx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(sdu_buffer_sizeP - payload_offset); Pdcp_stats_rx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(sdu_buffer_sizeP - payload_offset);
Pdcp_stats_rx_sn[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=sequence_number; Pdcp_stats_rx_sn[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=sequence_number;
if (oo_flag == 1 ) if (oo_flag == 1 )
...@@ -866,15 +840,13 @@ pdcp_data_ind( ...@@ -866,15 +840,13 @@ pdcp_data_ind(
Pdcp_stats_rx_aiat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (pdcp_enb[ctxt_pP->module_id].sfn - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); Pdcp_stats_rx_aiat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (pdcp_enb[ctxt_pP->module_id].sfn - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]);
Pdcp_stats_rx_aiat_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(pdcp_enb[ctxt_pP->module_id].sfn - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); Pdcp_stats_rx_aiat_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(pdcp_enb[ctxt_pP->module_id].sfn - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]);
Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=pdcp_enb[ctxt_pP->module_id].sfn; Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=pdcp_enb[ctxt_pP->module_id].sfn;
#if defined(STOP_ON_IP_TRAFFIC_OVERLOAD) #if defined(STOP_ON_IP_TRAFFIC_OVERLOAD)
else { else {
AssertFatal(0, PROTOCOL_PDCP_CTXT_FMT" PDCP_DATA_IND SDU DROPPED, OUT OF MEMORY \n", AssertFatal(0, PROTOCOL_PDCP_CTXT_FMT" PDCP_DATA_IND SDU DROPPED, OUT OF MEMORY \n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p)); PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p));
} }
#endif
#endif
} }
free_mem_block(sdu_buffer_pP, __func__); free_mem_block(sdu_buffer_pP, __func__);
...@@ -889,41 +861,42 @@ pdcp_data_ind( ...@@ -889,41 +861,42 @@ pdcp_data_ind(
return TRUE; return TRUE;
} }
void pdcp_update_stats(const protocol_ctxt_t* const ctxt_pP){ void pdcp_update_stats(const protocol_ctxt_t *const ctxt_pP) {
uint16_t pdcp_uid = 0; uint16_t pdcp_uid = 0;
uint8_t rb_id = 0; uint8_t rb_id = 0;
// these stats are measured for both eNB and UE on per seond basis // these stats are measured for both eNB and UE on per seond basis
for (rb_id =0; rb_id < NB_RB_MAX; rb_id ++){ for (rb_id =0; rb_id < NB_RB_MAX; rb_id ++) {
for (pdcp_uid=0; pdcp_uid< MAX_MOBILES_PER_ENB;pdcp_uid++){ for (pdcp_uid=0; pdcp_uid< MAX_MOBILES_PER_ENB; pdcp_uid++) {
//printf("frame %d and subframe %d \n", pdcp_enb[ctxt_pP->module_id].frame, pdcp_enb[ctxt_pP->module_id].subframe); //printf("frame %d and subframe %d \n", pdcp_enb[ctxt_pP->module_id].frame, pdcp_enb[ctxt_pP->module_id].subframe);
// tx stats // tx stats
if (Pdcp_stats_tx_window_ms[ctxt_pP->module_id][pdcp_uid] > 0 && if (Pdcp_stats_tx_window_ms[ctxt_pP->module_id][pdcp_uid] > 0 &&
pdcp_enb[ctxt_pP->module_id].sfn % Pdcp_stats_tx_window_ms[ctxt_pP->module_id][pdcp_uid] == 0){ pdcp_enb[ctxt_pP->module_id].sfn % Pdcp_stats_tx_window_ms[ctxt_pP->module_id][pdcp_uid] == 0) {
// unit: bit/s // unit: bit/s
Pdcp_stats_tx_throughput_w[ctxt_pP->module_id][pdcp_uid][rb_id]=Pdcp_stats_tx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]*8; Pdcp_stats_tx_throughput_w[ctxt_pP->module_id][pdcp_uid][rb_id]=Pdcp_stats_tx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]*8;
Pdcp_stats_tx_w[ctxt_pP->module_id][pdcp_uid][rb_id]= Pdcp_stats_tx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]; Pdcp_stats_tx_w[ctxt_pP->module_id][pdcp_uid][rb_id]= Pdcp_stats_tx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id];
Pdcp_stats_tx_bytes_w[ctxt_pP->module_id][pdcp_uid][rb_id]= Pdcp_stats_tx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]; Pdcp_stats_tx_bytes_w[ctxt_pP->module_id][pdcp_uid][rb_id]= Pdcp_stats_tx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id];
if (Pdcp_stats_tx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id] > 0){
if (Pdcp_stats_tx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id] > 0) {
Pdcp_stats_tx_aiat_w[ctxt_pP->module_id][pdcp_uid][rb_id]=(Pdcp_stats_tx_aiat_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]/Pdcp_stats_tx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]); Pdcp_stats_tx_aiat_w[ctxt_pP->module_id][pdcp_uid][rb_id]=(Pdcp_stats_tx_aiat_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]/Pdcp_stats_tx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]);
}else { } else {
Pdcp_stats_tx_aiat_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0; Pdcp_stats_tx_aiat_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0;
} }
// reset the tmp vars // reset the tmp vars
Pdcp_stats_tx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0; Pdcp_stats_tx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0;
Pdcp_stats_tx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0; Pdcp_stats_tx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0;
Pdcp_stats_tx_aiat_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0; Pdcp_stats_tx_aiat_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0;
} }
if (Pdcp_stats_rx_window_ms[ctxt_pP->module_id][pdcp_uid] > 0 && if (Pdcp_stats_rx_window_ms[ctxt_pP->module_id][pdcp_uid] > 0 &&
pdcp_enb[ctxt_pP->module_id].sfn % Pdcp_stats_rx_window_ms[ctxt_pP->module_id][pdcp_uid] == 0){ pdcp_enb[ctxt_pP->module_id].sfn % Pdcp_stats_rx_window_ms[ctxt_pP->module_id][pdcp_uid] == 0) {
// rx stats // rx stats
Pdcp_stats_rx_goodput_w[ctxt_pP->module_id][pdcp_uid][rb_id]=Pdcp_stats_rx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]*8; Pdcp_stats_rx_goodput_w[ctxt_pP->module_id][pdcp_uid][rb_id]=Pdcp_stats_rx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]*8;
Pdcp_stats_rx_w[ctxt_pP->module_id][pdcp_uid][rb_id]= Pdcp_stats_rx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]; Pdcp_stats_rx_w[ctxt_pP->module_id][pdcp_uid][rb_id]= Pdcp_stats_rx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id];
Pdcp_stats_rx_bytes_w[ctxt_pP->module_id][pdcp_uid][rb_id]= Pdcp_stats_rx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]; Pdcp_stats_rx_bytes_w[ctxt_pP->module_id][pdcp_uid][rb_id]= Pdcp_stats_rx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id];
if(Pdcp_stats_rx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id] > 0){ if(Pdcp_stats_rx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id] > 0) {
Pdcp_stats_rx_aiat_w[ctxt_pP->module_id][pdcp_uid][rb_id]= (Pdcp_stats_rx_aiat_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]/Pdcp_stats_rx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]); Pdcp_stats_rx_aiat_w[ctxt_pP->module_id][pdcp_uid][rb_id]= (Pdcp_stats_rx_aiat_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]/Pdcp_stats_rx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]);
} else { } else {
Pdcp_stats_rx_aiat_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0; Pdcp_stats_rx_aiat_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0;
...@@ -935,17 +908,15 @@ void pdcp_update_stats(const protocol_ctxt_t* const ctxt_pP){ ...@@ -935,17 +908,15 @@ void pdcp_update_stats(const protocol_ctxt_t* const ctxt_pP){
Pdcp_stats_rx_aiat_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0; Pdcp_stats_rx_aiat_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0;
} }
} }
} }
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
pdcp_run ( pdcp_run (
const protocol_ctxt_t* const ctxt_pP const protocol_ctxt_t *const ctxt_pP
) )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
{ {
if (ctxt_pP->enb_flag) { if (ctxt_pP->enb_flag) {
start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].pdcp_run); start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].pdcp_run);
} else { } else {
...@@ -956,9 +927,7 @@ pdcp_run ( ...@@ -956,9 +927,7 @@ pdcp_run (
pdcp_enb[ctxt_pP->module_id].frame=ctxt_pP->frame; // 1023 pdcp_enb[ctxt_pP->module_id].frame=ctxt_pP->frame; // 1023
pdcp_enb[ctxt_pP->module_id].subframe= ctxt_pP->subframe; pdcp_enb[ctxt_pP->module_id].subframe= ctxt_pP->subframe;
pdcp_update_stats(ctxt_pP); pdcp_update_stats(ctxt_pP);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_RUN, VCD_FUNCTION_IN); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_RUN, VCD_FUNCTION_IN);
#if defined(ENABLE_ITTI) #if defined(ENABLE_ITTI)
MessageDef *msg_p; MessageDef *msg_p;
int result; int result;
...@@ -969,7 +938,6 @@ pdcp_run ( ...@@ -969,7 +938,6 @@ pdcp_run (
itti_poll_msg (ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, &msg_p); itti_poll_msg (ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, &msg_p);
if (msg_p != NULL) { if (msg_p != NULL) {
switch (ITTI_MSG_ID(msg_p)) { switch (ITTI_MSG_ID(msg_p)) {
case RRC_DCCH_DATA_REQ: case RRC_DCCH_DATA_REQ:
PROTOCOL_CTXT_SET_BY_MODULE_ID( PROTOCOL_CTXT_SET_BY_MODULE_ID(
...@@ -989,7 +957,6 @@ pdcp_run ( ...@@ -989,7 +957,6 @@ pdcp_run (
RRC_DCCH_DATA_REQ (msg_p).muip, RRC_DCCH_DATA_REQ (msg_p).muip,
RRC_DCCH_DATA_REQ (msg_p).confirmp, RRC_DCCH_DATA_REQ (msg_p).confirmp,
RRC_DCCH_DATA_REQ (msg_p).mode); RRC_DCCH_DATA_REQ (msg_p).mode);
LOG_D(PDCP, "Before calling pdcp_data_req from pdcp_run! RRC_DCCH_DATA_REQ (msg_p).rb_id: %d \n", RRC_DCCH_DATA_REQ (msg_p).rb_id); LOG_D(PDCP, "Before calling pdcp_data_req from pdcp_run! RRC_DCCH_DATA_REQ (msg_p).rb_id: %d \n", RRC_DCCH_DATA_REQ (msg_p).rb_id);
result = pdcp_data_req (&ctxt, result = pdcp_data_req (&ctxt,
SRB_FLAG_YES, SRB_FLAG_YES,
...@@ -1003,6 +970,7 @@ pdcp_run ( ...@@ -1003,6 +970,7 @@ pdcp_run (
, NULL, NULL , NULL, NULL
#endif #endif
); );
if (result != TRUE) if (result != TRUE)
LOG_E(PDCP, "PDCP data request failed!\n"); LOG_E(PDCP, "PDCP data request failed!\n");
...@@ -1011,16 +979,17 @@ pdcp_run ( ...@@ -1011,16 +979,17 @@ pdcp_run (
AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
break; break;
case RRC_PCCH_DATA_REQ: case RRC_PCCH_DATA_REQ: {
{
sdu_size_t sdu_buffer_sizeP; sdu_size_t sdu_buffer_sizeP;
sdu_buffer_sizeP = RRC_PCCH_DATA_REQ(msg_p).sdu_size; sdu_buffer_sizeP = RRC_PCCH_DATA_REQ(msg_p).sdu_size;
uint8_t CC_id = RRC_PCCH_DATA_REQ(msg_p).CC_id; uint8_t CC_id = RRC_PCCH_DATA_REQ(msg_p).CC_id;
uint8_t ue_index = RRC_PCCH_DATA_REQ(msg_p).ue_index; uint8_t ue_index = RRC_PCCH_DATA_REQ(msg_p).ue_index;
RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_paging[ue_index] = sdu_buffer_sizeP; RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_paging[ue_index] = sdu_buffer_sizeP;
if (sdu_buffer_sizeP > 0) { if (sdu_buffer_sizeP > 0) {
memcpy(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].paging[ue_index], RRC_PCCH_DATA_REQ(msg_p).sdu_p, sdu_buffer_sizeP); memcpy(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].paging[ue_index], RRC_PCCH_DATA_REQ(msg_p).sdu_p, sdu_buffer_sizeP);
} }
//paging pdcp log //paging pdcp log
LOG_D(PDCP, "PDCP Received RRC_PCCH_DATA_REQ CC_id %d length %d \n", CC_id, sdu_buffer_sizeP); LOG_D(PDCP, "PDCP Received RRC_PCCH_DATA_REQ CC_id %d length %d \n", CC_id, sdu_buffer_sizeP);
} }
...@@ -1037,7 +1006,6 @@ pdcp_run ( ...@@ -1037,7 +1006,6 @@ pdcp_run (
} while(msg_p != NULL); } while(msg_p != NULL);
#endif #endif
// IP/NAS -> PDCP traffic : TX, read the pkt from the upper layer buffer // IP/NAS -> PDCP traffic : TX, read the pkt from the upper layer buffer
#if defined(LINK_ENB_PDCP_TO_GTPV1U) #if defined(LINK_ENB_PDCP_TO_GTPV1U)
...@@ -1050,9 +1018,7 @@ pdcp_run ( ...@@ -1050,9 +1018,7 @@ pdcp_run (
// PDCP -> NAS/IP traffic: RX // PDCP -> NAS/IP traffic: RX
if (ctxt_pP->enb_flag) { if (ctxt_pP->enb_flag) {
start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].pdcp_ip); start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].pdcp_ip);
} } else {
else {
start_meas(&UE_pdcp_stats[ctxt_pP->module_id].pdcp_ip); start_meas(&UE_pdcp_stats[ctxt_pP->module_id].pdcp_ip);
} }
...@@ -1069,20 +1035,23 @@ pdcp_run ( ...@@ -1069,20 +1035,23 @@ pdcp_run (
} else { } else {
stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].pdcp_run); stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].pdcp_run);
} }
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_RUN, VCD_FUNCTION_OUT); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_RUN, VCD_FUNCTION_OUT);
} }
void pdcp_add_UE(const protocol_ctxt_t* const ctxt_pP){ void pdcp_add_UE(const protocol_ctxt_t *const ctxt_pP) {
int i, ue_flag=1; //, ret=-1; to be decied later int i, ue_flag=1; //, ret=-1; to be decied later
for (i=0; i < MAX_MOBILES_PER_ENB; i++){
for (i=0; i < MAX_MOBILES_PER_ENB; i++) {
if (pdcp_enb[ctxt_pP->module_id].rnti[i] == ctxt_pP->rnti) { if (pdcp_enb[ctxt_pP->module_id].rnti[i] == ctxt_pP->rnti) {
ue_flag=-1; ue_flag=-1;
break; break;
} }
} }
if (ue_flag == 1 ){
for (i=0; i < MAX_MOBILES_PER_ENB ; i++){ if (ue_flag == 1 ) {
if (pdcp_enb[ctxt_pP->module_id].rnti[i] == 0 ){ for (i=0; i < MAX_MOBILES_PER_ENB ; i++) {
if (pdcp_enb[ctxt_pP->module_id].rnti[i] == 0 ) {
pdcp_enb[ctxt_pP->module_id].rnti[i]=ctxt_pP->rnti; pdcp_enb[ctxt_pP->module_id].rnti[i]=ctxt_pP->rnti;
pdcp_enb[ctxt_pP->module_id].uid[i]=i; pdcp_enb[ctxt_pP->module_id].uid[i]=i;
pdcp_enb[ctxt_pP->module_id].num_ues++; pdcp_enb[ctxt_pP->module_id].num_ues++;
...@@ -1092,13 +1061,14 @@ void pdcp_add_UE(const protocol_ctxt_t* const ctxt_pP){ ...@@ -1092,13 +1061,14 @@ void pdcp_add_UE(const protocol_ctxt_t* const ctxt_pP){
} }
} }
} }
//return ret; //return ret;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
boolean_t boolean_t
pdcp_remove_UE( pdcp_remove_UE(
const protocol_ctxt_t* const ctxt_pP const protocol_ctxt_t *const ctxt_pP
) )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
{ {
...@@ -1109,8 +1079,8 @@ pdcp_remove_UE( ...@@ -1109,8 +1079,8 @@ pdcp_remove_UE(
int i; int i;
// check and remove SRBs first // check and remove SRBs first
for(int i = 0;i<MAX_MOBILES_PER_ENB;i++){ for(int i = 0; i<MAX_MOBILES_PER_ENB; i++) {
if(pdcp_eNB_UE_instance_to_rnti[i] == ctxt_pP->rnti){ if(pdcp_eNB_UE_instance_to_rnti[i] == ctxt_pP->rnti) {
pdcp_eNB_UE_instance_to_rnti[i] = NOT_A_RNTI; pdcp_eNB_UE_instance_to_rnti[i] = NOT_A_RNTI;
break; break;
} }
...@@ -1124,7 +1094,6 @@ pdcp_remove_UE( ...@@ -1124,7 +1094,6 @@ pdcp_remove_UE(
for (drb_id=0; drb_id<LTE_maxDRB; drb_id++) { for (drb_id=0; drb_id<LTE_maxDRB; drb_id++) {
key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, drb_id, SRB_FLAG_NO); key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, drb_id, SRB_FLAG_NO);
h_rc = hashtable_remove(pdcp_coll_p, key); h_rc = hashtable_remove(pdcp_coll_p, key);
} }
(void)h_rc; /* remove gcc warning "set but not used" */ (void)h_rc; /* remove gcc warning "set but not used" */
...@@ -1149,7 +1118,7 @@ pdcp_remove_UE( ...@@ -1149,7 +1118,7 @@ pdcp_remove_UE(
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
boolean_t boolean_t
rrc_pdcp_config_asn1_req ( rrc_pdcp_config_asn1_req (
const protocol_ctxt_t* const ctxt_pP, const protocol_ctxt_t *const ctxt_pP,
LTE_SRB_ToAddModList_t *const srb2add_list_pP, LTE_SRB_ToAddModList_t *const srb2add_list_pP,
LTE_DRB_ToAddModList_t *const drb2add_list_pP, LTE_DRB_ToAddModList_t *const drb2add_list_pP,
LTE_DRB_ToReleaseList_t *const drb2release_list_pP, LTE_DRB_ToReleaseList_t *const drb2release_list_pP,
...@@ -1158,7 +1127,7 @@ rrc_pdcp_config_asn1_req ( ...@@ -1158,7 +1127,7 @@ rrc_pdcp_config_asn1_req (
uint8_t *const kRRCint_pP, uint8_t *const kRRCint_pP,
uint8_t *const kUPenc_pP uint8_t *const kUPenc_pP
#if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0))
,LTE_PMCH_InfoList_r9_t* const pmch_InfoList_r9_pP ,LTE_PMCH_InfoList_r9_t *const pmch_InfoList_r9_pP
#endif #endif
,rb_id_t *const defaultDRB ,rb_id_t *const defaultDRB
) )
...@@ -1179,7 +1148,6 @@ rrc_pdcp_config_asn1_req ( ...@@ -1179,7 +1148,6 @@ rrc_pdcp_config_asn1_req (
LTE_SRB_ToAddMod_t *srb_toaddmod_p = NULL; LTE_SRB_ToAddMod_t *srb_toaddmod_p = NULL;
LTE_DRB_ToAddMod_t *drb_toaddmod_p = NULL; LTE_DRB_ToAddMod_t *drb_toaddmod_p = NULL;
pdcp_t *pdcp_p = NULL; pdcp_t *pdcp_p = NULL;
hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE;
hashtable_rc_t h_rc; hashtable_rc_t h_rc;
hash_key_t key_defaultDRB = HASHTABLE_NOT_A_KEY_VALUE; hash_key_t key_defaultDRB = HASHTABLE_NOT_A_KEY_VALUE;
...@@ -1189,7 +1157,6 @@ rrc_pdcp_config_asn1_req ( ...@@ -1189,7 +1157,6 @@ rrc_pdcp_config_asn1_req (
LTE_MBMS_SessionInfoList_r9_t *mbms_SessionInfoList_r9_p = NULL; LTE_MBMS_SessionInfoList_r9_t *mbms_SessionInfoList_r9_p = NULL;
LTE_MBMS_SessionInfo_r9_t *MBMS_SessionInfo_p = NULL; LTE_MBMS_SessionInfo_r9_t *MBMS_SessionInfo_p = NULL;
#endif #endif
LOG_T(PDCP, PROTOCOL_CTXT_FMT" %s() SRB2ADD %p DRB2ADD %p DRB2RELEASE %p\n", LOG_T(PDCP, PROTOCOL_CTXT_FMT" %s() SRB2ADD %p DRB2ADD %p DRB2RELEASE %p\n",
PROTOCOL_CTXT_ARGS(ctxt_pP), PROTOCOL_CTXT_ARGS(ctxt_pP),
__FUNCTION__, __FUNCTION__,
...@@ -1206,7 +1173,7 @@ rrc_pdcp_config_asn1_req ( ...@@ -1206,7 +1173,7 @@ rrc_pdcp_config_asn1_req (
rlc_type = RLC_MODE_AM; rlc_type = RLC_MODE_AM;
lc_id = srb_id; lc_id = srb_id;
key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, srb_id, SRB_FLAG_YES); key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, srb_id, SRB_FLAG_YES);
h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p);
if (h_rc == HASH_TABLE_OK) { if (h_rc == HASH_TABLE_OK) {
action = CONFIG_ACTION_MODIFY; action = CONFIG_ACTION_MODIFY;
...@@ -1224,7 +1191,6 @@ rrc_pdcp_config_asn1_req ( ...@@ -1224,7 +1191,6 @@ rrc_pdcp_config_asn1_req (
key); key);
free(pdcp_p); free(pdcp_p);
return TRUE; return TRUE;
} else { } else {
LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_ADD key 0x%"PRIx64"\n", LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_ADD key 0x%"PRIx64"\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p), PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p),
...@@ -1296,10 +1262,9 @@ rrc_pdcp_config_asn1_req ( ...@@ -1296,10 +1262,9 @@ rrc_pdcp_config_asn1_req (
if (drb2add_list_pP != NULL) { if (drb2add_list_pP != NULL) {
for (cnt=0; cnt<drb2add_list_pP->list.count; cnt++) { for (cnt=0; cnt<drb2add_list_pP->list.count; cnt++) {
drb_toaddmod_p = drb2add_list_pP->list.array[cnt]; drb_toaddmod_p = drb2add_list_pP->list.array[cnt];
drb_id = drb_toaddmod_p->drb_Identity;// + drb_id_offset; drb_id = drb_toaddmod_p->drb_Identity;// + drb_id_offset;
if (drb_toaddmod_p->logicalChannelIdentity) { if (drb_toaddmod_p->logicalChannelIdentity) {
lc_id = *(drb_toaddmod_p->logicalChannelIdentity); lc_id = *(drb_toaddmod_p->logicalChannelIdentity);
} else { } else {
...@@ -1315,14 +1280,13 @@ rrc_pdcp_config_asn1_req ( ...@@ -1315,14 +1280,13 @@ rrc_pdcp_config_asn1_req (
DevCheck4(drb_id < LTE_maxDRB, drb_id, LTE_maxDRB, ctxt_pP->module_id, ctxt_pP->rnti); DevCheck4(drb_id < LTE_maxDRB, drb_id, LTE_maxDRB, ctxt_pP->module_id, ctxt_pP->rnti);
key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, drb_id, SRB_FLAG_NO); key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, drb_id, SRB_FLAG_NO);
h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p);
if (h_rc == HASH_TABLE_OK) { if (h_rc == HASH_TABLE_OK) {
action = CONFIG_ACTION_MODIFY; action = CONFIG_ACTION_MODIFY;
LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_MODIFY key 0x%"PRIx64"\n", LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_MODIFY key 0x%"PRIx64"\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p), PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p),
key); key);
} else { } else {
action = CONFIG_ACTION_ADD; action = CONFIG_ACTION_ADD;
pdcp_p = calloc(1, sizeof(pdcp_t)); pdcp_p = calloc(1, sizeof(pdcp_t));
...@@ -1437,7 +1401,7 @@ rrc_pdcp_config_asn1_req ( ...@@ -1437,7 +1401,7 @@ rrc_pdcp_config_asn1_req (
pdrb_id_p = drb2release_list_pP->list.array[cnt]; pdrb_id_p = drb2release_list_pP->list.array[cnt];
drb_id = *pdrb_id_p; drb_id = *pdrb_id_p;
key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, drb_id, SRB_FLAG_NO); key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, drb_id, SRB_FLAG_NO);
h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p);
if (h_rc != HASH_TABLE_OK) { if (h_rc != HASH_TABLE_OK) {
LOG_E(PDCP, PROTOCOL_CTXT_FMT" PDCP REMOVE FAILED drb_id %ld\n", LOG_E(PDCP, PROTOCOL_CTXT_FMT" PDCP REMOVE FAILED drb_id %ld\n",
...@@ -1445,8 +1409,8 @@ rrc_pdcp_config_asn1_req ( ...@@ -1445,8 +1409,8 @@ rrc_pdcp_config_asn1_req (
drb_id); drb_id);
continue; continue;
} }
lc_id = pdcp_p->lcid;
lc_id = pdcp_p->lcid;
action = CONFIG_ACTION_REMOVE; action = CONFIG_ACTION_REMOVE;
pdcp_config_req_asn1 ( pdcp_config_req_asn1 (
ctxt_pP, ctxt_pP,
...@@ -1469,7 +1433,7 @@ rrc_pdcp_config_asn1_req ( ...@@ -1469,7 +1433,7 @@ rrc_pdcp_config_asn1_req (
if ((defaultDRB != NULL) && (*defaultDRB == drb_id)) { if ((defaultDRB != NULL) && (*defaultDRB == drb_id)) {
// default DRB being removed. nevertheless this shouldn't happen as removing default DRB is not allowed in standard // default DRB being removed. nevertheless this shouldn't happen as removing default DRB is not allowed in standard
key_defaultDRB = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag); key_defaultDRB = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag);
h_defaultDRB_rc = hashtable_get(pdcp_coll_p, key_defaultDRB, (void**)&pdcp_p); h_defaultDRB_rc = hashtable_get(pdcp_coll_p, key_defaultDRB, (void **)&pdcp_p);
if (h_defaultDRB_rc == HASH_TABLE_OK) { if (h_defaultDRB_rc == HASH_TABLE_OK) {
h_defaultDRB_rc = hashtable_remove(pdcp_coll_p, key_defaultDRB); h_defaultDRB_rc = hashtable_remove(pdcp_coll_p, key_defaultDRB);
...@@ -1490,12 +1454,14 @@ rrc_pdcp_config_asn1_req ( ...@@ -1490,12 +1454,14 @@ rrc_pdcp_config_asn1_req (
for (j=0; j<mbms_SessionInfoList_r9_p->list.count; j++) { for (j=0; j<mbms_SessionInfoList_r9_p->list.count; j++) {
MBMS_SessionInfo_p = mbms_SessionInfoList_r9_p->list.array[j]; MBMS_SessionInfo_p = mbms_SessionInfoList_r9_p->list.array[j];
if (MBMS_SessionInfo_p->sessionId_r9) if (MBMS_SessionInfo_p->sessionId_r9)
lc_id = MBMS_SessionInfo_p->sessionId_r9->buf[0]; lc_id = MBMS_SessionInfo_p->sessionId_r9->buf[0];
else else
lc_id = MBMS_SessionInfo_p->logicalChannelIdentity_r9; lc_id = MBMS_SessionInfo_p->logicalChannelIdentity_r9;
mch_id = MBMS_SessionInfo_p->tmgi_r9.serviceId_r9.buf[2]; //serviceId is 3-octet string mch_id = MBMS_SessionInfo_p->tmgi_r9.serviceId_r9.buf[2]; //serviceId is 3-octet string
// mch_id = j; // mch_id = j;
// can set the mch_id = i // can set the mch_id = i
if (ctxt_pP->enb_flag) { if (ctxt_pP->enb_flag) {
...@@ -1523,7 +1489,6 @@ rrc_pdcp_config_asn1_req ( ...@@ -1523,7 +1489,6 @@ rrc_pdcp_config_asn1_req (
MBMS_SessionInfo_p->tmgi_r9.serviceId_r9.buf[2], MBMS_SessionInfo_p->tmgi_r9.serviceId_r9.buf[2],
drb_id, drb_id,
action); action);
pdcp_config_req_asn1 ( pdcp_config_req_asn1 (
ctxt_pP, ctxt_pP,
NULL, // unused for MBMS NULL, // unused for MBMS
...@@ -1551,8 +1516,8 @@ rrc_pdcp_config_asn1_req ( ...@@ -1551,8 +1516,8 @@ rrc_pdcp_config_asn1_req (
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
boolean_t boolean_t
pdcp_config_req_asn1 ( pdcp_config_req_asn1 (
const protocol_ctxt_t* const ctxt_pP, const protocol_ctxt_t *const ctxt_pP,
pdcp_t * const pdcp_pP, pdcp_t *const pdcp_pP,
const srb_flag_t srb_flagP, const srb_flag_t srb_flagP,
const rlc_mode_t rlc_modeP, const rlc_mode_t rlc_modeP,
const config_action_t actionP, const config_action_t actionP,
...@@ -1568,31 +1533,35 @@ pdcp_config_req_asn1 ( ...@@ -1568,31 +1533,35 @@ pdcp_config_req_asn1 (
uint8_t *const kUPenc_pP) uint8_t *const kUPenc_pP)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
{ {
switch (actionP) { switch (actionP) {
case CONFIG_ACTION_ADD: case CONFIG_ACTION_ADD:
DevAssert(pdcp_pP != NULL); DevAssert(pdcp_pP != NULL);
if (ctxt_pP->enb_flag == ENB_FLAG_YES) { if (ctxt_pP->enb_flag == ENB_FLAG_YES) {
pdcp_pP->is_ue = FALSE; pdcp_pP->is_ue = FALSE;
pdcp_add_UE(ctxt_pP); pdcp_add_UE(ctxt_pP);
//pdcp_eNB_UE_instance_to_rnti[ctxtP->module_id] = ctxt_pP->rnti; //pdcp_eNB_UE_instance_to_rnti[ctxtP->module_id] = ctxt_pP->rnti;
// pdcp_eNB_UE_instance_to_rnti[pdcp_eNB_UE_instance_to_rnti_index] = ctxt_pP->rnti; // pdcp_eNB_UE_instance_to_rnti[pdcp_eNB_UE_instance_to_rnti_index] = ctxt_pP->rnti;
if( srb_flagP == SRB_FLAG_NO ) { if( srb_flagP == SRB_FLAG_NO ) {
for(int i = 0;i<MAX_MOBILES_PER_ENB;i++){ for(int i = 0; i<MAX_MOBILES_PER_ENB; i++) {
if(pdcp_eNB_UE_instance_to_rnti[pdcp_eNB_UE_instance_to_rnti_index] == NOT_A_RNTI){ if(pdcp_eNB_UE_instance_to_rnti[pdcp_eNB_UE_instance_to_rnti_index] == NOT_A_RNTI) {
break; break;
} }
pdcp_eNB_UE_instance_to_rnti_index = (pdcp_eNB_UE_instance_to_rnti_index + 1) % MAX_MOBILES_PER_ENB; pdcp_eNB_UE_instance_to_rnti_index = (pdcp_eNB_UE_instance_to_rnti_index + 1) % MAX_MOBILES_PER_ENB;
} }
pdcp_eNB_UE_instance_to_rnti[pdcp_eNB_UE_instance_to_rnti_index] = ctxt_pP->rnti; pdcp_eNB_UE_instance_to_rnti[pdcp_eNB_UE_instance_to_rnti_index] = ctxt_pP->rnti;
pdcp_eNB_UE_instance_to_rnti_index = (pdcp_eNB_UE_instance_to_rnti_index + 1) % MAX_MOBILES_PER_ENB; pdcp_eNB_UE_instance_to_rnti_index = (pdcp_eNB_UE_instance_to_rnti_index + 1) % MAX_MOBILES_PER_ENB;
} }
//pdcp_eNB_UE_instance_to_rnti_index = (pdcp_eNB_UE_instance_to_rnti_index + 1) % MAX_MOBILES_PER_ENB; //pdcp_eNB_UE_instance_to_rnti_index = (pdcp_eNB_UE_instance_to_rnti_index + 1) % MAX_MOBILES_PER_ENB;
} else { } else {
pdcp_pP->is_ue = TRUE; pdcp_pP->is_ue = TRUE;
pdcp_UE_UE_module_id_to_rnti[ctxt_pP->module_id] = ctxt_pP->rnti; pdcp_UE_UE_module_id_to_rnti[ctxt_pP->module_id] = ctxt_pP->rnti;
} }
pdcp_pP->is_srb = (srb_flagP == SRB_FLAG_YES) ? TRUE : FALSE; pdcp_pP->is_srb = (srb_flagP == SRB_FLAG_YES) ? TRUE : FALSE;
pdcp_pP->lcid = lc_idP; pdcp_pP->lcid = lc_idP;
pdcp_pP->rb_id = rb_idP; pdcp_pP->rb_id = rb_idP;
...@@ -1607,7 +1576,6 @@ pdcp_config_req_asn1 ( ...@@ -1607,7 +1576,6 @@ pdcp_config_req_asn1 (
pdcp_pP->seq_num_size = PDCP_SN_5BIT; pdcp_pP->seq_num_size = PDCP_SN_5BIT;
} }
pdcp_pP->rlc_mode = rlc_modeP; pdcp_pP->rlc_mode = rlc_modeP;
pdcp_pP->next_pdcp_tx_sn = 0; pdcp_pP->next_pdcp_tx_sn = 0;
pdcp_pP->next_pdcp_rx_sn = 0; pdcp_pP->next_pdcp_rx_sn = 0;
...@@ -1617,7 +1585,6 @@ pdcp_config_req_asn1 ( ...@@ -1617,7 +1585,6 @@ pdcp_config_req_asn1 (
pdcp_pP->last_submitted_pdcp_rx_sn = 4095; pdcp_pP->last_submitted_pdcp_rx_sn = 4095;
pdcp_pP->first_missing_pdu = -1; pdcp_pP->first_missing_pdu = -1;
pdcp_pP->rx_hfn_offset = 0; pdcp_pP->rx_hfn_offset = 0;
LOG_I(PDCP, PROTOCOL_PDCP_CTXT_FMT" Action ADD LCID %d (%s id %d) " LOG_I(PDCP, PROTOCOL_PDCP_CTXT_FMT" Action ADD LCID %d (%s id %d) "
"configured with SN size %d bits and RLC %s\n", "configured with SN size %d bits and RLC %s\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_pP), PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_pP),
...@@ -1626,6 +1593,7 @@ pdcp_config_req_asn1 ( ...@@ -1626,6 +1593,7 @@ pdcp_config_req_asn1 (
rb_idP, rb_idP,
pdcp_pP->seq_num_size, pdcp_pP->seq_num_size,
(rlc_modeP == RLC_MODE_AM ) ? "AM" : (rlc_modeP == RLC_MODE_TM) ? "TM" : "UM"); (rlc_modeP == RLC_MODE_AM ) ? "AM" : (rlc_modeP == RLC_MODE_TM) ? "TM" : "UM");
/* Setup security */ /* Setup security */
if (security_modeP != 0xff) { if (security_modeP != 0xff) {
pdcp_config_set_security( pdcp_config_set_security(
...@@ -1638,6 +1606,7 @@ pdcp_config_req_asn1 ( ...@@ -1638,6 +1606,7 @@ pdcp_config_req_asn1 (
kRRCint_pP, kRRCint_pP,
kUPenc_pP); kUPenc_pP);
} }
break; break;
case CONFIG_ACTION_MODIFY: case CONFIG_ACTION_MODIFY:
...@@ -1678,7 +1647,7 @@ pdcp_config_req_asn1 ( ...@@ -1678,7 +1647,7 @@ pdcp_config_req_asn1 (
case CONFIG_ACTION_REMOVE: case CONFIG_ACTION_REMOVE:
DevAssert(pdcp_pP != NULL); DevAssert(pdcp_pP != NULL);
//#warning "TODO pdcp_module_id_to_rnti" //#warning "TODO pdcp_module_id_to_rnti"
//pdcp_module_id_to_rnti[ctxt_pP.module_id ][dst_id] = NOT_A_RNTI; //pdcp_module_id_to_rnti[ctxt_pP.module_id ][dst_id] = NOT_A_RNTI;
LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_REMOVE LCID %d RBID %d configured\n", LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_REMOVE LCID %d RBID %d configured\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_pP), PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_pP),
...@@ -1749,14 +1718,14 @@ pdcp_config_req_asn1 ( ...@@ -1749,14 +1718,14 @@ pdcp_config_req_asn1 (
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
pdcp_config_set_security( pdcp_config_set_security(
const protocol_ctxt_t* const ctxt_pP, const protocol_ctxt_t *const ctxt_pP,
pdcp_t * const pdcp_pP, pdcp_t *const pdcp_pP,
const rb_id_t rb_idP, const rb_id_t rb_idP,
const uint16_t lc_idP, const uint16_t lc_idP,
const uint8_t security_modeP, const uint8_t security_modeP,
uint8_t * const kRRCenc, uint8_t *const kRRCenc,
uint8_t * const kRRCint, uint8_t *const kRRCint,
uint8_t * const kUPenc) uint8_t *const kUPenc)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
{ {
DevAssert(pdcp_pP != NULL); DevAssert(pdcp_pP != NULL);
...@@ -1764,16 +1733,13 @@ pdcp_config_set_security( ...@@ -1764,16 +1733,13 @@ pdcp_config_set_security(
if ((security_modeP >= 0) && (security_modeP <= 0x77)) { if ((security_modeP >= 0) && (security_modeP <= 0x77)) {
pdcp_pP->cipheringAlgorithm = security_modeP & 0x0f; pdcp_pP->cipheringAlgorithm = security_modeP & 0x0f;
pdcp_pP->integrityProtAlgorithm = (security_modeP>>4) & 0xf; pdcp_pP->integrityProtAlgorithm = (security_modeP>>4) & 0xf;
LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_SET_SECURITY_MODE: cipheringAlgorithm %d integrityProtAlgorithm %d\n", LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_SET_SECURITY_MODE: cipheringAlgorithm %d integrityProtAlgorithm %d\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_pP), PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_pP),
pdcp_pP->cipheringAlgorithm, pdcp_pP->cipheringAlgorithm,
pdcp_pP->integrityProtAlgorithm); pdcp_pP->integrityProtAlgorithm);
pdcp_pP->kRRCenc = kRRCenc; pdcp_pP->kRRCenc = kRRCenc;
pdcp_pP->kRRCint = kRRCint; pdcp_pP->kRRCint = kRRCint;
pdcp_pP->kUPenc = kUPenc; pdcp_pP->kUPenc = kUPenc;
/* Activate security */ /* Activate security */
pdcp_pP->security_activated = 1; pdcp_pP->security_activated = 1;
MSC_LOG_EVENT( MSC_LOG_EVENT(
...@@ -1796,7 +1762,7 @@ pdcp_config_set_security( ...@@ -1796,7 +1762,7 @@ pdcp_config_set_security(
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
rrc_pdcp_config_req ( rrc_pdcp_config_req (
const protocol_ctxt_t* const ctxt_pP, const protocol_ctxt_t *const ctxt_pP,
const srb_flag_t srb_flagP, const srb_flag_t srb_flagP,
const uint32_t actionP, const uint32_t actionP,
const rb_id_t rb_idP, const rb_id_t rb_idP,
...@@ -1806,10 +1772,9 @@ rrc_pdcp_config_req ( ...@@ -1806,10 +1772,9 @@ rrc_pdcp_config_req (
pdcp_t *pdcp_p = NULL; pdcp_t *pdcp_p = NULL;
hash_key_t key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); hash_key_t key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP);
hashtable_rc_t h_rc; hashtable_rc_t h_rc;
h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p);
if (h_rc == HASH_TABLE_OK) { if (h_rc == HASH_TABLE_OK) {
/* /*
* Initialize sequence number state variables of relevant PDCP entity * Initialize sequence number state variables of relevant PDCP entity
*/ */
...@@ -1860,7 +1825,6 @@ rrc_pdcp_config_req ( ...@@ -1860,7 +1825,6 @@ rrc_pdcp_config_req (
pdcp_p->first_missing_pdu = -1; pdcp_p->first_missing_pdu = -1;
pdcp_p->security_activated = 0; pdcp_p->security_activated = 0;
h_rc = hashtable_remove(pdcp_coll_p, key); h_rc = hashtable_remove(pdcp_coll_p, key);
break; break;
case CONFIG_ACTION_SET_SECURITY_MODE: case CONFIG_ACTION_SET_SECURITY_MODE:
...@@ -1891,7 +1855,6 @@ rrc_pdcp_config_req ( ...@@ -1891,7 +1855,6 @@ rrc_pdcp_config_req (
LOG_E(PDCP, PROTOCOL_PDCP_CTXT_FMT" PDCP ADD FAILED\n", LOG_E(PDCP, PROTOCOL_PDCP_CTXT_FMT" PDCP ADD FAILED\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p)); PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p));
free(pdcp_p); free(pdcp_p);
} else { } else {
pdcp_p->is_srb = srb_flagP; pdcp_p->is_srb = srb_flagP;
pdcp_p->rb_id = rb_idP; pdcp_p->rb_id = rb_idP;
...@@ -1912,7 +1875,6 @@ rrc_pdcp_config_req ( ...@@ -1912,7 +1875,6 @@ rrc_pdcp_config_req (
if (rb_idP < DTCH) { // SRB if (rb_idP < DTCH) { // SRB
pdcp_p->seq_num_size = 5; pdcp_p->seq_num_size = 5;
} else { // DRB } else { // DRB
pdcp_p->seq_num_size = 12; pdcp_p->seq_num_size = 12;
} }
...@@ -1948,10 +1910,8 @@ pdcp_module_init ( ...@@ -1948,10 +1910,8 @@ pdcp_module_init (
) )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
{ {
#ifdef PDCP_USE_RT_FIFO #ifdef PDCP_USE_RT_FIFO
int ret; int ret;
ret=rtf_create(PDCP2NW_DRIVER_FIFO,32768); ret=rtf_create(PDCP2NW_DRIVER_FIFO,32768);
if (ret < 0) { if (ret < 0) {
...@@ -1966,7 +1926,6 @@ pdcp_module_init ( ...@@ -1966,7 +1926,6 @@ pdcp_module_init (
if (ret < 0) { if (ret < 0) {
LOG_E(PDCP, "Cannot create NW_DRIVER2PDCP_FIFO fifo %d (ERROR %d)\n", NW_DRIVER2PDCP_FIFO, ret); LOG_E(PDCP, "Cannot create NW_DRIVER2PDCP_FIFO fifo %d (ERROR %d)\n", NW_DRIVER2PDCP_FIFO, ret);
return -1; return -1;
} else { } else {
LOG_D(PDCP, "Created NW_DRIVER2PDCP_FIFO fifo %d\n", NW_DRIVER2PDCP_FIFO); LOG_D(PDCP, "Created NW_DRIVER2PDCP_FIFO fifo %d\n", NW_DRIVER2PDCP_FIFO);
...@@ -1977,18 +1936,17 @@ pdcp_module_init ( ...@@ -1977,18 +1936,17 @@ pdcp_module_init (
pdcp_input_sdu_remaining_size_to_read=0; pdcp_input_sdu_remaining_size_to_read=0;
pdcp_input_sdu_size_read=0; pdcp_input_sdu_size_read=0;
#endif #endif
return 0; return 0;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
pdcp_free ( pdcp_free (
void* pdcp_pP void *pdcp_pP
) )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
{ {
pdcp_t* pdcp_p = (pdcp_t*)pdcp_pP; pdcp_t *pdcp_p = (pdcp_t *)pdcp_pP;
if (pdcp_p != NULL) { if (pdcp_p != NULL) {
if (pdcp_p->kUPenc != NULL) { if (pdcp_p->kUPenc != NULL) {
...@@ -2022,7 +1980,6 @@ void pdcp_module_cleanup (void) ...@@ -2022,7 +1980,6 @@ void pdcp_module_cleanup (void)
void pdcp_layer_init(void) void pdcp_layer_init(void)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
{ {
module_id_t instance; module_id_t instance;
int i,j; int i,j;
#if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0))
...@@ -2044,11 +2001,12 @@ void pdcp_layer_init(void) ...@@ -2044,11 +2001,12 @@ void pdcp_layer_init(void)
memset(&pdcp_mbms_array_ue[instance][service_id][session_id], 0, sizeof(pdcp_mbms_t)); memset(&pdcp_mbms_array_ue[instance][service_id][session_id], 0, sizeof(pdcp_mbms_t));
} }
} }
#endif #endif
pdcp_eNB_UE_instance_to_rnti[instance] = NOT_A_RNTI; pdcp_eNB_UE_instance_to_rnti[instance] = NOT_A_RNTI;
} }
pdcp_eNB_UE_instance_to_rnti_index = 0;
pdcp_eNB_UE_instance_to_rnti_index = 0;
for (instance = 0; instance < NUMBER_OF_eNB_MAX; instance++) { for (instance = 0; instance < NUMBER_OF_eNB_MAX; instance++) {
#if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0))
...@@ -2064,23 +2022,21 @@ void pdcp_layer_init(void) ...@@ -2064,23 +2022,21 @@ void pdcp_layer_init(void)
#ifdef MBMS_MULTICAST_OUT #ifdef MBMS_MULTICAST_OUT
mbms_socket = socket(AF_INET, SOCK_RAW, IPPROTO_RAW); mbms_socket = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
if (mbms_socket == -1) if (mbms_socket == -1)
LOG_W(PDCP, "Could not create RAW socket, MBMS packets will not be put to the network\n"); LOG_W(PDCP, "Could not create RAW socket, MBMS packets will not be put to the network\n");
#endif
#endif
LOG_I(PDCP, "PDCP layer has been initialized\n"); LOG_I(PDCP, "PDCP layer has been initialized\n");
pdcp_output_sdu_bytes_to_write=0; pdcp_output_sdu_bytes_to_write=0;
pdcp_output_header_bytes_to_write=0; pdcp_output_header_bytes_to_write=0;
pdcp_input_sdu_remaining_size_to_read=0; pdcp_input_sdu_remaining_size_to_read=0;
memset(pdcp_enb, 0, sizeof(pdcp_enb_t)); memset(pdcp_enb, 0, sizeof(pdcp_enb_t));
memset(Pdcp_stats_tx_window_ms, 0, sizeof(Pdcp_stats_tx_window_ms)); memset(Pdcp_stats_tx_window_ms, 0, sizeof(Pdcp_stats_tx_window_ms));
memset(Pdcp_stats_rx_window_ms, 0, sizeof(Pdcp_stats_rx_window_ms)); memset(Pdcp_stats_rx_window_ms, 0, sizeof(Pdcp_stats_rx_window_ms));
for (i =0; i< MAX_NUM_CCs ; i ++){
for (j=0; j< MAX_MOBILES_PER_ENB;j++){ for (i =0; i< MAX_NUM_CCs ; i ++) {
for (j=0; j< MAX_MOBILES_PER_ENB; j++) {
Pdcp_stats_tx_window_ms[i][j]=100; Pdcp_stats_tx_window_ms[i][j]=100;
Pdcp_stats_rx_window_ms[i][j]=100; Pdcp_stats_rx_window_ms[i][j]=100;
} }
...@@ -2096,8 +2052,6 @@ void pdcp_layer_init(void) ...@@ -2096,8 +2052,6 @@ void pdcp_layer_init(void)
memset(Pdcp_stats_tx_throughput_w, 0, sizeof(Pdcp_stats_tx_throughput_w)); memset(Pdcp_stats_tx_throughput_w, 0, sizeof(Pdcp_stats_tx_throughput_w));
memset(Pdcp_stats_tx_aiat, 0, sizeof(Pdcp_stats_tx_aiat)); memset(Pdcp_stats_tx_aiat, 0, sizeof(Pdcp_stats_tx_aiat));
memset(Pdcp_stats_tx_iat, 0, sizeof(Pdcp_stats_tx_iat)); memset(Pdcp_stats_tx_iat, 0, sizeof(Pdcp_stats_tx_iat));
memset(Pdcp_stats_rx, 0, sizeof(Pdcp_stats_rx)); memset(Pdcp_stats_rx, 0, sizeof(Pdcp_stats_rx));
memset(Pdcp_stats_rx_w, 0, sizeof(Pdcp_stats_rx_w)); memset(Pdcp_stats_rx_w, 0, sizeof(Pdcp_stats_rx_w));
memset(Pdcp_stats_rx_tmp_w, 0, sizeof(Pdcp_stats_rx_tmp_w)); memset(Pdcp_stats_rx_tmp_w, 0, sizeof(Pdcp_stats_rx_tmp_w));
...@@ -2109,7 +2063,6 @@ void pdcp_layer_init(void) ...@@ -2109,7 +2063,6 @@ void pdcp_layer_init(void)
memset(Pdcp_stats_rx_aiat, 0, sizeof(Pdcp_stats_rx_aiat)); memset(Pdcp_stats_rx_aiat, 0, sizeof(Pdcp_stats_rx_aiat));
memset(Pdcp_stats_rx_iat, 0, sizeof(Pdcp_stats_rx_iat)); memset(Pdcp_stats_rx_iat, 0, sizeof(Pdcp_stats_rx_iat));
memset(Pdcp_stats_rx_outoforder, 0, sizeof(Pdcp_stats_rx_outoforder)); memset(Pdcp_stats_rx_outoforder, 0, sizeof(Pdcp_stats_rx_outoforder));
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -2117,15 +2070,17 @@ void pdcp_layer_cleanup (void) ...@@ -2117,15 +2070,17 @@ void pdcp_layer_cleanup (void)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
{ {
list_free (&pdcp_sdu_list); list_free (&pdcp_sdu_list);
hashtable_destroy(pdcp_coll_p); hashtable_destroy(&pdcp_coll_p);
#ifdef MBMS_MULTICAST_OUT #ifdef MBMS_MULTICAST_OUT
if(mbms_socket != -1) { if(mbms_socket != -1) {
close(mbms_socket); close(mbms_socket);
mbms_socket = -1; mbms_socket = -1;
} }
#endif #endif
} }
#ifdef PDCP_USE_RT_FIFO #ifdef PDCP_USE_RT_FIFO
EXPORT_SYMBOL(pdcp_2_nas_irq); EXPORT_SYMBOL(pdcp_2_nas_irq);
#endif //PDCP_USE_RT_FIFO #endif //PDCP_USE_RT_FIFO
...@@ -677,7 +677,7 @@ void ...@@ -677,7 +677,7 @@ void
rlc_module_cleanup (void) rlc_module_cleanup (void)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
{ {
hashtable_destroy(rlc_coll_p); hashtable_destroy(&rlc_coll_p);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
......
...@@ -50,9 +50,7 @@ static mapping rrc_status_names[] = { ...@@ -50,9 +50,7 @@ static mapping rrc_status_names[] = {
extern RAN_CONTEXT_t RC; extern RAN_CONTEXT_t RC;
int dump_eNB_l2_stats(char *buffer, int length) int dump_eNB_l2_stats(char *buffer, int length) {
{
int eNB_id,UE_id,number_of_cards; int eNB_id,UE_id,number_of_cards;
int len= length; int len= length;
int CC_id=0; int CC_id=0;
...@@ -87,7 +85,6 @@ int dump_eNB_l2_stats(char *buffer, int length) ...@@ -87,7 +85,6 @@ int dump_eNB_l2_stats(char *buffer, int length)
unsigned int stat_timer_reordering_timed_out; unsigned int stat_timer_reordering_timed_out;
unsigned int stat_timer_poll_retransmit_timed_out; unsigned int stat_timer_poll_retransmit_timed_out;
unsigned int stat_timer_status_prohibit_timed_out; unsigned int stat_timer_status_prohibit_timed_out;
#ifdef EXMIMO #ifdef EXMIMO
number_of_cards=1; number_of_cards=1;
#else #else
...@@ -103,7 +100,6 @@ int dump_eNB_l2_stats(char *buffer, int length) ...@@ -103,7 +100,6 @@ int dump_eNB_l2_stats(char *buffer, int length)
for (CC_id=0 ; CC_id < MAX_NUM_CCs; CC_id++) { for (CC_id=0 ; CC_id < MAX_NUM_CCs; CC_id++) {
eNB->eNB_stats[CC_id].dlsch_bitrate= 0; eNB->eNB_stats[CC_id].dlsch_bitrate= 0;
len += sprintf(&buffer[len],"eNB %d CC %d Frame %d: Active UEs %d, Available PRBs %d, nCCE %d, Scheduling decisions %d, Missed Deadlines %d \n", len += sprintf(&buffer[len],"eNB %d CC %d Frame %d: Active UEs %d, Available PRBs %d, nCCE %d, Scheduling decisions %d, Missed Deadlines %d \n",
eNB_id, CC_id, eNB->frame, eNB_id, CC_id, eNB->frame,
eNB->eNB_stats[CC_id].num_dlactive_UEs, eNB->eNB_stats[CC_id].num_dlactive_UEs,
...@@ -111,27 +107,22 @@ int dump_eNB_l2_stats(char *buffer, int length) ...@@ -111,27 +107,22 @@ int dump_eNB_l2_stats(char *buffer, int length)
eNB->eNB_stats[CC_id].available_ncces, eNB->eNB_stats[CC_id].available_ncces,
eNB->eNB_stats[CC_id].sched_decisions, eNB->eNB_stats[CC_id].sched_decisions,
eNB->eNB_stats[CC_id].missed_deadlines); eNB->eNB_stats[CC_id].missed_deadlines);
len += sprintf(&buffer[len],"BCCH , NB_TX_MAC = %d, transmitted bytes (TTI %d, total %d) MCS (TTI %d)\n", len += sprintf(&buffer[len],"BCCH , NB_TX_MAC = %d, transmitted bytes (TTI %d, total %d) MCS (TTI %d)\n",
eNB->eNB_stats[CC_id].total_num_bcch_pdu, eNB->eNB_stats[CC_id].total_num_bcch_pdu,
eNB->eNB_stats[CC_id].bcch_buffer, eNB->eNB_stats[CC_id].bcch_buffer,
eNB->eNB_stats[CC_id].total_bcch_buffer, eNB->eNB_stats[CC_id].total_bcch_buffer,
eNB->eNB_stats[CC_id].bcch_mcs); eNB->eNB_stats[CC_id].bcch_mcs);
len += sprintf(&buffer[len],"PCCH , NB_TX_MAC = %d, transmitted bytes (TTI %d, total %d) MCS (TTI %d)\n", len += sprintf(&buffer[len],"PCCH , NB_TX_MAC = %d, transmitted bytes (TTI %d, total %d) MCS (TTI %d)\n",
eNB->eNB_stats[CC_id].total_num_pcch_pdu, eNB->eNB_stats[CC_id].total_num_pcch_pdu,
eNB->eNB_stats[CC_id].pcch_buffer, eNB->eNB_stats[CC_id].pcch_buffer,
eNB->eNB_stats[CC_id].total_pcch_buffer, eNB->eNB_stats[CC_id].total_pcch_buffer,
eNB->eNB_stats[CC_id].pcch_mcs); eNB->eNB_stats[CC_id].pcch_mcs);
eNB->eNB_stats[CC_id].dlsch_bitrate=((eNB->eNB_stats[CC_id].dlsch_bytes_tx*8)/((eNB->frame + 1)*10)); eNB->eNB_stats[CC_id].dlsch_bitrate=((eNB->eNB_stats[CC_id].dlsch_bytes_tx*8)/((eNB->frame + 1)*10));
eNB->eNB_stats[CC_id].total_dlsch_pdus_tx+=eNB->eNB_stats[CC_id].dlsch_pdus_tx; eNB->eNB_stats[CC_id].total_dlsch_pdus_tx+=eNB->eNB_stats[CC_id].dlsch_pdus_tx;
eNB->eNB_stats[CC_id].total_dlsch_bytes_tx+=eNB->eNB_stats[CC_id].dlsch_bytes_tx; eNB->eNB_stats[CC_id].total_dlsch_bytes_tx+=eNB->eNB_stats[CC_id].dlsch_bytes_tx;
eNB->eNB_stats[CC_id].total_dlsch_bitrate=((eNB->eNB_stats[CC_id].total_dlsch_bytes_tx*8)/((eNB->frame + 1)*10)); eNB->eNB_stats[CC_id].total_dlsch_bitrate=((eNB->eNB_stats[CC_id].total_dlsch_bytes_tx*8)/((eNB->frame + 1)*10));
eNB->eNB_stats[CC_id].ulsch_bitrate=((eNB->eNB_stats[CC_id].ulsch_bytes_rx*8)/((eNB->frame + 1)*10)); eNB->eNB_stats[CC_id].ulsch_bitrate=((eNB->eNB_stats[CC_id].ulsch_bytes_rx*8)/((eNB->frame + 1)*10));
eNB->eNB_stats[CC_id].total_ulsch_bitrate=((eNB->eNB_stats[CC_id].total_ulsch_bytes_rx*8)/((eNB->frame + 1)*10)); eNB->eNB_stats[CC_id].total_ulsch_bitrate=((eNB->eNB_stats[CC_id].total_ulsch_bytes_rx*8)/((eNB->frame + 1)*10));
len += sprintf(&buffer[len],"DLSCH bitrate (TTI %u, avg %u) kbps, Transmitted bytes (TTI %u, total %u), Transmitted PDU (TTI %u, total %u) \n", len += sprintf(&buffer[len],"DLSCH bitrate (TTI %u, avg %u) kbps, Transmitted bytes (TTI %u, total %u), Transmitted PDU (TTI %u, total %u) \n",
eNB->eNB_stats[CC_id].dlsch_bitrate, eNB->eNB_stats[CC_id].dlsch_bitrate,
eNB->eNB_stats[CC_id].total_dlsch_bitrate, eNB->eNB_stats[CC_id].total_dlsch_bitrate,
...@@ -139,7 +130,6 @@ int dump_eNB_l2_stats(char *buffer, int length) ...@@ -139,7 +130,6 @@ int dump_eNB_l2_stats(char *buffer, int length)
eNB->eNB_stats[CC_id].total_dlsch_bytes_tx, eNB->eNB_stats[CC_id].total_dlsch_bytes_tx,
eNB->eNB_stats[CC_id].dlsch_pdus_tx, eNB->eNB_stats[CC_id].dlsch_pdus_tx,
eNB->eNB_stats[CC_id].total_dlsch_pdus_tx); eNB->eNB_stats[CC_id].total_dlsch_pdus_tx);
len += sprintf(&buffer[len],"ULSCH bitrate (TTI %u, avg %u) kbps, Received bytes (TTI %u, total %u), Received PDU (TTI %lu, total %u) \n", len += sprintf(&buffer[len],"ULSCH bitrate (TTI %u, avg %u) kbps, Received bytes (TTI %u, total %u), Received PDU (TTI %lu, total %u) \n",
eNB->eNB_stats[CC_id].ulsch_bitrate, eNB->eNB_stats[CC_id].ulsch_bitrate,
eNB->eNB_stats[CC_id].total_ulsch_bitrate, eNB->eNB_stats[CC_id].total_ulsch_bitrate,
...@@ -154,15 +144,12 @@ int dump_eNB_l2_stats(char *buffer, int length) ...@@ -154,15 +144,12 @@ int dump_eNB_l2_stats(char *buffer, int length)
for (UE_id=UE_list->head; UE_id>=0; UE_id=UE_list->next[UE_id]) { for (UE_id=UE_list->head; UE_id>=0; UE_id=UE_list->next[UE_id]) {
for (i=0; i<UE_list->numactiveCCs[UE_id]; i++) { for (i=0; i<UE_list->numactiveCCs[UE_id]; i++) {
CC_id=UE_list->ordered_CCids[i][UE_id]; CC_id=UE_list->ordered_CCids[i][UE_id];
UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_bitrate=((UE_list->eNB_UE_stats[CC_id][UE_id].TBS*8)/((eNB->frame + 1)*10)); UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_bitrate=((UE_list->eNB_UE_stats[CC_id][UE_id].TBS*8)/((eNB->frame + 1)*10));
UE_list->eNB_UE_stats[CC_id][UE_id].total_dlsch_bitrate= ((UE_list->eNB_UE_stats[CC_id][UE_id].total_pdu_bytes*8)/((eNB->frame + 1)*10)); UE_list->eNB_UE_stats[CC_id][UE_id].total_dlsch_bitrate= ((UE_list->eNB_UE_stats[CC_id][UE_id].total_pdu_bytes*8)/((eNB->frame + 1)*10));
UE_list->eNB_UE_stats[CC_id][UE_id].total_overhead_bytes+= UE_list->eNB_UE_stats[CC_id][UE_id].overhead_bytes; UE_list->eNB_UE_stats[CC_id][UE_id].total_overhead_bytes+= UE_list->eNB_UE_stats[CC_id][UE_id].overhead_bytes;
UE_list->eNB_UE_stats[CC_id][UE_id].avg_overhead_bytes=((UE_list->eNB_UE_stats[CC_id][UE_id].total_overhead_bytes*8)/((eNB->frame + 1)*10)); UE_list->eNB_UE_stats[CC_id][UE_id].avg_overhead_bytes=((UE_list->eNB_UE_stats[CC_id][UE_id].total_overhead_bytes*8)/((eNB->frame + 1)*10));
UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_bitrate=((UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS*8)/((eNB->frame + 1)*10)); UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_bitrate=((UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS*8)/((eNB->frame + 1)*10));
UE_list->eNB_UE_stats[CC_id][UE_id].total_ulsch_bitrate= ((UE_list->eNB_UE_stats[CC_id][UE_id].total_pdu_bytes_rx*8)/((eNB->frame + 1)*10)); UE_list->eNB_UE_stats[CC_id][UE_id].total_ulsch_bitrate= ((UE_list->eNB_UE_stats[CC_id][UE_id].total_pdu_bytes_rx*8)/((eNB->frame + 1)*10));
len += sprintf(&buffer[len],"[MAC] UE %d (DLSCH),status %s, RNTI %x : CQI %d, MCS1 %d, MCS2 %d, RB (tx %d, retx %d, total %d), ncce (tx %d, retx %d) \n", len += sprintf(&buffer[len],"[MAC] UE %d (DLSCH),status %s, RNTI %x : CQI %d, MCS1 %d, MCS2 %d, RB (tx %d, retx %d, total %d), ncce (tx %d, retx %d) \n",
UE_id, UE_id,
map_int_to_str(rrc_status_names, UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status), map_int_to_str(rrc_status_names, UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status),
...@@ -176,7 +163,6 @@ int dump_eNB_l2_stats(char *buffer, int length) ...@@ -176,7 +163,6 @@ int dump_eNB_l2_stats(char *buffer, int length)
UE_list->eNB_UE_stats[CC_id][UE_id].ncce_used, UE_list->eNB_UE_stats[CC_id][UE_id].ncce_used,
UE_list->eNB_UE_stats[CC_id][UE_id].ncce_used_retx UE_list->eNB_UE_stats[CC_id][UE_id].ncce_used_retx
); );
len += sprintf(&buffer[len], len += sprintf(&buffer[len],
"[MAC] DLSCH bitrate (TTI %d, avg %d), Transmitted bytes " "[MAC] DLSCH bitrate (TTI %d, avg %d), Transmitted bytes "
"(TTI %d, total %"PRIu64"), Total Transmitted PDU %d, Overhead " "(TTI %d, total %"PRIu64"), Total Transmitted PDU %d, Overhead "
...@@ -190,8 +176,6 @@ int dump_eNB_l2_stats(char *buffer, int length) ...@@ -190,8 +176,6 @@ int dump_eNB_l2_stats(char *buffer, int length)
UE_list->eNB_UE_stats[CC_id][UE_id].total_overhead_bytes, UE_list->eNB_UE_stats[CC_id][UE_id].total_overhead_bytes,
UE_list->eNB_UE_stats[CC_id][UE_id].avg_overhead_bytes UE_list->eNB_UE_stats[CC_id][UE_id].avg_overhead_bytes
); );
len += sprintf(&buffer[len],"[MAC] UE %d (ULSCH), Status %s, Failute timer %d, RNTI %x : rx power (normalized %d, target %d), MCS (pre %d, post %d), RB (rx %d, retx %d, total %d), Current TBS %d \n", len += sprintf(&buffer[len],"[MAC] UE %d (ULSCH), Status %s, Failute timer %d, RNTI %x : rx power (normalized %d, target %d), MCS (pre %d, post %d), RB (rx %d, retx %d, total %d), Current TBS %d \n",
UE_id, UE_id,
map_int_to_str(rrc_status_names, UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status), map_int_to_str(rrc_status_names, UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status),
...@@ -206,7 +190,6 @@ int dump_eNB_l2_stats(char *buffer, int length) ...@@ -206,7 +190,6 @@ int dump_eNB_l2_stats(char *buffer, int length)
UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx, UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx,
UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS
); );
len += sprintf(&buffer[len], len += sprintf(&buffer[len],
"[MAC] ULSCH bitrate (TTI %d, avg %d), received bytes (total %"PRIu64")," "[MAC] ULSCH bitrate (TTI %d, avg %d), received bytes (total %"PRIu64"),"
"Total received PDU %d, Total errors %d\n", "Total received PDU %d, Total errors %d\n",
...@@ -215,7 +198,6 @@ int dump_eNB_l2_stats(char *buffer, int length) ...@@ -215,7 +198,6 @@ int dump_eNB_l2_stats(char *buffer, int length)
UE_list->eNB_UE_stats[CC_id][UE_id].total_pdu_bytes_rx, UE_list->eNB_UE_stats[CC_id][UE_id].total_pdu_bytes_rx,
UE_list->eNB_UE_stats[CC_id][UE_id].total_num_pdus_rx, UE_list->eNB_UE_stats[CC_id][UE_id].total_num_pdus_rx,
UE_list->eNB_UE_stats[CC_id][UE_id].num_errors_rx); UE_list->eNB_UE_stats[CC_id][UE_id].num_errors_rx);
len+= sprintf(&buffer[len],"[MAC] Received PHR PH = %d (db)\n", UE_list->UE_template[CC_id][UE_id].phr_info); len+= sprintf(&buffer[len],"[MAC] Received PHR PH = %d (db)\n", UE_list->UE_template[CC_id][UE_id].phr_info);
len+= sprintf(&buffer[len],"[MAC] Estimated size LCGID[0][1][2][3] = %u %u %u %u\n", len+= sprintf(&buffer[len],"[MAC] Estimated size LCGID[0][1][2][3] = %u %u %u %u\n",
UE_list->UE_template[CC_id][UE_id].ul_buffer_info[LCGID0], UE_list->UE_template[CC_id][UE_id].ul_buffer_info[LCGID0],
...@@ -232,7 +214,6 @@ int dump_eNB_l2_stats(char *buffer, int length) ...@@ -232,7 +214,6 @@ int dump_eNB_l2_stats(char *buffer, int length)
eNB->frame, eNB->frame,
eNB->subframe, eNB->subframe,
eNB_id); eNB_id);
rlc_status = rlc_stat_req(&ctxt, rlc_status = rlc_stat_req(&ctxt,
SRB_FLAG_YES, SRB_FLAG_YES,
DCCH, DCCH,
...@@ -272,7 +253,6 @@ int dump_eNB_l2_stats(char *buffer, int length) ...@@ -272,7 +253,6 @@ int dump_eNB_l2_stats(char *buffer, int length)
stat_tx_pdcp_bytes, stat_tx_pdcp_bytes,
stat_tx_pdcp_sdu_discarded, stat_tx_pdcp_sdu_discarded,
stat_tx_pdcp_bytes_discarded); stat_tx_pdcp_bytes_discarded);
len+=sprintf(&buffer[len],"[RLC] DCCH Mode %s, NB_TX_DATA = %d (bytes %d)\tNB_TX_CONTROL %d (bytes %d)\tNB_TX_RETX %d (bytes %d)\tNB_TX_RETX_BY_STATUS = %d (bytes %d)\n", len+=sprintf(&buffer[len],"[RLC] DCCH Mode %s, NB_TX_DATA = %d (bytes %d)\tNB_TX_CONTROL %d (bytes %d)\tNB_TX_RETX %d (bytes %d)\tNB_TX_RETX_BY_STATUS = %d (bytes %d)\n",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE", (stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_tx_data_pdu, stat_tx_data_pdu,
...@@ -283,8 +263,6 @@ int dump_eNB_l2_stats(char *buffer, int length) ...@@ -283,8 +263,6 @@ int dump_eNB_l2_stats(char *buffer, int length)
stat_tx_retransmit_bytes, stat_tx_retransmit_bytes,
stat_tx_retransmit_pdu_by_status, stat_tx_retransmit_pdu_by_status,
stat_tx_retransmit_bytes_by_status); stat_tx_retransmit_bytes_by_status);
len+=sprintf(&buffer[len],"[RLC] DCCH Mode %s, NB_RX_DATA = %d (bytes %d)\tNB_RX_CONTROL %d (bytes %d)\tNB_RX_DUPL %d (bytes %d)\tNB_RX_DROP = %d (bytes %d)\tNB_RX_OUT_OF_WINDOW = %d (bytes %d)\n", len+=sprintf(&buffer[len],"[RLC] DCCH Mode %s, NB_RX_DATA = %d (bytes %d)\tNB_RX_CONTROL %d (bytes %d)\tNB_RX_DUPL %d (bytes %d)\tNB_RX_DROP = %d (bytes %d)\tNB_RX_OUT_OF_WINDOW = %d (bytes %d)\n",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE", (stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_rx_data_pdu, stat_rx_data_pdu,
...@@ -297,14 +275,11 @@ int dump_eNB_l2_stats(char *buffer, int length) ...@@ -297,14 +275,11 @@ int dump_eNB_l2_stats(char *buffer, int length)
stat_rx_data_bytes_dropped, stat_rx_data_bytes_dropped,
stat_rx_data_pdu_out_of_window, stat_rx_data_pdu_out_of_window,
stat_rx_data_bytes_out_of_window); stat_rx_data_bytes_out_of_window);
len+=sprintf(&buffer[len],"[RLC] DCCH Mode %s, RX_REODERING_TIMEOUT = %d\tRX_POLL_RET_TIMEOUT %d\tRX_PROHIBIT_TIME_OUT %d\n", len+=sprintf(&buffer[len],"[RLC] DCCH Mode %s, RX_REODERING_TIMEOUT = %d\tRX_POLL_RET_TIMEOUT %d\tRX_PROHIBIT_TIME_OUT %d\n",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE", (stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_timer_reordering_timed_out, stat_timer_reordering_timed_out,
stat_timer_poll_retransmit_timed_out, stat_timer_poll_retransmit_timed_out,
stat_timer_status_prohibit_timed_out); stat_timer_status_prohibit_timed_out);
len+=sprintf(&buffer[len],"[RLC] DCCH Mode %s, NB_SDU_TO_RX = %d (bytes %d)\n", len+=sprintf(&buffer[len],"[RLC] DCCH Mode %s, NB_SDU_TO_RX = %d (bytes %d)\n",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE", (stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_rx_pdcp_sdu, stat_rx_pdcp_sdu,
...@@ -350,7 +325,6 @@ int dump_eNB_l2_stats(char *buffer, int length) ...@@ -350,7 +325,6 @@ int dump_eNB_l2_stats(char *buffer, int length)
stat_tx_pdcp_bytes, stat_tx_pdcp_bytes,
stat_tx_pdcp_sdu_discarded, stat_tx_pdcp_sdu_discarded,
stat_tx_pdcp_bytes_discarded); stat_tx_pdcp_bytes_discarded);
len+=sprintf(&buffer[len],"[RLC] DTCH Mode %s, NB_TX_DATA = %d (bytes %d)\tNB_TX_CONTROL %d (bytes %d)\tNB_TX_RETX %d (bytes %d)\tNB_TX_RETX_BY_STATUS = %d (bytes %d)\n", len+=sprintf(&buffer[len],"[RLC] DTCH Mode %s, NB_TX_DATA = %d (bytes %d)\tNB_TX_CONTROL %d (bytes %d)\tNB_TX_RETX %d (bytes %d)\tNB_TX_RETX_BY_STATUS = %d (bytes %d)\n",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE", (stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_tx_data_pdu, stat_tx_data_pdu,
...@@ -361,8 +335,6 @@ int dump_eNB_l2_stats(char *buffer, int length) ...@@ -361,8 +335,6 @@ int dump_eNB_l2_stats(char *buffer, int length)
stat_tx_retransmit_bytes, stat_tx_retransmit_bytes,
stat_tx_retransmit_pdu_by_status, stat_tx_retransmit_pdu_by_status,
stat_tx_retransmit_bytes_by_status); stat_tx_retransmit_bytes_by_status);
len+=sprintf(&buffer[len],"[RLC] DTCH Mode %s, NB_RX_DATA = %d (bytes %d)\tNB_RX_CONTROL %d (bytes %d)\tNB_RX_DUPL %d (bytes %d)\tNB_RX_DROP = %d (bytes %d)\tNB_RX_OUT_OF_WINDOW = %d (bytes %d)\n", len+=sprintf(&buffer[len],"[RLC] DTCH Mode %s, NB_RX_DATA = %d (bytes %d)\tNB_RX_CONTROL %d (bytes %d)\tNB_RX_DUPL %d (bytes %d)\tNB_RX_DROP = %d (bytes %d)\tNB_RX_OUT_OF_WINDOW = %d (bytes %d)\n",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE", (stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_rx_data_pdu, stat_rx_data_pdu,
...@@ -375,30 +347,23 @@ int dump_eNB_l2_stats(char *buffer, int length) ...@@ -375,30 +347,23 @@ int dump_eNB_l2_stats(char *buffer, int length)
stat_rx_data_bytes_dropped, stat_rx_data_bytes_dropped,
stat_rx_data_pdu_out_of_window, stat_rx_data_pdu_out_of_window,
stat_rx_data_bytes_out_of_window); stat_rx_data_bytes_out_of_window);
len+=sprintf(&buffer[len],"[RLC] DTCH Mode %s, RX_REODERING_TIMEOUT = %d\tRX_POLL_RET_TIMEOUT %d\tRX_PROHIBIT_TIME_OUT %d\n", len+=sprintf(&buffer[len],"[RLC] DTCH Mode %s, RX_REODERING_TIMEOUT = %d\tRX_POLL_RET_TIMEOUT %d\tRX_PROHIBIT_TIME_OUT %d\n",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE", (stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_timer_reordering_timed_out, stat_timer_reordering_timed_out,
stat_timer_poll_retransmit_timed_out, stat_timer_poll_retransmit_timed_out,
stat_timer_status_prohibit_timed_out); stat_timer_status_prohibit_timed_out);
len+=sprintf(&buffer[len],"[RLC] DTCH Mode %s, NB_SDU_TO_RX = %d (bytes %d)\n", len+=sprintf(&buffer[len],"[RLC] DTCH Mode %s, NB_SDU_TO_RX = %d (bytes %d)\n",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE", (stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_rx_pdcp_sdu, stat_rx_pdcp_sdu,
stat_rx_pdcp_bytes); stat_rx_pdcp_bytes);
} }
} }
} }
return len + 1 /* SR: for trailing \0 */; return len + 1 /* SR: for trailing \0 */;
} }
#ifdef PROC #ifdef PROC
int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) {
{
int len = 0,fg,Overhead, Sign; int len = 0,fg,Overhead, Sign;
unsigned int i,j,k,kk; unsigned int i,j,k,kk;
unsigned int Mod_id = 0,CH_index; unsigned int Mod_id = 0,CH_index;
...@@ -417,18 +382,12 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) ...@@ -417,18 +382,12 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length)
// if (mac_xface->is_cluster_head == 0) { // if (mac_xface->is_cluster_head == 0) {
for (k=0; k<NB_INST; k++) { for (k=0; k<NB_INST; k++) {
if (Mac_rlc_xface->Is_cluster_head[k] == 0) { if (Mac_rlc_xface->Is_cluster_head[k] == 0) {
#ifndef PHY_EMUL_ONE_MACHINE #ifndef PHY_EMUL_ONE_MACHINE
Mod_id=k-NB_CH_INST; Mod_id=k-NB_CH_INST;
len+=sprintf(&buffer[len],"UE TTI: %d\n",Mac_rlc_xface->frame); len+=sprintf(&buffer[len],"UE TTI: %d\n",Mac_rlc_xface->frame);
for (CH_index = 0; CH_index<NB_CNX_UE; CH_index++) { for (CH_index = 0; CH_index<NB_CNX_UE; CH_index++) {
if (UE_mac_inst[Mod_id].Dcch_lchan[CH_index].Active==1) { if (UE_mac_inst[Mod_id].Dcch_lchan[CH_index].Active==1) {
len+=sprintf(&buffer[len],"CH %d: Wideband SINR %d dB---\n", len+=sprintf(&buffer[len],"CH %d: Wideband SINR %d dB---\n",
CH_index,UE_mac_inst[Mod_id].Def_meas[CH_index].Wideband_sinr); CH_index,UE_mac_inst[Mod_id].Def_meas[CH_index].Wideband_sinr);
...@@ -440,21 +399,14 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) ...@@ -440,21 +399,14 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length)
} }
len+=sprintf(&buffer[len],"\n"); len+=sprintf(&buffer[len],"\n");
len+=sprintf(&buffer[len],"BCCH %d, NB_RX_MAC = %d (%d errors)\n", len+=sprintf(&buffer[len],"BCCH %d, NB_RX_MAC = %d (%d errors)\n",
UE_mac_inst[Mod_id].Bcch_lchan[CH_index].Lchan_info.Lchan_id.Index, UE_mac_inst[Mod_id].Bcch_lchan[CH_index].Lchan_info.Lchan_id.Index,
UE_mac_inst[Mod_id].Bcch_lchan[CH_index].Lchan_info.NB_RX, UE_mac_inst[Mod_id].Bcch_lchan[CH_index].Lchan_info.NB_RX,
UE_mac_inst[Mod_id].Bcch_lchan[CH_index].Lchan_info.NB_RX_ERRORS); UE_mac_inst[Mod_id].Bcch_lchan[CH_index].Lchan_info.NB_RX_ERRORS);
len+=sprintf(&buffer[len],"CCCH %d, NB_RX_MAC = %d (%d errors)\n", len+=sprintf(&buffer[len],"CCCH %d, NB_RX_MAC = %d (%d errors)\n",
UE_mac_inst[Mod_id].Ccch_lchan[CH_index].Lchan_info.Lchan_id.Index, UE_mac_inst[Mod_id].Ccch_lchan[CH_index].Lchan_info.Lchan_id.Index,
UE_mac_inst[Mod_id].Ccch_lchan[CH_index].Lchan_info.NB_RX, UE_mac_inst[Mod_id].Ccch_lchan[CH_index].Lchan_info.NB_RX,
UE_mac_inst[Mod_id].Ccch_lchan[CH_index].Lchan_info.NB_RX_ERRORS); UE_mac_inst[Mod_id].Ccch_lchan[CH_index].Lchan_info.NB_RX_ERRORS);
len+=sprintf(&buffer[len],"LCHAN %d (DCCH), NB_TX_MAC = %d (%d bits/TTI, %d kbits/sec), NB_RX_MAC = %d (%d errors)\n", len+=sprintf(&buffer[len],"LCHAN %d (DCCH), NB_TX_MAC = %d (%d bits/TTI, %d kbits/sec), NB_RX_MAC = %d (%d errors)\n",
UE_mac_inst[Mod_id].Dcch_lchan[CH_index].Lchan_info.Lchan_id.Index, UE_mac_inst[Mod_id].Dcch_lchan[CH_index].Lchan_info.Lchan_id.Index,
UE_mac_inst[Mod_id].Dcch_lchan[CH_index].Lchan_info.NB_TX, UE_mac_inst[Mod_id].Dcch_lchan[CH_index].Lchan_info.NB_TX,
...@@ -484,8 +436,6 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) ...@@ -484,8 +436,6 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length)
Pdcp_stats_rx_rate[k][CH_index][i], Pdcp_stats_rx_rate[k][CH_index][i],
(10*Pdcp_stats_rx_rate[k][CH_index][i])>>5, (10*Pdcp_stats_rx_rate[k][CH_index][i])>>5,
Sign*(10*Overhead)>>5); Sign*(10*Overhead)>>5);
int status = rlc_stat_req (k, int status = rlc_stat_req (k,
UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.Lchan_id.Index, UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.Lchan_id.Index,
&tx_pdcp_sdu, &tx_pdcp_sdu,
...@@ -544,18 +494,13 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) ...@@ -544,18 +494,13 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length)
UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.NB_RX_TB[kk]); UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.NB_RX_TB[kk]);
len+=sprintf(&buffer[len],"\n"); len+=sprintf(&buffer[len],"\n");
} }
} }
} }
} }
#endif //PHY_EMUL_ONE_MACHINE #endif //PHY_EMUL_ONE_MACHINE
} else if(Mac_rlc_xface->Is_cluster_head[k] ==1) { } else if(Mac_rlc_xface->Is_cluster_head[k] ==1) {
Mod_id=k; Mod_id=k;
len+=sprintf(&buffer[len], len+=sprintf(&buffer[len],
"-------------------------------------------------------------------CH %d: TTI: %d------------------------------------------------------------------\n", "-------------------------------------------------------------------CH %d: TTI: %d------------------------------------------------------------------\n",
...@@ -567,7 +512,6 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) ...@@ -567,7 +512,6 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length)
i,//CH_rrc_inst[Mod_id].Info.UE_list[i].L2_id[0], i,//CH_rrc_inst[Mod_id].Info.UE_list[i].L2_id[0],
CH_mac_inst[Mod_id].Def_meas[i].Wideband_sinr, CH_mac_inst[Mod_id].Def_meas[i].Wideband_sinr,
print_cqi(CH_mac_inst[Mod_id].Def_meas[i].cqi)); print_cqi(CH_mac_inst[Mod_id].Def_meas[i].cqi));
len+=sprintf(&buffer[len], len+=sprintf(&buffer[len],
"[MAC] LCHAN %d (DCCH), NB_TX_MAC= %d (%d bits/TTI, %d kbits/s), NB_RX_MAC= %d (errors %d, sacch errors %d, sach errors %d, sach_missing %d)\n\n", "[MAC] LCHAN %d (DCCH), NB_TX_MAC= %d (%d bits/TTI, %d kbits/s), NB_RX_MAC= %d (errors %d, sacch errors %d, sach errors %d, sach_missing %d)\n\n",
CH_mac_inst[Mod_id].Dcch_lchan[i].Lchan_info.Lchan_id.Index, CH_mac_inst[Mod_id].Dcch_lchan[i].Lchan_info.Lchan_id.Index,
...@@ -656,7 +600,6 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) ...@@ -656,7 +600,6 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length)
CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.Req_rate, CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.Req_rate,
CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.Rx_rate, CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.Rx_rate,
CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.NB_BW_REQ_RX); CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.NB_BW_REQ_RX);
/* /*
len+=sprintf(&buffer[len]," TX per TB: "); len+=sprintf(&buffer[len]," TX per TB: ");
for(kk=0;kk<MAX_NUMBER_TB_PER_LCHAN/2;kk++) for(kk=0;kk<MAX_NUMBER_TB_PER_LCHAN/2;kk++)
...@@ -672,7 +615,6 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) ...@@ -672,7 +615,6 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length)
} }
} }
} }
} }
} }
......
...@@ -61,8 +61,7 @@ extern RAN_CONTEXT_t RC; ...@@ -61,8 +61,7 @@ extern RAN_CONTEXT_t RC;
static int gtpv1u_dump_socket_g; static int gtpv1u_dump_socket_g;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
int gtpv1u_eNB_create_dump_socket(void) int gtpv1u_eNB_create_dump_socket(void) {
{
struct ifreq ifr; struct ifreq ifr;
int hdrincl=1; int hdrincl=1;
...@@ -92,8 +91,7 @@ int gtpv1u_eNB_create_dump_socket(void) ...@@ -92,8 +91,7 @@ int gtpv1u_eNB_create_dump_socket(void)
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void gtpv1u_eNB_write_dump_socket(uint8_t *buffer_pP, uint32_t buffer_lengthP) static void gtpv1u_eNB_write_dump_socket(uint8_t *buffer_pP, uint32_t buffer_lengthP) {
{
struct sockaddr_in sin; struct sockaddr_in sin;
memset(&sin, 0, sizeof(sin)); memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET; sin.sin_family = AF_INET;
...@@ -108,12 +106,10 @@ static void gtpv1u_eNB_write_dump_socket(uint8_t *buffer_pP, uint32_t buffer_len ...@@ -108,12 +106,10 @@ static void gtpv1u_eNB_write_dump_socket(uint8_t *buffer_pP, uint32_t buffer_len
#endif #endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static int gtpv1u_eNB_send_init_udp(const Gtpv1uS1Req * req) static int gtpv1u_eNB_send_init_udp(const Gtpv1uS1Req *req) {
{
// Create and alloc new message // Create and alloc new message
MessageDef *message_p; MessageDef *message_p;
struct in_addr addr={0}; struct in_addr addr= {0};
message_p = itti_alloc_new_message(TASK_GTPV1_U, UDP_INIT); message_p = itti_alloc_new_message(TASK_GTPV1_U, UDP_INIT);
if (message_p == NULL) { if (message_p == NULL) {
...@@ -124,7 +120,6 @@ static int gtpv1u_eNB_send_init_udp(const Gtpv1uS1Req * req) ...@@ -124,7 +120,6 @@ static int gtpv1u_eNB_send_init_udp(const Gtpv1uS1Req * req)
addr.s_addr = req->enb_ip_address_for_S1u_S12_S4_up; addr.s_addr = req->enb_ip_address_for_S1u_S12_S4_up;
UDP_INIT(message_p).address = inet_ntoa(addr); UDP_INIT(message_p).address = inet_ntoa(addr);
LOG_I(GTPU, "Tx UDP_INIT IP addr %s (%x)\n", UDP_INIT(message_p).address,UDP_INIT(message_p).port); LOG_I(GTPU, "Tx UDP_INIT IP addr %s (%x)\n", UDP_INIT(message_p).address,UDP_INIT(message_p).port);
MSC_LOG_EVENT( MSC_LOG_EVENT(
MSC_GTPU_ENB, MSC_GTPU_ENB,
"0 UDP bind %s:%u", "0 UDP bind %s:%u",
...@@ -135,7 +130,7 @@ static int gtpv1u_eNB_send_init_udp(const Gtpv1uS1Req * req) ...@@ -135,7 +130,7 @@ static int gtpv1u_eNB_send_init_udp(const Gtpv1uS1Req * req)
static int gtpv1u_s1_req( static int gtpv1u_s1_req(
const instance_t instanceP, const instance_t instanceP,
const Gtpv1uS1Req * const req) { const Gtpv1uS1Req *const req) {
memcpy(&RC.gtpv1u_data_g->enb_ip_address_for_S1u_S12_S4_up, memcpy(&RC.gtpv1u_data_g->enb_ip_address_for_S1u_S12_S4_up,
&req->enb_ip_address_for_S1u_S12_S4_up, &req->enb_ip_address_for_S1u_S12_S4_up,
sizeof (req->enb_ip_address_for_S1u_S12_S4_up)); sizeof (req->enb_ip_address_for_S1u_S12_S4_up));
...@@ -148,8 +143,7 @@ NwGtpv1uRcT gtpv1u_eNB_log_request(NwGtpv1uLogMgrHandleT hLogMgr, ...@@ -148,8 +143,7 @@ NwGtpv1uRcT gtpv1u_eNB_log_request(NwGtpv1uLogMgrHandleT hLogMgr,
uint32_t logLevel, uint32_t logLevel,
NwCharT *file, NwCharT *file,
uint32_t line, uint32_t line,
NwCharT *logStr) NwCharT *logStr) {
{
LOG_D(GTPU, "%s\n", logStr); LOG_D(GTPU, "%s\n", logStr);
return NW_GTPV1U_OK; return NW_GTPV1U_OK;
} }
...@@ -161,12 +155,10 @@ NwGtpv1uRcT gtpv1u_eNB_send_udp_msg( ...@@ -161,12 +155,10 @@ NwGtpv1uRcT gtpv1u_eNB_send_udp_msg(
uint32_t buffer_len, uint32_t buffer_len,
uint32_t buffer_offset, uint32_t buffer_offset,
uint32_t peerIpAddr, uint32_t peerIpAddr,
uint16_t peerPort) uint16_t peerPort) {
{
// Create and alloc new message // Create and alloc new message
MessageDef *message_p = NULL; MessageDef *message_p = NULL;
udp_data_req_t *udp_data_req_p = NULL; udp_data_req_t *udp_data_req_p = NULL;
message_p = itti_alloc_new_message(TASK_GTPV1_U, UDP_DATA_REQ); message_p = itti_alloc_new_message(TASK_GTPV1_U, UDP_DATA_REQ);
if (message_p) { if (message_p) {
...@@ -190,8 +182,7 @@ NwGtpv1uRcT gtpv1u_eNB_send_udp_msg( ...@@ -190,8 +182,7 @@ NwGtpv1uRcT gtpv1u_eNB_send_udp_msg(
/* Callback called when a gtpv1u message arrived on UDP interface */ /* Callback called when a gtpv1u message arrived on UDP interface */
NwGtpv1uRcT gtpv1u_eNB_process_stack_req( NwGtpv1uRcT gtpv1u_eNB_process_stack_req(
NwGtpv1uUlpHandleT hUlp, NwGtpv1uUlpHandleT hUlp,
NwGtpv1uUlpApiT *pUlpApi) NwGtpv1uUlpApiT *pUlpApi) {
{
boolean_t result = FALSE; boolean_t result = FALSE;
teid_t teid = 0; teid_t teid = 0;
hashtable_rc_t hash_rc = HASH_TABLE_KEY_NOT_EXISTS; hashtable_rc_t hash_rc = HASH_TABLE_KEY_NOT_EXISTS;
...@@ -217,13 +208,13 @@ NwGtpv1uRcT gtpv1u_eNB_process_stack_req( ...@@ -217,13 +208,13 @@ NwGtpv1uRcT gtpv1u_eNB_process_stack_req(
LOG_E(GTPU, "Error while retrieving T-PDU"); LOG_E(GTPU, "Error while retrieving T-PDU");
} }
itti_free(TASK_UDP, ((NwGtpv1uMsgT*)pUlpApi->apiInfo.recvMsgInfo.hMsg)->msgBuf); itti_free(TASK_UDP, ((NwGtpv1uMsgT *)pUlpApi->apiInfo.recvMsgInfo.hMsg)->msgBuf);
#if defined(GTP_DUMP_SOCKET) && GTP_DUMP_SOCKET > 0 #if defined(GTP_DUMP_SOCKET) && GTP_DUMP_SOCKET > 0
gtpv1u_eNB_write_dump_socket(buffer,buffer_len); gtpv1u_eNB_write_dump_socket(buffer,buffer_len);
#endif #endif
rc = nwGtpv1uMsgDelete(RC.gtpv1u_data_g->gtpv1u_stack, rc = nwGtpv1uMsgDelete(RC.gtpv1u_data_g->gtpv1u_stack,
pUlpApi->apiInfo.recvMsgInfo.hMsg); pUlpApi->apiInfo.recvMsgInfo.hMsg);
if (rc != NW_GTPV1U_OK) { if (rc != NW_GTPV1U_OK) {
LOG_E(GTPU, "nwGtpv1uMsgDelete failed: 0x%x\n", rc); LOG_E(GTPU, "nwGtpv1uMsgDelete failed: 0x%x\n", rc);
} }
...@@ -231,7 +222,7 @@ NwGtpv1uRcT gtpv1u_eNB_process_stack_req( ...@@ -231,7 +222,7 @@ NwGtpv1uRcT gtpv1u_eNB_process_stack_req(
//----------------------- //-----------------------
// GTPV1U->PDCP mapping // GTPV1U->PDCP mapping
//----------------------- //-----------------------
hash_rc = hashtable_get(RC.gtpv1u_data_g->teid_mapping, teid, (void**)&gtpv1u_teid_data_p); hash_rc = hashtable_get(RC.gtpv1u_data_g->teid_mapping, teid, (void **)&gtpv1u_teid_data_p);
if (hash_rc == HASH_TABLE_OK) { if (hash_rc == HASH_TABLE_OK) {
#if defined(LOG_GTPU) && LOG_GTPU > 0 #if defined(LOG_GTPU) && LOG_GTPU > 0
...@@ -242,8 +233,7 @@ NwGtpv1uRcT gtpv1u_eNB_process_stack_req( ...@@ -242,8 +233,7 @@ NwGtpv1uRcT gtpv1u_eNB_process_stack_req(
gtpv1u_teid_data_p->ue_id, gtpv1u_teid_data_p->ue_id,
gtpv1u_teid_data_p->eps_bearer_id); gtpv1u_teid_data_p->eps_bearer_id);
#endif #endif
//#warning "LG eps bearer mapping to DRB id to do (offset -4)"
//#warning "LG eps bearer mapping to DRB id to do (offset -4)"
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, gtpv1u_teid_data_p->enb_id, ENB_FLAG_YES, gtpv1u_teid_data_p->ue_id, 0, 0,gtpv1u_teid_data_p->enb_id); PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, gtpv1u_teid_data_p->enb_id, ENB_FLAG_YES, gtpv1u_teid_data_p->ue_id, 0, 0,gtpv1u_teid_data_p->enb_id);
MSC_LOG_TX_MESSAGE( MSC_LOG_TX_MESSAGE(
MSC_GTPU_ENB, MSC_GTPU_ENB,
...@@ -253,7 +243,6 @@ NwGtpv1uRcT gtpv1u_eNB_process_stack_req( ...@@ -253,7 +243,6 @@ NwGtpv1uRcT gtpv1u_eNB_process_stack_req(
0,0, 0,0,
(gtpv1u_teid_data_p->eps_bearer_id) ? gtpv1u_teid_data_p->eps_bearer_id - 4: 5-4, (gtpv1u_teid_data_p->eps_bearer_id) ? gtpv1u_teid_data_p->eps_bearer_id - 4: 5-4,
buffer_len); buffer_len);
result = pdcp_data_req( result = pdcp_data_req(
&ctxt, &ctxt,
SRB_FLAG_NO, SRB_FLAG_NO,
...@@ -268,9 +257,7 @@ NwGtpv1uRcT gtpv1u_eNB_process_stack_req( ...@@ -268,9 +257,7 @@ NwGtpv1uRcT gtpv1u_eNB_process_stack_req(
#endif #endif
); );
if ( result == FALSE ) { if ( result == FALSE ) {
if (ctxt.configured == FALSE ) if (ctxt.configured == FALSE )
LOG_W(GTPU, "PDCP data request failed, cause: RB is not configured!\n") ; LOG_W(GTPU, "PDCP data request failed, cause: RB is not configured!\n") ;
else else
...@@ -278,7 +265,6 @@ NwGtpv1uRcT gtpv1u_eNB_process_stack_req( ...@@ -278,7 +265,6 @@ NwGtpv1uRcT gtpv1u_eNB_process_stack_req(
return NW_GTPV1U_FAILURE; return NW_GTPV1U_FAILURE;
} }
} else { } else {
LOG_W(GTPU, "Received T-PDU from gtpv1u stack teid %u unknown size %u", teid, buffer_len); LOG_W(GTPU, "Received T-PDU from gtpv1u stack teid %u unknown size %u", teid, buffer_len);
} }
...@@ -289,7 +275,6 @@ NwGtpv1uRcT gtpv1u_eNB_process_stack_req( ...@@ -289,7 +275,6 @@ NwGtpv1uRcT gtpv1u_eNB_process_stack_req(
LOG_E(GTPU, "Received undefined UlpApi (%02x) from gtpv1u stack!\n", LOG_E(GTPU, "Received undefined UlpApi (%02x) from gtpv1u stack!\n",
pUlpApi->apiType); pUlpApi->apiType);
} }
} // end of switch } // end of switch
return NW_GTPV1U_OK; return NW_GTPV1U_OK;
...@@ -301,8 +286,7 @@ int data_recv_callback(uint16_t portP, ...@@ -301,8 +286,7 @@ int data_recv_callback(uint16_t portP,
uint32_t address, uint32_t address,
uint8_t *buffer, uint8_t *buffer,
uint32_t length, uint32_t length,
void *arg_p) void *arg_p) {
{
gtpv1u_data_t *gtpv1u_data_p; gtpv1u_data_t *gtpv1u_data_p;
if (arg_p == NULL) { if (arg_p == NULL) {
...@@ -310,7 +294,6 @@ int data_recv_callback(uint16_t portP, ...@@ -310,7 +294,6 @@ int data_recv_callback(uint16_t portP,
} }
gtpv1u_data_p = (gtpv1u_data_t *)arg_p; gtpv1u_data_p = (gtpv1u_data_t *)arg_p;
return nwGtpv1uProcessUdpReq(gtpv1u_data_p->gtpv1u_stack, return nwGtpv1uProcessUdpReq(gtpv1u_data_p->gtpv1u_stack,
buffer, buffer,
length, length,
...@@ -421,9 +404,7 @@ static NwGtpv1uRcT gtpv1u_start_timer_wrapper( ...@@ -421,9 +404,7 @@ static NwGtpv1uRcT gtpv1u_start_timer_wrapper(
uint32_t timeoutUsec, uint32_t timeoutUsec,
uint32_t tmrType, uint32_t tmrType,
void *timeoutArg, void *timeoutArg,
NwGtpv1uTimerHandleT *hTmr) NwGtpv1uTimerHandleT *hTmr) {
{
NwGtpv1uRcT rc = NW_GTPV1U_OK; NwGtpv1uRcT rc = NW_GTPV1U_OK;
long timer_id; long timer_id;
...@@ -453,11 +434,8 @@ static NwGtpv1uRcT gtpv1u_start_timer_wrapper( ...@@ -453,11 +434,8 @@ static NwGtpv1uRcT gtpv1u_start_timer_wrapper(
static NwGtpv1uRcT static NwGtpv1uRcT
gtpv1u_stop_timer_wrapper( gtpv1u_stop_timer_wrapper(
NwGtpv1uTimerMgrHandleT tmrMgrHandle, NwGtpv1uTimerMgrHandleT tmrMgrHandle,
NwGtpv1uTimerHandleT hTmr) NwGtpv1uTimerHandleT hTmr) {
{
NwGtpv1uRcT rc = NW_GTPV1U_OK; NwGtpv1uRcT rc = NW_GTPV1U_OK;
return rc; return rc;
} }
...@@ -468,18 +446,14 @@ gtpv1u_initial_req( ...@@ -468,18 +446,14 @@ gtpv1u_initial_req(
gtpv1u_data_t *gtpv1u_data_pP, gtpv1u_data_t *gtpv1u_data_pP,
teid_t teidP, teid_t teidP,
tcp_udp_port_t portP, tcp_udp_port_t portP,
uint32_t address) uint32_t address) {
{
NwGtpv1uUlpApiT ulp_req; NwGtpv1uUlpApiT ulp_req;
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE; NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
memset(&ulp_req, 0, sizeof(NwGtpv1uUlpApiT)); memset(&ulp_req, 0, sizeof(NwGtpv1uUlpApiT));
ulp_req.apiType = NW_GTPV1U_ULP_API_INITIAL_REQ; ulp_req.apiType = NW_GTPV1U_ULP_API_INITIAL_REQ;
ulp_req.apiInfo.initialReqInfo.teid = teidP; ulp_req.apiInfo.initialReqInfo.teid = teidP;
ulp_req.apiInfo.initialReqInfo.peerPort = portP; ulp_req.apiInfo.initialReqInfo.peerPort = portP;
ulp_req.apiInfo.initialReqInfo.peerIp = address; ulp_req.apiInfo.initialReqInfo.peerIp = address;
rc = nwGtpv1uProcessUlpReq(gtpv1u_data_pP->gtpv1u_stack, &ulp_req); rc = nwGtpv1uProcessUlpReq(gtpv1u_data_pP->gtpv1u_stack, &ulp_req);
if (rc == NW_GTPV1U_OK) { if (rc == NW_GTPV1U_OK) {
...@@ -500,9 +474,7 @@ gtpv1u_new_data_req( ...@@ -500,9 +474,7 @@ gtpv1u_new_data_req(
uint8_t *buffer_pP, uint8_t *buffer_pP,
uint32_t buf_lenP, uint32_t buf_lenP,
uint32_t buf_offsetP uint32_t buf_offsetP
) ) {
{
NwGtpv1uUlpApiT stack_req; NwGtpv1uUlpApiT stack_req;
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE; NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
struct gtpv1u_ue_data_s ue; struct gtpv1u_ue_data_s ue;
...@@ -510,17 +482,14 @@ gtpv1u_new_data_req( ...@@ -510,17 +482,14 @@ gtpv1u_new_data_req(
struct gtpv1u_bearer_s *bearer_p = NULL; struct gtpv1u_bearer_s *bearer_p = NULL;
hashtable_rc_t hash_rc = HASH_TABLE_KEY_NOT_EXISTS;; hashtable_rc_t hash_rc = HASH_TABLE_KEY_NOT_EXISTS;;
gtpv1u_data_t *gtpv1u_data_p = NULL; gtpv1u_data_t *gtpv1u_data_p = NULL;
memset(&ue, 0, sizeof(struct gtpv1u_ue_data_s)); memset(&ue, 0, sizeof(struct gtpv1u_ue_data_s));
ue.ue_id = ue_rntiP; ue.ue_id = ue_rntiP;
AssertFatal(enb_module_idP >=0, "Bad parameter enb module id %u\n", enb_module_idP); AssertFatal(enb_module_idP >=0, "Bad parameter enb module id %u\n", enb_module_idP);
AssertFatal((rab_idP - GTPV1U_BEARER_OFFSET)< GTPV1U_MAX_BEARERS_ID, "Bad parameter rab id %u\n", rab_idP); AssertFatal((rab_idP - GTPV1U_BEARER_OFFSET)< GTPV1U_MAX_BEARERS_ID, "Bad parameter rab id %u\n", rab_idP);
AssertFatal((rab_idP - GTPV1U_BEARER_OFFSET) >= 0 , "Bad parameter rab id %u\n", rab_idP); AssertFatal((rab_idP - GTPV1U_BEARER_OFFSET) >= 0 , "Bad parameter rab id %u\n", rab_idP);
gtpv1u_data_p = RC.gtpv1u_data_g; gtpv1u_data_p = RC.gtpv1u_data_g;
/* Check that UE context is present in ue map. */ /* Check that UE context is present in ue map. */
hash_rc = hashtable_get(gtpv1u_data_p->ue_mapping, (uint64_t)ue_rntiP, (void**)&ue_inst_p); hash_rc = hashtable_get(gtpv1u_data_p->ue_mapping, (uint64_t)ue_rntiP, (void **)&ue_inst_p);
if (hash_rc == HASH_TABLE_KEY_NOT_EXISTS ) { if (hash_rc == HASH_TABLE_KEY_NOT_EXISTS ) {
LOG_E(GTPU, "[UE %d] Trying to send data on non-existing UE context\n", ue_rntiP); LOG_E(GTPU, "[UE %d] Trying to send data on non-existing UE context\n", ue_rntiP);
...@@ -536,18 +505,16 @@ gtpv1u_new_data_req( ...@@ -536,18 +505,16 @@ gtpv1u_new_data_req(
if (bearer_p->state != BEARER_UP) { if (bearer_p->state != BEARER_UP) {
LOG_W(GTPU, "Trying to send data over bearer with state(%u) != BEARER_UP\n", LOG_W(GTPU, "Trying to send data over bearer with state(%u) != BEARER_UP\n",
bearer_p->state); bearer_p->state);
//#warning LG: HACK WHILE WAITING FOR NAS, normally return -1 //#warning LG: HACK WHILE WAITING FOR NAS, normally return -1
if (bearer_p->state != BEARER_IN_CONFIG) if (bearer_p->state != BEARER_IN_CONFIG)
return -1; return -1;
} }
memset(&stack_req, 0, sizeof(NwGtpv1uUlpApiT)); memset(&stack_req, 0, sizeof(NwGtpv1uUlpApiT));
stack_req.apiType = NW_GTPV1U_ULP_API_SEND_TPDU; stack_req.apiType = NW_GTPV1U_ULP_API_SEND_TPDU;
stack_req.apiInfo.sendtoInfo.teid = bearer_p->teid_sgw; stack_req.apiInfo.sendtoInfo.teid = bearer_p->teid_sgw;
stack_req.apiInfo.sendtoInfo.ipAddr = bearer_p->sgw_ip_addr; stack_req.apiInfo.sendtoInfo.ipAddr = bearer_p->sgw_ip_addr;
LOG_D(GTPU, "TX TO TEID %u addr 0x%x\n",bearer_p->teid_sgw, bearer_p->sgw_ip_addr); LOG_D(GTPU, "TX TO TEID %u addr 0x%x\n",bearer_p->teid_sgw, bearer_p->sgw_ip_addr);
rc = nwGtpv1uGpduMsgNew(gtpv1u_data_p->gtpv1u_stack, rc = nwGtpv1uGpduMsgNew(gtpv1u_data_p->gtpv1u_stack,
bearer_p->teid_sgw, bearer_p->teid_sgw,
...@@ -587,10 +554,9 @@ gtpv1u_new_data_req( ...@@ -587,10 +554,9 @@ gtpv1u_new_data_req(
int int
gtpv1u_create_s1u_tunnel( gtpv1u_create_s1u_tunnel(
const instance_t instanceP, const instance_t instanceP,
const gtpv1u_enb_create_tunnel_req_t * const create_tunnel_req_pP, const gtpv1u_enb_create_tunnel_req_t *const create_tunnel_req_pP,
gtpv1u_enb_create_tunnel_resp_t * const create_tunnel_resp_pP gtpv1u_enb_create_tunnel_resp_t *const create_tunnel_resp_pP
) ) {
{
/* Create a new nw-gtpv1-u stack req using API */ /* Create a new nw-gtpv1-u stack req using API */
NwGtpv1uUlpApiT stack_req; NwGtpv1uUlpApiT stack_req;
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE; NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
...@@ -606,8 +572,6 @@ gtpv1u_create_s1u_tunnel( ...@@ -606,8 +572,6 @@ gtpv1u_create_s1u_tunnel(
int ip_offset = 0; int ip_offset = 0;
in_addr_t in_addr; in_addr_t in_addr;
int addrs_length_in_bytes= 0; int addrs_length_in_bytes= 0;
MSC_LOG_RX_MESSAGE( MSC_LOG_RX_MESSAGE(
MSC_GTPU_ENB, MSC_GTPU_ENB,
MSC_RRC_ENB, MSC_RRC_ENB,
...@@ -616,7 +580,6 @@ gtpv1u_create_s1u_tunnel( ...@@ -616,7 +580,6 @@ gtpv1u_create_s1u_tunnel(
0,0,create_tunnel_req_pP->rnti, instanceP, 0,0,create_tunnel_req_pP->rnti, instanceP,
create_tunnel_req_pP->num_tunnels, create_tunnel_req_pP->eps_bearer_id[0], create_tunnel_req_pP->num_tunnels, create_tunnel_req_pP->eps_bearer_id[0],
create_tunnel_req_pP->sgw_S1u_teid[0]); create_tunnel_req_pP->sgw_S1u_teid[0]);
create_tunnel_resp_pP->rnti = create_tunnel_req_pP->rnti; create_tunnel_resp_pP->rnti = create_tunnel_req_pP->rnti;
create_tunnel_resp_pP->status = 0; create_tunnel_resp_pP->status = 0;
create_tunnel_resp_pP->num_tunnels = 0; create_tunnel_resp_pP->num_tunnels = 0;
...@@ -627,7 +590,6 @@ gtpv1u_create_s1u_tunnel( ...@@ -627,7 +590,6 @@ gtpv1u_create_s1u_tunnel(
LOG_D(GTPU, "Rx GTPV1U_ENB_CREATE_TUNNEL_REQ ue rnti %x eps bearer id %u\n", LOG_D(GTPU, "Rx GTPV1U_ENB_CREATE_TUNNEL_REQ ue rnti %x eps bearer id %u\n",
create_tunnel_req_pP->rnti, eps_bearer_id); create_tunnel_req_pP->rnti, eps_bearer_id);
memset(&stack_req, 0, sizeof(NwGtpv1uUlpApiT)); memset(&stack_req, 0, sizeof(NwGtpv1uUlpApiT));
stack_req.apiType = NW_GTPV1U_ULP_API_CREATE_TUNNEL_ENDPOINT; stack_req.apiType = NW_GTPV1U_ULP_API_CREATE_TUNNEL_ENDPOINT;
do { do {
...@@ -636,7 +598,6 @@ gtpv1u_create_s1u_tunnel( ...@@ -636,7 +598,6 @@ gtpv1u_create_s1u_tunnel(
stack_req.apiInfo.createTunnelEndPointInfo.teid = s1u_teid; stack_req.apiInfo.createTunnelEndPointInfo.teid = s1u_teid;
stack_req.apiInfo.createTunnelEndPointInfo.hUlpSession = 0; stack_req.apiInfo.createTunnelEndPointInfo.hUlpSession = 0;
stack_req.apiInfo.createTunnelEndPointInfo.hStackSession = 0; stack_req.apiInfo.createTunnelEndPointInfo.hStackSession = 0;
rc = nwGtpv1uProcessUlpReq(RC.gtpv1u_data_g->gtpv1u_stack, &stack_req); rc = nwGtpv1uProcessUlpReq(RC.gtpv1u_data_g->gtpv1u_stack, &stack_req);
LOG_D(GTPU, ".\n"); LOG_D(GTPU, ".\n");
} while (rc != NW_GTPV1U_OK); } while (rc != NW_GTPV1U_OK);
...@@ -647,7 +608,6 @@ gtpv1u_create_s1u_tunnel( ...@@ -647,7 +608,6 @@ gtpv1u_create_s1u_tunnel(
hash_rc = hashtable_get(RC.gtpv1u_data_g->ue_mapping, create_tunnel_req_pP->rnti, (void **)&gtpv1u_ue_data_p); hash_rc = hashtable_get(RC.gtpv1u_data_g->ue_mapping, create_tunnel_req_pP->rnti, (void **)&gtpv1u_ue_data_p);
if ((hash_rc == HASH_TABLE_KEY_NOT_EXISTS) || (hash_rc == HASH_TABLE_OK)) { if ((hash_rc == HASH_TABLE_KEY_NOT_EXISTS) || (hash_rc == HASH_TABLE_OK)) {
if (hash_rc == HASH_TABLE_KEY_NOT_EXISTS) { if (hash_rc == HASH_TABLE_KEY_NOT_EXISTS) {
gtpv1u_ue_data_p = calloc (1, sizeof(gtpv1u_ue_data_t)); gtpv1u_ue_data_p = calloc (1, sizeof(gtpv1u_ue_data_t));
hash_rc = hashtable_insert(RC.gtpv1u_data_g->ue_mapping, create_tunnel_req_pP->rnti, gtpv1u_ue_data_p); hash_rc = hashtable_insert(RC.gtpv1u_data_g->ue_mapping, create_tunnel_req_pP->rnti, gtpv1u_ue_data_p);
...@@ -660,7 +620,6 @@ gtpv1u_create_s1u_tunnel( ...@@ -660,7 +620,6 @@ gtpv1u_create_s1u_tunnel(
&RC.gtpv1u_data_g->enb_ip_address_for_S1u_S12_S4_up, &RC.gtpv1u_data_g->enb_ip_address_for_S1u_S12_S4_up,
sizeof (in_addr_t)); sizeof (in_addr_t));
create_tunnel_resp_pP->enb_addr.length = sizeof (in_addr_t); create_tunnel_resp_pP->enb_addr.length = sizeof (in_addr_t);
addrs_length_in_bytes = create_tunnel_req_pP->sgw_addr[i].length / 8; addrs_length_in_bytes = create_tunnel_req_pP->sgw_addr[i].length / 8;
AssertFatal((addrs_length_in_bytes == 4) || AssertFatal((addrs_length_in_bytes == 4) ||
(addrs_length_in_bytes == 16) || (addrs_length_in_bytes == 16) ||
...@@ -670,7 +629,7 @@ gtpv1u_create_s1u_tunnel( ...@@ -670,7 +629,7 @@ gtpv1u_create_s1u_tunnel(
if ((addrs_length_in_bytes == 4) || if ((addrs_length_in_bytes == 4) ||
(addrs_length_in_bytes == 20)) { (addrs_length_in_bytes == 20)) {
in_addr = *((in_addr_t*)create_tunnel_req_pP->sgw_addr[i].buffer); in_addr = *((in_addr_t *)create_tunnel_req_pP->sgw_addr[i].buffer);
ip_offset = 4; ip_offset = 4;
gtpv1u_ue_data_p->bearers[eps_bearer_id - GTPV1U_BEARER_OFFSET].sgw_ip_addr = in_addr; gtpv1u_ue_data_p->bearers[eps_bearer_id - GTPV1U_BEARER_OFFSET].sgw_ip_addr = in_addr;
} }
...@@ -688,7 +647,6 @@ gtpv1u_create_s1u_tunnel( ...@@ -688,7 +647,6 @@ gtpv1u_create_s1u_tunnel(
gtpv1u_ue_data_p->bearers[eps_bearer_id - GTPV1U_BEARER_OFFSET].teid_sgw = create_tunnel_req_pP->sgw_S1u_teid[i]; gtpv1u_ue_data_p->bearers[eps_bearer_id - GTPV1U_BEARER_OFFSET].teid_sgw = create_tunnel_req_pP->sgw_S1u_teid[i];
gtpv1u_ue_data_p->num_bearers++; gtpv1u_ue_data_p->num_bearers++;
create_tunnel_resp_pP->enb_S1u_teid[i] = s1u_teid; create_tunnel_resp_pP->enb_S1u_teid[i] = s1u_teid;
} else { } else {
create_tunnel_resp_pP->enb_S1u_teid[i] = 0; create_tunnel_resp_pP->enb_S1u_teid[i] = 0;
create_tunnel_resp_pP->status = 0xFF; create_tunnel_resp_pP->status = 0xFF;
...@@ -696,11 +654,10 @@ gtpv1u_create_s1u_tunnel( ...@@ -696,11 +654,10 @@ gtpv1u_create_s1u_tunnel(
create_tunnel_resp_pP->eps_bearer_id[i] = eps_bearer_id; create_tunnel_resp_pP->eps_bearer_id[i] = eps_bearer_id;
create_tunnel_resp_pP->num_tunnels += 1; create_tunnel_resp_pP->num_tunnels += 1;
//----------------------- //-----------------------
// GTPV1U->PDCP mapping // GTPV1U->PDCP mapping
//----------------------- //-----------------------
hash_rc = hashtable_get(RC.gtpv1u_data_g->teid_mapping, s1u_teid, (void**)&gtpv1u_teid_data_p); hash_rc = hashtable_get(RC.gtpv1u_data_g->teid_mapping, s1u_teid, (void **)&gtpv1u_teid_data_p);
if (hash_rc == HASH_TABLE_KEY_NOT_EXISTS) { if (hash_rc == HASH_TABLE_KEY_NOT_EXISTS) {
gtpv1u_teid_data_p = calloc (1, sizeof(gtpv1u_teid_data_t)); gtpv1u_teid_data_p = calloc (1, sizeof(gtpv1u_teid_data_t));
...@@ -714,6 +671,7 @@ gtpv1u_create_s1u_tunnel( ...@@ -714,6 +671,7 @@ gtpv1u_create_s1u_tunnel(
create_tunnel_resp_pP->status = 0xFF; create_tunnel_resp_pP->status = 0xFF;
} }
} }
MSC_LOG_TX_MESSAGE( MSC_LOG_TX_MESSAGE(
MSC_GTPU_ENB, MSC_GTPU_ENB,
MSC_RRC_ENB, MSC_RRC_ENB,
...@@ -721,7 +679,6 @@ gtpv1u_create_s1u_tunnel( ...@@ -721,7 +679,6 @@ gtpv1u_create_s1u_tunnel(
"0 GTPV1U_ENB_CREATE_TUNNEL_RESP rnti %x teid %x", "0 GTPV1U_ENB_CREATE_TUNNEL_RESP rnti %x teid %x",
create_tunnel_resp_pP->rnti, create_tunnel_resp_pP->rnti,
s1u_teid); s1u_teid);
LOG_D(GTPU, "Tx GTPV1U_ENB_CREATE_TUNNEL_RESP ue rnti %x status %d\n", LOG_D(GTPU, "Tx GTPV1U_ENB_CREATE_TUNNEL_RESP ue rnti %x status %d\n",
create_tunnel_req_pP->rnti, create_tunnel_req_pP->rnti,
create_tunnel_resp_pP->status); create_tunnel_resp_pP->status);
...@@ -730,11 +687,9 @@ gtpv1u_create_s1u_tunnel( ...@@ -730,11 +687,9 @@ gtpv1u_create_s1u_tunnel(
int gtpv1u_update_s1u_tunnel( int gtpv1u_update_s1u_tunnel(
const instance_t instanceP, const instance_t instanceP,
const gtpv1u_enb_create_tunnel_req_t * const create_tunnel_req_pP, const gtpv1u_enb_create_tunnel_req_t *const create_tunnel_req_pP,
const rnti_t prior_rnti const rnti_t prior_rnti
) ) {
{
/* Local tunnel end-point identifier */ /* Local tunnel end-point identifier */
teid_t s1u_teid = 0; teid_t s1u_teid = 0;
gtpv1u_teid_data_t *gtpv1u_teid_data_p = NULL; gtpv1u_teid_data_t *gtpv1u_teid_data_p = NULL;
...@@ -744,12 +699,12 @@ int gtpv1u_update_s1u_tunnel( ...@@ -744,12 +699,12 @@ int gtpv1u_update_s1u_tunnel(
hashtable_rc_t hash_rc = HASH_TABLE_KEY_NOT_EXISTS; hashtable_rc_t hash_rc = HASH_TABLE_KEY_NOT_EXISTS;
int i,j; int i,j;
uint8_t bearers_num = 0,bearers_total = 0; uint8_t bearers_num = 0,bearers_total = 0;
//----------------------- //-----------------------
// PDCP->GTPV1U mapping // PDCP->GTPV1U mapping
//----------------------- //-----------------------
hash_rc = hashtable_get(RC.gtpv1u_data_g->ue_mapping, prior_rnti, (void **)&gtpv1u_ue_data_p); hash_rc = hashtable_get(RC.gtpv1u_data_g->ue_mapping, prior_rnti, (void **)&gtpv1u_ue_data_p);
if(hash_rc != HASH_TABLE_OK){
if(hash_rc != HASH_TABLE_OK) {
LOG_E(GTPU,"Error get ue_mapping(rnti=%x) from GTPV1U hashtable error\n", prior_rnti); LOG_E(GTPU,"Error get ue_mapping(rnti=%x) from GTPV1U hashtable error\n", prior_rnti);
return -1; return -1;
} }
...@@ -757,12 +712,10 @@ int gtpv1u_update_s1u_tunnel( ...@@ -757,12 +712,10 @@ int gtpv1u_update_s1u_tunnel(
gtpv1u_ue_data_new_p = calloc (1, sizeof(gtpv1u_ue_data_t)); gtpv1u_ue_data_new_p = calloc (1, sizeof(gtpv1u_ue_data_t));
memcpy(gtpv1u_ue_data_new_p,gtpv1u_ue_data_p,sizeof(gtpv1u_ue_data_t)); memcpy(gtpv1u_ue_data_new_p,gtpv1u_ue_data_p,sizeof(gtpv1u_ue_data_t));
gtpv1u_ue_data_new_p->ue_id = create_tunnel_req_pP->rnti; gtpv1u_ue_data_new_p->ue_id = create_tunnel_req_pP->rnti;
hash_rc = hashtable_insert(RC.gtpv1u_data_g->ue_mapping, create_tunnel_req_pP->rnti, gtpv1u_ue_data_new_p); hash_rc = hashtable_insert(RC.gtpv1u_data_g->ue_mapping, create_tunnel_req_pP->rnti, gtpv1u_ue_data_new_p);
AssertFatal(hash_rc == HASH_TABLE_OK, "Error inserting ue_mapping in GTPV1U hashtable"); AssertFatal(hash_rc == HASH_TABLE_OK, "Error inserting ue_mapping in GTPV1U hashtable");
LOG_I(GTPU, "inserting ue_mapping(rnti=%x) in GTPV1U hashtable\n", LOG_I(GTPU, "inserting ue_mapping(rnti=%x) in GTPV1U hashtable\n",
create_tunnel_req_pP->rnti); create_tunnel_req_pP->rnti);
hash_rc = hashtable_remove(RC.gtpv1u_data_g->ue_mapping, prior_rnti); hash_rc = hashtable_remove(RC.gtpv1u_data_g->ue_mapping, prior_rnti);
LOG_I(GTPU, "hashtable_remove ue_mapping(rnti=%x) in GTPV1U hashtable\n", LOG_I(GTPU, "hashtable_remove ue_mapping(rnti=%x) in GTPV1U hashtable\n",
prior_rnti); prior_rnti);
...@@ -770,52 +723,55 @@ int gtpv1u_update_s1u_tunnel( ...@@ -770,52 +723,55 @@ int gtpv1u_update_s1u_tunnel(
// GTPV1U->PDCP mapping // GTPV1U->PDCP mapping
//----------------------- //-----------------------
bearers_total =gtpv1u_ue_data_new_p->num_bearers; bearers_total =gtpv1u_ue_data_new_p->num_bearers;
for(j = 0;j<GTPV1U_MAX_BEARERS_ID;j++){
for(j = 0; j<GTPV1U_MAX_BEARERS_ID; j++) {
if(gtpv1u_ue_data_new_p->bearers[j].state != BEARER_IN_CONFIG) if(gtpv1u_ue_data_new_p->bearers[j].state != BEARER_IN_CONFIG)
continue; continue;
bearers_num++; bearers_num++;
for (i = 0; i < create_tunnel_req_pP->num_tunnels; i++) { for (i = 0; i < create_tunnel_req_pP->num_tunnels; i++) {
if(j == (create_tunnel_req_pP->eps_bearer_id[i]-GTPV1U_BEARER_OFFSET)) if(j == (create_tunnel_req_pP->eps_bearer_id[i]-GTPV1U_BEARER_OFFSET))
break; break;
} }
if(i < create_tunnel_req_pP->num_tunnels){
if(i < create_tunnel_req_pP->num_tunnels) {
s1u_teid = gtpv1u_ue_data_new_p->bearers[j].teid_eNB; s1u_teid = gtpv1u_ue_data_new_p->bearers[j].teid_eNB;
hash_rc = hashtable_get(RC.gtpv1u_data_g->teid_mapping, s1u_teid, (void**)&gtpv1u_teid_data_p); hash_rc = hashtable_get(RC.gtpv1u_data_g->teid_mapping, s1u_teid, (void **)&gtpv1u_teid_data_p);
if (hash_rc == HASH_TABLE_OK) { if (hash_rc == HASH_TABLE_OK) {
gtpv1u_teid_data_p->ue_id = create_tunnel_req_pP->rnti; gtpv1u_teid_data_p->ue_id = create_tunnel_req_pP->rnti;
gtpv1u_teid_data_p->eps_bearer_id = create_tunnel_req_pP->eps_bearer_id[i]; gtpv1u_teid_data_p->eps_bearer_id = create_tunnel_req_pP->eps_bearer_id[i];
LOG_I(GTPU, "updata teid_mapping te_id %u (prior_rnti %x rnti %x) in GTPV1U hashtable\n", LOG_I(GTPU, "updata teid_mapping te_id %u (prior_rnti %x rnti %x) in GTPV1U hashtable\n",
s1u_teid,prior_rnti,create_tunnel_req_pP->rnti); s1u_teid,prior_rnti,create_tunnel_req_pP->rnti);
}else{ } else {
LOG_W(GTPU, "Error get teid mapping(s1u_teid=%u) from GTPV1U hashtable", s1u_teid); LOG_W(GTPU, "Error get teid mapping(s1u_teid=%u) from GTPV1U hashtable", s1u_teid);
} }
}else{ } else {
s1u_teid = gtpv1u_ue_data_new_p->bearers[j].teid_eNB; s1u_teid = gtpv1u_ue_data_new_p->bearers[j].teid_eNB;
hash_rc = hashtable_remove(RC.gtpv1u_data_g->teid_mapping, s1u_teid); hash_rc = hashtable_remove(RC.gtpv1u_data_g->teid_mapping, s1u_teid);
if (hash_rc != HASH_TABLE_OK) { if (hash_rc != HASH_TABLE_OK) {
LOG_D(GTPU, "Removed user rnti %x , enb S1U teid %u not found\n", prior_rnti, s1u_teid); LOG_D(GTPU, "Removed user rnti %x , enb S1U teid %u not found\n", prior_rnti, s1u_teid);
} }
gtpv1u_ue_data_new_p->bearers[j].state = BEARER_DOWN; gtpv1u_ue_data_new_p->bearers[j].state = BEARER_DOWN;
gtpv1u_ue_data_new_p->num_bearers--; gtpv1u_ue_data_new_p->num_bearers--;
LOG_I(GTPU, "delete teid_mapping te_id %u (rnti%x) bearer_id %d in GTPV1U hashtable\n", LOG_I(GTPU, "delete teid_mapping te_id %u (rnti%x) bearer_id %d in GTPV1U hashtable\n",
s1u_teid,prior_rnti,j+GTPV1U_BEARER_OFFSET);; s1u_teid,prior_rnti,j+GTPV1U_BEARER_OFFSET);;
} }
if(bearers_num > bearers_total) if(bearers_num > bearers_total)
break; break;
} }
return 0;
return 0;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static int gtpv1u_delete_s1u_tunnel( static int gtpv1u_delete_s1u_tunnel(
const instance_t instanceP, const instance_t instanceP,
const gtpv1u_enb_delete_tunnel_req_t * const req_pP) const gtpv1u_enb_delete_tunnel_req_t *const req_pP) {
{
NwGtpv1uUlpApiT stack_req; NwGtpv1uUlpApiT stack_req;
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE; NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
MessageDef *message_p = NULL; MessageDef *message_p = NULL;
...@@ -823,22 +779,16 @@ static int gtpv1u_delete_s1u_tunnel( ...@@ -823,22 +779,16 @@ static int gtpv1u_delete_s1u_tunnel(
hashtable_rc_t hash_rc = HASH_TABLE_KEY_NOT_EXISTS; hashtable_rc_t hash_rc = HASH_TABLE_KEY_NOT_EXISTS;
teid_t teid_eNB = 0; teid_t teid_eNB = 0;
int erab_index = 0; int erab_index = 0;
message_p = itti_alloc_new_message(TASK_GTPV1_U, GTPV1U_ENB_DELETE_TUNNEL_RESP); message_p = itti_alloc_new_message(TASK_GTPV1_U, GTPV1U_ENB_DELETE_TUNNEL_RESP);
GTPV1U_ENB_DELETE_TUNNEL_RESP(message_p).rnti = req_pP->rnti; GTPV1U_ENB_DELETE_TUNNEL_RESP(message_p).rnti = req_pP->rnti;
GTPV1U_ENB_DELETE_TUNNEL_RESP(message_p).status = 0; GTPV1U_ENB_DELETE_TUNNEL_RESP(message_p).status = 0;
hash_rc = hashtable_get(RC.gtpv1u_data_g->ue_mapping, req_pP->rnti, (void **)&gtpv1u_ue_data_p);
hash_rc = hashtable_get(RC.gtpv1u_data_g->ue_mapping, req_pP->rnti, (void**)&gtpv1u_ue_data_p);
if (hash_rc == HASH_TABLE_OK) { if (hash_rc == HASH_TABLE_OK) {
for (erab_index = 0; erab_index < req_pP->num_erab; erab_index++) { for (erab_index = 0; erab_index < req_pP->num_erab; erab_index++) {
teid_eNB = gtpv1u_ue_data_p->bearers[req_pP->eps_bearer_id[erab_index] - GTPV1U_BEARER_OFFSET].teid_eNB; teid_eNB = gtpv1u_ue_data_p->bearers[req_pP->eps_bearer_id[erab_index] - GTPV1U_BEARER_OFFSET].teid_eNB;
LOG_D(GTPU, "Rx GTPV1U_ENB_DELETE_TUNNEL user rnti %x eNB S1U teid %u eps bearer id %u\n", LOG_D(GTPU, "Rx GTPV1U_ENB_DELETE_TUNNEL user rnti %x eNB S1U teid %u eps bearer id %u\n",
req_pP->rnti, teid_eNB, req_pP->eps_bearer_id[erab_index]); req_pP->rnti, teid_eNB, req_pP->eps_bearer_id[erab_index]);
{ {
memset(&stack_req, 0, sizeof(NwGtpv1uUlpApiT)); memset(&stack_req, 0, sizeof(NwGtpv1uUlpApiT));
stack_req.apiType = NW_GTPV1U_ULP_API_DESTROY_TUNNEL_ENDPOINT; stack_req.apiType = NW_GTPV1U_ULP_API_DESTROY_TUNNEL_ENDPOINT;
...@@ -846,7 +796,6 @@ static int gtpv1u_delete_s1u_tunnel( ...@@ -846,7 +796,6 @@ static int gtpv1u_delete_s1u_tunnel(
req_pP->eps_bearer_id[erab_index], req_pP->eps_bearer_id[erab_index],
teid_eNB); teid_eNB);
stack_req.apiInfo.destroyTunnelEndPointInfo.hStackSessionHandle = gtpv1u_ue_data_p->bearers[req_pP->eps_bearer_id[erab_index] - GTPV1U_BEARER_OFFSET].teid_eNB_stack_session; stack_req.apiInfo.destroyTunnelEndPointInfo.hStackSessionHandle = gtpv1u_ue_data_p->bearers[req_pP->eps_bearer_id[erab_index] - GTPV1U_BEARER_OFFSET].teid_eNB_stack_session;
rc = nwGtpv1uProcessUlpReq(RC.gtpv1u_data_g->gtpv1u_stack, &stack_req); rc = nwGtpv1uProcessUlpReq(RC.gtpv1u_data_g->gtpv1u_stack, &stack_req);
LOG_D(GTPU, ".\n"); LOG_D(GTPU, ".\n");
} }
...@@ -881,12 +830,10 @@ static int gtpv1u_delete_s1u_tunnel( ...@@ -881,12 +830,10 @@ static int gtpv1u_delete_s1u_tunnel(
} }
}// else silently do nothing }// else silently do nothing
LOG_D(GTPU, "Tx GTPV1U_ENB_DELETE_TUNNEL_RESP user rnti %x eNB S1U teid %u status %u\n", LOG_D(GTPU, "Tx GTPV1U_ENB_DELETE_TUNNEL_RESP user rnti %x eNB S1U teid %u status %u\n",
GTPV1U_ENB_DELETE_TUNNEL_RESP(message_p).rnti, GTPV1U_ENB_DELETE_TUNNEL_RESP(message_p).rnti,
GTPV1U_ENB_DELETE_TUNNEL_RESP(message_p).enb_S1u_teid, GTPV1U_ENB_DELETE_TUNNEL_RESP(message_p).enb_S1u_teid,
GTPV1U_ENB_DELETE_TUNNEL_RESP(message_p).status); GTPV1U_ENB_DELETE_TUNNEL_RESP(message_p).status);
MSC_LOG_TX_MESSAGE( MSC_LOG_TX_MESSAGE(
MSC_GTPU_ENB, MSC_GTPU_ENB,
MSC_RRC_ENB, MSC_RRC_ENB,
...@@ -894,23 +841,19 @@ static int gtpv1u_delete_s1u_tunnel( ...@@ -894,23 +841,19 @@ static int gtpv1u_delete_s1u_tunnel(
"0 GTPV1U_ENB_DELETE_TUNNEL_RESP rnti %x teid %x", "0 GTPV1U_ENB_DELETE_TUNNEL_RESP rnti %x teid %x",
GTPV1U_ENB_DELETE_TUNNEL_RESP(message_p).rnti, GTPV1U_ENB_DELETE_TUNNEL_RESP(message_p).rnti,
teid_eNB); teid_eNB);
return itti_send_msg_to_task(TASK_RRC_ENB, instanceP, message_p); return itti_send_msg_to_task(TASK_RRC_ENB, instanceP, message_p);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
int gtpv1u_eNB_init(void) int gtpv1u_eNB_init(void) {
{
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE; NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
NwGtpv1uUlpEntityT ulp; NwGtpv1uUlpEntityT ulp;
NwGtpv1uUdpEntityT udp; NwGtpv1uUdpEntityT udp;
NwGtpv1uLogMgrEntityT log; NwGtpv1uLogMgrEntityT log;
NwGtpv1uTimerMgrEntityT tmr; NwGtpv1uTimerMgrEntityT tmr;
// enb_properties_p = enb_config_get()->properties[0]; // enb_properties_p = enb_config_get()->properties[0];
RC.gtpv1u_data_g = (gtpv1u_data_t*)calloc(sizeof(gtpv1u_data_t),1); RC.gtpv1u_data_g = (gtpv1u_data_t *)calloc(sizeof(gtpv1u_data_t),1);
LOG_I(GTPU, "Initializing GTPU stack %p\n",&RC.gtpv1u_data_g); LOG_I(GTPU, "Initializing GTPU stack %p\n",&RC.gtpv1u_data_g);
//gtpv1u_data_g.gtpv1u_stack; //gtpv1u_data_g.gtpv1u_stack;
/* Initialize UE hashtable */ /* Initialize UE hashtable */
...@@ -918,8 +861,7 @@ int gtpv1u_eNB_init(void) ...@@ -918,8 +861,7 @@ int gtpv1u_eNB_init(void)
AssertFatal(RC.gtpv1u_data_g->ue_mapping != NULL, " ERROR Initializing TASK_GTPV1_U task interface: in hashtable_create returned %p\n", RC.gtpv1u_data_g->ue_mapping); AssertFatal(RC.gtpv1u_data_g->ue_mapping != NULL, " ERROR Initializing TASK_GTPV1_U task interface: in hashtable_create returned %p\n", RC.gtpv1u_data_g->ue_mapping);
RC.gtpv1u_data_g->teid_mapping = hashtable_create (256, NULL, NULL); RC.gtpv1u_data_g->teid_mapping = hashtable_create (256, NULL, NULL);
AssertFatal(RC.gtpv1u_data_g->teid_mapping != NULL, " ERROR Initializing TASK_GTPV1_U task interface: in hashtable_create\n"); AssertFatal(RC.gtpv1u_data_g->teid_mapping != NULL, " ERROR Initializing TASK_GTPV1_U task interface: in hashtable_create\n");
// RC.gtpv1u_data_g.enb_ip_address_for_S1u_S12_S4_up = enb_properties_p->enb_ipv4_address_for_S1U; // RC.gtpv1u_data_g.enb_ip_address_for_S1u_S12_S4_up = enb_properties_p->enb_ipv4_address_for_S1U;
//gtpv1u_data_g.udp_data; //gtpv1u_data_g.udp_data;
RC.gtpv1u_data_g->seq_num = 0; RC.gtpv1u_data_g->seq_num = 0;
RC.gtpv1u_data_g->restart_counter = 0; RC.gtpv1u_data_g->restart_counter = 0;
...@@ -936,7 +878,6 @@ int gtpv1u_eNB_init(void) ...@@ -936,7 +878,6 @@ int gtpv1u_eNB_init(void)
return -1; return -1;
} }
/* Set the ULP API callback. Called once message have been processed by the /* Set the ULP API callback. Called once message have been processed by the
* nw-gtpv1u stack. * nw-gtpv1u stack.
*/ */
...@@ -983,7 +924,6 @@ int gtpv1u_eNB_init(void) ...@@ -983,7 +924,6 @@ int gtpv1u_eNB_init(void)
} }
#endif #endif
LOG_D(GTPU, "Initializing GTPV1U interface for eNB: DONE\n"); LOG_D(GTPU, "Initializing GTPV1U interface for eNB: DONE\n");
return 0; return 0;
} }
...@@ -997,16 +937,13 @@ void *gtpv1u_eNB_process_itti_msg(void *notUsed) { ...@@ -997,16 +937,13 @@ void *gtpv1u_eNB_process_itti_msg(void *notUsed) {
instance_t instance; instance_t instance;
MessageDef *received_message_p = NULL; MessageDef *received_message_p = NULL;
int rc = 0; int rc = 0;
itti_receive_msg(TASK_GTPV1_U, &received_message_p); itti_receive_msg(TASK_GTPV1_U, &received_message_p);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GTPV1U_ENB_TASK, VCD_FUNCTION_IN); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GTPV1U_ENB_TASK, VCD_FUNCTION_IN);
DevAssert(received_message_p != NULL); DevAssert(received_message_p != NULL);
instance = ITTI_MSG_INSTANCE(received_message_p); instance = ITTI_MSG_INSTANCE(received_message_p);
//msg_name_p = ITTI_MSG_NAME(received_message_p); //msg_name_p = ITTI_MSG_NAME(received_message_p);
switch (ITTI_MSG_ID(received_message_p)) { switch (ITTI_MSG_ID(received_message_p)) {
case GTPV1U_ENB_S1_REQ: case GTPV1U_ENB_S1_REQ:
gtpv1u_s1_req(instance, &received_message_p->ittiMsg.gtpv1uS1Req); gtpv1u_s1_req(instance, &received_message_p->ittiMsg.gtpv1uS1Req);
...@@ -1037,17 +974,14 @@ void *gtpv1u_eNB_process_itti_msg(void *notUsed) { ...@@ -1037,17 +974,14 @@ void *gtpv1u_eNB_process_itti_msg(void *notUsed) {
gtpv1u_ue_data_t *gtpv1u_ue_data_p = NULL; gtpv1u_ue_data_t *gtpv1u_ue_data_p = NULL;
teid_t enb_s1u_teid = 0; teid_t enb_s1u_teid = 0;
teid_t sgw_s1u_teid = 0; teid_t sgw_s1u_teid = 0;
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GTPV1U_PROCESS_TUNNEL_DATA_REQ, VCD_FUNCTION_IN); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GTPV1U_PROCESS_TUNNEL_DATA_REQ, VCD_FUNCTION_IN);
data_req_p = &GTPV1U_ENB_TUNNEL_DATA_REQ(received_message_p); data_req_p = &GTPV1U_ENB_TUNNEL_DATA_REQ(received_message_p);
//ipv4_send_data(ipv4_data_p->sd, data_ind_p->buffer, data_ind_p->length); //ipv4_send_data(ipv4_data_p->sd, data_ind_p->buffer, data_ind_p->length);
#if defined(GTP_DUMP_SOCKET) && GTP_DUMP_SOCKET > 0 #if defined(GTP_DUMP_SOCKET) && GTP_DUMP_SOCKET > 0
gtpv1u_eNB_write_dump_socket(&data_req_p->buffer[data_req_p->offset],data_req_p->length); gtpv1u_eNB_write_dump_socket(&data_req_p->buffer[data_req_p->offset],data_req_p->length);
#endif #endif
memset(&stack_req, 0, sizeof(NwGtpv1uUlpApiT)); memset(&stack_req, 0, sizeof(NwGtpv1uUlpApiT));
hash_rc = hashtable_get(RC.gtpv1u_data_g->ue_mapping, (uint64_t)data_req_p->rnti, (void **)&gtpv1u_ue_data_p);
hash_rc = hashtable_get(RC.gtpv1u_data_g->ue_mapping, (uint64_t)data_req_p->rnti, (void**)&gtpv1u_ue_data_p);
if (hash_rc == HASH_TABLE_KEY_NOT_EXISTS) { if (hash_rc == HASH_TABLE_KEY_NOT_EXISTS) {
LOG_E(GTPU, "nwGtpv1uProcessUlpReq failed: while getting ue rnti %x in hashtable ue_mapping\n", data_req_p->rnti); LOG_E(GTPU, "nwGtpv1uProcessUlpReq failed: while getting ue rnti %x in hashtable ue_mapping\n", data_req_p->rnti);
...@@ -1058,7 +992,6 @@ void *gtpv1u_eNB_process_itti_msg(void *notUsed) { ...@@ -1058,7 +992,6 @@ void *gtpv1u_eNB_process_itti_msg(void *notUsed) {
stack_req.apiType = NW_GTPV1U_ULP_API_SEND_TPDU; stack_req.apiType = NW_GTPV1U_ULP_API_SEND_TPDU;
stack_req.apiInfo.sendtoInfo.teid = sgw_s1u_teid; stack_req.apiInfo.sendtoInfo.teid = sgw_s1u_teid;
stack_req.apiInfo.sendtoInfo.ipAddr = gtpv1u_ue_data_p->bearers[data_req_p->rab_id - GTPV1U_BEARER_OFFSET].sgw_ip_addr; stack_req.apiInfo.sendtoInfo.ipAddr = gtpv1u_ue_data_p->bearers[data_req_p->rab_id - GTPV1U_BEARER_OFFSET].sgw_ip_addr;
rc = nwGtpv1uGpduMsgNew( rc = nwGtpv1uGpduMsgNew(
RC.gtpv1u_data_g->gtpv1u_stack, RC.gtpv1u_data_g->gtpv1u_stack,
sgw_s1u_teid, sgw_s1u_teid,
...@@ -1092,7 +1025,6 @@ void *gtpv1u_eNB_process_itti_msg(void *notUsed) { ...@@ -1092,7 +1025,6 @@ void *gtpv1u_eNB_process_itti_msg(void *notUsed) {
enb_s1u_teid, enb_s1u_teid,
sgw_s1u_teid, sgw_s1u_teid,
data_req_p->length); data_req_p->length);
} }
rc = nwGtpv1uMsgDelete(RC.gtpv1u_data_g->gtpv1u_stack, rc = nwGtpv1uMsgDelete(RC.gtpv1u_data_g->gtpv1u_stack,
...@@ -1113,11 +1045,11 @@ void *gtpv1u_eNB_process_itti_msg(void *notUsed) { ...@@ -1113,11 +1045,11 @@ void *gtpv1u_eNB_process_itti_msg(void *notUsed) {
case TERMINATE_MESSAGE: { case TERMINATE_MESSAGE: {
if (RC.gtpv1u_data_g->ue_mapping != NULL) { if (RC.gtpv1u_data_g->ue_mapping != NULL) {
hashtable_destroy (RC.gtpv1u_data_g->ue_mapping); hashtable_destroy (&(RC.gtpv1u_data_g->ue_mapping));
} }
if (RC.gtpv1u_data_g->teid_mapping != NULL) { if (RC.gtpv1u_data_g->teid_mapping != NULL) {
hashtable_destroy (RC.gtpv1u_data_g->teid_mapping); hashtable_destroy (&(RC.gtpv1u_data_g->teid_mapping));
} }
LOG_W(GTPU, " *** Exiting GTPU thread\n"); LOG_W(GTPU, " *** Exiting GTPU thread\n");
...@@ -1141,15 +1073,12 @@ void *gtpv1u_eNB_process_itti_msg(void *notUsed) { ...@@ -1141,15 +1073,12 @@ void *gtpv1u_eNB_process_itti_msg(void *notUsed) {
AssertFatal(rc == EXIT_SUCCESS, "Failed to free memory (%d)!\n", rc); AssertFatal(rc == EXIT_SUCCESS, "Failed to free memory (%d)!\n", rc);
received_message_p = NULL; received_message_p = NULL;
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GTPV1U_ENB_TASK, VCD_FUNCTION_OUT); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GTPV1U_ENB_TASK, VCD_FUNCTION_OUT);
return NULL; return NULL;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void *gtpv1u_eNB_task(void *args) void *gtpv1u_eNB_task(void *args) {
{
int rc = 0; int rc = 0;
rc = gtpv1u_eNB_init(); rc = gtpv1u_eNB_init();
AssertFatal(rc == 0, "gtpv1u_eNB_init Failed"); AssertFatal(rc == 0, "gtpv1u_eNB_init Failed");
itti_mark_task_ready(TASK_GTPV1_U); itti_mark_task_ready(TASK_GTPV1_U);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment