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) {
int unknowndetected=0;
char testprefix[CONFIG_MAXOPTLENGTH];
int finalcheck = 0;
memset(testprefix,0,sizeof(testprefix));
memset(testprefix,0,sizeof(testprefix));
if (prefix != NULL) {
......
......@@ -2,9 +2,9 @@
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
......@@ -28,17 +28,33 @@
//-------------------------------------------------------------------------------------------------------------------------------
char* hashtable_rc_code2string(hashtable_rc_t rcP)
char *hashtable_rc_code2string(hashtable_rc_t rcP)
//-------------------------------------------------------------------------------------------------------------------------------
{
switch (rcP) {
case HASH_TABLE_OK: return "HASH_TABLE_OK";break;
case HASH_TABLE_INSERT_OVERWRITTEN_DATA: 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";
}
switch (rcP) {
case HASH_TABLE_OK:
return "HASH_TABLE_OK";
break;
case HASH_TABLE_INSERT_OVERWRITTEN_DATA:
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)
* 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,9 +71,8 @@ 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.
*/
static hash_size_t def_hashfunc(const uint64_t keyP)
{
return (hash_size_t)keyP;
static hash_size_t def_hashfunc(const uint64_t keyP) {
return (hash_size_t)keyP;
}
//-------------------------------------------------------------------------------------------------------------------------------
......@@ -67,132 +82,147 @@ 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.
* 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 *hashtbl = NULL;
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;
if(!(hashtbl=malloc(sizeof(hash_table_t)))) {
return NULL;
}
if(!(hashtbl=malloc(sizeof(hash_table_t)))) {
return NULL;
}
if(!(hashtbl->nodes=calloc(sizeP, sizeof(hash_node_t*)))) {
free(hashtbl);
return NULL;
}
if(!(hashtbl->nodes=calloc(sizeP, sizeof(hash_node_t *)))) {
free(hashtbl);
return NULL;
}
hashtbl->size=sizeP;
hashtbl->size=sizeP;
if(hashfuncP) hashtbl->hashfunc=hashfuncP;
else hashtbl->hashfunc=def_hashfunc;
if(hashfuncP) hashtbl->hashfunc=hashfuncP;
else hashtbl->hashfunc=def_hashfunc;
if(freefuncP) hashtbl->freefunc=freefuncP;
else hashtbl->freefunc=free;
if(freefuncP) hashtbl->freefunc=freefuncP;
else hashtbl->freefunc=free;
return hashtbl;
return hashtbl;
}
//-------------------------------------------------------------------------------------------------------------------------------
/*
* 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.
*/
hashtable_rc_t hashtable_destroy(hash_table_t * hashtblP)
{
hash_size_t n;
hash_node_t *node, *oldnode;
hashtable_rc_t hashtable_destroy(hash_table_t **hashtblP) {
hash_size_t n;
hash_node_t *node, *oldnode;
if (hashtblP == NULL) {
return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
}
if (*hashtblP == NULL) {
return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
}
for(n=0; n<(*hashtblP)->size; ++n) {
node=(*hashtblP)->nodes[n];
for(n=0; n<hashtblP->size; ++n) {
node=hashtblP->nodes[n];
while(node) {
oldnode=node;
node=node->next;
if (oldnode->data) {
hashtblP->freefunc(oldnode->data);
}
free(oldnode);
}
while(node) {
oldnode=node;
node=node->next;
if (oldnode->data) {
(*hashtblP)->freefunc(oldnode->data);
}
free(oldnode);
}
free(hashtblP->nodes);
free(hashtblP);
hashtblP=NULL;
return HASH_TABLE_OK;
}
free((*hashtblP)->nodes);
free((*hashtblP));
*hashtblP=NULL;
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_size_t hash = 0;
hash_node_t *node = NULL;
hash_size_t hash = 0;
if (hashtblP == NULL) {
return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
}
if (hashtblP == NULL) {
return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
}
hash=hashtblP->hashfunc(keyP)%hashtblP->size;
node=hashtblP->nodes[hash];
while(node) {
if(node->key == keyP) {
return HASH_TABLE_OK;
}
node=node->next;
hash=hashtblP->hashfunc(keyP)%hashtblP->size;
node=hashtblP->nodes[hash];
while(node) {
if(node->key == keyP) {
return HASH_TABLE_OK;
}
return HASH_TABLE_KEY_NOT_EXISTS;
node=node->next;
}
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;
unsigned int i = 0;
unsigned int num_elements = 0;
if (hashtblP == NULL) {
return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
}
while ((num_elements < hashtblP->num_elements) && (i < hashtblP->size)) {
if (hashtblP->nodes[i] != NULL) {
node=hashtblP->nodes[i];
while(node) {
num_elements += 1;
functP(node->key, node->data, parameterP);
node=node->next;
}
}
i += 1;
hash_node_t *node = NULL;
unsigned int i = 0;
unsigned int num_elements = 0;
if (hashtblP == NULL) {
return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
}
while ((num_elements < hashtblP->num_elements) && (i < hashtblP->size)) {
if (hashtblP->nodes[i] != NULL) {
node=hashtblP->nodes[i];
while(node) {
num_elements += 1;
functP(node->key, node->data, parameterP);
node=node->next;
}
}
return HASH_TABLE_OK;
i += 1;
}
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;
unsigned int i = 0;
if (hashtblP == NULL) {
hash_node_t *node = NULL;
unsigned int i = 0;
if (hashtblP == NULL) {
*remaining_bytes_in_buffer_pP = snprintf(
buffer_pP,
*remaining_bytes_in_buffer_pP,
"HASH_TABLE_BAD_PARAMETER_HASHTABLE");
return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
}
while ((i < hashtblP->size) && (*remaining_bytes_in_buffer_pP > 0)) {
if (hashtblP->nodes[i] != NULL) {
node=hashtblP->nodes[i];
while(node) {
*remaining_bytes_in_buffer_pP = snprintf(
buffer_pP,
*remaining_bytes_in_buffer_pP,
"HASH_TABLE_BAD_PARAMETER_HASHTABLE");
return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
}
while ((i < hashtblP->size) && (*remaining_bytes_in_buffer_pP > 0)) {
if (hashtblP->nodes[i] != NULL) {
node=hashtblP->nodes[i];
while(node) {
*remaining_bytes_in_buffer_pP = snprintf(
buffer_pP,
*remaining_bytes_in_buffer_pP,
"Key 0x%"PRIx64" Element %p\n",
node->key,
node->data);
node=node->next;
}
}
i += 1;
buffer_pP,
*remaining_bytes_in_buffer_pP,
"Key 0x%"PRIx64" Element %p\n",
node->key,
node->data);
node=node->next;
}
}
return HASH_TABLE_OK;
i += 1;
}
return HASH_TABLE_OK;
}
//-------------------------------------------------------------------------------------------------------------------------------
......@@ -200,97 +230,110 @@ hashtable_rc_t hashtable_dump_content (const hash_table_t * const hashtblP, char
* 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.
*/
hashtable_rc_t hashtable_insert(hash_table_t * const hashtblP, const hash_key_t keyP, void *dataP)
{
hash_node_t *node = NULL;
hash_size_t hash = 0;
if (hashtblP == NULL) {
return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
}
hash=hashtblP->hashfunc(keyP)%hashtblP->size;
hashtable_rc_t hashtable_insert(hash_table_t *const hashtblP, const hash_key_t keyP, void *dataP) {
hash_node_t *node = NULL;
hash_size_t hash = 0;
node=hashtblP->nodes[hash];
while(node) {
if(node->key == keyP) {
if (node->data) {
hashtblP->freefunc(node->data);
}
node->data=dataP;
return HASH_TABLE_INSERT_OVERWRITTEN_DATA;
}
node=node->next;
}
if(!(node=malloc(sizeof(hash_node_t)))) return -1;
node->key=keyP;
node->data=dataP;
if (hashtblP->nodes[hash]) {
node->next=hashtblP->nodes[hash];
} else {
node->next = NULL;
if (hashtblP == NULL) {
return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
}
hash=hashtblP->hashfunc(keyP)%hashtblP->size;
node=hashtblP->nodes[hash];
while(node) {
if(node->key == keyP) {
if (node->data) {
hashtblP->freefunc(node->data);
}
node->data=dataP;
return HASH_TABLE_INSERT_OVERWRITTEN_DATA;
}
hashtblP->nodes[hash]=node;
hashtblP->num_elements += 1;
return HASH_TABLE_OK;
node=node->next;
}
if(!(node=malloc(sizeof(hash_node_t)))) return -1;
node->key=keyP;
node->data=dataP;
if (hashtblP->nodes[hash]) {
node->next=hashtblP->nodes[hash];
} else {
node->next = NULL;
}
hashtblP->nodes[hash]=node;
hashtblP->num_elements += 1;
return HASH_TABLE_OK;
}
//-------------------------------------------------------------------------------------------------------------------------------
/*
* 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.
*/
hashtable_rc_t hashtable_remove(hash_table_t * const hashtblP, const hash_key_t keyP)
{
hash_node_t *node, *prevnode=NULL;
hash_size_t hash = 0;
hashtable_rc_t hashtable_remove(hash_table_t *const hashtblP, const hash_key_t keyP) {
hash_node_t *node, *prevnode=NULL;
hash_size_t hash = 0;
if (hashtblP == NULL) {
return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
}
hash=hashtblP->hashfunc(keyP)%hashtblP->size;
node=hashtblP->nodes[hash];
while(node) {
if(node->key == keyP) {
if(prevnode) prevnode->next=node->next;
else hashtblP->nodes[hash]=node->next;
if (node->data) {
hashtblP->freefunc(node->data);
}
free(node);
hashtblP->num_elements -= 1;
return HASH_TABLE_OK;
}
prevnode=node;
node=node->next;
if (hashtblP == NULL) {
return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
}
hash=hashtblP->hashfunc(keyP)%hashtblP->size;
node=hashtblP->nodes[hash];
while(node) {
if(node->key == keyP) {
if(prevnode) prevnode->next=node->next;
else hashtblP->nodes[hash]=node->next;
if (node->data) {
hashtblP->freefunc(node->data);
}
free(node);
hashtblP->num_elements -= 1;
return HASH_TABLE_OK;
}
return HASH_TABLE_KEY_NOT_EXISTS;
prevnode=node;
node=node->next;
}
return HASH_TABLE_KEY_NOT_EXISTS;
}
//-------------------------------------------------------------------------------------------------------------------------------
/*
* 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.
*/
hashtable_rc_t hashtable_get(const hash_table_t * const hashtblP, const hash_key_t keyP, void** dataP)
{
hash_node_t *node = NULL;
hash_size_t hash = 0;
hashtable_rc_t hashtable_get(const hash_table_t *const hashtblP, const hash_key_t keyP, void **dataP) {
hash_node_t *node = NULL;
hash_size_t hash = 0;
if (hashtblP == NULL) {
*dataP = NULL;
return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
}
hash=hashtblP->hashfunc(keyP)%hashtblP->size;
/* fprintf(stderr, "hashtable_get() key=%s, hash=%d\n", key, hash);*/
if (hashtblP == NULL) {
*dataP = NULL;
return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
}
node=hashtblP->nodes[hash];
hash=hashtblP->hashfunc(keyP)%hashtblP->size;
/* fprintf(stderr, "hashtable_get() key=%s, hash=%d\n", key, hash);*/
node=hashtblP->nodes[hash];
while(node) {
if(node->key == keyP) {
*dataP = node->data;
return HASH_TABLE_OK;
}
node=node->next;
while(node) {
if(node->key == keyP) {
*dataP = node->data;
return HASH_TABLE_OK;
}
*dataP = NULL;
return HASH_TABLE_KEY_NOT_EXISTS;
node=node->next;
}
*dataP = NULL;
return HASH_TABLE_KEY_NOT_EXISTS;
}
//-------------------------------------------------------------------------------------------------------------------------------
/*
......@@ -304,36 +347,33 @@ 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.
*/
hashtable_rc_t hashtable_resize(hash_table_t * const hashtblP, const hash_size_t sizeP)
{
hash_table_t newtbl;
hash_size_t n;
hash_node_t *node,*next;
if (hashtblP == NULL) {
return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
}
hashtable_rc_t hashtable_resize(hash_table_t *const hashtblP, const hash_size_t sizeP) {
hash_table_t newtbl;
hash_size_t n;
hash_node_t *node,*next;
newtbl.size = sizeP;
newtbl.hashfunc = hashtblP->hashfunc;
if (hashtblP == NULL) {
return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
}
if(!(newtbl.nodes=calloc(sizeP, sizeof(hash_node_t*)))) return -1;
newtbl.size = sizeP;
newtbl.hashfunc = hashtblP->hashfunc;
for(n=0; n<hashtblP->size; ++n) {
for(node=hashtblP->nodes[n]; node; node=next) {
next = node->next;
hashtable_insert(&newtbl, node->key, node->data);
// Lionel GAUTHIER: BAD CODE TO BE REWRITTEN
hashtable_remove(hashtblP, node->key);
if(!(newtbl.nodes=calloc(sizeP, sizeof(hash_node_t *)))) return -1;
}
for(n=0; n<hashtblP->size; ++n) {
for(node=hashtblP->nodes[n]; node; node=next) {
next = node->next;
hashtable_insert(&newtbl, node->key, node->data);
// Lionel GAUTHIER: BAD CODE TO BE REWRITTEN
hashtable_remove(hashtblP, node->key);
}
}
free(hashtblP->nodes);
hashtblP->size=newtbl.size;
hashtblP->nodes=newtbl.nodes;
return HASH_TABLE_OK;
free(hashtblP->nodes);
hashtblP->size=newtbl.size;
hashtblP->nodes=newtbl.nodes;
return HASH_TABLE_OK;
}
......
......@@ -2,9 +2,9 @@
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
......@@ -31,41 +31,41 @@ typedef uint64_t hash_key_t;
#define HASHTABLE_NOT_A_KEY_VALUE ((uint64_t)-1)
typedef enum hashtable_return_code_e {
HASH_TABLE_OK = 0,
HASH_TABLE_INSERT_OVERWRITTEN_DATA = 1,
HASH_TABLE_KEY_NOT_EXISTS = 2,
HASH_TABLE_KEY_ALREADY_EXISTS = 3,
HASH_TABLE_BAD_PARAMETER_HASHTABLE = 4,
HASH_TABLE_SYSTEM_ERROR = 5,
HASH_TABLE_CODE_MAX
HASH_TABLE_OK = 0,
HASH_TABLE_INSERT_OVERWRITTEN_DATA = 1,
HASH_TABLE_KEY_NOT_EXISTS = 2,
HASH_TABLE_KEY_ALREADY_EXISTS = 3,
HASH_TABLE_BAD_PARAMETER_HASHTABLE = 4,
HASH_TABLE_SYSTEM_ERROR = 5,
HASH_TABLE_CODE_MAX
} hashtable_rc_t;
typedef struct hash_node_s {
hash_key_t key;
void *data;
struct hash_node_s *next;
hash_key_t key;
void *data;
struct hash_node_s *next;
} hash_node_t;
typedef struct hash_table_s {
hash_size_t size;
hash_size_t num_elements;
struct hash_node_s **nodes;
hash_size_t (*hashfunc)(const hash_key_t);
void (*freefunc)(void*);
hash_size_t size;
hash_size_t num_elements;
struct hash_node_s **nodes;
hash_size_t (*hashfunc)(const hash_key_t);
void (*freefunc)(void *);
} hash_table_t;
char* hashtable_rc_code2string(hashtable_rc_t rcP);
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*));
hashtable_rc_t hashtable_destroy(hash_table_t * const hashtbl);
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_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_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_resize (hash_table_t * const hashtbl, const hash_size_t size);
char *hashtable_rc_code2string(hashtable_rc_t rcP);
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 *));
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_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_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_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);
......
......@@ -23,19 +23,19 @@
#include "memory_pools.h"
#if T_TRACER
#include <string.h>
#include "T.h"
#include <string.h>
#include "T.h"
#endif
/*------------------------------------------------------------------------------*/
const static int mp_debug = 0;
# define MP_DEBUG(x, args...) do { if (mp_debug) fprintf(stdout, "[MP][D]"x, ##args); fflush (stdout); } \
while(0)
while(0)
/*------------------------------------------------------------------------------*/
#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
#define MEMORY_POOL_ITEM_INFO_NUMBER 2
......@@ -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 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;
}
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;
uint32_t free_items;
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;
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 put;
items_group_position_t get;
items_group_position_t free_items;
items_group_index_t index = ITEMS_GROUP_INDEX_INVALID;
/* Get current put position */
put = items_group->positions.ind.put % items_group->number_plus_one;
/* 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
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;
/* Get current put position and increase it */
put_raw = __sync_fetch_and_add (&items_group->positions.ind.put, 1);
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
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);
/* Save freed item index at current put position */
items_group->indexes[put] = index;
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;
/* Recover memory_pools */
memory_pools = (memory_pools_t *) memory_pools_handle;
/* Sanity check on passed handle */
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);
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;
memory_pool_item_t *memory_pool_item;
/* Recover memory_pools */
address = memory_pool_item_handle - sizeof(memory_pool_item_start_t);
memory_pool_item = (memory_pool_item_t *) address;
/* Sanity check on passed handle */
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);
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;
address = (void *) memory_pool->items;
address += index * memory_pool->pool_item_size;
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;
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 */
/* Allocate memory_pools */
memory_pools = malloc (sizeof(memory_pools_t));
AssertFatal (memory_pools != NULL, "Memory pools structure allocation failed!\n");
/* Initialize memory_pools */
{
memory_pools->start_mark = POOLS_START_MARK;
memory_pools->pools_number = pools_number;
memory_pools->pools_defined = 0;
/* Allocate pools */
memory_pools->pools = calloc (pools_number, sizeof(memory_pool_t));
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)
memory_pools->pools[pool].start_mark = POOL_START_MARK;
}
}
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;
pool_id_t pool;
char *statistics;
......@@ -296,13 +268,10 @@ char *memory_pools_statistics(memory_pools_handle_t memory_pools_handle)
uint32_t allocated_pools_memory = 0;
items_group_t *items_group;
uint32_t pool_items_size;
/* Recover memory_pools */
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);
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");
for (pool = 0; pool < memory_pools->pools_defined; pool++) {
......@@ -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));
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_pool_t *memory_pool;
pool_id_t pool;
items_group_index_t item_index;
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_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 */
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);
/* 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);
/* Select pool */
pool = memory_pools->pools_defined;
memory_pool = &memory_pools->pools[pool];
/* Initialize 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
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.get = 0;
/* Allocate free indexes */
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");
......@@ -369,7 +330,6 @@ int memory_pools_add_pool (memory_pools_handle_t memory_pools_handle, uint32_t p
/* Last index is not allocated */
memory_pool->items_group_free.indexes[item_index] = ITEMS_GROUP_INDEX_INVALID;
/* Allocate items */
memory_pool->items = calloc (pool_items_number, memory_pool->pool_item_size);
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
memory_pool_item->data[memory_pool->item_data_number] = POOL_ITEM_END_MARK;
}
}
memory_pools->pools_defined ++;
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_pool_item_t *memory_pool_item;
memory_pool_item_handle_t memory_pool_item_handle = NULL;
pool_id_t pool;
items_group_index_t item_index = ITEMS_GROUP_INDEX_INVALID;
/* Recover memory_pools */
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);
......@@ -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 */
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 = ITEM_STATUS_ALLOCATED;
memory_pool_item->start.info[0] = info_0;
memory_pool_item->start.info[1] = info_1;
memory_pool_item_handle = memory_pool_item->data;
MP_DEBUG(" Alloc [%2u][%6d]{%6d}, %3u %3u, %6u, %p, %p, %p\n",
pool, item_index,
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
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_pool_item_t *memory_pool_item;
pool_id_t pool;
......@@ -455,36 +408,29 @@ int memory_pools_free (memory_pools_handle_t memory_pools_handle, memory_pool_it
uint32_t pool_item_size;
uint16_t info_1;
int result;
/* Recover memory_pools */
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);
/* Recover memory pool item */
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);
info_1 = memory_pool_item->start.info[1];
/* Recover pool index */
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);
item_size = memory_pools->pools[pool].item_data_number;
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;
MP_DEBUG(" Free [%2u][%6d]{%6d}, %3u %3u, %p, %p, %p, %u\n",
pool, item_index,
items_group_free_items (&memory_pools->pools[pool].items_group_free),
memory_pool_item->start.info[0], info_1,
memory_pool_item_handle, memory_pool_item,
memory_pools->pools[pool].items, ((uint32_t) (item_size * sizeof(memory_pool_data_t))));
/* Sanity check on calculated 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",
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) */
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);
......@@ -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,
"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 = ITEM_STATUS_FREE;
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);
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_pool_item_t *memory_pool_item;
pool_id_t pool;
items_group_index_t item_index;
uint32_t 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);
/* Recover memory pool item */
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);
/* Set info[1] */
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
/* Recover memory_pools */
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);
/* Recover pool index */
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);
item_size = memory_pools->pools[pool].item_data_number;
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;
MP_DEBUG(" Info [%2u][%6d]{%6d}, %3u %3u, %p, %p, %p, %u\n",
pool, item_index,
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_handle, memory_pool_item,
memory_pools->pools[pool].items, ((uint32_t) (item_size * sizeof(memory_pool_data_t))));
/* Sanity check on calculated 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",
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) */
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);
......
......@@ -77,17 +77,17 @@ paramdef_t telnetoptions[] = {
/* configuration parameters for telnet utility */
/* optname helpstr paramflags XXXptr defXXXval type numelt */
/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
{"listenaddr", "<listen ip address>\n", 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 },
{"priority", "<scheduling policy (0-99)\n", 0, iptr:&telnetparams.priority, defuintval:0, TYPE_INT, 0 },
{"debug", "<debug level>\n", 0, uptr:NULL, defuintval:0, TYPE_UINT, 0 },
{"loopcount", "<loop command iterations>\n", 0, uptr:&(telnetparams.loopcount), defuintval:10, TYPE_UINT, 0 },
{"loopdelay", "<loop command delay (ms)>\n", 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 },
{"histsize", "<history sizes>\n", 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 },
{"staticmod", "<static modules selection>\n", 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 }
{"listenaddr", "<listen ip address>", 0, uptr:&telnetparams.listenaddr, defstrval:"0.0.0.0", TYPE_IPV4ADDR, 0 },
{"listenport", "<local port>", 0, uptr:&(telnetparams.listenport), defuintval:9090, TYPE_UINT, 0 },
{"priority", "<scheduling policy (0-99)", 0, iptr:&telnetparams.priority, defuintval:0, TYPE_INT, 0 },
{"debug", "<debug level>", 0, uptr:NULL, defuintval:0, TYPE_UINT, 0 },
{"loopcount", "<loop command iterations>", 0, uptr:&(telnetparams.loopcount), defuintval:10, TYPE_UINT, 0 },
{"loopdelay", "<loop command delay (ms)>", 0, uptr:&(telnetparams.loopdelay), defuintval:5000, TYPE_UINT, 0 },
{"histfile", "<history file name>", PARAMFLAG_NOFREE, strptr:&(telnetparams.histfile), defstrval:"oaitelnet.history", TYPE_STRING, 0 },
{"histsize", "<history sizes>", 0, iptr:&(telnetparams.histsize), defuintval:50, TYPE_INT, 0 },
{"phypbsize", "<phy dump buff size (bytes)>",0, uptr:&(telnetparams.phyprntbuff_size),defuintval:65000, TYPE_UINT, 0 },
{"staticmod", "<static modules selection>", 0, strlistptr:NULL, defstrlistval:telnet_defstatmod,TYPE_STRINGLIST,(sizeof(telnet_defstatmod)/sizeof(char *))},
{"shrmod", "<dynamic modules selection>", 0, strlistptr:NULL, defstrlistval:NULL,TYPE_STRINGLIST,0 }
};
int get_phybsize(void) {
......@@ -355,7 +355,8 @@ int setgetvar(int moduleindex,char getorset,char *params) {
char varname[TELNET_CMD_MAXSIZE];
char *varval=NULL;
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++) {
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) {
memset(cmdb,0,sizeof(cmdb));
bufbck=strdup(buf);
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)
printf("process_command: %i words, module=%s cmd=%s, parameters= %s\n",j,modulename,cmd,cmdb);
......
......@@ -29,7 +29,7 @@
* \note
* \warning
*/
#define _GNU_SOURCE
#define _GNU_SOURCE
#include <string.h>
#include <pthread.h>
......@@ -39,104 +39,88 @@
#define TELNETSRV_PHYCMD_MAIN
#include "telnetsrv_phycmd.h"
char *prnbuff;
extern int dump_eNB_stats(PHY_VARS_eNB *eNB, char* buffer, int length);
void init_phytelnet(void)
{
prnbuff=malloc(get_phybsize() );
if (prnbuff == NULL)
{
fprintf(stderr,"Error %s on malloc in init_phytelnet()\n",strerror(errno));
}
}
extern int dump_eNB_l2_stats(char *buffer, int length);
void init_phytelnet(void) {
prnbuff=malloc(get_phybsize() );
void display_uestatshead( telnet_printfunc_t prnt)
{
prnt("cc ue rnti Dmcs Umcs tao tau Dbr Dtb \n");
if (prnbuff == NULL) {
fprintf(stderr,"Error %s on malloc in init_phytelnet()\n",strerror(errno));
}
}
void dump_uestats(int debug, telnet_printfunc_t prnt, uint8_t prntflag)
{
void display_uestatshead( telnet_printfunc_t prnt) {
prnt("cc ue rnti Dmcs Umcs tao tau Dbr Dtb \n");
}
int p;
void dump_uestats(int debug, telnet_printfunc_t prnt, uint8_t prntflag) {
int p;
prnbuff=malloc(20480);
p=dump_eNB_l2_stats( prnbuff, 20480);
p=dump_eNB_l2_stats( prnbuff, 0);
if(prntflag>=1)
prnt("%s\n",prnbuff);
if(debug>=1)
prnt("%i bytes printed\n",p);
if(prntflag>=1)
prnt("%s\n",prnbuff);
if(debug>=1)
prnt("%i bytes printed\n",p);
free(prnbuff);
}
void display_uestats(int debug, telnet_printfunc_t prnt, int ue)
{
for (int cc=0; cc<1 ; cc++)
{
}
void display_uestats(int debug, telnet_printfunc_t prnt, int ue) {
for (int cc=0; cc<1 ; cc++) {
}
}
void display_phycounters(char *buf, int debug, telnet_printfunc_t prnt)
{
prnt(" DLSCH kb DLSCH kb/s\n");
dump_uestats(debug, prnt,0);
void display_phycounters(char *buf, int debug, telnet_printfunc_t prnt) {
prnt(" DLSCH kb DLSCH kb/s\n");
dump_uestats(debug, prnt,0);
}
int dump_phyvars(char *buf, int debug, telnet_printfunc_t prnt)
{
if (debug > 0)
prnt("phy interface module received %s\n",buf);
if (strcasestr(buf,"phycnt") != NULL)
{
display_phycounters(buf, debug, prnt);
}
if (strcasestr(buf,"uestat") != NULL)
{
char *cptr=strcasestr(buf+sizeof("uestat"),"UE");
display_uestatshead(prnt);
if (cptr != NULL)
{
int ueidx = strtol( cptr+sizeof("UE"), NULL, 10);
if (ueidx < NUMBER_OF_UE_MAX && ueidx >= 0)
{
display_uestats(debug, prnt,ueidx);
}
} /* if cptr != NULL */
else
{
for (int ue=0; ue<NUMBER_OF_UE_MAX ; ue++)
{
display_uestats(debug, prnt,ue);
}
} /* else cptr != NULL */
} /* uestat */
if (strcasestr(buf,"uedump") != NULL)
{
dump_uestats(debug, prnt,1);
}
return 0;
int dump_phyvars(char *buf, int debug, telnet_printfunc_t prnt) {
if (debug > 0)
prnt("phy interface module received %s\n",buf);
if (strcasestr(buf,"phycnt") != NULL) {
display_phycounters(buf, debug, prnt);
}
if (strcasestr(buf,"uestat") != NULL) {
char *cptr=strcasestr(buf+sizeof("uestat"),"UE");
display_uestatshead(prnt);
if (cptr != NULL) {
int ueidx = strtol( cptr+sizeof("UE"), NULL, 10);
if (ueidx < NUMBER_OF_UE_MAX && ueidx >= 0) {
display_uestats(debug, prnt,ueidx);
}
} /* if cptr != NULL */
else {
for (int ue=0; ue<NUMBER_OF_UE_MAX ; ue++) {
display_uestats(debug, prnt,ue);
}
} /* else cptr != NULL */
} /* uestat */
if (strcasestr(buf,"uedump") != NULL) {
dump_uestats(debug, prnt,1);
}
return 0;
}
telnetshell_cmddef_t phy_cmdarray[] = {
{"disp","[phycnt,uedump,uestat UE<x>]", dump_phyvars},
{"disp","[phycnt,uedump,uestat UE<x>]", dump_phyvars},
{"","",NULL},
{"","",NULL},
};
/*-------------------------------------------------------------------------------------*/
void add_phy_cmds(void)
{
init_phytelnet();
add_telnetcmd("phy", phy_vardef, phy_cmdarray);
void add_phy_cmds(void) {
init_phytelnet();
add_telnetcmd("phy", phy_vardef, phy_cmdarray);
}
......@@ -61,7 +61,7 @@ typedef struct {
char local_addr[80];
int local_port;
char* remote_addr;
char *remote_addr;
int remote_port;
uint8_t duplex_mode;
......@@ -127,12 +127,12 @@ typedef struct mac mac_t;
typedef struct mac {
void* user_data;
void *user_data;
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 (*hi_dci0_req)(mac_t* mac, nfapi_hi_dci0_request_t* req);
void (*tx_req)(mac_t* mac, nfapi_tx_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 (*hi_dci0_req)(mac_t *mac, nfapi_hi_dci0_request_t *req);
void (*tx_req)(mac_t *mac, nfapi_tx_request_t *req);
} mac_t;
typedef struct {
......@@ -145,15 +145,15 @@ typedef struct {
unsigned aperiodic_timing_enabled;
unsigned periodic_timing_period;
// This is not really the right place if we have multiple PHY,
// This is not really the right place if we have multiple PHY,
// should be part of the phy struct
udp_data udp;
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;
......@@ -165,24 +165,27 @@ typedef struct {
} 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_tl_t* tlv = (nfapi_tl_t*)ve;
nfapi_tl_t *tlv = (nfapi_tl_t *)ve;
switch(tlv->tag) {
case VENDOR_EXT_TLV_2_TAG:
{
//NFAPI_TRACE(NFAPI_TRACE_INFO, "Packing VENDOR_EXT_TLV_2\n");
vendor_ext_tlv_2* ve = (vendor_ext_tlv_2*)tlv;
if(!push32(ve->dummy, ppWritePackedMsg, end))
return 0;
return 1;
}
break;
case VENDOR_EXT_TLV_2_TAG: {
//NFAPI_TRACE(NFAPI_TRACE_INFO, "Packing VENDOR_EXT_TLV_2\n");
vendor_ext_tlv_2 *ve = (vendor_ext_tlv_2 *)tlv;
if(!push32(ve->dummy, ppWritePackedMsg, end))
return 0;
return 1;
}
break;
}
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;
}
......@@ -192,17 +195,14 @@ extern void init_eNB_afterRU(void);
extern uint16_t sf_ahead;
void oai_create_enb(void) {
int bodge_counter=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, eNB->single_thread_flag, eNB->if_inst);
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->Mod_id = bodge_counter;
eNB->CC_id = bodge_counter;
eNB->abstraction_flag = 0;
eNB->single_thread_flag = 0;//single_thread_flag;
RC.nb_CC[bodge_counter] = 1;
if (eNB->if_inst==0) {
......@@ -213,7 +213,6 @@ void oai_create_enb(void) {
// 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
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");
install_schedule_handlers(RC.eNB[0][0]->if_inst);
}
......@@ -227,17 +226,13 @@ void oai_create_enb(void) {
}
void oai_enb_init(void) {
printf("%s() About to call init_eNB_afterRU()\n", __FUNCTION__);
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);
oai_create_enb();
nfapi_pnf_param_request_t req;
memset(&req, 0, sizeof(req));
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) {
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);
vnf_info* vnf = (vnf_info*)(config->user_data);
vnf_info *vnf = (vnf_info *)(config->user_data);
pnf_info *pnf = vnf->pnfs;
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);
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);
vnf_info* vnf = (vnf_info*)(config->user_data);
vnf_info *vnf = (vnf_info *)(config->user_data);
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;
memset(&phy,0,sizeof(phy));
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);
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);
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
rf_info rf;
memset(&rf,0,sizeof(rf));
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);
pnf->rfs[0] = rf;
}
nfapi_pnf_config_request_t req;
memset(&req, 0, sizeof(req));
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.number_phy_rf_config_info = 2; // DJP pnf.phys.size();
printf("DJP:Hard coded num phy rf to 2\n");
......@@ -311,25 +292,22 @@ 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);
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);
if(1) {
nfapi_pnf_start_request_t req;
memset(&req, 0, sizeof(req));
req.header.phy_id = resp->header.phy_id;
req.header.message_id = NFAPI_PNF_START_REQUEST;
nfapi_vnf_pnf_start_req(config, p5_idx, &req);
nfapi_pnf_start_request_t req;
memset(&req, 0, sizeof(req));
req.header.phy_id = resp->header.phy_id;
req.header.message_id = NFAPI_PNF_START_REQUEST;
nfapi_vnf_pnf_start_req(config, p5_idx, &req);
} else {
// Rather than send the pnf_start_request we will demonstrate
// 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);
vendor_ext_p5_req 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_
req.dummy2 = 1977;
nfapi_vnf_vendor_extension(config, p5_idx, &req.header);
}
return 0;
}
int wake_eNB_rxtx(PHY_VARS_eNB *eNB, uint16_t sfn, uint16_t sf) {
L1_proc_t *proc=&eNB->proc;
L1_rxtx_proc_t *L1_proc= (sf&1)? &proc->L1_proc : &proc->L1_proc_tx;
LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms;
//printf("%s(eNB:%p, sfn:%d, sf:%d)\n", __FUNCTION__, eNB, sfn, sf);
//int i;
struct timespec wait;
wait.tv_sec=0;
wait.tv_nsec=5000000L;
......@@ -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_sfn = 0;
proc->subframe_rx = old_sf;
proc->frame_rx = old_sfn;
// Try to be 1 frame back
old_sf = sf;
old_sfn = sfn;
......@@ -380,9 +351,7 @@ int wake_eNB_rxtx(PHY_VARS_eNB *eNB, uint16_t sfn, uint16_t sf) {
}
++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);
// 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
// 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) {
//LOG_D(PHY,"%s() About to attempt pthread_mutex_unlock\n", __FUNCTION__);
pthread_mutex_unlock( &L1_proc->mutex );
//LOG_D(PHY,"%s() UNLOCKED pthread_mutex_unlock\n", __FUNCTION__);
return(0);
}
......@@ -415,12 +383,10 @@ extern pthread_cond_t nfapi_sync_cond;
extern pthread_mutex_t nfapi_sync_mutex;
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");
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");
pthread_mutex_lock(&nfapi_sync_mutex);
nfapi_sync_var=0;
......@@ -431,9 +397,9 @@ int phy_sync_indication(struct nfapi_vnf_p7_config* config, uint8_t sync) {
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;
if (first_time) {
printf("[VNF] subframe indication %d\n", NFAPI_SFNSF2DEC(sfn_sf));
first_time = 0;
......@@ -442,40 +408,33 @@ int phy_subframe_indication(struct nfapi_vnf_p7_config* config, uint16_t phy_id,
if (RC.eNB && RC.eNB[0][0]->configured) {
uint16_t sfn = NFAPI_SFNSF2SFN(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);
wake_eNB_rxtx(RC.eNB[0][0], sfn, sf);
} else {
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);
}
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);
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);
pthread_mutex_lock(&eNB->UL_INFO_mutex);
eNB->UL_INFO.rach_ind = *ind;
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) {
printf("preamble[%d]: rnti:%02x preamble:%d timing_advance:%d\n",
i,
ind->rach_indication_body.preamble_list[i].preamble_rel8.rnti,
ind->rach_indication_body.preamble_list[i].preamble_rel8.preamble,
ind->rach_indication_body.preamble_list[i].preamble_rel8.timing_advance
);
printf("preamble[%d]: rnti:%02x preamble:%d timing_advance:%d\n",
i,
ind->rach_indication_body.preamble_list[i].preamble_rel8.rnti,
ind->rach_indication_body.preamble_list[i].preamble_rel8.preamble,
ind->rach_indication_body.preamble_list[i].preamble_rel8.timing_advance
);
}
if(ind->rach_indication_body.preamble_list[i].preamble_rel13.tl.tag == NFAPI_PREAMBLE_REL13_TAG) {
......@@ -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];
}
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);
//mac_rach_ind(p7_vnf->mac, ind);
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];
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);
eNB->UL_INFO.harq_ind = *ind;
eNB->UL_INFO.harq_ind.harq_indication_body.harq_pdu_list = eNB->harq_pdu_list;
......@@ -507,51 +462,41 @@ int phy_harq_indication(struct nfapi_vnf_p7_config* config, nfapi_harq_indicatio
}
pthread_mutex_unlock(&eNB->UL_INFO_mutex);
// vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
//mac_harq_ind(p7_vnf->mac, ind);
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];
pthread_mutex_lock(&eNB->UL_INFO_mutex);
eNB->UL_INFO.crc_ind = *ind;
nfapi_crc_indication_t *dest_ind = &eNB->UL_INFO.crc_ind;
nfapi_crc_indication_pdu_t *dest_pdu_list = eNB->crc_pdu_list;
*dest_ind = *ind;
dest_ind->crc_indication_body.crc_pdu_list = dest_pdu_list;
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++) {
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",
__FUNCTION__,
NFAPI_SFNSF2DEC(ind->sfn_sf), ind->crc_indication_body.number_of_crcs, eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs,
i,
ind->crc_indication_body.crc_pdu_list[i].rx_ue_information.rnti,
eNB->UL_INFO.crc_ind.crc_indication_body.crc_pdu_list[i].rx_ue_information.rnti);
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__,
NFAPI_SFNSF2DEC(ind->sfn_sf), ind->crc_indication_body.number_of_crcs, eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs,
i,
ind->crc_indication_body.crc_pdu_list[i].rx_ue_information.rnti,
eNB->UL_INFO.crc_ind.crc_indication_body.crc_pdu_list[i].rx_ue_information.rnti);
}
pthread_mutex_unlock(&eNB->UL_INFO_mutex);
// vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
//mac_crc_ind(p7_vnf->mac, ind);
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];
if (ind->rx_indication_body.number_of_pdus==0) {
......@@ -559,198 +504,170 @@ int phy_rx_indication(struct nfapi_vnf_p7_config* config, nfapi_rx_indication_t*
}
pthread_mutex_lock(&eNB->UL_INFO_mutex);
nfapi_rx_indication_t *dest_ind = &eNB->UL_INFO.rx_ind;
nfapi_rx_indication_pdu_t *dest_pdu_list = eNB->rx_pdu_list;
*dest_ind = *ind;
dest_ind->rx_indication_body.rx_pdu_list = dest_pdu_list;
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 *src_pdu = &ind->rx_indication_body.rx_pdu_list[i];
memcpy(dest_pdu, src_pdu, sizeof(*src_pdu));
// DJP - TODO FIXME - intentional memory leak
dest_pdu->data = malloc(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",
__FUNCTION__,
NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rx_indication_body.number_of_pdus, i,
dest_pdu->rx_ue_information.handle,
dest_pdu->rx_ue_information.rnti,
dest_pdu->rx_indication_rel8.length,
dest_pdu->rx_indication_rel8.offset,
dest_pdu->rx_indication_rel8.ul_cqi,
dest_pdu->rx_indication_rel8.timing_advance,
dest_pdu->data
);
__FUNCTION__,
NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rx_indication_body.number_of_pdus, i,
dest_pdu->rx_ue_information.handle,
dest_pdu->rx_ue_information.rnti,
dest_pdu->rx_indication_rel8.length,
dest_pdu->rx_indication_rel8.offset,
dest_pdu->rx_indication_rel8.ul_cqi,
dest_pdu->rx_indication_rel8.timing_advance,
dest_pdu->data
);
}
pthread_mutex_unlock(&eNB->UL_INFO_mutex);
// vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
//mac_rx_ind(p7_vnf->mac, ind);
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);
//mac_srs_ind(p7_vnf->mac, ind);
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];
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);
nfapi_sr_indication_t *dest_ind = &eNB->UL_INFO.sr_ind;
nfapi_sr_indication_pdu_t *dest_pdu_list = eNB->sr_pdu_list;
*dest_ind = *ind;
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);
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 *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);
memcpy(dest_pdu, src_pdu, sizeof(*src_pdu));
}
pthread_mutex_unlock(&eNB->UL_INFO_mutex);
// vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
//mac_sr_ind(p7_vnf->mac, ind);
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);
//mac_cqi_ind(p7_vnf->mac, ind);
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);
pthread_mutex_lock(&eNB->UL_INFO_mutex);
eNB->UL_INFO.cqi_ind = ind->cqi_indication_body;
pthread_mutex_unlock(&eNB->UL_INFO_mutex);
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);
//mac_lbt_dl_ind(p7_vnf->mac, ind);
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);
//mac_nb_harq_ind(p7_vnf->mac, ind);
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);
//mac_nrach_ind(p7_vnf->mac, ind);
return 1;
}
void* vnf_allocate(size_t size) {
void *vnf_allocate(size_t 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);
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_start(args, message);
nfapi_log("FILE>", "FUNC", 999, PHY, nfapitooai_level(nfapi_level), message, args);
va_end(args);
}
int phy_vendor_ext(struct nfapi_vnf_p7_config* config, nfapi_p7_message_header_t* msg) {
if(msg->message_id == P7_VENDOR_EXT_IND)
{
int phy_vendor_ext(struct nfapi_vnf_p7_config *config, nfapi_p7_message_header_t *msg) {
if(msg->message_id == P7_VENDOR_EXT_IND) {
//vendor_ext_p7_ind* ind = (vendor_ext_p7_ind*)msg;
//printf("[VNF] vendor_ext (error_code:%d)\n", ind->error_code);
}
else
{
} else {
printf("[VNF] unknown %02x\n", msg->message_id);
}
return 0;
}
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)
{
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) {
*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;
}
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);
}
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)ppReadPackedMessage;
(void)ve;
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_tl_t *tlv = (nfapi_tl_t *)ve;
nfapi_tl_t* tlv = (nfapi_tl_t*)ve;
switch(tlv->tag) {
case VENDOR_EXT_TLV_1_TAG:
{
//NFAPI_TRACE(NFAPI_TRACE_INFO, "Packing VENDOR_EXT_TLV_1\n");
vendor_ext_tlv_1* ve = (vendor_ext_tlv_1*)tlv;
if(!push32(ve->dummy, ppWritePackedMsg, end))
return 0;
return 1;
}
break;
case VENDOR_EXT_TLV_1_TAG: {
//NFAPI_TRACE(NFAPI_TRACE_INFO, "Packing VENDOR_EXT_TLV_1\n");
vendor_ext_tlv_1 *ve = (vendor_ext_tlv_1 *)tlv;
if(!push32(ve->dummy, ppWritePackedMsg, end))
return 0;
return 1;
}
break;
default:
return -1;
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__);
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))
return 0;
}
......@@ -758,54 +675,48 @@ int phy_unpack_p7_vendor_extension(nfapi_p7_message_header_t* header, uint8_t**
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__);
if(header->message_id == P7_VENDOR_EXT_REQ) {
//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) &&
push16(req->dummy2, ppWritePackedMsg, end)))
push16(req->dummy2, ppWritePackedMsg, end)))
return 0;
}
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__);
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);
return (!(push16(req->dummy1, ppWritePackedMsg, end) &&
push16(req->dummy2, ppWritePackedMsg, end)));
push16(req->dummy2, ppWritePackedMsg, end)));
}
return 0;
}
static pthread_t vnf_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__);
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);
return config;
}
void set_thread_priority(int priority);
void* vnf_p7_thread_start(void* ptr) {
void *vnf_p7_thread_start(void *ptr) {
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->sync_indication = &phy_sync_indication;
p7_vnf->config->subframe_indication = &phy_subframe_indication;
......@@ -821,117 +732,87 @@ void* vnf_p7_thread_start(void* ptr) {
p7_vnf->config->nrach_indication = &phy_nrach_indication;
p7_vnf->config->malloc = &vnf_allocate;
p7_vnf->config->free = &vnf_deallocate;
p7_vnf->config->trace = &vnf_trace;
p7_vnf->config->vendor_ext = &phy_vendor_ext;
p7_vnf->config->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.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.pack_vendor_extension_tlv = &phy_pack_vendor_extension_tlv;
p7_vnf->config->codec_config.allocate = &vnf_allocate;
p7_vnf->config->codec_config.deallocate = &vnf_deallocate;
p7_vnf->config->allocate_p7_vendor_ext = &phy_allocate_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__);
pthread_create(&vnf_p7_start_pthread, NULL, &vnf_p7_start_thread, p7_vnf->config);
return 0;
}
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);
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_p7_info *p7_vnf = vnf->p7_vnfs;
pnf_info *pnf = vnf->pnfs;
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);
if(p7_vnf->thread_started == 0) {
pthread_t vnf_p7_thread;
pthread_create(&vnf_p7_thread, NULL, &vnf_p7_thread_start, p7_vnf);
p7_vnf->thread_started = 1;
}
else
{
// P7 thread already running.
} else {
// P7 thread already running.
}
// start all the phys in the pnf.
printf("[VNF] Sending NFAPI_PARAM_REQUEST phy_id:%d\n", pnf->phys[0].id);
memset(&req, 0, sizeof(req));
req.header.message_id = NFAPI_PARAM_REQUEST;
req.header.phy_id = pnf->phys[0].id;
nfapi_vnf_param_req(config, p5_idx, &req);
return 0;
}
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);
vnf_info* vnf = (vnf_info*)(config->user_data);
vnf_info *vnf = (vnf_info *)(config->user_data);
vnf_p7_info *p7_vnf = vnf->p7_vnfs;
pnf_info *pnf = vnf->pnfs;
phy_info *phy = pnf->phys;
struct sockaddr_in pnf_p7_sockaddr;
nfapi_config_request_t *req = &RC.mac[0]->config[0];
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);
phy->remote_addr = inet_ntoa(pnf_p7_sockaddr.sin_addr);
// 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, p7_vnf->periodic_timing_period);
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);
req->header.message_id = NFAPI_CONFIG_REQUEST;
req->header.phy_id = phy->id;
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.value = p7_vnf->local_port;
req->num_tlv++;
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;
struct sockaddr_in vnf_p7_sockaddr;
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);
req->num_tlv++;
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.value = p7_vnf->timing_window;
printf("[VNF] Timing window:%u\n", p7_vnf->timing_window);
req->num_tlv++;
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.value = (p7_vnf->aperiodic_timing_enabled << 1) | (p7_vnf->periodic_timing_enabled);
req->num_tlv++;
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.value = p7_vnf->periodic_timing_period;
req->num_tlv++;
......@@ -943,142 +824,110 @@ 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.dummy = 2016;
req->vendor_extension = &ve2.tl;
nfapi_vnf_config_req(config, p5_idx, req);
printf("[VNF] Sent NFAPI_CONFIG_REQ num_tlv:%u\n",req->num_tlv);
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;
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");
oai_enb_init();
memset(&req, 0, sizeof(req));
req.header.message_id = NFAPI_START_REQUEST;
req.header.phy_id = resp->header.phy_id;
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);
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);
vnf_info* vnf = (vnf_info*)(config->user_data);
vnf_info *vnf = (vnf_info *)(config->user_data);
pnf_info *pnf = vnf->pnfs;
phy_info *phy = pnf->phys;
vnf_p7_info *p7_vnf = vnf->p7_vnfs;
nfapi_vnf_p7_add_pnf((p7_vnf->config), phy->remote_addr, phy->remote_port, phy->id);
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__);
switch(msg->message_id) {
case P5_VENDOR_EXT_RSP:
{
vendor_ext_p5_rsp* rsp = (vendor_ext_p5_rsp*)msg;
printf("[VNF] P5_VENDOR_EXT_RSP error_code:%d\n", rsp->error_code);
// send the start request
nfapi_pnf_start_request_t req;
memset(&req, 0, sizeof(req));
req.header.message_id = NFAPI_PNF_START_REQUEST;
nfapi_vnf_pnf_start_req(config, p5_idx, &req);
}
break;
case P5_VENDOR_EXT_RSP: {
vendor_ext_p5_rsp *rsp = (vendor_ext_p5_rsp *)msg;
printf("[VNF] P5_VENDOR_EXT_RSP error_code:%d\n", rsp->error_code);
// send the start request
nfapi_pnf_start_request_t req;
memset(&req, 0, sizeof(req));
req.header.message_id = NFAPI_PNF_START_REQUEST;
nfapi_vnf_pnf_start_req(config, p5_idx, &req);
}
break;
}
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__);
if(header->message_id == P5_VENDOR_EXT_RSP)
{
vendor_ext_p5_rsp* req = (vendor_ext_p5_rsp*)(header);
if(header->message_id == P5_VENDOR_EXT_RSP) {
vendor_ext_p5_rsp *req = (vendor_ext_p5_rsp *)(header);
return(!pull16(ppReadPackedMessage, &req->error_code, end));
}
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) {
*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;
}
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);
}
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__);
pthread_setname_np(pthread_self(), "VNF");
config = (nfapi_vnf_config_t*)ptr;
config = (nfapi_vnf_config_t *)ptr;
nfapi_vnf_start(config);
}
static vnf_info vnf;
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;
memset(&vnf, 0, sizeof(vnf));
memset(vnf.p7_vnfs, 0, sizeof(vnf.p7_vnfs));
vnf.p7_vnfs[0].timing_window = 32;
vnf.p7_vnfs[0].periodic_timing_enabled = 1;
vnf.p7_vnfs[0].aperiodic_timing_enabled = 0;
vnf.p7_vnfs[0].periodic_timing_period = 10;
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);
strcpy(vnf.p7_vnfs[0].local_addr, vnf_addr);
vnf.p7_vnfs[0].local_port = 50001;
vnf.p7_vnfs[0].mac = (mac_t*)malloc(sizeof(mac_t));
nfapi_vnf_config_t* config = nfapi_vnf_config_create();
vnf.p7_vnfs[0].mac = (mac_t *)malloc(sizeof(mac_t));
nfapi_vnf_config_t *config = nfapi_vnf_config_create();
config->malloc = malloc;
config->free = free;
config->trace = &vnf_trace;
config->vnf_p5_port = vnf_p5_port;
config->vnf_ipv4 = 1;
config->vnf_ipv6 = 0;
config->pnf_list = 0;
config->phy_list = 0;
config->pnf_connection_indication = &pnf_connection_indication_cb;
config->pnf_disconnect_indication = &pnf_disconnection_indication_cb;
config->pnf_param_resp = &pnf_param_resp_cb;
......@@ -1088,33 +937,26 @@ void configure_nfapi_vnf(char *vnf_addr, int vnf_p5_port)
config->config_resp = &config_resp_cb;
config->start_resp = &start_resp_cb;
config->vendor_ext = &vendor_ext_cb;
config->user_data = &vnf;
// 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.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.pack_p4_p5_vendor_extension = &vnf_pack_p4_p5_vendor_extension;
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->codec_config.allocate = &vnf_allocate;
config->codec_config.deallocate = &vnf_deallocate;
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__);
}
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;
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;
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_dci = 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)
if (retval!=0) {
LOG_E(PHY, "%s() Problem sending retval:%d\n", __FUNCTION__, 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;
tx_req->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!!
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);
int retval = nfapi_vnf_p7_tx_req(p7_config, tx_req);
if (retval!=0) {
LOG_E(PHY, "%s() Problem sending retval:%d\n", __FUNCTION__, retval);
} else {
tx_req->tx_request_body.number_of_pdus = 0;
}
return retval;
}
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;
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;
//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);
if (retval!=0) {
......@@ -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_dci = 0;
}
return retval;
}
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;
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;
//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);
int retval = nfapi_vnf_p7_ul_config_req(p7_config, ul_config_req);
if (retval!=0) {
......@@ -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.srs_present = 0;
}
return retval;
}
......@@ -34,11 +34,11 @@
#include "log_extern.h"
#include "assertions.h"
#if defined(ENABLE_ITTI)
# include "intertask_interface.h"
# if defined(ENABLE_USE_MME)
# include "s1ap_eNB.h"
# include "sctp_eNB_task.h"
# endif
#include "intertask_interface.h"
#if defined(ENABLE_USE_MME)
#include "s1ap_eNB.h"
#include "sctp_eNB_task.h"
#endif
#endif
#include "SystemInformationBlockType2.h"
......@@ -56,11 +56,10 @@
void RCconfig_NbIoTL1(void) {
paramdef_t NbIoT_L1_Params[] = L1PARAMS_DESC;
paramlist_def_t NbIoT_L1_ParamList = {NBIOT_L1LIST_CONFIG_STRING,NULL,0};
/* No component carrier for NbIoT, ignore number of CC */
// 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);
/* No component carrier for NbIoT, ignore number of CC */
// 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);
if (NbIoT_L1_ParamList.numelt > 0) {
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 *));
......@@ -68,219 +67,190 @@ void RCconfig_NbIoTL1(void) {
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) {
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]);
memset(RC.L1_NB_IoT[j],0,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]);
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) {
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.remote_addr = strdup(*(NbIoT_L1_ParamList.paramarray[j][L1_REMOTE_N_ADDRESS_IDX].strptr));
RC.L1_NB_IoT[j]->eth_params_n.my_portc = *(NbIoT_L1_ParamList.paramarray[j][L1_LOCAL_N_PORTC_IDX].iptr);
RC.L1_NB_IoT[j]->eth_params_n.remote_portc = *(NbIoT_L1_ParamList.paramarray[j][L1_REMOTE_N_PORTC_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.transp_preference = ETH_UDP_MODE;
} else { // other midhaul
}
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.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.my_portc = *(NbIoT_L1_ParamList.paramarray[j][L1_LOCAL_N_PORTC_IDX].iptr);
RC.L1_NB_IoT[j]->eth_params_n.remote_portc = *(NbIoT_L1_ParamList.paramarray[j][L1_REMOTE_N_PORTC_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.transp_preference = ETH_UDP_MODE;
}
else { // other midhaul
}
}// j=0..num_inst
printf("Initializing northbound interface for NB-IoT L1\n");
l1_north_init_NB_IoT();
} else {
LOG_I(PHY,"No " NBIOT_L1LIST_CONFIG_STRING " configuration found");
LOG_I(PHY,"No " NBIOT_L1LIST_CONFIG_STRING " configuration found");
}
}
void RCconfig_NbIoTmacrlc(void) {
paramdef_t NbIoT_MacRLC_Params[] = MACRLCPARAMS_DESC;
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;
config_getlist( &NbIoT_MacRLC_ParamList,NbIoT_MacRLC_Params,sizeof(NbIoT_MacRLC_Params)/sizeof(paramdef_t), NULL);
/* 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);
if ( NbIoT_MacRLC_ParamList.numelt > 0) {
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) {
// 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) {
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.remote_addr = strdup(*(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_N_ADDRESS_IDX].strptr));
RC.nb_iot_mac[j]->eth_params_n.my_portc = *(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_PORTC_IDX].iptr);
RC.nb_iot_mac[j]->eth_params_n.remote_portc = *(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_N_PORTC_IDX].iptr);
RC.nb_iot_mac[j]->eth_params_n.my_portd = *(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_PORTD_IDX].iptr);
RC.nb_iot_mac[j]->eth_params_n.remote_portd = *(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_N_PORTD_IDX].iptr);;
RC.nb_iot_mac[j]->eth_params_n.transp_preference = ETH_UDP_MODE;
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.remote_addr = strdup(*(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_N_ADDRESS_IDX].strptr));
RC.nb_iot_mac[j]->eth_params_n.my_portc = *(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_PORTC_IDX].iptr);
RC.nb_iot_mac[j]->eth_params_n.remote_portc = *(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_N_PORTC_IDX].iptr);
RC.nb_iot_mac[j]->eth_params_n.my_portd = *(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_PORTD_IDX].iptr);
RC.nb_iot_mac[j]->eth_params_n.remote_portd = *(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_N_PORTD_IDX].iptr);;
RC.nb_iot_mac[j]->eth_params_n.transp_preference = ETH_UDP_MODE;
} else { // other midhaul
AssertFatal(1==0,"MACRLC %d: %s unknown northbound midhaul\n",j, *(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_N_PREFERENCE_IDX].strptr));
}
AssertFatal(1==0,"MACRLC %d: %s unknown northbound midhaul\n",j, *(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_N_PREFERENCE_IDX].strptr));
}
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) {
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.remote_addr = strdup(*(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_S_ADDRESS_IDX].strptr));
RC.nb_iot_mac[j]->eth_params_s.my_portc = *(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_S_PORTC_IDX].iptr);
RC.nb_iot_mac[j]->eth_params_s.remote_portc = *(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_S_PORTC_IDX].iptr);
RC.nb_iot_mac[j]->eth_params_s.my_portd = *(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_S_PORTD_IDX].iptr);
RC.nb_iot_mac[j]->eth_params_s.remote_portd = *(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_S_PORTD_IDX].iptr);
RC.nb_iot_mac[j]->eth_params_s.transp_preference = ETH_UDP_MODE;
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.remote_addr = strdup(*(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_S_ADDRESS_IDX].strptr));
RC.nb_iot_mac[j]->eth_params_s.my_portc = *(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_S_PORTC_IDX].iptr);
RC.nb_iot_mac[j]->eth_params_s.remote_portc = *(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_S_PORTC_IDX].iptr);
RC.nb_iot_mac[j]->eth_params_s.my_portd = *(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_S_PORTD_IDX].iptr);
RC.nb_iot_mac[j]->eth_params_s.remote_portd = *(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_S_PORTD_IDX].iptr);
RC.nb_iot_mac[j]->eth_params_s.transp_preference = ETH_UDP_MODE;
} else { // other midhaul
AssertFatal(1==0,"MACRLC %d: %s unknown southbound midhaul\n",j,*(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_S_PREFERENCE_IDX].strptr));
}
AssertFatal(1==0,"MACRLC %d: %s unknown southbound midhaul\n",j,*(NbIoT_MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_S_PREFERENCE_IDX].strptr));
}
}// j=0..num_inst */
} else {// MacRLC_ParamList.numelt > 0
AssertFatal (0,
"No " NBIOT_MACRLCLIST_CONFIG_STRING " configuration found");
AssertFatal (0,
"No " NBIOT_MACRLCLIST_CONFIG_STRING " configuration found");
}
}
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];
checkedparam_t NBIoTCheckParams[] = NBIOT_RRCPARAMS_CHECK_DESC;
checkedparam_t NBIoTCheckParams[] = NBIOT_RRCPARAMS_CHECK_DESC_0_14;
checkedparam_t NBIoTCheckParamsB[] = NBIOT_RRCPARAMS_CHECK_DESC_15_end;
paramdef_t NBIoTParams[] = NBIOTRRCPARAMS_DESC;
paramdef_t NBIoTPrachParams[] = NBIOTRRC_NPRACH_PARAMS_DESC;
checkedparam_t NBIoTPrachCheckParams[] = NBIOT_RRCLIST_NPRACHPARAMSCHECK_DESC;
paramdef_t NBIoTRRCRefParams[] = NBIOTRRCPARAMS_RRCREF_DESC;
paramdef_t NBIoTLteCCParams[] = NBIOT_LTECCPARAMS_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++ ) {
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++ ) {
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_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);
NBIoTParams[NBIOT_RACH_PREAMBLEINITIALRECEIVEDTARGETPOWER_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).rach_preambleInitialReceivedTargetPower_NB);
NBIoTParams[NBIOT_RACH_PREAMBLETRANSMAX_CE_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax_CE_NB);
NBIoTParams[NBIOT_BCCH_MODIFICATIONPERIODCOEFF_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).bcch_modificationPeriodCoeff_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_RSRP_RANGE_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).nprach_rsrp_range);
NBIoTParams[NBIOT_RACH_PREAMBLETRANSMAX_CE_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax_CE_NB);
NBIoTParams[NBIOT_BCCH_MODIFICATIONPERIODCOEFF_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).bcch_modificationPeriodCoeff_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_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_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_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_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_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_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_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_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_UE_TIMERSANDCONSTANTS_T300_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t300_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_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_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_T310_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t310_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_T310_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t310_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_N311_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_n311_NB);
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).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).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).npusch_alpha = config_get_processedint( &(NBIoTParams[NBIOT_NPUSCH_ALPHA_IDX] ) );
for (int i=0; i<MAX_NUM_NBIOT_CELEVELS; i++) {
char *tmpptr=NULL;
NBIoTPrachParams[NBIOT_NPRACH_PERIODICITY_IDX ].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).nprach_Periodicity[i]);
NBIoTPrachParams[NBIOT_NPRACH_STARTTIME_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).nprach_StartTime[i]);
NBIoTPrachParams[NBIOT_NPRACH_SUBCARRIEROFFSET_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).nprach_SubcarrierOffset[i]);
NBIoTPrachParams[NBIOT_NPRACH_NUMSUBCARRIERS_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).nprach_NumSubcarriers[i]);
NBIoTPrachParams[NBIOT_NUMREPETITIONSPERPREAMBLEATTEMPT_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).numRepetitionsPerPreambleAttempt_NB[i]);
NBIoTParams[NBIOT_NPDCCH_NUMREPETITIONS_RA_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).npdcch_NumRepetitions_RA[i]);
NBIoTParams[NBIOT_NPDCCH_STARTSF_CSS_RA_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).npdcch_StartSF_CSS_RA[i]);
NBIoTParams[NBIOT_NPDCCH_OFFSET_RA_IDX].strptr = &tmpptr;
sprintf(instprefix, "%s.[%i].%s.[%i]",NBIOT_RRCLIST_CONFIG_STRING, nbiotrrc_id,NBIOT_RRCLIST_NPRACHPARAMS_CONFIG_STRING,i);
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]) );
char *tmpptr=NULL;
NBIoTPrachParams[NBIOT_NPRACH_PERIODICITY_IDX ].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).nprach_Periodicity[i]);
NBIoTPrachParams[NBIOT_NPRACH_STARTTIME_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).nprach_StartTime[i]);
NBIoTPrachParams[NBIOT_NPRACH_SUBCARRIEROFFSET_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).nprach_SubcarrierOffset[i]);
NBIoTPrachParams[NBIOT_NPRACH_NUMSUBCARRIERS_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).nprach_NumSubcarriers[i]);
NBIoTPrachParams[NBIOT_NUMREPETITIONSPERPREAMBLEATTEMPT_NB_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).numRepetitionsPerPreambleAttempt_NB[i]);
NBIoTParams[NBIOT_NPDCCH_NUMREPETITIONS_RA_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).npdcch_NumRepetitions_RA[i]);
NBIoTParams[NBIOT_NPDCCH_STARTSF_CSS_RA_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).npdcch_StartSF_CSS_RA[i]);
NBIoTParams[NBIOT_NPDCCH_OFFSET_RA_IDX].strptr = &tmpptr;
sprintf(instprefix, "%s.[%i].%s.[%i]",NBIOT_RRCLIST_CONFIG_STRING, nbiotrrc_id,NBIOT_RRCLIST_NPRACHPARAMS_CONFIG_STRING,i);
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]) );
}
/* 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 );
config_get( NBIoTRRCRefParams,sizeof(NBIoTRRCRefParams)/sizeof(paramdef_t),instprefix);
/* read SIB1 parameters in the LTE RRC and CC sections */
/* 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 );
config_get( NBIoTRRCRefParams,sizeof(NBIoTRRCRefParams)/sizeof(paramdef_t),instprefix);
/* read SIB1 parameters in the LTE RRC and CC sections */
sprintf(instprefix, ENB_CONFIG_STRING_ENB_LIST ".[%i]." ENB_CONFIG_STRING_COMPONENT_CARRIERS ".[%i]",
*(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_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_DOWNLINK_FREQUENCY_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).downlink_frequency);
*(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_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_DOWNLINK_FREQUENCY_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).downlink_frequency);
NBIoTLteCCParams[LTECCPARAMS_UPLINK_FREQUENCY_OFFSET_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).uplink_frequency_offset);
NBIoTLteCCParams[LTECCPARAMS_NID_CELL_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).Nid_cell);
NBIoTLteCCParams[LTECCPARAMS_N_RB_DL_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).N_RB_DL);
NBIoTLteCCParams[LTECCPARAMS_NID_CELL_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).Nid_cell);
NBIoTLteCCParams[LTECCPARAMS_N_RB_DL_IDX].uptr = (uint32_t *)&(NBIOTRRC_CONFIGURATION_REQ (msg_p).N_RB_DL);
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);
NBIOTRRC_CONFIGURATION_REQ (msg_p).frame_type = config_get_processedint( &(NBIoTLteCCParams[LTECCPARAMS_FRAME_TYPE_IDX]) );
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).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]) );
return 0;
return 0;
}
void RCConfig_NbIoT(RAN_CONTEXT_t *RC) {
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_ParamList = {NBIOT_RRCLIST_CONFIG_STRING,NULL,0};
config_getlist( &NbIoT_ParamList,NULL,0,NULL);
RC->nb_nb_iot_rrc_inst = NbIoT_ParamList.numelt;
config_getlist( &NbIoT_MACRLCParamList,NULL,0, NULL);
RC->nb_nb_iot_macrlc_inst = NbIoT_MACRLCParamList.numelt;
// Get num L1 instances
config_getlist( &NbIoT_L1ParamList,NULL,0, NULL);
RC->nb_nb_iot_L1_inst = NbIoT_L1ParamList.numelt;
config_getlist( &NbIoT_MACRLCParamList,NULL,0, NULL);
RC->nb_nb_iot_macrlc_inst = NbIoT_MACRLCParamList.numelt;
// Get num L1 instances
config_getlist( &NbIoT_L1ParamList,NULL,0, NULL);
RC->nb_nb_iot_L1_inst = NbIoT_L1ParamList.numelt;
}
......@@ -134,42 +134,37 @@ static const eutra_bandentry_t eutra_bandtable[] = {
{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;
int bw_by_100 = bw / 100;
int i;
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,
"Band %d, bw %u : DL carrier frequency %u Hz < %u\n",
eutra_bandP, bw, dl_CarrierFreq,
eutra_bandtable[i].dl_min);
"Band %d, bw %u : DL carrier frequency %u Hz < %u\n",
eutra_bandP, bw, dl_CarrierFreq,
eutra_bandtable[i].dl_min);
AssertFatal(dl_CarrierFreq_by_100k <=
(eutra_bandtable[i].dl_max - bw_by_100),
"Band %d, bw %u: DL carrier frequency %u Hz > %d\n",
eutra_bandP, bw, dl_CarrierFreq,
eutra_bandtable[i].dl_max - bw_by_100);
(eutra_bandtable[i].dl_max - bw_by_100),
"Band %d, bw %u: DL carrier frequency %u Hz > %d\n",
eutra_bandP, bw, dl_CarrierFreq,
eutra_bandtable[i].dl_max - bw_by_100);
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;
int bw_by_100 = bw / 100;
int i;
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,
"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
"Band %d, bw %u : DL carrier frequency %lld Hz > %d\n",
eutra_bandP, bw, dl_CarrierFreq,
eutra_bandtable[i].dl_max - bw_by_100);
return (dl_CarrierFreq_by_100k - eutra_bandtable[i].dl_min +
(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;
int bw_by_100 = bw / 100;
int i;
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,
"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
"Band %d, bw %u : UL carrier frequency %lld Hz > %d\n",
eutra_bandP, bw, ul_CarrierFreq,
eutra_bandtable[i].ul_max - bw_by_100);
return (ul_CarrierFreq_by_100k - eutra_bandtable[i].ul_min +
((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;
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 +
(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;
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);
}
......
......@@ -51,35 +51,35 @@
#include "msc.h"
#include "targets/COMMON/openairinterface5g_limits.h"
#if defined(ENABLE_SECURITY)
# include "UTIL/OSA/osa_defs.h"
#include "UTIL/OSA/osa_defs.h"
#endif
#if defined(ENABLE_ITTI)
# include "intertask_interface.h"
#include "intertask_interface.h"
#endif
#if defined(LINK_ENB_PDCP_TO_GTPV1U)
# include "gtpv1u_eNB_task.h"
# include "gtpv1u.h"
#include "gtpv1u_eNB_task.h"
#include "gtpv1u.h"
#endif
extern int otg_enabled;
#if defined(ENABLE_USE_MME)
extern uint8_t nfapi_mode;
extern uint8_t nfapi_mode;
#endif
#include "common/ran_context.h"
extern RAN_CONTEXT_t RC;
hash_table_t *pdcp_coll_p = NULL;
#ifdef MBMS_MULTICAST_OUT
# include <sys/types.h>
# include <sys/socket.h>
# include <netinet/in.h>
# include <netinet/ip.h>
# include <netinet/udp.h>
# include <unistd.h>
static int mbms_socket = -1;
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/udp.h>
#include <unistd.h>
static int mbms_socket = -1;
#endif
//-----------------------------------------------------------------------------
......@@ -91,7 +91,7 @@ static int mbms_socket = -1;
* code at targets/TEST/PDCP/test_pdcp.c:test_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 rb_id_t rb_idP,
const mui_t muiP,
......@@ -100,13 +100,12 @@ boolean_t pdcp_data_req(
unsigned char *const sdu_buffer_pP,
const pdcp_transmission_mode_t modeP
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
,const uint32_t * const sourceL2Id
,const uint32_t * const destinationL2Id
,const uint32_t *const sourceL2Id
,const uint32_t *const destinationL2Id
#endif
)
//-----------------------------------------------------------------------------
{
pdcp_t *pdcp_p = NULL;
uint8_t i = 0;
uint8_t pdcp_header_len = 0;
......@@ -116,17 +115,17 @@ boolean_t pdcp_data_req(
mem_block_t *pdcp_pdu_p = NULL;
rlc_op_status_t rlc_status;
boolean_t ret = TRUE;
hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE;
hashtable_rc_t h_rc;
uint8_t rb_offset= (srb_flagP == 0) ? DTCH -1 : 0;
uint16_t pdcp_uid=0;
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_REQ,VCD_FUNCTION_IN);
CHECK_CTXT_ARGS(ctxt_pP);
#if T_TRACER
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));
#endif
if (sdu_buffer_sizeP == 0) {
......@@ -138,8 +137,8 @@ boolean_t pdcp_data_req(
* XXX MAX_IP_PACKET_SIZE is 4096, shouldn't this be MAX SDU size, which is 8188 bytes?
*/
AssertFatal(sdu_buffer_sizeP<= MAX_IP_PACKET_SIZE,"Requested SDU size (%d) is bigger than that can be handled by PDCP (%u)!\n",
sdu_buffer_sizeP, MAX_IP_PACKET_SIZE);
sdu_buffer_sizeP, MAX_IP_PACKET_SIZE);
if (modeP == PDCP_TRANSMISSION_MODE_TRANSPARENT) {
AssertError (rb_idP < NB_RB_MBMS_MAX, return FALSE, "RB id is too high (%u/%d) %u %u!\n", rb_idP, NB_RB_MBMS_MAX, ctxt_pP->module_id, ctxt_pP->rnti);
} else {
......@@ -151,21 +150,21 @@ 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);
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 (modeP != PDCP_TRANSMISSION_MODE_TRANSPARENT) {
LOG_W(PDCP, PROTOCOL_CTXT_FMT" Instance is not configured for rb_id %d Ignoring SDU...\n",
PROTOCOL_CTXT_ARGS(ctxt_pP),
rb_idP);
PROTOCOL_CTXT_ARGS(ctxt_pP),
rb_idP);
ctxt_pP->configured=FALSE;
return FALSE;
}
}else{
} else {
// instance for a given RB is configured
ctxt_pP->configured=TRUE;
}
if (ctxt_pP->enb_flag == ENB_FLAG_YES) {
start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].data_req);
} else {
......@@ -182,7 +181,7 @@ boolean_t pdcp_data_req(
memcpy(&pdcp_pdu_p->data[0], sdu_buffer_pP, sdu_buffer_sizeP);
#if defined(DEBUG_PDCP_PAYLOAD)
rlc_util_print_hex_octets(PDCP,
(unsigned char*)&pdcp_pdu_p->data[0],
(unsigned char *)&pdcp_pdu_p->data[0],
sdu_buffer_sizeP);
#endif
LOG_D(PDCP, "Before rlc_data_req 1, srb_flagP: %d, rb_idP: %d \n", srb_flagP, rb_idP);
......@@ -190,7 +189,7 @@ boolean_t pdcp_data_req(
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
,NULL, NULL
#endif
);
);
} else {
rlc_status = RLC_OP_STATUS_OUT_OF_RESSOURCES;
LOG_W(PDCP,PROTOCOL_CTXT_FMT" PDCP_DATA_REQ SDU DROPPED, OUT OF MEMORY \n",
......@@ -212,13 +211,11 @@ boolean_t pdcp_data_req(
}
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",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p),
pdcp_pdu_size,
pdcp_header_len,
pdcp_tailer_len);
/*
* Allocate a new block for the new PDU (i.e. PDU header and SDU payload)
*/
......@@ -230,7 +227,6 @@ boolean_t pdcp_data_req(
*
* Place User Plane PDCP Data PDU header first
*/
if (srb_flagP) { // this Control plane PDCP Data PDU
pdcp_control_plane_data_pdu_header pdu_header;
pdu_header.sn = pdcp_get_next_tx_seq_number(pdcp_p);
......@@ -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(&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",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p));
......@@ -257,12 +253,11 @@ boolean_t pdcp_data_req(
pdu_header.sn = pdcp_get_next_tx_seq_number(pdcp_p);
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",
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);
} else {
stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].data_req);
......@@ -281,7 +276,6 @@ boolean_t pdcp_data_req(
"There must be a problem with PDCP initialization, ignoring this PDU...\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p),
current_sn);
free_mem_block(pdcp_pdu_p, __func__);
if (ctxt_pP->enb_flag == ENB_FLAG_YES) {
......@@ -295,7 +289,6 @@ boolean_t pdcp_data_req(
}
LOG_D(PDCP, "Sequence number %d is assigned to current PDU\n", current_sn);
/* Then append data... */
memcpy(&pdcp_pdu_p->data[pdcp_header_len], sdu_buffer_pP, sdu_buffer_sizeP);
......@@ -311,7 +304,6 @@ boolean_t pdcp_data_req(
if ((pdcp_p->security_activated != 0) &&
(((pdcp_p->cipheringAlgorithm) != 0) ||
((pdcp_p->integrityProtAlgorithm) != 0))) {
if (ctxt_pP->enb_flag == ENB_FLAG_YES) {
start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].apply_security);
} else {
......@@ -335,7 +327,6 @@ boolean_t pdcp_data_req(
}
#endif
/* 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",
pdcp_pdu_size);
......@@ -366,45 +357,42 @@ boolean_t pdcp_data_req(
* Ask sublayer to transmit data and check return value
* to see if RLC succeeded
*/
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);
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
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
,sourceL2Id
,destinationL2Id
,sourceL2Id
,destinationL2Id
#endif
);
}
switch (rlc_status) {
case RLC_OP_STATUS_OK:
LOG_D(PDCP, "Data sending request over RLC succeeded!\n");
ret=TRUE;
break;
case RLC_OP_STATUS_BAD_PARAMETER:
LOG_W(PDCP, "Data sending request over RLC failed with 'Bad Parameter' reason!\n");
ret= FALSE;
break;
case RLC_OP_STATUS_INTERNAL_ERROR:
LOG_W(PDCP, "Data sending request over RLC failed with 'Internal Error' reason!\n");
ret= FALSE;
break;
case RLC_OP_STATUS_OUT_OF_RESSOURCES:
LOG_W(PDCP, "Data sending request over RLC failed with 'Out of Resources' reason!\n");
ret= FALSE;
break;
default:
LOG_W(PDCP, "RLC returned an unknown status code after PDCP placed the order to send some data (Status Code:%d)\n", rlc_status);
ret= FALSE;
break;
case RLC_OP_STATUS_OK:
LOG_D(PDCP, "Data sending request over RLC succeeded!\n");
ret=TRUE;
break;
case RLC_OP_STATUS_BAD_PARAMETER:
LOG_W(PDCP, "Data sending request over RLC failed with 'Bad Parameter' reason!\n");
ret= FALSE;
break;
case RLC_OP_STATUS_INTERNAL_ERROR:
LOG_W(PDCP, "Data sending request over RLC failed with 'Internal Error' reason!\n");
ret= FALSE;
break;
case RLC_OP_STATUS_OUT_OF_RESSOURCES:
LOG_W(PDCP, "Data sending request over RLC failed with 'Out of Resources' reason!\n");
ret= FALSE;
break;
default:
LOG_W(PDCP, "RLC returned an unknown status code after PDCP placed the order to send some data (Status Code:%d)\n", rlc_status);
ret= FALSE;
break;
}
if (ctxt_pP->enb_flag == ENB_FLAG_YES) {
......@@ -418,7 +406,7 @@ boolean_t pdcp_data_req(
* 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 )
break;
}
......@@ -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_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_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;
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_REQ,VCD_FUNCTION_OUT);
return ret;
}
//-----------------------------------------------------------------------------
boolean_t
pdcp_data_ind(
const protocol_ctxt_t* const ctxt_pP,
const protocol_ctxt_t *const ctxt_pP,
const srb_flag_t srb_flagP,
const MBMS_flag_t MBMS_flagP,
const rb_id_t rb_idP,
const sdu_size_t sdu_buffer_sizeP,
mem_block_t* const sdu_buffer_pP
mem_block_t *const sdu_buffer_pP
)
//-----------------------------------------------------------------------------
{
......@@ -464,22 +449,20 @@ pdcp_data_ind(
hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE;
hashtable_rc_t h_rc;
uint8_t rb_offset= (srb_flagP == 0) ? DTCH -1 :0;
uint16_t pdcp_uid=0;
uint16_t pdcp_uid=0;
uint8_t oo_flag=0;
#if defined(LINK_ENB_PDCP_TO_GTPV1U)
MessageDef *message_p = NULL;
uint8_t *gtpu_buffer_p = NULL;
#endif
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,
"[MSG] PDCP UL %s PDU on rb_id %d\n", (srb_flagP)? "CONTROL" : "DATA", rb_idP);
#if T_TRACER
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));
#endif
if (MBMS_flagP) {
......@@ -498,7 +481,6 @@ pdcp_data_ind(
rb_idP,
sdu_buffer_sizeP,
ctxt_pP->enb_flag);
} else {
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",
......@@ -508,7 +490,6 @@ pdcp_data_ind(
sdu_buffer_sizeP,
ctxt_pP->enb_flag);
}
} else {
rb_id = rb_idP % LTE_maxDRB;
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(
ctxt_pP->module_id,
ctxt_pP->rnti);
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) {
LOG_W(PDCP,
......@@ -557,16 +538,16 @@ pdcp_data_ind(
if (srb_flagP) { //SRB1/2
pdcp_header_len = PDCP_CONTROL_PLANE_DATA_PDU_SN_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
pdcp_tailer_len = 0;
if (pdcp_p->seq_num_size == PDCP_SN_7BIT) {
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) {
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 {
//sequence_number = 4095;
LOG_E(PDCP,
......@@ -648,19 +629,18 @@ pdcp_data_ind(
#endif
//rrc_lite_data_ind(module_id, //Modified MW - L2 Interface
MSC_LOG_TX_MESSAGE(
(ctxt_pP->enb_flag == ENB_FLAG_NO)? MSC_PDCP_UE:MSC_PDCP_ENB,
MSC_LOG_TX_MESSAGE(
(ctxt_pP->enb_flag == ENB_FLAG_NO)? MSC_PDCP_UE:MSC_PDCP_ENB,
(ctxt_pP->enb_flag == ENB_FLAG_NO)? MSC_RRC_UE:MSC_RRC_ENB,
NULL,0,
PROTOCOL_PDCP_CTXT_FMT" DATA-IND len %u",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p),
sdu_buffer_sizeP - pdcp_header_len - pdcp_tailer_len);
rrc_data_ind(ctxt_pP,
rb_id,
sdu_buffer_sizeP - pdcp_header_len - pdcp_tailer_len,
(uint8_t*)&sdu_buffer_pP->data[pdcp_header_len]);
free_mem_block(sdu_buffer_pP, __func__);
rrc_data_ind(ctxt_pP,
rb_id,
sdu_buffer_sizeP - pdcp_header_len - pdcp_tailer_len,
(uint8_t *)&sdu_buffer_pP->data[pdcp_header_len]);
free_mem_block(sdu_buffer_pP, __func__);
// free_mem_block(new_sdu, __func__);
if (ctxt_pP->enb_flag) {
......@@ -701,7 +681,6 @@ pdcp_data_ind(
} else {
stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].validate_security);
}
}
#endif
......@@ -724,7 +703,6 @@ pdcp_data_ind(
}
// XXX Decompression would be done at this point
/*
* After checking incoming sequence number PDCP header
* has to be stripped off so here we copy SDU buffer starting
......@@ -735,13 +713,13 @@ pdcp_data_ind(
if ((TRUE == ctxt_pP->enb_flag) && (FALSE == srb_flagP)) {
MSC_LOG_TX_MESSAGE(
MSC_PDCP_ENB,
MSC_GTPU_ENB,
NULL,0,
"0 GTPV1U_ENB_TUNNEL_DATA_REQ ue %x rab %u len %u",
ctxt_pP->rnti,
rb_id + 4,
sdu_buffer_sizeP - payload_offset);
MSC_PDCP_ENB,
MSC_GTPU_ENB,
NULL,0,
"0 GTPV1U_ENB_TUNNEL_DATA_REQ ue %x rab %u len %u",
ctxt_pP->rnti,
rb_id + 4,
sdu_buffer_sizeP - payload_offset);
//LOG_T(PDCP,"Sending to GTPV1U %d bytes\n", sdu_buffer_sizeP - payload_offset);
gtpu_buffer_p = itti_malloc(TASK_PDCP_ENB, TASK_GTPV1_U,
sdu_buffer_sizeP - payload_offset + GTPU_HEADER_OVERHEAD_MAX);
......@@ -755,26 +733,25 @@ pdcp_data_ind(
GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rnti = ctxt_pP->rnti;
GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rab_id = rb_id + 4;
itti_send_msg_to_task(TASK_GTPV1_U, INSTANCE_DEFAULT, message_p);
packet_forwarded = TRUE;
packet_forwarded = TRUE;
}
#else
packet_forwarded = FALSE;
#endif
#ifdef MBMS_MULTICAST_OUT
if ((MBMS_flagP != 0) && (mbms_socket != -1)) {
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 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 sockaddr_in dest_addr;
dest_addr.sin_family = AF_INET;
dest_addr.sin_port = udp_header->dest;
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;
}
#endif
if (FALSE == packet_forwarded) {
......@@ -797,84 +774,79 @@ pdcp_data_ind(
if (ctxt_pP->enb_flag == ENB_FLAG_NO) {
((pdcp_data_ind_header_t *) new_sdu_p->data)->rb_id = rb_id;
#if defined(ENABLE_USE_MME)
/* for the UE compiled in S1 mode, we need 1 here
* for the UE compiled in noS1 mode, we need 0
* TODO: be sure of this
*/
if (nfapi_mode == 3) {
#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
((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
} else {
((pdcp_data_ind_header_t*) new_sdu_p->data)->inst = 1;
((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = 1;
}
#endif
} 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)->inst = ctxt_pP->module_id;
((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;
}
// 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
//((pdcp_data_ind_header_t*) new_sdu_p->data)->inst = ctxt_pP->module_id;
#ifdef DEBUG_PDCP_FIFO_FLUSH_SDU
static uint32_t pdcp_inst = 0;
((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);
((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);
#endif
//((pdcp_data_ind_header_t*) new_sdu_p->data)->inst = 1; //pdcp_inst++;
memcpy(&new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], \
&sdu_buffer_pP->data[payload_offset], \
sdu_buffer_sizeP - payload_offset);
list_add_tail_eurecom (new_sdu_p, sdu_list_p);
}
/* Print octets of incoming data in hexadecimal form */
LOG_D(PDCP, "Following content has been received from RLC (%d,%d)(PDCP header has already been removed):\n",
sdu_buffer_sizeP - payload_offset + (int)sizeof(pdcp_data_ind_header_t),
sdu_buffer_sizeP - payload_offset);
//util_print_hex_octets(PDCP, &new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], sdu_buffer_sizeP - payload_offset);
//util_flush_hex_octets(PDCP, &new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], sdu_buffer_sizeP - payload_offset);
/*
* Update PDCP statistics
* XXX Following two actions are identical, is there a merge error?
*/
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 ){
break;
/* Print octets of incoming data in hexadecimal form */
LOG_D(PDCP, "Following content has been received from RLC (%d,%d)(PDCP header has already been removed):\n",
sdu_buffer_sizeP - payload_offset + (int)sizeof(pdcp_data_ind_header_t),
sdu_buffer_sizeP - payload_offset);
//util_print_hex_octets(PDCP, &new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], sdu_buffer_sizeP - payload_offset);
//util_flush_hex_octets(PDCP, &new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], sdu_buffer_sizeP - payload_offset);
/*
* Update PDCP statistics
* XXX Following two actions are identical, is there a merge error?
*/
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 ) {
break;
}
}
}
Pdcp_stats_rx[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_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;
if (oo_flag == 1 )
Pdcp_stats_rx_outoforder[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_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=pdcp_enb[ctxt_pP->module_id].sfn;
Pdcp_stats_rx[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_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;
if (oo_flag == 1 )
Pdcp_stats_rx_outoforder[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_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)
else {
AssertFatal(0, PROTOCOL_PDCP_CTXT_FMT" PDCP_DATA_IND SDU DROPPED, OUT OF MEMORY \n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p));
}
#endif
#endif
}
free_mem_block(sdu_buffer_pP, __func__);
......@@ -889,63 +861,62 @@ pdcp_data_ind(
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;
uint8_t rb_id = 0;
// 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 (pdcp_uid=0; pdcp_uid< MAX_MOBILES_PER_ENB;pdcp_uid++){
// 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 (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);
// tx stats
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){
// 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_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];
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]);
}else {
Pdcp_stats_tx_aiat_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0;
}
// reset the tmp vars
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_aiat_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0;
pdcp_enb[ctxt_pP->module_id].sfn % Pdcp_stats_tx_window_ms[ctxt_pP->module_id][pdcp_uid] == 0) {
// 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_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];
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]);
} else {
Pdcp_stats_tx_aiat_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0;
}
// reset the tmp vars
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_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 &&
pdcp_enb[ctxt_pP->module_id].sfn % Pdcp_stats_rx_window_ms[ctxt_pP->module_id][pdcp_uid] == 0){
// 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_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];
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]);
} else {
Pdcp_stats_rx_aiat_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0;
}
// reset the tmp vars
Pdcp_stats_rx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0;
Pdcp_stats_rx_bytes_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;
}
pdcp_enb[ctxt_pP->module_id].sfn % Pdcp_stats_rx_window_ms[ctxt_pP->module_id][pdcp_uid] == 0) {
// 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_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];
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]);
} else {
Pdcp_stats_rx_aiat_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0;
}
// reset the tmp vars
Pdcp_stats_rx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0;
Pdcp_stats_rx_bytes_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
pdcp_run (
const protocol_ctxt_t* const ctxt_pP
const protocol_ctxt_t *const ctxt_pP
)
//-----------------------------------------------------------------------------
{
if (ctxt_pP->enb_flag) {
start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].pdcp_run);
} else {
......@@ -953,12 +924,10 @@ pdcp_run (
}
pdcp_enb[ctxt_pP->module_id].sfn++; // range: 0 to 18,446,744,073,709,551,615
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_update_stats(ctxt_pP);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_RUN, VCD_FUNCTION_IN);
#if defined(ENABLE_ITTI)
MessageDef *msg_p;
int result;
......@@ -969,66 +938,66 @@ pdcp_run (
itti_poll_msg (ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, &msg_p);
if (msg_p != NULL) {
switch (ITTI_MSG_ID(msg_p)) {
case RRC_DCCH_DATA_REQ:
PROTOCOL_CTXT_SET_BY_MODULE_ID(
&ctxt,
RRC_DCCH_DATA_REQ (msg_p).module_id,
RRC_DCCH_DATA_REQ (msg_p).enb_flag,
RRC_DCCH_DATA_REQ (msg_p).rnti,
RRC_DCCH_DATA_REQ (msg_p).frame,
0,
RRC_DCCH_DATA_REQ (msg_p).eNB_index);
LOG_D(PDCP, PROTOCOL_CTXT_FMT"Received %s from %s: instance %d, rb_id %d, muiP %d, confirmP %d, mode %d\n",
PROTOCOL_CTXT_ARGS(&ctxt),
ITTI_MSG_NAME (msg_p),
ITTI_MSG_ORIGIN_NAME(msg_p),
ITTI_MSG_INSTANCE (msg_p),
RRC_DCCH_DATA_REQ (msg_p).rb_id,
RRC_DCCH_DATA_REQ (msg_p).muip,
RRC_DCCH_DATA_REQ (msg_p).confirmp,
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);
result = pdcp_data_req (&ctxt,
SRB_FLAG_YES,
RRC_DCCH_DATA_REQ (msg_p).rb_id,
RRC_DCCH_DATA_REQ (msg_p).muip,
RRC_DCCH_DATA_REQ (msg_p).confirmp,
RRC_DCCH_DATA_REQ (msg_p).sdu_size,
RRC_DCCH_DATA_REQ (msg_p).sdu_p,
RRC_DCCH_DATA_REQ (msg_p).mode
case RRC_DCCH_DATA_REQ:
PROTOCOL_CTXT_SET_BY_MODULE_ID(
&ctxt,
RRC_DCCH_DATA_REQ (msg_p).module_id,
RRC_DCCH_DATA_REQ (msg_p).enb_flag,
RRC_DCCH_DATA_REQ (msg_p).rnti,
RRC_DCCH_DATA_REQ (msg_p).frame,
0,
RRC_DCCH_DATA_REQ (msg_p).eNB_index);
LOG_D(PDCP, PROTOCOL_CTXT_FMT"Received %s from %s: instance %d, rb_id %d, muiP %d, confirmP %d, mode %d\n",
PROTOCOL_CTXT_ARGS(&ctxt),
ITTI_MSG_NAME (msg_p),
ITTI_MSG_ORIGIN_NAME(msg_p),
ITTI_MSG_INSTANCE (msg_p),
RRC_DCCH_DATA_REQ (msg_p).rb_id,
RRC_DCCH_DATA_REQ (msg_p).muip,
RRC_DCCH_DATA_REQ (msg_p).confirmp,
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);
result = pdcp_data_req (&ctxt,
SRB_FLAG_YES,
RRC_DCCH_DATA_REQ (msg_p).rb_id,
RRC_DCCH_DATA_REQ (msg_p).muip,
RRC_DCCH_DATA_REQ (msg_p).confirmp,
RRC_DCCH_DATA_REQ (msg_p).sdu_size,
RRC_DCCH_DATA_REQ (msg_p).sdu_p,
RRC_DCCH_DATA_REQ (msg_p).mode
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
, NULL, NULL
, NULL, NULL
#endif
);
if (result != TRUE)
LOG_E(PDCP, "PDCP data request failed!\n");
);
// Message buffer has been processed, free it now.
result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), RRC_DCCH_DATA_REQ (msg_p).sdu_p);
AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
break;
if (result != TRUE)
LOG_E(PDCP, "PDCP data request failed!\n");
case RRC_PCCH_DATA_REQ:
{
sdu_size_t sdu_buffer_sizeP;
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 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;
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);
}
//paging pdcp log
LOG_D(PDCP, "PDCP Received RRC_PCCH_DATA_REQ CC_id %d length %d \n", CC_id, sdu_buffer_sizeP);
}
break;
// Message buffer has been processed, free it now.
result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), RRC_DCCH_DATA_REQ (msg_p).sdu_p);
AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
break;
default:
LOG_E(PDCP, "Received unexpected message %s\n", ITTI_MSG_NAME (msg_p));
case RRC_PCCH_DATA_REQ: {
sdu_size_t sdu_buffer_sizeP;
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 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;
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);
}
//paging pdcp log
LOG_D(PDCP, "PDCP Received RRC_PCCH_DATA_REQ CC_id %d length %d \n", CC_id, sdu_buffer_sizeP);
}
break;
default:
LOG_E(PDCP, "Received unexpected message %s\n", ITTI_MSG_NAME (msg_p));
break;
}
result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p);
......@@ -1037,7 +1006,6 @@ pdcp_run (
} while(msg_p != NULL);
#endif
// IP/NAS -> PDCP traffic : TX, read the pkt from the upper layer buffer
#if defined(LINK_ENB_PDCP_TO_GTPV1U)
......@@ -1050,9 +1018,7 @@ pdcp_run (
// PDCP -> NAS/IP traffic: RX
if (ctxt_pP->enb_flag) {
start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].pdcp_ip);
}
else {
} else {
start_meas(&UE_pdcp_stats[ctxt_pP->module_id].pdcp_ip);
}
......@@ -1069,36 +1035,40 @@ pdcp_run (
} else {
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);
}
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
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) {
ue_flag=-1;
break;
}
}
if (ue_flag == 1 ){
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].uid[i]=i;
pdcp_enb[ctxt_pP->module_id].num_ues++;
printf("add new uid is %d %x\n\n", i, ctxt_pP->rnti);
// ret=1;
break;
if (ue_flag == 1 ) {
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].uid[i]=i;
pdcp_enb[ctxt_pP->module_id].num_ues++;
printf("add new uid is %d %x\n\n", i, ctxt_pP->rnti);
// ret=1;
break;
}
}
}
//return ret;
}
//-----------------------------------------------------------------------------
boolean_t
pdcp_remove_UE(
const protocol_ctxt_t* const ctxt_pP
const protocol_ctxt_t *const ctxt_pP
)
//-----------------------------------------------------------------------------
{
......@@ -1106,11 +1076,11 @@ pdcp_remove_UE(
LTE_DRB_Identity_t drb_id = 0;
hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE;
hashtable_rc_t h_rc;
int i;
// check and remove SRBs first
int i;
// check and remove SRBs first
for(int i = 0;i<MAX_MOBILES_PER_ENB;i++){
if(pdcp_eNB_UE_instance_to_rnti[i] == ctxt_pP->rnti){
for(int i = 0; i<MAX_MOBILES_PER_ENB; i++) {
if(pdcp_eNB_UE_instance_to_rnti[i] == ctxt_pP->rnti) {
pdcp_eNB_UE_instance_to_rnti[i] = NOT_A_RNTI;
break;
}
......@@ -1124,24 +1094,23 @@ pdcp_remove_UE(
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);
h_rc = hashtable_remove(pdcp_coll_p, key);
}
(void)h_rc; /* remove gcc warning "set but not used" */
// remove ue for pdcp enb inst
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 ) {
LOG_I(PDCP, "remove uid is %d/%d %x\n", i,
pdcp_enb[ctxt_pP->module_id].uid[i],
pdcp_enb[ctxt_pP->module_id].rnti[i]);
pdcp_enb[ctxt_pP->module_id].uid[i],
pdcp_enb[ctxt_pP->module_id].rnti[i]);
pdcp_enb[ctxt_pP->module_id].uid[i]=0;
pdcp_enb[ctxt_pP->module_id].rnti[i]=0;
pdcp_enb[ctxt_pP->module_id].num_ues--;
break;
}
}
return 1;
}
......@@ -1149,7 +1118,7 @@ pdcp_remove_UE(
//-----------------------------------------------------------------------------
boolean_t
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_DRB_ToAddModList_t *const drb2add_list_pP,
LTE_DRB_ToReleaseList_t *const drb2release_list_pP,
......@@ -1158,9 +1127,9 @@ rrc_pdcp_config_asn1_req (
uint8_t *const kRRCint_pP,
uint8_t *const kUPenc_pP
#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
,rb_id_t *const defaultDRB
,rb_id_t *const defaultDRB
)
//-----------------------------------------------------------------------------
{
......@@ -1179,7 +1148,6 @@ rrc_pdcp_config_asn1_req (
LTE_SRB_ToAddMod_t *srb_toaddmod_p = NULL;
LTE_DRB_ToAddMod_t *drb_toaddmod_p = NULL;
pdcp_t *pdcp_p = NULL;
hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE;
hashtable_rc_t h_rc;
hash_key_t key_defaultDRB = HASHTABLE_NOT_A_KEY_VALUE;
......@@ -1189,7 +1157,6 @@ rrc_pdcp_config_asn1_req (
LTE_MBMS_SessionInfoList_r9_t *mbms_SessionInfoList_r9_p = NULL;
LTE_MBMS_SessionInfo_r9_t *MBMS_SessionInfo_p = NULL;
#endif
LOG_T(PDCP, PROTOCOL_CTXT_FMT" %s() SRB2ADD %p DRB2ADD %p DRB2RELEASE %p\n",
PROTOCOL_CTXT_ARGS(ctxt_pP),
__FUNCTION__,
......@@ -1206,7 +1173,7 @@ rrc_pdcp_config_asn1_req (
rlc_type = RLC_MODE_AM;
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);
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) {
action = CONFIG_ACTION_MODIFY;
......@@ -1224,9 +1191,8 @@ rrc_pdcp_config_asn1_req (
key);
free(pdcp_p);
return TRUE;
} else {
LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_ADD key 0x%"PRIx64"\n",
} else {
LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_ADD key 0x%"PRIx64"\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p),
key);
}
......@@ -1234,15 +1200,37 @@ rrc_pdcp_config_asn1_req (
if (srb_toaddmod_p->rlc_Config) {
switch (srb_toaddmod_p->rlc_Config->present) {
case LTE_SRB_ToAddMod__rlc_Config_PR_NOTHING:
break;
case LTE_SRB_ToAddMod__rlc_Config_PR_NOTHING:
break;
case LTE_SRB_ToAddMod__rlc_Config_PR_explicitValue:
switch (srb_toaddmod_p->rlc_Config->choice.explicitValue.present) {
case LTE_RLC_Config_PR_NOTHING:
break;
default:
pdcp_config_req_asn1 (
ctxt_pP,
pdcp_p,
SRB_FLAG_YES,
rlc_type,
action,
lc_id,
mch_id,
srb_id,
srb_sn,
0, // drb_report
0, // header compression
security_modeP,
kRRCenc_pP,
kRRCint_pP,
kUPenc_pP);
break;
}
case LTE_SRB_ToAddMod__rlc_Config_PR_explicitValue:
switch (srb_toaddmod_p->rlc_Config->choice.explicitValue.present) {
case LTE_RLC_Config_PR_NOTHING:
break;
default:
case LTE_SRB_ToAddMod__rlc_Config_PR_defaultValue:
pdcp_config_req_asn1 (
ctxt_pP,
pdcp_p,
......@@ -1259,34 +1247,12 @@ rrc_pdcp_config_asn1_req (
kRRCenc_pP,
kRRCint_pP,
kUPenc_pP);
// already the default values
break;
}
break;
case LTE_SRB_ToAddMod__rlc_Config_PR_defaultValue:
pdcp_config_req_asn1 (
ctxt_pP,
pdcp_p,
SRB_FLAG_YES,
rlc_type,
action,
lc_id,
mch_id,
srb_id,
srb_sn,
0, // drb_report
0, // header compression
security_modeP,
kRRCenc_pP,
kRRCint_pP,
kUPenc_pP);
// already the default values
break;
default:
DevParam(srb_toaddmod_p->rlc_Config->present, ctxt_pP->module_id, ctxt_pP->rnti);
break;
default:
DevParam(srb_toaddmod_p->rlc_Config->present, ctxt_pP->module_id, ctxt_pP->rnti);
break;
}
}
}
......@@ -1296,10 +1262,9 @@ rrc_pdcp_config_asn1_req (
if (drb2add_list_pP != NULL) {
for (cnt=0; cnt<drb2add_list_pP->list.count; cnt++) {
drb_toaddmod_p = drb2add_list_pP->list.array[cnt];
drb_id = drb_toaddmod_p->drb_Identity;// + drb_id_offset;
if (drb_toaddmod_p->logicalChannelIdentity) {
lc_id = *(drb_toaddmod_p->logicalChannelIdentity);
} else {
......@@ -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);
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) {
action = CONFIG_ACTION_MODIFY;
LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_MODIFY key 0x%"PRIx64"\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p),
key);
} else {
action = CONFIG_ACTION_ADD;
pdcp_p = calloc(1, sizeof(pdcp_t));
......@@ -1352,7 +1316,7 @@ rrc_pdcp_config_asn1_req (
LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_ADD ADD key 0x%"PRIx64"\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p),
key);
}
}
}
if (drb_toaddmod_p->pdcp_Config) {
......@@ -1372,44 +1336,44 @@ rrc_pdcp_config_asn1_req (
}
switch (drb_toaddmod_p->pdcp_Config->headerCompression.present) {
case LTE_PDCP_Config__headerCompression_PR_NOTHING:
case LTE_PDCP_Config__headerCompression_PR_notUsed:
header_compression_profile=0x0;
break;
case LTE_PDCP_Config__headerCompression_PR_rohc:
// parse the struc and get the rohc profile
if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0001) {
header_compression_profile=0x0001;
} else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0002) {
header_compression_profile=0x0002;
} else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0003) {
header_compression_profile=0x0003;
} else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0004) {
header_compression_profile=0x0004;
} else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0006) {
header_compression_profile=0x0006;
} else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0101) {
header_compression_profile=0x0101;
} else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0102) {
header_compression_profile=0x0102;
} else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0103) {
header_compression_profile=0x0103;
} else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0104) {
header_compression_profile=0x0104;
} else {
case LTE_PDCP_Config__headerCompression_PR_NOTHING:
case LTE_PDCP_Config__headerCompression_PR_notUsed:
header_compression_profile=0x0;
LOG_W(PDCP,"unknown header compresion profile\n");
}
break;
// set the applicable profile
break;
case LTE_PDCP_Config__headerCompression_PR_rohc:
// parse the struc and get the rohc profile
if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0001) {
header_compression_profile=0x0001;
} else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0002) {
header_compression_profile=0x0002;
} else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0003) {
header_compression_profile=0x0003;
} else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0004) {
header_compression_profile=0x0004;
} else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0006) {
header_compression_profile=0x0006;
} else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0101) {
header_compression_profile=0x0101;
} else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0102) {
header_compression_profile=0x0102;
} else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0103) {
header_compression_profile=0x0103;
} else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0104) {
header_compression_profile=0x0104;
} else {
header_compression_profile=0x0;
LOG_W(PDCP,"unknown header compresion profile\n");
}
// set the applicable profile
break;
default:
LOG_W(PDCP,PROTOCOL_PDCP_CTXT_FMT"[RB %ld] unknown drb_toaddmod->PDCP_Config->headerCompression->present \n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p), drb_id);
break;
default:
LOG_W(PDCP,PROTOCOL_PDCP_CTXT_FMT"[RB %ld] unknown drb_toaddmod->PDCP_Config->headerCompression->present \n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p), drb_id);
break;
}
pdcp_config_req_asn1 (
......@@ -1437,7 +1401,7 @@ rrc_pdcp_config_asn1_req (
pdrb_id_p = drb2release_list_pP->list.array[cnt];
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);
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) {
LOG_E(PDCP, PROTOCOL_CTXT_FMT" PDCP REMOVE FAILED drb_id %ld\n",
......@@ -1445,8 +1409,8 @@ rrc_pdcp_config_asn1_req (
drb_id);
continue;
}
lc_id = pdcp_p->lcid;
lc_id = pdcp_p->lcid;
action = CONFIG_ACTION_REMOVE;
pdcp_config_req_asn1 (
ctxt_pP,
......@@ -1469,7 +1433,7 @@ rrc_pdcp_config_asn1_req (
if ((defaultDRB != NULL) && (*defaultDRB == drb_id)) {
// 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);
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) {
h_defaultDRB_rc = hashtable_remove(pdcp_coll_p, key_defaultDRB);
......@@ -1490,12 +1454,14 @@ rrc_pdcp_config_asn1_req (
for (j=0; j<mbms_SessionInfoList_r9_p->list.count; j++) {
MBMS_SessionInfo_p = mbms_SessionInfoList_r9_p->list.array[j];
if (MBMS_SessionInfo_p->sessionId_r9)
lc_id = MBMS_SessionInfo_p->sessionId_r9->buf[0];
else
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 = j;
// mch_id = j;
// can set the mch_id = i
if (ctxt_pP->enb_flag) {
......@@ -1517,13 +1483,12 @@ rrc_pdcp_config_asn1_req (
}
LOG_D(PDCP, "lc_id (%02ld) mch_id(%02x,%02x,%02x) drb_id(%ld) action(%d)\n",
lc_id,
MBMS_SessionInfo_p->tmgi_r9.serviceId_r9.buf[0],
MBMS_SessionInfo_p->tmgi_r9.serviceId_r9.buf[1],
MBMS_SessionInfo_p->tmgi_r9.serviceId_r9.buf[2],
drb_id,
action);
lc_id,
MBMS_SessionInfo_p->tmgi_r9.serviceId_r9.buf[0],
MBMS_SessionInfo_p->tmgi_r9.serviceId_r9.buf[1],
MBMS_SessionInfo_p->tmgi_r9.serviceId_r9.buf[2],
drb_id,
action);
pdcp_config_req_asn1 (
ctxt_pP,
NULL, // unused for MBMS
......@@ -1551,8 +1516,8 @@ rrc_pdcp_config_asn1_req (
//-----------------------------------------------------------------------------
boolean_t
pdcp_config_req_asn1 (
const protocol_ctxt_t* const ctxt_pP,
pdcp_t * const pdcp_pP,
const protocol_ctxt_t *const ctxt_pP,
pdcp_t *const pdcp_pP,
const srb_flag_t srb_flagP,
const rlc_mode_t rlc_modeP,
const config_action_t actionP,
......@@ -1568,179 +1533,183 @@ pdcp_config_req_asn1 (
uint8_t *const kUPenc_pP)
//-----------------------------------------------------------------------------
{
switch (actionP) {
case CONFIG_ACTION_ADD:
DevAssert(pdcp_pP != NULL);
if (ctxt_pP->enb_flag == ENB_FLAG_YES) {
pdcp_pP->is_ue = FALSE;
pdcp_add_UE(ctxt_pP);
//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;
if( srb_flagP == SRB_FLAG_NO ) {
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){
break;
}
pdcp_eNB_UE_instance_to_rnti_index = (pdcp_eNB_UE_instance_to_rnti_index + 1) % MAX_MOBILES_PER_ENB;
case CONFIG_ACTION_ADD:
DevAssert(pdcp_pP != NULL);
if (ctxt_pP->enb_flag == ENB_FLAG_YES) {
pdcp_pP->is_ue = FALSE;
pdcp_add_UE(ctxt_pP);
//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;
if( srb_flagP == SRB_FLAG_NO ) {
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) {
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[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;
} else {
pdcp_pP->is_ue = TRUE;
pdcp_UE_UE_module_id_to_rnti[ctxt_pP->module_id] = ctxt_pP->rnti;
}
//pdcp_eNB_UE_instance_to_rnti_index = (pdcp_eNB_UE_instance_to_rnti_index + 1) % MAX_MOBILES_PER_ENB;
} else {
pdcp_pP->is_ue = TRUE;
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->lcid = lc_idP;
pdcp_pP->rb_id = rb_idP;
pdcp_pP->header_compression_profile = header_compression_profileP;
pdcp_pP->status_report = rb_reportP;
if (rb_snP == LTE_PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits) {
pdcp_pP->seq_num_size = PDCP_SN_12BIT;
} else if (rb_snP == LTE_PDCP_Config__rlc_UM__pdcp_SN_Size_len7bits) {
pdcp_pP->seq_num_size = PDCP_SN_7BIT;
} else {
pdcp_pP->seq_num_size = PDCP_SN_5BIT;
}
pdcp_pP->is_srb = (srb_flagP == SRB_FLAG_YES) ? TRUE : FALSE;
pdcp_pP->lcid = lc_idP;
pdcp_pP->rb_id = rb_idP;
pdcp_pP->header_compression_profile = header_compression_profileP;
pdcp_pP->status_report = rb_reportP;
pdcp_pP->rlc_mode = rlc_modeP;
pdcp_pP->next_pdcp_tx_sn = 0;
pdcp_pP->next_pdcp_rx_sn = 0;
pdcp_pP->next_pdcp_rx_sn_before_integrity = 0;
pdcp_pP->tx_hfn = 0;
pdcp_pP->rx_hfn = 0;
pdcp_pP->last_submitted_pdcp_rx_sn = 4095;
pdcp_pP->first_missing_pdu = -1;
pdcp_pP->rx_hfn_offset = 0;
if (rb_snP == LTE_PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits) {
pdcp_pP->seq_num_size = PDCP_SN_12BIT;
} else if (rb_snP == LTE_PDCP_Config__rlc_UM__pdcp_SN_Size_len7bits) {
pdcp_pP->seq_num_size = PDCP_SN_7BIT;
} else {
pdcp_pP->seq_num_size = PDCP_SN_5BIT;
}
LOG_I(PDCP, PROTOCOL_PDCP_CTXT_FMT" Action ADD LCID %d (%s id %d) "
pdcp_pP->rlc_mode = rlc_modeP;
pdcp_pP->next_pdcp_tx_sn = 0;
pdcp_pP->next_pdcp_rx_sn = 0;
pdcp_pP->next_pdcp_rx_sn_before_integrity = 0;
pdcp_pP->tx_hfn = 0;
pdcp_pP->rx_hfn = 0;
pdcp_pP->last_submitted_pdcp_rx_sn = 4095;
pdcp_pP->first_missing_pdu = -1;
pdcp_pP->rx_hfn_offset = 0;
LOG_I(PDCP, PROTOCOL_PDCP_CTXT_FMT" Action ADD LCID %d (%s id %d) "
"configured with SN size %d bits and RLC %s\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_pP),
lc_idP,
(srb_flagP == SRB_FLAG_YES) ? "SRB" : "DRB",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_pP),
lc_idP,
(srb_flagP == SRB_FLAG_YES) ? "SRB" : "DRB",
rb_idP,
pdcp_pP->seq_num_size,
(rlc_modeP == RLC_MODE_AM ) ? "AM" : (rlc_modeP == RLC_MODE_TM) ? "TM" : "UM");
/* Setup security */
if (security_modeP != 0xff) {
pdcp_config_set_security(
ctxt_pP,
pdcp_pP,
rb_idP,
pdcp_pP->seq_num_size,
(rlc_modeP == RLC_MODE_AM ) ? "AM" : (rlc_modeP == RLC_MODE_TM) ? "TM" : "UM");
/* Setup security */
if (security_modeP != 0xff) {
pdcp_config_set_security(
ctxt_pP,
pdcp_pP,
rb_idP,
lc_idP,
security_modeP,
kRRCenc_pP,
kRRCint_pP,
kUPenc_pP);
}
break;
lc_idP,
security_modeP,
kRRCenc_pP,
kRRCint_pP,
kUPenc_pP);
}
case CONFIG_ACTION_MODIFY:
DevAssert(pdcp_pP != NULL);
pdcp_pP->header_compression_profile=header_compression_profileP;
pdcp_pP->status_report = rb_reportP;
pdcp_pP->rlc_mode = rlc_modeP;
break;
/* Setup security */
if (security_modeP != 0xff) {
pdcp_config_set_security(
ctxt_pP,
pdcp_pP,
rb_idP,
lc_idP,
security_modeP,
kRRCenc_pP,
kRRCint_pP,
kUPenc_pP);
}
case CONFIG_ACTION_MODIFY:
DevAssert(pdcp_pP != NULL);
pdcp_pP->header_compression_profile=header_compression_profileP;
pdcp_pP->status_report = rb_reportP;
pdcp_pP->rlc_mode = rlc_modeP;
if (rb_snP == LTE_PDCP_Config__rlc_UM__pdcp_SN_Size_len7bits) {
pdcp_pP->seq_num_size = 7;
} else if (rb_snP == LTE_PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits) {
pdcp_pP->seq_num_size = 12;
} else {
pdcp_pP->seq_num_size=5;
}
/* Setup security */
if (security_modeP != 0xff) {
pdcp_config_set_security(
ctxt_pP,
pdcp_pP,
rb_idP,
lc_idP,
security_modeP,
kRRCenc_pP,
kRRCint_pP,
kUPenc_pP);
}
LOG_I(PDCP,PROTOCOL_PDCP_CTXT_FMT" Action MODIFY LCID %d "
if (rb_snP == LTE_PDCP_Config__rlc_UM__pdcp_SN_Size_len7bits) {
pdcp_pP->seq_num_size = 7;
} else if (rb_snP == LTE_PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits) {
pdcp_pP->seq_num_size = 12;
} else {
pdcp_pP->seq_num_size=5;
}
LOG_I(PDCP,PROTOCOL_PDCP_CTXT_FMT" Action MODIFY LCID %d "
"RB id %d reconfigured with SN size %d and RLC %s \n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_pP),
lc_idP,
rb_idP,
rb_snP,
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_pP),
lc_idP,
rb_idP,
rb_snP,
(rlc_modeP == RLC_MODE_AM) ? "AM" : (rlc_modeP == RLC_MODE_TM) ? "TM" : "UM");
break;
break;
case CONFIG_ACTION_REMOVE:
DevAssert(pdcp_pP != NULL);
//#warning "TODO pdcp_module_id_to_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",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_pP),
lc_idP,
rb_idP);
case CONFIG_ACTION_REMOVE:
DevAssert(pdcp_pP != NULL);
//#warning "TODO pdcp_module_id_to_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",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_pP),
lc_idP,
rb_idP);
if (ctxt_pP->enb_flag == ENB_FLAG_YES) {
// pdcp_remove_UE(ctxt_pP);
}
if (ctxt_pP->enb_flag == ENB_FLAG_YES) {
// pdcp_remove_UE(ctxt_pP);
}
/* Security keys */
if (pdcp_pP->kUPenc != NULL) {
free(pdcp_pP->kUPenc);
}
/* Security keys */
if (pdcp_pP->kUPenc != NULL) {
free(pdcp_pP->kUPenc);
}
if (pdcp_pP->kRRCint != NULL) {
free(pdcp_pP->kRRCint);
}
if (pdcp_pP->kRRCint != NULL) {
free(pdcp_pP->kRRCint);
}
if (pdcp_pP->kRRCenc != NULL) {
free(pdcp_pP->kRRCenc);
}
if (pdcp_pP->kRRCenc != NULL) {
free(pdcp_pP->kRRCenc);
}
memset(pdcp_pP, 0, sizeof(pdcp_t));
break;
memset(pdcp_pP, 0, sizeof(pdcp_t));
break;
#if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0))
case CONFIG_ACTION_MBMS_ADD:
case CONFIG_ACTION_MBMS_MODIFY:
LOG_D(PDCP," %s service_id/mch index %d, session_id/lcid %d, rbid %d configured\n",
//PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_pP),
actionP == CONFIG_ACTION_MBMS_ADD ? "CONFIG_ACTION_MBMS_ADD" : "CONFIG_ACTION_MBMS_MODIFY",
mch_idP,
lc_idP,
rb_idP);
case CONFIG_ACTION_MBMS_ADD:
case CONFIG_ACTION_MBMS_MODIFY:
LOG_D(PDCP," %s service_id/mch index %d, session_id/lcid %d, rbid %d configured\n",
//PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_pP),
actionP == CONFIG_ACTION_MBMS_ADD ? "CONFIG_ACTION_MBMS_ADD" : "CONFIG_ACTION_MBMS_MODIFY",
mch_idP,
lc_idP,
rb_idP);
if (ctxt_pP->enb_flag == ENB_FLAG_YES) {
pdcp_mbms_array_eNB[ctxt_pP->module_id][mch_idP][lc_idP].instanciated_instance = TRUE ;
pdcp_mbms_array_eNB[ctxt_pP->module_id][mch_idP][lc_idP].rb_id = rb_idP;
} else {
pdcp_mbms_array_ue[ctxt_pP->module_id][mch_idP][lc_idP].instanciated_instance = TRUE ;
pdcp_mbms_array_ue[ctxt_pP->module_id][mch_idP][lc_idP].rb_id = rb_idP;
}
if (ctxt_pP->enb_flag == ENB_FLAG_YES) {
pdcp_mbms_array_eNB[ctxt_pP->module_id][mch_idP][lc_idP].instanciated_instance = TRUE ;
pdcp_mbms_array_eNB[ctxt_pP->module_id][mch_idP][lc_idP].rb_id = rb_idP;
} else {
pdcp_mbms_array_ue[ctxt_pP->module_id][mch_idP][lc_idP].instanciated_instance = TRUE ;
pdcp_mbms_array_ue[ctxt_pP->module_id][mch_idP][lc_idP].rb_id = rb_idP;
}
break;
break;
#endif
case CONFIG_ACTION_SET_SECURITY_MODE:
pdcp_config_set_security(
ctxt_pP,
pdcp_pP,
rb_idP,
lc_idP,
security_modeP,
kRRCenc_pP,
kRRCint_pP,
kUPenc_pP);
break;
default:
DevParam(actionP, ctxt_pP->module_id, ctxt_pP->rnti);
break;
case CONFIG_ACTION_SET_SECURITY_MODE:
pdcp_config_set_security(
ctxt_pP,
pdcp_pP,
rb_idP,
lc_idP,
security_modeP,
kRRCenc_pP,
kRRCint_pP,
kUPenc_pP);
break;
default:
DevParam(actionP, ctxt_pP->module_id, ctxt_pP->rnti);
break;
}
return 0;
......@@ -1749,14 +1718,14 @@ pdcp_config_req_asn1 (
//-----------------------------------------------------------------------------
void
pdcp_config_set_security(
const protocol_ctxt_t* const ctxt_pP,
pdcp_t * const pdcp_pP,
const protocol_ctxt_t *const ctxt_pP,
pdcp_t *const pdcp_pP,
const rb_id_t rb_idP,
const uint16_t lc_idP,
const uint8_t security_modeP,
uint8_t * const kRRCenc,
uint8_t * const kRRCint,
uint8_t * const kUPenc)
uint8_t *const kRRCenc,
uint8_t *const kRRCint,
uint8_t *const kUPenc)
//-----------------------------------------------------------------------------
{
DevAssert(pdcp_pP != NULL);
......@@ -1764,30 +1733,27 @@ pdcp_config_set_security(
if ((security_modeP >= 0) && (security_modeP <= 0x77)) {
pdcp_pP->cipheringAlgorithm = security_modeP & 0x0f;
pdcp_pP->integrityProtAlgorithm = (security_modeP>>4) & 0xf;
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),
pdcp_pP->cipheringAlgorithm,
pdcp_pP->integrityProtAlgorithm);
pdcp_pP->cipheringAlgorithm,
pdcp_pP->integrityProtAlgorithm);
pdcp_pP->kRRCenc = kRRCenc;
pdcp_pP->kRRCint = kRRCint;
pdcp_pP->kUPenc = kUPenc;
/* Activate security */
pdcp_pP->security_activated = 1;
MSC_LOG_EVENT(
(ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
"0 Set security ciph %X integ %x UE %"PRIx16" ",
pdcp_pP->cipheringAlgorithm,
pdcp_pP->integrityProtAlgorithm,
ctxt_pP->rnti);
MSC_LOG_EVENT(
(ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
"0 Set security ciph %X integ %x UE %"PRIx16" ",
pdcp_pP->cipheringAlgorithm,
pdcp_pP->integrityProtAlgorithm,
ctxt_pP->rnti);
} else {
MSC_LOG_EVENT(
(ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
"0 Set security failed UE %"PRIx16" ",
ctxt_pP->rnti);
LOG_E(PDCP,PROTOCOL_PDCP_CTXT_FMT" bad security mode %d",
MSC_LOG_EVENT(
(ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
"0 Set security failed UE %"PRIx16" ",
ctxt_pP->rnti);
LOG_E(PDCP,PROTOCOL_PDCP_CTXT_FMT" bad security mode %d",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_pP),
security_modeP);
}
......@@ -1796,7 +1762,7 @@ pdcp_config_set_security(
//-----------------------------------------------------------------------------
void
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 uint32_t actionP,
const rb_id_t rb_idP,
......@@ -1806,102 +1772,23 @@ rrc_pdcp_config_req (
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);
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) {
/*
* Initialize sequence number state variables of relevant PDCP entity
*/
switch (actionP) {
case CONFIG_ACTION_ADD:
pdcp_p->is_srb = srb_flagP;
pdcp_p->rb_id = rb_idP;
if (ctxt_pP->enb_flag == ENB_FLAG_NO) {
pdcp_p->is_ue = TRUE;
pdcp_UE_UE_module_id_to_rnti[ctxt_pP->module_id] = ctxt_pP->rnti;
} else {
pdcp_p->is_ue = FALSE;
}
pdcp_p->next_pdcp_tx_sn = 0;
pdcp_p->next_pdcp_rx_sn = 0;
pdcp_p->tx_hfn = 0;
pdcp_p->rx_hfn = 0;
/* SN of the last PDCP SDU delivered to upper layers */
pdcp_p->last_submitted_pdcp_rx_sn = 4095;
if (rb_idP < DTCH) { // SRB
pdcp_p->seq_num_size = 5;
} else { // DRB
pdcp_p->seq_num_size = 12;
}
pdcp_p->first_missing_pdu = -1;
LOG_D(PDCP,PROTOCOL_PDCP_CTXT_FMT" Config request : Action ADD: radio bearer id %d (already added) configured\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p),
rb_idP);
break;
case CONFIG_ACTION_MODIFY:
break;
case CONFIG_ACTION_REMOVE:
LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_REMOVE: radio bearer id %d configured\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p),
rb_idP);
pdcp_p->next_pdcp_tx_sn = 0;
pdcp_p->next_pdcp_rx_sn = 0;
pdcp_p->tx_hfn = 0;
pdcp_p->rx_hfn = 0;
pdcp_p->last_submitted_pdcp_rx_sn = 4095;
pdcp_p->seq_num_size = 0;
pdcp_p->first_missing_pdu = -1;
pdcp_p->security_activated = 0;
h_rc = hashtable_remove(pdcp_coll_p, key);
break;
case CONFIG_ACTION_SET_SECURITY_MODE:
if ((security_modeP >= 0) && (security_modeP <= 0x77)) {
pdcp_p->cipheringAlgorithm= security_modeP & 0x0f;
pdcp_p->integrityProtAlgorithm = (security_modeP>>4) & 0xf;
LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_SET_SECURITY_MODE: cipheringAlgorithm %d integrityProtAlgorithm %d\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p),
pdcp_p->cipheringAlgorithm,
pdcp_p->integrityProtAlgorithm );
} else {
LOG_W(PDCP,PROTOCOL_PDCP_CTXT_FMT" bad security mode %d", PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p), security_modeP);
}
break;
default:
DevParam(actionP, ctxt_pP->module_id, ctxt_pP->rnti);
break;
}
} else {
/*
* Initialize sequence number state variables of relevant PDCP entity
*/
switch (actionP) {
case CONFIG_ACTION_ADD:
pdcp_p = calloc(1, sizeof(pdcp_t));
h_rc = hashtable_insert(pdcp_coll_p, key, pdcp_p);
if (h_rc != HASH_TABLE_OK) {
LOG_E(PDCP, PROTOCOL_PDCP_CTXT_FMT" PDCP ADD FAILED\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p));
free(pdcp_p);
} else {
case CONFIG_ACTION_ADD:
pdcp_p->is_srb = srb_flagP;
pdcp_p->rb_id = rb_idP;
if (ctxt_pP->enb_flag == ENB_FLAG_NO) {
pdcp_p->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;
} else {
pdcp_p->is_ue = FALSE;
}
}
pdcp_p->next_pdcp_tx_sn = 0;
pdcp_p->next_pdcp_rx_sn = 0;
......@@ -1912,46 +1799,119 @@ rrc_pdcp_config_req (
if (rb_idP < DTCH) { // SRB
pdcp_p->seq_num_size = 5;
} else { // DRB
pdcp_p->seq_num_size = 12;
}
pdcp_p->first_missing_pdu = -1;
LOG_D(PDCP,PROTOCOL_PDCP_CTXT_FMT" Inserting PDCP instance in collection key 0x%"PRIx64"\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p), key);
LOG_D(PDCP,PROTOCOL_PDCP_CTXT_FMT" Config request : Action ADD: radio bearer id %d configured\n",
LOG_D(PDCP,PROTOCOL_PDCP_CTXT_FMT" Config request : Action ADD: radio bearer id %d (already added) configured\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p),
rb_idP);
}
break;
break;
case CONFIG_ACTION_MODIFY:
break;
case CONFIG_ACTION_REMOVE:
LOG_D(PDCP, PROTOCOL_CTXT_FMT" CONFIG_REQ PDCP CONFIG_ACTION_REMOVE PDCP instance not found\n",
PROTOCOL_CTXT_ARGS(ctxt_pP));
break;
case CONFIG_ACTION_REMOVE:
LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_REMOVE: radio bearer id %d configured\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p),
rb_idP);
pdcp_p->next_pdcp_tx_sn = 0;
pdcp_p->next_pdcp_rx_sn = 0;
pdcp_p->tx_hfn = 0;
pdcp_p->rx_hfn = 0;
pdcp_p->last_submitted_pdcp_rx_sn = 4095;
pdcp_p->seq_num_size = 0;
pdcp_p->first_missing_pdu = -1;
pdcp_p->security_activated = 0;
h_rc = hashtable_remove(pdcp_coll_p, key);
break;
default:
LOG_E(PDCP, PROTOCOL_CTXT_FMT" CONFIG_REQ PDCP NOT FOUND\n",
PROTOCOL_CTXT_ARGS(ctxt_pP));
case CONFIG_ACTION_SET_SECURITY_MODE:
if ((security_modeP >= 0) && (security_modeP <= 0x77)) {
pdcp_p->cipheringAlgorithm= security_modeP & 0x0f;
pdcp_p->integrityProtAlgorithm = (security_modeP>>4) & 0xf;
LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_SET_SECURITY_MODE: cipheringAlgorithm %d integrityProtAlgorithm %d\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p),
pdcp_p->cipheringAlgorithm,
pdcp_p->integrityProtAlgorithm );
} else {
LOG_W(PDCP,PROTOCOL_PDCP_CTXT_FMT" bad security mode %d", PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p), security_modeP);
}
break;
default:
DevParam(actionP, ctxt_pP->module_id, ctxt_pP->rnti);
break;
}
} else {
switch (actionP) {
case CONFIG_ACTION_ADD:
pdcp_p = calloc(1, sizeof(pdcp_t));
h_rc = hashtable_insert(pdcp_coll_p, key, pdcp_p);
if (h_rc != HASH_TABLE_OK) {
LOG_E(PDCP, PROTOCOL_PDCP_CTXT_FMT" PDCP ADD FAILED\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p));
free(pdcp_p);
} else {
pdcp_p->is_srb = srb_flagP;
pdcp_p->rb_id = rb_idP;
if (ctxt_pP->enb_flag == ENB_FLAG_NO) {
pdcp_p->is_ue = TRUE;
pdcp_UE_UE_module_id_to_rnti[ctxt_pP->module_id] = ctxt_pP->rnti;
} else {
pdcp_p->is_ue = FALSE;
}
pdcp_p->next_pdcp_tx_sn = 0;
pdcp_p->next_pdcp_rx_sn = 0;
pdcp_p->tx_hfn = 0;
pdcp_p->rx_hfn = 0;
/* SN of the last PDCP SDU delivered to upper layers */
pdcp_p->last_submitted_pdcp_rx_sn = 4095;
if (rb_idP < DTCH) { // SRB
pdcp_p->seq_num_size = 5;
} else { // DRB
pdcp_p->seq_num_size = 12;
}
pdcp_p->first_missing_pdu = -1;
LOG_D(PDCP,PROTOCOL_PDCP_CTXT_FMT" Inserting PDCP instance in collection key 0x%"PRIx64"\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p), key);
LOG_D(PDCP,PROTOCOL_PDCP_CTXT_FMT" Config request : Action ADD: radio bearer id %d configured\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p),
rb_idP);
}
break;
case CONFIG_ACTION_REMOVE:
LOG_D(PDCP, PROTOCOL_CTXT_FMT" CONFIG_REQ PDCP CONFIG_ACTION_REMOVE PDCP instance not found\n",
PROTOCOL_CTXT_ARGS(ctxt_pP));
break;
default:
LOG_E(PDCP, PROTOCOL_CTXT_FMT" CONFIG_REQ PDCP NOT FOUND\n",
PROTOCOL_CTXT_ARGS(ctxt_pP));
}
}
}
//-----------------------------------------------------------------------------
int
pdcp_module_init (
void
)
//-----------------------------------------------------------------------------
{
#ifdef PDCP_USE_RT_FIFO
int ret;
ret=rtf_create(PDCP2NW_DRIVER_FIFO,32768);
if (ret < 0) {
......@@ -1966,7 +1926,6 @@ pdcp_module_init (
if (ret < 0) {
LOG_E(PDCP, "Cannot create NW_DRIVER2PDCP_FIFO fifo %d (ERROR %d)\n", NW_DRIVER2PDCP_FIFO, ret);
return -1;
} else {
LOG_D(PDCP, "Created NW_DRIVER2PDCP_FIFO fifo %d\n", NW_DRIVER2PDCP_FIFO);
......@@ -1977,18 +1936,17 @@ pdcp_module_init (
pdcp_input_sdu_remaining_size_to_read=0;
pdcp_input_sdu_size_read=0;
#endif
return 0;
}
//-----------------------------------------------------------------------------
void
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->kUPenc != NULL) {
......@@ -2022,7 +1980,6 @@ void pdcp_module_cleanup (void)
void pdcp_layer_init(void)
//-----------------------------------------------------------------------------
{
module_id_t instance;
int i,j;
#if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0))
......@@ -2044,12 +2001,13 @@ void pdcp_layer_init(void)
memset(&pdcp_mbms_array_ue[instance][service_id][session_id], 0, sizeof(pdcp_mbms_t));
}
}
#endif
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++) {
#if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0))
......@@ -2064,28 +2022,26 @@ void pdcp_layer_init(void)
#ifdef MBMS_MULTICAST_OUT
mbms_socket = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
if (mbms_socket == -1)
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");
pdcp_output_sdu_bytes_to_write=0;
pdcp_output_header_bytes_to_write=0;
pdcp_input_sdu_remaining_size_to_read=0;
memset(pdcp_enb, 0, sizeof(pdcp_enb_t));
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));
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_rx_window_ms[i][j]=100;
}
}
memset(Pdcp_stats_tx, 0, sizeof(Pdcp_stats_tx));
memset(Pdcp_stats_tx_w, 0, sizeof(Pdcp_stats_tx_w));
memset(Pdcp_stats_tx_tmp_w, 0, sizeof(Pdcp_stats_tx_tmp_w));
......@@ -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_aiat, 0, sizeof(Pdcp_stats_tx_aiat));
memset(Pdcp_stats_tx_iat, 0, sizeof(Pdcp_stats_tx_iat));
memset(Pdcp_stats_rx, 0, sizeof(Pdcp_stats_rx));
memset(Pdcp_stats_rx_w, 0, sizeof(Pdcp_stats_rx_w));
memset(Pdcp_stats_rx_tmp_w, 0, sizeof(Pdcp_stats_rx_tmp_w));
......@@ -2109,7 +2063,6 @@ void pdcp_layer_init(void)
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_outoforder, 0, sizeof(Pdcp_stats_rx_outoforder));
}
//-----------------------------------------------------------------------------
......@@ -2117,15 +2070,17 @@ void pdcp_layer_cleanup (void)
//-----------------------------------------------------------------------------
{
list_free (&pdcp_sdu_list);
hashtable_destroy(pdcp_coll_p);
hashtable_destroy(&pdcp_coll_p);
#ifdef MBMS_MULTICAST_OUT
if(mbms_socket != -1) {
close(mbms_socket);
mbms_socket = -1;
}
#endif
}
#ifdef PDCP_USE_RT_FIFO
EXPORT_SYMBOL(pdcp_2_nas_irq);
EXPORT_SYMBOL(pdcp_2_nas_irq);
#endif //PDCP_USE_RT_FIFO
......@@ -677,7 +677,7 @@ void
rlc_module_cleanup (void)
//-----------------------------------------------------------------------------
{
hashtable_destroy(rlc_coll_p);
hashtable_destroy(&rlc_coll_p);
}
//-----------------------------------------------------------------------------
void
......
......@@ -50,9 +50,7 @@ static mapping rrc_status_names[] = {
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 len= length;
int CC_id=0;
......@@ -87,7 +85,6 @@ int dump_eNB_l2_stats(char *buffer, int length)
unsigned int stat_timer_reordering_timed_out;
unsigned int stat_timer_poll_retransmit_timed_out;
unsigned int stat_timer_status_prohibit_timed_out;
#ifdef EXMIMO
number_of_cards=1;
#else
......@@ -103,35 +100,29 @@ int dump_eNB_l2_stats(char *buffer, int length)
for (CC_id=0 ; CC_id < MAX_NUM_CCs; CC_id++) {
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",
eNB_id, CC_id, eNB->frame,
eNB->eNB_stats[CC_id].num_dlactive_UEs,
eNB->eNB_stats[CC_id].available_prbs,
eNB->eNB_stats[CC_id].available_ncces,
eNB->eNB_stats[CC_id].sched_decisions,
eNB->eNB_stats[CC_id].missed_deadlines);
eNB->eNB_stats[CC_id].sched_decisions,
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",
eNB->eNB_stats[CC_id].total_num_bcch_pdu,
eNB->eNB_stats[CC_id].bcch_buffer,
eNB->eNB_stats[CC_id].total_bcch_buffer,
eNB->eNB_stats[CC_id].bcch_mcs);
eNB->eNB_stats[CC_id].total_num_bcch_pdu,
eNB->eNB_stats[CC_id].bcch_buffer,
eNB->eNB_stats[CC_id].total_bcch_buffer,
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",
eNB->eNB_stats[CC_id].total_num_pcch_pdu,
eNB->eNB_stats[CC_id].pcch_buffer,
eNB->eNB_stats[CC_id].total_pcch_buffer,
eNB->eNB_stats[CC_id].pcch_mcs);
eNB->eNB_stats[CC_id].total_num_pcch_pdu,
eNB->eNB_stats[CC_id].pcch_buffer,
eNB->eNB_stats[CC_id].total_pcch_buffer,
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].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_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].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",
eNB->eNB_stats[CC_id].dlsch_bitrate,
eNB->eNB_stats[CC_id].total_dlsch_bitrate,
......@@ -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].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",
eNB->eNB_stats[CC_id].ulsch_bitrate,
eNB->eNB_stats[CC_id].total_ulsch_bitrate,
......@@ -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 (i=0; i<UE_list->numactiveCCs[UE_id]; i++) {
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_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].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));
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,
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)
UE_list->eNB_UE_stats[CC_id][UE_id].ncce_used,
UE_list->eNB_UE_stats[CC_id][UE_id].ncce_used_retx
);
len += sprintf(&buffer[len],
"[MAC] DLSCH bitrate (TTI %d, avg %d), Transmitted bytes "
"(TTI %d, total %"PRIu64"), Total Transmitted PDU %d, Overhead "
......@@ -190,32 +176,28 @@ 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].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,
map_int_to_str(rrc_status_names, UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status),
UE_list->UE_sched_ctrl[UE_id].ul_failure_timer,
UE_list->UE_sched_ctrl[UE_id].ul_failure_timer,
UE_list->eNB_UE_stats[CC_id][UE_id].crnti,
UE_list->eNB_UE_stats[CC_id][UE_id].normalized_rx_power,
UE_list->eNB_UE_stats[CC_id][UE_id].target_rx_power,
UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1,
UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2,
UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used_rx,
UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used_retx_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
);
len += sprintf(&buffer[len],
UE_list->eNB_UE_stats[CC_id][UE_id].normalized_rx_power,
UE_list->eNB_UE_stats[CC_id][UE_id].target_rx_power,
UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1,
UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2,
UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used_rx,
UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used_retx_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
);
len += sprintf(&buffer[len],
"[MAC] ULSCH bitrate (TTI %d, avg %d), received bytes (total %"PRIu64"),"
"Total received PDU %d, Total errors %d\n",
UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_bitrate,
"Total received PDU %d, Total errors %d\n",
UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_bitrate,
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,
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);
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",
UE_list->UE_template[CC_id][UE_id].ul_buffer_info[LCGID0],
......@@ -224,181 +206,164 @@ int dump_eNB_l2_stats(char *buffer, int length)
UE_list->UE_template[CC_id][UE_id].ul_buffer_info[LCGID3]
);
}
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt,
eNB_id,
ENB_FLAG_YES,
UE_list->eNB_UE_stats[0][UE_id].crnti,//UE_PCCID(eNB_id,UE_id)][UE_id].crnti,
eNB->frame,
eNB->subframe,
eNB_id);
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt,
eNB_id,
ENB_FLAG_YES,
UE_list->eNB_UE_stats[0][UE_id].crnti,//UE_PCCID(eNB_id,UE_id)][UE_id].crnti,
eNB->frame,
eNB->subframe,
eNB_id);
rlc_status = rlc_stat_req(&ctxt,
SRB_FLAG_YES,
DCCH,
&stat_rlc_mode,
&stat_tx_pdcp_sdu,
&stat_tx_pdcp_bytes,
&stat_tx_pdcp_sdu_discarded,
&stat_tx_pdcp_bytes_discarded,
&stat_tx_data_pdu,
&stat_tx_data_bytes,
&stat_tx_retransmit_pdu_by_status,
&stat_tx_retransmit_bytes_by_status,
&stat_tx_retransmit_pdu,
&stat_tx_retransmit_bytes,
&stat_tx_control_pdu,
&stat_tx_control_bytes,
&stat_rx_pdcp_sdu,
&stat_rx_pdcp_bytes,
&stat_rx_data_pdus_duplicate,
&stat_rx_data_bytes_duplicate,
&stat_rx_data_pdu,
&stat_rx_data_bytes,
&stat_rx_data_pdu_dropped,
&stat_rx_data_bytes_dropped,
&stat_rx_data_pdu_out_of_window,
&stat_rx_data_bytes_out_of_window,
&stat_rx_control_pdu,
&stat_rx_control_bytes,
&stat_timer_reordering_timed_out,
&stat_timer_poll_retransmit_timed_out,
&stat_timer_status_prohibit_timed_out);
SRB_FLAG_YES,
DCCH,
&stat_rlc_mode,
&stat_tx_pdcp_sdu,
&stat_tx_pdcp_bytes,
&stat_tx_pdcp_sdu_discarded,
&stat_tx_pdcp_bytes_discarded,
&stat_tx_data_pdu,
&stat_tx_data_bytes,
&stat_tx_retransmit_pdu_by_status,
&stat_tx_retransmit_bytes_by_status,
&stat_tx_retransmit_pdu,
&stat_tx_retransmit_bytes,
&stat_tx_control_pdu,
&stat_tx_control_bytes,
&stat_rx_pdcp_sdu,
&stat_rx_pdcp_bytes,
&stat_rx_data_pdus_duplicate,
&stat_rx_data_bytes_duplicate,
&stat_rx_data_pdu,
&stat_rx_data_bytes,
&stat_rx_data_pdu_dropped,
&stat_rx_data_bytes_dropped,
&stat_rx_data_pdu_out_of_window,
&stat_rx_data_bytes_out_of_window,
&stat_rx_control_pdu,
&stat_rx_control_bytes,
&stat_timer_reordering_timed_out,
&stat_timer_poll_retransmit_timed_out,
&stat_timer_status_prohibit_timed_out);
if (rlc_status == RLC_OP_STATUS_OK) {
len+=sprintf(&buffer[len],"[RLC] DCCH Mode %s, NB_SDU_TO_TX = %d (bytes %d)\tNB_SDU_TO_TX_DISC %d (bytes %d)\n",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_tx_pdcp_sdu,
stat_tx_pdcp_bytes,
stat_tx_pdcp_sdu_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",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_tx_data_pdu,
stat_tx_data_bytes,
stat_tx_control_pdu,
stat_tx_control_bytes,
stat_tx_retransmit_pdu,
stat_tx_retransmit_bytes,
stat_tx_retransmit_pdu_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",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_rx_data_pdu,
stat_rx_data_bytes,
stat_rx_control_pdu,
stat_rx_control_bytes,
stat_rx_data_pdus_duplicate,
stat_rx_data_bytes_duplicate,
stat_rx_data_pdu_dropped,
stat_rx_data_bytes_dropped,
stat_rx_data_pdu_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",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_timer_reordering_timed_out,
stat_timer_poll_retransmit_timed_out,
stat_timer_status_prohibit_timed_out);
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_rx_pdcp_sdu,
stat_rx_pdcp_bytes);
len+=sprintf(&buffer[len],"[RLC] DCCH Mode %s, NB_SDU_TO_TX = %d (bytes %d)\tNB_SDU_TO_TX_DISC %d (bytes %d)\n",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_tx_pdcp_sdu,
stat_tx_pdcp_bytes,
stat_tx_pdcp_sdu_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",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_tx_data_pdu,
stat_tx_data_bytes,
stat_tx_control_pdu,
stat_tx_control_bytes,
stat_tx_retransmit_pdu,
stat_tx_retransmit_bytes,
stat_tx_retransmit_pdu_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",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_rx_data_pdu,
stat_rx_data_bytes,
stat_rx_control_pdu,
stat_rx_control_bytes,
stat_rx_data_pdus_duplicate,
stat_rx_data_bytes_duplicate,
stat_rx_data_pdu_dropped,
stat_rx_data_bytes_dropped,
stat_rx_data_pdu_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",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_timer_reordering_timed_out,
stat_timer_poll_retransmit_timed_out,
stat_timer_status_prohibit_timed_out);
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_rx_pdcp_sdu,
stat_rx_pdcp_bytes);
}
rlc_status = rlc_stat_req(&ctxt,
SRB_FLAG_NO,
DTCH-2, // DRB_IDENTITY
&stat_rlc_mode,
&stat_tx_pdcp_sdu,
&stat_tx_pdcp_bytes,
&stat_tx_pdcp_sdu_discarded,
&stat_tx_pdcp_bytes_discarded,
&stat_tx_data_pdu,
&stat_tx_data_bytes,
&stat_tx_retransmit_pdu_by_status,
&stat_tx_retransmit_bytes_by_status,
&stat_tx_retransmit_pdu,
&stat_tx_retransmit_bytes,
&stat_tx_control_pdu,
&stat_tx_control_bytes,
&stat_rx_pdcp_sdu,
&stat_rx_pdcp_bytes,
&stat_rx_data_pdus_duplicate,
&stat_rx_data_bytes_duplicate,
&stat_rx_data_pdu,
&stat_rx_data_bytes,
&stat_rx_data_pdu_dropped,
&stat_rx_data_bytes_dropped,
&stat_rx_data_pdu_out_of_window,
&stat_rx_data_bytes_out_of_window,
&stat_rx_control_pdu,
&stat_rx_control_bytes,
&stat_timer_reordering_timed_out,
&stat_timer_poll_retransmit_timed_out,
&stat_timer_status_prohibit_timed_out);
SRB_FLAG_NO,
DTCH-2, // DRB_IDENTITY
&stat_rlc_mode,
&stat_tx_pdcp_sdu,
&stat_tx_pdcp_bytes,
&stat_tx_pdcp_sdu_discarded,
&stat_tx_pdcp_bytes_discarded,
&stat_tx_data_pdu,
&stat_tx_data_bytes,
&stat_tx_retransmit_pdu_by_status,
&stat_tx_retransmit_bytes_by_status,
&stat_tx_retransmit_pdu,
&stat_tx_retransmit_bytes,
&stat_tx_control_pdu,
&stat_tx_control_bytes,
&stat_rx_pdcp_sdu,
&stat_rx_pdcp_bytes,
&stat_rx_data_pdus_duplicate,
&stat_rx_data_bytes_duplicate,
&stat_rx_data_pdu,
&stat_rx_data_bytes,
&stat_rx_data_pdu_dropped,
&stat_rx_data_bytes_dropped,
&stat_rx_data_pdu_out_of_window,
&stat_rx_data_bytes_out_of_window,
&stat_rx_control_pdu,
&stat_rx_control_bytes,
&stat_timer_reordering_timed_out,
&stat_timer_poll_retransmit_timed_out,
&stat_timer_status_prohibit_timed_out);
if (rlc_status == RLC_OP_STATUS_OK) {
len+=sprintf(&buffer[len],"[RLC] DTCH Mode %s, NB_SDU_TO_TX = %d (bytes %d)\tNB_SDU_TO_TX_DISC %d (bytes %d)\n",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_tx_pdcp_sdu,
stat_tx_pdcp_bytes,
stat_tx_pdcp_sdu_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",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_tx_data_pdu,
stat_tx_data_bytes,
stat_tx_control_pdu,
stat_tx_control_bytes,
stat_tx_retransmit_pdu,
stat_tx_retransmit_bytes,
stat_tx_retransmit_pdu_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",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_rx_data_pdu,
stat_rx_data_bytes,
stat_rx_control_pdu,
stat_rx_control_bytes,
stat_rx_data_pdus_duplicate,
stat_rx_data_bytes_duplicate,
stat_rx_data_pdu_dropped,
stat_rx_data_bytes_dropped,
stat_rx_data_pdu_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",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_timer_reordering_timed_out,
stat_timer_poll_retransmit_timed_out,
stat_timer_status_prohibit_timed_out);
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_rx_pdcp_sdu,
stat_rx_pdcp_bytes);
}
len+=sprintf(&buffer[len],"[RLC] DTCH Mode %s, NB_SDU_TO_TX = %d (bytes %d)\tNB_SDU_TO_TX_DISC %d (bytes %d)\n",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_tx_pdcp_sdu,
stat_tx_pdcp_bytes,
stat_tx_pdcp_sdu_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",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_tx_data_pdu,
stat_tx_data_bytes,
stat_tx_control_pdu,
stat_tx_control_bytes,
stat_tx_retransmit_pdu,
stat_tx_retransmit_bytes,
stat_tx_retransmit_pdu_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",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_rx_data_pdu,
stat_rx_data_bytes,
stat_rx_control_pdu,
stat_rx_control_bytes,
stat_rx_data_pdus_duplicate,
stat_rx_data_bytes_duplicate,
stat_rx_data_pdu_dropped,
stat_rx_data_bytes_dropped,
stat_rx_data_pdu_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",
(stat_rlc_mode==RLC_MODE_AM)? "AM": (stat_rlc_mode==RLC_MODE_UM)?"UM":"NONE",
stat_timer_reordering_timed_out,
stat_timer_poll_retransmit_timed_out,
stat_timer_status_prohibit_timed_out);
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_rx_pdcp_sdu,
stat_rx_pdcp_bytes);
}
}
}
return len + 1 /* SR: for trailing \0 */;
}
#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;
unsigned int i,j,k,kk;
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)
// if (mac_xface->is_cluster_head == 0) {
for (k=0; k<NB_INST; k++) {
if (Mac_rlc_xface->Is_cluster_head[k] == 0) {
#ifndef PHY_EMUL_ONE_MACHINE
Mod_id=k-NB_CH_INST;
len+=sprintf(&buffer[len],"UE TTI: %d\n",Mac_rlc_xface->frame);
for (CH_index = 0; CH_index<NB_CNX_UE; CH_index++) {
if (UE_mac_inst[Mod_id].Dcch_lchan[CH_index].Active==1) {
len+=sprintf(&buffer[len],"CH %d: Wideband SINR %d dB---\n",
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)
}
len+=sprintf(&buffer[len],"\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.NB_RX,
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",
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_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",
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,
......@@ -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],
(10*Pdcp_stats_rx_rate[k][CH_index][i])>>5,
Sign*(10*Overhead)>>5);
int status = rlc_stat_req (k,
UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.Lchan_id.Index,
&tx_pdcp_sdu,
......@@ -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]);
len+=sprintf(&buffer[len],"\n");
}
}
}
}
#endif //PHY_EMUL_ONE_MACHINE
} else if(Mac_rlc_xface->Is_cluster_head[k] ==1) {
Mod_id=k;
len+=sprintf(&buffer[len],
"-------------------------------------------------------------------CH %d: TTI: %d------------------------------------------------------------------\n",
......@@ -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],
CH_mac_inst[Mod_id].Def_meas[i].Wideband_sinr,
print_cqi(CH_mac_inst[Mod_id].Def_meas[i].cqi));
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",
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)
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.NB_BW_REQ_RX);
/*
len+=sprintf(&buffer[len]," TX per TB: ");
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)
}
}
}
}
}
......
......@@ -61,8 +61,7 @@ extern RAN_CONTEXT_t RC;
static int gtpv1u_dump_socket_g;
//-----------------------------------------------------------------------------
int gtpv1u_eNB_create_dump_socket(void)
{
int gtpv1u_eNB_create_dump_socket(void) {
struct ifreq ifr;
int hdrincl=1;
......@@ -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;
memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
......@@ -108,12 +106,10 @@ static void gtpv1u_eNB_write_dump_socket(uint8_t *buffer_pP, uint32_t buffer_len
#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
MessageDef *message_p;
struct in_addr addr={0};
struct in_addr addr= {0};
message_p = itti_alloc_new_message(TASK_GTPV1_U, UDP_INIT);
if (message_p == NULL) {
......@@ -124,21 +120,20 @@ static int gtpv1u_eNB_send_init_udp(const Gtpv1uS1Req * req)
addr.s_addr = req->enb_ip_address_for_S1u_S12_S4_up;
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);
MSC_LOG_EVENT(
MSC_GTPU_ENB,
"0 UDP bind %s:%u",
UDP_INIT(message_p).address,
UDP_INIT(message_p).port);
MSC_GTPU_ENB,
"0 UDP bind %s:%u",
UDP_INIT(message_p).address,
UDP_INIT(message_p).port);
return itti_send_msg_to_task(TASK_UDP, INSTANCE_DEFAULT, message_p);
}
static int gtpv1u_s1_req(
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,
&req->enb_ip_address_for_S1u_S12_S4_up,
sizeof (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));
gtpv1u_eNB_send_init_udp(req);
return 0;
}
......@@ -148,8 +143,7 @@ NwGtpv1uRcT gtpv1u_eNB_log_request(NwGtpv1uLogMgrHandleT hLogMgr,
uint32_t logLevel,
NwCharT *file,
uint32_t line,
NwCharT *logStr)
{
NwCharT *logStr) {
LOG_D(GTPU, "%s\n", logStr);
return NW_GTPV1U_OK;
}
......@@ -161,12 +155,10 @@ NwGtpv1uRcT gtpv1u_eNB_send_udp_msg(
uint32_t buffer_len,
uint32_t buffer_offset,
uint32_t peerIpAddr,
uint16_t peerPort)
{
uint16_t peerPort) {
// Create and alloc new message
MessageDef *message_p = NULL;
udp_data_req_t *udp_data_req_p = NULL;
message_p = itti_alloc_new_message(TASK_GTPV1_U, UDP_DATA_REQ);
if (message_p) {
......@@ -190,8 +182,7 @@ NwGtpv1uRcT gtpv1u_eNB_send_udp_msg(
/* Callback called when a gtpv1u message arrived on UDP interface */
NwGtpv1uRcT gtpv1u_eNB_process_stack_req(
NwGtpv1uUlpHandleT hUlp,
NwGtpv1uUlpApiT *pUlpApi)
{
NwGtpv1uUlpApiT *pUlpApi) {
boolean_t result = FALSE;
teid_t teid = 0;
hashtable_rc_t hash_rc = HASH_TABLE_KEY_NOT_EXISTS;
......@@ -204,94 +195,88 @@ NwGtpv1uRcT gtpv1u_eNB_process_stack_req(
* - T-PDU
* - END-MARKER
*/
case NW_GTPV1U_ULP_API_RECV_TPDU: {
uint8_t buffer[4096];
uint32_t buffer_len;
/* Nw-gptv1u stack has processed a PDU. we can schedule it to PDCP
* for transmission.
*/
teid = pUlpApi->apiInfo.recvMsgInfo.teid;
if (NW_GTPV1U_OK != nwGtpv1uMsgGetTpdu(pUlpApi->apiInfo.recvMsgInfo.hMsg,
buffer, &buffer_len)) {
LOG_E(GTPU, "Error while retrieving T-PDU");
}
case NW_GTPV1U_ULP_API_RECV_TPDU: {
uint8_t buffer[4096];
uint32_t buffer_len;
/* Nw-gptv1u stack has processed a PDU. we can schedule it to PDCP
* for transmission.
*/
teid = pUlpApi->apiInfo.recvMsgInfo.teid;
if (NW_GTPV1U_OK != nwGtpv1uMsgGetTpdu(pUlpApi->apiInfo.recvMsgInfo.hMsg,
buffer, &buffer_len)) {
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
gtpv1u_eNB_write_dump_socket(buffer,buffer_len);
gtpv1u_eNB_write_dump_socket(buffer,buffer_len);
#endif
rc = nwGtpv1uMsgDelete(RC.gtpv1u_data_g->gtpv1u_stack,
pUlpApi->apiInfo.recvMsgInfo.hMsg);
rc = nwGtpv1uMsgDelete(RC.gtpv1u_data_g->gtpv1u_stack,
pUlpApi->apiInfo.recvMsgInfo.hMsg);
if (rc != NW_GTPV1U_OK) {
LOG_E(GTPU, "nwGtpv1uMsgDelete failed: 0x%x\n", rc);
}
if (rc != NW_GTPV1U_OK) {
LOG_E(GTPU, "nwGtpv1uMsgDelete failed: 0x%x\n", rc);
}
//-----------------------
// GTPV1U->PDCP mapping
//-----------------------
hash_rc = hashtable_get(RC.gtpv1u_data_g->teid_mapping, teid, (void**)&gtpv1u_teid_data_p);
//-----------------------
// GTPV1U->PDCP mapping
//-----------------------
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
LOG_D(GTPU, "Received T-PDU from gtpv1u stack teid %u size %d -> enb module id %u ue module id %u rab id %u\n",
teid,
buffer_len,
gtpv1u_teid_data_p->enb_id,
gtpv1u_teid_data_p->ue_id,
gtpv1u_teid_data_p->eps_bearer_id);
LOG_D(GTPU, "Received T-PDU from gtpv1u stack teid %u size %d -> enb module id %u ue module id %u rab id %u\n",
teid,
buffer_len,
gtpv1u_teid_data_p->enb_id,
gtpv1u_teid_data_p->ue_id,
gtpv1u_teid_data_p->eps_bearer_id);
#endif
//#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);
MSC_LOG_TX_MESSAGE(
MSC_GTPU_ENB,
MSC_PDCP_ENB,
NULL,0,
MSC_AS_TIME_FMT" DATA-REQ rb %u size %u",
0,0,
(gtpv1u_teid_data_p->eps_bearer_id) ? gtpv1u_teid_data_p->eps_bearer_id - 4: 5-4,
buffer_len);
result = pdcp_data_req(
&ctxt,
SRB_FLAG_NO,
(gtpv1u_teid_data_p->eps_bearer_id) ? gtpv1u_teid_data_p->eps_bearer_id - 4: 5-4,
0, // mui
SDU_CONFIRM_NO, // confirm
buffer_len,
buffer,
PDCP_TRANSMISSION_MODE_DATA
//#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);
MSC_LOG_TX_MESSAGE(
MSC_GTPU_ENB,
MSC_PDCP_ENB,
NULL,0,
MSC_AS_TIME_FMT" DATA-REQ rb %u size %u",
0,0,
(gtpv1u_teid_data_p->eps_bearer_id) ? gtpv1u_teid_data_p->eps_bearer_id - 4: 5-4,
buffer_len);
result = pdcp_data_req(
&ctxt,
SRB_FLAG_NO,
(gtpv1u_teid_data_p->eps_bearer_id) ? gtpv1u_teid_data_p->eps_bearer_id - 4: 5-4,
0, // mui
SDU_CONFIRM_NO, // confirm
buffer_len,
buffer,
PDCP_TRANSMISSION_MODE_DATA
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
,NULL, NULL
,NULL, NULL
#endif
);
if ( result == FALSE ) {
if (ctxt.configured == FALSE )
LOG_W(GTPU, "PDCP data request failed, cause: RB is not configured!\n") ;
else
LOG_W(GTPU, "PDCP data request failed\n");
return NW_GTPV1U_FAILURE;
);
if ( result == FALSE ) {
if (ctxt.configured == FALSE )
LOG_W(GTPU, "PDCP data request failed, cause: RB is not configured!\n") ;
else
LOG_W(GTPU, "PDCP data request failed\n");
return NW_GTPV1U_FAILURE;
}
} else {
LOG_W(GTPU, "Received T-PDU from gtpv1u stack teid %u unknown size %u", teid, buffer_len);
}
} else {
LOG_W(GTPU, "Received T-PDU from gtpv1u stack teid %u unknown size %u", teid, buffer_len);
}
}
break;
default: {
LOG_E(GTPU, "Received undefined UlpApi (%02x) from gtpv1u stack!\n",
pUlpApi->apiType);
}
} // end of switch
default: {
LOG_E(GTPU, "Received undefined UlpApi (%02x) from gtpv1u stack!\n",
pUlpApi->apiType);
}
} // end of switch
return NW_GTPV1U_OK;
}
......@@ -301,8 +286,7 @@ int data_recv_callback(uint16_t portP,
uint32_t address,
uint8_t *buffer,
uint32_t length,
void *arg_p)
{
void *arg_p) {
gtpv1u_data_t *gtpv1u_data_p;
if (arg_p == NULL) {
......@@ -310,7 +294,6 @@ int data_recv_callback(uint16_t portP,
}
gtpv1u_data_p = (gtpv1u_data_t *)arg_p;
return nwGtpv1uProcessUdpReq(gtpv1u_data_p->gtpv1u_stack,
buffer,
length,
......@@ -421,9 +404,7 @@ static NwGtpv1uRcT gtpv1u_start_timer_wrapper(
uint32_t timeoutUsec,
uint32_t tmrType,
void *timeoutArg,
NwGtpv1uTimerHandleT *hTmr)
{
NwGtpv1uTimerHandleT *hTmr) {
NwGtpv1uRcT rc = NW_GTPV1U_OK;
long timer_id;
......@@ -453,11 +434,8 @@ static NwGtpv1uRcT gtpv1u_start_timer_wrapper(
static NwGtpv1uRcT
gtpv1u_stop_timer_wrapper(
NwGtpv1uTimerMgrHandleT tmrMgrHandle,
NwGtpv1uTimerHandleT hTmr)
{
NwGtpv1uTimerHandleT hTmr) {
NwGtpv1uRcT rc = NW_GTPV1U_OK;
return rc;
}
......@@ -468,18 +446,14 @@ gtpv1u_initial_req(
gtpv1u_data_t *gtpv1u_data_pP,
teid_t teidP,
tcp_udp_port_t portP,
uint32_t address)
{
uint32_t address) {
NwGtpv1uUlpApiT ulp_req;
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
memset(&ulp_req, 0, sizeof(NwGtpv1uUlpApiT));
ulp_req.apiType = NW_GTPV1U_ULP_API_INITIAL_REQ;
ulp_req.apiInfo.initialReqInfo.teid = teidP;
ulp_req.apiInfo.initialReqInfo.peerPort = portP;
ulp_req.apiInfo.initialReqInfo.peerIp = address;
rc = nwGtpv1uProcessUlpReq(gtpv1u_data_pP->gtpv1u_stack, &ulp_req);
if (rc == NW_GTPV1U_OK) {
......@@ -500,9 +474,7 @@ gtpv1u_new_data_req(
uint8_t *buffer_pP,
uint32_t buf_lenP,
uint32_t buf_offsetP
)
{
) {
NwGtpv1uUlpApiT stack_req;
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
struct gtpv1u_ue_data_s ue;
......@@ -510,17 +482,14 @@ gtpv1u_new_data_req(
struct gtpv1u_bearer_s *bearer_p = NULL;
hashtable_rc_t hash_rc = HASH_TABLE_KEY_NOT_EXISTS;;
gtpv1u_data_t *gtpv1u_data_p = NULL;
memset(&ue, 0, sizeof(struct gtpv1u_ue_data_s));
ue.ue_id = ue_rntiP;
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) >= 0 , "Bad parameter rab id %u\n", rab_idP);
gtpv1u_data_p = RC.gtpv1u_data_g;
/* 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 ) {
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(
if (bearer_p->state != BEARER_UP) {
LOG_W(GTPU, "Trying to send data over bearer with state(%u) != BEARER_UP\n",
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)
return -1;
}
memset(&stack_req, 0, sizeof(NwGtpv1uUlpApiT));
stack_req.apiType = NW_GTPV1U_ULP_API_SEND_TPDU;
stack_req.apiInfo.sendtoInfo.teid = bearer_p->teid_sgw;
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);
rc = nwGtpv1uGpduMsgNew(gtpv1u_data_p->gtpv1u_stack,
bearer_p->teid_sgw,
......@@ -587,10 +554,9 @@ gtpv1u_new_data_req(
int
gtpv1u_create_s1u_tunnel(
const instance_t instanceP,
const gtpv1u_enb_create_tunnel_req_t * const create_tunnel_req_pP,
gtpv1u_enb_create_tunnel_resp_t * const create_tunnel_resp_pP
)
{
const gtpv1u_enb_create_tunnel_req_t *const create_tunnel_req_pP,
gtpv1u_enb_create_tunnel_resp_t *const create_tunnel_resp_pP
) {
/* Create a new nw-gtpv1-u stack req using API */
NwGtpv1uUlpApiT stack_req;
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
......@@ -606,17 +572,14 @@ gtpv1u_create_s1u_tunnel(
int ip_offset = 0;
in_addr_t in_addr;
int addrs_length_in_bytes= 0;
MSC_LOG_RX_MESSAGE(
MSC_GTPU_ENB,
MSC_RRC_ENB,
NULL,0,
MSC_AS_TIME_FMT" CREATE_TUNNEL_REQ RNTI %"PRIx16" inst %u ntuns %u ebid %u sgw-s1u teid %u",
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->sgw_S1u_teid[0]);
MSC_GTPU_ENB,
MSC_RRC_ENB,
NULL,0,
MSC_AS_TIME_FMT" CREATE_TUNNEL_REQ RNTI %"PRIx16" inst %u ntuns %u ebid %u sgw-s1u teid %u",
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->sgw_S1u_teid[0]);
create_tunnel_resp_pP->rnti = create_tunnel_req_pP->rnti;
create_tunnel_resp_pP->status = 0;
create_tunnel_resp_pP->num_tunnels = 0;
......@@ -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",
create_tunnel_req_pP->rnti, eps_bearer_id);
memset(&stack_req, 0, sizeof(NwGtpv1uUlpApiT));
stack_req.apiType = NW_GTPV1U_ULP_API_CREATE_TUNNEL_ENDPOINT;
do {
......@@ -636,7 +598,6 @@ gtpv1u_create_s1u_tunnel(
stack_req.apiInfo.createTunnelEndPointInfo.teid = s1u_teid;
stack_req.apiInfo.createTunnelEndPointInfo.hUlpSession = 0;
stack_req.apiInfo.createTunnelEndPointInfo.hStackSession = 0;
rc = nwGtpv1uProcessUlpReq(RC.gtpv1u_data_g->gtpv1u_stack, &stack_req);
LOG_D(GTPU, ".\n");
} while (rc != NW_GTPV1U_OK);
......@@ -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);
if ((hash_rc == HASH_TABLE_KEY_NOT_EXISTS) || (hash_rc == HASH_TABLE_OK)) {
if (hash_rc == HASH_TABLE_KEY_NOT_EXISTS) {
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);
......@@ -660,7 +620,6 @@ gtpv1u_create_s1u_tunnel(
&RC.gtpv1u_data_g->enb_ip_address_for_S1u_S12_S4_up,
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;
AssertFatal((addrs_length_in_bytes == 4) ||
(addrs_length_in_bytes == 16) ||
......@@ -670,7 +629,7 @@ gtpv1u_create_s1u_tunnel(
if ((addrs_length_in_bytes == 4) ||
(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;
gtpv1u_ue_data_p->bearers[eps_bearer_id - GTPV1U_BEARER_OFFSET].sgw_ip_addr = in_addr;
}
......@@ -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->num_bearers++;
create_tunnel_resp_pP->enb_S1u_teid[i] = s1u_teid;
} else {
create_tunnel_resp_pP->enb_S1u_teid[i] = 0;
create_tunnel_resp_pP->status = 0xFF;
......@@ -696,11 +654,10 @@ gtpv1u_create_s1u_tunnel(
create_tunnel_resp_pP->eps_bearer_id[i] = eps_bearer_id;
create_tunnel_resp_pP->num_tunnels += 1;
//-----------------------
// 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) {
gtpv1u_teid_data_p = calloc (1, sizeof(gtpv1u_teid_data_t));
......@@ -714,14 +671,14 @@ gtpv1u_create_s1u_tunnel(
create_tunnel_resp_pP->status = 0xFF;
}
}
MSC_LOG_TX_MESSAGE(
MSC_GTPU_ENB,
MSC_RRC_ENB,
NULL,0,
"0 GTPV1U_ENB_CREATE_TUNNEL_RESP rnti %x teid %x",
create_tunnel_resp_pP->rnti,
s1u_teid);
MSC_LOG_TX_MESSAGE(
MSC_GTPU_ENB,
MSC_RRC_ENB,
NULL,0,
"0 GTPV1U_ENB_CREATE_TUNNEL_RESP rnti %x teid %x",
create_tunnel_resp_pP->rnti,
s1u_teid);
LOG_D(GTPU, "Tx GTPV1U_ENB_CREATE_TUNNEL_RESP ue rnti %x status %d\n",
create_tunnel_req_pP->rnti,
create_tunnel_resp_pP->status);
......@@ -729,12 +686,10 @@ gtpv1u_create_s1u_tunnel(
}
int gtpv1u_update_s1u_tunnel(
const instance_t instanceP,
const gtpv1u_enb_create_tunnel_req_t * const create_tunnel_req_pP,
const rnti_t prior_rnti
)
{
const instance_t instanceP,
const gtpv1u_enb_create_tunnel_req_t *const create_tunnel_req_pP,
const rnti_t prior_rnti
) {
/* Local tunnel end-point identifier */
teid_t s1u_teid = 0;
gtpv1u_teid_data_t *gtpv1u_teid_data_p = NULL;
......@@ -744,12 +699,12 @@ int gtpv1u_update_s1u_tunnel(
hashtable_rc_t hash_rc = HASH_TABLE_KEY_NOT_EXISTS;
int i,j;
uint8_t bearers_num = 0,bearers_total = 0;
//-----------------------
// PDCP->GTPV1U mapping
//-----------------------
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);
return -1;
}
......@@ -757,65 +712,66 @@ int gtpv1u_update_s1u_tunnel(
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));
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);
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",
create_tunnel_req_pP->rnti);
create_tunnel_req_pP->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",
prior_rnti);
prior_rnti);
//-----------------------
// GTPV1U->PDCP mapping
//-----------------------
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)
continue;
bearers_num++;
for (i = 0; i < create_tunnel_req_pP->num_tunnels; i++) {
if(j == (create_tunnel_req_pP->eps_bearer_id[i]-GTPV1U_BEARER_OFFSET))
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;
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) {
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];
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);
}else{
} else {
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;
hash_rc = hashtable_remove(RC.gtpv1u_data_g->teid_mapping, s1u_teid);
if (hash_rc != HASH_TABLE_OK) {
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->num_bearers--;
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);;
}
if(bearers_num > bearers_total)
break;
}
return 0;
return 0;
}
//-----------------------------------------------------------------------------
static int gtpv1u_delete_s1u_tunnel(
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;
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
MessageDef *message_p = NULL;
......@@ -823,22 +779,16 @@ static int gtpv1u_delete_s1u_tunnel(
hashtable_rc_t hash_rc = HASH_TABLE_KEY_NOT_EXISTS;
teid_t teid_eNB = 0;
int erab_index = 0;
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).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) {
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;
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]);
{
memset(&stack_req, 0, sizeof(NwGtpv1uUlpApiT));
stack_req.apiType = NW_GTPV1U_ULP_API_DESTROY_TUNNEL_ENDPOINT;
......@@ -846,7 +796,6 @@ static int gtpv1u_delete_s1u_tunnel(
req_pP->eps_bearer_id[erab_index],
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;
rc = nwGtpv1uProcessUlpReq(RC.gtpv1u_data_g->gtpv1u_stack, &stack_req);
LOG_D(GTPU, ".\n");
}
......@@ -881,36 +830,30 @@ static int gtpv1u_delete_s1u_tunnel(
}
}// else silently do nothing
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).enb_S1u_teid,
GTPV1U_ENB_DELETE_TUNNEL_RESP(message_p).status);
MSC_LOG_TX_MESSAGE(
MSC_GTPU_ENB,
MSC_RRC_ENB,
NULL,0,
"0 GTPV1U_ENB_DELETE_TUNNEL_RESP rnti %x teid %x",
GTPV1U_ENB_DELETE_TUNNEL_RESP(message_p).rnti,
teid_eNB);
MSC_GTPU_ENB,
MSC_RRC_ENB,
NULL,0,
"0 GTPV1U_ENB_DELETE_TUNNEL_RESP rnti %x teid %x",
GTPV1U_ENB_DELETE_TUNNEL_RESP(message_p).rnti,
teid_eNB);
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;
NwGtpv1uUlpEntityT ulp;
NwGtpv1uUdpEntityT udp;
NwGtpv1uLogMgrEntityT log;
NwGtpv1uTimerMgrEntityT tmr;
// 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);
//gtpv1u_data_g.gtpv1u_stack;
/* Initialize UE hashtable */
......@@ -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);
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");
// 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;
RC.gtpv1u_data_g->seq_num = 0;
RC.gtpv1u_data_g->restart_counter = 0;
......@@ -936,7 +878,6 @@ int gtpv1u_eNB_init(void)
return -1;
}
/* Set the ULP API callback. Called once message have been processed by the
* nw-gtpv1u stack.
*/
......@@ -983,30 +924,26 @@ int gtpv1u_eNB_init(void)
}
#endif
LOG_D(GTPU, "Initializing GTPV1U interface for eNB: DONE\n");
return 0;
}
//-----------------------------------------------------------------------------
void *gtpv1u_eNB_process_itti_msg(void *notUsed) {
/* Trying to fetch a message from the message queue.
* If the queue is empty, this function will block till a
* message is sent to the task.
*/
instance_t instance;
MessageDef *received_message_p = NULL;
int rc = 0;
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);
DevAssert(received_message_p != NULL);
instance = ITTI_MSG_INSTANCE(received_message_p);
//msg_name_p = ITTI_MSG_NAME(received_message_p);
switch (ITTI_MSG_ID(received_message_p)) {
/* Trying to fetch a message from the message queue.
* If the queue is empty, this function will block till a
* message is sent to the task.
*/
instance_t instance;
MessageDef *received_message_p = NULL;
int rc = 0;
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);
DevAssert(received_message_p != NULL);
instance = ITTI_MSG_INSTANCE(received_message_p);
//msg_name_p = ITTI_MSG_NAME(received_message_p);
switch (ITTI_MSG_ID(received_message_p)) {
case GTPV1U_ENB_S1_REQ:
gtpv1u_s1_req(instance, &received_message_p->ittiMsg.gtpv1uS1Req);
......@@ -1037,17 +974,14 @@ void *gtpv1u_eNB_process_itti_msg(void *notUsed) {
gtpv1u_ue_data_t *gtpv1u_ue_data_p = NULL;
teid_t enb_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);
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);
#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);
#endif
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) {
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) {
stack_req.apiType = NW_GTPV1U_ULP_API_SEND_TPDU;
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;
rc = nwGtpv1uGpduMsgNew(
RC.gtpv1u_data_g->gtpv1u_stack,
sgw_s1u_teid,
......@@ -1072,7 +1005,7 @@ void *gtpv1u_eNB_process_itti_msg(void *notUsed) {
if (rc != NW_GTPV1U_OK) {
LOG_E(GTPU, "nwGtpv1uGpduMsgNew failed: 0x%x\n", rc);
MSC_LOG_EVENT(MSC_GTPU_ENB,"0 Failed send G-PDU ltid %u rtid %u size %u",
enb_s1u_teid,sgw_s1u_teid,data_req_p->length);
enb_s1u_teid,sgw_s1u_teid,data_req_p->length);
(void)enb_s1u_teid; /* avoid gcc warning "set but not used" */
} else {
rc = nwGtpv1uProcessUlpReq(RC.gtpv1u_data_g->gtpv1u_stack, &stack_req);
......@@ -1080,19 +1013,18 @@ void *gtpv1u_eNB_process_itti_msg(void *notUsed) {
if (rc != NW_GTPV1U_OK) {
LOG_E(GTPU, "nwGtpv1uProcessUlpReq failed: 0x%x\n", rc);
MSC_LOG_EVENT(MSC_GTPU_ENB,"0 Failed send G-PDU ltid %u rtid %u size %u",
enb_s1u_teid,sgw_s1u_teid,data_req_p->length);
enb_s1u_teid,sgw_s1u_teid,data_req_p->length);
} else {
MSC_LOG_TX_MESSAGE(
MSC_GTPU_ENB,
MSC_GTPU_SGW,
NULL,
0,
MSC_AS_TIME_FMT" G-PDU ltid %u rtid %u size %u",
0,0,
enb_s1u_teid,
sgw_s1u_teid,
data_req_p->length);
MSC_LOG_TX_MESSAGE(
MSC_GTPU_ENB,
MSC_GTPU_SGW,
NULL,
0,
MSC_AS_TIME_FMT" G-PDU ltid %u rtid %u size %u",
0,0,
enb_s1u_teid,
sgw_s1u_teid,
data_req_p->length);
}
rc = nwGtpv1uMsgDelete(RC.gtpv1u_data_g->gtpv1u_stack,
......@@ -1113,11 +1045,11 @@ void *gtpv1u_eNB_process_itti_msg(void *notUsed) {
case TERMINATE_MESSAGE: {
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) {
hashtable_destroy (RC.gtpv1u_data_g->teid_mapping);
hashtable_destroy (&(RC.gtpv1u_data_g->teid_mapping));
}
LOG_W(GTPU, " *** Exiting GTPU thread\n");
......@@ -1135,21 +1067,18 @@ void *gtpv1u_eNB_process_itti_msg(void *notUsed) {
ITTI_MSG_NAME(received_message_p));
}
break;
}
rc = itti_free(ITTI_MSG_ORIGIN_ID(received_message_p), received_message_p);
AssertFatal(rc == EXIT_SUCCESS, "Failed to free memory (%d)!\n", rc);
received_message_p = NULL;
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GTPV1U_ENB_TASK, VCD_FUNCTION_OUT);
}
return NULL;
rc = itti_free(ITTI_MSG_ORIGIN_ID(received_message_p), received_message_p);
AssertFatal(rc == EXIT_SUCCESS, "Failed to free memory (%d)!\n", rc);
received_message_p = NULL;
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GTPV1U_ENB_TASK, VCD_FUNCTION_OUT);
return NULL;
}
//-----------------------------------------------------------------------------
void *gtpv1u_eNB_task(void *args)
{
void *gtpv1u_eNB_task(void *args) {
int rc = 0;
rc = gtpv1u_eNB_init();
AssertFatal(rc == 0, "gtpv1u_eNB_init Failed");
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